package com.ruoyi.web.controller.zdsz;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryVo;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zdsz.domain.vo.ZTouchOperationEngineeringVo;
import com.ruoyi.zdsz.domain.bo.ZTouchOperationEngineeringBo;
import com.ruoyi.zdsz.service.IZTouchOperationEngineeringService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 碰口作业
 *
 * @author ruoyi
 * @date 2024-06-12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zdsz/touchOperationEngineering")
public class ZTouchOperationEngineeringController extends BaseController {

    private final IZTouchOperationEngineeringService iZTouchOperationEngineeringService;

    /**
     * 查询碰口作业列表
     */
    @GetMapping("/list")
    public TableDataInfo<ZTouchOperationEngineeringVo> list(ZTouchOperationEngineeringBo bo, PageQuery pageQuery) {
        return iZTouchOperationEngineeringService.queryPageList(bo, pageQuery);
    }


    @GetMapping("query/{id}/{type}")
    public R<ZTouchOperationEngineeringVo> querys(@NotNull(message = "主键不能为空") @PathVariable Long id,@NotNull(message = "环节不能为空") @PathVariable String type) {
        return R.ok(iZTouchOperationEngineeringService.query(id, type));
    }
    /**
     * 导出碰口作业列表
     */
    @Log(title = "碰口作业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZTouchOperationEngineeringBo bo, HttpServletResponse response) {
        List<ZTouchOperationEngineeringVo> list = iZTouchOperationEngineeringService.queryList(bo);
        ExcelUtil.exportExcel(list, "碰口作业", ZTouchOperationEngineeringVo.class, response);
    }

    /**
     * 获取碰口作业详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<ZTouchOperationEngineeringVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iZTouchOperationEngineeringService.queryById(id));
    }

    /**
     * 新增碰口作业
     */
    @Log(title = "碰口作业", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZTouchOperationEngineeringBo bo) {
        return toAjax(iZTouchOperationEngineeringService.insertByBo(bo));
    }

    /**
     * 修改碰口作业
     */
    @Log(title = "碰口作业", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZTouchOperationEngineeringBo bo) {
        return toAjax(iZTouchOperationEngineeringService.updateByBo(bo));
    }

    /**
     * 删除碰口作业
     *
     * @param ids 主键串
     */
    @Log(title = "碰口作业", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iZTouchOperationEngineeringService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
