diff --git a/luoo_common/src/main/java/enums/UserBadgeEnum.java b/luoo_common/src/main/java/enums/UserBadgeEnum.java new file mode 100644 index 0000000..a098302 --- /dev/null +++ b/luoo_common/src/main/java/enums/UserBadgeEnum.java @@ -0,0 +1,45 @@ +package enums; + + +public enum UserBadgeEnum { + //贡献者 三位数字,以1开头 + FOUNDER(100, "创始人"), + PRODUCT_MANAGER(101, "产品经理"), + EXPERIENCE_DESIGNER(102, "体验设计师"), + BACKEND(103, "服务端"), + QUALITY_ASSURANCE(104, "测试工程师"), + PROJECT_MANAGER(105, "项目管理"), + ANDROID_FRONTEND(106, "Android前端"), + IOS_FRONTEND(107, "IOS前端"), + PRODUCT_OPERATION(108, "产品运营"); + + + private Integer code; + private String desc; + + UserBadgeEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + + public static UserBadgeEnum getByCode(Integer code) { + for (UserBadgeEnum item : UserBadgeEnum.values()) { + if (item.getCode().equals(code)) { + return item; + } + } + return null; + } + + public Integer getCode() { + return code; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index 5e45609..ba0c2f6 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -36,6 +36,7 @@ import constants.Constants; import controller.BaseController; import com.luoo.user.dto.UserInfoUpdateDto; +import com.luoo.user.dto.response.UserBadge; import com.luoo.user.dto.response.UserRespDTO; import com.luoo.user.util.IpUtil; @@ -48,6 +49,7 @@ import dto.UserLoginDto; import enums.CollectTypeEnum; import enums.DateTimePatternEnum; import enums.RequestFrequencyTypeEnum; +import enums.UserBadgeEnum; import enums.UserRelationEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -275,7 +277,7 @@ public class MyController extends BaseController { UserRespDTO userRespDTO = new UserRespDTO(); BeanUtils.copyProperties(user, userRespDTO); if(!StringTools.isEmpty(user.getBadges())) { - userRespDTO.setBadgeList(Arrays.stream(user.getBadges().split(",")).map(Integer::valueOf).collect(Collectors.toList())); + userRespDTO.setBadgeList(Arrays.stream(user.getBadges().split(",")).map(this::getUserBadge).collect(Collectors.toList())); } if (null != userRespDTO.getAvatar()) { userRespDTO.setAvatar(Constants.RESOURCE_PREFIX + userRespDTO.getAvatar()); @@ -311,7 +313,13 @@ public class MyController extends BaseController { return userRespDTO; } - + private UserBadge getUserBadge(String code) { + UserBadge userBadge=new UserBadge(); + userBadge.setCode(Integer.valueOf(code)); + userBadge.setDesc(UserBadgeEnum.getByCode(userBadge.getCode()).getDesc()); + return userBadge; + } + // 查询我的获赞 @ApiOperation(value = "9.查询我的获赞的分页列表", notes = "游客无法获取") @GetMapping("/myThumbupList/{page}/{size}") diff --git a/luoo_user/src/main/java/com/luoo/user/dto/response/UserBadge.java b/luoo_user/src/main/java/com/luoo/user/dto/response/UserBadge.java new file mode 100644 index 0000000..6850276 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/response/UserBadge.java @@ -0,0 +1,11 @@ +package com.luoo.user.dto.response; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class UserBadge { + private Integer code; + private String desc; +} diff --git a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java index 3c36153..66e226b 100644 --- a/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java +++ b/luoo_user/src/main/java/com/luoo/user/dto/response/UserRespDTO.java @@ -17,8 +17,8 @@ public class UserRespDTO { private String avatar; @ApiModelProperty(value = "个性签名,首次注册登录,默认为“无签名”") private String signature; - @ApiModelProperty(value = "用户标识,1为贡献者 2为音乐人") - private List badgeList; + @ApiModelProperty(value = "用户标识,贡献者 三位数字,以1开头") + private List badgeList; @ApiModelProperty(value = "关注数") private int followCount; @ApiModelProperty(value = "粉丝数")