package com.njcn.supervision.controller.problem;

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.supervision.pojo.param.leaflet.WarningAddParam;
import com.njcn.supervision.pojo.param.problem.SupervisionUserComplaintParam;
import com.njcn.supervision.pojo.vo.problem.SupervisionUserComplaintVO;
import com.njcn.supervision.service.problem.SupervisionUserComplaintPOService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author hongawen
 */
@Slf4j
@RestController
@RequestMapping("/SupervisionUserComplaint")
@Api(tags = "用户投诉")
@AllArgsConstructor
public class SupervisionUserComplaintController extends BaseController {

    private final SupervisionUserComplaintPOService supervisionUserComplaintService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("分页用户投诉数据")
    @ApiImplicitParam(name = "supervisionUserComplaintQueryParam", value = "参数", required = true)
    public HttpResult<Page<SupervisionUserComplaintVO>> getSupervisionUserComplaint(@RequestBody SupervisionUserComplaintParam.SupervisionUserComplaintQueryParam supervisionUserComplaintQueryParam) {
        String methodDescribe = getMethodDescribe("getSupervisionUserComplaint");
        Page<SupervisionUserComplaintVO> out = supervisionUserComplaintService.getSupervisionUserComplaint(supervisionUserComplaintQueryParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
    @PostMapping("/add")
    @ApiOperation("投诉问题填报")
    @ApiImplicitParam(name = "supervisionUserComplaintParam", value = "实体参数", required = true)
    public HttpResult<String> addSupervisionUserComplaint(@RequestBody SupervisionUserComplaintParam supervisionUserComplaintParam) {
        String methodDescribe = getMethodDescribe("addSupervisionUserComplaint");
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, supervisionUserComplaintService.addSupervisionUserComplaint(supervisionUserComplaintParam), methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/initiateWarningLeaflet")
    @ApiOperation("针对用户投诉发起告警单")
    public HttpResult<Boolean> initiateWarningLeaflet(@RequestBody WarningAddParam warningAddParam){
        String methodDescribe = getMethodDescribe("initiateWarningLeaflet");
        supervisionUserComplaintService.initiateWarningLeaflet(warningAddParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Boolean.TRUE, methodDescribe);
    }



}
