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 index eac533d..454721f 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/ArtistController.java @@ -1,8 +1,8 @@ package com.luoo.user.controller; import api.Result; -import com.luoo.user.dto.ArtistRegisterDto; -import com.luoo.user.dto.ArtistUserBindDto; +import com.luoo.user.dto.artist.ArtistRegisterDto; +import com.luoo.user.dto.artist.ArtistUserBindDto; import com.luoo.user.service.ArtistService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/luoo_user/src/main/java/com/luoo/user/controller/BandController.java b/luoo_user/src/main/java/com/luoo/user/controller/BandController.java new file mode 100644 index 0000000..2851327 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/controller/BandController.java @@ -0,0 +1,40 @@ +package com.luoo.user.controller; + +import api.Result; +import com.luoo.user.dto.band.BandRegisterDto; +import com.luoo.user.service.BandService; +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/26 8:45 + * @Filename: BandController + * @Describe: 厂牌接口入口 + */ +@Api(tags = "BandController") +@RestController +@RequestMapping("/band") +public class BandController { + + @Autowired + private BandService bandService; + + @ApiOperation(value = "厂牌注册", notes = "厂牌注册") + @PostMapping("/register") + public Result register(@ApiParam(value = "注册对象", required = true) @Valid @RequestBody BandRegisterDto bandRegisterDto) { + bandService.bandRegister(bandRegisterDto); + return Result.success(); + } + +} diff --git a/luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterDto.java similarity index 98% rename from luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java rename to luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterDto.java index 3a66bcc..4065a4c 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/ArtistRegisterDto.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterDto.java @@ -1,4 +1,4 @@ -package com.luoo.user.dto; +package com.luoo.user.dto.artist; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/luoo_user/src/main/java/com/luoo/user/dto/ArtistUserBindDto.java b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistUserBindDto.java similarity index 85% rename from luoo_user/src/main/java/com/luoo/user/dto/ArtistUserBindDto.java rename to luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistUserBindDto.java index a9ec9e2..2541470 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/ArtistUserBindDto.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistUserBindDto.java @@ -1,10 +1,8 @@ -package com.luoo.user.dto; +package com.luoo.user.dto.artist; import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; import lombok.Data; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; diff --git a/luoo_user/src/main/java/com/luoo/user/dto/band/BandRegisterDto.java b/luoo_user/src/main/java/com/luoo/user/dto/band/BandRegisterDto.java new file mode 100644 index 0000000..43000c0 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/band/BandRegisterDto.java @@ -0,0 +1,75 @@ +package com.luoo.user.dto.band; + +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.band + * @Project: luoo_parent + * @Date: 2024/4/26 8:48 + * @Filename: BandRegisterDto + * @Describe: 厂牌注册参数 + */ +@Data +public class BandRegisterDto implements Serializable { + + @ApiModelProperty("用户名") + @NotBlank(message = "用户名不能为空") + private String userName; + + @ApiModelProperty("密码") + @NotBlank(message = "密码不能为空") + private String password; + + @ApiModelProperty("厂牌名称/昵称") + @NotBlank(message = "厂牌名称不能为空") + private String nickName; + + @ApiModelProperty("所在地区") + @NotBlank(message = "所在地区不能为空") + private String address; + + @ApiModelProperty("统一社会信用代码") + @NotBlank(message = "统一社会信用代码不能为空") + private String companyCode; + + @ApiModelProperty("公司名称") + @NotBlank(message = "公司名称不能为空") + private String CompanyName; + + @ApiModelProperty("法人") + @NotBlank(message = "法人不能为空") + private String legalPerson; + + @ApiModelProperty("营业执照") + private String businessLicense; + + @ApiModelProperty("运营者真实姓名") + @NotBlank(message = "运营者真实姓名不能为空") + private String name; + + @ApiModelProperty("手机号码") + @NotBlank(message = "手机号码不能为空") + private String mobile; + + @ApiModelProperty("身份证号") + @NotBlank(message = "身份证号不能为空") + private String idCard; + + @ApiModelProperty("联系邮箱") + @NotBlank(message = "联系邮箱不能为空") + private String email; + + @ApiModelProperty("运营者授权书") + @NotBlank(message = "运营者授权书不能为空") + private String authorization; + + @ApiModelProperty("作品清单") + @NotBlank(message = "作品清单不能为空") + private String works; + +} 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 index 4ba197d..36d40f1 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/ArtistService.java @@ -1,8 +1,8 @@ package com.luoo.user.service; import com.luoo.user.dao.*; -import com.luoo.user.dto.ArtistRegisterDto; -import com.luoo.user.dto.ArtistUserBindDto; +import com.luoo.user.dto.artist.ArtistRegisterDto; +import com.luoo.user.dto.artist.ArtistUserBindDto; import com.luoo.user.pojo.ArtistInfo; import com.luoo.user.pojo.ArtistResponsible; import com.luoo.user.pojo.ArtistUser; @@ -103,7 +103,7 @@ public class ArtistService { /** * 音乐人-成员绑定 * - * @param artistUserBindDto + * @param artistUserBindDto 绑定实体类 */ @Transactional(rollbackFor = Exception.class) public void bindArtistAndMember(ArtistUserBindDto artistUserBindDto) { @@ -123,7 +123,7 @@ public class ArtistService { /** * 音乐人-成员解绑 - * @param artistUserBindDto + * @param artistUserBindDto 绑定实体类 */ public void unBindArtistAndMember(ArtistUserBindDto artistUserBindDto) { ArtistUser artistUser = artistUserDao.findArtistUserByArtistIdAndUserId(artistUserBindDto.getArtistId(), artistUserBindDto.getUserId()); diff --git a/luoo_user/src/main/java/com/luoo/user/service/BandService.java b/luoo_user/src/main/java/com/luoo/user/service/BandService.java new file mode 100644 index 0000000..7318fc4 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/service/BandService.java @@ -0,0 +1,84 @@ +package com.luoo.user.service; + +import com.luoo.user.dao.BandInfoDao; +import com.luoo.user.dao.BandOperatorDao; +import com.luoo.user.dao.UserInfoDao; +import com.luoo.user.dto.band.BandRegisterDto; +import com.luoo.user.pojo.BandInfo; +import com.luoo.user.pojo.BandOperator; +import com.luoo.user.pojo.UserInfo; +import constants.Constants; +import enums.UserStatusEnum; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +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/26 8:46 + * @Filename: BandService + * @Describe: 厂牌相关逻辑 + */ +@Service +public class BandService { + + @Autowired + private BandInfoDao bandInfoDao; + + @Autowired + private BandOperatorDao bandOperatorDao; + + @Autowired + private UserInfoDao userInfoDao; + + @Autowired + private IdWorker idWorker; + + @Autowired + private BCryptPasswordEncoder encoder; + + @Transactional(rollbackFor = Exception.class) + public void bandRegister(BandRegisterDto bandRegisterDto) { + UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(bandRegisterDto.getUserName()); + if(userInfoByUserName != null) { + throw new RuntimeException("该用户名已存在,请重新输入!"); + } + + // 新增用户基本信息 + UserInfo userInfo = UserInfo.builder() + .id(String.valueOf(idWorker.nextId())) + .nickName(bandRegisterDto.getNickName()) + .joinTime(new Date()) + .status(UserStatusEnum.UNAPPROVED.getStatus()) + .thumbnail(Constants.DEFAULT_USER_THUMBNAIL) + .signature(Constants.DEFAULT_USER_SIGNATURE) + .userName(bandRegisterDto.getUserName()) + .password(encoder.encode(bandRegisterDto.getPassword())) + .build(); + userInfoDao.save(userInfo); + + // 新增厂牌基础信息 + BandInfo bandInfo = new BandInfo(); + BeanUtils.copyProperties(bandRegisterDto, bandInfo); + bandInfo.setId(String.valueOf(idWorker.nextId())); + + bandInfoDao.save(bandInfo); + + // 新增厂牌基础信息 + BandOperator bandOperator = new BandOperator(); + BeanUtils.copyProperties(bandRegisterDto, bandOperator); + bandOperator.setId(String.valueOf(idWorker.nextId())); + + bandOperatorDao.save(bandOperator); + + } + + +}