use of com.publiccms.entities.log.LogOperate 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.log.LogOperate 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.log.LogOperate 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;
}
use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class SysTaskAdminController 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) {
SysSite site = getSite(request);
SysTask entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
service.delete(id);
scheduledTask.delete(id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method runOnce.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("runOnce")
public String runOnce(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
SysTask entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
scheduledTask.runOnce(site, id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "runOnce.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
Aggregations