ref 升级脚手架依赖

This commit is contained in:
bootx
2025-08-21 12:48:17 +08:00
parent 1a3abea1e1
commit 6df7782ed2
107 changed files with 1419 additions and 6524 deletions

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>cn.bootx.platform</groupId>
<artifactId>bootx-platform-service</artifactId>
<version>3.0.0.beta5</version>
<version>3.0.0</version>
</parent>
<artifactId>service-baseapi</artifactId>

View File

@@ -0,0 +1,97 @@
package cn.bootx.platform.baseapi.controller.protocol;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolParam;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolQuery;
import cn.bootx.platform.baseapi.result.protocol.UserProtocolResult;
import cn.bootx.platform.baseapi.service.protocol.UserProtocolService;
import cn.bootx.platform.core.annotation.IgnoreAuth;
import cn.bootx.platform.core.annotation.RequestGroup;
import cn.bootx.platform.core.annotation.RequestPath;
import cn.bootx.platform.core.rest.Res;
import cn.bootx.platform.core.rest.param.PageParam;
import cn.bootx.platform.core.rest.result.PageResult;
import cn.bootx.platform.core.rest.result.Result;
import cn.bootx.platform.core.validation.ValidationGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 用户协议
* @author xxm
* @since 2025/5/9
*/
@Validated
@Tag(name = "用户协议")
@RequestGroup(groupCode = "UserProtocol", groupName = "用户协议", moduleCode = "baseapi" )
@RestController
@RequestMapping("/user/protocol")
@RequiredArgsConstructor
public class UserProtocolController {
private final UserProtocolService userProtocolService;
@RequestPath("分页")
@Operation(summary = "分页")
@GetMapping("/page")
public Result<PageResult<UserProtocolResult>> page(PageParam pageParam, UserProtocolQuery query){
return Res.ok(userProtocolService.page(pageParam, query));
}
@RequestPath("新增")
@Operation(summary = "新增")
@PostMapping("/add")
public Result<Void> add(@RequestBody @Validated(ValidationGroup.add.class) UserProtocolParam param){
userProtocolService.add(param);
return Res.ok();
}
@RequestPath("修改")
@Operation(summary = "修改")
@PostMapping("/update")
public Result<Void> update(@RequestBody @Validated(ValidationGroup.edit.class) UserProtocolParam param){
userProtocolService.update(param);
return Res.ok();
}
@RequestPath("删除")
@Operation(summary = "删除")
@PostMapping("/delete")
public Result<Void> delete(@NotNull(message = "主键不可为空") Long id){
userProtocolService.delete(id);
return Res.ok();
}
@RequestPath("查询")
@Operation(summary = "查询")
@GetMapping("/findById")
public Result<UserProtocolResult> findById(@NotNull(message = "主键不可为空") Long id){
return Res.ok(userProtocolService.findById(id));
}
@IgnoreAuth
@Operation(summary = "查询默认协议")
@GetMapping("/findDefault")
public Result<UserProtocolResult> findDefault(@NotNull(message = "协议类型不可为空") String type){
return Res.ok(userProtocolService.findDefault(type));
}
@RequestPath("设置默认")
@Operation(summary = "设置默认")
@PostMapping("/setDefault")
public Result<Void> setDefault(@NotNull(message = "主键不可为空") Long id){
userProtocolService.setDefault(id);
return Res.ok();
}
@RequestPath("取消默认")
@Operation(summary = "取消默认")
@PostMapping("/cancelDefault")
public Result<Void> cancelDefault(@NotNull(message = "主键不可为空") Long id){
userProtocolService.cancelDefault(id);
return Res.ok();
}
}

View File

@@ -0,0 +1,21 @@
package cn.bootx.platform.baseapi.convert.protocol;
import cn.bootx.platform.baseapi.entity.protocol.UserProtocol;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolParam;
import cn.bootx.platform.baseapi.result.protocol.UserProtocolResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
*用户协议管理
* @author xxm
* @since 2025/5/9
*/
@Mapper
public interface UserProtocolConvert {
UserProtocolConvert CONVERT = Mappers.getMapper(UserProtocolConvert.class);
UserProtocolResult toResult(UserProtocol userProtocol);
UserProtocol toEntity(UserProtocolParam param);
}

