|
|
@@ -1,14 +1,5 @@
|
|
|
package com.goafanti.permission.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.RoleMapper;
|
|
|
import com.goafanti.common.dao.RolePermissionMapper;
|
|
|
@@ -23,6 +14,13 @@ import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.permission.bo.RoleBo;
|
|
|
import com.goafanti.permission.bo.RolePermissionBo;
|
|
|
import com.goafanti.permission.service.RoleService;
|
|
|
+import net.sourceforge.pinyin4j.PinyinHelper;
|
|
|
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
|
|
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class RoleServiceImpl extends BaseMybatisDao<RoleMapper> implements RoleService {
|
|
|
@@ -49,7 +47,6 @@ public class RoleServiceImpl extends BaseMybatisDao<RoleMapper> implements RoleS
|
|
|
} else {
|
|
|
res = roleMapper.findRolePermissions();
|
|
|
}
|
|
|
-
|
|
|
Map<String, RoleBo> roleMap = new HashMap<>();
|
|
|
for (RolePermissionBo rp : res) {
|
|
|
RoleBo rb = roleMap.get(rp.getRid());
|
|
|
@@ -68,7 +65,24 @@ public class RoleServiceImpl extends BaseMybatisDao<RoleMapper> implements RoleS
|
|
|
rb.getPermissions().add(p);
|
|
|
}
|
|
|
}
|
|
|
- return new ArrayList<>(roleMap.values());
|
|
|
+ ArrayList<RoleBo> roleBos = new ArrayList<>(roleMap.values());
|
|
|
+ return listSrot(roleBos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<RoleBo> listSrot(ArrayList<RoleBo> roleBos) {
|
|
|
+ HanyuPinyinOutputFormat format=new HanyuPinyinOutputFormat();
|
|
|
+ Collections.sort(roleBos, (o1, o2) -> {
|
|
|
+ String str1=null;
|
|
|
+ String str2=null;
|
|
|
+ try {
|
|
|
+ str1= PinyinHelper.toHanYuPinyinString(o1.getRoleName(),format," ",true);
|
|
|
+ str2= PinyinHelper.toHanYuPinyinString(o2.getRoleName(),format," ",true);
|
|
|
+ } catch (BadHanyuPinyinOutputFormatCombination e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ return str1.compareTo(str2);
|
|
|
+ });
|
|
|
+ return roleBos;
|
|
|
}
|
|
|
|
|
|
@Override
|