refactor: 重构系统参数相关接口

This commit is contained in:
2024-05-28 23:04:03 +08:00
parent a07aedbf35
commit 6d0060b21c
8 changed files with 78 additions and 50 deletions

View File

@@ -41,7 +41,7 @@ public class OptionQuery implements Serializable {
/**
* 键列表
*/
@Schema(description = "键列表", example = "site_title,site_copyright")
@Schema(description = "键列表", example = "SITE_TITLE,SITE_COPYRIGHT")
@Query(type = QueryType.IN)
private List<String> code;
@@ -49,6 +49,5 @@ public class OptionQuery implements Serializable {
* 类别
*/
@Schema(description = "类别", example = "SITE")
@Query
private String category;
}

View File

@@ -18,6 +18,7 @@ package top.continew.admin.system.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.continew.starter.extension.crud.model.req.BaseReq;
@@ -37,6 +38,13 @@ public class OptionReq extends BaseReq {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Schema(description = "ID", example = "1")
@NotNull(message = "ID不能为空")
private Long id;
/**
* 键
*/

View File

@@ -17,7 +17,6 @@
package top.continew.admin.system.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import java.io.Serial;
@@ -40,7 +39,12 @@ public class OptionResetValueReq implements Serializable {
/**
* 键列表
*/
@Schema(description = "键列表", example = "site_title,site_copyright")
@NotEmpty(message = "键不能为空")
@Schema(description = "键列表", example = "SITE_TITLE,SITE_COPYRIGHT")
private List<String> code;
/**
* 类别
*/
@Schema(description = "类别", example = "SITE")
private String category;
}

View File

@@ -37,6 +37,12 @@ public class OptionResp implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Schema(description = "ID", example = "1")
private Long id;
/**
* 名称
*/

View File

@@ -17,8 +17,10 @@
package top.continew.admin.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.continew.admin.common.constant.CacheConstants;
@@ -78,7 +80,16 @@ public class OptionServiceImpl implements OptionService {
@Override
public void resetValue(OptionResetValueReq req) {
RedisUtils.deleteByPattern(CacheConstants.OPTION_KEY_PREFIX + StringConstants.ASTERISK);
baseMapper.lambdaUpdate().set(OptionDO::getValue, null).in(OptionDO::getCode, req.getCode()).update();
String category = req.getCategory();
List<String> codeList = req.getCode();
ValidationUtils.throwIf(StrUtil.isBlank(category) && CollUtil.isEmpty(codeList), "键列表不能为空");
LambdaUpdateChainWrapper<OptionDO> chainWrapper = baseMapper.lambdaUpdate().set(OptionDO::getValue, null);
if (StrUtil.isNotBlank(category)) {
chainWrapper.eq(OptionDO::getCategory, category);
} else {
chainWrapper.in(OptionDO::getCode, req.getCode());
}
chainWrapper.update();
}
@Override