package com.ruoyi.postCheck.controller;

import java.util.*;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.postCheck.domain.PostCheckedItems;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.postCheck.domain.PostChecked;
import com.ruoyi.postCheck.service.IPostCheckedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗检表管理Controller
 *
 * @author csg
 * @date 2024-01-05
 */
@Api(tags = "2.5.1-岗检表管理接口")
@RestController
@RequestMapping("/postCheck/postChecked")
public class PostCheckedController extends BaseController {
    @Autowired
    private IPostCheckedService postCheckedService;

    /**
     * 查询岗检表管理列表
     */
    @ApiOperation("查询岗检表管理列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkWorkgroupId", value = "检查工作组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkGroupId", value = "检查小组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedDeptId", value = "被检查部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedPostId", value = "被检查岗位ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "printUserId", value = "打印人ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "printTime", value = "打印时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "checkedImg", value = "上传：检查后的检查表照片或PDF，磁盘相对路径", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "checkedUserName", value = "上传：检查人中文姓名（上传页面设置的值）", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "checkedTime", value = "上传：检查时间（上传页面设置的值）", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "uploadUserId", value = "上传：检查表上传人ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "uploadTime", value = "上传：检查表上传时间", dataType = "Date", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "pageNum", value = "页码从1开始", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "分页大小", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序字段", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('postCheck:postChecked:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostChecked postChecked) {
        startPage();
        List<PostChecked> list = postCheckedService.selectPostCheckedList(postChecked);
        return getDataTable(list);
    }

    /**
     * 导出岗检表管理列表
     @ApiOperation("导出岗检表管理列表")
     @PreAuthorize("@ss.hasPermi('postCheck:postChecked:export')")
     @Log(title = "岗检表管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export") public void export(HttpServletResponse response, PostChecked postChecked) {
     List<PostChecked> list = postCheckedService.selectPostCheckedList(postChecked);
     ExcelUtil<PostChecked> util = new ExcelUtil<PostChecked>(PostChecked.class);
     util.exportExcel(response, list, "岗检表管理数据");
     }
     */

    /**
     * 获取岗检表管理详细信息
     */
    @ApiOperation("获取岗检表管理详细信息")
    @PreAuthorize("@ss.hasPermi('postCheck:postChecked:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(postCheckedService.selectPostCheckedById(id));
    }

    /**
     * 新增岗检表管理
     *
     * @ApiOperation("新增岗检表管理")
     * @ApiImplicitParams({
     * @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "checkWorkgroupId", value = "检查工作组ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "checkGroupId", value = "检查小组ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "checkedDeptId", value = "被检查部门ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "checkedPostId", value = "被检查岗位ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "printUserId", value = "打印人ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "printTime", value = "打印时间", dataType = "Date", dataTypeClass = Date.class),
     * @ApiImplicitParam(name = "checkedImg", value = "上传：检查后的检查表照片或PDF，磁盘相对路径", dataType = "String", dataTypeClass = String.class),
     * @ApiImplicitParam(name = "checkedUserName", value = "上传：检查人中文姓名（上传页面设置的值）", dataType = "String", dataTypeClass = String.class),
     * @ApiImplicitParam(name = "checkedTime", value = "上传：检查时间（上传页面设置的值）", dataType = "Date", dataTypeClass = Date.class),
     * @ApiImplicitParam(name = "uploadUserId", value = "上传：检查表上传人ID", dataType = "Long", dataTypeClass = Long.class),
     * @ApiImplicitParam(name = "uploadTime", value = "上传：检查表上传时间", dataType = "Date", dataTypeClass = Date.class),
     * @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
     * @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
     * })
     * @PreAuthorize("@ss.hasPermi('postCheck:postChecked:add')")
     * @Log(title = "岗检表管理", businessType = BusinessType.INSERT)
     * @PostMapping public AjaxResult add(@RequestBody PostChecked postChecked) {
     * return toAjax(postCheckedService.insertPostChecked(postChecked));
     * }
     */


    @ApiOperation("新增岗检表管理")
    @ApiImplicitParams({
//     @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkWorkgroupId", value = "检查工作组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkGroupId", value = "检查小组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedDeptId", value = "被检查部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedPostId", value = "被检查岗位ID", dataType = "Long", dataTypeClass = Long.class),
//     @ApiImplicitParam(name = "printUserId", value = "打印人ID", dataType = "Long", dataTypeClass = Long.class),
//     @ApiImplicitParam(name = "printTime", value = "打印时间", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "checkedImg", value = "上传：检查后的检查表照片或PDF，磁盘相对路径", dataType = "String", dataTypeClass = String.class),
//     @ApiImplicitParam(name = "checkedUserName", value = "上传：检查人中文姓名（上传页面设置的值）", dataType = "String", dataTypeClass = String.class),
//     @ApiImplicitParam(name = "checkedTime", value = "上传：检查时间（上传页面设置的值）", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "uploadUserId", value = "上传：检查表上传人ID", dataType = "Long", dataTypeClass = Long.class),
//     @ApiImplicitParam(name = "uploadTime", value = "上传：检查表上传时间", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
//     @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "children", value = "检查表明细数组", dataType = "List", dataTypeClass = PostCheckedItems.class),
    })


    @PreAuthorize("@ss.hasPermi('postCheck:postChecked:add')")
    @Log(title = "岗检表管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostChecked postChecked) {
        return toAjax(postCheckedService.insertPostChecked(postChecked));
    }

    /**
     * 修改岗检表管理
     */
    @ApiOperation("修改岗检表管理")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkWorkgroupId", value = "检查工作组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkGroupId", value = "检查小组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedDeptId", value = "被检查部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "checkedPostId", value = "被检查岗位ID", dataType = "Long", dataTypeClass = Long.class),
//     @ApiImplicitParam(name = "printUserId", value = "打印人ID", dataType = "Long", dataTypeClass = Long.class),
//     @ApiImplicitParam(name = "printTime", value = "打印时间", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "checkedImg", value = "上传：检查后的检查表照片或PDF，磁盘相对路径", dataType = "String", dataTypeClass = String.class),
//     @ApiImplicitParam(name = "checkedUserName", value = "上传：检查人中文姓名（上传页面设置的值）", dataType = "String", dataTypeClass = String.class),
//     @ApiImplicitParam(name = "checkedTime", value = "上传：检查时间（上传页面设置的值）", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "uploadUserId", value = "上传：检查表上传人ID", dataType = "Long", dataTypeClass = Long.class),
//     @ApiImplicitParam(name = "uploadTime", value = "上传：检查表上传时间", dataType = "Date", dataTypeClass = Date.class),
//     @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "Integer", dataTypeClass = Integer.class),
//     @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "children", value = "检查表明细数组", dataType = "List", dataTypeClass = PostCheckedItems.class),
    })
    @PreAuthorize("@ss.hasPermi('postCheck:postChecked:edit')")
    @Log(title = "岗检表管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostChecked postChecked) {
        return toAjax(postCheckedService.updatePostChecked(postChecked));
    }

    /**
     * 删除岗检表管理
     */
    @ApiOperation("删除岗检表管理")
    @ApiImplicitParam(name = "ids", value = "Long类型的主键数组", dataType = "Long[]", dataTypeClass = Long[].class)
    @PreAuthorize("@ss.hasPermi('postCheck:postChecked:remove')")
    @Log(title = "岗检表管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(postCheckedService.deletePostCheckedByIds(ids));
    }
}
