package com.cool.store.controller;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.dto.inspection.setting.AddInspectionSettingDTO;
import com.cool.store.dto.inspection.setting.CheckInspectionSettingDTO;
import com.cool.store.dto.inspection.setting.DeleteInspectionSettingDTO;
import com.cool.store.dto.inspection.setting.UpdateInspectionSettingDTO;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.InspectionSettingService;
import com.cool.store.vo.inspection.setting.InspectionSettingCheckVO;
import com.cool.store.vo.inspection.setting.InspectionSettingDetailVO;
import com.cool.store.vo.inspection.setting.InspectionSettingPageVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangchenbiao
 * @FileName: InspectionSettingController
 * @Description:稽核区域设置
 * @date 2023-07-17 14:29
 */
@RestController
@Slf4j
@Api(tags = "稽核区域设置")
public class InspectionSettingController {

    @Resource
    private InspectionSettingService inspectionSettingService;

    @ApiOperation("稽核区域设置列表")
    @GetMapping("/inspection/setting/page")
    public ResponseResult<PageInfo<InspectionSettingPageVO>> getInspectionSettingPage(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize){
        return ResponseResult.success(inspectionSettingService.getInspectionSettingPage(pageNum, pageSize));
    }

    @ApiOperation("稽核区域设置详情")
    @GetMapping("/inspection/setting/detail")
    public ResponseResult<InspectionSettingDetailVO> getInspectionSettingDetail(@RequestParam("inspectionSettingId")Long inspectionSettingId){
        return ResponseResult.success(inspectionSettingService.getInspectionSettingDetail(inspectionSettingId));
    }

    @ApiOperation("新增稽核区域设置")
    @PostMapping("/inspection/setting/add")
    public ResponseResult<Long> addInspectionSetting(@RequestBody AddInspectionSettingDTO param){
        return ResponseResult.success(inspectionSettingService.addInspectionSetting(CurrentUserHolder.getUserId(), param));
    }

    @ApiOperation("编辑稽核区域设置")
    @PostMapping("/inspection/setting/update")
    public ResponseResult<Integer> updateInspectionSetting(@RequestBody UpdateInspectionSettingDTO param){
        return ResponseResult.success(inspectionSettingService.updateInspectionSetting(CurrentUserHolder.getUserId(), param));
    }

    @ApiOperation("删除稽核区域设置")
    @PostMapping("/inspection/setting/delete")
    public ResponseResult<Integer> deleteInspectionSetting(@RequestBody DeleteInspectionSettingDTO param){
        return ResponseResult.success(inspectionSettingService.deleteInspectionSetting(CurrentUserHolder.getUserId(), param.getInspectionSettingId()));
    }

    @ApiOperation("校验稽核区域设置")
    @PostMapping("/inspection/setting/check")
    public ResponseResult<List<InspectionSettingCheckVO>> checkInspectionSetting(@RequestBody CheckInspectionSettingDTO param){
        return ResponseResult.success(inspectionSettingService.checkInspectionSetting(param));
    }

    @ApiOperation("查询已经关联的稽核人")
    @GetMapping("/inspection/setting/bind/users")
    public ResponseResult<List<String>> getBingUser(){
        return ResponseResult.success(inspectionSettingService.getBingUser());
    }

}
