fix
Helius
2021-09-15 7ab7943de217a9e5d4a489c22c7ae27a29692d55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.xzx.gc.system.controller;
 
import cn.hutool.core.convert.Convert;
import com.xzx.gc.common.Result;
import com.xzx.gc.common.annotations.PassToken;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.constant.SysConfigConstant;
import com.xzx.gc.common.request.BaseController;
import com.xzx.gc.entity.VersionInfo;
import com.xzx.gc.system.mapper.VersionInfoMapper;
import com.xzx.gc.system.service.ConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * @author :zz
 */
@RestController
@Api(tags = {"版本管理"})
@Validated
public class VersionController extends BaseController {
 
 
    @Autowired
    private VersionInfoMapper versionInfoMapper;
 
    @Autowired
    private ConfigService configService;
 
 
    @PostMapping("/version/list")
    @ApiOperation(value = "查询更新")
    @PassToken
    public Result<VersionInfo> version(){
        /**
         * 根据是否有特殊需求可指定某个版本必须强制更新,如currentVersion == XXX,则forceUpdate = true;
         * 如果currentVersion < newVersion,则isUpdate = true;
         * 如果currentVersion < minVersion,则forceUpdate = true;
         * 如果currentVersion >= minVersion,则forceUpdate = false;
         * 如果currentVersion == newVersion,则isUpdate = false.
         */
        Result result=new Result();
//        Validator.validateNotEmpty(commonDto.getExtra(),"当前版本号不能为空");
//        Double currentVersion=Convert.toDouble(commonDto.getExtra());
//        if(currentVersion==null){
//            return Result.error(-1,"版本号不正确");
//        }
 
 
        VersionInfo versionInfo=new VersionInfo();
        versionInfo.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));
        VersionInfo versionInfo1 = versionInfoMapper.selectOne(versionInfo);
//        Double newVersion = versionInfo1.getNewVersion();
//        Double minVersion = versionInfo1.getMinVersion();
//
//        if(NumberUtil.compare(currentVersion,newVersion)<0){
//            versionInfo1.setUpdateFlag(Convert.toShort(Constants.RESULT_SUCCESS));
//        }
//        if(NumberUtil.compare(currentVersion,minVersion)<0) {
//            versionInfo1.setForceUpdateFlag(Convert.toShort(Constants.RESULT_SUCCESS));
//        }
        result.setData(versionInfo1);
        return result;
    }
 
 
    @PostMapping("/version/audit")
    @ApiOperation(value = "版本审核状态查询")
    @PassToken
    public Result<String> audit(){
        return Result.success(configService.findByCode(SysConfigConstant.IOSAPP_AUDIT_STATUS).getConfigValue());
    }
}