package com.njcn.csdevice.controller.icd;


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.service.ICsTerminalLogsService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xy
 * @since 2025-09-26
 */
@Slf4j
@RequestMapping("/csTerminalLogs")
@RestController
@Api(tags = "云前置台账信息日志")
@AllArgsConstructor
public class CsTerminalLogsController extends BaseController {

    private final ICsTerminalLogsService csTerminalLogsService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/pushCldInfo")
    @ApiOperation("推送日志台账信息")
    public HttpResult<String> pushCldInfo(){
        String methodDescribe = getMethodDescribe("pushCldInfo");
        String result = csTerminalLogsService.pushCldInfo();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateCldInfo")
    @ApiOperation("更新日志台账信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "设备id", required = true),
            @ApiImplicitParam(name = "code", value = "流程状态", required = true)
    })
    public HttpResult<String> updateCldInfo(@RequestParam String id, @RequestParam Integer code){
        String methodDescribe = getMethodDescribe("updateCldInfo");
        csTerminalLogsService.updateLogs(id,code);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateLaterData")
    @ApiOperation("更新最新一组数据的推送状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "设备id", required = true),
            @ApiImplicitParam(name = "code", value = "流程状态", required = true)
    })
    public HttpResult<String> updateLaterData(@RequestParam String id, @RequestParam String code){
        String methodDescribe = getMethodDescribe("updateLaterData");
        csTerminalLogsService.updateLaterData(id,code);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}

