1.simplfy user badge

main
Gary 11 months ago
parent d8b798414b
commit b1d7a2963d

@ -3,15 +3,16 @@ 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, "产品运营");
CONTRIBUTOR(1, "贡献者"),
CONTRIBUTOR_FOUNDER(100, "创始人"),
CONTRIBUTOR_PRODUCT_MANAGER(101, "产品经理"),
CONTRIBUTOR_EXPERIENCE_DESIGNER(102, "体验设计师"),
CONTRIBUTOR_BACKEND(103, "服务端"),
CONTRIBUTOR_QUALITY_ASSURANCE(104, "测试工程师"),
CONTRIBUTOR_PROJECT_MANAGER(105, "项目管理"),
CONTRIBUTOR_ANDROID_FRONTEND(106, "Android前端"),
CONTRIBUTOR_IOS_FRONTEND(107, "IOS前端"),
CONTRIBUTOR_PRODUCT_OPERATION(108, "产品运营");
private Integer code;

@ -1,9 +1,11 @@
package com.luoo.user.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
@ -36,7 +38,6 @@ 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;
@ -277,7 +278,15 @@ 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(this::getUserBadge).collect(Collectors.toList()));
Set<Integer> badgeSet = new HashSet<>();
Arrays.stream(user.getBadges().split(",")).forEach(b->{
int code=Integer.valueOf(b.substring(0, 1));
badgeSet.add(code);
if(code==UserBadgeEnum.CONTRIBUTOR.getCode()) {
userRespDTO.setContributorRole(UserBadgeEnum.getByCode(Integer.valueOf(b)).getDesc());
}
});
userRespDTO.setBadgeList(new ArrayList<>(badgeSet));
}
if (null != userRespDTO.getAvatar()) {
userRespDTO.setAvatar(Constants.RESOURCE_PREFIX + userRespDTO.getAvatar());
@ -313,13 +322,6 @@ 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}")

@ -1,11 +0,0 @@
package com.luoo.user.dto.response;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserBadge {
private Integer code;
private String desc;
}

@ -17,8 +17,10 @@ public class UserRespDTO {
private String avatar;
@ApiModelProperty(value = "个性签名,首次注册登录,默认为“无签名”")
private String signature;
@ApiModelProperty(value = "用户标识,贡献者 三位数字以1开头")
private List<UserBadge> badgeList;
@ApiModelProperty(value = "用户标识,贡献者:1 ")
private List<Integer> badgeList;
@ApiModelProperty(value = "贡献者角色")
private String contributorRole;
@ApiModelProperty(value = "关注数")
private int followCount;
@ApiModelProperty(value = "粉丝数")

Loading…
Cancel
Save