Commit 2e228cf6 authored by hanfeng's avatar hanfeng

Merge branch 'base-modify' of http://10.5.52.3/youjj/cloud-platform into base-modify

parents 20b14a64 0eb897db
package com.xxfc.platform.app.entity;
import java.io.Serializable;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-24 10:34:00
*/
@Data
@Table(name = "app_version")
public class AppVersion implements Serializable {
private static final long serialVersionUID = 1L;
/**
* app版本信息表
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("app版本信息表")
private Integer id;
/**
* app手机系统类型(0:安卓,1:IOS)
*/
@Column(name = "sys_type")
@ApiModelProperty(value = "app手机系统类型(0:安卓,1:IOS)")
private Integer sysType;
/**
* 版本号
*/
@Column(name = "version")
@ApiModelProperty(value = "版本号")
private String version;
/**
* 版本号
*/
@Column(name = "version_name")
@ApiModelProperty(value = "版本号名称")
private String versionName;
/**
* 包的大小
*/
@Column(name = "packagesize")
@ApiModelProperty(value = "包的大小")
private String packagesize;
/**
* 升级内容
*/
@Column(name = "content")
@ApiModelProperty(value = "升级内容")
private String content;
/**
* 下载地址
*/
@Column(name = "download_url")
@ApiModelProperty(value = "下载地址")
private String downloadUrl;
/**
* 下载开关(0:可下载,1:不可下载)
*/
@Column(name = "download_switch")
@ApiModelProperty(value = "下载开关(0:可下载,1:不可下载)")
private Integer downloadSwitch;
/**
* 权重
*/
@Column(name = "weigh")
@ApiModelProperty(value = "权重")
private Integer weigh;
/**
* 版本上传时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "版本上传时间", hidden = true )
private Long crtTime;
/**
* 是否删除;0-正常;1-删除
*/
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
private Integer isDel;
}
package com.xxfc.platform.app.biz;
import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.xxfc.platform.app.entity.AppVersion;
import com.xxfc.platform.app.mapper.AppVersionMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
*
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-24 10:34:00
*/
@Service
public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
public ObjectRestResponse getVersion(String version,Integer type){
if (StringUtils.isBlank(version)||type==null){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
version=version.trim();
Example example =new Example(AppVersion.class);
example.createCriteria().andEqualTo("isDel",0).andEqualTo("downloadSwitch",0).andEqualTo("sysType",type);
example.setOrderByClause("version DESC");
List<AppVersion> list=selectByExample(example);
example.clear();
example.createCriteria().andEqualTo("version",version).andEqualTo("sysType",type);
List<AppVersion> list1=selectByExample(example);
Integer weigh1=0;
if(list1.size()>0){
weigh1=list1.get(0).getWeigh();
}
if (list.size()>0){
AppVersion appVersion=list.get(0);
String lats_version=appVersion.getVersion();
Integer weigh=appVersion.getWeigh();
if(!version.equals(lats_version)&&weigh>weigh1){
return new ObjectRestResponse().status(RestCode.SUCCESS.getStatus()).msg(RestCode.SUCCESS.getMsg()).data(appVersion).rel(false);
}
}
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
package com.xxfc.platform.app.mapper;
import com.xxfc.platform.app.entity.AppVersion;
import tk.mybatis.mapper.common.Mapper;
/**
*
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-24 10:34:00
*/
public interface AppVersionMapper extends Mapper<AppVersion> {
}
package com.xxfc.platform.app.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.app.biz.AppVersionBiz;
import com.xxfc.platform.app.entity.AppVersion;
import com.xxfc.platform.app.entity.Cofig;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("version")
@IgnoreClientToken
public class AppVersionController extends BaseController<AppVersionBiz,AppVersion> {
@ApiModelProperty("app自动更新")
@RequestMapping(value ="/app/unauth/info",method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse info(
@RequestParam(value = "type",defaultValue = "0") Integer type,
@RequestParam(value = "version",defaultValue = "") String version
){
return baseBiz.getVersion(version,type);
}
}
\ No newline at end of file
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