|
|
|
@ -224,23 +224,27 @@ public class RoleFormButtonServiceImpl extends BaseService<RoleFormButton, Long> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public MyPageData<Map<String, Object>> listAllFormButtons(Long roleId, MyOrderParam orderParam, MyPageParam pageParam) { |
|
|
|
public MyPageData<Map<String, Object>> listAllFormButtons(Long roleId, String pageName, MyOrderParam orderParam, MyPageParam pageParam) { |
|
|
|
// 1. 查询已发布的 page(不分页,获取全量)
|
|
|
|
// 1. 分页查询已发布页面(分页维度为「页面」,可按页面名称模糊筛选)
|
|
|
|
List<OnlinePage> pageList = onlinePageService.queryByEnableList(); |
|
|
|
if (pageParam != null) { |
|
|
|
|
|
|
|
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<OnlinePage> pageList = onlinePageService.queryByEnableList(pageName); |
|
|
|
if (CollectionUtil.isEmpty(pageList)) { |
|
|
|
if (CollectionUtil.isEmpty(pageList)) { |
|
|
|
return new MyPageData<>(Collections.emptyList(), 0L); |
|
|
|
return new MyPageData<>(Collections.emptyList(), 0L); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
long total = pageList instanceof Page ? ((Page) pageList).getTotal() : pageList.size(); |
|
|
|
Set<Long> pageIdSet = pageList.stream().map(OnlinePage::getPageId).collect(Collectors.toSet()); |
|
|
|
Set<Long> pageIdSet = pageList.stream().map(OnlinePage::getPageId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
// 2. 分页查询 OnlineForm
|
|
|
|
// 2. 查询这些页面下的全部表单(不再分页),按页面分组
|
|
|
|
if (pageParam != null) { |
|
|
|
|
|
|
|
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineForm.class); |
|
|
|
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineForm.class); |
|
|
|
OnlineForm onlineForm = new OnlineForm(); |
|
|
|
OnlineForm onlineForm = new OnlineForm(); |
|
|
|
onlineForm.setPageIdSet(pageIdSet); |
|
|
|
onlineForm.setPageIdSet(pageIdSet); |
|
|
|
List<OnlineForm> formList = onlineFormService.getOnlineFormList(onlineForm, orderBy); |
|
|
|
List<OnlineForm> formList = onlineFormService.getOnlineFormList(onlineForm, orderBy); |
|
|
|
long total = formList instanceof Page ? ((Page) formList).getTotal() : formList.size(); |
|
|
|
Map<Long, List<OnlineForm>> formMapByPageId = new HashMap<>(); |
|
|
|
|
|
|
|
for (OnlineForm form : formList) { |
|
|
|
|
|
|
|
formMapByPageId.computeIfAbsent(form.getPageId(), k -> new ArrayList<>()).add(form); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3. 如果传了 roleId,查询 RoleFormButton 获取勾选状态
|
|
|
|
// 3. 如果传了 roleId,查询 RoleFormButton 获取勾选状态
|
|
|
|
Map<Long, Set<String>> formCheckedMap = Collections.emptyMap(); |
|
|
|
Map<Long, Set<String>> formCheckedMap = Collections.emptyMap(); |
|
|
|
@ -254,19 +258,26 @@ public class RoleFormButtonServiceImpl extends BaseService<RoleFormButton, Long> |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 4. 构建结果
|
|
|
|
// 4. 按页面组装两层结构:页面 → 表单 → 按钮
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>(); |
|
|
|
List<Map<String, Object>> result = new ArrayList<>(); |
|
|
|
for (OnlineForm form : formList) { |
|
|
|
for (OnlinePage page : pageList) { |
|
|
|
|
|
|
|
Map<String, Object> pageItem = new HashMap<>(); |
|
|
|
|
|
|
|
pageItem.put("pageName", page.getPageName()); |
|
|
|
|
|
|
|
List<Map<String, Object>> formItemList = new ArrayList<>(); |
|
|
|
|
|
|
|
for (OnlineForm form : formMapByPageId.getOrDefault(page.getPageId(), Collections.emptyList())) { |
|
|
|
List<WidgetJsonButtonParser.ButtonInfo> buttons = |
|
|
|
List<WidgetJsonButtonParser.ButtonInfo> buttons = |
|
|
|
WidgetJsonButtonParser.extractEnabledButtons(form.getWidgetJson()); |
|
|
|
WidgetJsonButtonParser.extractEnabledButtons(form.getWidgetJson()); |
|
|
|
Map<String, Object> item = getButtonResult(form, buttons); |
|
|
|
Map<String, Object> formItem = getButtonResult(form, buttons); |
|
|
|
if (roleId != null) { |
|
|
|
if (roleId != null) { |
|
|
|
Set<String> checkedNames = formCheckedMap.get(form.getFormId()); |
|
|
|
Set<String> checkedNames = formCheckedMap.get(form.getFormId()); |
|
|
|
if (CollectionUtil.isNotEmpty(checkedNames)) { |
|
|
|
if (CollectionUtil.isNotEmpty(checkedNames)) { |
|
|
|
applyCheckedStatus(item, checkedNames); |
|
|
|
applyCheckedStatus(formItem, checkedNames); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
formItemList.add(formItem); |
|
|
|
} |
|
|
|
} |
|
|
|
result.add(item); |
|
|
|
pageItem.put("formList", formItemList); |
|
|
|
|
|
|
|
result.add(pageItem); |
|
|
|
} |
|
|
|
} |
|
|
|
return new MyPageData<>(result, total); |
|
|
|
return new MyPageData<>(result, total); |
|
|
|
} |
|
|
|
} |
|
|
|
|