Search in sources :

Example 1 with SysModule

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;
}
Also used : SysModule(com.publiccms.entities.sys.SysModule) List(java.util.List) HashSet(java.util.HashSet)

Example 2 with SysModule

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();
        }
    }
}
Also used : SysModule(com.publiccms.entities.sys.SysModule) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with SysModule

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)));
            }
        }
    }
}
Also used : SysModule(com.publiccms.entities.sys.SysModule) SysRoleAuthorized(com.publiccms.entities.sys.SysRoleAuthorized) SysRoleAuthorizedId(com.publiccms.entities.sys.SysRoleAuthorizedId) List(java.util.List) HashSet(java.util.HashSet)

Example 4 with SysModule

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;
}
Also used : SysModule(com.publiccms.entities.sys.SysModule) LogOperate(com.publiccms.entities.log.LogOperate) SysRoleModule(com.publiccms.entities.sys.SysRoleModule) List(java.util.List) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SysModule (com.publiccms.entities.sys.SysModule)4 List (java.util.List)3 HashSet (java.util.HashSet)2 LogOperate (com.publiccms.entities.log.LogOperate)1 SysRoleAuthorized (com.publiccms.entities.sys.SysRoleAuthorized)1 SysRoleAuthorizedId (com.publiccms.entities.sys.SysRoleAuthorizedId)1 SysRoleModule (com.publiccms.entities.sys.SysRoleModule)1 SysSite (com.publiccms.entities.sys.SysSite)1 LinkedHashMap (java.util.LinkedHashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1