From fb118431acb8d9f6ab7ef6aa7aee97ed02cd8ab18270a0f3ef6f1c00c2e88f04 Mon Sep 17 00:00:00 2001 From: yanglei Date: Mon, 10 Nov 2025 11:13:44 +0800 Subject: [PATCH] =?UTF-8?q?minio=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=87=B3=E4=B8=8D=E5=90=8C=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cdzy/payment/model/entity/EbikeUser.java | 50 ++++------ .../cdzy/user/enums/EbikeFileTypeEnum.java | 27 ++++++ .../com/cdzy/user/model/entity/EbikeUser.java | 5 - .../impl/EbikeFaultReportServiceImpl.java | 20 ++-- .../java/com/cdzy/user/utils/MinioUtil.java | 94 +++++++++++++++---- ebike-user/src/main/resources/db/init.sql | 2 - 6 files changed, 132 insertions(+), 66 deletions(-) create mode 100644 ebike-user/src/main/java/com/cdzy/user/enums/EbikeFileTypeEnum.java diff --git a/ebike-payment/src/main/java/com/cdzy/payment/model/entity/EbikeUser.java b/ebike-payment/src/main/java/com/cdzy/payment/model/entity/EbikeUser.java index 1961b0d..4fc10c4 100644 --- a/ebike-payment/src/main/java/com/cdzy/payment/model/entity/EbikeUser.java +++ b/ebike-payment/src/main/java/com/cdzy/payment/model/entity/EbikeUser.java @@ -13,10 +13,10 @@ import java.io.Serializable; import java.time.LocalDateTime; /** - * 用户基本信息 实体类 + * 用户基本信息实体类 * - * @author: yanglei - * @since: 2025-10-15 09:21 + * @author : yanglei + * @since : 2025-10-15 09:21 */ @Data @@ -42,40 +42,35 @@ public class EbikeUser implements Serializable { */ private String mobile; - /** - * 密码 - */ - private String password; - - /** - * 邮箱 - */ - private String email; - /** * 昵称 */ private String nickname; - /** - * 性别 1-男 2-女 0-未知 - */ - private Integer gender; - - /** - * 生日 - */ - private LocalDateTime birthdate; - /** * 头像 */ private String avatar; /** - * 角色 + * 性别 1-男 2-女 0-未知 */ - private String role; + private Integer gender; + + /** + * 国家 + */ + private String country; + + /** + * 省 + */ + private String province; + + /** + * 市 + */ + private String city; /** * 地址 @@ -92,11 +87,6 @@ public class EbikeUser implements Serializable { */ private Integer userStatus; - /** - * 用户是否通过实名认证 1-是 2-否 - */ - private Integer userRealNameVerified; - /** * 创建人 */ diff --git a/ebike-user/src/main/java/com/cdzy/user/enums/EbikeFileTypeEnum.java b/ebike-user/src/main/java/com/cdzy/user/enums/EbikeFileTypeEnum.java new file mode 100644 index 0000000..1cb1066 --- /dev/null +++ b/ebike-user/src/main/java/com/cdzy/user/enums/EbikeFileTypeEnum.java @@ -0,0 +1,27 @@ +package com.cdzy.user.enums; + +import lombok.Getter; + +/** + * 文件上传至minio不同路径(同一桶中) + * + * @author: yanglei + * @since: 2025-11-10 10:13 + */ + +@Getter +public enum EbikeFileTypeEnum { + + // 用户身份证 + USER_IDCARD("user_idCard/"), + + // 文件故障上报 + FAULT_ATTACHMENT("fault_attachment/"); + + private final String pathPrefix; + + EbikeFileTypeEnum(String pathPrefix) { + this.pathPrefix = pathPrefix; + } + +} diff --git a/ebike-user/src/main/java/com/cdzy/user/model/entity/EbikeUser.java b/ebike-user/src/main/java/com/cdzy/user/model/entity/EbikeUser.java index 37d1e1f..7531258 100644 --- a/ebike-user/src/main/java/com/cdzy/user/model/entity/EbikeUser.java +++ b/ebike-user/src/main/java/com/cdzy/user/model/entity/EbikeUser.java @@ -87,11 +87,6 @@ public class EbikeUser implements Serializable { */ private Integer userStatus; - /** - * 用户是否通过实名认证 1-是 2-否 - */ - private Integer userRealNameVerified; - /** * 创建人 */ diff --git a/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeFaultReportServiceImpl.java b/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeFaultReportServiceImpl.java index f6d741f..d2e3890 100644 --- a/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeFaultReportServiceImpl.java +++ b/ebike-user/src/main/java/com/cdzy/user/service/impl/EbikeFaultReportServiceImpl.java @@ -1,7 +1,7 @@ package com.cdzy.user.service.impl; -import cn.dev33.satoken.stp.StpUtil; import com.cdzy.common.ex.EbikeException; +import com.cdzy.user.enums.EbikeFileTypeEnum; import com.cdzy.user.mapper.EbikeFaultReportMapper; import com.cdzy.user.model.dto.EbikeAttachmentFileDto; import com.cdzy.user.model.dto.EbikeFaultReportDto; @@ -85,17 +85,19 @@ public class EbikeFaultReportServiceImpl extends ServiceImpl getAllBucket() throws Exception{ + public List getAllBucket() throws Exception { List buckets = minioClient.listBuckets(); return buckets.stream().map(Bucket::name).collect(Collectors.toList()); } /** * 下载文件 - * @param bucket 数据桶名称 + * + * @param bucket 数据桶名称 * @param objectName 文件名称 * @return 文件流 * @throws Exception 异常 */ - public InputStream downLoad(String bucket,String objectName) throws Exception{ + public InputStream downLoad(String bucket, String objectName) throws Exception { return minioClient.getObject(GetObjectArgs.builder().bucket(bucket).object(objectName).build()); } /** * 下载默认桶内文件 + * * @param objectName 文件名称 * @return 文件流 * @throws Exception 异常 */ - public InputStream downLoad(String objectName) throws Exception{ + public InputStream downLoad(String objectName) throws Exception { return minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build()); } /** * 删除桶 + * * @param bucket 数据桶名称 * @throws Exception 异常 */ - public void deleteBucket(String bucket) throws Exception{ + public void deleteBucket(String bucket) throws Exception { minioClient.removeBucket(RemoveBucketArgs.builder().bucket(bucket).build()); } /** * 删除文件 - * @param bucket 数据桶名称 + * + * @param bucket 数据桶名称 * @param objectName 文件名称 * @throws Exception 异常 */ - public void deleteObject(String bucket,String objectName) throws Exception{ + public void deleteObject(String bucket, String objectName) throws Exception { minioClient.removeObject(RemoveObjectArgs.builder().bucket(bucket).object(objectName).build()); } /** * 删除默认桶内文件 + * * @param objectName 文件名称 * @throws Exception 异常 */ - public void deleteObject(String objectName) throws Exception{ + public void deleteObject(String objectName) throws Exception { minioClient.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); } /** * 批量上传文件(原子性操作) + * * @param fileStreams 文件流列表 - * @param bucket 数据桶名称 + * @param bucket 数据桶名称 * @param objectNames 文件名列表 * @return 是否全部成功 * @throws Exception 异常 @@ -209,7 +260,8 @@ public class MinioUtil { /** * 回滚批量上传操作 - * @param bucket 数据桶名称 + * + * @param bucket 数据桶名称 * @param objectNames 需要删除的文件名列表 */ private void rollbackBatchUpload(String bucket, List objectNames) { @@ -240,7 +292,8 @@ public class MinioUtil { /** * 获取MinIO中指定文件的文件流 - * @param bucket 数据桶名称 + * + * @param bucket 数据桶名称 * @param objectName 文件名称 * @return 文件流 * @throws Exception 异常 @@ -256,6 +309,7 @@ public class MinioUtil { /** * 获取默认桶中文件的文件流 + * * @param objectName 文件名称 * @return 文件流 * @throws Exception 异常 diff --git a/ebike-user/src/main/resources/db/init.sql b/ebike-user/src/main/resources/db/init.sql index 18c8d6d..04f7b04 100644 --- a/ebike-user/src/main/resources/db/init.sql +++ b/ebike-user/src/main/resources/db/init.sql @@ -123,7 +123,6 @@ CREATE TABLE "public"."ebike_user" ( "address" varchar(200) COLLATE "pg_catalog"."default", "last_login_time" timestamp(6), "user_status" int2, - "user_real_name_verified" int2, "create_by" int8, "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, "update_by" int8, @@ -142,7 +141,6 @@ COMMENT ON COLUMN "public"."ebike_user"."city" IS '市'; COMMENT ON COLUMN "public"."ebike_user"."address" IS '地址'; COMMENT ON COLUMN "public"."ebike_user"."last_login_time" IS '记录用户最后一次登录的时间'; COMMENT ON COLUMN "public"."ebike_user"."user_status" IS '用户的状态,-1-注销 1-激活 2-禁用'; -COMMENT ON COLUMN "public"."ebike_user"."user_real_name_verified" IS '用户是否通过实名认证 1-是 2-否'; COMMENT ON COLUMN "public"."ebike_user"."create_by" IS '创建人ID'; COMMENT ON COLUMN "public"."ebike_user"."create_time" IS '创建时间'; COMMENT ON COLUMN "public"."ebike_user"."update_by" IS '最后修改人ID';