release-音乐人注册逻辑

release-2024-08-08
pikaqiudeshujia 7 months ago
parent b20a0df9bb
commit a0732031b1

@ -3,6 +3,8 @@ package enums;
public enum UserStatusEnum { public enum UserStatusEnum {
UNAPPROVED(-1, "未审批"),
DISABLE(0, "禁用"), DISABLE(0, "禁用"),
ENABLE(1, "启用"); ENABLE(1, "启用");

@ -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<Void> register(@ApiParam(value = "注册对象", required = true) @Valid @RequestBody ArtistRegisterDto artistRegisterDto) {
artistService.artistRegister(artistRegisterDto);
return Result.success();
}
}

@ -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<ArtistInfo,String>, JpaSpecificationExecutor<ArtistInfo> {
}

@ -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<ArtistResponsible,String>, JpaSpecificationExecutor<ArtistResponsible> {
}

@ -21,6 +21,10 @@ public interface UserInfoDao extends JpaRepository<UserInfo, String>, JpaSpecifi
public UserInfo findUserInfoByWxId(String wxId); public UserInfo findUserInfoByWxId(String wxId);
public UserInfo findByAppleId(String appleId); public UserInfo findByAppleId(String appleId);
/**
* userName
*/
public UserInfo findUserInfoByUserName(String userName);
@Modifying @Modifying
@Query(value = "update tb_user_info set follow_count=follow_count+? where id = ?", nativeQuery = true) @Query(value = "update tb_user_info set follow_count=follow_count+? where id = ?", nativeQuery = true)

@ -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;
}

@ -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;
}

@ -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;
}

@ -1,7 +1,6 @@
package com.luoo.user.pojo; package com.luoo.user.pojo;
import lombok.Getter; import lombok.*;
import lombok.Setter;
import java.util.Date; import java.util.Date;
@ -20,6 +19,9 @@ import java.io.Serializable;
@Getter @Getter
@Setter @Setter
@Entity @Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name="tb_user_info") @Table(name="tb_user_info")
public class UserInfo implements Serializable { public class UserInfo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -179,5 +181,10 @@ public class UserInfo implements Serializable {
*/ */
private Integer enablePush; private Integer enablePush;
/**
*
*/
private String userName;
} }

@ -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);
}
}

@ -1,15 +1,19 @@
alter table tb_user_info alter table tb_user_info
add type int null comment '用户类型'; add type int null comment '用户类型';
alter table tb_user_info
add user_name varchar(20) null comment '登录用户名';
create table tb_artist_info create table tb_artist_info
( (
id varchar(20) not null comment 'id' id varchar(20) not null comment 'id'
primary key, 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 '艺人背景图', background_image varchar(255) null comment '艺人背景图',
address varchar(255) null comment '所在地区', address varchar(255) null comment '所在地区',
style varchar(20) null comment '表tb_tag_info的id', 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 '音乐人基础信息'; comment '音乐人基础信息';
@ -17,10 +21,11 @@ create table tb_artist_responsible
( (
id varchar(20) not null comment 'id' id varchar(20) not null comment 'id'
primary key, 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 '用户名', name varchar(255) null comment '用户名',
sex int null comment '性别', sex int null comment '性别',
mobile varchar(255) null comment '手机号' mobile varchar(255) null comment '手机号'
) )
comment '音乐人负责人'; comment '音乐人负责人';

Loading…
Cancel
Save