diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/BaseExceptionHandler.java b/luoo_comment/src/main/java/com/luoo/comment/controller/BaseExceptionHandler.java new file mode 100644 index 0000000..196e251 --- /dev/null +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/BaseExceptionHandler.java @@ -0,0 +1,16 @@ +package com.luoo.comment.controller; + +import api.StatusCode; +import controller.AbstractBaseExceptionHandler; +import org.springframework.web.bind.annotation.ControllerAdvice; + +/** + * 统一异常处理类 + */ +@ControllerAdvice +public class BaseExceptionHandler extends AbstractBaseExceptionHandler { + @Override + protected StatusCode getCommonFailedStatusCode() { + return StatusCode.COMMENT_COMMON_FAILED; + } +} diff --git a/luoo_common/src/main/java/controller/AbstractBaseExceptionHandler.java b/luoo_common/src/main/java/controller/AbstractBaseExceptionHandler.java new file mode 100644 index 0000000..02aec9a --- /dev/null +++ b/luoo_common/src/main/java/controller/AbstractBaseExceptionHandler.java @@ -0,0 +1,58 @@ +package controller; + +import java.util.Arrays; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + +import api.Result; +import api.StatusCode; +import dto.UserLoginDto; +import exception.BizException; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public abstract class AbstractBaseExceptionHandler extends BaseController { + @ExceptionHandler(value = Exception.class) + @ResponseBody + public Result error(Exception e, HttpServletRequest request) { + log.error("{}user: {} 请求错误,请求地址: {}, 请求参数: {}, 错误信息: ", getDeviceType(request.getHeader("device_type")), + getUserId(request.getHeader("Authorization")), request.getRequestURL(), + getRequestParameter(request.getParameterMap()), e); + if (e instanceof BizException) { + BizException biz = (BizException) e; + StatusCode statusCode = null == biz.getCodeEnum() ? getCommonFailedStatusCode() : biz.getCodeEnum(); + return Result.failed(statusCode, biz.getMessage()); + } + return Result.failed(getCommonFailedStatusCode(), e.getMessage()); + } + + protected abstract StatusCode getCommonFailedStatusCode(); + + private String getRequestParameter(Map parameterMap) { + if (CollectionUtils.isEmpty(parameterMap)) { + return ""; + } + return parameterMap.entrySet().stream().map(this::getParameter).collect(Collectors.joining("|")); + } + + private String getParameter(Entry e) { + return e.getKey() + ":" + + (null == e.getValue() ? "" : Arrays.stream(e.getValue()).collect(Collectors.joining(","))); + } + + private String getDeviceType(String deviceType) { + return null == deviceType ? "" : (deviceType + " "); + } + + private String getUserId(String authorization) { + UserLoginDto userLoginDto = getUserLoginDto(authorization); + return null == userLoginDto ? "" : (userLoginDto.getUserId() + "_" + userLoginDto.getNickName()); + } +} 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 b1df820..75bf1a6 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 @@ -1,61 +1,16 @@ package com.luoo.music.controller; -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 controller.AbstractBaseExceptionHandler; 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()); - } - - /** - * 参数校检异常 - * - * @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()); - } +public class BaseExceptionHandler extends AbstractBaseExceptionHandler { + @Override + protected StatusCode getCommonFailedStatusCode() { + return StatusCode.MUSIC_COMMON_FAILED; + } } diff --git a/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java b/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java index 0a55915..99d800a 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/JournalController.java @@ -12,7 +12,6 @@ import com.luoo.music.dto.response.JournalRespDTO; import com.luoo.music.dto.response.SongRespDTO; import io.swagger.annotations.*; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.redis.core.RedisTemplate; @@ -50,6 +49,9 @@ public class JournalController { @Autowired private JournalService journalService; + + @Autowired + private JournalMapper journalMapper; @Autowired private SongController songController; @@ -124,7 +126,7 @@ public class JournalController { List pageList = journalService.orderByField(objectIds); UserLoginDto user = jwtUtil.getUserLoginDto(authorization); Set journalCollectSet = getMyCollectSet(user.getUserId(),queryReq.getUserId(),objectIds); - List list = pageList.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet)) + List list = pageList.stream().map(a -> journalMapper.getJournalRespDTO(a, journalCollectSet)) .collect(Collectors.toList()); // list = list.stream().map(journalRespDTO -> randomCDN(journalRespDTO)).collect(Collectors.toList()); return Result.success(new PageResult(count, list)); @@ -278,7 +280,7 @@ public class JournalController { List ids=journals.stream().map(Journal::getId).collect(Collectors.toList()); Set journalCollectSet = null == user ? Collections.emptySet() : userCollectInfoService.getCollectSet(user.getUserId(),ids, CollectTypeEnum.JOURNAL); - List list = journals.stream().sorted(Comparator.comparing(Journal::getUserCollectCount).reversed()).map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet)) + List list = journals.stream().sorted(Comparator.comparing(Journal::getUserCollectCount).reversed()).map(a -> journalMapper.getJournalRespDTO(a, journalCollectSet)) .collect(Collectors.toList()); return Result.success(list); } @@ -288,7 +290,7 @@ public class JournalController { @GlobalInterceptor public Result> recommend() { List journals = journalService.recommend(); - List list = journals.stream().sorted(Comparator.comparing(Journal::getUserCollectCount).reversed()).map(a -> JournalMapper.getJournalRespDTO(a)) + List list = journals.stream().sorted(Comparator.comparing(Journal::getUserCollectCount).reversed()).map(a -> journalMapper.getJournalRespDTO(a)) .collect(Collectors.toList()); return Result.success(list); } diff --git a/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java b/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java index 05fb856..e4cb7e7 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/SearchController.java @@ -43,6 +43,9 @@ public class SearchController { @Autowired private JournalService journalService; + @Autowired + private JournalMapper journalMapper; + @Autowired private JournalSongService journalSongService; @@ -89,7 +92,7 @@ public class SearchController { @VerifyParam(required = true) FuzzySearchReq query) throws InterruptedException, ExecutionException { PageRequest pageRequest = PageRequest.of(getPageNum(query.getPageNum()), getPageSize(query.getPageSize())); List pageResults=journalService.fuzzySearch(query.getKeyword(),pageRequest); - List list = pageResults.stream().map(JournalMapper::getJournalRespDTO) + List list = pageResults.stream().map(journalMapper::getJournalRespDTO) .collect(Collectors.toList()); return Result.success(new PageResult(Long.valueOf(list.size()), list)); } diff --git a/luoo_music/src/main/java/com/luoo/music/dao/JournalTagDao.java b/luoo_music/src/main/java/com/luoo/music/dao/JournalTagDao.java index 52f352d..19704f4 100644 --- a/luoo_music/src/main/java/com/luoo/music/dao/JournalTagDao.java +++ b/luoo_music/src/main/java/com/luoo/music/dao/JournalTagDao.java @@ -32,7 +32,6 @@ public interface JournalTagDao extends JpaRepository, JpaSpec @Query(value = "select journal_id FROM tb_journal_tag where tag_id=?1 or tag_id in (select id from tb_tag_info where parent_id=?1)", nativeQuery = true) List getJournalIdByTagId(String tagId); - @Query(value = "select journal_id from tb_journal_tag where tag_id in (select tag_id from tb_journal_tag where journal_id=?1) and not journal_id=?1 order by rand() limit ?2", nativeQuery = true) List recommendByJournalId(String journalId, Integer limit); } diff --git a/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java b/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java index 77dca1a..0ae5238 100644 --- a/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java +++ b/luoo_music/src/main/java/com/luoo/music/dao/TagDao.java @@ -33,4 +33,7 @@ public interface TagDao extends JpaRepository, JpaSpecificationExec @Query(value = "select name_ch from tb_journal_tag,tb_tag_info where journal_id = ?1 and tb_journal_tag.tag_id =tb_tag_info.id ;", nativeQuery = true) List getTagNameChByJournalId(String journalId); + + @Query(value = "select * from tb_tag_info where name_ch=?1 limit 1", nativeQuery = true) + Tag findByTagName(String tagName); } diff --git a/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java b/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java index a6f3dd1..04f1396 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/mapper/JournalMapper.java @@ -10,31 +10,60 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import com.luoo.music.client.UserClient; import net.oschina.j2cache.CacheChannel; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.data.mongodb.core.MongoTemplate; import com.apifan.common.random.RandomSource; import com.apifan.common.random.entity.Poem; import com.luoo.music.dao.CommentDao; +import com.luoo.music.dao.TagDao; import com.luoo.music.dto.response.CommentDTO; +import com.luoo.music.dto.response.JournalFilterDTO; import com.luoo.music.dto.response.JournalRespDTO; +import com.luoo.music.dto.response.TagDTO; import com.luoo.music.pojo.Journal; +import com.luoo.music.pojo.Tag; +import com.luoo.music.service.TagService; + import constants.Constants; import enums.DateTimePatternEnum; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + import util.DateUtil; import util.StringTools; - +@Component public class JournalMapper { - public static JournalRespDTO getJournalRespDTO(Journal journal) { + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private CacheChannel cacheChannel; + + @Autowired + private MongoTemplate mongoTemplate; + + @Autowired + private CommentDao commentDao; + + @Autowired + private TagDao tagDao; + + @Autowired + private UserClient userClient; + + public JournalRespDTO getJournalRespDTO(Journal journal) { return getJournalRespDTO(journal, Collections.emptySet()); } - public static JournalRespDTO getJournalRespDTO(Journal journal, Set journalCollectSet) { + public JournalRespDTO getJournalRespDTO(Journal journal, Set journalCollectSet) { JournalRespDTO journalRespDTO = new JournalRespDTO(); journalRespDTO.setId(journal.getId()); journalRespDTO.setJournalNo(journal.getJournalNo()); @@ -48,6 +77,8 @@ public class JournalMapper { String nameChTags=journal.getNameChTags(); if(!StringTools.isEmpty(nameChTags)) { List tags=Arrays.stream(nameChTags.split(",")).collect(Collectors.toList()); + List tagInfos = tags.stream().map(this::getTagDto).filter(Objects::nonNull).collect(Collectors.toList()); + journalRespDTO.setTagInfos(tagInfos); journalRespDTO.setTags(tags); } journalRespDTO.setContent(journal.getContent()); @@ -56,9 +87,22 @@ public class JournalMapper { return journalRespDTO; } + private TagDTO getTagDto(String tagName) { + return (TagDTO) this.cacheChannel.get("tag", tagName, key -> getTagDtoByName(tagName), false).getValue(); + + } + private TagDTO getTagDtoByName(String tagName) { + Tag tag=tagDao.findByTagName(tagName); + if(null==tag) { + return null; + } + TagDTO tagDTO=new TagDTO(); + tagDTO.setName(tag.getNameCh()); + tagDTO.setId(tag.getId()); + return tagDTO; + } - public static JournalRespDTO getJournalRespDTO(Journal journal, - MongoTemplate mongoTemplate, RedisTemplate redisTemplate, CommentDao commentDao, UserClient userClient, CacheChannel cacheChannel) { + public JournalRespDTO getJournalRespDTOWithComment(Journal journal) { JournalRespDTO journalRespDTO = getJournalRespDTO(journal); CommentDTO commentDTO = CommentMapper.getCommentDTO(journalRespDTO.getId(), mongoTemplate, commentDao, redisTemplate,userClient,cacheChannel); @@ -70,7 +114,7 @@ public class JournalMapper { } - private static String getPublishDate(Journal journal) { + private String getPublishDate(Journal journal) { LocalDateTime date = null == journal.getPubTime() ? journal.getCreateTime() : journal.getPubTime(); return DateUtil.format(date, DateTimePatternEnum.YYYY_DOT_MM_DOT_DD.getPattern()); } diff --git a/luoo_music/src/main/java/com/luoo/music/dto/request/JournalQueryReq.java b/luoo_music/src/main/java/com/luoo/music/dto/request/JournalQueryReq.java index 1032948..372f0fa 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/request/JournalQueryReq.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/request/JournalQueryReq.java @@ -33,6 +33,7 @@ public class JournalQueryReq implements Serializable { public String countString() { return getString(categoryId) + "_" + getString(journalNoRange); } + private String getString(String value) { return StringTools.isEmpty(value) ? null : value; } diff --git a/luoo_music/src/main/java/com/luoo/music/dto/response/JournalRespDTO.java b/luoo_music/src/main/java/com/luoo/music/dto/response/JournalRespDTO.java index bc50964..e3d9aa8 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/response/JournalRespDTO.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/response/JournalRespDTO.java @@ -20,6 +20,8 @@ public class JournalRespDTO implements Serializable { private String image; @ApiModelProperty(value = "期刊标签") private List tags; + @ApiModelProperty(value = "期刊标签信息") + private List tagInfos; @ApiModelProperty(value = "概要") private String summary; @ApiModelProperty(value = "文案") diff --git a/luoo_music/src/main/java/com/luoo/music/service/JournalService.java b/luoo_music/src/main/java/com/luoo/music/service/JournalService.java index 60e971c..17af6d3 100644 --- a/luoo_music/src/main/java/com/luoo/music/service/JournalService.java +++ b/luoo_music/src/main/java/com/luoo/music/service/JournalService.java @@ -1,6 +1,7 @@ package com.luoo.music.service; import java.util.*; +import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.persistence.criteria.CriteriaBuilder; @@ -14,6 +15,8 @@ import constants.Constants; import enums.JournalPublishEnum; import enums.JournalStatusEnum; import net.oschina.j2cache.CacheChannel; +import net.oschina.j2cache.CacheObject; + import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; @@ -57,6 +60,9 @@ public class JournalService { @Autowired private JournalSongDao journalSongDao; + @Autowired + private JournalMapper journalMapper; + @Autowired private JournalTagDao journalTagDao; @Autowired @@ -228,8 +234,6 @@ public class JournalService { return Collections.emptyList(); } - - public boolean isLatest10ByJournalNo(String journalNo) { return null!=journalDao.isLatest10ByJournalNo(journalNo); } @@ -349,23 +353,38 @@ public class JournalService { return journalDao.orderByField(recommendIds); } - public List orderByJournalIdField(List jouranlIds) { - return journalSongDao.orderByJournalIdField(jouranlIds); + return CollectionUtils.isEmpty(jouranlIds) ? Collections.emptyList() + : journalSongDao.orderByJournalIdField(jouranlIds); } - @SuppressWarnings("unchecked") public List queryJournalByPage(JournalQueryReq queryReq) { if(StringTools.isEmpty(queryReq.getCategoryId())&&StringTools.isEmpty(queryReq.getJournalNoRange())) { - return (List) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString(), key -> getJournalRespDTOWithComment(queryReq) , false).getValue() ; + return queryJournalByPage(queryReq, key -> getJournalRespDTOWithComment(queryReq)); } - List list= (List) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString(), key -> getJournalRespDTO(queryReq) , false).getValue() ; + List list= queryJournalByPage(queryReq,key -> getJournalRespDTO(queryReq)) ; list.parallelStream().forEach(j->{ updateComment(j); }); return list; } + @SuppressWarnings("unchecked") + private List queryJournalByPage(JournalQueryReq queryReq, + Function> function) { + CacheObject cacheObject=this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString()); + if(null==cacheObject||null==cacheObject.getValue()) { + List result = function.apply(queryReq); + if(CollectionUtils.isEmpty(result)) { + return Collections.emptyList(); + } + this.cacheChannel.set(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString(), result); + return result; + } + return (List) cacheObject.getValue(); + } + + private void updateComment(JournalRespDTO journalRespDTO) { CommentDTO commentDTO = CommentMapper.getCommentDTO(journalRespDTO.getId(), mongoTemplate, commentDao, redisTemplate,userClient,cacheChannel); @@ -378,12 +397,12 @@ public class JournalService { private List getJournalRespDTO(JournalQueryReq queryReq) { List pageList = queryPage(queryReq); return pageList.stream().map(a -> - JournalMapper.getJournalRespDTO(a)).collect(Collectors.toList()); + journalMapper.getJournalRespDTO(a)).collect(Collectors.toList()); } private List getJournalRespDTOWithComment(JournalQueryReq queryReq) { List pageList = queryPage(queryReq); - return pageList.stream().map(journal -> JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao,userClient,cacheChannel)).collect(Collectors.toList()); + return pageList.stream().map(journal -> journalMapper.getJournalRespDTOWithComment(journal)).collect(Collectors.toList()); } @@ -397,7 +416,7 @@ public class JournalService { if(null==journal) { return null; } - return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao,userClient,cacheChannel); + return journalMapper.getJournalRespDTOWithComment(journal); } public JournalRespDTO queryJournalByJournalNo(String journalNo) { @@ -409,7 +428,7 @@ public class JournalService { if(null==journal) { return null; } - return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao,userClient,cacheChannel); + return journalMapper.getJournalRespDTOWithComment(journal); } public JournalFilterDTO getJournalFilterDTO() { diff --git a/luoo_music/src/main/resources/ext.dic b/luoo_music/src/main/resources/ext.dic index 1fb130f..ee3c2e8 100644 --- a/luoo_music/src/main/resources/ext.dic +++ b/luoo_music/src/main/resources/ext.dic @@ -2,4 +2,5 @@ 诛仙2 梦幻诛仙 梦幻诛仙2 -大罗法咒 \ No newline at end of file +大罗法咒 +黑暗 \ No newline at end of file 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 353a1d3..97e8cbd 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 @@ -1,62 +1,16 @@ package com.luoo.user.controller; -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 controller.AbstractBaseExceptionHandler; 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.USER_COMMON_FAILED, e.getMessage()); - } - - @ExceptionHandler(value = BizException.class) - @ResponseBody - public Result error(BizException e) { - log.info("业务错误:{}", e.getMessage()); - 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()); +public class BaseExceptionHandler extends AbstractBaseExceptionHandler { + @Override + protected StatusCode getCommonFailedStatusCode() { + return StatusCode.USER_COMMON_FAILED; } -} +} \ No newline at end of file