package com.ruoyi.web.controller.zdsz;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.dtflys.forest.annotation.GetRequest;
import com.ruoyi.zdsz.domain.bo.ZEngineeringNodeBo;
import com.ruoyi.zdsz.service.IZEngineeringNodeService;
import lombok.RequiredArgsConstructor;

import javax.annotation.Resource;
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.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zdsz.domain.vo.ZEngineeringReviewVo;
import com.ruoyi.zdsz.domain.bo.ZEngineeringReviewBo;
import com.ruoyi.zdsz.service.IZEngineeringReviewService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工程审核
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zdsz/engineeringReview")
public class ZEngineeringReviewController extends BaseController {

    private final IZEngineeringReviewService iZEngineeringReviewService;
   @Resource
    private IZEngineeringNodeService izEngineeringNodeService;

    /**
     * 查询工程审核列表
     */
//    @SaCheckPermission("zdsz:engineeringReview:list")
    @GetMapping("/list")
    public TableDataInfo<ZEngineeringReviewVo> list(ZEngineeringReviewBo bo, PageQuery pageQuery) {
        return iZEngineeringReviewService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出工程审核列表
     */
//    @SaCheckPermission("zdsz:engineeringReview:export")
    @Log(title = "工程审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZEngineeringReviewBo bo, HttpServletResponse response) {
        List<ZEngineeringReviewVo> list = iZEngineeringReviewService.queryList(bo);
        ExcelUtil.exportExcel(list, "工程审核", ZEngineeringReviewVo.class, response);
    }

    /**
     * 获取工程审核详细信息
     *
     * @param id 主键
     */
//    @SaCheckPermission("zdsz:engineeringReview:query")
    @GetMapping()
    public R getInfo( @RequestBody ZEngineeringNodeBo bo) {
        return R.ok(iZEngineeringReviewService.query(bo));
    }

    /**
     * 新增工程审核
     */
    //@SaCheckPermission("zdsz:engineeringReview:add")
    @Log(title = "工程审核", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZEngineeringReviewBo bo) {
        return toAjax(iZEngineeringReviewService.insert(bo));
    }

    /**
     * 修改工程审核
     */
//    @SaCheckPermission("zdsz:engineeringReview:edit")
    @Log(title = "工程审核", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZEngineeringReviewBo bo) {
        return toAjax(iZEngineeringReviewService.updateByBo(bo));
    }

    /**
     * 删除工程审核
     *
     * @param ids 主键串
     */
//    @SaCheckPermission("zdsz:engineeringReview:remove")
    @Log(title = "工程审核", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable String[] ids) {
        return toAjax(iZEngineeringReviewService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
    /**
     * 批量审核
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("zdsz:engineeringReview:remove")
    @Log(title = "工程审核", businessType = BusinessType.DELETE)
    @GetMapping("/ZEngineeringReview")
    public R ZEngineeringReview(ZEngineeringNodeBo bo) {
        return R.ok(izEngineeringNodeService.ZEngineeringReview(bo));
    }
}
