package com.dk.mdm.controller.mst;

import com.dk.common.response.ResponseResultVO;
import com.dk.common.model.pojo.mst.StaffPurview;
import com.dk.common.service.BaseService;
import com.dk.common.model.vo.mst.StaffVO;
import com.dk.mdm.service.mst.StaffService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.mst.StaffPurviewService;

import java.util.List;
import java.util.Map;

/**
 * @desc   : 员工数据范围API接口
 * @author : 姜永辉
 * @date   : 2023/1/4 9:25
 */
@Api(tags = "员工数据范围API接口")
@RestController
@RequestMapping("/mst/staff_purview")
public class StaffPurviewController{

    public BaseService<StaffPurview> getService() {
        return staffPurviewService;
    }

    @Autowired
    private StaffPurviewService staffPurviewService;

    @Autowired
    private StaffService staffService;


    /**
     * @desc   : 查询范围权限
     * @author : 常皓宁
     * @date   : 2024/4/2 14:46
     */
    @PostMapping("get_purview/{staffId}")
    public ResponseResultVO getPurview(@PathVariable String staffId) {
        return staffPurviewService.getPurview(staffId);
    }

    /**
     * @desc : 员工数据范围
     * @author : 姜永辉
     * @date : 2024/2/26 10:36
     */
    @ApiOperation(
            value = "获取员工权限",
            notes = "获取员工权限"
    )
    @PostMapping("get_staff_purview")
    public ResponseResultVO<Map<String, Object>> getStaffPurview(@RequestBody Map<String, Object> param) {
        return staffPurviewService.getStaffPurview(param);
    }

    /**
     * @desc : 新建员工--员工数据范围
     * @author : 姜永辉
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "新建员工--权限", notes = "新建员工--权限")
    @PostMapping({"save_staff_purview"})
    public ResponseResultVO<?> saveStaffPurview(@RequestBody StaffVO staffVO) {
        return staffService.saveStaffPurview(staffVO);
    }

    /**
     * @desc   : 保存范围权限
     * @author : 常皓宁
     * @date   : 2024/4/3 14:45
     */
    @PostMapping("save_purview/{staffId}")
    public ResponseResultVO savePurview(@RequestBody List<StaffPurview> staffPurviewList, @PathVariable String staffId) {
        return staffPurviewService.savePurview(staffPurviewList, staffId);
    }

}
