|
|
@ -1,18 +1,12 @@
|
|
|
|
package com.luoo.user.service;
|
|
|
|
package com.luoo.user.service;
|
|
|
|
|
|
|
|
|
|
|
|
import api.PageResult;
|
|
|
|
import api.PageResult;
|
|
|
|
import com.luoo.user.dao.ArtistInfoDao;
|
|
|
|
import com.luoo.user.dao.*;
|
|
|
|
import com.luoo.user.dao.ArtistUserDao;
|
|
|
|
|
|
|
|
import com.luoo.user.dao.UserInfoDao;
|
|
|
|
|
|
|
|
import com.luoo.user.dao.UserProcessDao;
|
|
|
|
|
|
|
|
import com.luoo.user.dto.UserProcessApproveDto;
|
|
|
|
import com.luoo.user.dto.UserProcessApproveDto;
|
|
|
|
import com.luoo.user.dto.artist.ArtistRegisterDto;
|
|
|
|
import com.luoo.user.dto.artist.ArtistRegisterDto;
|
|
|
|
import com.luoo.user.dto.artist.ArtistSearchDto;
|
|
|
|
import com.luoo.user.dto.artist.ArtistSearchDto;
|
|
|
|
import com.luoo.user.dto.artist.ArtistUserBindDto;
|
|
|
|
import com.luoo.user.dto.artist.ArtistUserBindDto;
|
|
|
|
import com.luoo.user.pojo.ArtistInfo;
|
|
|
|
import com.luoo.user.pojo.*;
|
|
|
|
import com.luoo.user.pojo.ArtistUser;
|
|
|
|
|
|
|
|
import com.luoo.user.pojo.UserInfo;
|
|
|
|
|
|
|
|
import com.luoo.user.pojo.UserProcess;
|
|
|
|
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.Constants;
|
|
|
|
import constants.ErrorConstants;
|
|
|
|
import constants.ErrorConstants;
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
import dto.UserLoginDto;
|
|
|
@ -25,16 +19,24 @@ import exception.BizException;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.JwtUtil;
|
|
|
|
import util.JwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -65,136 +67,69 @@ public class ArtistService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ArtistUserDao artistUserDao;
|
|
|
|
private ArtistUserDao artistUserDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private UserProcessDao userProcessDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private UserMessageService userMessageService;
|
|
|
|
private UserMessageService userMessageService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ArtistRegisterDao artistRegisterDao;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 音乐人注册
|
|
|
|
* 音乐人注册
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void artistRegister(String token, ArtistRegisterDto artistRegisterDto) {
|
|
|
|
public void artistRegister(String token, ArtistRegisterDto artistRegisterDto) {
|
|
|
|
|
|
|
|
|
|
|
|
UserLoginDto currentUser = jwtUtil.getUserLoginDto(token);
|
|
|
|
UserLoginDto currentUser = jwtUtil.getUserLoginDto(token);
|
|
|
|
UserInfo userInfo;
|
|
|
|
String id = artistRegisterDto.getId();
|
|
|
|
if (currentUser == null) {
|
|
|
|
if (StringUtils.isNotBlank(id)) {
|
|
|
|
// 用户校验失败,请重新登录
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(artistRegisterDto.getUserId())) {
|
|
|
|
|
|
|
|
// 重新发起音乐人账号审批
|
|
|
|
|
|
|
|
UserInfo info = userInfoDao.findById(artistRegisterDto.getUserId()).get();
|
|
|
|
|
|
|
|
if(ObjectUtils.notEqual(artistRegisterDto.getUserName(), info.getUserName())) {
|
|
|
|
|
|
|
|
throw new BizException("用户名不允许修改");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Integer count = userInfoDao.countByUserNameAndUserNameNotNullAndIdNot(artistRegisterDto.getUserName(), artistRegisterDto.getUserId());
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
|
|
|
throw new BizException("该用户名已存在,请重新输入!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
userInfo = UserInfo.builder()
|
|
|
|
|
|
|
|
.id(info.getId())
|
|
|
|
|
|
|
|
.nickName(artistRegisterDto.getNickName())
|
|
|
|
|
|
|
|
.avatar(artistRegisterDto.getAvatar())
|
|
|
|
|
|
|
|
.joinTime(new Date())
|
|
|
|
|
|
|
|
.status(UserStatusEnum.UNAPPROVED.getStatus())
|
|
|
|
|
|
|
|
.thumbnail(Constants.DEFAULT_USER_THUMBNAIL)
|
|
|
|
|
|
|
|
.signature(Constants.DEFAULT_USER_SIGNATURE)
|
|
|
|
|
|
|
|
.userName(artistRegisterDto.getUserName())
|
|
|
|
|
|
|
|
.type(artistRegisterDto.getType())
|
|
|
|
|
|
|
|
.password(encoder.encode(artistRegisterDto.getPassword()))
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArtistInfo artistInfoByUserId = artistInfoDao.findArtistInfoByUserId(artistRegisterDto.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增音乐人基本信息
|
|
|
|
|
|
|
|
ArtistInfo artistInfo = ArtistInfo.builder()
|
|
|
|
|
|
|
|
.id(artistInfoByUserId != null ? artistInfoByUserId.getId() : String.valueOf(idWorker.nextId()))
|
|
|
|
|
|
|
|
.userId(userInfo.getId())
|
|
|
|
|
|
|
|
.backgroundImage(artistRegisterDto.getBackgroundImage())
|
|
|
|
|
|
|
|
.address(artistRegisterDto.getAddress())
|
|
|
|
|
|
|
|
.style(artistRegisterDto.getStyle())
|
|
|
|
|
|
|
|
.bandUserId(artistRegisterDto.getBandUserId())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
artistInfoDao.save(artistInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 新增音乐人账号
|
|
|
|
// 新增音乐人账号
|
|
|
|
// 目前一个用户只能新增一个音乐人账号
|
|
|
|
// 一个用户只能新增一个音乐人账号
|
|
|
|
UserProcess currentUserProcess = userProcessDao.findUserProcessByCreateUserAndTypeOrderByCreateTime(currentUser.getUserId(), UserProcessTypeEnum.ARTIST.getCode());
|
|
|
|
List<ArtistRegister> list = artistRegisterDao.findAllByCreateUser(currentUser.getUserId());
|
|
|
|
if(currentUserProcess != null) {
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
// 用户已存在音乐人账号
|
|
|
|
// 用户已存在音乐人账号
|
|
|
|
throw new BizException(ErrorConstants.USER_ALREADY_EXISTS_ARTIST);
|
|
|
|
throw new BizException(ErrorConstants.USER_ALREADY_EXISTS_ARTIST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Integer count = userInfoDao.countByUserNameAndUserNameNotNull(artistRegisterDto.getUserName());
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
|
|
|
throw new BizException("该用户名已存在,请重新输入!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 新增用户基本信息
|
|
|
|
|
|
|
|
userInfo = UserInfo.builder()
|
|
|
|
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
|
|
|
|
.nickName(artistRegisterDto.getNickName())
|
|
|
|
|
|
|
|
.avatar(artistRegisterDto.getAvatar())
|
|
|
|
|
|
|
|
.joinTime(new Date())
|
|
|
|
|
|
|
|
.status(UserStatusEnum.UNAPPROVED.getStatus())
|
|
|
|
|
|
|
|
.thumbnail(Constants.DEFAULT_USER_THUMBNAIL)
|
|
|
|
|
|
|
|
.signature(Constants.DEFAULT_USER_SIGNATURE)
|
|
|
|
|
|
|
|
.userName(artistRegisterDto.getUserName())
|
|
|
|
|
|
|
|
.type(artistRegisterDto.getType())
|
|
|
|
|
|
|
|
.password(encoder.encode(artistRegisterDto.getPassword()))
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增音乐人基本信息
|
|
|
|
|
|
|
|
ArtistInfo artistInfo = ArtistInfo.builder()
|
|
|
|
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
|
|
|
|
.userId(userInfo.getId())
|
|
|
|
|
|
|
|
.backgroundImage(artistRegisterDto.getBackgroundImage())
|
|
|
|
|
|
|
|
.address(artistRegisterDto.getAddress())
|
|
|
|
|
|
|
|
.style(artistRegisterDto.getStyle())
|
|
|
|
|
|
|
|
.bandUserId(artistRegisterDto.getBandUserId())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
artistInfoDao.save(artistInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增音乐人负责人信息
|
|
|
|
List<ArtistRegister> allByUserName = artistRegisterDao.findAllByUserName(artistRegisterDto.getUserName());
|
|
|
|
// ArtistResponsible artistResponsible = ArtistResponsible.builder()
|
|
|
|
if (!allByUserName.isEmpty()) {
|
|
|
|
// .id(String.valueOf(idWorker.nextId()))
|
|
|
|
// 用户名已存在
|
|
|
|
// .userId(userInfo.getId())
|
|
|
|
throw new BizException(ErrorConstants.USER_NAME_ALREADY_EXISTS);
|
|
|
|
// .sex(artistRegisterDto.getSex())
|
|
|
|
|
|
|
|
// .name(artistRegisterDto.getNickName())
|
|
|
|
|
|
|
|
// .mobile(artistRegisterDto.getMobile())
|
|
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
|
|
// artistResponsibleDao.save(artistResponsible);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 审核记录
|
|
|
|
|
|
|
|
List<UserProcess> successList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.ARTIST.getCode(), UserProcessStatusEnum.SUCCESS.getCode());
|
|
|
|
|
|
|
|
if (!successList.isEmpty()) {
|
|
|
|
|
|
|
|
throw new BizException("该账号已审核通过,请勿重复申请");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<UserProcess> upApprovedList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.ARTIST.getCode(), UserProcessStatusEnum.UNAPPROVED.getCode());
|
|
|
|
ArtistRegister artistRegister = new ArtistRegister();
|
|
|
|
if (!upApprovedList.isEmpty()) {
|
|
|
|
BeanUtils.copyProperties(artistRegisterDto, artistRegister);
|
|
|
|
throw new BizException("该账号正在审核中,请勿重复申请");
|
|
|
|
// 未审核状态
|
|
|
|
|
|
|
|
artistRegister.setStatus(UserProcessStatusEnum.UNAPPROVED.getCode());
|
|
|
|
|
|
|
|
// 创建人
|
|
|
|
|
|
|
|
artistRegister.setCreateUser(currentUser.getUserId());
|
|
|
|
|
|
|
|
// 密码加密
|
|
|
|
|
|
|
|
artistRegister.setPassword(encoder.encode(artistRegisterDto.getPassword()));
|
|
|
|
|
|
|
|
artistRegisterDao.save(artistRegister);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 拒绝后重新发起音乐人账号审批
|
|
|
|
|
|
|
|
// 判断当前是否是拒绝状态
|
|
|
|
|
|
|
|
ArtistRegister artistRegister = artistRegisterDao.findById(id).get();
|
|
|
|
|
|
|
|
if (ObjectUtils.notEqual(UserProcessStatusEnum.FAIL.getCode(), artistRegister.getStatus())) {
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.STATE_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UserProcess userProcess = UserProcess.builder()
|
|
|
|
List<ArtistRegister> allByUserName = artistRegisterDao.findAllByUserNameAndIdNot(artistRegisterDto.getUserName(), id);
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
if (!allByUserName.isEmpty()) {
|
|
|
|
.userId(userInfo.getId())
|
|
|
|
// 用户名已存在
|
|
|
|
.type(UserProcessTypeEnum.ARTIST.getCode())
|
|
|
|
throw new BizException(ErrorConstants.USER_NAME_ALREADY_EXISTS);
|
|
|
|
.status(UserProcessStatusEnum.UNAPPROVED.getCode())
|
|
|
|
}
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
|
|
.createUser(currentUser.getUserId())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userProcessDao.save(userProcess);
|
|
|
|
BeanUtils.copyProperties(artistRegisterDto, artistRegister);
|
|
|
|
|
|
|
|
// 未审核状态
|
|
|
|
|
|
|
|
artistRegister.setStatus(UserProcessStatusEnum.UNAPPROVED.getCode());
|
|
|
|
|
|
|
|
// 创建人
|
|
|
|
|
|
|
|
artistRegister.setCreateUser(currentUser.getUserId());
|
|
|
|
|
|
|
|
// 密码加密
|
|
|
|
|
|
|
|
artistRegister.setPassword(encoder.encode(artistRegisterDto.getPassword()));
|
|
|
|
|
|
|
|
artistRegisterDao.save(artistRegister);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -227,27 +162,50 @@ public class ArtistService {
|
|
|
|
throw new BizException("请填写拒绝理由!");
|
|
|
|
throw new BizException("请填写拒绝理由!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UserProcess userProcessById = userProcessDao.findUserProcessById(userProcessApproveDto.getId());
|
|
|
|
ArtistRegister artistRegister = artistRegisterDao.findById(userProcessApproveDto.getId()).get();
|
|
|
|
userProcessById.setContent(userProcessApproveDto.getContent());
|
|
|
|
artistRegister.setStatus(userProcessApproveDto.getStatus());
|
|
|
|
userProcessById.setModifyTime(new Date());
|
|
|
|
artistRegister.setContent(userProcessApproveDto.getContent());
|
|
|
|
userProcessById.setStatus(userProcessApproveDto.getStatus());
|
|
|
|
artistRegister.setModifyTime(new Date());
|
|
|
|
|
|
|
|
artistRegisterDao.save(artistRegister);
|
|
|
|
userProcessDao.save(userProcessById);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userProcessById.getUserId()).get();
|
|
|
|
if (ObjectUtils.equals(UserProcessStatusEnum.SUCCESS.getCode(), userProcessApproveDto.getStatus())) {
|
|
|
|
userInfo.setStatus(ObjectUtils.equals(UserProcessStatusEnum.FAIL.getCode(), userProcessApproveDto.getStatus()) ?
|
|
|
|
// 审核通过
|
|
|
|
UserStatusEnum.DISABLE.getStatus() : UserStatusEnum.ENABLE.getStatus());
|
|
|
|
// 新增用户基本信息,直接是启用状态
|
|
|
|
userInfo.setModifyTime(new Date());
|
|
|
|
UserInfo userInfo = UserInfo.builder()
|
|
|
|
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
|
|
|
|
.nickName(artistRegister.getNickName())
|
|
|
|
|
|
|
|
.avatar(artistRegister.getAvatar())
|
|
|
|
|
|
|
|
.joinTime(new Date())
|
|
|
|
|
|
|
|
.status(UserStatusEnum.ENABLE.getStatus())
|
|
|
|
|
|
|
|
.thumbnail(Constants.DEFAULT_USER_THUMBNAIL)
|
|
|
|
|
|
|
|
.signature(Constants.DEFAULT_USER_SIGNATURE)
|
|
|
|
|
|
|
|
.userName(artistRegister.getUserName())
|
|
|
|
|
|
|
|
.type(artistRegister.getType())
|
|
|
|
|
|
|
|
.password(artistRegister.getPassword())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增音乐人基本信息
|
|
|
|
|
|
|
|
ArtistInfo artistInfo = ArtistInfo.builder()
|
|
|
|
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
|
|
|
|
.userId(userInfo.getId())
|
|
|
|
|
|
|
|
.backgroundImage(artistRegister.getBackgroundImage())
|
|
|
|
|
|
|
|
.address(artistRegister.getAddress())
|
|
|
|
|
|
|
|
.style(artistRegister.getStyle())
|
|
|
|
|
|
|
|
.bandUserId(artistRegister.getBandUserId())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
artistInfoDao.save(artistInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UserInfo sendUser = userInfoDao.findById(artistRegister.getCreateUser()).get();
|
|
|
|
|
|
|
|
|
|
|
|
UserMessageDto userMessageDto = new UserMessageDto();
|
|
|
|
UserMessageDto userMessageDto = new UserMessageDto();
|
|
|
|
userMessageDto.setType(MessageTypeEnum.PRIVATE_MESSAGE.getType());
|
|
|
|
userMessageDto.setType(MessageTypeEnum.PRIVATE_MESSAGE.getType());
|
|
|
|
userMessageDto.setSendUserId(userInfo.getId());
|
|
|
|
userMessageDto.setSendUserId(sendUser.getId());
|
|
|
|
userMessageDto.setTitle(title);
|
|
|
|
userMessageDto.setTitle(title);
|
|
|
|
userMessageDto.setContent(content);
|
|
|
|
userMessageDto.setContent(content);
|
|
|
|
userMessageDto.setUserId(userProcessById.getCreateUser());
|
|
|
|
userMessageDto.setUserId(artistRegister.getCreateUser());
|
|
|
|
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX + userInfo.getAvatar());
|
|
|
|
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX + sendUser.getAvatar());
|
|
|
|
userMessageDto.setSendUserNickName(userInfo.getNickName());
|
|
|
|
userMessageDto.setSendUserNickName(sendUser.getNickName());
|
|
|
|
userMessageService.sendUserMessage(userMessageDto);
|
|
|
|
userMessageService.sendUserMessage(userMessageDto);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -288,60 +246,72 @@ public class ArtistService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 分页显示音乐人列表
|
|
|
|
* 分页显示音乐人列表
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public PageResult<ArtistInfo> getList(ArtistSearchDto artistSearchDto, Integer page, Integer size) {
|
|
|
|
public PageResult<ArtistRegister> getList(ArtistSearchDto artistSearchDto, Integer page, Integer size) {
|
|
|
|
Pageable pageable = PageRequest.of(page - 1, size);
|
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "createTime");
|
|
|
|
Page<ArtistInfo> artistInfoPage;
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
|
|
|
|
if(artistSearchDto.getStatus() == null) {
|
|
|
|
|
|
|
|
artistInfoPage = artistInfoDao.findAllNoStatus(pageable);
|
|
|
|
Specification<ArtistRegister> artistRegisterDtoSpecification = buildSearchSpecification(artistSearchDto);
|
|
|
|
} else {
|
|
|
|
Page<ArtistRegister> artistRegisterPage = artistRegisterDao.findAll(artistRegisterDtoSpecification, pageRequest);
|
|
|
|
artistInfoPage = artistInfoDao.findAllByStatus(artistSearchDto.getStatus(), pageable);
|
|
|
|
|
|
|
|
}
|
|
|
|
long totalElements = artistRegisterPage.getTotalElements();
|
|
|
|
long totalElements = artistInfoPage.getTotalElements();
|
|
|
|
return new PageResult<>(totalElements, artistRegisterPage.getContent());
|
|
|
|
return new PageResult<>(totalElements, artistInfoPage.getContent());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取上一次申请的审批状态
|
|
|
|
* 检索条件
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param param 查询对象
|
|
|
|
|
|
|
|
* @return 检索条件
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public UserProcess lastApplyResult(String token) {
|
|
|
|
private Specification<ArtistRegister> buildSearchSpecification(ArtistSearchDto param) {
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
return (Root<ArtistRegister> root, CriteriaQuery<?> query, CriteriaBuilder builder) -> {
|
|
|
|
if (user == null) {
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getType() != null) {
|
|
|
|
|
|
|
|
predicateList.add(builder.and(builder.equal(root.get("type"), param.getType())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getStatus() != null) {
|
|
|
|
|
|
|
|
predicateList.add(builder.and(builder.equal(root.get("status"), param.getStatus())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getSearchStr())) {
|
|
|
|
|
|
|
|
// 专辑名称
|
|
|
|
|
|
|
|
String likeExpression = "%" + param.getSearchStr() + "%";
|
|
|
|
|
|
|
|
predicateList.add(builder.and(builder.like(root.get("nickName"), likeExpression)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(param.getStyle())) {
|
|
|
|
|
|
|
|
// 专辑名称
|
|
|
|
|
|
|
|
String likeExpression = "%" + param.getStyle() + "%";
|
|
|
|
|
|
|
|
predicateList.add(builder.and(builder.like(root.get("style"), likeExpression)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getStartTime() != null) {
|
|
|
|
|
|
|
|
predicateList.add(builder.greaterThanOrEqualTo(root.get("createTime"), param.getStartTime()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (param.getEndTime() != null) {
|
|
|
|
|
|
|
|
predicateList.add(builder.lessThanOrEqualTo(root.get("createTime"), param.getEndTime()));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return userProcessDao.findUserProcessByCreateUserAndTypeOrderByCreateTime(user.getUserId(), UserProcessTypeEnum.ARTIST.getCode());
|
|
|
|
return builder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 返回给前端上一次申请的对象
|
|
|
|
* 获取上一次申请的审批状态
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public ArtistRegisterDto lastApplyRecord(String token) {
|
|
|
|
public ArtistRegister lastApplyResult(String token) {
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(token);
|
|
|
|
if (user == null) {
|
|
|
|
if (user == null) {
|
|
|
|
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
|
|
|
|
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UserProcess userprocess = userProcessDao.findUserProcessByCreateUserAndTypeOrderByCreateTime(user.getUserId(), UserProcessTypeEnum.ARTIST.getCode());
|
|
|
|
|
|
|
|
String userId = userprocess.getUserId();
|
|
|
|
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userId).get();
|
|
|
|
|
|
|
|
ArtistInfo artistInfoByUserId = artistInfoDao.findArtistInfoByUserId(userId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ArtistRegisterDto.builder()
|
|
|
|
return artistRegisterDao.findArtistRegisterByCreateUserOrderByCreateTime(user.getUserId());
|
|
|
|
.userId(userInfo.getId())
|
|
|
|
|
|
|
|
.nickName(userInfo.getNickName())
|
|
|
|
|
|
|
|
.avatar(userInfo.getAvatar())
|
|
|
|
|
|
|
|
.userName(userInfo.getUserName())
|
|
|
|
|
|
|
|
.type(userInfo.getType())
|
|
|
|
|
|
|
|
.password("")
|
|
|
|
|
|
|
|
.backgroundImage(artistInfoByUserId.getBackgroundImage())
|
|
|
|
|
|
|
|
.address(artistInfoByUserId.getAddress())
|
|
|
|
|
|
|
|
.style(artistInfoByUserId.getStyle())
|
|
|
|
|
|
|
|
.bandUserId(artistInfoByUserId.getBandUserId())
|
|
|
|
|
|
|
|
.screenshot(artistInfoByUserId.getScreenshot())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|