| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.oying.domain.BucketStorage; |
| | | import com.oying.modules.security.service.OnlineUserService; |
| | | import com.oying.modules.security.service.UserCacheManager; |
| | | import com.oying.modules.system.domain.Job; |
| | |
| | | import com.oying.modules.system.mapper.UserMapper; |
| | | import com.oying.modules.system.mapper.UserRoleMapper; |
| | | import com.oying.modules.system.service.UserService; |
| | | import com.oying.service.BucketStorageService; |
| | | import com.oying.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.oying.config.properties.FileProperties; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | private final RedisUtils redisUtils; |
| | | private final UserCacheManager userCacheManager; |
| | | private final OnlineUserService onlineUserService; |
| | | private final BucketStorageService bucketStorageService; |
| | | |
| | | @Override |
| | | public PageResult<User> queryAll(UserQueryCriteria criteria, Page<Object> page) { |
| | |
| | | } |
| | | User user = userMapper.findByUsername(SecurityUtils.getCurrentUsername()); |
| | | String oldPath = user.getAvatarPath(); |
| | | File file = FileUtil.upload(multipartFile, properties.getPath().getAvatar()); |
| | | user.setAvatarPath(Objects.requireNonNull(file).getPath()); |
| | | user.setAvatarName(file.getName()); |
| | | BucketStorage bucketStorage = bucketStorageService.create(null, multipartFile); |
| | | user.setAvatarPath(bucketStorage.getPath()); |
| | | user.setAvatarName(bucketStorage.getRealName()); |
| | | saveOrUpdate(user); |
| | | if (StringUtils.isNotBlank(oldPath)) { |
| | | FileUtil.del(oldPath); |
| | | bucketStorageService.deleteById(oldPath); |
| | | } |
| | | @NotBlank String username = user.getUsername(); |
| | | flushCache(username); |
| | | return new HashMap<String, String>(1) {{ |
| | | put("avatar", file.getName()); |
| | | put("avatar", bucketStorage.getRealName()); |
| | | }}; |
| | | } |
| | | |