1.update contributor seq

main
Gary 11 months ago
parent d410cead76
commit 01af3116ff

@ -44,4 +44,13 @@ public enum UserBadgeEnum {
public void setDesc(String desc) {
this.desc = desc;
}
public static UserBadgeEnum getByValue(String string) {
for (UserBadgeEnum item : UserBadgeEnum.values()) {
if (item.getDesc().equals(string)) {
return item;
}
}
return null;
}
}

@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@ -290,7 +291,7 @@ public class MyController extends BaseController {
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.setContributorRole(UserBadgeEnum.getByCode(Integer.valueOf(b.split("_")[0])).getDesc());
}
});
userRespDTO.setBadgeList(new ArrayList<>(badgeSet));
@ -383,8 +384,11 @@ public class MyController extends BaseController {
@ApiOperation(value = "11.感谢", notes = "贡献者列表")
@GetMapping("/thanks")
public Result<List<UserRespDTO>> getThanks() {
List<UserRespDTO> list=userInfoService.getThanks().stream().map(user->getUserRespDTO(user, false, Collections.emptySet())).collect(Collectors.toList());
List<UserRespDTO> list=userInfoService.getThanks().stream().sorted(Comparator.comparing(u->getIndex(u))).map(user->getUserRespDTO(user, false, Collections.emptySet())).collect(Collectors.toList());
return Result.success(list);
}
private Integer getIndex(UserInfo u) {
return Integer.valueOf(Arrays.stream(u.getBadges().split(",")).filter(s->s.startsWith(String.valueOf(UserBadgeEnum.CONTRIBUTOR.getCode()))).findFirst().get().split("_")[1]);
}
}

@ -36,6 +36,6 @@ public interface UserInfoDao extends JpaRepository<UserInfo, String>, JpaSpecifi
@Query(value = "select * from tb_user_info where id = ?1", nativeQuery = true)
public UserInfo getById(String id);
@Query(value = "select * from tb_user_info where badges like '%1%' ", nativeQuery = true)
@Query(value = "select * from tb_user_info where badges like '1%' ", nativeQuery = true)
public List<UserInfo> getThanks();
}

@ -0,0 +1,62 @@
package com.luoo.user.util;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import com.luoo.user.pojo.UserInfo;
import enums.UserBadgeEnum;
public class UserBadgeTest {
@Test
public void test() {
List<String> ss=getList();
for(int i=0;i<ss.size();i++) {
printUpdateSql(ss.get(i),i+1);
}
//ss.forEach(this::printUpdateSql);
String badge="106_1";
System.out.println(getIndex(badge));
}
private Integer getIndex(String badge) {
return Integer.valueOf(Arrays.stream(badge.split(",")).filter(s->s.startsWith(String.valueOf(UserBadgeEnum.CONTRIBUTOR.getCode()))).findFirst().get().split("_")[1]);
}
private void printUpdateSql(String s, int i) {
String[] segs=s.split(",");
if(segs.length<2) {
return;
}
int code=UserBadgeEnum.getByValue(segs[0]).getCode();
String mobile=segs[1];
System.out.println("UPDATE indie_user.tb_user_info SET badges='"+code+"_"+i+"' WHERE mobile='"+mobile+"';");
}
private List<String> getList() {
List<String> ss=new ArrayList<>();
ss.add("UI,18758090993");
ss.add("IOS前端,18551843868");
ss.add("Java,18200158229");
ss.add("Android前端,13266603385");
ss.add("Java,18311057634");
ss.add("H5前端,17858850966");
ss.add("H5前端,15033352380");
ss.add("Java");
ss.add("Java,18610234961");
ss.add("Android测试,18514589123");
ss.add("IOS测试,19939378614");
ss.add("产品,18922274448");
ss.add("技术顾问,18002283025");
ss.add("技术顾问");
ss.add("服务器支持");
ss.add("公众号支持,18408263665");
return ss;
}
}
Loading…
Cancel
Save