View File

@@ -2,6 +2,7 @@ package cn.bootx.platform.baseapi.dao.dict;
import cn.bootx.platform.baseapi.entity.dict.DictionaryItem;
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
import cn.bootx.platform.common.mybatisplus.base.MpRealDelEntity;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.core.rest.param.PageParam;
@@ -63,7 +64,11 @@ public class DictionaryItemManager extends BaseManager<DictionaryItemMapper, Dic
}
public void updateDictCode(Long dictId, String dictCode) {
lambdaUpdate().set(DictionaryItem::getDictCode, dictCode).eq(DictionaryItem::getDictId, dictId).update();
lambdaUpdate()
.set(DictionaryItem::getDictCode, dictCode)
.eq(DictionaryItem::getDictId, dictId)
.setIncrBy(MpRealDelEntity::getVersion, 1)
.update();
}
public List<DictionaryItem> findAllByEnable(boolean enable) {

View File

@@ -30,21 +30,21 @@ public class SystemParamManager extends BaseManager<SystemParamMapper, SystemPar
* 根据键名获取键值
*/
public Optional<SystemParameter> findByKey(String key) {
return this.findByField(SystemParameter::getKey, key);
return this.findByField(SystemParameter::getParamKey, key);
}
/**
* key重复检查
*/
public boolean existsByKey(String key) {
return existedByField(SystemParameter::getKey, key);
return existedByField(SystemParameter::getParamKey, key);
}
/**
* key重复检查
*/
public boolean existsByKey(String key, Long id) {
return existedByField(SystemParameter::getKey, key, id);
return existedByField(SystemParameter::getParamKey, key, id);
}
/**
@@ -54,7 +54,7 @@ public class SystemParamManager extends BaseManager<SystemParamMapper, SystemPar
Page<SystemParameter> mpPage = MpUtil.getMpPage(pageParam);
return lambdaQuery().orderByDesc(MpIdEntity::getId)
.like(StrUtil.isNotBlank(param.getName()), SystemParameter::getName, param.getName())
.like(StrUtil.isNotBlank(param.getKey()), SystemParameter::getKey, param.getKey())
.like(StrUtil.isNotBlank(param.getKey()), SystemParameter::getParamKey, param.getKey())
.page(mpPage);
}

View File

@@ -0,0 +1,79 @@
package cn.bootx.platform.baseapi.dao.protocol;
import cn.bootx.platform.baseapi.entity.protocol.UserProtocol;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolQuery;
import cn.bootx.platform.common.mybatisplus.base.MpRealDelEntity;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.query.generator.QueryGenerator;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.core.rest.param.PageParam;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* 用户协议管理
* @author xxm
* @since 2025/5/9
*/
@Slf4j
@Repository
@RequiredArgsConstructor
public class UserProtocolManager extends BaseManager<UserProtocolMapper, UserProtocol> {
/**
* 分页
*/
public Page<UserProtocol> page(PageParam pageParam, UserProtocolQuery query){
Page<UserProtocol> mpPage = MpUtil.getMpPage(pageParam, UserProtocol.class);
QueryWrapper<UserProtocol> generator = QueryGenerator.generator(query);
return this.page(mpPage,generator);
}
/**
* 根据分类查询默认协议
*/
public Optional<UserProtocol> findDefault(String type){
return this.lambdaQuery()
.eq(UserProtocol::getType,type)
.eq(UserProtocol::getDefaultProtocol,true)
.oneOpt();
}
/**
* 清除默认协议
*/
public void clearDefault(String type){
this.lambdaUpdate()
.eq(UserProtocol::getType,type)
.set(UserProtocol::getDefaultProtocol,false)
.setIncrBy(MpRealDelEntity::getVersion, 1)
.update();
}
/**
* 设置默认协议
*/
public void setDefault(Long id){
this.lambdaUpdate()
.eq(UserProtocol::getId,id)
.set(UserProtocol::getDefaultProtocol,true)
.setIncrBy(MpRealDelEntity::getVersion, 1)
.update();
}
/**
* 取消默认协议
*/
public void cancelDefault(Long id){
this.lambdaUpdate()
.eq(UserProtocol::getId,id)
.set(UserProtocol::getDefaultProtocol,false)
.setIncrBy(MpRealDelEntity::getVersion, 1)
.update();
}
}

View File

@@ -0,0 +1,14 @@
package cn.bootx.platform.baseapi.dao.protocol;
import cn.bootx.platform.baseapi.entity.protocol.UserProtocol;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author xxm
* @since 2025/5/9
*/
@Mapper
public interface UserProtocolMapper extends MPJBaseMapper<UserProtocol> {
}

View File

@@ -28,10 +28,10 @@ public class SystemParameter extends MpBaseEntity implements ToResult<SystemPara
private String name;
/** 参数键名 */
private String key;
private String paramKey;
/** 参数值 */
private String value;
private String paramValue;
/** 参数类型 */
private String type;

View File

@@ -0,0 +1,47 @@
package cn.bootx.platform.baseapi.entity.protocol;
import cn.bootx.platform.baseapi.convert.protocol.UserProtocolConvert;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolParam;
import cn.bootx.platform.baseapi.result.protocol.UserProtocolResult;
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
import cn.bootx.platform.common.mybatisplus.function.ToResult;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 用户协议管理
* @author xxm
* @since 2025/5/9
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@TableName("base_user_protocol")
public class UserProtocol extends MpBaseEntity implements ToResult<UserProtocolResult> {
/** 名称 */
private String name;
/** 显示名称 */
private String showName;
/** 类型 */
private String type;
/** 默认协议 */
private Boolean defaultProtocol;
/** 内容 */
private String content;
@Override
public UserProtocolResult toResult() {
return UserProtocolConvert.CONVERT.toResult(this);
}
public static UserProtocol init(UserProtocolParam param) {
return UserProtocolConvert.CONVERT.toEntity(param);
}
}

View File

@@ -0,0 +1,44 @@
package cn.bootx.platform.baseapi.param.protocol;
import cn.bootx.platform.core.validation.ValidationGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 用户协议管理
* @author xxm
* @since 2025/5/9
*/
@Data
@Accessors(chain = true)
@Schema(title = "用户协议管理")
public class UserProtocolParam {
@Null(message = "Id需要为空", groups = ValidationGroup.add.class)
@NotNull(message = "Id不可为空", groups = ValidationGroup.edit.class)
@Schema(description = "主键")
private Long id;
/** 名称 */
@NotBlank(message = "名称不能为空")
@Schema(description = "名称")
private String name;
/** 显示名称 */
@NotBlank(message = "显示名称不能为空")
@Schema(description = "显示名称")
private String showName;
/** 类型 */
@NotBlank(message = "类型不能为空")
@Schema(description = "类型")
private String type;
/** 内容 */
@Schema(description = "内容")
private String content;
}

View File

@@ -0,0 +1,32 @@
package cn.bootx.platform.baseapi.param.protocol;
import cn.bootx.platform.common.mybatisplus.query.entity.SortParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 用户协议
* @author xxm
* @since 2025/5/11
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "用户协议")
public class UserProtocolQuery extends SortParam {
/** 名称 */
@Schema(description = "名称")
private String name;
/** 显示名称 */
@Schema(description = "显示名称")
private String showName;
/** 类型 */
@Schema(description = "类型")
private String type;
}

