release- 审核完后发送站内消息,成功失败都需要

release-2024-08-08
pikaqiudeshujia 6 months ago
parent b8bf71ab45
commit c7a780e974

@ -34,7 +34,7 @@ public class ArtistController {
@PostMapping("/register") @PostMapping("/register")
public Result<Void> register(@RequestHeader(value = "Authorization", required = true) String authorization, public Result<Void> register(@RequestHeader(value = "Authorization", required = true) String authorization,
@Validated @RequestBody ArtistRegisterDto artistRegisterDto) { @Validated @RequestBody ArtistRegisterDto artistRegisterDto) {
artistService.artistRegister(artistRegisterDto); artistService.artistRegister(authorization, artistRegisterDto);
return Result.success(); return Result.success();
} }

@ -57,4 +57,7 @@ public class UserProcess implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@LastModifiedDate @LastModifiedDate
private Date modifyTime; private Date modifyTime;
@ApiModelProperty("创建人")
private String createUser;
} }

@ -10,6 +10,10 @@ import com.luoo.user.pojo.ArtistUser;
import com.luoo.user.pojo.UserInfo; import com.luoo.user.pojo.UserInfo;
import com.luoo.user.pojo.UserProcess; import com.luoo.user.pojo.UserProcess;
import constants.Constants; import constants.Constants;
import constants.ErrorConstants;
import dto.UserLoginDto;
import dto.UserMessageDto;
import enums.MessageTypeEnum;
import enums.UserProcessStatusEnum; import enums.UserProcessStatusEnum;
import enums.UserProcessTypeEnum; import enums.UserProcessTypeEnum;
import enums.UserStatusEnum; import enums.UserStatusEnum;
@ -25,6 +29,7 @@ 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 java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -59,12 +64,17 @@ public class ArtistService {
@Autowired @Autowired
private UserProcessDao userProcessDao; private UserProcessDao userProcessDao;
@Autowired
private UserMessageService userMessageService;
@Autowired
private JwtUtil jwtUtil;
/** /**
* *
*
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void artistRegister(ArtistRegisterDto artistRegisterDto) { public void artistRegister(String token, ArtistRegisterDto artistRegisterDto) {
UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(artistRegisterDto.getUserName()); UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(artistRegisterDto.getUserName());
if (userInfoByUserName != null) { if (userInfoByUserName != null) {
@ -124,7 +134,15 @@ public class ArtistService {
.status(UserProcessStatusEnum.UNAPPROVED.getCode()) .status(UserProcessStatusEnum.UNAPPROVED.getCode())
.createTime(new Date()) .createTime(new Date())
.build(); .build();
UserLoginDto user = jwtUtil.getUserLoginDto(token);
if (user != null) {
userProcess.setCreateUser(user.getUserId());
} else {
// 用户校验失败,请重新登录
throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE);
}
userProcessDao.save(userProcess); userProcessDao.save(userProcess);
} }
/** /**
@ -146,6 +164,11 @@ public class ArtistService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void approve(UserProcessApproveDto userProcessApproveDto) { public void approve(UserProcessApproveDto userProcessApproveDto) {
String title = ObjectUtils.equals(UserProcessStatusEnum.SUCCESS.getCode(), userProcessApproveDto.getStatus()) ?
"音乐人审核通过" : "音乐人审核失败";
String content = userProcessApproveDto.getContent();
if (ObjectUtils.equals(UserProcessStatusEnum.FAIL.getCode(), userProcessApproveDto.getStatus()) if (ObjectUtils.equals(UserProcessStatusEnum.FAIL.getCode(), userProcessApproveDto.getStatus())
&& StringUtils.isBlank(userProcessApproveDto.getContent())) { && StringUtils.isBlank(userProcessApproveDto.getContent())) {
throw new BizException("请填写拒绝理由!"); throw new BizException("请填写拒绝理由!");
@ -163,7 +186,16 @@ public class ArtistService {
UserStatusEnum.DISABLE.getStatus() : UserStatusEnum.ENABLE.getStatus()); UserStatusEnum.DISABLE.getStatus() : UserStatusEnum.ENABLE.getStatus());
userInfo.setModifyTime(new Date()); userInfo.setModifyTime(new Date());
userInfoDao.save(userInfo); userInfoDao.save(userInfo);
// todo 审核完后发送站内消息,成功失败都需要
UserMessageDto userMessageDto = new UserMessageDto();
userMessageDto.setType(MessageTypeEnum.PRIVATE_MESSAGE.getType());
userMessageDto.setSendUserId(userInfo.getId());
userMessageDto.setTitle(title);
userMessageDto.setContent(content);
userMessageDto.setUserId(userProcessById.getCreateUser());
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX + userInfo.getAvatar());
userMessageDto.setSendUserNickName(userInfo.getNickName());
userMessageService.sendUserMessage(userMessageDto);
} }
/** /**
@ -189,6 +221,7 @@ public class ArtistService {
/** /**
* - * -
*
* @param artistUserBindDto * @param artistUserBindDto
*/ */
public void unBindArtistAndMember(ArtistUserBindDto artistUserBindDto) { public void unBindArtistAndMember(ArtistUserBindDto artistUserBindDto) {

@ -0,0 +1,3 @@
alter table tb_user_process
add create_user varchar(20) null comment '创建人';
Loading…
Cancel
Save