Compare commits
3 Commits
46175c7295
...
9917e46c29
| Author | SHA1 | Date | |
|---|---|---|---|
| 9917e46c29 | |||
| 54cd851245 | |||
| 8b13d4cd92 |
@@ -46,6 +46,8 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/druid/**")
|
||||
// 排除错误页面
|
||||
.excludePathPatterns("/error", "/error/**")
|
||||
// 排除校验更新接口
|
||||
.excludePathPatterns("app_version", "/app_version/checkUpdate")
|
||||
// 排除咨询接口
|
||||
.excludePathPatterns("/contactMsg", "/contactMsg/**");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.corewing.app.dto.biz.appVersion;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class CheckVersionRequest {
|
||||
|
||||
@NotBlank(message = "版本不能为空")
|
||||
private String localVersion;
|
||||
|
||||
@NotBlank(message = "构建版本不能为空")
|
||||
private int localBuildNumber;
|
||||
|
||||
@NotBlank(message = "类型不能为空")
|
||||
private String type;
|
||||
|
||||
}
|
||||
38
src/main/java/com/corewing/app/entity/AppVersion.java
Normal file
38
src/main/java/com/corewing/app/entity/AppVersion.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* app版本控制
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_version")
|
||||
public class AppVersion {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String version;
|
||||
|
||||
private int versionNumber;
|
||||
|
||||
private int buildNumber;
|
||||
|
||||
private String updateContent;
|
||||
|
||||
private String downloadUrl;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -66,13 +67,13 @@ public class Tutorial implements Serializable {
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 教程分类id
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.corewing.app.entity.AppVersion;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AppVersionMapper extends BaseMapper<AppVersion> {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.corewing.app.modules.app;
|
||||
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.dto.biz.appVersion.CheckVersionRequest;
|
||||
import com.corewing.app.entity.AppVersion;
|
||||
import com.corewing.app.service.AppVersionService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* app升级校验接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app_version")
|
||||
public class AppVersionController {
|
||||
|
||||
@Resource
|
||||
private AppVersionService appVersionService;
|
||||
|
||||
/**
|
||||
* 校验是否存在新版本
|
||||
* @param checkVersionRequest
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/checkUpdate")
|
||||
public Result<Object> checkUpdate(CheckVersionRequest checkVersionRequest) {
|
||||
AppVersion version = appVersionService.getNewAppVersion(checkVersionRequest);
|
||||
if(version == null) {
|
||||
return Result.error("暂无新版本");
|
||||
}
|
||||
return Result.success(version);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.dto.biz.appVersion.CheckVersionRequest;
|
||||
import com.corewing.app.entity.AppVersion;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
public interface AppVersionService extends IService<AppVersion> {
|
||||
|
||||
AppVersion getNewAppVersion(@Valid CheckVersionRequest checkVersionRequest);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.dto.biz.appVersion.CheckVersionRequest;
|
||||
import com.corewing.app.entity.AppVersion;
|
||||
import com.corewing.app.mapper.AppVersionMapper;
|
||||
import com.corewing.app.service.AppVersionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements AppVersionService {
|
||||
|
||||
@Override
|
||||
public AppVersion getNewAppVersion(CheckVersionRequest checkVersionRequest) {
|
||||
int checkVersionNumber = Integer.parseInt(checkVersionRequest.getLocalVersion().replace(".", ""));
|
||||
LambdaQueryWrapper<AppVersion> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.gt(AppVersion::getVersionNumber, checkVersionNumber)
|
||||
.or().gt(AppVersion::getBuildNumber, checkVersionRequest.getLocalBuildNumber());
|
||||
wrapper.eq(AppVersion::getType, checkVersionRequest.getType());
|
||||
wrapper.eq(AppVersion::getStatus, 1);
|
||||
wrapper.orderByDesc(AppVersion::getVersionNumber, AppVersion::getBuildNumber);
|
||||
wrapper.last("limit 1");
|
||||
List<AppVersion> list = list(wrapper);
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user