View File

@@ -0,0 +1,39 @@
package cn.bootx.platform.baseapi.result.protocol;
import cn.bootx.platform.core.result.BaseResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 用户协议管理
* @author xxm
* @since 2025/5/9
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "用户协议管理")
public class UserProtocolResult extends BaseResult {
/** 名称 */
@Schema(description = "名称")
private String name;
/** 显示名称 */
@Schema(description = "显示名称")
private String showName;
/** 类型 */
@Schema(description = "类型")
private String type;
/** 默认协议 */
@Schema(description = "默认协议")
private Boolean defaultProtocol;
/** 内容 */
@Schema(description = "内容")
private String content;
}

View File

@@ -36,7 +36,7 @@ public class SystemParamService {
*/
public void add(SystemParameterParam param) {
SystemParameter systemParameter = SystemParameter.init(param);
if (systemParamManager.existsByKey(systemParameter.getKey())) {
if (systemParamManager.existsByKey(systemParameter.getParamKey())) {
throw new BizException("key重复");
}
// 默认非内置
@@ -81,7 +81,7 @@ public class SystemParamService {
if (Objects.equals(param.getEnable(), false)) {
throw new BizException("该参数已停用");
}
return param.getValue();
return param.getParamValue();
}
/**

View File

@@ -0,0 +1,107 @@
package cn.bootx.platform.baseapi.service.protocol;
import cn.bootx.platform.baseapi.dao.protocol.UserProtocolManager;
import cn.bootx.platform.baseapi.entity.protocol.UserProtocol;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolParam;
import cn.bootx.platform.baseapi.param.protocol.UserProtocolQuery;
import cn.bootx.platform.baseapi.result.protocol.UserProtocolResult;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.core.exception.BizException;
import cn.bootx.platform.core.exception.DataNotExistException;
import cn.bootx.platform.core.rest.param.PageParam;
import cn.bootx.platform.core.rest.result.PageResult;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 用户协议管理服务
* @author xxm
* @since 2025/5/9
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class UserProtocolService {
private final UserProtocolManager userProtocolManager;
/**
* 分页
*/
public PageResult<UserProtocolResult> page(PageParam pageParam, UserProtocolQuery query){
return MpUtil.toPageResult(userProtocolManager.page(pageParam,query));
}
/**
* 添加
*/
public void add(UserProtocolParam param){
var userProtocol = UserProtocol.init(param);
userProtocolManager.save(userProtocol);
}
/**
* 更新
*/
public void update(UserProtocolParam param){
var userProtocol = userProtocolManager.findById(param.getId())
.orElseThrow(() -> new DataNotExistException("用户协议不存在"));
BeanUtil.copyProperties(param, userProtocol, CopyOptions.create().ignoreNullValue());
userProtocolManager.updateById(userProtocol);
}
/**
* 删除
*/
public void delete(Long id){
// 默认不可被删除
var userProtocol = userProtocolManager.findById(id)
.orElseThrow(() -> new DataNotExistException("用户协议不存在"));
if (userProtocol.getDefaultProtocol()){
throw new BizException("默认协议不可删除");
}
userProtocolManager.deleteById(id);
}
/**
* 根据ID查询
*/
public UserProtocolResult findById(Long id){
return userProtocolManager.findById(id)
.map(UserProtocol::toResult)
.orElseThrow(() -> new DataNotExistException("用户协议不存在"));
}
/**
* 根据分类查询默认协议
*/
public UserProtocolResult findDefault(String type){
return userProtocolManager.findDefault(type)
.map(UserProtocol::toResult)
.orElseThrow(() -> new DataNotExistException("用户协议不存在"));
}
/**
* 设置默认协议
*/
@Transactional(rollbackFor = Exception.class)
public void setDefault(Long id){
var userProtocol = userProtocolManager.findById(id)
.orElseThrow(() -> new DataNotExistException("用户协议不存在"));
userProtocolManager.clearDefault(userProtocol.getType());
userProtocolManager.setDefault(id);
}
/**
* 取消默认协议
*/
public void cancelDefault(Long id){
var userProtocol = userProtocolManager.findById(id)
.orElseThrow(() -> new DataNotExistException("用户协议不存在"));
userProtocolManager.cancelDefault(id);
}
}