From 183c32a12ac4814d5b2b671877f1cf48f2e5b73c Mon Sep 17 00:00:00 2001 From: lvxinran Date: Wed, 18 Dec 2019 00:40:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BC=9A=E4=BF=AE=E6=94=B9=E5=90=8D?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/exception/ErrorCode.java | 6 ++++- .../ljsd/jieling/logic/family/GuildLogic.java | 24 +++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java b/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java index 81d36f183..8feb3d9c7 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java @@ -139,7 +139,11 @@ public enum ErrorCode implements IErrorCode { MAP_IN(105,"在地图探索中,不可以操作"), HERO_LIVE_AGAIN(106,"英雄{0}秒后复活"), REWARD_COLLECTING(107,"奖励正在积攒中!"), - IN_BLACK(108,"对方已被您加入黑名单,无法添加好友") + IN_BLACK(108,"对方已被您加入黑名单,无法添加好友"), + NULL_NAME(109,"名字不能为空"), + NAME_LENGTH_ERROR(110,"公会名长度不符"), + EXIST_NAME(111,"此名已存在"); + ; private static final Set CodeSet = new HashSet<>(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java index 5d8b1a6e1..42c8dc112 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java @@ -87,10 +87,7 @@ public class GuildLogic { int uid = session.getUid(); User user = UserManager.getUser(uid); int msgId = MessageTypeProto.MessageType.FAMILY_CREATE_RESPONSE_VALUE; - String err = checkForCreateGuild(user, familyName, announce); - if(!"".equals(err)){ - throw new ErrorCodeException(ErrorCode.newDefineCode(err)); - } + checkForCreateGuild(user, familyName, announce); boolean enough= ItemUtil.itemCost(user, SGuildSetting.sGuildSetting.getCreatCost(), BIReason.CREATE_GUILD_CONSUME, 0); if(!enough){ throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH); @@ -118,31 +115,29 @@ public class GuildLogic { MessageUtil.sendMessage(session,1,msgId,build,true); } - public static String checkForCreateGuild( User user,String familyName,String announce) throws Exception { + public static void checkForCreateGuild( User user,String familyName,String announce) throws Exception { if(!Repot37EventUtil.Report37Chat(user, ChatContentType.FAMILY_NAME.getType(),announce)){ - return "包含敏感字"; + throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE); } if(StringUtil.isEmpty(familyName)){ - return "名字不能为空"; + throw new ErrorCodeException(ErrorCode.NULL_NAME); } boolean result = true; if(!StringUtil.isEmpty(announce)){ result = ShieldedWordUtils.checkName(user,announce,false,ChatContentType.FAMILY_NAME); if (!result) { - return "包含敏感字"; + throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE); } } if(familyName.length()SGuildSetting.sGuildSetting.getNameSize()[1]){ - return "公会名长度不符"; + throw new ErrorCodeException(ErrorCode.NAME_LENGTH_ERROR); } Map guildInfoMap = GuilidManager.guildInfoMap; for(Map.Entry entry:guildInfoMap.entrySet()){ if(entry.getValue().getName().equals(familyName)){ - return "此名已存在"; + throw new ErrorCodeException(ErrorCode.EXIST_NAME); } } - - return ""; } @@ -687,10 +682,7 @@ public class GuildLogic { if(type==1){ guildInfo.setAnnounce(content); }else{ - String checkResult = checkForCreateGuild(user, content, guildInfo.getAnnounce()); - if(!"".equals(checkResult)){ - throw new ErrorCodeException(ErrorCode.newDefineCode(checkResult)); - } + checkForCreateGuild(user, content, guildInfo.getAnnounce()); int[][] renameCost = SGuildSetting.sGuildSetting.getRenameCost(); boolean b = ItemUtil.itemCost(user, renameCost, BIReason.FAMILY_RENAME, 1); if(!b){