From 09c2841fa3b3ca090207d843d20b91b7e71028e6 Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Sun, 28 Apr 2024 08:45:21 +0800 Subject: [PATCH] =?UTF-8?q?release-=E7=94=B3=E8=AF=B7=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E4=BA=BA=E6=97=B6=E6=96=B0=E5=A2=9E=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/enums/UserProcessStatusEnum.java | 26 +++++++++++++++++ .../main/java/enums/UserProcessTypeEnum.java | 27 ++++++++++++++++++ .../com/luoo/user/dao/UserProcessDao.java | 5 ++++ .../java/com/luoo/user/pojo/UserProcess.java | 4 +-- .../com/luoo/user/service/ArtistService.java | 28 ++++++++++++++++--- 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 luoo_common/src/main/java/enums/UserProcessStatusEnum.java create mode 100644 luoo_common/src/main/java/enums/UserProcessTypeEnum.java diff --git a/luoo_common/src/main/java/enums/UserProcessStatusEnum.java b/luoo_common/src/main/java/enums/UserProcessStatusEnum.java new file mode 100644 index 0000000..47a72fe --- /dev/null +++ b/luoo_common/src/main/java/enums/UserProcessStatusEnum.java @@ -0,0 +1,26 @@ +package enums; + +import lombok.Getter; + +/** + * @Author: yawei.huang + * @Package: enums + * @Project: luoo_parent + * @Date: 2024/4/28 8:36 + * @Filename: UserProcessStatusEnum + * @Describe: + */ +@Getter +public enum UserProcessStatusEnum { + UNAPPROVED(0, "未审核"), + SUCCESS(1, "审核成功"), + FAIL(2, "审核失败"); + + private final Integer code; + private final String desc; + + UserProcessStatusEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } +} diff --git a/luoo_common/src/main/java/enums/UserProcessTypeEnum.java b/luoo_common/src/main/java/enums/UserProcessTypeEnum.java new file mode 100644 index 0000000..0d7b889 --- /dev/null +++ b/luoo_common/src/main/java/enums/UserProcessTypeEnum.java @@ -0,0 +1,27 @@ +package enums; + +import lombok.Getter; + +/** + * @Author: yawei.huang + * @Package: enums + * @Project: luoo_parent + * @Date: 2024/4/28 8:34 + * @Filename: UserProcessTypeEnum + * @Describe: + */ +@Getter +public enum UserProcessTypeEnum { + + ARTIST(1, "音乐人"), + SUCCESS(2, "厂牌"); + + private final Integer code; + private final String desc; + + UserProcessTypeEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserProcessDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserProcessDao.java index 23a401d..7232cd3 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/UserProcessDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserProcessDao.java @@ -4,6 +4,8 @@ import com.luoo.user.pojo.UserProcess; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import java.util.List; + /** * @Author: yawei.huang * @Package: com.luoo.user.dao @@ -13,4 +15,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @Describe: */ public interface UserProcessDao extends JpaRepository, JpaSpecificationExecutor { + + public List findUserProcessByUserIdAndTypeAndStatus(String userId, Integer type, Integer status); + } diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/UserProcess.java b/luoo_user/src/main/java/com/luoo/user/pojo/UserProcess.java index 7b91e31..1c1b4c1 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/UserProcess.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/UserProcess.java @@ -33,10 +33,10 @@ public class UserProcess implements Serializable { private String userId; @ApiModelProperty("申请类型 1-音乐人 2-厂牌") - private String type; + private Integer type; @ApiModelProperty("申请状态 0-待审批 1-审批通过 2-审批成功") - private String status; + private Integer status; @ApiModelProperty("拒绝理由") private String content; diff --git a/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java index 36d40f1..3659d49 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java @@ -3,11 +3,10 @@ package com.luoo.user.service; import com.luoo.user.dao.*; import com.luoo.user.dto.artist.ArtistRegisterDto; import com.luoo.user.dto.artist.ArtistUserBindDto; -import com.luoo.user.pojo.ArtistInfo; -import com.luoo.user.pojo.ArtistResponsible; -import com.luoo.user.pojo.ArtistUser; -import com.luoo.user.pojo.UserInfo; +import com.luoo.user.pojo.*; import constants.Constants; +import enums.UserProcessStatusEnum; +import enums.UserProcessTypeEnum; import enums.UserStatusEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; import util.IdWorker; import java.util.Date; +import java.util.List; /** * @Author: yawei.huang @@ -51,6 +51,9 @@ public class ArtistService { @Autowired private ArtistUserDao artistUserDao; + @Autowired + private UserProcessDao userProcessDao; + /** * 音乐人注册 * @@ -98,6 +101,23 @@ public class ArtistService { .build(); artistResponsibleDao.save(artistResponsible); + // 审核记录 + List successList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.ARTIST.getCode(), UserProcessStatusEnum.SUCCESS.getCode()); + if(!successList.isEmpty()) { + throw new RuntimeException("该账号已审核通过,请勿重复申请"); + } + List upApprovedList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.ARTIST.getCode(), UserProcessStatusEnum.UNAPPROVED.getCode()); + if(!upApprovedList.isEmpty()) { + throw new RuntimeException("该账号正在审核中,请勿重复申请"); + } + + UserProcess userProcess = UserProcess.builder() + .id(String.valueOf(idWorker.nextId())) + .userId(userInfo.getId()) + .type(UserProcessTypeEnum.ARTIST.getCode()) + .status(UserProcessStatusEnum.UNAPPROVED.getCode()) + .build(); + userProcessDao.save(userProcess); } /**