package com.njcn.device.device.controller;

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.device.device.service.TerminalVersionService;
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
import com.njcn.device.pq.pojo.po.DevVersion;
import com.njcn.device.pq.pojo.vo.TerminalVersionVO;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * pqs
 * 终端程序版本管理
 * @author cdf
 * @date 2022/5/12
 */
@Slf4j
@Api(tags = "终端程序版本管理")
@RestController
@RequestMapping("/version")
@RequiredArgsConstructor
public class DeviceVersionController extends BaseController {

    private final TerminalVersionService terminalVersionService;

    /**
     * 查询终端程序版本主列表
     *
     * @author cdf
     * @date 2022/5/11
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTerminalVersionList")
    @ApiOperation("查询终端程序版本主列表")
    public HttpResult<List<TerminalVersionVO>> getTerminalVersionList(@RequestBody TerminalMainQueryParam terminalMainQueryParam) {
        String methodDescribe = getMethodDescribe("getTerminalVersionList");
        List<TerminalVersionVO> resList = terminalVersionService.getTerminalVersionList(terminalMainQueryParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe);
    }

    /**
     * 查询装置升级日志
     * @author cdf
     * @date 2022/5/17
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTerminalUpLog")
    @ApiOperation("查询终端程序版本升级日志")
    public HttpResult<List<DevVersion>> getTerminalUpLog(@RequestParam("id")String id) {
        String methodDescribe = getMethodDescribe("getTerminalUpLog");
        List<DevVersion> resList = terminalVersionService.getTerminalUpLog(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getDevVersionList")
    @ApiOperation("查询终端版本信息")
    public HttpResult<List<TerminalVersionVO.Version>> getVersionList(@RequestBody List<String> ids) {
        String methodDescribe = getMethodDescribe("getVersionList");
        List<TerminalVersionVO.Version> versionList = terminalVersionService.getVersionList(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, versionList, methodDescribe);
    }


}
