From a0732031b13641c8539ba631ec9857fa5be6ef1d Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Thu, 25 Apr 2024 14:08:03 +0800 Subject: [PATCH] =?UTF-8?q?release-=E9=9F=B3=E4=B9=90=E4=BA=BA=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/enums/UserStatusEnum.java | 2 + .../user/controller/ArtistController.java | 40 ++++++++ .../java/com/luoo/user/dao/ArtistInfoDao.java | 16 ++++ .../luoo/user/dao/ArtistResponsibleDao.java | 17 ++++ .../java/com/luoo/user/dao/UserInfoDao.java | 4 + .../com/luoo/user/dto/ArtistRegisterDto.java | 65 +++++++++++++ .../java/com/luoo/user/pojo/ArtistInfo.java | 46 +++++++++ .../com/luoo/user/pojo/ArtistResponsible.java | 44 +++++++++ .../java/com/luoo/user/pojo/UserInfo.java | 11 ++- .../com/luoo/user/service/ArtistService.java | 96 +++++++++++++++++++ luoo_user/src/main/resources/sql/20240425.sql | 11 ++- 11 files changed, 347 insertions(+), 5 deletions(-) create mode 100644 luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java create mode 100644 luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java create mode 100644 luoo_user/src/main/java/com/luoo/user/dao/ArtistResponsibleDao.java create mode 100644 luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java create mode 100644 luoo_user/src/main/java/com/luoo/user/pojo/ArtistInfo.java create mode 100644 luoo_user/src/main/java/com/luoo/user/pojo/ArtistResponsible.java create mode 100644 luoo_user/src/main/java/com/luoo/user/service/ArtistService.java diff --git a/luoo_common/src/main/java/enums/UserStatusEnum.java b/luoo_common/src/main/java/enums/UserStatusEnum.java index 658b79e..59ac439 100644 --- a/luoo_common/src/main/java/enums/UserStatusEnum.java +++ b/luoo_common/src/main/java/enums/UserStatusEnum.java @@ -3,6 +3,8 @@ package enums; public enum UserStatusEnum { + UNAPPROVED(-1, "未审批"), + DISABLE(0, "禁用"), ENABLE(1, "启用"); diff --git a/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java b/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java new file mode 100644 index 0000000..f49e98a --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java @@ -0,0 +1,40 @@ +package com.luoo.user.controller; + +import api.Result; +import com.luoo.user.dto.ArtistRegisterDto; +import com.luoo.user.service.ArtistService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.controller + * @Project: luoo_parent + * @Date: 2024/4/25 13:52 + * @Filename: ArtistController + * @Describe: + */ +@Api(tags = "ArtistController") +@RestController +@RequestMapping("/artist") +public class ArtistController { + + @Autowired + private ArtistService artistService; + + @ApiOperation(value = "音乐人注册", notes = "音乐人注册") + @PostMapping("/register") + public Result register(@ApiParam(value = "注册对象", required = true) @Valid @RequestBody ArtistRegisterDto artistRegisterDto) { + artistService.artistRegister(artistRegisterDto); + return Result.success(); + } + +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java b/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java new file mode 100644 index 0000000..964c333 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dao/ArtistInfoDao.java @@ -0,0 +1,16 @@ +package com.luoo.user.dao; + +import com.luoo.user.pojo.ArtistInfo; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dao + * @Project: luoo_parent + * @Date: 2024/4/25 11:02 + * @Filename: ArtistDao + * @Describe: + */ +public interface ArtistInfoDao extends JpaRepository, JpaSpecificationExecutor { +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/ArtistResponsibleDao.java b/luoo_user/src/main/java/com/luoo/user/dao/ArtistResponsibleDao.java new file mode 100644 index 0000000..690752d --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dao/ArtistResponsibleDao.java @@ -0,0 +1,17 @@ +package com.luoo.user.dao; + +import com.luoo.user.pojo.ArtistResponsible; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dao + * @Project: luoo_parent + * @Date: 2024/4/25 11:02 + * @Filename: ArtistResponsibleDao + * @Describe: + */ +public interface ArtistResponsibleDao extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java index b7a7ad4..fc09a08 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java @@ -21,6 +21,10 @@ public interface UserInfoDao extends JpaRepository, JpaSpecifi public UserInfo findUserInfoByWxId(String wxId); public UserInfo findByAppleId(String appleId); + /** + * 根据userName查询是否已存在 + */ + public UserInfo findUserInfoByUserName(String userName); @Modifying @Query(value = "update tb_user_info set follow_count=follow_count+? where id = ?", nativeQuery = true) diff --git a/luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java b/luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java new file mode 100644 index 0000000..e990c92 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java @@ -0,0 +1,65 @@ +package com.luoo.user.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dto + * @Project: luoo_parent + * @Date: 2024/4/25 11:07 + * @Filename: ArtistRegisterDto + * @Describe: + */ +@Data +public class ArtistRegisterDto implements Serializable { + @ApiModelProperty(name = "名称") + @NotBlank(message = "名称必填") + private String nickName; + + @ApiModelProperty(name = "艺人类型") + @NotBlank(message = "艺人类型必填") + private Integer type; + + @ApiModelProperty(name = "艺人背景图片") + @NotBlank(message = "艺人背景图片必填") + private String backgroundImage; + + @ApiModelProperty(name = "艺人头像") + @NotBlank(message = "艺人头像必填") + private String avatar; + + @ApiModelProperty(name = "所在地区") + @NotBlank(message = "所在地区必填") + private String address; + + @ApiModelProperty(name = "流派风格") + @NotBlank(message = "流派风格必填") + private String style; + + @ApiModelProperty(name = "所属公司/厂牌") + private String bandUserId; + + @ApiModelProperty(name = "负责人名称") + @NotBlank(message = "负责人名称必填") + private String responsibleName; + + @ApiModelProperty(name = "性别") + @NotBlank(message = "负责人性别必填") + private Integer sex; + + @ApiModelProperty(name = "负责人手机") + @NotBlank(message = "负责人手机必填") + private String mobile; + + @ApiModelProperty(name = "登录用户名") + @NotBlank(message = "用户名必填") + private String userName; + + @ApiModelProperty(name = "密码") + @NotBlank(message = "密码必填") + private String password; +} diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/ArtistInfo.java b/luoo_user/src/main/java/com/luoo/user/pojo/ArtistInfo.java new file mode 100644 index 0000000..c144bf0 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/pojo/ArtistInfo.java @@ -0,0 +1,46 @@ +package com.luoo.user.pojo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.pojo + * @Project: luoo_parent + * @Date: 2024/4/25 10:55 + * @Filename: ArtistInfo + * @Describe: 音乐人基础信息 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode +@Builder +@Entity +@Table(name="tb_artist_info") +public class ArtistInfo implements Serializable { + + @Id + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("tb_user表id") + private String userId; + + @ApiModelProperty("艺人背景图") + private String backgroundImage; + + @ApiModelProperty("所在地区") + private String address; + + @ApiModelProperty("表tb_tag_info的id") + private String style; + + @ApiModelProperty("tb_user表中厂牌类型用户的id") + private String bandUserId; +} diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/ArtistResponsible.java b/luoo_user/src/main/java/com/luoo/user/pojo/ArtistResponsible.java new file mode 100644 index 0000000..7113ab6 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/pojo/ArtistResponsible.java @@ -0,0 +1,44 @@ +package com.luoo.user.pojo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.pojo + * @Project: luoo_parent + * @Date: 2024/4/25 10:59 + * @Filename: ArtistResponsible + * @Describe: 音乐人负责人 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode +@Builder +@Entity +@Table(name="tb_artist_responsible") +public class ArtistResponsible implements Serializable { + + @Id + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("tb_user表id") + private String userId; + + @ApiModelProperty("用户名") + private String name; + + @ApiModelProperty("性别") + private Integer sex; + + @ApiModelProperty("手机号") + private String mobile; + +} diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java b/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java index 7317844..f4945c7 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/UserInfo.java @@ -1,7 +1,6 @@ package com.luoo.user.pojo; -import lombok.Getter; -import lombok.Setter; +import lombok.*; import java.util.Date; @@ -20,6 +19,9 @@ import java.io.Serializable; @Getter @Setter @Entity +@Builder +@AllArgsConstructor +@NoArgsConstructor @Table(name="tb_user_info") public class UserInfo implements Serializable { private static final long serialVersionUID = 1L; @@ -178,6 +180,11 @@ public class UserInfo implements Serializable { * 是否启用推送 */ private Integer enablePush; + + /** + * 登录用户名 + */ + private String userName; } diff --git a/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java new file mode 100644 index 0000000..62618d9 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java @@ -0,0 +1,96 @@ +package com.luoo.user.service; + +import com.luoo.user.dao.ArtistInfoDao; +import com.luoo.user.dao.ArtistResponsibleDao; +import com.luoo.user.dao.UserInfoDao; +import com.luoo.user.dto.ArtistRegisterDto; +import com.luoo.user.pojo.ArtistInfo; +import com.luoo.user.pojo.ArtistResponsible; +import com.luoo.user.pojo.UserInfo; +import constants.Constants; +import enums.UserStatusEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import util.IdWorker; + +import java.util.Date; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.service + * @Project: luoo_parent + * @Date: 2024/4/25 11:04 + * @Filename: ArtistService + * @Describe: 音乐人相关逻辑 + */ +@Service +@Slf4j +public class ArtistService { + + @Autowired + private ArtistInfoDao artistInfoDao; + + @Autowired + private ArtistResponsibleDao artistResponsibleDao; + + @Autowired + private UserInfoService userInfoService; + + @Autowired + private UserInfoDao userInfoDao; + + @Autowired + private IdWorker idWorker; + + /** + * 音乐人注册 + * + */ + @Transactional(rollbackFor = Exception.class) + public void artistRegister(ArtistRegisterDto artistRegisterDto) { + + UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(artistRegisterDto.getUserName()); + if(userInfoByUserName == null) { + throw new RuntimeException("该用户名已存在,请重新输入!"); + } + + // 新增用户基本信息 + UserInfo 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()) + .password(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); + + // 新增音乐人负责人信息 + ArtistResponsible artistResponsible = ArtistResponsible.builder() + .userId(userInfo.getId()) + .sex(artistRegisterDto.getSex()) + .name(artistRegisterDto.getNickName()) + .mobile(artistRegisterDto.getMobile()) + .build(); + artistResponsibleDao.save(artistResponsible); + + } + + +} diff --git a/luoo_user/src/main/resources/sql/20240425.sql b/luoo_user/src/main/resources/sql/20240425.sql index 9c8e5e8..58eddb1 100644 --- a/luoo_user/src/main/resources/sql/20240425.sql +++ b/luoo_user/src/main/resources/sql/20240425.sql @@ -1,15 +1,19 @@ alter table tb_user_info add type int null comment '用户类型'; + +alter table tb_user_info + add user_name varchar(20) null comment '登录用户名'; + create table tb_artist_info ( id varchar(20) not null comment 'id' primary key, - user_id varchar(20) null comment 'tb_user表id', + user_id varchar(20) null comment 'tb_user_info表id', background_image varchar(255) null comment '艺人背景图', address varchar(255) null comment '所在地区', style varchar(20) null comment '表tb_tag_info的id', - band_user_id varchar(20) null comment 'tb_user表中厂牌类型用户的id' + band_user_id varchar(20) null comment 'tb_user_info表中厂牌类型用户的id' ) comment '音乐人基础信息'; @@ -17,10 +21,11 @@ create table tb_artist_responsible ( id varchar(20) not null comment 'id' primary key, - user_id varchar(20) null comment 'tb_user表id', + user_id varchar(20) null comment 'tb_user_info表id', name varchar(255) null comment '用户名', sex int null comment '性别', mobile varchar(255) null comment '手机号' ) comment '音乐人负责人'; +