wangwei 7 年之前
父節點
當前提交
5a4e0ab042

+ 7 - 3
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/RolePrivilegeController.java

@@ -91,7 +91,8 @@ public class RolePrivilegeController extends ControllerSupport {
 		List<Long> roleIdList = Lists.newArrayList();
 		for (Role cur : roleList) {
 			String roleCode = cur.getRoleCode();
-			cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity role = roleRepo.findByCode(roleCode);
+			cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity role = roleRepo
+					.findByCode(roleCode);
 			if (null == role) {
 				throw new StatusException("B-002002", "role code is wrong. roleCode=" + roleCode);
 			}
@@ -106,7 +107,8 @@ public class RolePrivilegeController extends ControllerSupport {
 			pIdSet.add(String.valueOf(cur.getPrivilegeId()));
 		}
 
-		List<PrivilegeEntity> privilegeList = privilegeRepo.findAllByGroupId(privilegeGroup.getId());
+		List<PrivilegeEntity> privilegeList = privilegeRepo
+				.findAllByGroupIdOrderByWeightDesc(privilegeGroup.getId());
 
 		List<PrivilegeInfo> privilegeInfoList = Lists.newArrayList();
 
@@ -126,6 +128,7 @@ public class RolePrivilegeController extends ControllerSupport {
 			privilegeInfo.setParentId(cur.getParentId());
 			privilegeInfo.setUpdateTime(cur.getUpdateTime());
 			privilegeInfo.setDescription(cur.getDescription());
+			privilegeInfo.setWeight(cur.getWeight());
 			privilegeInfo.setExt1(cur.getExt1());
 			privilegeInfo.setExt2(cur.getExt2());
 			privilegeInfo.setExt3(cur.getExt3());
@@ -168,7 +171,8 @@ public class RolePrivilegeController extends ControllerSupport {
 	@GetMapping("getPrivilegeTree/{groupId}")
 	public EleTreeNode getPrivilegeTree(@PathVariable Long groupId) {
 		PrivilegeGroupEntity group = privilegeGroupRepo.findOne(groupId);
-		List<PrivilegeEntity> privilegeList = privilegeRepo.findAllByGroupId(groupId);
+		List<PrivilegeEntity> privilegeList = privilegeRepo
+				.findAllByGroupIdOrderByWeightDesc(groupId);
 		EleTreeNode rootNode = new EleTreeNode(-1L, group.getName());
 		TreeUtil.convert2OneEleTreeNode(rootNode, privilegeList);
 

+ 10 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/bean/PrivilegeInfo.java

@@ -55,6 +55,8 @@ public class PrivilegeInfo implements JsonSerializable, TreeNode {
 
 	private Date creationTime;
 
+	private Long weight = 0L;
+
 	/**
 	 * 扩展属性
 	 */
@@ -152,6 +154,14 @@ public class PrivilegeInfo implements JsonSerializable, TreeNode {
 		this.creationTime = creationTime;
 	}
 
+	public Long getWeight() {
+		return weight;
+	}
+
+	public void setWeight(Long weight) {
+		this.weight = weight;
+	}
+
 	public String getExt1() {
 		return ext1;
 	}

+ 1 - 1
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/PrivilegeRepo.java

@@ -21,7 +21,7 @@ public interface PrivilegeRepo
 			QueryByExampleExecutor<PrivilegeEntity>,
 			JpaSpecificationExecutor<PrivilegeEntity> {
 
-	List<PrivilegeEntity> findAllByGroupId(Long groupId);
+	List<PrivilegeEntity> findAllByGroupIdOrderByWeightDesc(Long groupId);
 
 	List<PrivilegeEntity> findAllByParentId(Long parentId);
 

+ 14 - 0
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/PrivilegeEntity.java

@@ -58,6 +58,12 @@ public class PrivilegeEntity extends JpaEntity implements TreeNode {
 	@Column(unique = false, nullable = true)
 	private String description;
 
+	/**
+	 * 权重(越大越靠前)
+	 */
+	@Column(unique = false, nullable = false)
+	private Long weight = 0L;
+
 	/**
 	 * 扩展属性
 	 */
@@ -136,6 +142,14 @@ public class PrivilegeEntity extends JpaEntity implements TreeNode {
 		this.description = description;
 	}
 
+	public Long getWeight() {
+		return weight;
+	}
+
+	public void setWeight(Long weight) {
+		this.weight = weight;
+	}
+
 	public String getExt1() {
 		return ext1;
 	}