package com.njcn.csdevice.controller.equipment;

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.csdevice.pojo.po.CsDevCapacityPO;
import com.njcn.csdevice.service.CsDevCapacityPOService;
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.*;

import java.util.List;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/3/27  15:31【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/capacity")
@Api(tags = "设备电流限值")
@AllArgsConstructor
public class CsDevCapacityController extends BaseController {

    private final CsDevCapacityPOService csDevCapacityPOService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getDevCapacity")
    @ApiOperation("根据设备id获取电流限值")
    @ApiImplicitParam(name = "id", value = "设备id", required = true)
    public HttpResult<Double> getDevCapacity(@RequestParam("id") String id){
        String methodDescribe = getMethodDescribe("getDevCapacity");
        Double limit  = csDevCapacityPOService.getDevCapacity(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, limit, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addList")
    @ApiOperation("批量新增")
    @ApiImplicitParam(name = "list", value = "设备id", required = true)
    public HttpResult<String> addList(@RequestBody List<CsDevCapacityPO> list){
        String methodDescribe = getMethodDescribe("addList");
        csDevCapacityPOService.addList(list);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}
