package com.njcn.advance.controller.carrycapacity;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityQueryDataParam;
import com.njcn.advance.pojo.carrycapacity.param.CarryCapacityResultParam;
import com.njcn.advance.pojo.carrycapacity.po.CarryCapacityResultPO;
import com.njcn.advance.pojo.carrycapacity.vo.CarryCapacityDResultVO;
import com.njcn.advance.service.carrycapacity.CarryCapacityResultPOService;
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.web.controller.BaseController;
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.*;

import java.util.List;


/**
 * @author hongawen
 * @version 1.0.0
 * @date 2023年07月21日 10:06
 */
@RestController
@RequestMapping("result")
@Api(tags = "承载能力评估结果")
@RequiredArgsConstructor
public class CarryCapacityResultController extends BaseController {


    private final CarryCapacityResultPOService carryCapacityResultPOService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryResultList")
    @ApiOperation("承载能力评估列表查询")
    @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
    public HttpResult<IPage<CarryCapacityDResultVO>> queryResultList(@RequestBody @Validated CarryCapacityResultParam.CarryCapacityResultPageParam queryParam) {
        String methodDescribe = getMethodDescribe("queryResultList");
        IPage<CarryCapacityDResultVO> vo = carryCapacityResultPOService.queryResultList(queryParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryResultbyCondition")
    @ApiOperation("承载能力评估列表查询")
    @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
    public HttpResult<CarryCapacityDResultVO> queryResultbyCondition(@RequestBody @Validated CarryCapacityQueryDataParam queryParam) {
        String methodDescribe = getMethodDescribe("queryResultbyCondition");
        CarryCapacityDResultVO vo = carryCapacityResultPOService.queryResultbyCondition(queryParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
    }
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/remove")
    @ApiOperation("承载能力评估用户批量删除")
    public HttpResult<Boolean> remove(@RequestParam("ids") List<String> ids) {
        String methodDescribe = getMethodDescribe("remove");
        Boolean flag = carryCapacityResultPOService.lambdaUpdate().in(CarryCapacityResultPO::getId, ids).set(CarryCapacityResultPO::getStatus, 0).update();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }


}
