use of com.publiccms.entities.sys.SysModule in project PublicCMS-preview by sanluan.
the class SysModuleService method getPageUrl.
/**
* @param parentId
* @return
*/
@SuppressWarnings("unchecked")
public Set<String> getPageUrl(Integer parentId) {
Set<String> urls = new HashSet<>();
for (SysModule entity : (List<SysModule>) getPage(parentId, null, null, null).getList()) {
if (CommonUtils.notEmpty(entity.getUrl())) {
int index = entity.getUrl().indexOf("?");
urls.add(entity.getUrl().substring(0, index > 0 ? index : entity.getUrl().length()));
}
urls.addAll(getPageUrl(entity.getId()));
}
return urls;
}
use of com.publiccms.entities.sys.SysModule in project PublicCMS-preview by sanluan.
the class SysModuleDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Integer id = handler.getInteger("id");
if (CommonUtils.notEmpty(id)) {
SysModule entity = service.getEntity(id);
if (null != entity) {
handler.put("object", entity).render();
}
} else {
Integer[] ids = handler.getIntegerArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<SysModule> entityList = service.getEntitys(ids);
Map<String, SysModule> map = new LinkedHashMap<>();
for (SysModule entity : entityList) {
map.put(String.valueOf(entity.getId()), entity);
}
handler.put("map", map).render();
}
}
}
use of com.publiccms.entities.sys.SysModule in project PublicCMS-preview by sanluan.
the class SysRoleAuthorizedService method dealRoleModules.
/**
* @param roleId
* @param showAllModule
* @param modules
* @param pageUrls
*/
public void dealRoleModules(Integer roleId, boolean showAllModule, List<SysModule> modules, Set<String> pageUrls) {
if (CommonUtils.notEmpty(roleId)) {
Set<String> urls = new HashSet<>();
if (CommonUtils.notEmpty(modules)) {
for (SysModule module : modules) {
if (CommonUtils.notEmpty(module.getUrl()) && !showAllModule) {
int index = module.getUrl().indexOf("?");
urls.add(module.getUrl().substring(0, index > 0 ? index : module.getUrl().length()));
}
if (CommonUtils.notEmpty(module.getAuthorizedUrl())) {
for (String url : StringUtils.split(module.getAuthorizedUrl(), ',')) {
urls.add(url);
}
}
}
}
if (showAllModule) {
urls.addAll(pageUrls);
}
@SuppressWarnings("unchecked") List<SysRoleAuthorized> list = (List<SysRoleAuthorized>) getPage(roleId, null, null, null).getList();
for (SysRoleAuthorized roleAuthorized : list) {
if (urls.contains(roleAuthorized.getId().getUrl())) {
urls.remove(roleAuthorized.getId().getUrl());
} else {
delete(roleAuthorized.getId());
}
}
if (!urls.isEmpty()) {
for (String url : urls) {
save(new SysRoleAuthorized(new SysRoleAuthorizedId(roleId, url)));
}
}
}
}
use of com.publiccms.entities.sys.SysModule in project PublicCMS-preview by sanluan.
the class SysModuleAdminController method delete.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@SuppressWarnings("unchecked")
@RequestMapping("delete")
public String delete(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (ControllerUtils.verifyCustom("noright", !siteComponent.isMaster(site.getId()), model)) {
return TEMPLATE_ERROR;
}
SysModule entity = service.getEntity(id);
if (null != entity) {
service.delete(id);
List<SysRoleModule> roleModuleList = (List<SysRoleModule>) roleModuleService.getPage(null, id, null, null).getList();
roleModuleService.deleteByModuleId(id);
dealRoleAuthorized(roleModuleList);
logOperateService.save(new LogOperate(getSite(request).getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.module", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
Aggregations