增加版本管理
							parent
							
								
									fdb8b7ee9d
								
							
						
					
					
						commit
						b73f9521ae
					
				| @ -0,0 +1,142 @@ | |||||||
|  | package com.glxp.api.controller.system; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import cn.hutool.core.collection.CollectionUtil; | ||||||
|  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||||
|  | import com.github.pagehelper.Page; | ||||||
|  | import com.github.pagehelper.PageHelper; | ||||||
|  | import com.glxp.api.annotation.AuthRuleAnnotation; | ||||||
|  | import com.glxp.api.annotation.Log; | ||||||
|  | import com.glxp.api.common.enums.ResultEnum; | ||||||
|  | import com.glxp.api.common.res.BaseResponse; | ||||||
|  | import com.glxp.api.common.util.ResultVOUtils; | ||||||
|  | import com.glxp.api.constant.BusinessType; | ||||||
|  | import com.glxp.api.controller.BaseController; | ||||||
|  | import com.glxp.api.entity.anno.AnncmntDevEntity; | ||||||
|  | import com.glxp.api.entity.system.SysJarVersion; | ||||||
|  | import com.glxp.api.req.anno.AnncmntDevEntityRequest; | ||||||
|  | import com.glxp.api.req.system.DeleteRequest; | ||||||
|  | import com.glxp.api.req.system.SysJarVersionRequest; | ||||||
|  | import com.glxp.api.res.PageSimpleResponse; | ||||||
|  | import com.glxp.api.service.anno.AnncmntDevService; | ||||||
|  | import com.glxp.api.service.system.SysJarVersionService; | ||||||
|  | import com.glxp.api.util.BeanCopyUtils; | ||||||
|  | import com.glxp.api.util.StringUtils; | ||||||
|  | import lombok.RequiredArgsConstructor; | ||||||
|  | import org.springframework.validation.BindingResult; | ||||||
|  | import org.springframework.validation.annotation.Validated; | ||||||
|  | import org.springframework.web.bind.annotation.*; | ||||||
|  | import springfox.documentation.annotations.ApiIgnore; | ||||||
|  | 
 | ||||||
