package com.njcn.process.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.pojo.param.SupvAlarmBackParam;
import com.njcn.process.pojo.po.SupvAlarmBack;
import com.njcn.process.service.ISupvAlarmBackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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 com.njcn.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 技术监督预告警单反馈数据表 前端控制器
 * </p>
 *
 * @author wr
 * @since 2023-09-01
 */
@RestController
@Api(tags ="预告警单反馈")
@RequestMapping("/supvAlarmBack")
@RequiredArgsConstructor
public class SupvAlarmBackController extends BaseController {

    private final ISupvAlarmBackService supvAlarmBackService;

    @PostMapping("addAlarmBack")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("新增预告警单反馈")
    public HttpResult<Boolean> addAlarmBack(@RequestBody @Validated SupvAlarmBackParam.AlarmBackInsert insert){
        String methodDescribe = getMethodDescribe("addAlarmBack");
        Boolean b = supvAlarmBackService.addAlarmBack(insert);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

    @PostMapping("updateAlarmBack")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("修改预告警单反馈")
    public HttpResult<Boolean> updateAlarmBack(@RequestBody @Validated SupvAlarmBackParam.AlarmBackUpdate update){
        String methodDescribe = getMethodDescribe("updateAlarmBack");
        Boolean b = supvAlarmBackService.updateAlarmBack(update);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

    @PostMapping("delAlarmBack")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("删除预告警单反馈")
    @ApiImplicitParam(name = "planIds",value = "监督计划索引集合",required = true)
    public HttpResult<Boolean> delAlarmBack(@RequestBody List<String> planIds){
        String methodDescribe = getMethodDescribe("delAlarmBack");
        Boolean b = supvAlarmBackService.delAlarmBack(planIds);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }
    @PostMapping("/downAlarmBack")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @ApiOperation("导出预告警单反馈数据信息")
    public void downAlarm(){
        supvAlarmBackService.downAlarmBack();
    }

    @PostMapping("pageAlarmBack")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("分页查询预告警单反馈")
    @ApiImplicitParam(name = "param",value = "请求体",required = true)
    public HttpResult<Page<SupvAlarmBack>> pageAlarmBack(@RequestBody SupvAlarmBackParam param){
        String methodDescribe = getMethodDescribe("pageAlarmBack");
        Page<SupvAlarmBack> supvPlanHisPage = supvAlarmBackService.pageAlarmBack(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, supvPlanHisPage, methodDescribe);
    }
}

