diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index 496fa81..92de5bb 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -9,6 +9,7 @@ package constants; * @Describe: 报错信息,方便国际化 */ public class ErrorConstants { + // 专辑部分 public final static String MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE = "必须在新建状态下申请审核"; public final static String MUST_OPERATE_IN_PERSON = "必须本人操作"; @@ -24,4 +25,6 @@ public class ErrorConstants { public final static String PRICE_CAN_NOT_BE_EMPTY = "定价不能为空"; public final static String PRICING_MUST_BE_GREATER_THAN_0 = "定价必须大于0"; + + public final static String ALBUM_SONG_LIST_IS_EMPTY = "专辑歌曲为空"; } diff --git a/luoo_common/src/main/java/util/IdWorker.java b/luoo_common/src/main/java/util/IdWorker.java index f40451a..c32da18 100644 --- a/luoo_common/src/main/java/util/IdWorker.java +++ b/luoo_common/src/main/java/util/IdWorker.java @@ -80,7 +80,7 @@ public class IdWorker { public synchronized long nextId() { long timestamp = timeGen(); if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); + throw new BizException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); } if (lastTimestamp == timestamp) { diff --git a/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java b/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java index 38e3f0a..e5a995c 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/AlbumController.java @@ -12,6 +12,7 @@ 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.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** @@ -52,7 +53,7 @@ public class AlbumController { @ApiOperation(value = "新增专辑", notes = "新增专辑") @RequestMapping(value = "/add", method = RequestMethod.POST) public Result add(@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, - @ApiParam(value = "专辑信息", required = true) @RequestBody AlbumAddDTO addModel) { + @ApiParam(value = "专辑信息", required = true) @Validated @RequestBody AlbumAddDTO addModel) { albumService.addAlbum(token, addModel); return Result.success(); } diff --git a/luoo_music/src/main/java/com/luoo/music/controller/BaseExceptionHandler.java b/luoo_music/src/main/java/com/luoo/music/controller/BaseExceptionHandler.java index d34876c..b1df820 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/BaseExceptionHandler.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/BaseExceptionHandler.java @@ -4,29 +4,58 @@ import api.Result; import api.StatusCode; import exception.BizException; import lombok.extern.slf4j.Slf4j; - +import org.springframework.validation.BindingResult; +import org.springframework.validation.ObjectError; +import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.StringJoiner; + /** * 统一异常处理类 */ @Slf4j @ControllerAdvice public class BaseExceptionHandler { - @ExceptionHandler(value = Exception.class) - @ResponseBody - public Result error(Exception e) { - log.error("执行出错", e); - return Result.failed(StatusCode.MUSIC_COMMON_FAILED); - } - - @ExceptionHandler(value = BizException.class) - @ResponseBody - public Result error(BizException e) { - log.info("业务错误:{}", e.getMessage()); - StatusCode statusCode = null == e.getCodeEnum() ? StatusCode.MUSIC_COMMON_FAILED : e.getCodeEnum(); - return Result.failed(statusCode, e.getMessage()); - } + @ExceptionHandler(value = Exception.class) + @ResponseBody + public Result error(Exception e) { + log.error("执行出错", e); + return Result.failed(StatusCode.MUSIC_COMMON_FAILED); + } + + @ExceptionHandler(value = BizException.class) + @ResponseBody + public Result error(BizException e) { + log.info("业务错误:{}", e.getMessage()); + StatusCode statusCode = null == e.getCodeEnum() ? StatusCode.MUSIC_COMMON_FAILED : e.getCodeEnum(); + return Result.failed(statusCode, e.getMessage()); + } + + /** + * 参数校检异常 + * + * @param e 实体类校验 + */ + @ExceptionHandler(value = MethodArgumentNotValidException.class) + @ResponseBody + public Result handle(MethodArgumentNotValidException e) { + BindingResult bindingResult = e.getBindingResult(); + + StringJoiner joiner = new StringJoiner(";"); + + for (ObjectError error : bindingResult.getAllErrors()) { + String code = error.getCode(); + String[] codes = error.getCodes(); + + String property = codes[1]; + property = property.replace(code, "").replaceFirst(".", ""); + + String defaultMessage = error.getDefaultMessage(); + joiner.add(property + defaultMessage); + } + return Result.failed(StatusCode.MUSIC_COMMON_FAILED, joiner.toString()); + } } diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumAddDTO.java b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumAddDTO.java index 59b2900..7d6c306 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumAddDTO.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumAddDTO.java @@ -1,8 +1,10 @@ package com.luoo.music.dto.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -23,7 +25,7 @@ public class AlbumAddDTO implements Serializable { * 专辑名称 */ @ApiModelProperty("专辑名称") - @NotNull(message = "专辑名称不能为空") + @NotBlank(message = "专辑名称不能为空") private String name; /** @@ -43,7 +45,7 @@ public class AlbumAddDTO implements Serializable { * 专辑风格 */ @ApiModelProperty("专辑风格") - @NotNull(message = "专辑风格不能为空") + @NotBlank(message = "专辑风格不能为空") private String mainStyle; /** @@ -51,6 +53,7 @@ public class AlbumAddDTO implements Serializable { */ @ApiModelProperty("发行日期") @NotNull(message = "发行日期不能为空") + @JsonFormat(pattern = "yyyy-MM-dd") private Date publishDate; /** @@ -69,7 +72,7 @@ public class AlbumAddDTO implements Serializable { * 专辑封面 */ @ApiModelProperty("专辑封面") - @NotNull(message = "专辑封面不能为空") + @NotBlank(message = "专辑封面不能为空") private String image; /** diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongAddDTO.java b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongAddDTO.java index 8ed88dd..c70b840 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongAddDTO.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongAddDTO.java @@ -20,7 +20,7 @@ import java.util.List; public class AlbumSongAddDTO implements Serializable { @ApiModelProperty("歌曲名称") - @NotNull(message = "歌曲名称不能为空") + @NotBlank(message = "歌曲名称不能为空") private String name; @ApiModelProperty("歌曲版本") @@ -39,22 +39,26 @@ public class AlbumSongAddDTO implements Serializable { private String albumStr; @ApiModelProperty("曲风") + @NotNull(message = "曲风不能为空") private List tags; @ApiModelProperty("语种") + @NotNull(message = "语种不能为空") private List language; @ApiModelProperty("作词") + @NotBlank(message = "作词不能为空") private String lyricName; @ApiModelProperty("作曲") + @NotBlank(message = "作曲不能为空") private String compositionName; @ApiModelProperty("歌词") private String lyric; @ApiModelProperty("歌曲url") - @NotNull(message = "歌曲不能为空") + @NotBlank(message = "歌曲不能为空") private String url; @ApiModelProperty("排序") @@ -64,5 +68,4 @@ public class AlbumSongAddDTO implements Serializable { // @ApiModelProperty("mv") // private String mvUrl; - } diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongRequireDTO.java b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongRequireDTO.java new file mode 100644 index 0000000..943bab3 --- /dev/null +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/AlbumSongRequireDTO.java @@ -0,0 +1,72 @@ +package com.luoo.music.dto.response; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @Author: yawei.huang + * @Package: com.luoo.music.dto.response + * @Project: luoo_parent + * @Date: 2024/5/6 10:45 + * @Filename: AlbumSongAddDTO + * @Describe: 专辑歌曲必填校验 + */ +@Data +public class AlbumSongRequireDTO implements Serializable { + + @ApiModelProperty("歌曲名称") + @NotBlank(message = "歌曲名称不能为空") + private String name; + + @ApiModelProperty("歌曲版本") + @NotNull(message = "歌曲版本不能为空") + private Integer version; + + @ApiModelProperty("是否收费") + @NotNull(message = "是否收费不能为空") + private Integer charge; + + @ApiModelProperty("歌曲定价") + private Float price; + + @ApiModelProperty("歌手") + @NotBlank(message = "歌手不能为空") + private String albumStr; + + @ApiModelProperty("曲风") + @NotNull(message = "曲风不能为空") + private List tags; + + @ApiModelProperty("语种") + @NotNull(message = "语种不能为空") + private List language; + + @ApiModelProperty("作词") + @NotBlank(message = "作词不能为空") + private String lyricName; + + @ApiModelProperty("作曲") + @NotBlank(message = "作曲不能为空") + private String compositionName; + + @ApiModelProperty("歌词") + private String lyric; + + @ApiModelProperty("歌曲url") + @NotBlank(message = "歌曲不能为空") + private String url; + + @ApiModelProperty("排序") + @NotNull(message = "排序不能为空") + private Integer sort; + +// @ApiModelProperty("mv") +// private String mvUrl; + + +} diff --git a/luoo_music/src/main/java/com/luoo/music/pojo/ArtistAlbum.java b/luoo_music/src/main/java/com/luoo/music/pojo/ArtistAlbum.java index d68d128..6c8ca95 100644 --- a/luoo_music/src/main/java/com/luoo/music/pojo/ArtistAlbum.java +++ b/luoo_music/src/main/java/com/luoo/music/pojo/ArtistAlbum.java @@ -64,6 +64,7 @@ public class ArtistAlbum implements Serializable { * 发行日期 */ @ApiModelProperty("发行日期") + @JsonFormat(pattern = "yyyy-MM-dd") private Date publishDate; /** @@ -124,8 +125,8 @@ public class ArtistAlbum implements Serializable { @ApiModelProperty("修改人") private String updateUser; - @ApiModelProperty("收费类型 1-下载 2-试听及下载") - private Integer chargeType; +// @ApiModelProperty("收费类型 1-下载 2-试听及下载") +// private Integer chargeType; @Transient @ApiModelProperty("专辑歌曲绑定关系") diff --git a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java index 455b827..d6f396f 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/AlbumService.java @@ -2,10 +2,7 @@ package com.luoo.music.service; import api.PageResult; import com.luoo.music.dao.*; -import com.luoo.music.dto.response.AlbumAddDTO; -import com.luoo.music.dto.response.AlbumSearchDTO; -import com.luoo.music.dto.response.AlbumSongAddDTO; -import com.luoo.music.dto.response.AlbumUpdateDTO; +import com.luoo.music.dto.response.*; import com.luoo.music.pojo.*; import com.luoo.music.util.Constants; import constants.ErrorConstants; @@ -13,6 +10,7 @@ import dto.UserLoginDto; import enums.AlbumStateEnum; import enums.SongInfoChargeEnum; import enums.SongInfoStateEnum; +import exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.ObjectUtils; @@ -24,6 +22,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; import util.IdWorker; import util.JwtUtil; @@ -31,7 +30,6 @@ import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.validation.Valid; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -178,11 +176,11 @@ public class AlbumService { ArtistAlbum artistAlbum = artistAlbumDao.findById(id).get(); if (artistAlbum == null) { // 专辑不存在,请刷新后重试 - throw new RuntimeException(ErrorConstants.ALBUM_DOES_NOT_EXIST); + throw new BizException(ErrorConstants.ALBUM_DOES_NOT_EXIST); } if (ObjectUtils.equals(AlbumStateEnum.FORCE.getCode(), artistAlbum.getState())) { // 专辑因不可抗力原因无法显示 - throw new RuntimeException(ErrorConstants.CAUSE_OF_FORCE_MAJEURE); + throw new BizException(ErrorConstants.CAUSE_OF_FORCE_MAJEURE); } // 整个数据库所有的tag @@ -256,7 +254,7 @@ public class AlbumService { artistAlbum.setCreateUser(user.getUserId()); } else { // 用户校验失败,请重新登录 - throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE); + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); } artistAlbum.setState(AlbumStateEnum.SAVE.getCode()); artistAlbumDao.save(artistAlbum); @@ -285,12 +283,12 @@ public class AlbumService { if (user != null) { if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) { // 必须本人操作 - throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE); + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); } artistAlbum.setUpdateUser(user.getUserId()); } else { // 用户校验失败,请重新登 - throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE); + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); } artistAlbumDao.save(artistAlbum); @@ -322,7 +320,7 @@ public class AlbumService { ArtistAlbumSong artistAlbumSong = artistAlbumSongDao.findById(id).get(); if (artistAlbumSong.getId() == null) { // 该专辑不存在此歌曲 - throw new RuntimeException(ErrorConstants.THE_SONG_DOES_NOT_EXIST); + throw new BizException(ErrorConstants.THE_SONG_DOES_NOT_EXIST); } checkAlbum(token, artistAlbumSong.getAlbumId()); @@ -344,11 +342,11 @@ public class AlbumService { if (user != null) { if (ObjectUtils.notEqual(user.getUserId(), artistAlbum.getCreateUser())) { // 必须本人操作 - throw new RuntimeException(ErrorConstants.MUST_OPERATE_IN_PERSON); + throw new BizException(ErrorConstants.MUST_OPERATE_IN_PERSON); } } else { // 用户校验失败,请重新登录 - throw new RuntimeException(ErrorConstants.USER_VERIFICATION_FAILURE); + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); } return artistAlbum; } @@ -367,13 +365,49 @@ public class AlbumService { addSongForAlbum(albumSongAddDTO, user, artistAlbum); } + /** + * 提交审核 + * + * @param token token + * @param id 专辑id + */ @Transactional(rollbackFor = Exception.class) public void checkForApply(String token, String id) { - UserLoginDto user = jwtUtil.getUserLoginDto(token); ArtistAlbum artistAlbum = checkAlbum(token, id); if (ObjectUtils.notEqual(AlbumStateEnum.SAVE.getCode(), artistAlbum.getState())) { // 必须在新建状态下申请审核 - throw new RuntimeException(ErrorConstants.MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE); + throw new BizException(ErrorConstants.MUST_APPLY_FOR_REVIEW_IN_THE_NEW_STATE); + } + ArtistAlbum album = getOne(id); + List songList = album.getSongList(); + if(songList.isEmpty()) { + throw new BizException(ErrorConstants.ALBUM_SONG_LIST_IS_EMPTY); + } + for (SongInfo songInfo : songList) { + AlbumSongRequireDTO albumSongRequireDTO = new AlbumSongRequireDTO(); + BeanUtils.copyProperties(songInfo, albumSongRequireDTO); + checkSong(albumSongRequireDTO); + } + + artistAlbum.setState(AlbumStateEnum.IN_APPROVE.getCode()); + artistAlbumDao.save(artistAlbum); + } + + /** + * 必填校验 + * + * @param albumSongRequireDTO 校验对象 + */ + private void checkSong(@Validated AlbumSongRequireDTO albumSongRequireDTO) { + if(ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), albumSongRequireDTO.getCharge())) { + if(albumSongRequireDTO.getPrice() == null) { + // 定价不能为空 + throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY); + } + if(albumSongRequireDTO.getPrice() <= 0) { + // 定价必须大于0 + throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0); + } } } @@ -384,16 +418,16 @@ public class AlbumService { * @param user 当前登录用户 * @param artistAlbum 专辑对象 */ - private void addSongForAlbum(@Valid AlbumSongAddDTO albumSongAddDTO, UserLoginDto user, ArtistAlbum artistAlbum) { + private void addSongForAlbum(@Validated AlbumSongAddDTO albumSongAddDTO, UserLoginDto user, ArtistAlbum artistAlbum) { - if(ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), artistAlbum.getChargeType())) { + if(ObjectUtils.notEqual(SongInfoChargeEnum.CHARGE.getCode(), albumSongAddDTO.getCharge())) { if(albumSongAddDTO.getPrice() == null) { // 定价不能为空 - throw new RuntimeException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY); + throw new BizException(ErrorConstants.PRICE_CAN_NOT_BE_EMPTY); } if(albumSongAddDTO.getPrice() <= 0) { // 定价必须大于0 - throw new RuntimeException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0); + throw new BizException(ErrorConstants.PRICING_MUST_BE_GREATER_THAN_0); } } @@ -410,7 +444,7 @@ public class AlbumService { if (user != null) { artistAlbum.setCreateUser(user.getUserId()); } else { - throw new RuntimeException(ErrorConstants.MUST_OPERATE_IN_PERSON); + throw new BizException(ErrorConstants.MUST_OPERATE_IN_PERSON); } songInfoDao.save(songInfo); diff --git a/luoo_user/src/main/java/com/luoo/user/controller/BaseExceptionHandler.java b/luoo_user/src/main/java/com/luoo/user/controller/BaseExceptionHandler.java index 08f4aef..353a1d3 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/BaseExceptionHandler.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/BaseExceptionHandler.java @@ -4,10 +4,15 @@ import exception.BizException; import api.Result; import api.StatusCode; import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.BindingResult; +import org.springframework.validation.ObjectError; +import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.StringJoiner; + /** * 统一异常处理类 */ @@ -29,4 +34,29 @@ public class BaseExceptionHandler { StatusCode statusCode = null == e.getCodeEnum() ? StatusCode.USER_COMMON_FAILED : e.getCodeEnum(); return Result.failed(statusCode, e.getMessage()); } + + /** + * 参数校检异常 + * + * @param e 实体类校验 + */ + @ExceptionHandler(value = MethodArgumentNotValidException.class) + @ResponseBody + public Result handle(MethodArgumentNotValidException e) { + BindingResult bindingResult = e.getBindingResult(); + + StringJoiner joiner = new StringJoiner(";"); + + for (ObjectError error : bindingResult.getAllErrors()) { + String code = error.getCode(); + String[] codes = error.getCodes(); + + String property = codes[1]; + property = property.replace(code, "").replaceFirst(".", ""); + + String defaultMessage = error.getDefaultMessage(); + joiner.add(property + defaultMessage); + } + return Result.failed(StatusCode.MUSIC_COMMON_FAILED, joiner.toString()); + } } 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 d541edd..b54cf1f 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 @@ -9,6 +9,7 @@ import constants.Constants; import enums.UserProcessStatusEnum; import enums.UserProcessTypeEnum; import enums.UserStatusEnum; +import exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -66,7 +67,7 @@ public class ArtistService { UserInfo userInfoByUserName = userInfoDao.findUserInfoByUserName(artistRegisterDto.getUserName()); if(userInfoByUserName != null) { - throw new RuntimeException("该用户名已存在,请重新输入!"); + throw new BizException("该用户名已存在,请重新输入!"); } // 新增用户基本信息 @@ -107,11 +108,11 @@ public class ArtistService { // 审核记录 List successList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.ARTIST.getCode(), UserProcessStatusEnum.SUCCESS.getCode()); if(!successList.isEmpty()) { - throw new RuntimeException("该账号已审核通过,请勿重复申请"); + throw new BizException("该账号已审核通过,请勿重复申请"); } List upApprovedList = userProcessDao.findUserProcessByUserIdAndTypeAndStatus(userInfo.getId(), UserProcessTypeEnum.ARTIST.getCode(), UserProcessStatusEnum.UNAPPROVED.getCode()); if(!upApprovedList.isEmpty()) { - throw new RuntimeException("该账号正在审核中,请勿重复申请"); + throw new BizException("该账号正在审核中,请勿重复申请"); } UserProcess userProcess = UserProcess.builder() @@ -133,7 +134,7 @@ public class ArtistService { public void approve(UserProcessApproveDto userProcessApproveDto) { if(ObjectUtils.equals(UserProcessStatusEnum.FAIL.getCode(), userProcessApproveDto.getStatus()) && StringUtils.isBlank(userProcessApproveDto.getContent())) { - throw new RuntimeException("请填写拒绝理由!"); + throw new BizException("请填写拒绝理由!"); } UserProcess userProcessById = userProcessDao.findUserProcessById(userProcessApproveDto.getId()); @@ -167,7 +168,7 @@ public class ArtistService { artistUserDao.save(build); } else { - throw new RuntimeException("请勿重复绑定!"); + throw new BizException("请勿重复绑定!"); } } @@ -180,7 +181,7 @@ public class ArtistService { if(artistUser != null) { artistUserDao.delete(artistUser); } else { - throw new RuntimeException("没有绑定关系!"); + throw new BizException("没有绑定关系!"); } }