|  | import javax.validation.Valid; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 用户信息 | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | @ApiIgnore | ||||||
|  | @Validated | ||||||
|  | @RequiredArgsConstructor | ||||||
|  | @RestController | ||||||
|  | public class SysJarVersionController extends BaseController { | ||||||
|  | 
 | ||||||
|  |     private final SysJarVersionService sysJarVersionService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/sys/jar/list") | ||||||
|  |     public BaseResponse list(SysJarVersionRequest request, BindingResult bindingResult) { | ||||||
|  |         if (bindingResult.hasErrors()) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | ||||||
|  |         } | ||||||
|  |         int offset = (request.getPage() - 1) * request.getLimit(); | ||||||
|  |         Page<SysJarVersion> pages =  PageHelper.offsetPage(offset, request.getLimit()); | ||||||
|  |         List<SysJarVersion> list = sysJarVersionService.list(getQueryWrapper(request)); | ||||||
|  |         PageSimpleResponse<SysJarVersion> pageSimpleResponse = new PageSimpleResponse<>(); | ||||||
|  |         pageSimpleResponse.setTotal(pages.getTotal()); | ||||||
|  |         pageSimpleResponse.setList(list); | ||||||
|  | 
 | ||||||
|  |         return ResultVOUtils.success(pageSimpleResponse); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @AuthRuleAnnotation("") | ||||||
|  |     @PostMapping("/sys/jar/save") | ||||||
|  |     @Log(title = "jar包管理", businessType = BusinessType.INSERT) | ||||||
|  |     public BaseResponse save(@RequestBody SysJarVersion entity, | ||||||
|  |                              BindingResult bindingResult) { | ||||||
|  | 
 | ||||||
|  |         if (bindingResult.hasErrors()) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         boolean b = sysJarVersionService.save(entity); | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.NOT_NETWORK); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success("添加成功!"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @AuthRuleAnnotation("") | ||||||
|  |     @PostMapping("/sys/jar/edit") | ||||||
|  |     @Log(title = "jar包管理", businessType = BusinessType.UPDATE) | ||||||
|  |     public BaseResponse edit(@RequestBody @Valid SysJarVersion entity, | ||||||
|  |                              BindingResult bindingResult) { | ||||||
|  | 
 | ||||||
|  |         if (bindingResult.hasErrors()) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | ||||||
|  |         } | ||||||
|  |         if (entity.getId() == null) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); | ||||||
|  |         } | ||||||
|  |         SysJarVersion originEntity = sysJarVersionService.getById(entity.getId()); | ||||||
|  |         if (originEntity == null) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); | ||||||
|  |         } | ||||||
|  |         boolean b = sysJarVersionService.updateById(entity); | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.NOT_NETWORK); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return ResultVOUtils.success("修改成功!"); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @AuthRuleAnnotation("") | ||||||
|  |     @PostMapping("/sys/jar/delete") | ||||||
|  |     @Log(title = "jar包管理", businessType = BusinessType.DELETE) | ||||||
|  |     public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) { | ||||||
|  | 
 | ||||||
|  |         if (StringUtils.isEmpty(deleteRequest.getId())) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); | ||||||
|  |         } | ||||||
|  |         boolean b = sysJarVersionService.removeById(deleteRequest.getId()); | ||||||
|  | 
 | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.NOT_NETWORK); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static QueryWrapper<SysJarVersion> getQueryWrapper(SysJarVersionRequest request) { | ||||||
|  |         SysJarVersion entity = new SysJarVersion(); | ||||||
|  |         BeanCopyUtils.copy(request, entity); | ||||||
|  |         QueryWrapper queryWrapper = new QueryWrapper(entity); | ||||||
|  |         return queryWrapper; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @GetMapping("/jar/getLatestVersion") | ||||||
|  |     @Log(title = "jar包管理") | ||||||
|  |     public BaseResponse getLatestVersion() { | ||||||
|  | 
 | ||||||
|  |         QueryWrapper queryWrapper = new QueryWrapper(); | ||||||
|  |         queryWrapper.eq("status","1"); | ||||||
|  |         queryWrapper.orderByDesc("version"); | ||||||
|  |         List<SysJarVersion> list =  sysJarVersionService.list(queryWrapper); | ||||||
|  |         if(CollectionUtil.isEmpty(list)){ | ||||||
|  |             return ResultVOUtils.paramVerifyFail("暂无版本"); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success(list.get(0)); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,10 @@ | |||||||
|  | package com.glxp.api.dao.system; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||||
|  | import com.glxp.api.entity.anno.AnncmntDevEntity; | ||||||
|  | import com.glxp.api.entity.system.SysJarVersion; | ||||||
|  | import org.apache.ibatis.annotations.Mapper; | ||||||
|  | 
 | ||||||
|  | @Mapper | ||||||
|  | public interface SysJarVersionMapper extends BaseMapper<SysJarVersion> { | ||||||
|  | } | ||||||
| @ -0,0 +1,85 @@ | |||||||
|  | package com.glxp.api.entity.system; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.annotation.IdType; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableField; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableName; | ||||||
|  | import lombok.AllArgsConstructor; | ||||||
|  | import lombok.Builder; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.NoArgsConstructor; | ||||||
|  | 
 | ||||||
|  | import java.io.Serializable; | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | @Data | ||||||
|  | @Builder | ||||||
|  | @AllArgsConstructor | ||||||
|  | @NoArgsConstructor | ||||||
|  | @TableName(value = "sys_jar_version") | ||||||
|  | public class SysJarVersion implements Serializable { | ||||||
|  |     @TableId(value = "id", type = IdType.INPUT) | ||||||
|  |     private Integer id; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 版本号 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "version") | ||||||
|  |     private String version; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 版本名称 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "name") | ||||||
|  |     private String name; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 是否强制 0否 1是 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "isForce") | ||||||
|  |     private String isForce; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 文件路径 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "filePath") | ||||||
|  |     private String filePath; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 状态 1正常 2下线 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "status") | ||||||
|  |     private String status; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 创建人 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "`createUser`") | ||||||
|  |     private String createUser; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 创建时间 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "createTime") | ||||||
|  |     private Date createTime; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 更新人 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "updateUser") | ||||||
|  |     private String updateUser; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 更新时间 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "updateTime") | ||||||
|  |     private Date updateTime; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 备注 | ||||||
|  |      */ | ||||||
|  |     @TableField(value = "remark") | ||||||
|  |     private String remark; | ||||||
|  | 
 | ||||||
|  |     private static final long serialVersionUID = 1L; | ||||||
|  | } | ||||||
| @ -0,0 +1,9 @@ | |||||||
|  | package com.glxp.api.req.system; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.util.page.ListPageRequest; | ||||||
|  | import lombok.Data; | ||||||
|  | 
 | ||||||
|  | @Data | ||||||
|  | public class SysJarVersionRequest extends ListPageRequest { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,13 @@ | |||||||
|  | package com.glxp.api.service.system; | ||||||
|  | 
 | ||||||
|  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||||
|  | import com.glxp.api.dao.anno.AnncmntDevMapper; | ||||||
|  | import com.glxp.api.dao.system.SysJarVersionMapper; | ||||||
|  | import com.glxp.api.entity.anno.AnncmntDevEntity; | ||||||
|  | import com.glxp.api.entity.system.SysJarVersion; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  | public class SysJarVersionService extends ServiceImpl<SysJarVersionMapper, SysJarVersion> { | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,5 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||||
|  | <mapper namespace="com.glxp.api.dao.system.SysJarVersionMapper"> | ||||||
|  | 
 | ||||||
|  | </mapper> | ||||||
					Loading…
					
					
				
		Reference in New Issue