package com.ruoyi.postCheck.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.postCheck.domain.PostTeamDept;
import com.ruoyi.postCheck.service.IPostTeamDeptService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗检工作组关联部门Controller
 *
 * @author csg
 * @date 2023-12-19
 */
@Api(tags = "2.2.2-组织机构添加部门")
@RestController
@RequestMapping("/postCheck/teamDept")
public class PostTeamDeptController extends BaseController {
    @Autowired
    private IPostTeamDeptService postTeamDeptService;

    /**
     * 查询岗检工作组关联部门列表
     */
    @ApiOperation("查询岗检工作组关联部门列表")
//    @PreAuthorize("@ss.hasPermi('postCheck:teamDept:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostTeamDept postTeamDept) {
        startPage();
        List<PostTeamDept> list = postTeamDeptService.selectPostTeamDeptList(postTeamDept);
        return getDataTable(list);
    }

    /**
     * 导出岗检工作组关联部门列表
     @ApiOperation("导出岗检工作组关联部门列表")
     @PreAuthorize("@ss.hasPermi('postCheck:teamDept:export')")
     @Log(title = "岗检工作组关联部门", businessType = BusinessType.EXPORT)
     @PostMapping("/export") public void export(HttpServletResponse response, PostTeamDept postTeamDept)
     {
     List<PostTeamDept> list = postTeamDeptService.selectPostTeamDeptList(postTeamDept);
     ExcelUtil<PostTeamDept> util = new ExcelUtil<PostTeamDept>(PostTeamDept.class);
     util.exportExcel(response, list, "岗检工作组关联部门数据");
     }
     */

    /**
     * 获取岗检工作组关联部门详细信息
     */
//    @ApiOperation("获取岗检工作组关联部门详细信息")
//    @PreAuthorize("@ss.hasPermi('postCheck:teamDept:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id) {
//        return success(postTeamDeptService.selectPostTeamDeptById(id));
//    }

    /**
     * 新增岗检工作组关联部门
     */
    @ApiOperation("新增岗检工作组关联部门")
    /*
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "postTeamId", value = "岗检工作组ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "type", value = "类型（1-牵头；2-成员）：2联合办公室（多部门）；3综合/生产工作组（1牵头部门/多成员部门）", dataType = "Integer", dataTypeClass = Integer.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:teamDept:add')")
    @Log(title = "岗检工作组关联部门", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<PostTeamDept> postTeamDeptList) {
        return toAjax(postTeamDeptService.insertPostTeamDept(postTeamDeptList));
    }

    /**
     * 修改岗检工作组关联部门
     */
//    @ApiOperation("修改岗检工作组关联部门")
//    @PreAuthorize("@ss.hasPermi('postCheck:teamDept:edit')")
//    @Log(title = "岗检工作组关联部门", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody PostTeamDept postTeamDept) {
//        return toAjax(postTeamDeptService.updatePostTeamDept(postTeamDept));
//    }

    /**
     * 删除岗检工作组关联部门
     */
    @ApiOperation("删除岗检工作组关联部门")
//    @PreAuthorize("@ss.hasPermi('postCheck:teamDept:remove')")
    @Log(title = "岗检工作组关联部门", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(
            @ApiParam(name = "ids", value = "岗检工作组关联部门表ids", required = true)
            @PathVariable Long[] ids) {
        return toAjax(postTeamDeptService.deletePostTeamDeptByIds(ids));
    }
}
