package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.manager.service.TbJcglKhbmService;
import com.mosty.base.model.dto.jcgl.TbJcglKhbmEditPzDto;
import com.mosty.base.model.entity.jcgl.TbJcglKhbm;
import com.mosty.base.model.query.jcgl.TbJcglKhbmQuery;
import com.mosty.base.model.vo.jcgl.TbJcglKhbmVo;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.token.JwtSysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/khbm")
@Api(tags = "绩效考核部门相关接口")
public class TbJcglKhbmController {

    private final TbJcglKhbmService tbJcglKhbmService;

    @PostMapping("/addKhbm")
    @JwtSysUser
    @ApiOperation(value = "添加绩效考核部门")
    public ResponseResult<Void> addKhbm(@RequestBody List<String> ssbmidList) {
        this.tbJcglKhbmService.addKhbm(ssbmidList);
        return ResponseResult.success();
    }

    @DeleteMapping("/delKhbm")
    @JwtSysUser
    @ApiOperation(value = "删除绩效考核部门")
    public ResponseResult<Void> delKhbm(@RequestBody List<String> ids) {
        this.tbJcglKhbmService.delKhbm(ids);
        return ResponseResult.success();
    }

    @GetMapping("/getPageList")
    @JwtSysUser
    @ApiOperation(value = "查询绩效考核参与部门列表")
    public ResponseResult<IPage<TbJcglKhbmVo>> getPageList(TbJcglKhbmQuery dto) {
        return ResponseResult.success(this.tbJcglKhbmService.getPageList(dto));
    }

    @GetMapping("/getAllKhbm")
    @JwtSysUser
    @ApiOperation(value = "查询所有的已选中的部门")
    public ResponseResult<List<String>> getAllKhbm() {
        return ResponseResult.success(this.tbJcglKhbmService.getAllKhbm());
    }

    @PostMapping("/editKhbm")
    @JwtSysUser
    @ApiOperation(value = "修改考核部门配置")
    public ResponseResult<Void> editKhbm(@RequestBody TbJcglKhbm dto) {
        this.tbJcglKhbmService.editKhbm(dto);
        return ResponseResult.success();
    }
}
