Search in sources :

Example 46 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysRoleAdminController method save.

/**
 * @param entity
 * @param moduleIds
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("save")
public String save(SysRole entity, Integer[] moduleIds, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    if (entity.isOwnsAllRight()) {
        moduleIds = null;
        entity.setShowAllModule(false);
    }
    if (null != entity.getId()) {
        SysRole oldEntity = service.getEntity(entity.getId());
        if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        entity = service.update(entity.getId(), entity, ignoreProperties);
        roleModuleService.updateRoleModules(entity.getId(), moduleIds);
        if (null != entity) {
            logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.role", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        }
    } else {
        entity.setSiteId(site.getId());
        service.save(entity);
        if (CommonUtils.notEmpty(moduleIds)) {
            List<SysRoleModule> list = new ArrayList<>();
            for (int moduleId : moduleIds) {
                list.add(new SysRoleModule(new SysRoleModuleId(entity.getId(), moduleId)));
            }
            roleModuleService.save(list);
        }
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.role", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    roleAuthorizedService.dealRoleModules(entity.getId(), entity.isShowAllModule(), moduleService.getEntitys(moduleIds), moduleService.getPageUrl(null));
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysRole(com.publiccms.entities.sys.SysRole) ArrayList(java.util.ArrayList) SysRoleModule(com.publiccms.entities.sys.SysRoleModule) SysSite(com.publiccms.entities.sys.SysSite) SysRoleModuleId(com.publiccms.entities.sys.SysRoleModuleId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 47 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysRoleAdminController method delete.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("delete")
public String delete(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysRole entity = service.getEntity(id);
    SysSite site = getSite(request);
    if (null != entity) {
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.delete(id);
        @SuppressWarnings("unchecked") List<SysRoleUser> roleUserList = (List<SysRoleUser>) roleUserService.getPage(id, null, null, null).getList();
        for (SysRoleUser roleUser : roleUserList) {
            userService.deleteRoleIds(roleUser.getId().getUserId(), id);
        }
        roleUserService.deleteByRoleId(id);
        roleModuleService.deleteByRoleId(id);
        roleAuthorizedService.deleteByRoleId(id);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.role", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysRole(com.publiccms.entities.sys.SysRole) ArrayList(java.util.ArrayList) List(java.util.List) SysSite(com.publiccms.entities.sys.SysSite) SysRoleUser(com.publiccms.entities.sys.SysRoleUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 48 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysSiteAdminController method save.

/**
 * @param entity
 * @param domainName
 * @param roleName
 * @param deptName
 * @param userName
 * @param password
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("save")
public String save(SysSite entity, String domainName, String roleName, String deptName, String userName, String password, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    if (ControllerUtils.verifyCustom("noright", !siteComponent.isMaster(site.getId()), model)) {
        return TEMPLATE_ERROR;
    }
    if (!entity.isUseStatic()) {
        entity.setUseSsi(false);
    }
    if (null != entity.getId()) {
        entity = service.update(entity.getId(), entity, ignoreProperties);
        if (null != entity) {
            logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.site", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        }
    } else {
        if (ControllerUtils.verifyCustom("needAuthorizationEdition", !CmsVersion.isAuthorizationEdition(), model) || ControllerUtils.verifyCustom("unauthorizedDomain", !CmsVersion.verifyDomain(domainName), model) || ControllerUtils.verifyNotEmpty("userName", userName, model) || ControllerUtils.verifyNotEmpty("password", password, model) || ControllerUtils.verifyHasExist("domain", service.getEntity(domainName), model)) {
            return TEMPLATE_ERROR;
        }
        service.save(entity);
        SysDomain domain = new SysDomain(domainName, entity.getId(), false);
        domainService.save(domain);
        SysDept dept = new SysDept(entity.getId(), deptName, 0, true, true);
        // 初始化部门
        deptService.save(dept);
        SysRole role = new SysRole(entity.getId(), roleName, true, true);
        // 初始化角色
        roleService.save(role);
        SysUser user = new SysUser(entity.getId(), userName, VerificationUtils.md5Encode(password), userName, dept.getId(), role.getId().toString(), null, false, true, false, null, null, 0, CommonUtils.getDate());
        // 初始化用户
        userService.save(user);
        // 初始化角色用户映射
        roleUserService.save(new SysRoleUser(new SysRoleUserId(role.getId(), user.getId())));
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.site", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    siteComponent.clear();
    return TEMPLATE_DONEANDREFRESH;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysDomain(com.publiccms.entities.sys.SysDomain) SysUser(com.publiccms.entities.sys.SysUser) SysDept(com.publiccms.entities.sys.SysDept) SysRole(com.publiccms.entities.sys.SysRole) SysRoleUserId(com.publiccms.entities.sys.SysRoleUserId) SysSite(com.publiccms.entities.sys.SysSite) SysRoleUser(com.publiccms.entities.sys.SysRoleUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 49 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysSiteAdminController method reCreateIndex.

/**
 * @param request
 * @param session
 * @return view name
 */
@RequestMapping("reCreateIndex")
public String reCreateIndex(HttpServletRequest request, HttpSession session) {
    contentService.reCreateIndex();
    SysSite site = getSite(request);
    Long userId = getAdminFromSession(session).getId();
    logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB_MANAGER, "delete.site", RequestUtils.getIpAddress(request), CommonUtils.getDate(), BLANK));
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with SysSite

use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.

the class SysSiteAdminController method execSql.

/**
 * @param sql
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("execSql")
public String execSql(String sql, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    if (ControllerUtils.verifyCustom("noright", !siteComponent.isMaster(site.getId()), model)) {
        return TEMPLATE_ERROR;
    }
    if (-1 < sql.indexOf(" ")) {
        String type = sql.substring(0, sql.indexOf(" "));
        try {
            if ("update".equalsIgnoreCase(type)) {
                model.addAttribute("result", sqlService.update(sql));
            } else if ("insert".equalsIgnoreCase(type)) {
                model.addAttribute("result", sqlService.insert(sql));
            } else if ("delete".equalsIgnoreCase(type)) {
                model.addAttribute("result", sqlService.delete(sql));
            } else {
                model.addAttribute("result", JsonUtils.getString(sqlService.select(sql)));
            }
        } catch (Exception e) {
            model.addAttribute("error", e.getMessage());
        }
        model.addAttribute("sql", sql);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "execsql.site", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(model)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) IOException(java.io.IOException) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SysSite (com.publiccms.entities.sys.SysSite)175 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)135 LogOperate (com.publiccms.entities.log.LogOperate)117 IOException (java.io.IOException)33 SysUser (com.publiccms.entities.sys.SysUser)21 LinkedHashMap (java.util.LinkedHashMap)19 TemplateException (freemarker.template.TemplateException)15 File (java.io.File)14 CmsContent (com.publiccms.entities.cms.CmsContent)12 CmsCategory (com.publiccms.entities.cms.CmsCategory)11 MultipartFile (org.springframework.web.multipart.MultipartFile)10 SysTask (com.publiccms.entities.sys.SysTask)9 HashMap (java.util.HashMap)8 LogUpload (com.publiccms.entities.log.LogUpload)7 SysDept (com.publiccms.entities.sys.SysDept)7 SysUserToken (com.publiccms.entities.sys.SysUserToken)7 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)7 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)6 CmsPlace (com.publiccms.entities.cms.CmsPlace)5 SysDomain (com.publiccms.entities.sys.SysDomain)5