diff --git a/service/src/main/java/cn/bunny/services/factory/UserFactory.java b/service/src/main/java/cn/bunny/services/factory/UserFactory.java index ce98250..83694f4 100644 --- a/service/src/main/java/cn/bunny/services/factory/UserFactory.java +++ b/service/src/main/java/cn/bunny/services/factory/UserFactory.java @@ -149,12 +149,12 @@ public class UserFactory { */ public String checkUserAvatar(String avatar) { if (!StringUtils.hasText(avatar)) return null; - String regex = "https?://.*?/(.*)"; + String regex = "^https?://.*?/(.*)"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(avatar); // 如果没有匹配 - if (!matcher.matches()) return null; + if (!matcher.matches()) return avatar; // 匹配后返回内容 return "/" + matcher.group(1); diff --git a/service/src/main/java/cn/bunny/services/service/impl/PowerServiceImpl.java b/service/src/main/java/cn/bunny/services/service/impl/PowerServiceImpl.java index e47a3c9..eea7068 100644 --- a/service/src/main/java/cn/bunny/services/service/impl/PowerServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/impl/PowerServiceImpl.java @@ -20,6 +20,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jakarta.validation.Valid; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -72,6 +74,7 @@ public class PowerServiceImpl extends ServiceImpl implements * @return 所有权限列表 */ @Override + @Cacheable(cacheNames = "power", key = "'allPower'", cacheManager = "cacheManagerWithMouth") public List getAllPowers() { List powerList = list(); return powerList.stream().map(power -> { @@ -87,6 +90,7 @@ public class PowerServiceImpl extends ServiceImpl implements * @param dto 权限添加 */ @Override + @CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true) public void addPower(@Valid PowerAddDto dto) { // 添加权限时确保权限码和请求地址是唯一的 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -108,6 +112,7 @@ public class PowerServiceImpl extends ServiceImpl implements * @param dto 权限更新 */ @Override + @CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true) public void updatePower(@Valid PowerUpdateDto dto) { Long id = dto.getId(); List powerList = list(Wrappers.lambdaQuery().eq(Power::getId, id)); @@ -126,6 +131,7 @@ public class PowerServiceImpl extends ServiceImpl implements * @param ids 删除id列表 */ @Override + @CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true) public void deletePower(List ids) { // 判断数据请求是否为空 if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY); @@ -143,6 +149,7 @@ public class PowerServiceImpl extends ServiceImpl implements * @param dto 批量修改权限表单 */ @Override + @CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true) public void updateBatchByPowerWithParentId(PowerUpdateBatchByParentIdDto dto) { List powerList = dto.getIds().stream().map(id -> { Power power = new Power(); diff --git a/service/src/main/java/cn/bunny/services/service/impl/RoleServiceImpl.java b/service/src/main/java/cn/bunny/services/service/impl/RoleServiceImpl.java index 0a4d620..690f0a3 100644 --- a/service/src/main/java/cn/bunny/services/service/impl/RoleServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/impl/RoleServiceImpl.java @@ -20,6 +20,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import jakarta.validation.Valid; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.List; @@ -77,6 +79,7 @@ public class RoleServiceImpl extends ServiceImpl implements Ro * @return 所有角色列表 */ @Override + @Cacheable(cacheNames = "role", key = "'allRole'", cacheManager = "cacheManagerWithMouth") public List getAllRoles() { return list().stream().map(role -> { RoleVo roleVo = new RoleVo(); @@ -91,6 +94,7 @@ public class RoleServiceImpl extends ServiceImpl implements Ro * @param dto 角色添加 */ @Override + @CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true) public void addRole(@Valid RoleAddDto dto) { // 判断角色码是否被添加过 List roleList = list(Wrappers.lambdaQuery().eq(Role::getRoleCode, dto.getRoleCode())); @@ -108,6 +112,7 @@ public class RoleServiceImpl extends ServiceImpl implements Ro * @param dto 角色更新 */ @Override + @CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true) public void updateRole(@Valid RoleUpdateDto dto) { // 查询更新的角色是否存在 List roleList = list(Wrappers.lambdaQuery().eq(Role::getId, dto.getId())); @@ -125,6 +130,7 @@ public class RoleServiceImpl extends ServiceImpl implements Ro * @param ids 删除id列表 */ @Override + @CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true) public void deleteRole(List ids) { // 判断数据请求是否为空 if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY); diff --git a/service/src/main/resources/application-dev.yml b/service/src/main/resources/application-dev.yml index 77d66c6..fd81c62 100644 --- a/service/src/main/resources/application-dev.yml +++ b/service/src/main/resources/application-dev.yml @@ -23,8 +23,6 @@ mybatis-plus: map-underscore-to-camel-case: true # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志 - - bunny: master: host: 192.168.3.98 diff --git a/service/src/main/resources/mapper/UserMapper.xml b/service/src/main/resources/mapper/UserMapper.xml index 3fcdaec..019d001 100644 --- a/service/src/main/resources/mapper/UserMapper.xml +++ b/service/src/main/resources/mapper/UserMapper.xml @@ -63,7 +63,6 @@ - order by update_time desc