版本信息操作
This commit is contained in:
parent
8a4d083bc8
commit
6725f7bf32
|
|
@ -1,4 +1,4 @@
|
||||||
package com.czg.controller;
|
package com.czg.admin;
|
||||||
|
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.czg.admin;
|
||||||
|
|
||||||
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.system.dto.VersionDTO;
|
||||||
|
import com.czg.system.service.VersionService;
|
||||||
|
import com.czg.validator.group.InsertGroup;
|
||||||
|
import com.czg.validator.group.UpdateGroup;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GYJoker
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/version")
|
||||||
|
public class VersionController {
|
||||||
|
@Resource
|
||||||
|
private VersionService versionService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增版本
|
||||||
|
* @param versionDTO 版本信息
|
||||||
|
* @return Long id
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
@SaAdminCheckPermission("version:add")
|
||||||
|
public CzgResult<Long> insertVersion(@RequestBody @Validated({InsertGroup.class}) VersionDTO versionDTO) {
|
||||||
|
return versionService.insertVersion(versionDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新版本
|
||||||
|
* @param versionDTO 版本信息
|
||||||
|
* @return Long id
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
@SaAdminCheckPermission("version:update")
|
||||||
|
public CzgResult<Long> updateVersion(@RequestBody @Validated({UpdateGroup.class}) VersionDTO versionDTO) {
|
||||||
|
return versionService.updateVersion(versionDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除版本
|
||||||
|
* @param id 版本id
|
||||||
|
* @return Long id
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@SaAdminCheckPermission("version:delete")
|
||||||
|
public CzgResult<Long> deleteVersion(@PathVariable Long id) {
|
||||||
|
return versionService.deleteVersion(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本信息
|
||||||
|
* @param source 渠道
|
||||||
|
* @param type 类型
|
||||||
|
* @return VersionDTO
|
||||||
|
*/
|
||||||
|
@GetMapping("/{source}/{type}")
|
||||||
|
@SaAdminCheckPermission("version:get")
|
||||||
|
public CzgResult<VersionDTO> getVersionInfo(@PathVariable("source") String source, @PathVariable("type") String type) {
|
||||||
|
return versionService.getVersionInfo(source, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本列表
|
||||||
|
* @return List<VersionDTO>
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
@SaAdminCheckPermission("version:getList")
|
||||||
|
public CzgResult<List<VersionDTO>> getVersionList() {
|
||||||
|
return versionService.getVersionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package com.czg.controller;
|
|
||||||
|
|
||||||
import com.czg.SysParamsDTO2;
|
|
||||||
import com.czg.resp.CzgResult;
|
|
||||||
import com.czg.system.dto.SysParamsDTO;
|
|
||||||
import com.czg.system.service.SysParamsService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author GYJoker
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/feign")
|
|
||||||
public class FeignController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SysParamsService sysParamsService;
|
|
||||||
|
|
||||||
@RequestMapping("/testCall/{name}")
|
|
||||||
public CzgResult<SysParamsDTO2> testCall(@PathVariable String name) {
|
|
||||||
return CzgResult.success(new SysParamsDTO2().setParamCode("system-server:" + name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/sysParam/code/{code}")
|
|
||||||
public SysParamsDTO getParamsByCode(@PathVariable String code) {
|
|
||||||
CzgResult<SysParamsDTO> paramsByCode = sysParamsService.getParamsByCode(code);
|
|
||||||
return paramsByCode.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.czg.user;
|
||||||
|
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.system.dto.VersionDTO;
|
||||||
|
import com.czg.system.service.VersionService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GYJoker
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user/version")
|
||||||
|
public class UserVersionController {
|
||||||
|
@Resource
|
||||||
|
private VersionService versionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本信息
|
||||||
|
* @param source 渠道
|
||||||
|
* @param type 类型
|
||||||
|
* @return VersionDTO
|
||||||
|
*/
|
||||||
|
@GetMapping("/info/{source}/{type}")
|
||||||
|
public CzgResult<VersionDTO> getVersionInfo(@PathVariable("source") String source, @PathVariable("type") String type) {
|
||||||
|
return versionService.getVersionInfo(source, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.czg.system.dto;
|
||||||
|
|
||||||
|
import com.czg.validator.group.Group;
|
||||||
|
import com.czg.validator.group.UpdateGroup;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GYJoker
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class VersionDTO {
|
||||||
|
|
||||||
|
@NotNull(message = "版本id不能为空", groups = {UpdateGroup.class})
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@NotBlank(message = "渠道不能为空", groups = {Group.class})
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@NotBlank(message = "版本类型不能为空", groups = {Group.class})
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@NotBlank(message = "版本号不能为空", groups = {Group.class})
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
private Integer isForce = 0;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@NotBlank(message = "下载地址不能为空", groups = {Group.class})
|
||||||
|
private String url;
|
||||||
|
}
|
||||||
|
|
@ -31,15 +31,15 @@ public class Version implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id(keyType = KeyType.Auto)
|
@Id(keyType = KeyType.Auto)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LDBL_APP;WX;
|
* pc 桌面端, manager_app 管理端, phone_book 电话机点餐
|
||||||
*/
|
*/
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ios;android;
|
* 0 windows,1 安卓,2 iOS
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
|
@ -49,9 +49,9 @@ public class Version implements Serializable {
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0:不更新;1:更新
|
* 0:不强制更新;1:强制更新
|
||||||
*/
|
*/
|
||||||
private Integer isUp;
|
private Integer isForce;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新提示内容
|
* 更新提示内容
|
||||||
|
|
@ -64,9 +64,9 @@ public class Version implements Serializable {
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选中 0否 1是
|
* 更新者id
|
||||||
*/
|
*/
|
||||||
private Integer sel;
|
private Long updateUserId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
package com.czg.system.service;
|
package com.czg.system.service;
|
||||||
|
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.system.dto.VersionDTO;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
import com.czg.system.entity.Version;
|
import com.czg.system.entity.Version;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 版本管理 服务层。
|
* 版本管理 服务层。
|
||||||
*
|
*
|
||||||
|
|
@ -11,4 +15,38 @@ import com.czg.system.entity.Version;
|
||||||
*/
|
*/
|
||||||
public interface VersionService extends IService<Version> {
|
public interface VersionService extends IService<Version> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增版本
|
||||||
|
* @param versionDTO 版本信息
|
||||||
|
* @return Long id
|
||||||
|
*/
|
||||||
|
CzgResult<Long> insertVersion(VersionDTO versionDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新版本
|
||||||
|
* @param versionDTO 版本信息
|
||||||
|
* @return Long id
|
||||||
|
*/
|
||||||
|
CzgResult<Long> updateVersion(VersionDTO versionDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除版本
|
||||||
|
* @param id 版本id
|
||||||
|
* @return Long id
|
||||||
|
*/
|
||||||
|
CzgResult<Long> deleteVersion(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本信息
|
||||||
|
* @param source 渠道
|
||||||
|
* @param type 类型
|
||||||
|
* @return VersionDTO
|
||||||
|
*/
|
||||||
|
CzgResult<VersionDTO> getVersionInfo(String source, String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取版本列表
|
||||||
|
* @return List<VersionDTO>
|
||||||
|
*/
|
||||||
|
CzgResult<List<VersionDTO>> getVersionList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
package com.czg.service.system.service.impl;
|
package com.czg.service.system.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.czg.system.entity.Version;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.system.mapper.VersionMapper;
|
import com.czg.service.system.mapper.VersionMapper;
|
||||||
|
import com.czg.system.dto.VersionDTO;
|
||||||
|
import com.czg.system.entity.Version;
|
||||||
|
import com.czg.system.service.VersionService;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 版本管理 服务层实现。
|
* 版本管理 服务层实现。
|
||||||
*
|
*
|
||||||
|
|
@ -12,6 +21,78 @@ import org.springframework.stereotype.Service;
|
||||||
* @since 2025-02-12
|
* @since 2025-02-12
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class VersionServiceImpl extends ServiceImpl<VersionMapper, Version> {
|
public class VersionServiceImpl extends ServiceImpl<VersionMapper, Version> implements VersionService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<Long> insertVersion(VersionDTO versionDTO) {
|
||||||
|
Version version = getVersionBySource(versionDTO.getSource(), versionDTO.getType());
|
||||||
|
if (version != null) {
|
||||||
|
return CzgResult.failure("版本已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
version = BeanUtil.toBean(versionDTO, Version.class);
|
||||||
|
version.setUpdateUserId(StpKit.ADMIN.getLoginId(1L));
|
||||||
|
save(version);
|
||||||
|
return CzgResult.success(version.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<Long> updateVersion(VersionDTO versionDTO) {
|
||||||
|
Version version = getVersionBySource(versionDTO.getSource(), versionDTO.getType());
|
||||||
|
if (version != null && !version.getId().equals(versionDTO.getId())) {
|
||||||
|
return CzgResult.failure("版本已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
version = getById(versionDTO.getId());
|
||||||
|
if (version == null) {
|
||||||
|
return CzgResult.failure("版本不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(versionDTO.getSource())) {
|
||||||
|
version.setSource(versionDTO.getSource());
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(versionDTO.getVersion())) {
|
||||||
|
version.setVersion(versionDTO.getVersion());
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(versionDTO.getType())) {
|
||||||
|
version.setType(versionDTO.getType());
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(versionDTO.getUrl())) {
|
||||||
|
version.setUrl(versionDTO.getUrl());
|
||||||
|
}
|
||||||
|
version.setIsForce(versionDTO.getIsForce());
|
||||||
|
version.setMessage(versionDTO.getMessage());
|
||||||
|
version.setUpdateUserId(StpKit.ADMIN.getLoginId(1L));
|
||||||
|
|
||||||
|
updateById(version);
|
||||||
|
return CzgResult.success(version.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<Long> deleteVersion(Long id) {
|
||||||
|
boolean exists = super.exists(new QueryWrapper().eq(Version::getId, id));
|
||||||
|
if (!exists) {
|
||||||
|
return CzgResult.failure("版本不存在");
|
||||||
|
}
|
||||||
|
removeById(id);
|
||||||
|
return CzgResult.success(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<VersionDTO> getVersionInfo(String source, String type) {
|
||||||
|
Version version = getVersionBySource(source, type);
|
||||||
|
VersionDTO versionDTO = BeanUtil.toBean(version, VersionDTO.class);
|
||||||
|
return CzgResult.success(versionDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<List<VersionDTO>> getVersionList() {
|
||||||
|
List<Version> versions = list();
|
||||||
|
List<VersionDTO> dtoList = BeanUtil.copyToList(versions, VersionDTO.class);
|
||||||
|
return CzgResult.success(dtoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Version getVersionBySource(String source, String type) {
|
||||||
|
return getOne(new QueryWrapper().eq(Version::getSource, source).eq(Version::getType, type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue