package com.njcn.csdevice.controller.icd;


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.param.IcdBzParam;
import com.njcn.csdevice.param.IcdBzReplyParam;
import com.njcn.csdevice.pojo.vo.CldLogsVo;
import com.njcn.csdevice.service.ICsTerminalReplyService;
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.ApiImplicitParams;
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.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xy
 * @since 2025-10-09
 */
@Slf4j
@RequestMapping("/csTerminalReply")
@RestController
@Api(tags = "云前置台账信息响应记录")
@AllArgsConstructor

public class CsTerminalReplyController extends BaseController {

    private final ICsTerminalReplyService csTerminalReplyService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryData")
    @ApiOperation("查询推送结果")
    public HttpResult<List<String>> queryData(){
        String methodDescribe = getMethodDescribe("queryData");
        List<String> result = csTerminalReplyService.queryReplyData();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateData")
    @ApiOperation("更新推送结果")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<String> updateData(@RequestBody @Validated IcdBzReplyParam param){
        String methodDescribe = getMethodDescribe("updateData");
        csTerminalReplyService.updateReplyData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/bzLogs")
    @ApiOperation("补召日志")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<Page<CldLogsVo>> bzLogs(@RequestBody @Validated BaseParam param){
        String methodDescribe = getMethodDescribe("bzLogs");
        Page<CldLogsVo> list = csTerminalReplyService.getBzLogs(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateBzData")
    @ApiOperation("更新补召推送结果")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<String> updateBzData(@RequestBody @Validated IcdBzReplyParam param){
        String methodDescribe = getMethodDescribe("updateBzData");
        csTerminalReplyService.updateBzData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}

