package vip.xiaonuo.write.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.production.entity.ProductionWriteRate;
import vip.xiaonuo.production.param.ProductionPageParam;
import vip.xiaonuo.production.param.ProductionWriteRateAddParam;
import vip.xiaonuo.sys.modular.user.entity.SysUser;
import vip.xiaonuo.write.entity.WriteThreshold;
import vip.xiaonuo.write.param.WriteThresholdAddParam;
import vip.xiaonuo.write.param.WriteThresholdPageParam;
import vip.xiaonuo.write.service.IWriteThresholdService;

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

/**
 * <p>
 * 通用预警阈值 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-01
 */
@RestController
@Api(tags = "通用预警阈值")
@ApiSupport(author = "wang", order = 1)
@Validated
public class WriteThresholdController {

    @Autowired
    private IWriteThresholdService thresholdService;


    @PostMapping("/write-threshold/add")
    @ApiOperationSupport(order = 1)
    @ApiOperation("通用预警阈值添加")
    public CommonResult add(@RequestBody WriteThresholdAddParam addParam){
        return thresholdService.add(addParam);
    }

    @PostMapping("/write-threshold/edit")
    @ApiOperationSupport(order = 2)
    @ApiOperation("通用预警阈值修改")
    public CommonResult edit(@RequestBody WriteThreshold threshold) {
        return thresholdService.edit(threshold);
    }

    @PostMapping("/write-threshold/delete")
    @ApiOperationSupport(order = 3)
    @ApiOperation("通用预警阈值删除")
    public CommonResult delete(@RequestBody Map<String, String> paramsMap) {
        return thresholdService.delete(paramsMap);
    }

    @PostMapping("/write-threshold/page")
    @ApiOperationSupport(order = 4)
    @ApiOperation("通用预警阈值分页")
    public CommonResult<Page<WriteThreshold>> page(@RequestBody WriteThresholdPageParam pageParam) {
        return CommonResult.data(thresholdService.page(pageParam));
    }

    @PostMapping("/write-threshold/getUserList")
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取处理人列表")
    public CommonResult<List<SysUser>> getUserList(@RequestBody Map<String, String> paramsMap) {
        return CommonResult.data(thresholdService.getUserList(paramsMap));
    }
}
