From 885742c2d80f606c698b08dc187cb9c3c6e15246 Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Wed, 19 Jun 2024 13:59:31 +0800 Subject: [PATCH] =?UTF-8?q?release-=20app=E7=AB=AF=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=AE=80=E7=95=A5=E7=89=88=E6=B3=A8=E5=86=8C=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E4=BA=BA=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/ArtistController.java | 17 +++++++++ .../user/dto/artist/ArtistRegisterAppDto.java | 38 +++++++++++++++++++ .../com/luoo/user/service/ArtistService.java | 15 +++++--- 3 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterAppDto.java 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 4d39269..23f4909 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 @@ -3,6 +3,7 @@ package com.luoo.user.controller; import api.PageResult; import api.Result; import com.luoo.user.dto.UserProcessApproveDto; +import com.luoo.user.dto.artist.ArtistRegisterAppDto; import com.luoo.user.dto.artist.ArtistRegisterDto; import com.luoo.user.dto.artist.ArtistSearchDto; import com.luoo.user.dto.artist.ArtistUserBindDto; @@ -12,6 +13,7 @@ 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.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -40,6 +42,21 @@ public class ArtistController { return Result.success(); } + @ApiOperation(value = "APP音乐人注册", notes = "APP音乐人注册简单模板") + @PostMapping("/app/register") + public Result appRegister(@RequestHeader(value = "Authorization", required = true) String authorization, + @Validated @RequestBody ArtistRegisterAppDto artistRegisterAppDto) { + ArtistRegisterDto artistRegisterDto = new ArtistRegisterDto(); + BeanUtils.copyProperties(artistRegisterAppDto, artistRegisterDto); + artistService.artistRegister(authorization, artistRegisterDto); + return Result.success(); + } + + + + + + @ApiOperation(value = "未审核的音乐人列表", notes = "未审核的音乐人列表") @GetMapping("/list/un-approve/{page}/{size}") public Result> getUnApproveList(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, diff --git a/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterAppDto.java b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterAppDto.java new file mode 100644 index 0000000..7d4d9b5 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/artist/ArtistRegisterAppDto.java @@ -0,0 +1,38 @@ +package com.luoo.user.dto.artist; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * APP端申请成为音乐人接口 + * + * @Author: yawei.huang + * @Package: com.luoo.user.dto.artist + * @Project: luoo_parent + * @Date: 2024/6/19 13:50 + * @Filename: ArtistRegisterAppDto + * @Describe: + */ +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Data +public class ArtistRegisterAppDto implements Serializable { + @ApiModelProperty("歌手名") + @NotBlank(message = "歌手名必填") + private String nickName; + + @ApiModelProperty("所在地区") + @NotBlank(message = "所在地区必填") + private String address; + + @ApiModelProperty("流派风格") + @NotBlank(message = "流派风格必填") + private String style; +} 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 ca77937..f6ba26c 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 @@ -101,11 +101,15 @@ public class ArtistService { throw new BizException(ErrorConstants.USER_ALREADY_EXISTS_ARTIST); } - List allByUserName = artistRegisterDao.findAllByUserName(artistRegisterDto.getUserName()); - if (!allByUserName.isEmpty()) { - // 用户名已存在 - throw new BizException(ErrorConstants.USER_NAME_ALREADY_EXISTS); + if(StringUtils.isBlank(artistRegisterDto.getUserName())) { + // app端新增时不需要填写用户名。可能为空 + List allByUserName = artistRegisterDao.findAllByUserName(artistRegisterDto.getUserName()); + if (!allByUserName.isEmpty()) { + // 用户名已存在 + throw new BizException(ErrorConstants.USER_NAME_ALREADY_EXISTS); + } } + ArtistRegister artistRegister = new ArtistRegister(); BeanUtils.copyProperties(artistRegisterDto, artistRegister); // 未审核状态 @@ -113,7 +117,7 @@ public class ArtistService { // 创建人 artistRegister.setCreateUser(currentUser.getUserId()); // 密码加密 - artistRegister.setPassword(encoder.encode(artistRegisterDto.getPassword())); + artistRegister.setPassword(StringUtils.isBlank(artistRegisterDto.getPassword()) ? null : encoder.encode(artistRegisterDto.getPassword())); String serialNo = redisLockUtil.generateSerialNumber(); artistRegister.setSerialNo(serialNo); @@ -123,6 +127,7 @@ public class ArtistService { } else { // 拒绝后重新发起音乐人账号审批 // 判断当前是否是拒绝状态 + // 重新发起id为空,app不可能发起,不考虑用户名密码为空的情况 ArtistRegister artistRegister = artistRegisterDao.findById(id).get(); if (ObjectUtils.notEqual(UserProcessStatusEnum.FAIL.getCode(), artistRegister.getStatus())) { throw new BizException(ErrorConstants.STATE_ERROR);