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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations