检测APP版本是否可以添加
This commit is contained in:
parent
2728cb1843
commit
ae69d8a11b
@ -296,7 +296,7 @@ public enum ResultCode {
|
||||
WECHAT_QRCODE_ERROR(80502, "微信二维码生成异常"),
|
||||
WECHAT_MP_MESSAGE_ERROR(80503, "微信小程序小消息订阅异常"),
|
||||
|
||||
|
||||
APP_VERSION_EXIST(80600, "APP版本已存在")
|
||||
;
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
@ -17,4 +17,11 @@ public interface AppVersionService extends IService<AppVersion> {
|
||||
* @return 最新的APP版本号
|
||||
*/
|
||||
AppVersion getAppVersion(String appType);
|
||||
|
||||
/**
|
||||
* 检测APP版本信息
|
||||
* @param appVersion app版本
|
||||
* @return 是否可添加
|
||||
*/
|
||||
boolean checkAppVersion(AppVersion appVersion);
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package cn.lili.modules.system.serviceimpl;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.system.entity.dos.AppVersion;
|
||||
import cn.lili.modules.system.mapper.AppVersionMapper;
|
||||
import cn.lili.modules.system.service.AppVersionService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -22,4 +25,13 @@ public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVers
|
||||
public AppVersion getAppVersion(String appType) {
|
||||
return this.baseMapper.getLatestVersion(appType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAppVersion(AppVersion appVersion) {
|
||||
//检测版本是否存在
|
||||
if(null!=this.getOne(new LambdaQueryWrapper<AppVersion>().eq(AppVersion::getVersion,appVersion))){
|
||||
throw new ServiceException(ResultCode.APP_VERSION_EXIST);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +48,12 @@ public class AppVersionManagerController {
|
||||
@ApiOperation(value = "添加app版本信息", response = AppVersion.class)
|
||||
@PostMapping
|
||||
public ResultMessage<Object> add(@Valid AppVersion appVersion) {
|
||||
|
||||
if(this.appVersionService.checkAppVersion(appVersion)){
|
||||
if(this.appVersionService.save(appVersion)){
|
||||
return ResultUtil.success();
|
||||
}
|
||||
}
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
@ -59,10 +62,13 @@ public class AppVersionManagerController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
public ResultMessage<Boolean> edit(@Valid AppVersion appVersion, @PathVariable String id) {
|
||||
public ResultMessage<Object> edit(@Valid AppVersion appVersion, @PathVariable String id) {
|
||||
|
||||
if(this.appVersionService.checkAppVersion(appVersion)){
|
||||
if(this.appVersionService.updateById(appVersion)){
|
||||
return ResultUtil.success();
|
||||
}
|
||||
}
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user