Authored by qinchao

用户权限

... ... @@ -20,4 +20,7 @@ public class AuthModule {
private int moduleLevel;
//////// 不是数据库字段
private int moduleGroupSeq;
}
... ...
... ... @@ -9,7 +9,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, name, cname
id, name, cname,seqno
</sql>
<select id="selectAll" resultMap="BaseResultMap">
... ...
... ... @@ -18,7 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping("module")
... ... @@ -42,6 +43,37 @@ public class ModuleCtrl {
return new BaseResponse<List<User>>();
}
List<ModuleGroup> groups=moduleGroupMapper.selectAll();
Map<String,Integer> groupSeq=groups.stream().collect(Collectors.toMap(ModuleGroup::getName, ModuleGroup::getSeqNO));
for(AuthModule a:list){
if(groupSeq.containsKey(a.getModuleGroup())){
a.setModuleGroupSeq(groupSeq.get(a.getModuleGroup()));
}else{
a.setModuleGroupSeq(0);
}
}
Collections.sort(list, new Comparator(){
@Override
public int compare(Object o1, Object o2) {
AuthModule stu1=(AuthModule)o1;
AuthModule stu2=(AuthModule)o2;
if(stu1.getModuleGroupSeq()
>stu2.getModuleGroupSeq()){
return 1;
}else if(stu1.getModuleGroupSeq()==stu2.getModuleGroupSeq()){
if(stu1.getId()>stu2.getId()){
return 1;
}else {
return -1;
}
}else{
return -1;
}
}
});
return new BaseResponse<List<AuthModule>>(list);
}catch (Exception e){
log.error("getAll error",e);
... ...