mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	feat: 文件上传按日期拆分目录 & 事务检查 (#68)
This commit is contained in:
		| @@ -28,6 +28,7 @@ import lombok.RequiredArgsConstructor; | |||||||
| import me.zhyd.oauth.model.AuthUser; | import me.zhyd.oauth.model.AuthUser; | ||||||
| import org.springframework.security.crypto.password.PasswordEncoder; | import org.springframework.security.crypto.password.PasswordEncoder; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
| import top.continew.admin.auth.model.resp.RouteResp; | import top.continew.admin.auth.model.resp.RouteResp; | ||||||
| import top.continew.admin.auth.service.LoginService; | import top.continew.admin.auth.service.LoginService; | ||||||
| import top.continew.admin.auth.service.PermissionService; | import top.continew.admin.auth.service.PermissionService; | ||||||
| @@ -108,6 +109,7 @@ public class LoginServiceImpl implements LoginService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public String socialLogin(AuthUser authUser) { |     public String socialLogin(AuthUser authUser) { | ||||||
|         String source = authUser.getSource(); |         String source = authUser.getSource(); | ||||||
|         String openId = authUser.getUuid(); |         String openId = authUser.getUuid(); | ||||||
|   | |||||||
| @@ -47,6 +47,7 @@ import top.continew.starter.core.util.URLUtils; | |||||||
| import top.continew.starter.core.util.validate.CheckUtils; | import top.continew.starter.core.util.validate.CheckUtils; | ||||||
| import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; | import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; | ||||||
|  |  | ||||||
|  | import java.time.LocalDate; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||||
| @@ -89,9 +90,13 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes | |||||||
|             storage = storageService.getByCode(storageCode); |             storage = storageService.getByCode(storageCode); | ||||||
|             CheckUtils.throwIfNotExists(storage, "StorageDO", "Code", storageCode); |             CheckUtils.throwIfNotExists(storage, "StorageDO", "Code", storageCode); | ||||||
|         } |         } | ||||||
|  |         LocalDate today = LocalDate.now(); | ||||||
|  |         String path = today.getYear() + StringConstants.SLASH + today.getMonthValue() + StringConstants.SLASH + today | ||||||
|  |             .getDayOfMonth() + StringConstants.SLASH; | ||||||
|         UploadPretreatment uploadPretreatment = fileStorageService.of(file) |         UploadPretreatment uploadPretreatment = fileStorageService.of(file) | ||||||
|             .setPlatform(storage.getCode()) |             .setPlatform(storage.getCode()) | ||||||
|             .putAttr(ClassUtil.getClassName(StorageDO.class, false), storage); |             .putAttr(ClassUtil.getClassName(StorageDO.class, false), storage) | ||||||
|  |             .setPath(path); | ||||||
|         // 图片文件生成缩略图 |         // 图片文件生成缩略图 | ||||||
|         if (FileTypeEnum.IMAGE.getExtensions().contains(FileNameUtil.extName(file.getOriginalFilename()))) { |         if (FileTypeEnum.IMAGE.getExtensions().contains(FileNameUtil.extName(file.getOriginalFilename()))) { | ||||||
|             uploadPretreatment.thumbnail(img -> img.size(100, 100)); |             uploadPretreatment.thumbnail(img -> img.size(100, 100)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 kils
					kils