Merge remote-tracking branch 'origin/release-2024-04-25' into release-2024-04-25

release-2024-08-08
huangyawei 6 months ago
commit 17fe73d066

@ -29,5 +29,17 @@
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.7.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -0,0 +1,52 @@
package util;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* @Author: yawei.huang
* @Package: util
* @Project: luoo_parent
* @Date: 2024/5/30 8:34
* @Filename: RedisLockUtil
* @Describe:
*/
@Component
public class RedisLockUtil {
@Resource
private RedisTemplate<String, String> redisTemplate;
private static final String KEY_PREFIX = "serial_number:";
private static final String DATE_FORMAT = "yyMMdd";
public String generateSerialNumber() {
String key = KEY_PREFIX + getCurrentDate();
Long increment = redisTemplate.opsForValue().increment(key, 1);
if (increment == 1) {
redisTemplate.expire(key, getSecondsUntilEndOfDay(), TimeUnit.SECONDS);
}
return getCurrentDate() + String.format("%04d", increment);
}
private String getCurrentDate() {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
return sdf.format(new Date());
}
private long getSecondsUntilEndOfDay() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime endOfDay = now.with(LocalTime.MAX);
Duration duration = Duration.between(now, endOfDay);
return duration.getSeconds();
}
}

@ -1,6 +1,4 @@
package com.luoo.user; package com.luoo.user;
import java.net.InetAddress;
import java.net.UnknownHostException;
import com.spring4all.mongodb.EnableMongoPlus; import com.spring4all.mongodb.EnableMongoPlus;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -9,13 +7,17 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import util.IdWorker; import util.IdWorker;
import util.JwtUtil; import util.JwtUtil;
import util.RedisLockUtil;
import java.net.InetAddress;
import java.net.UnknownHostException;
@EnableMongoPlus @EnableMongoPlus
@SpringBootApplication @SpringBootApplication
@ -55,4 +57,9 @@ public class UserApplication {
public JwtUtil jwtUtil(){ public JwtUtil jwtUtil(){
return new JwtUtil(); return new JwtUtil();
} }
@Bean
public RedisLockUtil redisLockUtil() {
return new RedisLockUtil();
}
} }

