release- 判断是否已通过实名认证,才能新建专辑

release-2024-08-08
pikaqiudeshujia 7 months ago
parent 9065196e6d
commit c321e0856d

@ -10,6 +10,10 @@ package constants;
*/ */
public class ErrorConstants { 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_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核";
public final static String MUST_OPERATE_IN_PERSON = "必须本人操作"; public final static String MUST_OPERATE_IN_PERSON = "必须本人操作";

@ -47,4 +47,12 @@ public interface UserClient {
@GetMapping("/simple_user/user/{id}") @GetMapping("/simple_user/user/{id}")
UserInfoDTO findByUserId(@PathVariable String id); UserInfoDTO findByUserId(@PathVariable String id);
/**
*
*
* @param userId id
* @return
*/
@GetMapping("/my/info/real/{userId}")
Boolean getRealNameInfo(@PathVariable String userId);
} }

@ -1,6 +1,7 @@
package com.luoo.music.service; package com.luoo.music.service;
import api.PageResult; import api.PageResult;
import com.luoo.music.client.UserClient;
import com.luoo.music.dao.*; import com.luoo.music.dao.*;
import com.luoo.music.dto.response.*; import com.luoo.music.dto.response.*;
import com.luoo.music.pojo.*; import com.luoo.music.pojo.*;
@ -10,6 +11,7 @@ import dto.UserLoginDto;
import enums.AlbumStateEnum; import enums.AlbumStateEnum;
import enums.SongInfoChargeEnum; import enums.SongInfoChargeEnum;
import enums.SongInfoStateEnum; import enums.SongInfoStateEnum;
import enums.UserTypeEnum;
import exception.BizException; import exception.BizException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -69,6 +71,9 @@ public class AlbumService {
@Autowired @Autowired
private S3Service s3Service; private S3Service s3Service;
@Autowired
private UserClient userClient;
public PageResult<ArtistAlbum> getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) { public PageResult<ArtistAlbum> getList(AlbumSearchDTO albumSearchDTO, Integer page, Integer size) {
List<ArtistAlbum> result = new ArrayList<>(); List<ArtistAlbum> result = new ArrayList<>();
Sort sort = new Sort(Sort.Direction.DESC, "createTime"); Sort sort = new Sort(Sort.Direction.DESC, "createTime");
@ -248,6 +253,20 @@ public class AlbumService {
artistAlbum.setId(String.valueOf(idWorker.nextId())); artistAlbum.setId(String.valueOf(idWorker.nextId()));
UserLoginDto user = jwtUtil.getUserLoginDto(token); UserLoginDto user = jwtUtil.getUserLoginDto(token);
if (user != null) { 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()); artistAlbum.setCreateUser(user.getUserId());
} else { } else {
// 用户校验失败,请重新登录 // 用户校验失败,请重新登录
@ -265,6 +284,10 @@ public class AlbumService {
} }
} }
private void checkRealNameType(String userId) {
}
/** /**
* *
* *

@ -575,5 +575,16 @@ public class MyController extends BaseController {
return Result.success(); return Result.success();
} }
/**
*
*
* @param userId id
* @return
*/
@GetMapping("/info/real/name/{userId}")
public Boolean getRealNameInfo(@PathVariable String userId) {
return userInfoService.getRealNameInfo(userId);
}
} }

@ -17,6 +17,9 @@ import java.util.List;
*/ */
public interface UserRealNameDao extends JpaRepository<UserRealName, String>, JpaSpecificationExecutor<UserRealName> { public interface UserRealNameDao extends JpaRepository<UserRealName, String>, JpaSpecificationExecutor<UserRealName> {
@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<UserRealName> checkExist(String userId); public List<UserRealName> checkExist(String userId);
@Query(value = "select * from tb_user_real_name where user_id = ? and state = 2", nativeQuery = true)
public List<UserRealName> passList(String userId);
} }

@ -522,4 +522,15 @@ public class UserInfoService {
userRealName.setUpdateUser(user.getUserId()); userRealName.setUpdateUser(user.getUserId());
userRealNameDao.save(userRealName); userRealNameDao.save(userRealName);
} }
/**
* id
*
* @param userId id
* @return
*/
public Boolean getRealNameInfo(String userId) {
List<UserRealName> userRealNames = userRealNameDao.passList(userId);
return !userRealNames.isEmpty();
}
} }

Loading…
Cancel
Save