parent
b20a0df9bb
commit
a0732031b1
@ -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> {
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue