package com.njcn.device.pms.controller.majornetwork;

import com.njcn.common.pojo.annotation.OperateInfo;
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.device.pms.pojo.param.RMpDevAbnormalManageParam;
import com.njcn.device.pms.pojo.param.RMpDevEvaluateDetailParam;
import com.njcn.device.pms.pojo.vo.RMpDevEvaluateDetailVO;
import com.njcn.device.pms.pojo.vo.RMpDevSolveVO;
import com.njcn.device.pms.service.majornetwork.RMpDevEvaluateDetailService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
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 java.util.List;

/**
 * @Title RMpDevEvaluateDetailController
 * @Package com.njcn.device.pms.controller.majornetwork
 * @Author jianghaifei
 * @Date 2022-11-17 15:44
 * @Version V1.0
 */
@RestController
@Api(tags = "终端质量评价")
@RequiredArgsConstructor
@RequestMapping("/rMpDevEvaluateDetail")
public class RMpDevEvaluateDetailController extends BaseController {

    private final RMpDevEvaluateDetailService rMpDevEvaluateDetailService;

    @PostMapping("/getRMpDevEvaluateDetailList")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("终端质量评价")
    public HttpResult<List<RMpDevEvaluateDetailVO>> getRMpDevEvaluateDetailList(@RequestBody RMpDevEvaluateDetailParam rMpDevEvaluateDetailParam) {
        String methodDescribe = getMethodDescribe("getRMpDevEvaluateDetailList");
        //没有携带【维度】条件
        if (StringUtils.isBlank(rMpDevEvaluateDetailParam.getSearchType())) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, null, methodDescribe);
        }
        List<RMpDevEvaluateDetailVO> list = null;
        //单位维度
        if ("1".equals(rMpDevEvaluateDetailParam.getSearchType())) {
            list = rMpDevEvaluateDetailService.getOrgDevEvaluateDetailList(rMpDevEvaluateDetailParam);
        }
        //厂商维度
        else if ("2".equals(rMpDevEvaluateDetailParam.getSearchType())) {
            list = rMpDevEvaluateDetailService.getManufactureDevEvaluateDetailList(rMpDevEvaluateDetailParam);
        }
        //终端型号
        else if ("3".equals(rMpDevEvaluateDetailParam.getSearchType())) {
            list = rMpDevEvaluateDetailService.getModelDevEvaluateDetailList(rMpDevEvaluateDetailParam);
        } else {
            //没有对应的searchType
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INVALID_PARAMETER, null, methodDescribe);
        }

        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }
}
