package cn.cslg.report.controller.InvalidReReport;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.dto.invalidReReport.InvalidReasonFieldDTO;
import cn.cslg.report.common.model.dto.invalidReReport.InvalidReasonFieldSortDTO;
import cn.cslg.report.entity.invalidReReport.InvalidReasonField;
import cn.cslg.report.service.business.InvalidReReport.InvalidReasonFieldService;
import cn.cslg.report.service.business.InvalidReReport.InvalidReasonFieldValueService;
import cn.cslg.report.service.business.InvalidReReport.ProofStrService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 无效理由自定义栏位的Controller层
 *
 * @Author lrj
 * @Data 2023/4/1
 */
@Tag(name = "无效理由自定义栏位值管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(Constants.REPORT_API + "/invalidReasonField")
public class InvalidReasonFieldController {
    private final InvalidReasonFieldService invalidReasonFieldService;

    @Operation(summary = "添加自定义栏位")
    @PostMapping("/addOrUpdateFields")
    public String addOrUpdate(@RequestBody InvalidReasonFieldDTO invalidReasonFieldDTO){
        return   invalidReasonFieldService.addOrUpdate(invalidReasonFieldDTO);
    }

    @Operation(summary = "查询自定义栏位")
    @GetMapping("/queryFields")
    public String queryFields(Integer reportId){
        return  invalidReasonFieldService.queryFields(reportId);
    }

    @Operation(summary = "删除自定义栏位")
    @PostMapping("/deleteFields")
    public String deleteFields(@RequestBody List<Integer> fieldIds){
        return  invalidReasonFieldService.deleteFields(fieldIds);
    }

    @Operation(summary = "批量变更自定义字段排序")
    @PostMapping("/updateSort")
    public String updateSort(@RequestBody List<InvalidReasonFieldSortDTO> invalidReasonFieldSortDTOS){
        return  invalidReasonFieldService.updateSort(invalidReasonFieldSortDTOS);
    }


}
