系统参数 缓存

微信工具类
支付宝工具类
This commit is contained in:
2025-02-12 11:29:06 +08:00
parent adbe0035e2
commit d84000de25
7 changed files with 18 additions and 51 deletions

View File

@@ -2,6 +2,9 @@ package com.czg.service.system.mapper;
import com.czg.system.entity.SysParams;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
/**
* 映射层。
@@ -9,6 +12,11 @@ import com.mybatisflex.core.BaseMapper;
* @author mac
* @since 2025-02-07
*/
@CacheConfig(cacheNames = "params")
public interface SysParamsMapper extends BaseMapper<SysParams> {
@Cacheable(key = "#code")
@Select("select * from sys_params where param_code = #{code}")
SysParams getSysParam(String code);
}

View File

@@ -12,20 +12,19 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.util.ArrayList;
import java.util.List;
/**
* 服务层实现。
* 服务层实现。
*
* @author mac
* @since 2025-02-07
*/
@DubboService
@CacheConfig(cacheNames = "params")
public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams> implements SysParamsService {
public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams> implements SysParamsService {
@Override
public CzgResult<String> insertParams(SysParamsDTO paramsDTO) {
@@ -42,7 +41,7 @@ public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams
sysParams.setParamCode(paramsDTO.getParamCode())
.setParamValue(paramsDTO.getParamValue())
.setParamType(paramsDTO.getParamType())
.setRemark(paramsDTO.getRemark())
.setRemark(paramsDTO.getRemark())
.setCreateUserId(userId);
save(sysParams);
@@ -90,10 +89,8 @@ public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams
}
@Override
@Cacheable(key = "#code")
public CzgResult<SysParamsDTO> getParamsByCode(String code) {
SysParams sysParams = getOne(new QueryWrapper().eq(SysParams::getParamCode, code));
SysParams sysParams = getMapper().getSysParam(code);
if (sysParams == null) {
return CzgResult.failure("参数不存在");
}
@@ -104,14 +101,8 @@ public class SysParamsServiceImpl extends ServiceImpl<SysParamsMapper, SysParams
}
@Override
public SysParamsDTO getParamsByCode2(String code) {
SysParams sysParams = getOne(new QueryWrapper().eq(SysParams::getParamCode, code));
if (sysParams == null) {
return null;
}
return BeanUtil.toBean(sysParams, SysParamsDTO.class);
public SysParams getSysParam(String code) {
return getMapper().getSysParam(code);
}
@Override