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.PostHighlights;
import com.ruoyi.postCheck.service.IPostHighlightsService;
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-26
 */
@Api(tags = "6.2.1-岗检亮点接口")
@RestController
@RequestMapping("/postCheck/postHighlights")
public class PostHighlightsController extends BaseController {
    @Autowired
    private IPostHighlightsService postHighlightsService;

    /**
     * 查询岗检亮点列表
     */
    @ApiOperation("查询岗检亮点列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "highlightsType", value = "职责类别：1-业务职责；2-党建及党风廉政；3-安全环保职责；4-合规保密职；5-其他；", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "problemAttribute", value = "问题属性（1-完整问题；2-有效性问题；3-适宜性问题；）", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "highlights", value = "管理亮点", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "delFlag", value = "del_flag", 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:postHighlights:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostHighlights postHighlights) {
        startPage();
        List<PostHighlights> list = postHighlightsService.selectPostHighlightsList(postHighlights);
        return getDataTable(list);
    }

    /**
     * 导出岗检亮点列表
     */
    @ApiOperation("导出岗检亮点列表")
    @PreAuthorize("@ss.hasPermi('postCheck:postHighlights:export')")
    @Log(title = "岗检亮点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PostHighlights postHighlights) {
        List<PostHighlights> list = postHighlightsService.selectPostHighlightsList(postHighlights);
        ExcelUtil<PostHighlights> util = new ExcelUtil<PostHighlights>(PostHighlights.class);
        util.exportExcel(response, list, "岗检亮点数据");
    }

    /**
     * 获取岗检亮点详细信息
     */
    @ApiOperation("获取岗检亮点详细信息")
    @PreAuthorize("@ss.hasPermi('postCheck:postHighlights:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(postHighlightsService.selectPostHighlightsById(id));
    }

    /**
     * 新增岗检亮点
     */
    @ApiOperation("新增岗检亮点")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "highlightsType", value = "职责类别：1-业务职责；2-党建及党风廉政；3-安全环保职责；4-合规保密职；5-其他；", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "problemAttribute", value = "问题属性（1-完整问题；2-有效性问题；3-适宜性问题；）", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "highlights", value = "管理亮点", dataType = "String", dataTypeClass = String.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:postHighlights:add')")
    @Log(title = "岗检亮点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostHighlights postHighlights) {
        return toAjax(postHighlightsService.insertPostHighlights(postHighlights));
    }

    /**
     * 修改岗检亮点
     */
    @ApiOperation("修改岗检亮点")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "highlightsType", value = "职责类别：1-业务职责；2-党建及党风廉政；3-安全环保职责；4-合规保密职；5-其他；", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "problemAttribute", value = "问题属性（1-完整问题；2-有效性问题；3-适宜性问题；）", dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "highlights", value = "管理亮点", dataType = "String", dataTypeClass = String.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:postHighlights:edit')")
    @Log(title = "岗检亮点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostHighlights postHighlights) {
        return toAjax(postHighlightsService.updatePostHighlights(postHighlights));
    }

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