@ -86,7 +86,7 @@ public class ArtistController {
@ApiOperation(value = "上一次申请的记录", notes = "上一次申请的记录:申请状态 0-待审批 1-审批通过 2-审批不通过") @ApiOperation(value = "上一次申请的记录", notes = "上一次申请的记录:申请状态 0-待审批 1-审批通过 2-审批不通过")
@GetMapping("/last/apply/record") @GetMapping("/last/apply/record")
public Result<ArtistRegister> lastApplyRecord(@ApiParam(value = "Header中的token信息", required = true) String token) { public Result<ArtistRegister> lastApplyRecord(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token) {
return Result.success(artistService.lastApplyResult(token)); return Result.success(artistService.lastApplyResult(token));
} }

@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -22,7 +23,7 @@ public class UserProcessApproveDto implements Serializable {
private String id; private String id;
@ApiModelProperty("审核结果 1-通过 2-拒绝") @ApiModelProperty("审核结果 1-通过 2-拒绝")
@NotBlank(message = "审核结果必填") @NotNull(message = "审核结果必填")
private Integer status; private Integer status;
@ApiModelProperty("拒绝理由") @ApiModelProperty("拒绝理由")

@ -49,4 +49,7 @@ public class ArtistInfo implements Serializable {
@ApiModelProperty(name = "播放器音乐人管理后台实时截图") @ApiModelProperty(name = "播放器音乐人管理后台实时截图")
private String screenshot; private String screenshot;
@ApiModelProperty("编号")
private String serialNo;
} }

@ -3,17 +3,21 @@ package com.luoo.user.pojo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.*; import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.time.LocalDateTime;
/** /**
* @Author: yawei.huang * @Author: yawei.huang
@ -29,7 +33,10 @@ import java.util.Date;
@EqualsAndHashCode @EqualsAndHashCode
@Builder @Builder
@Entity @Entity
@DynamicInsert
@DynamicUpdate
@Table(name="tb_artist_register") @Table(name="tb_artist_register")
@EntityListeners(AuditingEntityListener.class)
public class ArtistRegister implements Serializable { public class ArtistRegister implements Serializable {
@Id @Id
@ApiModelProperty("id") @ApiModelProperty("id")
@ -93,17 +100,20 @@ public class ArtistRegister implements Serializable {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
@CreatedDate @CreatedDate
private Date createTime; private LocalDateTime createTime;
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@LastModifiedDate @LastModifiedDate
private Date modifyTime; private LocalDateTime modifyTime;
@ApiModelProperty("创建人") @ApiModelProperty("创建人")
private String createUser; private String createUser;
@ApiModelProperty("修改人") @ApiModelProperty("修改人")
private String updateUser; private String updateUser;
@ApiModelProperty("编号")
private String serialNo;
} }

@ -1,19 +1,24 @@
package com.luoo.user.service; package com.luoo.user.service;
import api.PageResult; import api.PageResult;
import com.luoo.user.dao.*; import com.luoo.user.dao.ArtistInfoDao;
import com.luoo.user.dao.ArtistRegisterDao;
import com.luoo.user.dao.ArtistUserDao;
import com.luoo.user.dao.UserInfoDao;
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.*; import com.luoo.user.pojo.ArtistInfo;
import com.luoo.user.pojo.ArtistRegister;
import com.luoo.user.pojo.ArtistUser;
import com.luoo.user.pojo.UserInfo;
import constants.Constants; import constants.Constants;
import constants.ErrorConstants; import constants.ErrorConstants;
import dto.UserLoginDto; import dto.UserLoginDto;
import dto.UserMessageDto; import dto.UserMessageDto;
import enums.MessageTypeEnum; import enums.MessageTypeEnum;
import enums.UserProcessStatusEnum; import enums.UserProcessStatusEnum;
import enums.UserProcessTypeEnum;
import enums.UserStatusEnum; import enums.UserStatusEnum;
import exception.BizException; import exception.BizException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -31,6 +36,7 @@ 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 util.RedisLockUtil;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
@ -76,6 +82,8 @@ public class ArtistService {
@Autowired @Autowired
private ArtistRegisterDao artistRegisterDao; private ArtistRegisterDao artistRegisterDao;
@Autowired
private RedisLockUtil redisLockUtil;
/** /**
* *
*/ */
@ -84,7 +92,7 @@ public class ArtistService {
UserLoginDto currentUser = jwtUtil.getUserLoginDto(token); UserLoginDto currentUser = jwtUtil.getUserLoginDto(token);
String id = artistRegisterDto.getId(); String id = artistRegisterDto.getId();
if (StringUtils.isNotBlank(id)) { if (StringUtils.isBlank(id)) {
// 新增音乐人账号 // 新增音乐人账号
// 一个用户只能新增一个音乐人账号 // 一个用户只能新增一个音乐人账号
List<ArtistRegister> list = artistRegisterDao.findAllByCreateUser(currentUser.getUserId()); List<ArtistRegister> list = artistRegisterDao.findAllByCreateUser(currentUser.getUserId());
@ -106,6 +114,11 @@ public class ArtistService {
artistRegister.setCreateUser(currentUser.getUserId()); artistRegister.setCreateUser(currentUser.getUserId());
// 密码加密 // 密码加密
artistRegister.setPassword(encoder.encode(artistRegisterDto.getPassword())); artistRegister.setPassword(encoder.encode(artistRegisterDto.getPassword()));
String serialNo = redisLockUtil.generateSerialNumber();
artistRegister.setSerialNo(serialNo);
artistRegister.setId(String.valueOf(idWorker.nextId()));
artistRegisterDao.save(artistRegister); artistRegisterDao.save(artistRegister);
} else { } else {
// 拒绝后重新发起音乐人账号审批 // 拒绝后重新发起音乐人账号审批
@ -154,6 +167,8 @@ public class ArtistService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void approve(String token, UserProcessApproveDto userProcessApproveDto) { public void approve(String token, UserProcessApproveDto userProcessApproveDto) {
UserLoginDto currentUser = jwtUtil.getUserLoginDto(token);
String title = ObjectUtils.equals(UserProcessStatusEnum.SUCCESS.getCode(), userProcessApproveDto.getStatus()) ? String title = ObjectUtils.equals(UserProcessStatusEnum.SUCCESS.getCode(), userProcessApproveDto.getStatus()) ?
"音乐人审核通过" : "音乐人审核失败"; "音乐人审核通过" : "音乐人审核失败";
String content = userProcessApproveDto.getContent(); String content = userProcessApproveDto.getContent();
@ -164,10 +179,9 @@ public class ArtistService {
} }
ArtistRegister artistRegister = artistRegisterDao.findById(userProcessApproveDto.getId()).get(); ArtistRegister artistRegister = artistRegisterDao.findById(userProcessApproveDto.getId()).get();
artistRegister.setUserId(currentUser.getUserId());
artistRegister.setStatus(userProcessApproveDto.getStatus()); artistRegister.setStatus(userProcessApproveDto.getStatus());
artistRegister.setContent(userProcessApproveDto.getContent()); artistRegister.setContent(userProcessApproveDto.getContent());
artistRegister.setModifyTime(new Date());
artistRegisterDao.save(artistRegister);
if (ObjectUtils.equals(UserProcessStatusEnum.SUCCESS.getCode(), userProcessApproveDto.getStatus())) { if (ObjectUtils.equals(UserProcessStatusEnum.SUCCESS.getCode(), userProcessApproveDto.getStatus())) {
// 审核通过 // 审核通过
@ -190,18 +204,27 @@ public class ArtistService {
ArtistInfo artistInfo = ArtistInfo.builder() ArtistInfo artistInfo = ArtistInfo.builder()
.id(String.valueOf(idWorker.nextId())) .id(String.valueOf(idWorker.nextId()))
.userId(userInfo.getId()) .userId(userInfo.getId())
.description(artistRegister.getDescription())
.screenshot(artistRegister.getScreenshot())
.backgroundImage(artistRegister.getBackgroundImage()) .backgroundImage(artistRegister.getBackgroundImage())
.address(artistRegister.getAddress()) .address(artistRegister.getAddress())
.style(artistRegister.getStyle()) .style(artistRegister.getStyle())
.bandUserId(artistRegister.getBandUserId()) .bandUserId(artistRegister.getBandUserId())
.serialNo(artistRegister.getSerialNo())
.build(); .build();
artistInfoDao.save(artistInfo); artistInfoDao.save(artistInfo);
artistRegister.setArtistId(artistInfo.getId());
artistRegister.setUserId(userInfo.getId());
artistRegister.setUpdateUser(currentUser.getUserId());
} }
artistRegisterDao.save(artistRegister);
// 发送审核成功、失败的站内信 // 发送审核成功、失败的站内信
// 发送人是当前登录用户 // 发送人是当前登录用户
// 接收人是音乐人注册人 // 接收人是音乐人注册人
UserLoginDto currentUser = jwtUtil.getUserLoginDto(token);
UserMessageDto userMessageDto = new UserMessageDto(); UserMessageDto userMessageDto = new UserMessageDto();
userMessageDto.setType(MessageTypeEnum.PRIVATE_MESSAGE.getType()); userMessageDto.setType(MessageTypeEnum.PRIVATE_MESSAGE.getType());
userMessageDto.setSendUserId(currentUser.getUserId()); userMessageDto.setSendUserId(currentUser.getUserId());

@ -19,3 +19,25 @@ create table tb_artist_register
) )
comment '音乐人注册信息'; comment '音乐人注册信息';
alter table tb_artist_register
add serial_no varchar(20) null comment '编号';
alter table tb_artist_register
add content longtext null comment '拒绝理由';
alter table tb_artist_info
add serial_no varchar(20) null comment '编号';
alter table tb_artist_register
add create_time datetime null comment '创建时间';
alter table tb_artist_register
add modify_time datetime null comment '修改时间';
alter table tb_artist_register
add create_user varchar(20) null comment '创建人';
alter table tb_artist_register
add update_user varchar(20) null comment '修改人';

Loading…
Cancel
Save