fix: 用户头像上传不能回显
This commit is contained in:
parent
adc1d89a91
commit
bf62e081c0
|
@ -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);
|
||||
|
|
|
@ -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<PowerMapper, Power> implements
|
|||
* @return 所有权限列表
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(cacheNames = "power", key = "'allPower'", cacheManager = "cacheManagerWithMouth")
|
||||
public List<PowerVo> getAllPowers() {
|
||||
List<Power> powerList = list();
|
||||
return powerList.stream().map(power -> {
|
||||
|
@ -87,6 +90,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
|
|||
* @param dto 权限添加
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
|
||||
public void addPower(@Valid PowerAddDto dto) {
|
||||
// 添加权限时确保权限码和请求地址是唯一的
|
||||
LambdaQueryWrapper<Power> wrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -108,6 +112,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
|
|||
* @param dto 权限更新
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
|
||||
public void updatePower(@Valid PowerUpdateDto dto) {
|
||||
Long id = dto.getId();
|
||||
List<Power> powerList = list(Wrappers.<Power>lambdaQuery().eq(Power::getId, id));
|
||||
|
@ -126,6 +131,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
|
|||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
|
||||
public void deletePower(List<Long> ids) {
|
||||
// 判断数据请求是否为空
|
||||
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
|
||||
|
@ -143,6 +149,7 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
|
|||
* @param dto 批量修改权限表单
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
|
||||
public void updateBatchByPowerWithParentId(PowerUpdateBatchByParentIdDto dto) {
|
||||
List<Power> powerList = dto.getIds().stream().map(id -> {
|
||||
Power power = new Power();
|
||||
|
|
|
@ -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<RoleMapper, Role> implements Ro
|
|||
* @return 所有角色列表
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(cacheNames = "role", key = "'allRole'", cacheManager = "cacheManagerWithMouth")
|
||||
public List<RoleVo> getAllRoles() {
|
||||
return list().stream().map(role -> {
|
||||
RoleVo roleVo = new RoleVo();
|
||||
|
@ -91,6 +94,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
* @param dto 角色添加
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
|
||||
public void addRole(@Valid RoleAddDto dto) {
|
||||
// 判断角色码是否被添加过
|
||||
List<Role> roleList = list(Wrappers.<Role>lambdaQuery().eq(Role::getRoleCode, dto.getRoleCode()));
|
||||
|
@ -108,6 +112,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
* @param dto 角色更新
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
|
||||
public void updateRole(@Valid RoleUpdateDto dto) {
|
||||
// 查询更新的角色是否存在
|
||||
List<Role> roleList = list(Wrappers.<Role>lambdaQuery().eq(Role::getId, dto.getId()));
|
||||
|
@ -125,6 +130,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
|
||||
public void deleteRole(List<Long> ids) {
|
||||
// 判断数据请求是否为空
|
||||
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by update_time desc
|
||||
</select>
|
||||
|
||||
<!-- 查询用户 -->
|
||||
|
|
Loading…
Reference in New Issue