package com.ruoyi.postCheck.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.PostPlanInfo;
import com.ruoyi.postCheck.service.IPostPlanInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;

/**
 * 岗检计划明细表Controller
 *
 * @author csg
 * @date 2023-12-19
 */
@Api(tags = "2.3.2-岗检计划明细表接口（暂时不调，走2.3.1接口后端搞定）")
@RestController
@RequestMapping("/postCheck/postPlanInfo")
public class PostPlanInfoController extends BaseController
{
    @Autowired
    private IPostPlanInfoService postPlanInfoService;

    /**
     * 查询岗检计划明细表列表
     */
    @ApiOperation("查询岗检计划明细表列表")
    @PreAuthorize("@ss.hasPermi('postCheck:postPlanInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostPlanInfo postPlanInfo)
    {
        startPage();
        List<PostPlanInfo> list = postPlanInfoService.selectPostPlanInfoList(postPlanInfo);
        return getDataTable(list);
    }

    /**
     * 导出岗检计划明细表列表
     */
    @ApiOperation("导出岗检计划明细表列表")
    @PreAuthorize("@ss.hasPermi('postCheck:postPlanInfo:export')")
    @Log(title = "岗检计划明细表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PostPlanInfo postPlanInfo)
    {
        List<PostPlanInfo> list = postPlanInfoService.selectPostPlanInfoList(postPlanInfo);
        ExcelUtil<PostPlanInfo> util = new ExcelUtil<PostPlanInfo>(PostPlanInfo.class);
        util.exportExcel(response, list, "岗检计划明细表数据");
    }

    /**
     * 获取岗检计划明细表详细信息
     */
    @ApiOperation("获取岗检计划明细表详细信息")
    @PreAuthorize("@ss.hasPermi('postCheck:postPlanInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(postPlanInfoService.selectPostPlanInfoById(id));
    }

    /**
     * 新增岗检计划明细表
     */
    @ApiOperation("新增岗检计划明细表")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "postPlanId", value = "计划ID", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "checkedDeptId", value = "被检查部门ID", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "checkTime", value = "检查时间", dataType = "Date", dataTypeClass = Date.class),
        @ApiImplicitParam(name = "checkedPostId", value = "被检查岗位ID", dataType = "Long", dataTypeClass = Long.class),
        @ApiImplicitParam(name = "delFlag", value = "del_flag", dataType = "Integer", dataTypeClass = Integer.class),
        @ApiImplicitParam(name = "createUserId", value = "创建者用户ID", dataType = "Long", dataTypeClass = Long.class),
    })
    @PreAuthorize("@ss.hasPermi('postCheck:postPlanInfo:add')")
    @Log(title = "岗检计划明细表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostPlanInfo postPlanInfo)
    {
        return toAjax(postPlanInfoService.insertPostPlanInfo(postPlanInfo));
    }

    /**
     * 修改岗检计划明细表
     */
    @ApiOperation("修改岗检计划明细表")
    @PreAuthorize("@ss.hasPermi('postCheck:postPlanInfo:edit')")
    @Log(title = "岗检计划明细表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostPlanInfo postPlanInfo)
    {
        return toAjax(postPlanInfoService.updatePostPlanInfo(postPlanInfo));
    }

    /**
     * 删除岗检计划明细表
     */
    @ApiOperation("删除岗检计划明细表")
    @PreAuthorize("@ss.hasPermi('postCheck:postPlanInfo:remove')")
    @Log(title = "岗检计划明细表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(postPlanInfoService.deletePostPlanInfoByIds(ids));
    }
}
