admin管理员组文章数量:1531696
关键业务
添加一个新版本,默认是关闭发布的状态,如果填写的内容有误,可以进行修改删除
发布版本是很严谨的,一旦发布版本,就不能关闭
app端点击更新按钮时, 更新到已发布版本的最新版
CREATE TABLE `tb_version` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
`version` varchar(50) DEFAULT NULL COMMENT '版本号',
`picture_path` text COMMENT '图片路径',
`download_path` text COMMENT '更新包地址',
`download_type` int(2) DEFAULT NULL COMMENT '下载地址的类型 1上传应用 2填写外部链接',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
`release_time` datetime DEFAULT NULL COMMENT '发布时间',
`is_release` int(2) DEFAULT NULL COMMENT '是否发布 0关闭 1开启',
`is_delete` int(2) DEFAULT '0' COMMENT '是否删除 1删除 0未删除',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `index_version` (`version`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='版本信息';
CREATE TABLE `tb_version_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',
`version_id` bigint(20) NOT NULL COMMENT '版本ID',
`introduction` varchar(255) DEFAULT NULL COMMENT '版本内容',
`order_num` int(11) DEFAULT NULL COMMENT '顺序号',
`is_delete` int(2) DEFAULT '0' COMMENT '是否删除 1删除 0未删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='版本详情';
后台管理系统
VersionController.java
import com.yymt.common.annotation.Login;
import com.yymt.common.constants.VersionConstant;
import com.yymt.common.utils.BigDataUtil;
import com.yymt.common.utils.ConvertUtil;
import com.yymt.common.utils.R;
import com.yymt.dao.sys.VersionInfoDao;
import com.yymt.entity.sys.VersionEntity;
import com.yymt.modules.controller.base.BaseController;
import com.yymt.service.sys.VersionInfoService;
import com.yymt.service.sys.VersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 版本信息
*/
@RestController
@RequestMapping("version")
@Api(tags = "版本信息")
public class VersionController extends BaseController {
@Autowired
private VersionService versionService;
@Autowired
private VersionInfoService versionInfoService;
@Autowired
VersionInfoDao versionInfoDao;
@PostMapping("/save")
@ApiOperation(value = "保存")
@Login
public R save(
@ApiParam("参数说明 " +
"version:版本号,introduction:更新内容(必须传数组格式),picturePath:图片路径(必须传数组格式), " +
"downloadPath:下载链接, downloadType:下载链接的类型(1上传应用 2填写外部链接)")
@RequestBody Map<String, Object> params) {
return versionService.saveData(params);
}
@PostMapping("/updateReleaseStatus/{id}")
@ApiOperation(value = "开启发布")
@Login
public R updateReleaseStatus(@PathVariable("id") Long id){
VersionEntity versionEntity = versionService.selectById(id);
if (versionEntity == null) {
return R.error("该版本不存在");
}
if (VersionConstant.VERSION_RELEASE_OPEN == versionEntity.getIsRelease()) {
return R.error("已发布版本不能关闭!!");
}
versionEntity.setIsRelease(VersionConstant.VERSION_RELEASE_OPEN);
versionEntity.setReleaseTime(new Date());
versionService.updateById(versionEntity);
return R.ok();
}
@PostMapping("/list")
@ApiOperation(value = "列表")
@Login
public R list(
@ApiParam(value = "参数说明 titleKeyword:关键词,pageSize:个数,currPage:当前页")
@RequestBody Map<String, Object> params) {
return versionService.queryPageData(params, getTopUrl());
}
@PostMapping("/info/{id}")
@ApiOperation(value = "信息")
@Login
public R info(@PathVariable("id") Long id){
VersionEntity version = versionService.selectById(id);
if (version == null) {
return R.error("该数据不存在");
}
return versionService.selectInfo(id, getTopUrl());
}
@PostMapping("/update")
@ApiOperation(value = "修改")
@Login
public R update(
@ApiParam("参数说明 " +
"version:版本号,introduction:更新内容(必须传数组格式),picturePath:图片路径(必须传数组格式), " +
"downloadPath:下载链接, downloadType:下载链接的类型(1上传应用 2填写外部链接),id:版本ID(必填)")
@RequestBody Map<String, Object> params) {
Long id = ConvertUtil.parseLong(params.get("id"));
VersionEntity versionEntity = versionService.selectById(id);
if (versionEntity == null) {
return R.error("id不能为空或者该id不存在");
}
// ###### 先删除, 后添加 #######
versionService.deleteById(id);
// 获取当前版本的所有版本更新内容
List<Map<String, Object>> list = versionInfoDao.queryDataByVersionId(id);
// 获取所有id
List idList = BigDataUtil.getColumnValueToList(list, "id", 0);
versionInfoService.deleteBatchIds(idList);
return versionService.saveData(params);
}
@PostMapping("/delete/{id}")
@ApiOperation(value = "删除")
@Login
public R delete(@PathVariable("id") Long id)
版权声明:本文标题:app下载 - app版本更新 (实测可行版) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1725439211a1023353.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论