mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2025-01-27 13:53:59 +08:00
新增输入内容合法性检查
This commit is contained in:
parent
68c6ccd5d0
commit
2f8a0f2e23
@ -12,6 +12,10 @@ public class GroupController {
|
||||
public static void createGroup(AbstractOperator operator, String domName, String groupName) {
|
||||
AbstractOperator.Result FAIL = new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "创建权限组 %s 失败", groupName);
|
||||
AbstractOperator.Result SUCCESS = new AbstractOperator.Result(AbstractOperator.Result.SUCCESS, "创建权限组 %s 成功", groupName);
|
||||
if (groupName.contains(" ")) {
|
||||
operator.setResponse(FAIL.addMessage("权限组名称不能包含空格"));
|
||||
return;
|
||||
}
|
||||
DominionDTO dominion = DominionDTO.select(domName);
|
||||
if (dominion == null) {
|
||||
operator.setResponse(FAIL.addMessage("领地 %s 不存在", domName));
|
||||
@ -99,6 +103,10 @@ public class GroupController {
|
||||
public static void renameGroup(AbstractOperator operator, String domName, String oldName, String newName) {
|
||||
AbstractOperator.Result FAIL = new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "重命名权限组 %s 为 %s 失败", oldName, newName);
|
||||
AbstractOperator.Result SUCCESS = new AbstractOperator.Result(AbstractOperator.Result.SUCCESS, "重命名权限组 %s 为 %s 成功", oldName, newName);
|
||||
if (newName.contains(" ")) {
|
||||
operator.setResponse(FAIL.addMessage("权限组名称不能包含空格"));
|
||||
return;
|
||||
}
|
||||
DominionDTO dominion = DominionDTO.select(domName);
|
||||
if (dominion == null) {
|
||||
operator.setResponse(FAIL.addMessage("领地 %s 不存在", domName));
|
||||
|
@ -10,10 +10,14 @@ public class TemplateController {
|
||||
public static void createTemplate(AbstractOperator operator, String templateName) {
|
||||
AbstractOperator.Result SUCCESS = new AbstractOperator.Result(AbstractOperator.Result.SUCCESS, "创建成功");
|
||||
AbstractOperator.Result FAIL = new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "创建失败");
|
||||
if (templateName.contains(" ")) {
|
||||
operator.setResponse(FAIL.addMessage("模板名称不能包含空格"));
|
||||
return;
|
||||
}
|
||||
List<PrivilegeTemplateDTO> templates = PrivilegeTemplateDTO.selectAll(operator.getUniqueId());
|
||||
for (PrivilegeTemplateDTO template : templates) {
|
||||
if (template.getName().equals(templateName)) {
|
||||
operator.setResponse(FAIL.addMessage("已经存在名为" + templateName + "的权限模板"));
|
||||
operator.setResponse(FAIL.addMessage("已经存在名为 %s 的权限模板", templateName));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -22,7 +26,7 @@ public class TemplateController {
|
||||
operator.setResponse(FAIL.addMessage("可能是数据库错误,请联系管理员"));
|
||||
return;
|
||||
}
|
||||
operator.setResponse(SUCCESS.addMessage("成功创建名为" + templateName + "的权限模板"));
|
||||
operator.setResponse(SUCCESS.addMessage("成功创建名为 %s 的权限模板", templateName));
|
||||
}
|
||||
|
||||
public static void deleteTemplate(AbstractOperator operator, String templateName) {
|
||||
|
@ -46,7 +46,7 @@ public class GroupSetting {
|
||||
.append(Button.create("权限组列表").setExecuteCommand("/dominion group_list " + dominion.getName()).build())
|
||||
.append("权限组管理")
|
||||
);
|
||||
Button rename_btn = Button.create("重命名")
|
||||
Button rename_btn = Button.create("重命名此权限组")
|
||||
.setHoverText("重命名权限组 " + group.getName())
|
||||
.setExecuteCommand("/dominion cui_rename_group " + dominion.getName() + " " + group.getName());
|
||||
view.add(Line.create().append(rename_btn.build()));
|
||||
|
Loading…
Reference in New Issue
Block a user