package com.njcn.csdevice.controller.equipment;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.dto.CsEquipmentProcessDTO;
import com.njcn.csdevice.pojo.po.CsEquipmentProcessPO;
import com.njcn.csdevice.pojo.vo.CsEventSendMsgVO;
import com.njcn.csdevice.service.CsEquipmentProcessPOService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
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.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 java.util.List;

/**
 * 类的介绍：设备调试日志记录
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2023/9/14 10:01
 */
@Slf4j
@RestController
@RequestMapping("/process")
@Api(tags = "设备调试日志")
@AllArgsConstructor
public class CsEquipmentProcessController extends BaseController {

    private final CsEquipmentProcessPOService csEquipmentProcessPOService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/add")
    @ApiOperation("新增记录")
    @ApiImplicitParam(name = "csEquipmentProcess", value = "逻辑子设备标识", required = true)
    public HttpResult<String> add(@RequestBody @Validated CsEquipmentProcessPO csEquipmentProcess){
        String methodDescribe = getMethodDescribe("add");
        boolean result = csEquipmentProcessPOService.save(csEquipmentProcess);
        if (result){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "fail", methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/query")
    @ApiOperation("查询记录")
    @ApiImplicitParam(name = "csEquipmentProcessDTO", value = "查询参数", required = true)
    public HttpResult<List<CsEquipmentProcessDTO>> queryList(@RequestBody @Validated CsEquipmentProcessDTO csEquipmentProcessDTO){
        String methodDescribe = getMethodDescribe("queryList");
        List<CsEquipmentProcessDTO> result = csEquipmentProcessPOService.queryqueryList(csEquipmentProcessDTO);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryPage")
    @ApiOperation("分页查询记录")
    @ApiImplicitParam(name = "baseParam", value = "查询参数", required = true)
    public HttpResult<Page<CsEquipmentProcessDTO>> queryPage(@RequestBody BaseParam baseParam){
        String methodDescribe = getMethodDescribe("queryPage");
        Page<CsEquipmentProcessDTO> list = csEquipmentProcessPOService.queryPage(baseParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }


}
