Parcourir la source

部门列表排序修改

anderx il y a 2 ans
Parent
commit
5b597c231a

+ 21 - 0
src/main/java/com/goafanti/organization/service/impl/OrganizationServiceImpl.java

@@ -11,7 +11,11 @@ import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.organization.bo.DepOut;
 import com.goafanti.organization.bo.OrganizationListOut;
 import com.goafanti.organization.service.OrganizationService;
+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.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -63,6 +67,23 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
 			hideSign=null;
 		}
 		List<DepOut> depList=departmentMapper.selectSuperId(hideSign,null,null);
+
+		return listSort(depList);
+	}
+
+	private List<DepOut> listSort(List<DepOut> depList) {
+		HanyuPinyinOutputFormat format=new HanyuPinyinOutputFormat();
+		Collections.sort(depList, (o1, o2) -> {
+			String str1=null;
+			String str2=null;
+			try {
+				str1= PinyinHelper.toHanYuPinyinString(o1.getName(),format," ",true);
+				str2= PinyinHelper.toHanYuPinyinString(o2.getName(),format," ",true);
+			} catch (BadHanyuPinyinOutputFormatCombination e) {
+				throw new RuntimeException(e);
+			}
+			return str1.compareTo(str2);
+		});
 		return depList;
 	}
 

+ 2 - 2
src/main/java/com/goafanti/permission/service/impl/RoleServiceImpl.java

@@ -66,10 +66,10 @@ public class RoleServiceImpl extends BaseMybatisDao<RoleMapper> implements RoleS
 			}
 		}
 		ArrayList<RoleBo> roleBos = new ArrayList<>(roleMap.values());
-		return listSrot(roleBos);
+		return listSort(roleBos);
 	}
 
-	private List<RoleBo> listSrot(ArrayList<RoleBo> roleBos) {
+	private List<RoleBo> listSort(ArrayList<RoleBo> roleBos) {
 		HanyuPinyinOutputFormat format=new HanyuPinyinOutputFormat();
 		Collections.sort(roleBos, (o1, o2) -> {
 			String str1=null;