forked from github/cool-admin-java
feat: 组织模块授权支持排序
- AppOrgModuleEntity新增sortOrder字段 - authorizeModules按moduleKeys数组索引设置sortOrder - getModuleKeysByOrgId按sortOrder升序查询
This commit is contained in:
@@ -24,6 +24,9 @@ public class AppOrgModuleEntity extends BaseEntity<AppOrgModuleEntity> {
|
||||
@ColumnDefine(comment = "组织级模块配置", type = "text")
|
||||
private String config;
|
||||
|
||||
@ColumnDefine(comment = "排序号", type = "int", defaultValue = "0")
|
||||
private Integer sortOrder;
|
||||
|
||||
@ColumnDefine(comment = "状态 0:禁用 1:启用", defaultValue = "1")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ public class AppOrgModuleServiceImpl extends BaseServiceImpl<AppOrgModuleMapper,
|
||||
public List<String> getModuleKeysByOrgId(Long orgId) {
|
||||
List<AppOrgModuleEntity> modules = list(QueryWrapper.create()
|
||||
.eq(AppOrgModuleEntity::getOrgId, orgId)
|
||||
.eq(AppOrgModuleEntity::getStatus, 1));
|
||||
.eq(AppOrgModuleEntity::getStatus, 1)
|
||||
.orderBy(AppOrgModuleEntity::getSortOrder, true));
|
||||
return modules.stream()
|
||||
.map(AppOrgModuleEntity::getModuleKey)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -110,7 +110,8 @@ public class AppOrgServiceImpl extends BaseServiceImpl<AppOrgMapper, AppOrgEntit
|
||||
.eq(AppOrgModuleEntity::getOrgId, orgId);
|
||||
appOrgModuleService.remove(qw);
|
||||
|
||||
for (String moduleKey : moduleKeys) {
|
||||
for (int i = 0; i < moduleKeys.size(); i++) {
|
||||
String moduleKey = moduleKeys.get(i);
|
||||
AppModuleEntity module = appModuleMapper.selectOneByQuery(
|
||||
QueryWrapper.create().eq(AppModuleEntity::getModuleKey, moduleKey)
|
||||
);
|
||||
@@ -119,6 +120,7 @@ public class AppOrgServiceImpl extends BaseServiceImpl<AppOrgMapper, AppOrgEntit
|
||||
AppOrgModuleEntity orgModule = new AppOrgModuleEntity();
|
||||
orgModule.setOrgId(orgId);
|
||||
orgModule.setModuleKey(moduleKey);
|
||||
orgModule.setSortOrder(i);
|
||||
orgModule.setStatus(1);
|
||||
appOrgModuleService.add(orgModule);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user