package com.sckw.system.controller;

import com.sckw.core.utils.StringUtils;
import com.sckw.core.web.response.HttpResult;
import com.sckw.system.model.vo.req.FindVersionListReqVo;
import com.sckw.system.service.SysAreaService;
import com.sckw.system.service.SysVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 版本管理
 * @author zk
 * @date 2023-05-30
 */
@RestController
@RequestMapping("/sysVersion")
public class SysVersionController {

    @Autowired
    private SysVersionService sysVersionService;

    /**
     * @param reqVo 入参
     * @return HttpResult
     * @desc: 查询版本管理列表
     * @author: czh
     * @date: 2023/10/10
     */
    @PostMapping("/findPage")
    public HttpResult findPage(@RequestBody FindVersionListReqVo reqVo,
                               @RequestHeader(value = "System-Type") Integer systemType,
                               @RequestHeader(value = "Client-Type") String clientType) {
        reqVo.setSystemType(systemType);
        if(StringUtils.isBlank(reqVo.getClientType())) {
            reqVo.setClientType(clientType);
        }
        return HttpResult.ok(sysVersionService.findPage(reqVo));
    }

    /**
     * @param clientType 客户端类型
     * @return HttpResult
     * @desc: 查最新的版本信息
     * @author: czh
     * @date: 2023/10/10
     */
    @GetMapping("/findLatestVersion")
    public HttpResult findLatestVersion(@RequestParam(value = "clientType", required = true) String clientType,
                                        @RequestParam(value = "systemType", required = true) Integer systemType) {
        return HttpResult.ok(sysVersionService.findLatestVersion(systemType, clientType));
    }

}
