package com.ruoyi.web.controller.zdsz;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
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.page.TableDataInfo;
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.bo.ZEngineeringAirWallBo;
import com.ruoyi.zdsz.domain.vo.ZEngineeringAirWallVo;
import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryTypeVo;
import com.ruoyi.zdsz.domain.vo.ZEngineeringIndustryVo;
import com.ruoyi.zdsz.service.IZEngineeringAirWallService;
import com.ruoyi.zdsz.service.IZEngineeringIndustryService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 带气封堵施工
 *
 * @author ruoyi
 * @date 2024-01-02
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zdsz/engineeringAirWall")
public class ZEngineeringAirWallController extends BaseController {

    private final IZEngineeringAirWallService iZEngineeringAirWallService;

    /**
     * 查询,带气封堵施工列表
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:list")
    @GetMapping("/list")
    public TableDataInfo<ZEngineeringAirWallVo> list(ZEngineeringAirWallBo bo, PageQuery pageQuery, String enginType) {
//        bo.setType(type);
        bo.setEnginType(enginType);
        System.out.println("enginType==="+enginType);
        return iZEngineeringAirWallService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出,带气封堵施工列表
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:export")
    @Log(title = ",带气封堵施工", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZEngineeringAirWallBo bo, HttpServletResponse response) {
        List<ZEngineeringAirWallVo> list = iZEngineeringAirWallService.queryList(bo);
        ExcelUtil.exportExcel(list, "带气封堵施工", ZEngineeringAirWallVo.class, response);
    }

    /**
     * 获取,带气封堵施工详细信息
     *
     * @param id 主键
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:query")
    @GetMapping("/{id}")
    public R<ZEngineeringAirWallVo> getInfo(@NotNull(message = "主键不能为空")@PathVariable String id) {
        return R.ok(iZEngineeringAirWallService.queryById(id));
    }

    /**
     * 新增,带气封堵施工
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:add")
    @Log(title = ",带气封堵施工", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZEngineeringAirWallBo bo) {
        return toAjax(iZEngineeringAirWallService.insertByBo(bo));
    }

    /**
     * 修改,带气封堵施工
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:edit")
    @Log(title = ",带气封堵施工", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZEngineeringAirWallBo bo) {
        return toAjax(iZEngineeringAirWallService.updateByBo(bo));
    }

    /**
     * 删除,带气封堵施工
     *
     * @param ids 主键串
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:remove")
    @Log(title = ",带气封堵施工", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")@PathVariable String[] ids) {
        return toAjax(iZEngineeringAirWallService.deleteWithValidByIds(Arrays.asList(ids), true));
    }

    /**
     * ,带气封堵施工历史
     *
     */
//    @SaCheckPermission("zdsz:engineeringIndustry:query")
    @GetMapping("/{id}/{type}")
    public R<ZEngineeringAirWallVo> query(@NotNull(message = "主键不能为空") @PathVariable String id, @PathVariable String type) {
//        return R.ok(iZEngineeringAirWallService.query(id, type));
        return R.ok(iZEngineeringAirWallService.query(id, "带气封堵施工"));
    }

    /**
     * ,带气封堵施工根据工程类型查询工程名称
     */
    @GetMapping("/queryNameByType")
//    @SaCheckPermission("zdsz:engineeringIndustry:type")
    public R<List<ZEngineeringIndustryTypeVo>> queryNameByType(ZEngineeringAirWallBo bo) {
        return R.ok(iZEngineeringAirWallService.queryNameByType(bo));
    }

    /**
     * ,带气封堵施工修改工程
     */
    @PutMapping("/updateNodeByBo")
    @Log(title = ",带气封堵施工", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
//    @SaCheckPermission("zdsz:engineeringIndustry:removeNode")
    public R<Void> updateNodeByBo(@Validated(EditGroup.class) @RequestBody ZEngineeringAirWallBo bo) {
        return toAjax(iZEngineeringAirWallService.updateNodeByBo(bo));
    }

}
