app内更新
This commit is contained in:
@@ -2,9 +2,12 @@ package com.accompany.admin.service.system;
|
||||
|
||||
import com.accompany.admin.base.AbstractCoreService;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.GsonUtil;
|
||||
import com.accompany.core.base.BaseMapper;
|
||||
import com.accompany.business.model.AppVersion;
|
||||
import com.accompany.business.model.AppVersionExample;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.SysConf;
|
||||
import com.accompany.business.mybatismapper.AppVersionMapper;
|
||||
import com.accompany.business.service.AppVersionService;
|
||||
@@ -12,18 +15,20 @@ import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.business.util.ReplaceDomainUtil;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.gson.Gson;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by PaperCut on 2018/1/20.
|
||||
@@ -35,22 +40,15 @@ import java.util.List;
|
||||
@Service
|
||||
public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppVersionExample>{
|
||||
@Autowired
|
||||
AppVersionMapper appVersionMapper;
|
||||
|
||||
private AppVersionMapper appVersionMapper;
|
||||
@Autowired
|
||||
SysConfService sysConfService;
|
||||
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
JedisService jedisService;
|
||||
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
AppVersionService appVersionService;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
public static final String force_type = "force";
|
||||
public static final String suggest_type = "suggest";
|
||||
public static final String online_type = "online";
|
||||
private AppVersionService appVersionService;
|
||||
@Autowired
|
||||
private SysConfAdminService sysConfNacosAdminService;
|
||||
|
||||
public PageInfo<AppVersion> getVersionByPage(int page, int size, String os, String platform, String version) {
|
||||
PageHelper.startPage(page, size);
|
||||
@@ -71,34 +69,18 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
return new PageInfo<>(appVersionList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeInsert(AppVersion entity) {
|
||||
entity.setCreateTime(new Date());
|
||||
return super.beforeInsert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getId(AppVersion entity) {
|
||||
return entity.getVersionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseMapper<AppVersion, AppVersionExample> getMapper() {
|
||||
return appVersionMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新状态
|
||||
* @param ids
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
private int updateStatusByIds(List<Integer> ids, byte status)
|
||||
{
|
||||
private int updateStatusByIds(List<Integer> ids, byte status) {
|
||||
AppVersionExample example = new AppVersionExample();
|
||||
example.createCriteria().andVersionIdIn(ids);
|
||||
AppVersion appVersion = new AppVersion();
|
||||
appVersion.setStatus(status);
|
||||
appVersion.setUpdateTime(new Date());
|
||||
return appVersionMapper.updateByExampleSelective(appVersion, example);
|
||||
}
|
||||
|
||||
@@ -107,8 +89,7 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
public int countByStatus(byte status, String platform)
|
||||
{
|
||||
public int countByStatus(byte status, String platform) {
|
||||
AppVersionExample example = new AppVersionExample();
|
||||
example.createCriteria().andStatusEqualTo(status).andPlatformEqualTo(platform);
|
||||
return appVersionMapper.countByExample(example);
|
||||
@@ -119,8 +100,7 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int resetAudit(Integer id, String operator)
|
||||
{
|
||||
public int resetAudit(Integer id, String operator) {
|
||||
AppVersion appVersion = appVersionMapper.selectByPrimaryKey(id);
|
||||
if(appVersion == null) {
|
||||
throw new BusinessException("未找到该版本");
|
||||
@@ -129,17 +109,16 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
throw new BusinessException("已存在审核状态中的版本记录.请修改后再试");
|
||||
}
|
||||
|
||||
if(appVersion != null) {
|
||||
// 更新指定id的版本状态为审核中
|
||||
int result = updateStatusById(id, Constant.AppVersion.audit);
|
||||
if (result > 0) {
|
||||
// 更改系统配置的审核版本
|
||||
//sysConfService.setConfValueById(appVersionService.getAuditingVersionKey(appVersion.getPlatform()), appVersion.getVersion(), operator);
|
||||
// 更新版本中的缓存
|
||||
String key = appVersionService.getAppVersionKey(appVersion.getVersion(), appVersion.getOs(), appVersion.getPlatform());
|
||||
jedisService.hdel(RedisKey.app_version.getKey(), key);
|
||||
return result;
|
||||
}
|
||||
// 更新指定id的版本状态为审核中
|
||||
List<Integer> ids = Collections.singletonList(id);
|
||||
int result = updateStatusByIds(ids, Constant.AppVersion.audit);
|
||||
if (result > 0) {
|
||||
// 更改系统配置的审核版本
|
||||
//sysConfService.setConfValueById(appVersionService.getAuditingVersionKey(appVersion.getPlatform()), appVersion.getVersion(), operator);
|
||||
// 更新版本中的缓存
|
||||
String key = appVersionService.getAppVersionKey(appVersion.getVersion(), appVersion.getOs(), appVersion.getPlatform());
|
||||
jedisService.hdel(RedisKey.app_version.getKey(), key);
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -177,131 +156,124 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id更新状态
|
||||
* @param id
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
private int updateStatusById(Integer id, byte status)
|
||||
{
|
||||
AppVersionExample example = new AppVersionExample();
|
||||
example.createCriteria().andVersionIdEqualTo(id);
|
||||
AppVersion appVersion = new AppVersion();
|
||||
appVersion.setStatus(status);
|
||||
return appVersionMapper.updateByExampleSelective(appVersion, example);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量重置状态(只支持强制更新和建议更新)
|
||||
* @param type
|
||||
* @param status
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public int resetStatus(String type, List<Integer> ids) {
|
||||
int result = 0;
|
||||
if(force_type.equalsIgnoreCase(type)) {
|
||||
// 设置为强制更新
|
||||
result = updateStatusByIds(ids, Constant.AppVersion.forceupdate);
|
||||
} else if(suggest_type.equalsIgnoreCase(type)) {
|
||||
// 设置为建议更新
|
||||
result = updateStatusByIds(ids, Constant.AppVersion.recommupdate);
|
||||
}else if(online_type.equalsIgnoreCase(type)) {
|
||||
// 设置线上版本
|
||||
result = updateStatusByIds(ids, Constant.AppVersion.online);
|
||||
}
|
||||
if(result>0){
|
||||
appVersionService.cleanCache();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(AppVersion entity, boolean isEdit, boolean isSelective) {
|
||||
if(Constant.AppVersion.audit.equals(entity.getStatus())) {
|
||||
if(checkHasAudit(entity.getVersionId(),entity.getPlatform())) {
|
||||
throw new BusinessException("已存在审核状态中的版本记录.请修改后再试");
|
||||
public int resetStatus(Byte status, List<Integer> ids) {
|
||||
AppVersionExample example = new AppVersionExample();
|
||||
example.createCriteria().andVersionIdIn(ids);
|
||||
List<AppVersion> dbList = appVersionMapper.selectByExample(example);
|
||||
//更新状态在同一个os和channel分组下只能由一个
|
||||
if (isNeedUpdateStatus(status)){
|
||||
Optional<List<AppVersion>> optional = dbList.stream().collect(Collectors.groupingBy(v->String.format("%s_%s",v.getOs(),v.getPlatform())))
|
||||
.values().stream().filter(l->l.size() >1).findFirst();
|
||||
if (optional.isPresent()){
|
||||
String versonIds = optional.get().stream().map(AppVersion::getVersionId).map(Object::toString).collect(Collectors.joining("和"));
|
||||
throw new ServiceException(String.format("%s的状态冲突了", versonIds));
|
||||
}
|
||||
}
|
||||
|
||||
// 如果之前版本是审核中版本,则去除当前审核版本
|
||||
AppVersion beforeVersion = get(entity.getVersionId());
|
||||
if(beforeVersion != null && Constant.AppVersion.audit.equals(beforeVersion.getStatus())) {
|
||||
//sysConfService.setConfValueById(appVersionService.getAuditingVersionKey(entity.getPlatform()), "");
|
||||
int result = 0;
|
||||
for (AppVersion data: dbList){
|
||||
data.setStatus(status);
|
||||
result += save(data);
|
||||
}
|
||||
|
||||
int result = super.save(entity, isEdit, isSelective);
|
||||
// 更新配置中的审核版本
|
||||
if(Constant.AppVersion.audit.equals(entity.getStatus())) {
|
||||
//sysConfService.setConfValueById(appVersionService.getAuditingVersionKey(entity.getPlatform()), entity.getVersion());
|
||||
}
|
||||
|
||||
// 更新版本中的缓存
|
||||
String key = appVersionService.getAppVersionKey(entity.getVersion(), entity.getOs(), entity.getPlatform());
|
||||
jedisService.hset(RedisKey.app_version.getKey(), key, gson.toJson(entity));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Object id) {
|
||||
AppVersion appVersion = get(id);
|
||||
if(appVersion != null) {
|
||||
int result = super.delete(id);
|
||||
if(result > 0){
|
||||
if(Constant.AppVersion.audit.equals(appVersion.getStatus())) {
|
||||
//sysConfService.setConfValueById(appVersionService.getAuditingVersionKey(appVersion.getPlatform()), "");
|
||||
public void afterInsert(AppVersion entity) {
|
||||
jedisService.hset(RedisKey.app_version.getKey(),
|
||||
appVersionService.getAppVersionKey(entity.getVersion(), entity.getOs(), entity.getPlatform()), GsonUtil.getGson().toJson(entity));
|
||||
updateOtherStatus(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterUpdate(AppVersion entity) {
|
||||
jedisService.hset(RedisKey.app_version.getKey(),
|
||||
appVersionService.getAppVersionKey(entity.getVersion(), entity.getOs(), entity.getPlatform()), GsonUtil.getGson().toJson(entity));
|
||||
updateOtherStatus(entity);
|
||||
}
|
||||
|
||||
private void updateOtherStatus(AppVersion entity){
|
||||
String newestKey = appVersionService.getNewestVersionKey(entity.getOs(), entity.getPlatform());
|
||||
SysConf oldSysConf = sysConfNacosAdminService.getSysConfById(newestKey);
|
||||
if (null == oldSysConf || !oldSysConf.getConfigValue().equalsIgnoreCase(entity.getVersion())){
|
||||
if (isNeedUpdateStatus(entity.getStatus())){
|
||||
try {
|
||||
SysConf sysConf = new SysConf();
|
||||
sysConf.setConfigId(newestKey);
|
||||
sysConf.setConfigName(newestKey);
|
||||
sysConf.setConfigValue(entity.getVersion());
|
||||
sysConf.setNameSpace(Constant.SysConfId.newest_version);
|
||||
sysConf.setConfigStatus(Constant.StatusV2.valid);
|
||||
sysConfNacosAdminService.saveOrUpdate(sysConf);
|
||||
} catch (NacosException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
AppVersion updateEntity = new AppVersion();
|
||||
updateEntity.setStatus(Constant.AppVersion.online);
|
||||
|
||||
AppVersionExample example = new AppVersionExample();
|
||||
example.createCriteria().andOsEqualTo(entity.getOs()).andPlatformEqualTo(entity.getPlatform())
|
||||
.andVersionNotEqualTo(entity.getVersion())
|
||||
.andStatusIn(Arrays.asList(Constant.AppVersion.forceupdate, Constant.AppVersion.recommupdate));
|
||||
List<AppVersion> otherList = appVersionMapper.selectByExample(example);
|
||||
if (!CollectionUtils.isEmpty(otherList)){
|
||||
appVersionMapper.updateByExampleSelective(updateEntity, example);
|
||||
for (AppVersion o: otherList){
|
||||
jedisService.hdel(RedisKey.app_version.getKey(),
|
||||
appVersionService.getAppVersionKey(o.getVersion(), o.getOs(), o.getPlatform()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 清除缓存
|
||||
String key = appVersionService.getAppVersionKey(appVersion.getVersion(), appVersion.getOs(), appVersion.getPlatform());
|
||||
jedisService.hset(RedisKey.app_version.getKey(), key, "");
|
||||
|
||||
return result;
|
||||
} else if (!isNeedUpdateStatus(entity.getStatus())){//当前最新版本是它
|
||||
try {
|
||||
List<String> sysConfIdList = Arrays.asList(newestKey);
|
||||
sysConfNacosAdminService.delByIds(sysConfIdList);
|
||||
} catch (NacosException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<String> getPlatform(String os){
|
||||
List<String> platformLits = null;
|
||||
if(os!=null&&Constant.OsType.IOS.equalsIgnoreCase(os)){
|
||||
//IOS
|
||||
SysConf sysConf = sysConfService.getSysConfById(Constant.SysConfId.ios_platform);
|
||||
List<String> platformLits = new ArrayList<>();
|
||||
|
||||
List<String> sysConfIds = new ArrayList<>();
|
||||
sysConfIds.add(Constant.SysConfId.ios_platform);
|
||||
sysConfIds.add(Constant.SysConfId.android_platform);
|
||||
if(Constant.OsType.IOS.equalsIgnoreCase(os)){
|
||||
sysConfIds.remove(Constant.SysConfId.android_platform);
|
||||
}else if(Constant.OsType.ANDROID.equalsIgnoreCase(os)){
|
||||
sysConfIds.remove(Constant.SysConfId.ios_platform);
|
||||
}
|
||||
|
||||
for (String sysConfId: sysConfIds){
|
||||
SysConf sysConf = sysConfService.getSysConfById(sysConfId);
|
||||
String conVal = cleanEnter(sysConf.getConfigValue());
|
||||
String[] platformLitArray = conVal==null?null:conVal.split(",");
|
||||
platformLits = new ArrayList<>(Arrays.asList(platformLitArray));
|
||||
}else if(os!=null&&Constant.OsType.ANDROID.equalsIgnoreCase(os)){
|
||||
//ANDROID
|
||||
SysConf sysConf = sysConfService.getSysConfById(Constant.SysConfId.android_platform);
|
||||
String conVal = cleanEnter(sysConf.getConfigValue());
|
||||
String[] platformLitArray = conVal==null?null:conVal.split(",");
|
||||
platformLits = new ArrayList<>(Arrays.asList(platformLitArray));
|
||||
}else{
|
||||
//全部
|
||||
SysConf iosConf = sysConfService.getSysConfById(Constant.SysConfId.ios_platform);
|
||||
String iosConVal = cleanEnter(iosConf.getConfigValue());
|
||||
String[] iosArray = iosConVal==null?null:iosConVal.split(",");
|
||||
SysConf androidConf = sysConfService.getSysConfById(Constant.SysConfId.android_platform);
|
||||
String androidConVal = cleanEnter(androidConf.getConfigValue());
|
||||
String[] androidArray = androidConVal==null?null:androidConVal.split(",");
|
||||
platformLits = new ArrayList<>();
|
||||
platformLits.addAll(Arrays.asList(iosArray));
|
||||
platformLits.addAll(Arrays.asList(androidArray));
|
||||
if (StringUtils.isNotBlank(conVal)){
|
||||
platformLits.addAll(Arrays.asList(conVal.split(",")));
|
||||
}
|
||||
}
|
||||
return platformLits;
|
||||
}
|
||||
|
||||
public int deleteIds(Object[] ids, String operator) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteIds(Object[] ids) throws NacosException {
|
||||
int count = 0;
|
||||
List<String> sysConfIdList = new ArrayList<>();
|
||||
for(Object id : ids){
|
||||
AppVersion appVersion = get(id);
|
||||
if(appVersion != null) {
|
||||
int result = super.delete(id);
|
||||
count += result;
|
||||
if(result > 0){
|
||||
if(Constant.AppVersion.audit.equals(appVersion.getStatus())) {
|
||||
//sysConfService.setConfValueById(appVersionService.getAuditingVersionKey(appVersion.getPlatform()), "", operator);
|
||||
if(isNeedUpdateStatus(appVersion.getStatus())) {
|
||||
sysConfIdList.add(appVersionService.getNewestVersionKey(appVersion.getOs(), appVersion.getPlatform()));
|
||||
}
|
||||
// 清除缓存
|
||||
String key = appVersionService.getAppVersionKey(appVersion.getVersion(), appVersion.getOs(), appVersion.getPlatform());
|
||||
@@ -310,9 +282,36 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(sysConfIdList)){
|
||||
sysConfNacosAdminService.delByIds(sysConfIdList);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeInsert(AppVersion entity) {
|
||||
Date now = new Date();
|
||||
entity.setCreateTime(now);
|
||||
entity.setUpdateTime(now);
|
||||
return super.beforeInsert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeUpdate(AppVersion entity) {
|
||||
entity.setUpdateTime(new Date());
|
||||
return super.beforeUpdate(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getId(AppVersion entity) {
|
||||
return entity.getVersionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseMapper<AppVersion, AppVersionExample> getMapper() {
|
||||
return appVersionMapper;
|
||||
}
|
||||
|
||||
private String cleanEnter(String str){
|
||||
if(str == null){
|
||||
return str;
|
||||
@@ -321,5 +320,9 @@ public class AppVersionAdminService extends AbstractCoreService<AppVersion, AppV
|
||||
str = str.replaceAll("\r","");
|
||||
return str;
|
||||
}
|
||||
|
||||
private boolean isNeedUpdateStatus(Byte status){
|
||||
return Constant.AppVersion.forceupdate.equals(status) || Constant.AppVersion.recommupdate.equals(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,9 @@ public class SysConfAdminService extends SysConfService {
|
||||
List<SysConf> sysConfs = getRealTimeSysConfs();
|
||||
List<SysConf> filteredConfs = sysConfs.stream().filter(conf -> !configIds.contains(conf.getConfigId())).collect(Collectors.toList());
|
||||
|
||||
publishConfig2Nacos(filteredConfs);
|
||||
if (sysConfs.size() > filteredConfs.size()){
|
||||
publishConfig2Nacos(filteredConfs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.accompany.admin.controller.system;
|
||||
|
||||
import com.accompany.common.config.SystemConfig;
|
||||
import com.accompany.common.utils.GsonUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
@@ -10,7 +11,6 @@ import com.accompany.admin.service.system.AdminUserService;
|
||||
import com.accompany.admin.service.system.AppVersionAdminService;
|
||||
import com.accompany.admin.util.AdminUtil;
|
||||
import com.accompany.business.model.AppVersion;
|
||||
import com.accompany.business.service.AppVersionService;
|
||||
import com.accompany.business.service.SendSysMsgService;
|
||||
import com.accompany.business.service.api.QinniuService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
@@ -18,14 +18,11 @@ import com.accompany.business.vo.EditVersionVo;
|
||||
import com.accompany.business.vo.UploadFileInfoVo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.accompany.common.constant.Attach;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -53,27 +50,18 @@ import java.util.concurrent.CountDownLatch;
|
||||
@RequestMapping("/admin/version")
|
||||
public class AppVersionAdminController extends BaseController {
|
||||
@Autowired
|
||||
AppVersionAdminService appVersionAdminService;
|
||||
|
||||
private AppVersionAdminService appVersionAdminService;
|
||||
@Autowired
|
||||
private QinniuService qiuniuService;
|
||||
|
||||
@Autowired
|
||||
private AppVersionService appVersionService;
|
||||
|
||||
@Autowired
|
||||
private SendSysMsgService sendSysMsgService;
|
||||
@Resource(name = "bizExecutor")
|
||||
private TaskExecutor bizExecutor;
|
||||
|
||||
@Autowired
|
||||
private AdminUserService adminUserService;
|
||||
@Autowired
|
||||
private AdminLogService adminLogService;
|
||||
|
||||
|
||||
private final static Gson gson = new Gson();
|
||||
|
||||
@RequestMapping(value = "getList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public void getList(String os, String platform, String version) {
|
||||
@@ -93,14 +81,15 @@ public class AppVersionAdminController extends BaseController {
|
||||
throw new BusinessException("未选择平台");
|
||||
}
|
||||
int adminId = getAdminId();
|
||||
AdminUser adminUser = adminUserService.getAdminUserById(adminId);
|
||||
int result = appVersionService.batchSave(versionVo, adminUser.getUsername());
|
||||
//AdminUser adminUser = adminUserService.getAdminUserById(adminId);
|
||||
//int result = appVersionService.batchSave(versionVo, adminUser.getUsername());
|
||||
int result = appVersionAdminService.save(versionVo);
|
||||
adminLogService.insertLog(adminId, getClass().getCanonicalName(), "save", "params===>>" + JSONObject.toJSONString(versionVo));
|
||||
if (result > 0) {
|
||||
writeJson(true, "保存成功");
|
||||
return;
|
||||
}
|
||||
} catch (com.accompany.common.exception.BusinessException e) {
|
||||
} catch (BusinessException e) {
|
||||
writeJson(false, e.getMessage());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
@@ -120,8 +109,7 @@ public class AppVersionAdminController extends BaseController {
|
||||
}
|
||||
try {
|
||||
int adminId = getAdminId();
|
||||
AdminUser adminUser = adminUserService.getAdminUserById(adminId);
|
||||
int result = appVersionAdminService.deleteIds(ids.toArray(new Integer[]{}), adminUser.getUsername());
|
||||
int result = appVersionAdminService.deleteIds(ids.toArray(new Integer[]{}));
|
||||
adminLogService.insertLog(adminId, getClass().getCanonicalName(), "del", "params===>>ids:" + ids.toString());
|
||||
if (result > 0) {
|
||||
writeJson(true, "删除成功");
|
||||
@@ -130,20 +118,45 @@ public class AppVersionAdminController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to delete appVersion, Cause by {}", e.getCause().getMessage());
|
||||
}
|
||||
writeJson(false, "删除失败");
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "get", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public void get(@RequestParam("id") Integer id) {
|
||||
if (null == id){
|
||||
writeJson(false, "参数有误");
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
AppVersion appVersion = appVersionAdminService.get(id);
|
||||
if (appVersion != null) {
|
||||
jsonObject.put("entity", new EditVersionVo(appVersion));
|
||||
jsonObject.put("entity", appVersion);
|
||||
}
|
||||
writeJson(jsonObject.toJSONString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 置为强制更新或建议更新
|
||||
*
|
||||
* @param type
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "resetStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void resetStatus(@RequestParam("type") Byte type, HttpServletRequest request) {
|
||||
List<Integer> ids = getRequestArray(request, "ids", Integer.class);
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
writeJson(false, "参数有误");
|
||||
return;
|
||||
}
|
||||
int result = appVersionAdminService.resetStatus(type, ids);
|
||||
if (result > 0) {
|
||||
writeJson(true, "设置成功");
|
||||
return;
|
||||
}
|
||||
writeJson(false, "设置失败");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "resetAudit", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@@ -167,32 +180,6 @@ public class AppVersionAdminController extends BaseController {
|
||||
writeJson(false, "设置失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 置为强制更新或建议更新
|
||||
*
|
||||
* @param type
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "resetStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void resetStatus(@RequestParam("type") String type, HttpServletRequest request) {
|
||||
List<Integer> ids = getRequestArray(request, "ids", Integer.class);
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
writeJson(false, "参数有误");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int result = appVersionAdminService.resetStatus(type, ids);
|
||||
if (result > 0) {
|
||||
writeJson(true, "设置成功");
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to updateStatus, Cause by {}", e.getCause().getMessage());
|
||||
}
|
||||
writeJson(false, "设置失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据系统获取渠道信息
|
||||
*
|
||||
@@ -270,7 +257,7 @@ public class AppVersionAdminController extends BaseController {
|
||||
}
|
||||
}
|
||||
latch.await();
|
||||
writeJson(gson.toJson(returnList));
|
||||
writeJson(GsonUtil.getGson().toJson(returnList));
|
||||
}
|
||||
|
||||
private Map<String, Object> writeFileToLocal(MultipartFile uploadFile, HttpServletRequest request, String fileName) {
|
||||
@@ -311,7 +298,7 @@ public class AppVersionAdminController extends BaseController {
|
||||
Attach attach = new Attach();
|
||||
attach.setFirst(Constant.DefMsgType.Version);
|
||||
attach.setSecond(Constant.DefMsgType.ForceUpdateVersion);
|
||||
sendSysMsgService.broadCastMsg(SystemConfig.secretaryUid, gson.toJson(attach));
|
||||
sendSysMsgService.broadCastMsg(SystemConfig.secretaryUid, GsonUtil.getGson().toJson(attach));
|
||||
writeJson(true, "推送成功");
|
||||
|
||||
}
|
||||
|
@@ -23,10 +23,9 @@
|
||||
<option value="android">安卓</option>
|
||||
</select>
|
||||
</div>
|
||||
<label for="version" class="qry_col control-label">平台:</label>
|
||||
<label for="version" class="qry_col control-label">渠道:</label>
|
||||
<div class="col-sm-2">
|
||||
<select name="platform" id="platform_query" class="form-control" data-btn-class="btn-warning">
|
||||
</select>
|
||||
<select name="platform" id="platform_query" class="form-control" data-btn-class="btn-warning"></select>
|
||||
</div>
|
||||
<label for="version" class="qry_col control-label">版本号:</label>
|
||||
<div class="col-sm-2"><input type="text" class="form-control" name="version" id="version_query"></div>
|
||||
@@ -56,7 +55,7 @@
|
||||
<i class="glyphicon glyphicon-wrench"></i>置为线上版本
|
||||
</button>
|
||||
|
||||
<button class="btn btn-danger" id='sendVersionMsg'>推送强更全服广播</button>
|
||||
<!--<button class="btn btn-danger" id='sendVersionMsg'>推送强更全服广播</button>-->
|
||||
</div>
|
||||
</div>
|
||||
</section><!-- .content -->
|
||||
@@ -83,11 +82,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="platform" class="col-sm-2 control-label">平台:</label>
|
||||
<label for="platform" class="col-sm-2 control-label">渠道:</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="hidden" name="old_platform" id="old_platform"/>
|
||||
<select name="platform" id="platform" class="selectpicker show-tick form-control" multiple data-live-search="false" data-btn-class="btn-warning">
|
||||
</select>
|
||||
<select name="platform" id="platform" class="form-control selectpicker show-tick" data-live-search="false" data-btn-class="btn-warning"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -100,8 +98,8 @@
|
||||
<label for="status" class="col-sm-2 control-label">状态:</label>
|
||||
<div class="col-sm-10">
|
||||
<select name="status" id="status" class="form-control" data-btn-class="btn-warning">
|
||||
<option value="1">线上版本</option>
|
||||
<option value="2">审核中版本</option>
|
||||
<option value="1" selected="selected">线上版本</option>
|
||||
<option value="2">未上线版本</option>
|
||||
<option value="3">强制更新版本</option>
|
||||
<option value="4">建议更新版本</option>
|
||||
<option value="5">已删除版本</option>
|
||||
@@ -118,7 +116,7 @@
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="form-group">
|
||||
<label for="versionDesc" class="col-sm-2 control-label">版本描述:</label>
|
||||
<label for="versionDesc" class="col-sm-2 control-label">更新说明:</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea name="versionDesc" id="versionDesc" class="form-control" rows="3" placeholder="Enter ..."></textarea>
|
||||
</div>
|
||||
@@ -130,23 +128,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-left: -70px;">
|
||||
<label for="uploadFile" class="col-sm-3 control-label">安装包:</label>
|
||||
<div class="col-sm-10" style="float: inherit;">
|
||||
<input type="file" id="uploadFile" name="uploadFile" multiple="multiple" onchange="checkFile()">
|
||||
<button class="btn btn-success" type="button" id="uploadBtn">上传</button>
|
||||
</div>
|
||||
|
||||
<input type="text" name="fileMd5" id="fileMd5" style="display: none;">
|
||||
<input type="text" name="fileInfo" id="fileInfo" style="display: none;">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="publishTime" class="col-sm-2 control-label"></label>
|
||||
<label for="downloadLink" class="col-sm-2 control-label">下载链接:</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea autoHeight="true" disabled="disabled" style="width: 630px;" id="downloadLink" />
|
||||
<textarea autoHeight="true" id="downloadLink" name="downloadLink" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -186,11 +173,12 @@
|
||||
$('#table').bootstrapTable('destroy');
|
||||
initTable();
|
||||
});
|
||||
|
||||
setSelectOption("platform_query",$("#os_query"));
|
||||
|
||||
$("#table").on("click", '.opt-remove', function () {
|
||||
var id = $(this).attr("data-id");
|
||||
if(id == 'undefined')
|
||||
{
|
||||
if(id == 'undefined') {
|
||||
$("#tipMsg").text("id参数有误");
|
||||
$("#tipModal").modal('show');
|
||||
return;
|
||||
@@ -224,15 +212,10 @@
|
||||
$("#id").val(0);
|
||||
$("#old_platform").val("");
|
||||
$("#downloadLink").val("");
|
||||
$("#downloadLink").hide();
|
||||
$("#uploadFile").val("");
|
||||
$("#fileMd5").val("");
|
||||
$('#fileInfo').val("");
|
||||
$("#os").removeAttr("disabled","disabled");
|
||||
$("#version").removeAttr("disabled","disabled");
|
||||
$("#platform").removeAttr("disabled","disabled");
|
||||
$('#save').attr("disabled",false);
|
||||
$('#uploadBtn').attr("disabled",false);
|
||||
setSelectOption("platform",$("#os"));
|
||||
});
|
||||
|
||||
@@ -275,8 +258,7 @@
|
||||
|
||||
$("#resetSuggeestUpdate").click(function(){
|
||||
var rows = $("#table").bootstrapTable("getSelections");
|
||||
if(rows.length == 0)
|
||||
{
|
||||
if(rows.length == 0) {
|
||||
alert("请先选择要更新的记录");
|
||||
return;
|
||||
}
|
||||
@@ -289,7 +271,7 @@
|
||||
console.log(idArr);
|
||||
|
||||
if (confirm("你确认重置所选记录的状态为[建议更新版本]吗?")) {
|
||||
reqUpdateStatus(idArr, 'suggest');
|
||||
reqUpdateStatus(idArr, 4);
|
||||
}
|
||||
|
||||
})
|
||||
@@ -311,7 +293,7 @@
|
||||
console.log(idArr);
|
||||
|
||||
if (confirm("你确认重置所选记录的状态为[强制更新版本]吗?")) {
|
||||
reqUpdateStatus(idArr, 'force');
|
||||
reqUpdateStatus(idArr, 3);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -332,25 +314,23 @@
|
||||
console.log(idArr);
|
||||
|
||||
if (confirm("你确认重置所选记录的状态为[线上版本]吗?")) {
|
||||
reqUpdateStatus(idArr, 'online');
|
||||
reqUpdateStatus(idArr, 1);
|
||||
}
|
||||
})
|
||||
|
||||
function reqUpdateStatus(idArr, type)
|
||||
{
|
||||
function reqUpdateStatus(idArr, type) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "/admin/version/resetStatus.action",
|
||||
data: {'ids': JSON.stringify(idArr), 'type': type},
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if(json.success == 'true')
|
||||
{
|
||||
if(json.success == 'true') {
|
||||
$("#tipMsg").text("重置成功");
|
||||
$("#tipModal").modal('show');
|
||||
TableHelper.doRefresh("#table");
|
||||
} else {
|
||||
$("#tipMsg").text("重置失败");
|
||||
$("#tipMsg").text(json.message);
|
||||
$("#tipModal").modal('show');
|
||||
}
|
||||
}
|
||||
@@ -403,7 +383,6 @@
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if(json.entity){
|
||||
debugger;
|
||||
var publishDate = new Date(json.entity.publishTime).format("yyyy-MM-dd hh:mm:ss");
|
||||
$("#versionId").val(json.entity.versionId);
|
||||
$("#os").val(json.entity.os.toLowerCase());
|
||||
@@ -413,27 +392,16 @@
|
||||
$("#description").val(json.entity.description);
|
||||
$("#status").val(json.entity.status);
|
||||
ComboboxHelper.setDef("#status",json.entity.status);
|
||||
setSelectOption("platform",$("#os"));
|
||||
$("#publishTime").val(publishDate);
|
||||
$("#downloadLink").val(json.entity.downloadLink);
|
||||
if(!json.entity.downloadLink){
|
||||
$("#downloadLink").hide();
|
||||
}else{
|
||||
$("#downloadLink").show();
|
||||
$("#downloadLink").css('height','28px');
|
||||
}
|
||||
$("#fileMd5").val(json.entity.fileMd5);
|
||||
$('#fileInfo').val(json.entity.fileInfo);
|
||||
$("#uploadFile").val("");
|
||||
$('#save').attr("disabled",false);
|
||||
$('#uploadBtn').attr("disabled",false);
|
||||
// 打开编辑弹窗
|
||||
$("#versionModal").modal('show');
|
||||
}else{
|
||||
$("#tipMsg").text("获取菜单信息出错");
|
||||
$("#tipModal").modal('show');
|
||||
}
|
||||
debugger;
|
||||
setSelectOption("platform",$("#os"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -441,7 +409,7 @@
|
||||
|
||||
$("#save").click(function(){
|
||||
if($("#versionForm").validationEngine('validate')){
|
||||
checkFile();
|
||||
//checkFile();
|
||||
$("#os").removeAttr("disabled","disabled");
|
||||
$("#version").removeAttr("disabled","disabled");
|
||||
$("#platform").removeAttr("disabled","disabled");
|
||||
@@ -468,7 +436,7 @@
|
||||
});
|
||||
|
||||
|
||||
$("#sendVersionMsg").click(function(){
|
||||
/*$("#sendVersionMsg").click(function(){
|
||||
if (confirm("你确认要推送强制更新全服广播吗?")) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
@@ -485,11 +453,10 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});*/
|
||||
});
|
||||
|
||||
function setSelectOption(id,obj){
|
||||
debugger;
|
||||
var os = $(obj).val();
|
||||
var channel = $("#old_"+id).val();
|
||||
$.ajax({
|
||||
@@ -516,7 +483,6 @@
|
||||
function makeOption(id,data,channel){
|
||||
console.log("id="+id+",channel="+channel);
|
||||
var str = "";
|
||||
debugger;
|
||||
if(id.indexOf("_query")>-1){
|
||||
str = '<option value=""> 全部'+'</option>'
|
||||
}
|
||||
@@ -534,45 +500,48 @@
|
||||
{field: 'versionId', title: 'id', align: 'center', width: '5%'},
|
||||
{field: 'os', title: '系统', align: 'center', width: '5%'},
|
||||
{field: 'version', title: '版本号', align: 'center', width: '10%'},
|
||||
{field: 'platform', title: '平台', align: 'center', width: '10%'},
|
||||
{field: 'platform', title: '渠道', align: 'center', width: '10%'},
|
||||
{field: 'status', title: '状态', align: 'center', width: '15%', formatter: function (val, row, index) {
|
||||
if (val == 1) {
|
||||
return '线上版本';
|
||||
return '<color="green">线上版本</color>';
|
||||
}
|
||||
else if (val == 2) {
|
||||
return '审核中版本';
|
||||
return '未上线版本';
|
||||
}
|
||||
else if (val == 3) {
|
||||
return '强制更新版本';
|
||||
return '<color="red">强制更新版本</color>';
|
||||
}
|
||||
else if (val == 4) {
|
||||
return '建议更新版本';
|
||||
return '<color="yellow">建议更新版本</color>';
|
||||
}
|
||||
else if (val == 5) {
|
||||
return '已删除版本';
|
||||
}
|
||||
}
|
||||
},
|
||||
{field: 'downloadLink', title: '下载链接', align: 'center', width: '15%'},
|
||||
{field: 'publishTime', title: '发布时间', align: 'center', width: '15%', formatter:function(val,row, index){
|
||||
{field: 'downloadLink', title: '跳转链接', align: 'center', width: '15%'},
|
||||
{field: 'publishTime', title: '发布时间', align: 'center', width: '10%', formatter:function(val,row, index){
|
||||
var newDate = new Date();
|
||||
newDate.setTime(val);
|
||||
return newDate.toLocaleString();
|
||||
}
|
||||
},
|
||||
{field: 'createTime', title: '创建时间', align: 'center', width: '15%', formatter:function(val,row, index){
|
||||
{field: 'createTime', title: '创建时间', align: 'center', width: '10%', formatter:function(val,row, index){
|
||||
var newDate = new Date();
|
||||
newDate.setTime(val);
|
||||
return newDate.toLocaleString();
|
||||
}
|
||||
},
|
||||
{field: 'updateTime', title: '更新时间', align: 'center', width: '10%', formatter:function(val,row, index){
|
||||
var newDate = new Date();
|
||||
newDate.setTime(val);
|
||||
return newDate.toLocaleString();
|
||||
}
|
||||
},
|
||||
{field: 'versionId', title: '操作', align: 'center', width: '25%', formatter: function(val, row, index){
|
||||
return '<button class="btn btn-sm btn-success opt-edit" data-id=' + val + '>' +
|
||||
'<i class="glyphicon glyphicon-edit"></i>编辑</button>' +
|
||||
' <button class="btn btn-sm btn-danger opt-remove" data-id=' + val +
|
||||
'><i class="glyphicon glyphicon-remove"></i>删除</button>' +
|
||||
' <button class="btn btn-sm btn-success opt-reset" data-id=' + val +
|
||||
'><i class="glyphicon glyphicon-remove"></i>置为审核中</button>';
|
||||
return '<button class="btn btn-sm btn-success opt-edit" data-id=' + val + '><i class="glyphicon glyphicon-edit"></i>编辑</button> ' +
|
||||
'<button class="btn btn-sm btn-danger opt-remove" data-id=' + val + '><i class="glyphicon glyphicon-remove"></i>删除</button> ';
|
||||
/*+ '<button class="btn btn-sm btn-success opt-reset" data-id=' + val + '><i class="glyphicon glyphicon-remove"></i>置为审核中</button>';*/
|
||||
}}
|
||||
],
|
||||
cache: false,
|
||||
|
@@ -18,11 +18,13 @@ public class AppVersion {
|
||||
|
||||
private String fileMd5;
|
||||
|
||||
private String versionDesc;
|
||||
|
||||
private Date publishTime;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private String versionDesc;
|
||||
private Date updateTime;
|
||||
|
||||
public Integer getVersionId() {
|
||||
return versionId;
|
||||
@@ -103,4 +105,12 @@ public class AppVersion {
|
||||
public void setVersionDesc(String versionDesc) {
|
||||
this.versionDesc = versionDesc == null ? null : versionDesc.trim();
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
@@ -13,7 +13,9 @@ import com.accompany.common.exception.BusinessException;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.AppVersionUtil;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.common.utils.GsonUtil;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.base.BaseService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
@@ -40,12 +42,10 @@ public class AppVersionService extends BaseService {
|
||||
|
||||
@Autowired
|
||||
private AppVersionMapper appVersionMapper;
|
||||
|
||||
@Autowired
|
||||
private AppVersionUpdateConfService appVersionUpdateConfService;
|
||||
|
||||
@Autowired
|
||||
SysConfService sysConfService;
|
||||
private SysConfService sysConfService;
|
||||
|
||||
/**
|
||||
* 判断是否为审核中版本
|
||||
@@ -75,8 +75,8 @@ public class AppVersionService extends BaseService {
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public String getNewestVersionKey(String channel) {
|
||||
return channel + "_" + Constant.SysConfId.newest_version;
|
||||
public String getNewestVersionKey(String os, String channel) {
|
||||
return os + "_" + channel + "_" + Constant.SysConfId.newest_version;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public class AppVersionService extends BaseService {
|
||||
*/
|
||||
private AppVersion getNewestAppVersion(String os,String channel) {
|
||||
// 从配置表中获取当前最新的版本号
|
||||
String newestVersionValue = sysConfService.getSysConfValueById(getNewestVersionKey(channel));
|
||||
String newestVersionValue = sysConfService.getSysConfValueById(getNewestVersionKey(os, channel));
|
||||
// 根据版本号获取版本信息
|
||||
return getAppVersion(newestVersionValue, os,channel);
|
||||
}
|
||||
@@ -245,8 +245,7 @@ public class AppVersionService extends BaseService {
|
||||
if (StringUtils.isEmpty(appVersionStr)) {
|
||||
return null;
|
||||
} else {
|
||||
AppVersion appVersion = gson.fromJson(appVersionStr, AppVersion.class);
|
||||
return appVersion;
|
||||
return GsonUtil.getGson().fromJson(appVersionStr, AppVersion.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +257,7 @@ public class AppVersionService extends BaseService {
|
||||
String os = appVersion.getOs();
|
||||
String channel = appVersion.getPlatform();
|
||||
String key = getAppVersionKey(version, os, channel);
|
||||
jedisService.hwrite(RedisKey.app_version.getKey(), key, gson.toJson(appVersion));
|
||||
jedisService.hwrite(RedisKey.app_version.getKey(), key, GsonUtil.getGson().toJson(appVersion));
|
||||
}
|
||||
|
||||
private void deleteAppVersionCache(String version, String os, String channel) {
|
||||
@@ -343,33 +342,27 @@ public class AppVersionService extends BaseService {
|
||||
* @param os
|
||||
* @return
|
||||
*/
|
||||
public BusiResult<AppVersionVo> getNewestVersion(String version, String os, String channel) {
|
||||
AppVersion appVersion = getAppVersion(version, os, channel);
|
||||
if (appVersion == null) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
}
|
||||
AppVersionVo appVersionVo = new AppVersionVo();
|
||||
AppVersion newestVersion = getNewestAppVersion(appVersion.getOs(),appVersion.getPlatform());
|
||||
public AppVersionVo getNewestVersion(String version, String os, String channel) {
|
||||
AppVersion newestVersion = getNewestAppVersion(os, channel);
|
||||
if (newestVersion == null) {
|
||||
logger.info("Not found newestVersion. The version: " + appVersion.getVersion() + ", os: " + appVersion.getOs());
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
logger.info("Not found newestVersion. The version: " + version + ", os: " + os + ", channel: " + channel);
|
||||
return null;
|
||||
}
|
||||
if (newestVersion.getVersion().equals(version.trim())) {
|
||||
logger.info("The current version is the newest version: " + appVersion.getVersion() + ", os: " + appVersion.getOs());
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
if (AppVersionUtil.compareVersion(newestVersion.getVersion(), version) <= 0) {
|
||||
logger.info("The current version is the newest version: " + version + ", os: " + os + ", channel: "+ channel);
|
||||
return null;
|
||||
}
|
||||
// 将最新的版本及描述加入Vo
|
||||
AppVersionVo appVersionVo = new AppVersionVo();
|
||||
appVersionVo.setUpdateVersion(newestVersion.getVersion());
|
||||
appVersionVo.setUpdateVersionDesc(newestVersion.getVersionDesc());
|
||||
appVersionVo.setUpdateOs(newestVersion.getOs());
|
||||
appVersionVo.setUpdateStatus(appVersion.getStatus());
|
||||
appVersionVo.setUpdateStatus(newestVersion.getStatus());
|
||||
appVersionVo.setUpdateFileMd5(newestVersion.getFileMd5());
|
||||
appVersionVo.setUpdateDownloadLink(newestVersion.getDownloadLink());
|
||||
|
||||
ReplaceDomainUtil.handlerForObject(appVersionVo);
|
||||
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS);
|
||||
busiResult.setData(appVersionVo);
|
||||
return busiResult;
|
||||
return appVersionVo;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
<result column="file_md5" property="fileMd5" jdbcType="VARCHAR" />
|
||||
<result column="publish_time" property="publishTime" jdbcType="TIMESTAMP" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
||||
</resultMap>
|
||||
<resultMap id="ResultMapWithBLOBs" type="com.accompany.business.model.AppVersion" extends="BaseResultMap" >
|
||||
<result column="version_desc" property="versionDesc" jdbcType="LONGVARCHAR" />
|
||||
@@ -74,8 +75,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List" >
|
||||
version_id, os, version, platform, status, download_link, file_md5, publish_time,
|
||||
create_time
|
||||
version_id, os, version, platform, status, download_link, file_md5, publish_time, create_time, update_time
|
||||
</sql>
|
||||
<sql id="Blob_Column_List" >
|
||||
version_desc
|
||||
@@ -141,11 +141,12 @@
|
||||
<insert id="insert" parameterType="com.accompany.business.model.AppVersion" keyColumn="version_id" keyProperty="versionId" useGeneratedKeys="true">
|
||||
insert into app_version (os, version, platform,
|
||||
status, download_link, file_md5,
|
||||
publish_time, create_time, version_desc
|
||||
publish_time, create_time, update_time, version_desc
|
||||
)
|
||||
values (#{os,jdbcType=VARCHAR}, #{version,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR},
|
||||
#{status,jdbcType=TINYINT}, #{downloadLink,jdbcType=VARCHAR}, #{fileMd5,jdbcType=VARCHAR},
|
||||
#{publishTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{versionDesc,jdbcType=LONGVARCHAR}
|
||||
#{publishTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
|
||||
#{versionDesc,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.accompany.business.model.AppVersion" keyColumn="version_id" keyProperty="versionId" useGeneratedKeys="true">
|
||||
@@ -175,6 +176,9 @@
|
||||
<if test="createTime != null" >
|
||||
create_time,
|
||||
</if>
|
||||
<if test="createTime != null" >
|
||||
update_time,
|
||||
</if>
|
||||
<if test="versionDesc != null" >
|
||||
version_desc,
|
||||
</if>
|
||||
@@ -204,6 +208,9 @@
|
||||
<if test="createTime != null" >
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createTime != null" >
|
||||
#{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="versionDesc != null" >
|
||||
#{versionDesc,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@@ -245,6 +252,9 @@
|
||||
<if test="record.createTime != null" >
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="record.updateTime != null" >
|
||||
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="record.versionDesc != null" >
|
||||
version_desc = #{record.versionDesc,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@@ -264,6 +274,7 @@
|
||||
file_md5 = #{record.fileMd5,jdbcType=VARCHAR},
|
||||
publish_time = #{record.publishTime,jdbcType=TIMESTAMP},
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
|
||||
version_desc = #{record.versionDesc,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null" >
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@@ -280,6 +291,7 @@
|
||||
file_md5 = #{record.fileMd5,jdbcType=VARCHAR},
|
||||
publish_time = #{record.publishTime,jdbcType=TIMESTAMP},
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP}
|
||||
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
|
||||
<if test="_parameter != null" >
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@@ -311,6 +323,9 @@
|
||||
<if test="createTime != null" >
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null" >
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="versionDesc != null" >
|
||||
version_desc = #{versionDesc,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@@ -327,6 +342,7 @@
|
||||
file_md5 = #{fileMd5,jdbcType=VARCHAR},
|
||||
publish_time = #{publishTime,jdbcType=TIMESTAMP},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
version_desc = #{versionDesc,jdbcType=LONGVARCHAR}
|
||||
where version_id = #{versionId,jdbcType=INTEGER}
|
||||
</update>
|
||||
@@ -339,7 +355,8 @@
|
||||
download_link = #{downloadLink,jdbcType=VARCHAR},
|
||||
file_md5 = #{fileMd5,jdbcType=VARCHAR},
|
||||
publish_time = #{publishTime,jdbcType=TIMESTAMP},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||
where version_id = #{versionId,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
@@ -27,6 +27,15 @@ public class AppVersionController {
|
||||
private SysConfService sysConfService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(AppVersionController.class);
|
||||
|
||||
@RequestMapping(value = "getNewestVersion",method = RequestMethod.GET)
|
||||
public BusiResult<AppVersionVo> getNewestVersion(String appVersion,String os,String channel){
|
||||
if(StringUtils.isBlank(appVersion)||StringUtils.isBlank(os)){
|
||||
return new BusiResult<>(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
AppVersionVo vo = appVersionService.getNewestVersion(appVersion, os, channel);
|
||||
return new BusiResult<>(vo);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "get",method = RequestMethod.GET)
|
||||
public BusiResult getVersionInfo(Long uid, String appVersion,String os,String channel){
|
||||
if(StringUtils.isBlank(appVersion)||StringUtils.isBlank(os)){
|
||||
@@ -118,21 +127,6 @@ public class AppVersionController {
|
||||
return busiResult;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getNewestVersion",method = RequestMethod.GET)
|
||||
public BusiResult getNewestVersion( String appVersion,String os,String channel){
|
||||
if(StringUtils.isBlank(appVersion)||StringUtils.isBlank(os)){
|
||||
return new BusiResult(BusiStatus.PARAMETERILLEGAL,"参数异常");
|
||||
}
|
||||
BusiResult busiResult=null;
|
||||
try {
|
||||
busiResult=appVersionService.getNewestVersion(appVersion,os,channel);
|
||||
} catch (Exception e) {
|
||||
logger.error("getVersionInfo error..version="+appVersion,e);
|
||||
return new BusiResult(BusiStatus.BUSIERROR);
|
||||
}
|
||||
return busiResult;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/download/link")
|
||||
public BusiResult getDownloadLink(){
|
||||
String androidLink = sysConfService.getSysConfValueById(Constant.SysConfId.ANDROID_DOWNLOAD_LINK);
|
||||
|
Reference in New Issue
Block a user