Commit e78f08fd by fudahua

sdk版本

parent 83299a7a
package com.gic.haoban.manage.web.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -26,6 +30,10 @@ public class ApplicationController extends WebBaseController{
private ApplicationApiService applicationApiService;
@Autowired
private ApplicationSettingApiService applicationSettingApiService;
private static final String SDKVERSION_KEY = "haoban-wx-sdk-version";
@RequestMapping("application-list")
public HaobanResponse applicationList(String wxEnterpriseId) {
......@@ -63,4 +71,37 @@ public class ApplicationController extends WebBaseController{
}
@RequestMapping("sdk-version-check")
public HaobanResponse sdkVersionCheck(String skdVersion) {
if (StringUtils.isBlank(skdVersion)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
Object cache = RedisUtil.getCache(SDKVERSION_KEY);
if (null == cache) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
String limitSdkVersion = cache.toString();
String[] limitSdk = limitSdkVersion.split(".");
String[] versionSplit = skdVersion.split(".");
int checkFlag = checkNum(Integer.valueOf(limitSdk[0]), Integer.valueOf(versionSplit[0]));
if (checkFlag != 0) {
return resultResponse(HaoBanErrCode.ERR_1, checkFlag > 0 ? true : false);
}
checkFlag = checkNum(Integer.valueOf(limitSdk[1]), Integer.valueOf(versionSplit[1]));
if (checkFlag != 0) {
return resultResponse(HaoBanErrCode.ERR_1, checkFlag > 0 ? true : false);
}
checkFlag = checkNum(Integer.valueOf(limitSdk[2]), Integer.valueOf(versionSplit[2]));
if (checkFlag != 0) {
return resultResponse(HaoBanErrCode.ERR_1, checkFlag > 0 ? true : false);
}
return resultResponse(HaoBanErrCode.ERR_1, true);
}
private int checkNum(int limit, int cur) {
return cur > limit ? 1 : (cur == limit ? 0 : -1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment