From cd9298e89ff28624e03710eeffa423fc2b5cc43f Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Sun, 28 Apr 2024 08:46:31 +0800 Subject: [PATCH] =?UTF-8?q?release-=E7=94=B3=E8=AF=B7=E5=8E=82=E7=89=8C?= =?UTF-8?q?=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 --- .../main/java/enums/UserProcessTypeEnum.java | 2 +- .../com/luoo/user/service/BandService.java | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/luoo_common/src/main/java/enums/UserProcessTypeEnum.java b/luoo_common/src/main/java/enums/UserProcessTypeEnum.java index 0d7b889..8f54d6d 100644 --- a/luoo_common/src/main/java/enums/UserProcessTypeEnum.java +++ b/luoo_common/src/main/java/enums/UserProcessTypeEnum.java @@ -14,7 +14,7 @@ import lombok.Getter; public enum UserProcessTypeEnum { ARTIST(1, "音乐人"), - SUCCESS(2, "厂牌"); + BAND(2, "厂牌"); private final Integer code; private final String desc; diff --git a/luoo_user/src/main/java/com/luoo/user/service/BandService.java b/luoo_user/src/main/java/com/luoo/user/service/BandService.java index 7318fc4..8a94d83 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/BandService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/BandService.java @@ -3,11 +3,15 @@ package com.luoo.user.service; import com.luoo.user.dao.BandInfoDao; import com.luoo.user.dao.BandOperatorDao; import com.luoo.user.dao.UserInfoDao; +import com.luoo.user.dao.UserProcessDao; import com.luoo.user.dto.band.BandRegisterDto; import com.luoo.user.pojo.BandInfo; import com.luoo.user.pojo.BandOperator; import com.luoo.user.pojo.UserInfo; +import com.luoo.user.pojo.UserProcess; import constants.Constants; +import enums.UserProcessStatusEnum; +import enums.UserProcessTypeEnum; import enums.UserStatusEnum; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import util.IdWorker; import java.util.Date; +import java.util.List; /** * @Author: yawei.huang @@ -44,6 +49,9 @@ public class BandService { @Autowired private BCryptPasswordEncoder encoder; + @Autowired + private UserProcessDao userProcessDao; + @Transactional(rollbackFor = Exception.class) public void bandRegister(BandRegisterDto bandRegisterDto) { UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(bandRegisterDto.getUserName()); @@ -78,6 +86,23 @@ public class BandService { bandOperatorDao.save(bandOperator); + List successList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.BAND.getCode(), UserProcessStatusEnum.SUCCESS.getCode()); + if(!successList.isEmpty()) { + throw new RuntimeException("该账号已审核通过,请勿重复申请"); + } + List upApprovedList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.BAND.getCode(), UserProcessStatusEnum.UNAPPROVED.getCode()); + if(!upApprovedList.isEmpty()) { + throw new RuntimeException("该账号正在审核中,请勿重复申请"); + } + + UserProcess userProcess = UserProcess.builder() + .id(String.valueOf(idWorker.nextId())) + .userId(userInfo.getId()) + .type(UserProcessTypeEnum.BAND.getCode()) + .status(UserProcessStatusEnum.UNAPPROVED.getCode()) + .build(); + userProcessDao.save(userProcess); + }