diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index 5e57e1d..cd9e21c 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -10,6 +10,10 @@ package constants; */ public class ErrorConstants { // 专辑部分 + public final static String USER_IS_NOT_ARTIST = "只有音乐人可以新建专辑"; + + public final static String THE_REAL_NAME_AUTHENTICATION_IS_NOT_PASSED = "未通过实名认证"; + public final static String MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核"; public final static String MUST_OPERATE_IN_PERSON = "必须本人操作"; diff --git a/luoo_music/src/main/java/com/luoo/music/client/UserClient.java b/luoo_music/src/main/java/com/luoo/music/client/UserClient.java index 157cccc..0b9ce0a 100644 --- a/luoo_music/src/main/java/com/luoo/music/client/UserClient.java +++ b/luoo_music/src/main/java/com/luoo/music/client/UserClient.java @@ -47,4 +47,12 @@ public interface UserClient { @GetMapping("/simple_user/user/{id}") UserInfoDTO findByUserId(@PathVariable String id); + /** + * 判断用户是否已通过实名认证 + * + * @param userId 用户id + * @return 是否通过 + */ + @GetMapping("/my/info/real/{userId}") + Boolean getRealNameInfo(@PathVariable String userId); } diff --git a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java index 05d3c38..b3421e9 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java @@ -1,6 +1,7 @@ package com.luoo.music.service; import api.PageResult; +import com.luoo.music.client.UserClient; import com.luoo.music.dao.*; import com.luoo.music.dto.response.*; import com.luoo.music.pojo.*; @@ -10,6 +11,7 @@ import dto.UserLoginDto; import enums.AlbumStateEnum; import enums.SongInfoChargeEnum; import enums.SongInfoStateEnum; +import enums.UserTypeEnum; import exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -69,6 +71,9 @@ public class AlbumService { @Autowired private S3Service s3Service; + @Autowired + private UserClient userClient; + public PageResult getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) { List result = new ArrayList<>(); Sort sort = new Sort(Sort.Direction.DESC, "createTime"); @@ -248,6 +253,20 @@ public class AlbumService { artistAlbum.setId(String.valueOf(idWorker.nextId())); UserLoginDto user = jwtUtil.getUserLoginDto(token); if (user != null) { + Integer type = artistAlbum.getType(); + if(ObjectUtils.notEqual(UserTypeEnum.ARTIST_PERSON.getCode(), type) && + ObjectUtils.notEqual(UserTypeEnum.ARTIST_BAND.getCode(), type) + ) { + throw new BizException(ErrorConstants.USER_IS_NOT_ARTIST); + } + + // 校验是否通过实名认证 + Boolean realNameInfo = userClient.getRealNameInfo(user.getUserId()); + if(!realNameInfo) { + // 未通过实名认证 + throw new BizException(ErrorConstants.THE_REAL_NAME_AUTHENTICATION_IS_NOT_PASSED); + } + artistAlbum.setCreateUser(user.getUserId()); } else { // 用户校验失败,请重新登录 @@ -265,6 +284,10 @@ public class AlbumService { } } + private void checkRealNameType(String userId) { + + } + /** * 修改专辑信息 * diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index 828e61c..28789d9 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -575,5 +575,16 @@ public class MyController extends BaseController { return Result.success(); } + /** + * 获取用户实名认证信息 + * + * @param userId 用户id + * @return 实名认证信息 + */ + @GetMapping("/info/real/name/{userId}") + public Boolean getRealNameInfo(@PathVariable String userId) { + return userInfoService.getRealNameInfo(userId); + } + } diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserRealNameDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserRealNameDao.java index 82b9a69..2ddf5f2 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/UserRealNameDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserRealNameDao.java @@ -15,8 +15,11 @@ import java.util.List; * @Filename: UserRealNameDao * @Describe: */ -public interface UserRealNameDao extends JpaRepository, JpaSpecificationExecutor { +public interface UserRealNameDao extends JpaRepository, JpaSpecificationExecutor { - @Query(value = "select * from indie_user.tb_user_real_name where user_id = ? and (state = 1 or state = 2)",nativeQuery = true) + @Query(value = "select * from tb_user_real_name where user_id = ? and (state = 1 or state = 2)", nativeQuery = true) public List checkExist(String userId); + + @Query(value = "select * from tb_user_real_name where user_id = ? and state = 2", nativeQuery = true) + public List passList(String userId); } diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index a3321c4..d6a0202 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -522,4 +522,15 @@ public class UserInfoService { userRealName.setUpdateUser(user.getUserId()); userRealNameDao.save(userRealName); } + + /** + * 根据用户id获取是否有已通过的实名认证信息 + * + * @param userId 用户id + * @return 是否通过 + */ + public Boolean getRealNameInfo(String userId) { + List userRealNames = userRealNameDao.passList(userId); + return !userRealNames.isEmpty(); + } }