Commit e9250468 authored by jiawei's avatar jiawei
parents d60896b0 54bdac3f
...@@ -662,8 +662,17 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -662,8 +662,17 @@ public class ChinaMobileRestApiController extends BaseController {
Map map = new HashMap(); Map map = new HashMap();
if (StringUtils.isNotBlank(versionNo)) { if (StringUtils.isNotBlank(versionNo)) {
if (Long.parseLong(versionNo) >= Long.parseLong(current.getAppVersion())) { final String prefix = StringUtils.substring(versionNo, 0, StringUtils.indexOf(versionNo, "."));
final String suffix = StringUtils.substring(versionNo, StringUtils.indexOf(versionNo, ".")).replaceAll("\\.", "");
String currAppVersion = current.getAppVersion();
final String prefix1 = StringUtils.substring(currAppVersion, 0, StringUtils.indexOf(currAppVersion, "."));
final String suffix1 = StringUtils.substring(currAppVersion, StringUtils.indexOf(currAppVersion, ".")).replaceAll("\\.", "");
if (Double.parseDouble(prefix + "." + suffix) >= Double.parseDouble(prefix1 + "." + suffix1)) {
map.put("isLatest", true); map.put("isLatest", true);
} else {
map.put("isLatest", false);
} }
} else { } else {
map.put("isLatest", false); map.put("isLatest", false);
......
...@@ -11,6 +11,7 @@ import cn.wisenergy.chnmuseum.party.service.TAppVersionService; ...@@ -11,6 +11,7 @@ import cn.wisenergy.chnmuseum.party.service.TAppVersionService;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -44,43 +45,35 @@ public class TAppVersionController extends BaseController { ...@@ -44,43 +45,35 @@ public class TAppVersionController extends BaseController {
@Resource @Resource
private TAppVersionService tAppVersionService; private TAppVersionService tAppVersionService;
@PostMapping("/batchSave") @PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("t:app:version:batch:save") @RequiresAuthentication //@RequiresPermissions("t:app:version:save")
@ApiOperation(value = "批量添加", notes = "批量添加") @ApiOperation(value = "添加", notes = "添加")
public Map<String, Object> batchSaveTAppVersion(@Validated(value = {Add.class}) List<TAppVersion> tAppVersionList) { @MethodLog(operModule = OperModule.APPVERSION, operType = OperType.ADD)
// 保存业务节点信息 public Map<String, Object> saveTAppVersion(@Validated(value = {Add.class}) TAppVersion tAppVersion) {
boolean result = tAppVersionService.saveBatch(tAppVersionList); final LambdaQueryWrapper<TAppVersion> eq = Wrappers.<TAppVersion>lambdaQuery().eq(TAppVersion::getAppVersion, tAppVersion.getAppVersion().trim());
// 返回操作结果 final List<TAppVersion> list = this.tAppVersionService.list(eq);
if (result) { if (!list.isEmpty() && list.size() > 1) {
return getSuccessResult();
} else {
// 保存失败 // 保存失败
return getFailResult(); return getFailResult("版本号不能重复");
} }
}
@PostMapping("/save") TUser user = getcurUser();
@RequiresAuthentication //@RequiresPermissions("t:app:version:save") // 默认不为当前版本
@ApiOperation(value = "添加", notes = "添加") if (tAppVersion.getIsCurrent() == null) {
@MethodLog(operModule = OperModule.APPVERSION, operType = OperType.ADD) tAppVersion.setIsCurrent(0);
public Map<String, Object> saveTAppVersion(@Validated(value = {Add.class}) TAppVersion tAppVersion) { }
TUser user = getcurUser(); tAppVersion.setUserId(user.getId());
// 默认不为当前版本 tAppVersion.setUserName(user.getUserName());
if (tAppVersion.getIsCurrent() == null){ // 如果有其他版本是当前版本状态,将其当前版本状态取消
tAppVersion.setIsCurrent(0); QueryWrapper<TAppVersion> qw = new QueryWrapper<>();
} qw.eq("is_current", 1);
tAppVersion.setUserId(user.getId()); List<TAppVersion> currentList = tAppVersionService.list(qw);
tAppVersion.setUserName(user.getUserName()); if (currentList != null && currentList.size() > 0 && tAppVersion.getIsCurrent() == 1) {
// 如果有其他版本是当前版本状态,将其当前版本状态取消 currentList.forEach(c -> {
QueryWrapper<TAppVersion> qw = new QueryWrapper<>(); c.setIsCurrent(0);
qw.eq("is_current",1); });
List<TAppVersion> currentList = tAppVersionService.list(qw); tAppVersionService.updateBatchById(currentList);
if (currentList != null && currentList.size() > 0 && tAppVersion.getIsCurrent() == 1){ }
currentList.stream().forEach(c->{
c.setIsCurrent(0);
});
tAppVersionService.updateBatchById(currentList);
}
// 保存业务节点信息 // 保存业务节点信息
boolean result = tAppVersionService.save(tAppVersion); boolean result = tAppVersionService.save(tAppVersion);
// 返回操作结果 // 返回操作结果
...@@ -93,40 +86,40 @@ public class TAppVersionController extends BaseController { ...@@ -93,40 +86,40 @@ public class TAppVersionController extends BaseController {
} }
@PutMapping("/update") @PutMapping("/update")
@RequiresAuthentication //@RequiresPermissions("t:app:version:update") @RequiresAuthentication //@RequiresPermissions("t:app:version:update")
@ApiOperation(value = "修改信息", notes = "修改信息") @ApiOperation(value = "修改信息", notes = "修改信息")
@MethodLog(operModule = OperModule.APPVERSION, operType = OperType.UPDATE) @MethodLog(operModule = OperModule.APPVERSION, operType = OperType.UPDATE)
public Map<String, Object> updateTAppVersion(@Validated(value = {Update.class}) TAppVersion tAppVersion) { public Map<String, Object> updateTAppVersion(@Validated(value = {Update.class}) TAppVersion tAppVersion) {
// 默认不为当前版本 // 默认不为当前版本
if (tAppVersion.getIsCurrent() == null){ if (tAppVersion.getIsCurrent() == null) {
tAppVersion.setIsCurrent(0); tAppVersion.setIsCurrent(0);
} }
// 如果有其他版本是当前版本状态,将其当前版本状态取消 // 如果有其他版本是当前版本状态,将其当前版本状态取消
QueryWrapper<TAppVersion> qw = new QueryWrapper<>(); QueryWrapper<TAppVersion> qw = new QueryWrapper<>();
qw.eq("is_current",1); qw.eq("is_current", 1);
List<TAppVersion> currentList = tAppVersionService.list(qw); List<TAppVersion> currentList = tAppVersionService.list(qw);
if (currentList != null && currentList.size() > 0 && tAppVersion.getIsCurrent() == 1){ if (currentList != null && currentList.size() > 0 && tAppVersion.getIsCurrent() == 1) {
currentList.stream().forEach(c->{ currentList.stream().forEach(c -> {
c.setIsCurrent(0); c.setIsCurrent(0);
}); });
tAppVersionService.updateBatchById(currentList); tAppVersionService.updateBatchById(currentList);
} }
// 更新版本信息 // 更新版本信息
boolean flag = tAppVersionService.updateById(tAppVersion); boolean flag = tAppVersionService.updateById(tAppVersion);
if (flag) { if (flag) {
return getSuccessResult(); return getSuccessResult();
} }
return getFailResult(); return getFailResult();
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
@RequiresAuthentication //@RequiresPermissions("t:app:version:delete") @RequiresAuthentication //@RequiresPermissions("t:app:version:delete")
@ApiOperation(value = "根据ID删除", notes = "根据ID删除") @ApiOperation(value = "根据ID删除", notes = "根据ID删除")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String") @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
}) })
@MethodLog(operModule = OperModule.APPVERSION, operType = OperType.DELETE) @MethodLog(operModule = OperModule.APPVERSION, operType = OperType.DELETE)
public Map<String, Object> deleteTAppVersion(@PathVariable("id") String id) { public Map<String, Object> deleteTAppVersion(@PathVariable("id") String id) {
boolean result = tAppVersionService.removeById(id); boolean result = tAppVersionService.removeById(id);
if (result) { if (result) {
...@@ -136,45 +129,45 @@ public class TAppVersionController extends BaseController { ...@@ -136,45 +129,45 @@ public class TAppVersionController extends BaseController {
} }
@GetMapping("/getList") @GetMapping("/getList")
@RequiresAuthentication //@RequiresPermissions("t:app:version:list") @RequiresAuthentication //@RequiresPermissions("t:app:version:list")
@ApiOperation(value = "获取全部列表(无分页)", notes = "获取全部列表(无分页)") @ApiOperation(value = "获取全部列表(无分页)", notes = "获取全部列表(无分页)")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "isCurrent", value = "是否为当前版本 0:否 1:是", paramType = "query", dataType = "String") @ApiImplicitParam(name = "isCurrent", value = "是否为当前版本 0:否 1:是", paramType = "query", dataType = "String")
}) })
@MethodLog(operModule = OperModule.APPVERSION, operType = OperType.SELECT) @MethodLog(operModule = OperModule.APPVERSION, operType = OperType.SELECT)
public Map<String, Object> getTAppVersionList(String isCurrent) { public Map<String, Object> getTAppVersionList(String isCurrent) {
QueryWrapper qw = new QueryWrapper(); QueryWrapper qw = new QueryWrapper();
qw.eq(StringUtils.isNotEmpty(isCurrent),"is_current",isCurrent).orderByDesc("update_time"); qw.eq(StringUtils.isNotEmpty(isCurrent), "is_current", isCurrent).orderByDesc("update_time");
List<TAppVersion> tAppVersionList = tAppVersionService.list(qw); List<TAppVersion> tAppVersionList = tAppVersionService.list(qw);
return getResult(tAppVersionList); return getResult(tAppVersionList);
} }
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "startDate", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "endDate", value = "结束时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "isCurrent", value = "是否为当前版本 0:否 1:是", paramType = "query", dataType = "String") @ApiImplicitParam(name = "isCurrent", value = "是否为当前版本 0:否 1:是", paramType = "query", dataType = "String")
}) })
@PostMapping("/getPageList") @PostMapping("/getPageList")
@RequiresAuthentication //@RequiresPermissions("t:app:version:page") @RequiresAuthentication //@RequiresPermissions("t:app:version:page")
@ApiOperation(value = "获取分页列表", notes = "获取分页列表") @ApiOperation(value = "获取分页列表", notes = "获取分页列表")
@MethodLog(operModule = OperModule.APPVERSION, operType = OperType.SELECT) @MethodLog(operModule = OperModule.APPVERSION, operType = OperType.SELECT)
public Map<String, Object> getTAppVersionPageList(LocalDate startDate, LocalDate endDate, String isCurrent) { public Map<String, Object> getTAppVersionPageList(LocalDate startDate, LocalDate endDate, String isCurrent) {
LambdaQueryWrapper<TAppVersion> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TAppVersion> queryWrapper = new LambdaQueryWrapper<>();
// 查询是否为当前版本 // 查询是否为当前版本
if (StringUtils.isNotBlank(isCurrent)) { if (StringUtils.isNotBlank(isCurrent)) {
queryWrapper.like(TAppVersion::getIsCurrent, isCurrent); queryWrapper.like(TAppVersion::getIsCurrent, isCurrent);
} }
// 查询时间范围 // 查询时间范围
if (startDate != null && endDate != null){ if (startDate != null && endDate != null) {
queryWrapper.ge(TAppVersion::getUpdateTime,startDate.atTime(0,0,0)) queryWrapper.ge(TAppVersion::getUpdateTime, startDate.atTime(0, 0, 0))
.le(TAppVersion::getUpdateTime,endDate.atTime(23,59,59)); .le(TAppVersion::getUpdateTime, endDate.atTime(23, 59, 59));
} }
queryWrapper.select().orderByDesc(TAppVersion::getUpdateTime); queryWrapper.select().orderByDesc(TAppVersion::getUpdateTime);
Page<TAppVersion> page = this.tAppVersionService.page(getPage(), queryWrapper); Page<TAppVersion> page = this.tAppVersionService.page(getPage(), queryWrapper);
return getResult(page); return getResult(page);
} }
@ApiOperation(value = "获取详情", notes = "获取详情") @ApiOperation(value = "获取详情", notes = "获取详情")
...@@ -182,11 +175,11 @@ public class TAppVersionController extends BaseController { ...@@ -182,11 +175,11 @@ public class TAppVersionController extends BaseController {
@ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path") @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
}) })
@GetMapping("/get/{id}") @GetMapping("/get/{id}")
@RequiresAuthentication //@RequiresPermissions("t:app:version:get:id") @RequiresAuthentication //@RequiresPermissions("t:app:version:get:id")
@MethodLog(operModule = OperModule.APPVERSION, operType = OperType.SELECT) @MethodLog(operModule = OperModule.APPVERSION, operType = OperType.SELECT)
public Map<String, Object> getById(@PathVariable("id") String id) { public Map<String, Object> getById(@PathVariable("id") String id) {
TAppVersion tAppVersion = tAppVersionService.getById(id); TAppVersion tAppVersion = tAppVersionService.getById(id);
return getResult(tAppVersion); return getResult(tAppVersion);
} }
} }
......
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