提交 ad87737f 编写于 作者: O o2sword

系统角色名称不允许修改

上级 1ba05601
package com.x.organization.assemble.control.jaxrs.role;
import com.x.base.core.project.organization.OrganizationDefinition;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
......@@ -38,12 +39,15 @@ class ActionEdit extends BaseAction {
if (StringUtils.isEmpty(wi.getName())) {
throw new ExceptionNameEmpty();
}
/** 重新取出 */
role = emc.find(role.getId(), Role.class);
if (OrganizationDefinition.DEFAULTROLES.contains(role.getName()) && !role.getName().equals(wi.getName())) {
throw new ExceptionDenyUpdateDefaultRole(role.getName());
}
Gson gsontool = new Gson();
String strRole = gsontool.toJson(role);
Wi.copier.copy(wi, role);
/** 如果唯一标识不为空,要检查唯一标识是否唯一 */
if (this.uniqueDuplicateWhenNotEmpty(business, role)) {
......@@ -59,11 +63,11 @@ class ActionEdit extends BaseAction {
emc.check(role, CheckPersistType.all);
emc.commit();
CacheManager.notify(Role.class);
/**创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
orgMessageFactory.createMessageCommunicate("modfiy", "role",strRole, role, effectivePerson);
Wo wo = new Wo();
wo.setId(role.getId());
result.setData(wo);
......@@ -82,6 +86,6 @@ class ActionEdit extends BaseAction {
ListTools.toList(JpaObject.FieldsUnmodify, "pinyin", "pinyinInitial"));
}
}
......@@ -8,12 +8,14 @@ import java.util.stream.Collectors;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Group;
......@@ -46,6 +48,9 @@ class ActionGet extends BaseAction {
throw new ExceptionRoleNotExist(flag);
}
Wo wo = Wo.copier.copy(o);
if (OrganizationDefinition.DEFAULTROLES.contains(wo.getName())) {
wo.setIsSystemRole(true);
}
this.referenceGroup(business, wo);
this.referencePerson(business, wo);
return wo;
......@@ -76,6 +81,9 @@ class ActionGet extends BaseAction {
private static final long serialVersionUID = -127291000673692614L;
@FieldDescribe("是否是系统角色")
private Boolean isSystemRole = false;
private List<WoGroup> woGroupList;
private List<WoPerson> woPersonList;
......@@ -99,6 +107,13 @@ class ActionGet extends BaseAction {
this.woPersonList = woPersonList;
}
public Boolean getIsSystemRole() {
return isSystemRole;
}
public void setIsSystemRole(Boolean isSystemRole) {
isSystemRole = isSystemRole;
}
}
public static class WoGroup extends Group {
......@@ -119,4 +134,4 @@ class ActionGet extends BaseAction {
}
}
\ No newline at end of file
}
package com.x.organization.assemble.control.jaxrs.role;
import com.x.base.core.project.exception.PromptException;
class ExceptionDenyUpdateDefaultRole extends PromptException {
private static final long serialVersionUID = 5167597034206987929L;
ExceptionDenyUpdateDefaultRole(String name) {
super("不能修改系统默认角色名称:{}.", name);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册