package com.ruoyi.web.controller.zdsz;

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

import com.ruoyi.zdsz.domain.bo.switchBo;
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.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zdsz.domain.vo.ZEngineeringNodeVo;
import com.ruoyi.zdsz.domain.bo.ZEngineeringNodeBo;
import com.ruoyi.zdsz.service.IZEngineeringNodeService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工程节点
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zdsz/engineeringNode")
public class ZEngineeringNodeController extends BaseController {

    private final IZEngineeringNodeService iZEngineeringNodeService;

    /**
     * 查询工程节点列表
     */
//    @SaCheckPermission("zdsz:engineeringNode:list")
    @GetMapping("/list")
    public TableDataInfo<ZEngineeringNodeVo> list(ZEngineeringNodeBo bo, PageQuery pageQuery) {
        return iZEngineeringNodeService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出工程节点列表
     */
//    @SaCheckPermission("zdsz:engineeringNode:export")
    @Log(title = "工程节点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZEngineeringNodeBo bo, HttpServletResponse response) {
        List<ZEngineeringNodeVo> list = iZEngineeringNodeService.queryList(bo);
        ExcelUtil.exportExcel(list, "工程节点", ZEngineeringNodeVo.class, response);
    }

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

    /**
     * 新增工程节点
     */
   // @SaCheckPermission("zdsz:engineeringNode:add")
    @Log(title = "工程节点", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R add(@Validated(AddGroup.class) @RequestBody ZEngineeringNodeBo bo) {
        bo.setCreateTime(new Date());
        return R.ok(iZEngineeringNodeService.insert(bo));
    }

    /**
     * 修改工程节点
     */
    //@SaCheckPermission("zdsz:engineeringNode:edit")
    @Log(title = "工程节点", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit( @RequestBody ZEngineeringNodeBo bo) {
        return toAjax(iZEngineeringNodeService.update(bo));
    }

    /**
     * 删除工程节点
     *
     * @param ids 主键串
     */
   // @SaCheckPermission("zdsz:engineeringNode:remove")
    @Log(title = "工程节点", businessType = BusinessType.DELETE)
    @DeleteMapping("")
    public R<Void> remove(
                          @RequestBody ZEngineeringNodeBo bo) {
        return toAjax(iZEngineeringNodeService.delete(bo));
    }
    @Log(title = "节点开关", businessType = BusinessType.UPDATE)
    @PostMapping("/batchNodes")
    public R batchNodes(
        @RequestBody switchBo bo) {
        return R.ok(iZEngineeringNodeService.batchNodes(bo));
    }

}
