use of com.publiccms.entities.sys.SysRoleModuleId 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;
}
Aggregations