From 9855819a1e58622a353de4612a5a52451d1a5959 Mon Sep 17 00:00:00 2001 From: zhoujunqiang Date: Fri, 9 Dec 2022 10:01:11 +0800 Subject: [PATCH] 1.留言功能调整; 2.代码结构调整,弃用动态代理 --- pom.xml | 4 ++-- src/main/java/com/qiwuai/garden/SecretGardenApplication.java | 4 +--- src/main/java/com/qiwuai/garden/common/InitSysServlet.java | 16 +++++++++++++++- src/main/java/com/qiwuai/garden/common/ProxyFactory.java | 5 ++++- src/main/java/com/qiwuai/garden/common/TimingAcquisition.java | 63 +++++++++++++++++++++++---------------------------------------- src/main/java/com/qiwuai/garden/common/cache/UserThread.java | 5 ----- src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java | 6 +++++- src/main/java/com/qiwuai/garden/common/utils/DataTrimUtil.java | 219 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java | 33 ++++++++++++++++++++++++++++----- src/main/java/com/qiwuai/garden/common/utils/PersistenceUtil.java | 60 ++++++++++++++++++++++++++++++++++++++++++------------------ src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java | 19 ------------------- src/main/java/com/qiwuai/garden/common/utils/SpeechUtil.java | 3 +-- src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- src/main/java/com/qiwuai/garden/common/utils/YamlUtil.java | 42 +++++++++++++++++++++++++----------------- src/main/java/com/qiwuai/garden/controller/CommonController.java | 550 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/com/qiwuai/garden/service/adviseService/impl/AdviseServiceImpl.java | 4 +++- src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java | 1 + src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java | 11 ++++++++--- src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java | 45 +++++++++++++++++++++++++++++++++++++++++---- src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java | 4 +++- src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java | 4 +++- src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java | 4 +++- src/main/java/com/qiwuai/garden/service/rankingService/impl/RankingServiceImpl.java | 28 +++++++++++++++++++++++++++- src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java | 4 +++- src/main/resources/application-crazyPro.yml | 12 ++++++------ src/main/resources/application-crazyUat.yml | 2 +- src/main/resources/application-dev.yml | 12 ++++++------ src/main/resources/application-pro.yml | 12 ++++++------ src/main/resources/application-uat.yml | 14 +++++++------- src/main/resources/log4j2.xml | 2 +- src/main/resources/speech/ranking.yaml | 4 ++++ src/main/resources/speech/social.yaml | 2 ++ 33 files changed, 973 insertions(+), 427 deletions(-) delete mode 100644 src/main/java/com/qiwuai/garden/common/cache/UserThread.java create mode 100644 src/main/java/com/qiwuai/garden/common/utils/DataTrimUtil.java diff --git a/pom.xml b/pom.xml index cab05d5..b669aed 100644 --- a/pom.xml +++ b/pom.xml @@ -5,10 +5,10 @@ 4.0.0 org.example - SecretGradeGame + SecretGardenGame 1.0-SNAPSHOT jar - secretGradeGame + secretGardenGame secretGardenGame diff --git a/src/main/java/com/qiwuai/garden/SecretGardenApplication.java b/src/main/java/com/qiwuai/garden/SecretGardenApplication.java index 83484bc..b9f811c 100644 --- a/src/main/java/com/qiwuai/garden/SecretGardenApplication.java +++ b/src/main/java/com/qiwuai/garden/SecretGardenApplication.java @@ -6,6 +6,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @@ -14,9 +15,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling public class SecretGardenApplication { public static void main(String[] args) { - TimingAcquisition timingAcquisition = new TimingAcquisition(); -// timingAcquisition.loadingTest(); - TimingAcquisition.loading(); SpringApplication.run(SecretGardenApplication.class, args); ExpireThread expireThread = new ExpireThread(); Thread thread = new Thread(expireThread); diff --git a/src/main/java/com/qiwuai/garden/common/InitSysServlet.java b/src/main/java/com/qiwuai/garden/common/InitSysServlet.java index fbda136..b2aa68f 100644 --- a/src/main/java/com/qiwuai/garden/common/InitSysServlet.java +++ b/src/main/java/com/qiwuai/garden/common/InitSysServlet.java @@ -13,6 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; @@ -27,6 +28,13 @@ import java.util.stream.Collectors; public class InitSysServlet implements InitializingBean { Logger log = LoggerFactory.getLogger(InitSysServlet.class); + @Value("${userFilePath}") + private String userFilePath; + @Value("${configFilePath}") + private String configFilePath; + @Value("${speechFilePath}") + private String speechFilePath; + private NurseryMapper nurseryMapper; private PlantPeriodMapper plantPeriodMapper; private PlantMapper plantMapper; @@ -178,6 +186,12 @@ public class InitSysServlet implements InitializingBean { */ @Override public void afterPropertiesSet() throws Exception { + //--------------------------加载玩家数据---------------------- + TimingAcquisition.loading(userFilePath); + + //--------------------加载话术----------------- + TimingAcquisition.speechLoading(speechFilePath); + //--------------------------缓存花圃配置信息---------------------- log.info("开始缓存花圃配置信息到缓存"); Map nurseryPojoMap = new ConcurrentHashMap<>(); @@ -514,7 +528,7 @@ public class InitSysServlet implements InitializingBean { TimingAcquisition.friendshipRankingList.addAll(friendshipRankingList); //获取所有地区 String fileName = "region.json"; - String s = PersistenceUtil.getConfigFromFile(fileName); + String s = PersistenceUtil.getConfigFromFile(configFilePath, fileName); Map> IPRegionsMap = JSON.parseObject(s, new TypeReference>>(){}); for (Map.Entry> entry : IPRegionsMap.entrySet()) { List regionIPList = entry.getValue(); diff --git a/src/main/java/com/qiwuai/garden/common/ProxyFactory.java b/src/main/java/com/qiwuai/garden/common/ProxyFactory.java index 669f706..bb03a1d 100644 --- a/src/main/java/com/qiwuai/garden/common/ProxyFactory.java +++ b/src/main/java/com/qiwuai/garden/common/ProxyFactory.java @@ -2,6 +2,7 @@ package com.qiwuai.garden.common; import com.qiwuai.garden.common.cache.CacheUtil; import com.qiwuai.garden.common.utils.DateUtil; +import com.qiwuai.garden.common.utils.HttpUtil; import com.qiwuai.garden.common.utils.SpeechUtil; import com.qiwuai.garden.common.utils.YamlUtil; import com.qiwuai.garden.dto.FriendDto; @@ -12,6 +13,7 @@ import com.qiwuai.garden.dto.base.ResultVarsResponse; import com.qiwuai.garden.dto.request.OperationRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.util.StringUtils; import java.lang.reflect.InvocationHandler; @@ -23,7 +25,8 @@ import java.util.Map; public class ProxyFactory { Logger log = LoggerFactory.getLogger(ProxyFactory.class); //从yml配置文件中取出对话过期时间 - String offlineTime = YamlUtil.getValueByKey("offlineTime"); + @Value("${offlineTime}") + private String offlineTime; private Object target; public ProxyFactory(Object target) { diff --git a/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java b/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java index f61ac02..249d455 100644 --- a/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java +++ b/src/main/java/com/qiwuai/garden/common/TimingAcquisition.java @@ -21,7 +21,6 @@ import org.springframework.util.StringUtils; import javax.annotation.PostConstruct; import java.io.File; import java.math.BigDecimal; -import java.text.ParseException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -83,7 +82,14 @@ public class TimingAcquisition { * 地区友情榜 */ public volatile static Map> regionFriendShipRankingListMap = new ConcurrentHashMap<>(); - + /** + * 配置文件信息 + */ + public volatile static Map applicationMap = new ConcurrentHashMap<>(); + /** + * 敏感词 + */ + public volatile static List sensitiveWordList = new ArrayList<>(); /** @@ -241,10 +247,8 @@ public class TimingAcquisition { /** * 通过json文件加载所有用户数据到缓存中 */ - public static void loading() { + public static void loading(String userFilePath) { log.info("-----------开始加载玩家数据----------------"); - //从yml配置文件中取出存放玩家数据的地址 - String userFilePath = YamlUtil.getValueByKey("userFilePath"); File file = new File(userFilePath); File[] files = file.listFiles(); if (files == null) { @@ -255,24 +259,17 @@ public class TimingAcquisition { if (f.isFile()) { String s = PersistenceUtil.getDataFromFile(String.valueOf(f)); //JSON转map对象 -// log.info("取出的数据:" + s); Map gardener = JSON.parseObject(s, new TypeReference>(){}); -// log.info("从文件中取出玩家的缓存数据:" + gardener); gardenerMap.putAll(gardener); } } log.info("-----------玩家数据加载完成----------------"); -// log.info("内存中所有玩家的缓存数据:" + gardenerMap ); - //加载话术 - speechLoading(); - //加载配置文件region.json -// regionNoLoading("region.json"); } /** * 通过yaml文件加载所有话术到缓存中 */ - public static void speechLoading() { + public static void speechLoading(String speechFilePath) { log.info("---------开始加载话术到缓存中---------"); Map>> plantSpeech = new HashMap<>(); Map>> gardenerSpeech = new HashMap<>(); @@ -284,26 +281,19 @@ public class TimingAcquisition { Map>> adviseSpeech = new HashMap<>(); Map>> rankingSpeech = new HashMap<>(); try { - plantSpeech = YamlUtil.loadSpeechToMap("plant.yaml"); - gardenerSpeech = YamlUtil.loadSpeechToMap("gardener.yaml"); - petSpeech = YamlUtil.loadSpeechToMap("pet.yaml"); - marketSpeech = YamlUtil.loadSpeechToMap("market.yaml"); - socialSpeech = YamlUtil.loadSpeechToMap("social.yaml"); - taskSpeech = YamlUtil.loadSpeechToMap("task.yaml"); - helpSpeech = YamlUtil.loadSpeechToMap("help.yaml"); - adviseSpeech = YamlUtil.loadSpeechToMap("advise.yaml"); - rankingSpeech = YamlUtil.loadSpeechToMap("ranking.yaml"); + plantSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "plant.yaml"); + gardenerSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "gardener.yaml"); + petSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "pet.yaml"); + marketSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "market.yaml"); + socialSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "social.yaml"); + taskSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "task.yaml"); + helpSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "help.yaml"); + adviseSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "advise.yaml"); + rankingSpeech = YamlUtil.loadSpeechToMap(speechFilePath, "ranking.yaml"); } catch (Exception e) { e.printStackTrace(); } //JSON转map对象 -// log.info("从yaml文件中取出的种植话术:" + plantSpeech); -// log.info("从yaml文件中取出的园丁话术:" + gardenerSpeech); -// log.info("从yaml文件中取出的宠物话术:" + petSpeech); -// log.info("从yaml文件中取出的市场话术:" + marketSpeech); -// log.info("从yaml文件中取出的社交话术:" + socialSpeech); -// log.info("从yaml文件中取出的任务话术:" + taskSpeech); -// log.info("从yaml文件中取出的帮助话术:" + helpSpeech); plantSpeechMap.putAll(plantSpeech); gardenerSpeechMap.putAll(gardenerSpeech); petSpeechMap.putAll(petSpeech); @@ -313,13 +303,6 @@ public class TimingAcquisition { helpSpeechMap.putAll(helpSpeech); adviseSpeechMap.putAll(adviseSpeech); rankingSpeechMap.putAll(rankingSpeech); -// log.info("缓存中玩家的种植话术:" + plantSpeechMap); -// log.info("缓存中玩家的园丁话术:" + gardenerSpeechMap); -// log.info("缓存中玩家的宠物话术:" + petSpeechMap); -// log.info("缓存中玩家的市场话术:" + marketSpeechMap); -// log.info("缓存中玩家的社交话术:" + socialSpeechMap); -// log.info("缓存中玩家的任务话术:" + taskSpeechMap); -// log.info("缓存中玩家的帮助话术:" + helpSpeechMap); log.info("---------加载话术到缓存的操作完成---------"); } @@ -327,8 +310,8 @@ public class TimingAcquisition { * @param fileName * 通过json文件加载配置到缓存中 */ - public static void regionNoLoading(String fileName) { - String s = PersistenceUtil.getConfigFromFile(fileName); + public static void regionNoLoading(String configFilePath, String fileName) { + String s = PersistenceUtil.getConfigFromFile(configFilePath, fileName); //JSON转map对象 log.info(fileName + "配置文件取出的配置数据:" + s); Map config = JSON.parseObject(s, new TypeReference>(){}); @@ -339,10 +322,10 @@ public class TimingAcquisition { /** * 通过json文件加载配置到缓存中 */ - public static String generateAddress(String IP) { + public static String generateAddress(String configFilePath, String IP) { String result = null; String fileName = "region.json"; - String s = PersistenceUtil.getConfigFromFile(fileName); + String s = PersistenceUtil.getConfigFromFile(configFilePath, fileName); Map> IPRegionsMap = JSON.parseObject(s, new TypeReference>>(){}); log.info(fileName + "文件中取出服务器和地区的数据:" + IPRegionsMap); //通过服务器IP找到所有的地区 diff --git a/src/main/java/com/qiwuai/garden/common/cache/UserThread.java b/src/main/java/com/qiwuai/garden/common/cache/UserThread.java deleted file mode 100644 index d3f78d2..0000000 --- a/src/main/java/com/qiwuai/garden/common/cache/UserThread.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.qiwuai.garden.common.cache; - - -public class UserThread { -} diff --git a/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java b/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java index 8f4128e..a37fb63 100644 --- a/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java +++ b/src/main/java/com/qiwuai/garden/common/schedule/ScheduleTask.java @@ -14,6 +14,7 @@ import com.qiwuai.garden.pojo.PetPojo; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; @@ -32,6 +33,9 @@ import java.util.concurrent.TimeUnit; public class ScheduleTask { Logger log = LoggerFactory.getLogger(ScheduleTask.class); + @Value("${configFilePath}") + public String configFilePath; + //定时喂养宠物,消耗物品 // @Scheduled(cron = "0 0 1 * * ?") // @Scheduled(cron = "0/60 * * * * ?") @@ -120,7 +124,7 @@ public class ScheduleTask { TimingAcquisition.friendshipRankingList.addAll(friendshipRankingList); //获取所有地区 String fileName = "region.json"; - String s = PersistenceUtil.getConfigFromFile(fileName); + String s = PersistenceUtil.getConfigFromFile(configFilePath, fileName); Map> IPRegionsMap = JSON.parseObject(s, new TypeReference>>(){}); for (Map.Entry> entry : IPRegionsMap.entrySet()) { List regionIPList = entry.getValue(); diff --git a/src/main/java/com/qiwuai/garden/common/utils/DataTrimUtil.java b/src/main/java/com/qiwuai/garden/common/utils/DataTrimUtil.java new file mode 100644 index 0000000..1bf2d2d --- /dev/null +++ b/src/main/java/com/qiwuai/garden/common/utils/DataTrimUtil.java @@ -0,0 +1,219 @@ +package com.qiwuai.garden.common.utils; + +import com.qiwuai.garden.common.Constants; +import com.qiwuai.garden.common.TimingAcquisition; +import com.qiwuai.garden.common.cache.CacheUtil; +import com.qiwuai.garden.dto.FriendDto; +import com.qiwuai.garden.dto.GardenerDto; +import com.qiwuai.garden.dto.base.CommonResponse; +import com.qiwuai.garden.dto.base.ResultVarsResponse; +import com.qiwuai.garden.dto.request.OperationRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; + +import java.text.ParseException; +import java.util.List; +import java.util.Map; + +public class DataTrimUtil { + static Logger log = LoggerFactory.getLogger(DataTrimUtil.class); + + /** + * 更改玩家状态 + */ + public static void AdjustStatus(String uid, String offlineTime) throws ParseException { + //玩家当前为离线状态 + GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); + //操作时间为今天之前,需重置 + String nowTime = DateUtil.getCurrentTime(); + if (!StringUtils.isEmpty(gardener.getOnlineTime())) { + if (DateUtil.compare(nowTime, gardener.getOnlineTime()) == 1) { + //遍历日常任务 + if (!StringUtils.isEmpty(gardener.getDailyTaskCountMap())) { + log.info(uid + "的日常任务重置时间:" + nowTime); + for (Map.Entry entry : gardener.getDailyTaskCountMap().entrySet()) { + entry.setValue(0); + } + for (Map.Entry entry : gardener.getDailyTaskFinishMap().entrySet()) { + entry.setValue(0); + } + //更新日常任务重置时间 + gardener.setDailyTaskResetTime(nowTime); + } + //重置好友已帮助的标记 + List friendList = gardener.getFriendList(); + if (!StringUtils.isEmpty(friendList)) { + if (friendList.size() != 0) { + for (FriendDto friend : friendList) { + //已经帮助过的好友重置 + if (friend.getHelpTag() == Constants.HELP_HAVE_SIGN) { + friend.setHelpTag(Constants.HELP_NO_SIGN); + } + } + } + } + //重置帮助和偷菜次数为0 + gardener.setHelpTimes(0); + gardener.setStealTimes(0); + //重置“今日已偷取的陌生人” + gardener.setStrangerMap(null); + //更新玩家在线状态 + statusUpdate(uid); + } + } else { + //更新玩家在线状态 + statusUpdate(uid); + } + if (gardener.getStatus() == Constants.OFFLINE) { + //更新玩家在线状态 + statusUpdate(uid); + } + //该玩家以唯一标识加入全局缓存,用于玩家离线判断 + String uniqueUid = uid + "%#%online%#%"; + CacheUtil.put(uniqueUid, "", Long.parseLong(offlineTime)); + } + + /** + * 判断整数尾数是否为1 + */ + public static CommonResponse AdjustParams(String uid, CommonResponse result, OperationRequest request) throws ParseException { + ResultVarsResponse data = result.getData(); + //检索到有新消息 + if (!StringUtils.isEmpty(data)) { + //玩家有新的消息提醒 + if (checkNewMessage(uid)) { + data.getVars().set消息提醒("1"); + } + //所有“后台附加返回”为null值的都给转成“无效返回” + if (StringUtils.isEmpty(data.getVars().get后台附加返回())) { + data.getVars().set后台附加返回("无效返回"); + } + //所有“后台附加返回”为null值的都给转成“无效返回” + if (StringUtils.isEmpty(data.getVars().get后台附加返回2())) { + data.getVars().set后台附加返回2("无效返回"); + } + //所有“建议指令”为null值的都给转成“无效返回” + if (StringUtils.isEmpty(data.getVars().get建议指令())) { + data.getVars().set建议指令("无效返回"); + } + //替换话术词汇 + String text = data.getVars().get反馈文本(); + if (!StringUtils.isEmpty(text)) { + //替换话术的【男园丁】或【女园丁】 + String gardenerName = request.getGardenerName(); + if (!StringUtils.isEmpty(gardenerName)) { + if (text.contains("【男园丁@正常】")) { + text = text.replace("【男园丁@正常】", "【" + gardenerName + "@正常】"); + } + if (text.contains("【女园丁@正常】")) { + text = text.replace("【女园丁@正常】", "【" + gardenerName + "@正常】"); + } + text = text.replace("园丁", gardenerName); + data.getVars().set反馈文本(text); + } + //替换话术里的{花圃称呼} + if (text.contains("{花圃称呼}")) { + data.getVars().set反馈文本(SpeechUtil.replaceNurseryName(text)); + } + } + //玩家货币数量 + //获取货币袋 + //货币配置信息 + Integer moneyId = Integer.parseInt(TimingAcquisition.systemConfigMap.get("money").getValue()); + Integer moneyNum = TimingAcquisition.gardenerMap.get(uid).getBackPack().getItemBags() + .get(Constants.ITEM_TYPE_MONEY).getItems(moneyId).getItemNum(); + data.getVars().set玩家金币数量(moneyNum); + //------------是否有宠物---------- + int petCount = TimingAcquisition.getPetNum(uid); + if (petCount > 0) { + data.getVars().set是否有宠物("是"); + } + //------------是否有植物---------- + boolean plantExist = TimingAcquisition.havaNurseryPlant(uid); + if (plantExist) { + data.getVars().set是否有植物("是"); + } + //------------是否开启日常任务---------- + boolean dailyTaskExist = TimingAcquisition.havaDailyTask(uid); + if (dailyTaskExist) { + data.getVars().set是否开启日常任务("是"); + } + String feedContent = "后台返回参数 = [" + + "code:" + result.getCode() + + ", msg:" + result.getMsg() + + ", 反馈ID:" + data.getVars().get反馈ID() + + ", 反馈文本:" + data.getVars().get反馈文本() + + ", 后台附加返回:" + data.getVars().get后台附加返回() + + ", 后台附加返回2:" + data.getVars().get后台附加返回2() + + ", 消息推送附加返回:" + data.getVars().get消息推送附加返回() + + ", 玩家当前地址:" + data.getVars().get玩家当前位置() + + ", 消息提醒:" + data.getVars().get消息提醒() + + ", 任务完成:" + data.getVars().get任务完成() + + ", 玩家金币数量:" + data.getVars().get玩家金币数量() + + ", 是否有宠物:" + data.getVars().get是否有宠物() + + ", 是否有植物:" + data.getVars().get是否有植物() + + ", 是否开启日常任务:" + data.getVars().get是否开启日常任务() + + "]"; + //玩家有新消息提示 + log.info(feedContent); + } + return result; + } + + /** + * 玩家状态更新为在线 + */ + public static void statusUpdate(String uid) { + if (!StringUtils.isEmpty(TimingAcquisition.gardenerMap.get(uid))) { + TimingAcquisition.gardenerMap.get(uid).setStatus(Constants.ONLINE); + //修改上线时间 + TimingAcquisition.gardenerMap.get(uid).setOnlineTime(DateUtil.getCurrentTime()); + } + } + + /** + * 检查玩家是否有新消息 + */ + public static boolean checkNewMessage(String uid) { + boolean result = false; + //获取玩家的所有消息提醒 + Map notice = TimingAcquisition.gardenerMap.get(uid).getNotice(); + //遍历所有消息提示,统计各类消息提醒次数 + for (Map.Entry entry : notice.entrySet()) { + if (entry.getValue() > 0) { + //好友申请提示个数 + if (Constants.ADD_FRIEND_NOTICE.equals(entry.getKey())) { + result = true; + break; + } + //好友申请通过的个数 + if (Constants.PASS_ADD_FRIEND_NOTICE.equals(entry.getKey())) { + result = true; + break; + } + //好友留言提示个数 + if (Constants.MESSAGE_NOTICE.equals(entry.getKey())) { + result = true; + break; + } + //偷菜简报提示个数 + if (Constants.STEAL_REPORT_NOTICE.equals(entry.getKey())) { + result = true; + break; + } + //帮助简报提示个数 + if (Constants.HELP_REPORT_NOTICE.equals(entry.getKey())) { + result = true; + break; + } + //任务提示个数 + if (Constants.TASK_NOTICE.equals(entry.getKey())) { + result = true; + break; + } + } + } + return result; + } +} diff --git a/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java b/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java index 7f151e6..4de780a 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/HttpUtil.java @@ -7,27 +7,50 @@ import com.qiwuai.garden.dto.response.PhraseResponse; import org.apache.commons.codec.digest.DigestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import java.util.List; +@Component public class HttpUtil { static Logger log = LoggerFactory.getLogger(HttpUtil.class); //动态词组更新秘钥 - public static String appSecret = YamlUtil.getValueByKey("appSecret"); + public static String appSecret; + @Value("${appSecret}") + public void setAppSecret(String appSecret) { + HttpUtil.appSecret = appSecret; + } //动态词组更新秘钥 - public static String updatePhraseUrl = YamlUtil.getValueByKey("updatePhraseUrl"); + public static String updatePhraseUrl; + @Value("${updatePhraseUrl}") + public void setUpdatePhraseUrl(String updatePhraseUrl) { + HttpUtil.updatePhraseUrl = updatePhraseUrl; + } //分享关系地址 - public static String shareRelationUrl = YamlUtil.getValueByKey("shareRelationUrl"); + public static String shareRelationUrl; + @Value("${shareRelationUrl}") + public void setShareRelationUrl(String shareRelationUrl) { + HttpUtil.shareRelationUrl = shareRelationUrl; + } //分享链接通道 - public static String shareChannelId = YamlUtil.getValueByKey("shareChannelId"); + public static String shareChannelId; + @Value("${shareChannelId}") + public void setShareChannelId(String shareChannelId) { + HttpUtil.shareChannelId = shareChannelId; + } //分享链接秘钥 - public static String shareAppSecret = YamlUtil.getValueByKey("shareAppSecret"); + public static String shareAppSecret; + @Value("${shareAppSecret}") + public void setShareAppSecret(String shareAppSecret) { + HttpUtil.shareAppSecret = shareAppSecret; + } //更新动态词组 public static void doPut(String phraseName, String phraseContent) { diff --git a/src/main/java/com/qiwuai/garden/common/utils/PersistenceUtil.java b/src/main/java/com/qiwuai/garden/common/utils/PersistenceUtil.java index fb8f4fb..2b2bf30 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/PersistenceUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/PersistenceUtil.java @@ -4,27 +4,45 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.TimingAcquisition; -import com.qiwuai.garden.dto.BackPackDto; import com.qiwuai.garden.dto.HelpReportDto; import com.qiwuai.garden.dto.MessageTimeDto; import com.qiwuai.garden.dto.StealReportDto; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; import java.io.*; import java.util.*; +@Component public class PersistenceUtil { //玩家数据的存放路径 - public static String userFilePath = YamlUtil.getValueByKey("userFilePath"); + public static String userFilePath; + @Value("${userFilePath}") + public void setUserFilePath(String userFilePath) { + PersistenceUtil.userFilePath = userFilePath; + } //各地区编号的存放路径 - public static String configFilePath = YamlUtil.getValueByKey("configFilePath"); + public static String configFilePath; + @Value("${configFilePath}") + public void setConfigFilePath(String configFilePath) { + PersistenceUtil.configFilePath = configFilePath; + } //各玩家的留言信息 - public static String messageFilePath = YamlUtil.getValueByKey("messageFilePath"); + public static String messageFilePath; + @Value("${messageFilePath}") + public void setMessageFilePath(String messageFilePath) { + PersistenceUtil.messageFilePath = messageFilePath; + } //各玩家的简报信息 - public static String reportFilePath = YamlUtil.getValueByKey("reportFilePath"); + public static String reportFilePath; + @Value("${reportFilePath}") + public void setReportFilePath(String reportFilePath) { + PersistenceUtil.reportFilePath = reportFilePath; + } /** * 保存玩家数据到json文件 * @param fileName @@ -122,7 +140,7 @@ public class PersistenceUtil { * @param fileName * @return String */ - public static String getConfigFromFile(String fileName) { + public static String getConfigFromFile(String configFilePath, String fileName) { BufferedReader reader = null; String lastStr = ""; try { @@ -152,20 +170,26 @@ public class PersistenceUtil { * @return String */ public static List getContentFromFile(String fileName) { - List contentList = new ArrayList<>(); - try { - File file = new File(configFilePath + fileName); - Workbook workbook = Workbook.getWorkbook(file); - Sheet sheet = workbook.getSheets()[0]; - for (int i = 0; i < sheet.getRows(); i++) { - Cell cell = sheet.getCell(0, i); - String content = cell.getContents(); - contentList.add(content); + List sensitiveWordList = TimingAcquisition.sensitiveWordList; + if (sensitiveWordList.size() != 0) { + return sensitiveWordList; + } else { + List contentList = new ArrayList<>(); + try { + File file = new File(configFilePath + fileName); + Workbook workbook = Workbook.getWorkbook(file); + Sheet sheet = workbook.getSheets()[0]; + for (int i = 0; i < sheet.getRows(); i++) { + Cell cell = sheet.getCell(0, i); + String content = cell.getContents(); + contentList.add(content); + } + sensitiveWordList.addAll(contentList); + } catch (Exception e) { + e.printStackTrace(); } - } catch (Exception e) { - e.printStackTrace(); + return contentList; } - return contentList; } /** diff --git a/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java b/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java index 5fb2a70..7ba9cdc 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/RequestConversionUtil.java @@ -2,21 +2,16 @@ package com.qiwuai.garden.common.utils; import com.qiwuai.garden.common.Constants; import com.qiwuai.garden.common.TimingAcquisition; -import com.qiwuai.garden.dto.GardenerDto; import com.qiwuai.garden.dto.base.CommonRequest; import com.qiwuai.garden.dto.request.CallRequest; import com.qiwuai.garden.dto.request.OperationRequest; import com.qiwuai.garden.pojo.AttributePojo; import com.qiwuai.garden.pojo.ItemPojo; -import com.qiwuai.garden.pojo.PetPojo; import com.qiwuai.garden.pojo.PlantPojo; -import com.qiwuai.garden.service.gardenerService.GardenerService; -import com.qiwuai.garden.service.gardenerService.impl.GardenerServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -32,20 +27,6 @@ public class RequestConversionUtil { OperationRequest operationRequest = new OperationRequest(); CallRequest callRequest = commonRequest.getVars(); operationRequest.setUid(commonRequest.getUid()); - //----------------------新的uid则创建用户-------------------------- - GardenerDto gardener = TimingAcquisition.gardenerMap.get(commonRequest.getUid()); - if (StringUtils.isEmpty(gardener)) { - //给新玩家分配姓名 -// List nameList = PersistenceUtil.getContentFromFile("name.xls"); -// String name = nameList.get(RandomDropUtil.getRandomNum(0, nameList.size())); - String name = "海棠仙子"; - OperationRequest operationReq = new OperationRequest(); - operationReq.setUid(commonRequest.getUid()); - operationReq.setGender(2); - operationReq.setName(name); - GardenerService gardenerService = new GardenerServiceImpl(); - gardenerService.create(operationReq); - } //---------------------存在GB_园丁姓名----------------------- String gardenerName = callRequest.getGB_园丁姓名(); if (!StringUtils.isEmpty(gardenerName)) { diff --git a/src/main/java/com/qiwuai/garden/common/utils/SpeechUtil.java b/src/main/java/com/qiwuai/garden/common/utils/SpeechUtil.java index 7ba2c12..8b0bebc 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/SpeechUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/SpeechUtil.java @@ -3,7 +3,6 @@ package com.qiwuai.garden.common.utils; import com.qiwuai.garden.common.TimingAcquisition; import java.util.List; -import java.util.Map; public class SpeechUtil { /** @@ -91,7 +90,7 @@ public class SpeechUtil { } /** - * 从任务模块话术获取话术 + * 从帮助模块话术获取话术 * @param someone * @param feedText * @return String diff --git a/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java b/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java index acb6ae6..8619895 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/TypeConvertUtil.java @@ -301,21 +301,45 @@ public class TypeConvertUtil { } /** - * 提取中文的阿拉伯数字 + * 提取文本中的阿拉伯数字 * @param param * @return Integer */ public static Integer extractNum(String param) { - int i; String regEx="[^0-9]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(param); if (!"".equals(m.replaceAll("").trim())) { - i = Integer.parseInt(m.replaceAll("").trim()); + if (StringUtils.isEmpty(extractChinese(param))) { + if (param.length() > 9) { + return Constants.REQ_NON; + } + } + return Integer.valueOf(m.replaceAll("").trim()); + } else { + return Constants.REQ_NON; + } + } + + /** + * 提取文本中的阿拉伯数字,以字符串返回 + * @param param + * @return Integer + */ + public static String getNumFromContext(String param) { + String regEx="[^0-9]"; + Pattern p = Pattern.compile(regEx); + Matcher m = p.matcher(param); + if (!"".equals(m.replaceAll("").trim())) { + if (StringUtils.isEmpty(extractChinese(param))) { + if (param.length() > 9) { + return Constants.NON_STR; + } + } + return m.replaceAll("").trim(); } else { - i = Constants.REQ_NON; + return Constants.NON_STR; } - return i; } /** @@ -344,6 +368,16 @@ public class TypeConvertUtil { } /** + * 删除中文 + * @param param + * @return Integer + */ + public static String removeChinese(String param) { + String regEx="[\u4e00-\u9fa5)]"; + return param.replaceAll(regEx, ""); + } + + /** * {"未读", "已读"}中文转成数字 * @param param * @return Integer @@ -465,4 +499,70 @@ public class TypeConvertUtil { pageInfo.setEnd(end); return pageInfo; } + + /** + * 正则匹配微信号、手机号码和qq号 + * @param context + */ + public static int checkContext(String context) { + //微信正则表达式 + String weChatPattern = "^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}+$"; + //qq正则表达式 + String qqPattern = "^[1-9][0-9]{4,10}$"; + //手机号正则表达式 + String phonePattern = "^((13[0-9])|(14[5,6,7,9])|(15[^4])|(16[5,6])|(17[0-9])|(18[0-9])|(19[1,8,9]))\\d{8}$"; + //留言内容不符合格式要求 + if (!context.contains("微信") && !context.contains("qq")&& !context.contains("QQ") && !context.contains("手机")) { + return 4; + } + //微信格式不正确 + if (context.contains("微信")) { + context = removeChinese(context); + //微信格式不正确 + if (!context.matches(weChatPattern) && !context.matches(phonePattern)) { + return 1; + } + } + //qq格式不正确 + if (context.contains("qq") || context.contains("QQ")) { + context = getNumFromContext(context); + //qq格式不正确 + if (!context.matches(qqPattern)) { + return 2; + } + } + //手机号码格式不正确 + if (context.contains("手机")) { + context = getNumFromContext(context); + //手机号码格式不正确 + if (!context.matches(phonePattern)) { + return 3; + } + } + return 0; + } + + /** + * 微信号、手机号码和qq号的文本替换 + * @param context + */ + public static String contextChange(String context) { + String result = ""; + //微信格式 + if (context.contains("微信")) { + context = removeChinese(context); + result = "微信:" + context; + } + //qq格式 + if (context.contains("qq") || context.contains("QQ")) { + context = getNumFromContext(context); + result = "QQ:" + context; + } + //手机号码格式 + if (context.contains("手机")) { + context = getNumFromContext(context); + result = "手机号码:" + context; + } + return result; + } } diff --git a/src/main/java/com/qiwuai/garden/common/utils/YamlUtil.java b/src/main/java/com/qiwuai/garden/common/utils/YamlUtil.java index 4c36289..58c565b 100644 --- a/src/main/java/com/qiwuai/garden/common/utils/YamlUtil.java +++ b/src/main/java/com/qiwuai/garden/common/utils/YamlUtil.java @@ -1,16 +1,18 @@ package com.qiwuai.garden.common.utils; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.qiwuai.garden.common.TimingAcquisition; import com.qiwuai.garden.dto.RegionIPDto; import lombok.Data; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.system.ApplicationHome; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import org.yaml.snakeyaml.Yaml; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; +import java.io.*; import java.net.URL; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -18,16 +20,13 @@ import java.util.concurrent.ConcurrentHashMap; @Component @Data public class YamlUtil { - //获取话术存放的路径 - public static String speechFilePath = YamlUtil.getValueByKey("speechFilePath"); - private static LinkedHashMap>> properties = new LinkedHashMap<>(); /** * 将话术转成map格式 * @param * @return Map>> */ - public static Map>> loadSpeechToMap(String fileName) { + public static Map>> loadSpeechToMap(String speechFilePath, String fileName) { Map>> speechMap = new HashMap<>(); try { InputStream in = new FileInputStream(speechFilePath + fileName); @@ -46,16 +45,25 @@ public class YamlUtil { */ public static String getValueByKey(String key) { String value = ""; - try { - Yaml yaml = new Yaml(); - ClassPathResource resource = new ClassPathResource("\\application.yml"); - properties = yaml.load(resource.getInputStream()); - String val = properties.get("spring").get("profiles").get("active"); - ClassPathResource resourceNext = new ClassPathResource("\\application-" + val + ".yml"); - Map map = yaml.load(resourceNext.getInputStream()); - value = String.valueOf(map.get(key)); - } catch (Exception e) { - e.printStackTrace(); + Map applicationMap = TimingAcquisition.applicationMap; + if (applicationMap.size() != 0) { + return String.valueOf(applicationMap.get(key)); + } else { + try { + Yaml yaml = new Yaml(); + ClassPathResource resource = new ClassPathResource("\\application.yml"); + properties = yaml.load(resource.getInputStream()); + String val = properties.get("spring").get("profiles").get("active"); +// ClassPathResource resourceNext = new ClassPathResource("\\application-" + val + ".yml"); +// Map map = yaml.load(resourceNext.getInputStream()); + FileInputStream fileInputStream = new FileInputStream("/home/jiaoyou/projects/secretGarden/application-" + val + ".yml"); + InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); + Map map = yaml.load(inputStreamReader); + applicationMap.putAll(map); + value = String.valueOf(map.get(key)); + } catch (Exception e) { + e.printStackTrace(); + } } return value; } diff --git a/src/main/java/com/qiwuai/garden/controller/CommonController.java b/src/main/java/com/qiwuai/garden/controller/CommonController.java index 9518d8b..6a31df0 100644 --- a/src/main/java/com/qiwuai/garden/controller/CommonController.java +++ b/src/main/java/com/qiwuai/garden/controller/CommonController.java @@ -1,7 +1,10 @@ package com.qiwuai.garden.controller; import com.qiwuai.garden.common.ProxyFactory; +import com.qiwuai.garden.common.TimingAcquisition; +import com.qiwuai.garden.common.utils.DataTrimUtil; import com.qiwuai.garden.common.utils.RequestConversionUtil; +import com.qiwuai.garden.dto.GardenerDto; import com.qiwuai.garden.dto.base.CommonRequest; import com.qiwuai.garden.dto.base.CommonResponse; import com.qiwuai.garden.dto.base.ResultResponse; @@ -31,6 +34,8 @@ import com.qiwuai.garden.service.taskService.TaskService; import com.qiwuai.garden.service.taskService.impl.TaskServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -43,46 +48,85 @@ import java.text.ParseException; @RequestMapping("/secretGarden") public class CommonController { Logger log = LoggerFactory.getLogger(CommonController.class); - //种植模块动态代理 - PlantService plantService = new PlantServiceImpl(); - PlantService plantServiceProxy = (PlantService) new ProxyFactory(plantService).getProxyInstance(); - //花圃模块动态代理 - NurseryService nurseryService = new NurseryServiceImpl(); - NurseryService nurseryServiceProxy = (NurseryService) new ProxyFactory(nurseryService).getProxyInstance(); - //园丁模块动态代理 - GardenerService gardenerService = new GardenerServiceImpl(); - GardenerService gardenerServiceProxy = (GardenerService) new ProxyFactory(gardenerService).getProxyInstance(); + + @Value("${offlineTime}") + private String offlineTime; + + //种植模块 + @Autowired + private PlantService plantService; + //花圃模块 + @Autowired + private NurseryService nurseryService; + //园丁模块 + @Autowired + private GardenerService gardenerService; //背包模块动态代理 - BackPackService backPackService = new BackPackServiceImpl(); - BackPackService backPackServiceProxy = (BackPackService) new ProxyFactory(backPackService).getProxyInstance(); + @Autowired + private BackPackService backPackService; //宠物模块动态代理 - PetService petService = new PetServiceImpl(); - PetService petServiceProxy = (PetService) new ProxyFactory(petService).getProxyInstance(); + @Autowired + private PetService petService; //市场模块动态代理 - MarketService marketService = new MarketServiceImpl(); - MarketService marketServiceProxy = (MarketService) new ProxyFactory(marketService).getProxyInstance(); + @Autowired + private MarketService marketService; //社交模块动态代理 - SocialService socialService = new SocialServiceImpl(); - SocialService socialServiceProxy = (SocialService) new ProxyFactory(socialService).getProxyInstance(); + @Autowired + private SocialService socialService; //任务模块动态代理 - TaskService taskService = new TaskServiceImpl(); - TaskService taskServiceProxy = (TaskService) new ProxyFactory(taskService).getProxyInstance(); + @Autowired + private TaskService taskService; //排行榜模块动态代理 - RankingService rankingService = new RankingServiceImpl(); - RankingService rankingServiceProxy = (RankingService) new ProxyFactory(rankingService).getProxyInstance(); + @Autowired + private RankingService rankingService; //帮助模块动态代理 - HelpService helpService = new HelpServiceImpl(); - HelpService helpServiceProxy = (HelpService) new ProxyFactory(helpService).getProxyInstance(); + @Autowired + private HelpService helpService; //建议模块动态代理 - AdviseService adviseService = new AdviseServiceImpl(); - AdviseService adviseServiceProxy = (AdviseService) new ProxyFactory(adviseService).getProxyInstance(); + @Autowired + private AdviseService adviseService; + +// //种植模块动态代理 +// PlantService plantService = new PlantServiceImpl(); +// PlantService plantServiceProxy = (PlantService) new ProxyFactory(plantService).getProxyInstance(); +// //花圃模块动态代理 +// NurseryService nurseryService = new NurseryServiceImpl(); +// NurseryService nurseryServiceProxy = (NurseryService) new ProxyFactory(nurseryService).getProxyInstance(); +// //园丁模块动态代理 +// GardenerService gardenerService = new GardenerServiceImpl(); +// GardenerService gardenerServiceProxy = (GardenerService) new ProxyFactory(gardenerService).getProxyInstance(); +// //背包模块动态代理 +// BackPackService backPackService = new BackPackServiceImpl(); +// BackPackService backPackServiceProxy = (BackPackService) new ProxyFactory(backPackService).getProxyInstance(); +// //宠物模块动态代理 +// PetService petService = new PetServiceImpl(); +// PetService petServiceProxy = (PetService) new ProxyFactory(petService).getProxyInstance(); +// //市场模块动态代理 +// MarketService marketService = new MarketServiceImpl(); +// MarketService marketServiceProxy = (MarketService) new ProxyFactory(marketService).getProxyInstance(); +// //社交模块动态代理 +// SocialService socialService = new SocialServiceImpl(); +// SocialService socialServiceProxy = (SocialService) new ProxyFactory(socialService).getProxyInstance(); +// //任务模块动态代理 +// TaskService taskService = new TaskServiceImpl(); +// TaskService taskServiceProxy = (TaskService) new ProxyFactory(taskService).getProxyInstance(); +// //排行榜模块动态代理 +// RankingService rankingService = new RankingServiceImpl(); +// RankingService rankingServiceProxy = (RankingService) new ProxyFactory(rankingService).getProxyInstance(); +// //帮助模块动态代理 +// HelpService helpService = new HelpServiceImpl(); +// HelpService helpServiceProxy = (HelpService) new ProxyFactory(helpService).getProxyInstance(); +// //建议模块动态代理 +// AdviseService adviseService = new AdviseServiceImpl(); +// AdviseService adviseServiceProxy = (AdviseService) new ProxyFactory(adviseService).getProxyInstance(); @PostMapping(value = "/call", produces = "application/json;charset=UTF-8") public CommonResponse startGame(@RequestBody CommonRequest commonRequest) throws ParseException { - log.info(commonRequest.getUid() + "当前操作的原始请求参数:" + commonRequest.getVars()); + String uid = commonRequest.getUid(); + log.info(uid + "当前操作的原始请求参数:" + commonRequest.getVars()); CommonResponse result = new CommonResponse(); //玩家没有提供uid - if (StringUtils.isEmpty(commonRequest.getUid())) { + if (StringUtils.isEmpty(uid)) { ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); log.info("未提供uid,无法创建用户"); @@ -94,12 +138,25 @@ public class CommonController { result.setData(resultVarsResponse); return result; } + //----------------------新的uid则创建用户-------------------------- + GardenerDto gardener = TimingAcquisition.gardenerMap.get(uid); + if (StringUtils.isEmpty(gardener)) { + //给新玩家分配姓名 +// List nameList = PersistenceUtil.getContentFromFile("name.xls"); +// String name = nameList.get(RandomDropUtil.getRandomNum(0, nameList.size())); + String name = "海棠仙子"; + OperationRequest operationReq = new OperationRequest(); + operationReq.setUid(commonRequest.getUid()); + operationReq.setGender(2); + operationReq.setName(name); + gardenerService.create(operationReq); + } OperationRequest operationReq = RequestConversionUtil.request2Operation(commonRequest); String operateName = commonRequest.getVars().get操作名(); - log.info(operationReq.getUid() + "开始执行操作:【" + operateName + "】, 请求参数:" + operationReq); + log.info(uid + "开始执行操作:【" + operateName + "】, 请求参数:" + operationReq); //操作名为null if (StringUtils.isEmpty(operateName)) { - log.info(operationReq.getUid() + "未提供操作名,无法操作"); + log.info(uid + "未提供操作名,无法操作"); ResultVarsResponse resultVarsResponse = new ResultVarsResponse(); ResultResponse resultResponse = new ResultResponse(); result.setCode(1); @@ -110,655 +167,658 @@ public class CommonController { result.setData(resultVarsResponse); return result; } + //登录玩家,修改在线状态 + DataTrimUtil.AdjustStatus(commonRequest.getUid(), offlineTime); + switch (operateName) { case "进入游戏": - result = gardenerServiceProxy.enterGame(operationReq); + result = gardenerService.enterGame(operationReq); break; case "创建用户": - result = gardenerServiceProxy.create(operationReq); + result = gardenerService.create(operationReq); break; case "更改园丁性别": - result = gardenerServiceProxy.changeGender(operationReq); + result = gardenerService.changeGender(operationReq); break; case "更改玩家称呼": - result = gardenerServiceProxy.changeCallName(operationReq); + result = gardenerService.changeCallName(operationReq); break; case "用户初始化": - result = gardenerServiceProxy.resetPlayer(operationReq); + result = gardenerService.resetPlayer(operationReq); break; case "种植": - result = plantServiceProxy.seedCheck(operationReq); + result = plantService.seedCheck(operationReq); break; case "确认种植": - result = plantServiceProxy.seed(operationReq); + result = plantService.seed(operationReq); break; case "取消种植": - result = plantServiceProxy.seedCancel(operationReq); + result = plantService.seedCancel(operationReq); break; case "批量种植": - result = plantServiceProxy.batchSeedCheck(operationReq); + result = plantService.batchSeedCheck(operationReq); break; case "确认批量种植": - result = plantServiceProxy.batchSeed(operationReq); + result = plantService.batchSeed(operationReq); break; case "取消批量种植": - result = plantServiceProxy.batchSeedCancel(operationReq); + result = plantService.batchSeedCancel(operationReq); break; case "收取": - result = plantServiceProxy.harvest(operationReq); + result = plantService.harvest(operationReq); break; case "铲除植物": - result = plantServiceProxy.clearPlantCheck(operationReq); + result = plantService.clearPlantCheck(operationReq); break; case "收获并铲除植物": - result = plantServiceProxy.clearAfterHarvest(operationReq); + result = plantService.clearAfterHarvest(operationReq); break; case "确认铲除植物": - result = plantServiceProxy.clearPlant(operationReq); + result = plantService.clearPlant(operationReq); break; case "取消铲除植物": - result = plantServiceProxy.clearPlantCancel(operationReq); + result = plantService.clearPlantCancel(operationReq); break; case "查询植物成熟时间指令": - result = plantServiceProxy.checkPlantMatureTime(operationReq); + result = plantService.checkPlantMatureTime(operationReq); break; case "加快植物成熟指令": - result = plantServiceProxy.speedPlantMatureTime(operationReq); + result = plantService.speedPlantMatureTime(operationReq); break; case "查看花圃数量指令": - result = nurseryServiceProxy.checkNurseryAmount(operationReq); + result = nurseryService.checkNurseryAmount(operationReq); break; case "查看花圃指令": - result = nurseryServiceProxy.checkNurseryByNum(operationReq); + result = nurseryService.checkNurseryByNum(operationReq); break; case "查看花圃状态": - result = nurseryServiceProxy.checkAllNursery(operationReq); + result = nurseryService.checkAllNursery(operationReq); break; case "查看花圃等级": - result = nurseryServiceProxy.checkNurseryLevel(operationReq); + result = nurseryService.checkNurseryLevel(operationReq); break; case "查看花圃升级类型": - result = nurseryServiceProxy.searchNurseryToType(operationReq); + result = nurseryService.searchNurseryToType(operationReq); break; case "查看花圃升级条件": - result = nurseryServiceProxy.searchUpgradeCondition(operationReq); + result = nurseryService.searchUpgradeCondition(operationReq); break; case "升级花圃": - result = nurseryServiceProxy.nurseryUpgrade(operationReq); + result = nurseryService.nurseryUpgrade(operationReq); break; case "取消升级花圃": - result = nurseryServiceProxy.nurseryUpgradeCancel(operationReq); + result = nurseryService.nurseryUpgradeCancel(operationReq); break; case "重置花圃": - result = nurseryServiceProxy.nurseryResetCheck(operationReq); + result = nurseryService.nurseryResetCheck(operationReq); break; case "确认重置花圃": - result = nurseryServiceProxy.nurseryReset(operationReq); + result = nurseryService.nurseryReset(operationReq); break; case "取消重置花圃": - result = nurseryServiceProxy.nurseryResetCancel(operationReq); + result = nurseryService.nurseryResetCancel(operationReq); break; case "开启新花圃": - result = nurseryServiceProxy.nurseryReclaimCheck(operationReq); + result = nurseryService.nurseryReclaimCheck(operationReq); break; case "确认开启新花圃": - result = nurseryServiceProxy.nurseryReclaim(operationReq); + result = nurseryService.nurseryReclaim(operationReq); break; case "取消开启新花圃": - result = nurseryServiceProxy.nurseryReclaimCancel(operationReq); + result = nurseryService.nurseryReclaimCancel(operationReq); break; case "花圃直接升级指令": - result = nurseryServiceProxy.nurseryUpgradeDirect(operationReq); + result = nurseryService.nurseryUpgradeDirect(operationReq); break; case "查看园丁等级": - result = gardenerServiceProxy.gardenerLevelCheck(operationReq); + result = gardenerService.gardenerLevelCheck(operationReq); break; case "园丁升级": - result = gardenerServiceProxy.gardenerUpgradeCheck(operationReq); + result = gardenerService.gardenerUpgradeCheck(operationReq); break; case "确认园丁升级": - result = gardenerServiceProxy.gardenerUpgrade(operationReq); + result = gardenerService.gardenerUpgrade(operationReq); break; case "取消园丁升级": - result = gardenerServiceProxy.gardenerUpgradeCancel(operationReq); + result = gardenerService.gardenerUpgradeCancel(operationReq); break; case "园丁直接升级指令": - result = gardenerServiceProxy.gardenerUpgradeDirect(operationReq); + result = gardenerService.gardenerUpgradeDirect(operationReq); break; case "使用技能": - result = gardenerServiceProxy.learnSkillCheck(operationReq); + result = gardenerService.learnSkillCheck(operationReq); break; case "确认使用技能": - result = gardenerServiceProxy.learnSkill(operationReq); + result = gardenerService.learnSkill(operationReq); break; case "取消使用技能": - result = gardenerServiceProxy.learnSkillCancel(operationReq); + result = gardenerService.learnSkillCancel(operationReq); break; case "重置园丁": - result = gardenerServiceProxy.resetSkillCheck(operationReq); + result = gardenerService.resetSkillCheck(operationReq); break; case "确认重置园丁": - result = gardenerServiceProxy.resetSkill(operationReq); + result = gardenerService.resetSkill(operationReq); break; case "取消重置园丁": - result = gardenerServiceProxy.resetSkillCancel(operationReq); + result = gardenerService.resetSkillCancel(operationReq); break; case "查看技能指令": - result = gardenerServiceProxy.skillCheck(operationReq); + result = gardenerService.skillCheck(operationReq); break; case "查看技能详情指令": - result = gardenerServiceProxy.skillInfoCheck(operationReq); + result = gardenerService.skillInfoCheck(operationReq); break; // case "查看下一页技能详情指令": -// result = gardenerServiceProxy.skillInfoNextCheck(operationReq); +// result = gardenerService.skillInfoNextCheck(operationReq); // break; // case "查看上一页技能详情指令": -// result = gardenerServiceProxy.skillInfoLastCheck(operationReq); +// result = gardenerService.skillInfoLastCheck(operationReq); // break; case "更改园丁姓名": - result = gardenerServiceProxy.renameCheck(operationReq); + result = gardenerService.renameCheck(operationReq); break; case "确认更改园丁姓名": - result = gardenerServiceProxy.rename(operationReq); + result = gardenerService.rename(operationReq); break; case "取消更改园丁姓名": - result = gardenerServiceProxy.renameCancel(operationReq); + result = gardenerService.renameCancel(operationReq); break; case "打开背包": - result = backPackServiceProxy.viewBackPack(operationReq); + result = backPackService.viewBackPack(operationReq); break; case "分类检索": - result = backPackServiceProxy.viewBackPackItem(operationReq); + result = backPackService.viewBackPackItem(operationReq); break; case "货币检索": - result = backPackServiceProxy.viewMoney(operationReq); + result = backPackService.viewMoney(operationReq); break; case "获取详情": - result = backPackServiceProxy.searchItemInfo(operationReq); + result = backPackService.searchItemInfo(operationReq); break; case "发放奖励": - result = backPackServiceProxy.taskAward(operationReq); + result = backPackService.taskAward(operationReq); break; case "查看宠物指令": - result = petServiceProxy.petView(operationReq); + result = petService.petView(operationReq); break; case "宠物移至花圃指令": - result = petServiceProxy.petMoveToNursery(operationReq); + result = petService.petMoveToNursery(operationReq); break; case "花圃宠物移至宠物栏指令": - result = petServiceProxy.petMoveToField(operationReq); + result = petService.petMoveToField(operationReq); break; case "花圃宠物移动指令": - result = petServiceProxy.nurseryPetMove(operationReq); + result = petService.nurseryPetMove(operationReq); break; case "宠物删除指令": - result = petServiceProxy.petDeleteCheck(operationReq); + result = petService.petDeleteCheck(operationReq); break; case "确认宠物删除指令": - result = petServiceProxy.petDelete(operationReq); + result = petService.petDelete(operationReq); break; case "取消宠物删除指令": - result = petServiceProxy.petDeleteCancel(operationReq); + result = petService.petDeleteCancel(operationReq); break; case "宠物换位指令": - result = petServiceProxy.petSetPosition(operationReq); + result = petService.petSetPosition(operationReq); break; case "宠物位置调换指令": - result = petServiceProxy.petSwitch(operationReq); + result = petService.petSwitch(operationReq); break; case "查询宠物栏状态指令": - result = petServiceProxy.petCheck(operationReq); + result = petService.petCheck(operationReq); break; case "查询花圃宠物数量指令": - result = petServiceProxy.nurseryPetNumCheck(operationReq); + result = petService.nurseryPetNumCheck(operationReq); break; case "总览查询指令": - result = petServiceProxy.petOverview(operationReq); + result = petService.petOverview(operationReq); break; case "查看花圃宠物指令": - result = petServiceProxy.nurseryPetCheck(operationReq); + result = petService.nurseryPetCheck(operationReq); break; case "确认查看花圃宠物指令": - result = petServiceProxy.nurseryPetCheckSure(operationReq); + result = petService.nurseryPetCheckSure(operationReq); break; case "取消查看花圃宠物指令": - result = petServiceProxy.nurseryPetCheckCancel(operationReq); + result = petService.nurseryPetCheckCancel(operationReq); break; case "花圃宠物调换指令": - result = petServiceProxy.nurseryPetSwitch(operationReq); + result = petService.nurseryPetSwitch(operationReq); break; case "发放花圃宠物指令": - result = petServiceProxy.addNurseryPet(operationReq); + result = petService.addNurseryPet(operationReq); break; case "查看新来宠物": - result = petServiceProxy.checkNewPets(operationReq); + result = petService.checkNewPets(operationReq); break; case "升级宠物": - result = petServiceProxy.updatePet(operationReq); + result = petService.updatePet(operationReq); break; case "购买指令": - result = marketServiceProxy.buyCheck(operationReq); + result = marketService.buyCheck(operationReq); break; case "确认购买指令": - result = marketServiceProxy.buy(operationReq); + result = marketService.buy(operationReq); break; case "取消购买指令": - result = marketServiceProxy.buyCancel(operationReq); + result = marketService.buyCancel(operationReq); break; case "出售指令": - result = marketServiceProxy.sellCheck(operationReq); + result = marketService.sellCheck(operationReq); break; case "确认出售指令": - result = marketServiceProxy.sell(operationReq); + result = marketService.sell(operationReq); break; case "取消出售指令": - result = marketServiceProxy.sellCancel(operationReq); + result = marketService.sellCancel(operationReq); break; case "出售宠物指令": - result = marketServiceProxy.sellPetCheck(operationReq); + result = marketService.sellPetCheck(operationReq); break; case "统一出售指令": - result = marketServiceProxy.sellAllCheck(operationReq); + result = marketService.sellAllCheck(operationReq); break; case "确认统一出售指令": - result = marketServiceProxy.sellAll(operationReq); + result = marketService.sellAll(operationReq); break; case "取消统一出售指令": - result = marketServiceProxy.sellAllCancel(operationReq); + result = marketService.sellAllCancel(operationReq); break; case "确认取消指令": - result = marketServiceProxy.cancel(operationReq); + result = marketService.cancel(operationReq); break; case "打开商店指令": - result = marketServiceProxy.openShop(operationReq); + result = marketService.openShop(operationReq); break; case "查询商品指令": - result = marketServiceProxy.goodsCheck(operationReq); + result = marketService.goodsCheck(operationReq); break; case "退出商店指令": - result = marketServiceProxy.quitShop(operationReq); + result = marketService.quitShop(operationReq); break; case "拜访陌生人": case "拜访好友": - result = socialServiceProxy.visitStrangerCheck(operationReq); //拜访好友的方法跟拜访陌生人一样 + result = socialService.visitStrangerCheck(operationReq); //拜访好友的方法跟拜访陌生人一样 break; case "确定拜访": - result = socialServiceProxy.visitStranger(operationReq); + result = socialService.visitStranger(operationReq); break; case "取消拜访": - result = socialServiceProxy.visitStrangerCancel(operationReq); + result = socialService.visitStrangerCancel(operationReq); break; case "随机拜访陌生人": - result = socialServiceProxy.visitStrangerRandom(operationReq); + result = socialService.visitStrangerRandom(operationReq); break; case "上一个玩家": - result = socialServiceProxy.visitLastOne(operationReq); + result = socialService.visitLastOne(operationReq); break; case "下一个玩家": - result = socialServiceProxy.visitNextOne(operationReq); + result = socialService.visitNextOne(operationReq); break; case "添加好友": - result = socialServiceProxy.addFriendAsk(operationReq); + result = socialService.addFriendAsk(operationReq); break; case "查看好友申请": - result = socialServiceProxy.addFriendCheck(operationReq); + result = socialService.addFriendCheck(operationReq); break; case "查看指定好友申请": - result = socialServiceProxy.addFriendCheckByName(operationReq); + result = socialService.addFriendCheckByName(operationReq); break; case "接受好友申请": - result = socialServiceProxy.addFriendRequestAgree(operationReq); + result = socialService.addFriendRequestAgree(operationReq); break; case "拒绝好友申请": - result = socialServiceProxy.addFriendRequestReject(operationReq); + result = socialService.addFriendRequestReject(operationReq); break; case "拜访特殊好友": - result = socialServiceProxy.visitFriendSpecialCheck(operationReq); + result = socialService.visitFriendSpecialCheck(operationReq); break; case "随机拜访好友": - result = socialServiceProxy.visitFriendRandomCheck(operationReq); + result = socialService.visitFriendRandomCheck(operationReq); break; case "删除好友": - result = socialServiceProxy.deleteFriendCheck(operationReq); + result = socialService.deleteFriendCheck(operationReq); break; case "确定删除": - result = socialServiceProxy.deleteFriend(operationReq); + result = socialService.deleteFriend(operationReq); break; case "取消删除": - result = socialServiceProxy.deleteFriendCancel(operationReq); + result = socialService.deleteFriendCancel(operationReq); break; case "查看园地": - result = socialServiceProxy.checkGarden(operationReq); + result = socialService.checkGarden(operationReq); break; case "设置收益比例": - result = socialServiceProxy.setEarnRateCheck(operationReq); + result = socialService.setEarnRateCheck(operationReq); break; case "确定设置收益比例": - result = socialServiceProxy.setEarnRate(operationReq); + result = socialService.setEarnRate(operationReq); break; case "取消设置收益比例": - result = socialServiceProxy.setEarnRateCancel(operationReq); + result = socialService.setEarnRateCancel(operationReq); break; case "偷菜": - result = socialServiceProxy.stealOther(operationReq); + result = socialService.stealOther(operationReq); break; case "随机偷菜": - result = socialServiceProxy.stealOtherRandom(operationReq); + result = socialService.stealOtherRandom(operationReq); break; case "帮助好友": - result = socialServiceProxy.helpFriend(operationReq); + result = socialService.helpFriend(operationReq); break; case "查询本人地址": - result = socialServiceProxy.checkLocationSelf(operationReq); + result = socialService.checkLocationSelf(operationReq); break; case "随机获取玩家地址": - result = socialServiceProxy.getRandomAddress(operationReq); + result = socialService.getRandomAddress(operationReq); break; case "查看简报": - result = socialServiceProxy.checkReport(operationReq); + result = socialService.checkReport(operationReq); break; case "查看帮助简报": - result = socialServiceProxy.checkHelpReport(operationReq); + result = socialService.checkHelpReport(operationReq); break; case "查看偷菜简报": - result = socialServiceProxy.checkStealReport(operationReq); + result = socialService.checkStealReport(operationReq); break; case "查看战斗详情": - result = socialServiceProxy.checkFightDetail(operationReq); + result = socialService.checkFightDetail(operationReq); break; case "获取战斗详情": - result = socialServiceProxy.getFightDetail(operationReq); + result = socialService.getFightDetail(operationReq); break; case "查看战斗轮次": - result = socialServiceProxy.checkFightRound(operationReq); + result = socialService.checkFightRound(operationReq); break; case "获取战斗轮次": - result = socialServiceProxy.getFightRound(operationReq); + result = socialService.getFightRound(operationReq); break; case "删除简报": - result = socialServiceProxy.deleteReportCheck(operationReq); + result = socialService.deleteReportCheck(operationReq); break; case "删除帮助简报": - result = socialServiceProxy.deleteHelpReportCheck(operationReq); + result = socialService.deleteHelpReportCheck(operationReq); break; case "删除偷菜简报": - result = socialServiceProxy.deleteStealReportCheck(operationReq); + result = socialService.deleteStealReportCheck(operationReq); break; case "确认删除简报": - result = socialServiceProxy.deleteReport(operationReq); + result = socialService.deleteReport(operationReq); break; case "取消删除简报": - result = socialServiceProxy.deleteReportCancel(operationReq); + result = socialService.deleteReportCancel(operationReq); break; case "查看提醒消息": - result = socialServiceProxy.checkNotice(operationReq); + result = socialService.checkNotice(operationReq); break; case "开始留言": - result = socialServiceProxy.leaveMessageCheck(operationReq); + result = socialService.leaveMessageCheck(operationReq); break; case "确定该留言": - result = socialServiceProxy.leaveMessage(operationReq); + result = socialService.leaveMessage(operationReq); break; case "取消该留言": - result = socialServiceProxy.leaveMessageCancel(operationReq); + result = socialService.leaveMessageCancel(operationReq); break; case "检查留言": - result = socialServiceProxy.checkMessage(operationReq); + result = socialService.checkMessage(operationReq); break; case "查看留言": - result = socialServiceProxy.readMessage(operationReq); + result = socialService.readMessage(operationReq); break; case "重播留言": - result = socialServiceProxy.repeatMessage(operationReq); + result = socialService.repeatMessage(operationReq); break; case "查看下一条留言": - result = socialServiceProxy.readNextMessage(operationReq); + result = socialService.readNextMessage(operationReq); break; case "查询好友数量": - result = socialServiceProxy.checkFriendNum(operationReq); + result = socialService.checkFriendNum(operationReq); break; case "查询在线好友数量": - result = socialServiceProxy.checkOnlineFriendNum(operationReq); + result = socialService.checkOnlineFriendNum(operationReq); break; case "查询好友": - result = socialServiceProxy.checkFriendInfo(operationReq); + result = socialService.checkFriendInfo(operationReq); break; case "离线筛选好友": - result = socialServiceProxy.checkOfflineFriend(operationReq); + result = socialService.checkOfflineFriend(operationReq); break; case "返回自家花园": - result = socialServiceProxy.backHome(operationReq); + result = socialService.backHome(operationReq); break; case "查询他人花圃数量": - result = socialServiceProxy.checkNurseryAmountSide(operationReq); + result = socialService.checkNurseryAmountSide(operationReq); break; case "查询他人指定花圃宠物": - result = socialServiceProxy.nurseryPetSideCheck(operationReq); + result = socialService.nurseryPetSideCheck(operationReq); break; case "查询任务": - result = taskServiceProxy.checkTask(operationReq); + result = taskService.checkTask(operationReq); break; case "查看排行榜": - result = rankingServiceProxy.checkRankingList(operationReq); + result = rankingService.checkRankingList(operationReq); break; case "查看本人榜单名次": - result = rankingServiceProxy.checkSelfRankingList(operationReq); + result = rankingService.checkSelfRankingList(operationReq); break; case "查看玩家榜单名次": - result = rankingServiceProxy.checkPlayerRankingList(operationReq); + result = rankingService.checkPlayerRankingList(operationReq); break; case "拜访榜单玩家": - result = rankingServiceProxy.visitRankingPlayer(operationReq); + result = rankingService.visitRankingPlayer(operationReq); break; case "打开帮助菜单": - result = helpServiceProxy.openHelpMenu(operationReq); + result = helpService.openHelpMenu(operationReq); break; case "帮助-花圃类型": - result = helpServiceProxy.nurseryTypeCheck(operationReq); + result = helpService.nurseryTypeCheck(operationReq); break; case "帮助-花圃升级路线": - result = helpServiceProxy.nurseryTypeGetCheck(operationReq); + result = helpService.nurseryTypeGetCheck(operationReq); break; case "帮助-花圃详情": - result = helpServiceProxy.nurseryTypeInfoCheck(operationReq); + result = helpService.nurseryTypeInfoCheck(operationReq); break; case "帮助-花圃等级上限": - result = helpServiceProxy.nurseryLevelMaxCheck(operationReq); + result = helpService.nurseryLevelMaxCheck(operationReq); break; case "帮助-升级花圃": - result = helpServiceProxy.nurseryLevelUpCheck(operationReq); + result = helpService.nurseryLevelUpCheck(operationReq); break; case "帮助-花圃重置": - result = helpServiceProxy.nurseryLevelResetCheck(operationReq); + result = helpService.nurseryLevelResetCheck(operationReq); break; case "帮助-花圃数量": - result = helpServiceProxy.nurseryNumCheck(operationReq); + result = helpService.nurseryNumCheck(operationReq); break; case "帮助-开启花圃": - result = helpServiceProxy.nurseryReclaimRuleCheck(operationReq); + result = helpService.nurseryReclaimRuleCheck(operationReq); break; case "帮助-花圃宠物": - result = helpServiceProxy.nurseryPetRuleCheck(operationReq); + result = helpService.nurseryPetRuleCheck(operationReq); break; case "帮助-花圃宠物数量": - result = helpServiceProxy.nurseryPetNumRuleCheck(operationReq); + result = helpService.nurseryPetNumRuleCheck(operationReq); break; case "帮助-花圃无法升级": - result = helpServiceProxy.nurseryUpgradeFailReasonCheck(operationReq); + result = helpService.nurseryUpgradeFailReasonCheck(operationReq); break; case "帮助-花圃无法开启": - result = helpServiceProxy.nurseryReclaimFailReasonCheck(operationReq); + result = helpService.nurseryReclaimFailReasonCheck(operationReq); break; case "帮助-花圃宠物无法放置": - result = helpServiceProxy.nurseryPetFailReasonCheck(operationReq); + result = helpService.nurseryPetFailReasonCheck(operationReq); break; case "帮助-如何种植": - result = helpServiceProxy.PlantingRuleCheck(operationReq); + result = helpService.PlantingRuleCheck(operationReq); break; case "帮助-生长阶段": - result = helpServiceProxy.PlantPeriodRuleCheck(operationReq); + result = helpService.PlantPeriodRuleCheck(operationReq); break; case "帮助-收取果实": - result = helpServiceProxy.PlantHarvestRuleCheck(operationReq); + result = helpService.PlantHarvestRuleCheck(operationReq); break; case "帮助-植物成熟时间": - result = helpServiceProxy.PlantMatureTimeRuleCheck(operationReq); + result = helpService.PlantMatureTimeRuleCheck(operationReq); break; case "帮助-铲除植物": - result = helpServiceProxy.PlantClearRuleCheck(operationReq); + result = helpService.PlantClearRuleCheck(operationReq); break; case "帮助-植物详情": - result = helpServiceProxy.PlantInfoRuleCheck(operationReq); + result = helpService.PlantInfoRuleCheck(operationReq); break; case "帮助-种植条件": - result = helpServiceProxy.PlantConditionCheck(operationReq); + result = helpService.PlantConditionCheck(operationReq); break; case "帮助-植物对应宠物": - result = helpServiceProxy.PlantAttractPetCheck(operationReq); + result = helpService.PlantAttractPetCheck(operationReq); break; case "帮助-不能种植原因": - result = helpServiceProxy.PlantingFailCheck(operationReq); + result = helpService.PlantingFailCheck(operationReq); break; case "帮助-不能成熟原因": - result = helpServiceProxy.PlantMatureFailCheck(operationReq); + result = helpService.PlantMatureFailCheck(operationReq); break; case "帮助-伴生植物": - result = helpServiceProxy.nearPlanRuleCheck(operationReq); + result = helpService.nearPlanRuleCheck(operationReq); break; case "帮助-伴生宠物": - result = helpServiceProxy.nearPetRuleCheck(operationReq); + result = helpService.nearPetRuleCheck(operationReq); break; case "帮助-园丁等级": - result = helpServiceProxy.gardenerLevelExplainCheck(operationReq); + result = helpService.gardenerLevelExplainCheck(operationReq); break; case "帮助-园丁升级": - result = helpServiceProxy.gardenerUpgradeExplainCheck(operationReq); + result = helpService.gardenerUpgradeExplainCheck(operationReq); break; case "帮助-园丁升级任务": - result = helpServiceProxy.gardenerUpgradeTaskCheck(operationReq); + result = helpService.gardenerUpgradeTaskCheck(operationReq); break; case "帮助-园丁升级消耗": - result = helpServiceProxy.gardenerUpgradeCostCheck(operationReq); + result = helpService.gardenerUpgradeCostCheck(operationReq); break; case "帮助-园丁功能": - result = helpServiceProxy.gardenerLevelAbilityCheck(operationReq); + result = helpService.gardenerLevelAbilityCheck(operationReq); break; case "查询园丁技能说明": - result = helpServiceProxy.gardenerSkillRuleCheck(operationReq); + result = helpService.gardenerSkillRuleCheck(operationReq); break; case "查询园丁技能重置规则": - result = helpServiceProxy.gardenerSkillResetRuleCheck(operationReq); + result = helpService.gardenerSkillResetRuleCheck(operationReq); break; case "查询园丁技能详情": - result = helpServiceProxy.gardenerLevelSkillRuleCheck(operationReq); + result = helpService.gardenerLevelSkillRuleCheck(operationReq); break; case "查询园丁技能获得方式": - result = helpServiceProxy.gardenerSkilGetlRuleCheck(operationReq); + result = helpService.gardenerSkilGetlRuleCheck(operationReq); break; case "查询背包查看方式说明": - result = helpServiceProxy.backPackRuleCheck(operationReq); + result = helpService.backPackRuleCheck(operationReq); break; case "查询园丁改名规则": - result = helpServiceProxy.gardenerRenameRuleCheck(operationReq); + result = helpService.gardenerRenameRuleCheck(operationReq); break; case "查询宠物获取方式": - result = helpServiceProxy.petGetRuleCheck(operationReq); + result = helpService.petGetRuleCheck(operationReq); break; case "查询宠物获取方式说明": - result = helpServiceProxy.petGetByNameRuleCheck(operationReq); + result = helpService.petGetByNameRuleCheck(operationReq); break; case "查询宠物说明": - result = helpServiceProxy.petExplainCheck(operationReq); + result = helpService.petExplainCheck(operationReq); break; case "查询宠物战斗规则": - result = helpServiceProxy.petFightRuleCheck(operationReq); + result = helpService.petFightRuleCheck(operationReq); break; case "查询宠物属性说明": - result = helpServiceProxy.petAttributeExplainCheck(operationReq); + result = helpService.petAttributeExplainCheck(operationReq); break; case "查询宠物属性克制": - result = helpServiceProxy.petAttributeRestrainCheck(operationReq); + result = helpService.petAttributeRestrainCheck(operationReq); break; case "查询宠物稀有度说明": - result = helpServiceProxy.petRarityCheck(operationReq); + result = helpService.petRarityCheck(operationReq); break; case "查询宠物资料": - result = helpServiceProxy.petInfoCheck(operationReq); + result = helpService.petInfoCheck(operationReq); break; case "查询宠物维护品": - result = helpServiceProxy.petCostCheck(operationReq); + result = helpService.petCostCheck(operationReq); break; case "查询拜访陌生人规则": - result = helpServiceProxy.visitStrangerRuleCheck(operationReq); + result = helpService.visitStrangerRuleCheck(operationReq); break; case "查询偷菜规则": - result = helpServiceProxy.stealStrangerRuleCheck(operationReq); + result = helpService.stealStrangerRuleCheck(operationReq); break; case "查询偷菜简报规则": - result = helpServiceProxy.stealReportRuleCheck(operationReq); + result = helpService.stealReportRuleCheck(operationReq); break; case "查询拜访好友规则": - result = helpServiceProxy.visitFriendRuleCheck(operationReq); + result = helpService.visitFriendRuleCheck(operationReq); break; case "查询好友申请规则": - result = helpServiceProxy.addFriendRuleCheck(operationReq); + result = helpService.addFriendRuleCheck(operationReq); break; case "查询好友帮助规则": - result = helpServiceProxy.helpFriendRuleCheck(operationReq); + result = helpService.helpFriendRuleCheck(operationReq); break; case "查询好友帮助报酬规则": - result = helpServiceProxy.helpFriendAwardRuleCheck(operationReq); + result = helpService.helpFriendAwardRuleCheck(operationReq); break; case "查询帮助简报规则": - result = helpServiceProxy.helpReportRuleCheck(operationReq); + result = helpService.helpReportRuleCheck(operationReq); break; case "查询购买物品规则": - result = helpServiceProxy.buyGoodsRuleCheck(operationReq); + result = helpService.buyGoodsRuleCheck(operationReq); break; case "查询出售物品规则": - result = helpServiceProxy.sellItemsRuleCheck(operationReq); + result = helpService.sellItemsRuleCheck(operationReq); break; case "查询日常任务规则": - result = helpServiceProxy.dailyTaskRuleCheck(operationReq); + result = helpService.dailyTaskRuleCheck(operationReq); break; case "查询排行榜规则": - result = helpServiceProxy.rankingListRuleCheck(operationReq); + result = helpService.rankingListRuleCheck(operationReq); break; case "查询排行榜操作规则": - result = helpServiceProxy.rankingListRuleLookCheck(operationReq); + result = helpService.rankingListRuleLookCheck(operationReq); break; case "重开引导指令": - result = helpServiceProxy.backgroundStoryCheck(operationReq); + result = helpService.backgroundStoryCheck(operationReq); break; case "查询货币说明": - result = helpServiceProxy.moneyExplainCheck(operationReq); + result = helpService.moneyExplainCheck(operationReq); break; case "询问建议": - result = adviseServiceProxy.adviseWithout(operationReq); + result = adviseService.adviseWithout(operationReq); break; case "询问种植建议": - result = adviseServiceProxy.adviseByPlant(operationReq); + result = adviseService.adviseByPlant(operationReq); break; case "询问宠物建议": - result = adviseServiceProxy.adviseByPet(operationReq); + result = adviseService.adviseByPet(operationReq); break; case "询问物品建议": - result = adviseServiceProxy.adviseByItem(operationReq); + result = adviseService.adviseByItem(operationReq); break; case "询问花圃建议": - result = adviseServiceProxy.adviseByNursery(operationReq); + result = adviseService.adviseByNursery(operationReq); break; case "询问货币建议": - result = adviseServiceProxy.adviseByMoney(operationReq); + result = adviseService.adviseByMoney(operationReq); break; case "同意建议": - result = adviseServiceProxy.adviseAgree(operationReq); + result = adviseService.adviseAgree(operationReq); break; case "拒绝建议": - result = adviseServiceProxy.adviseRefuse(operationReq); + result = adviseService.adviseRefuse(operationReq); break; } log.info(operationReq.getUid() + "已完成操作:【" + commonRequest.getVars().get操作名() + "】"); - return result; + return DataTrimUtil.AdjustParams(uid, result, operationReq); } } diff --git a/src/main/java/com/qiwuai/garden/service/adviseService/impl/AdviseServiceImpl.java b/src/main/java/com/qiwuai/garden/service/adviseService/impl/AdviseServiceImpl.java index 6f8d766..bda1f72 100644 --- a/src/main/java/com/qiwuai/garden/service/adviseService/impl/AdviseServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/adviseService/impl/AdviseServiceImpl.java @@ -21,6 +21,7 @@ import com.qiwuai.garden.service.plantService.impl.PlantServiceImpl; import com.qiwuai.garden.service.socialService.impl.SocialServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -35,7 +36,8 @@ import java.util.stream.Collectors; public class AdviseServiceImpl implements AdviseService { Logger log = LoggerFactory.getLogger(AdviseServiceImpl.class); //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; GardenerServiceImpl gardenerService = (GardenerServiceImpl) GetBeanUtil.getBean("gardenerServiceImpl"); diff --git a/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java b/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java index 5402519..b89aeb0 100644 --- a/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/backPackService/impl/BackPackServiceImpl.java @@ -18,6 +18,7 @@ import com.qiwuai.garden.pojo.*; import com.qiwuai.garden.service.backPackService.BackPackService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; diff --git a/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java b/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java index e5cd0ef..b3da70b 100644 --- a/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/gardenerService/impl/GardenerServiceImpl.java @@ -21,6 +21,7 @@ import com.qiwuai.garden.service.gardenerService.GardenerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -39,10 +40,14 @@ import java.util.stream.Stream; public class GardenerServiceImpl implements GardenerService { private Logger log = LoggerFactory.getLogger(GardenerServiceImpl.class); + //从yml配置文件中取出对话过期时间 + @Value("${expireTime}") + private String expireTime; + @Value("${configFilePath}") + private String configFilePath; + @Autowired private GardenerMapper gardenerMapper; - //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); @Override public CommonResponse enterGame(OperationRequest operationReq) throws ParseException { @@ -175,7 +180,7 @@ public class GardenerServiceImpl implements GardenerService { e.printStackTrace(); } //--------------生成新的玩家地址---------------- - String location = TimingAcquisition.generateAddress(hostAddress); + String location = TimingAcquisition.generateAddress(configFilePath, hostAddress); region = TypeConvertUtil.extractChinese(location); String num = location.replace(region, ""); gardenDto.setZone(region); diff --git a/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java b/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java index d48c70c..1f191f1 100644 --- a/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/marketService/impl/MarketServiceImpl.java @@ -16,6 +16,7 @@ import com.qiwuai.garden.service.marketService.MarketService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -31,7 +32,8 @@ public class MarketServiceImpl implements MarketService { Logger log = LoggerFactory.getLogger(MarketServiceImpl.class); //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; @Override public CommonResponse buyCheck(OperationRequest operationReq) { @@ -217,14 +219,29 @@ public class MarketServiceImpl implements MarketService { commonResponse.setData(resultVarsResponse); return commonResponse; } + //商品总价 + int price = itemPrice.multiply(new BigDecimal(number)).intValue(); + if (price < 0) { + log.info(uid + "的货币不足"); + //获取对应话术 + String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "buy_fail_money"); + text += SpeechUtil.getMarketSpeech(gender, "buy_fail_money"); + text = SpeechUtil.speechReplaceNum(text, callName.getName(), callName.getSubName()); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(400107); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("购买物品回复3"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //保存玩家这轮的请求信息,itemId和数量均保存,用于下一步的确认购买操作 operationReq.setItemId(itemId); operationReq.setItemTypeId(itemConfig.getItemTypeId()); operationReq.setNumber(number); operationReq.setOperationLabel(Constants.BUY_GOODS); CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); - //商品总价 - int price = itemPrice.multiply(new BigDecimal(number)).intValue(); //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "buy_check_success"); text = SpeechUtil.speechReplaceNum(text, number.toString(), goodsName, String.valueOf(price), moneyConfig.getName()); @@ -529,7 +546,7 @@ public class MarketServiceImpl implements MarketService { commonResponse.setData(resultVarsResponse); return commonResponse; } - if (item.getItemNum() == 0) { + if (item.getItemNum() <= 0) { log.info(uid + "玩家背包还没有该物品"); //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_check_fail_none"); @@ -604,6 +621,26 @@ public class MarketServiceImpl implements MarketService { return commonResponse; } int price = number * itemConfig.getPrice(); + if (price < 0) { + log.info(uid + "玩家出售物品数量大于背包有的数量"); + //获取对应话术 + String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_check_fail_num"); + text = SpeechUtil.speechReplaceNum(text, itemConfig.getName()); + //保存玩家这轮的请求信息,用于下一步的操作 + operationReq.setItemId(itemId); + operationReq.setItemTypeId(itemTypeId); + operationReq.setNumber(item.getItemNum()); //保存最大数量,提供给下一步操作 + operationReq.setOperationLabel(Constants.SELL_ITEMS); + CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(400216); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("出售物品回复1"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //获取对应话术 String text = SpeechUtil.getMarketSpeech(Constants.SPEECH_ASIDE, "sell_check_success"); text = SpeechUtil.speechReplaceNum(text, number.toString(), itemConfig.getName(), String.valueOf(price), money.getName()); diff --git a/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java b/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java index b79f226..ef9f091 100644 --- a/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/nurseryService/impl/NurseryServiceImpl.java @@ -17,6 +17,7 @@ import com.qiwuai.garden.service.nurseryService.NurseryService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -31,7 +32,8 @@ public class NurseryServiceImpl implements NurseryService { @Autowired private NurseryMapper nurseryMapper; //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; @Override public List findAll() { diff --git a/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java b/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java index 09a7139..7296b38 100644 --- a/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/petService/impl/PetServiceImpl.java @@ -18,6 +18,7 @@ import com.qiwuai.garden.service.petService.PetService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -30,7 +31,8 @@ public class PetServiceImpl implements PetService { private Logger log = LoggerFactory.getLogger(PetServiceImpl.class); //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; @Override public CommonResponse petView(OperationRequest operationReq) { diff --git a/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java b/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java index cf25c31..65a3b7c 100644 --- a/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/plantService/impl/PlantServiceImpl.java @@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -43,7 +44,8 @@ public class PlantServiceImpl implements PlantService { private AttributeMapper plantAttributeMapper; //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; public List plantSearch() { List plantList = plantMapper.searchAll(); diff --git a/src/main/java/com/qiwuai/garden/service/rankingService/impl/RankingServiceImpl.java b/src/main/java/com/qiwuai/garden/service/rankingService/impl/RankingServiceImpl.java index 156bd42..2998f52 100644 --- a/src/main/java/com/qiwuai/garden/service/rankingService/impl/RankingServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/rankingService/impl/RankingServiceImpl.java @@ -17,6 +17,7 @@ import com.qiwuai.garden.pojo.ItemPojo; import com.qiwuai.garden.service.rankingService.RankingService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -29,7 +30,8 @@ import java.util.stream.Collectors; public class RankingServiceImpl implements RankingService { Logger log = LoggerFactory.getLogger(RankingServiceImpl.class); //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; @Override public CommonResponse checkRankingList(OperationRequest operationReq) { @@ -374,6 +376,18 @@ public class RankingServiceImpl implements RankingService { int fightRanking = RankingUtil.getRankingByUid(Constants.FIGHT_RANKING, place, uid); //友情榜名次 int friendshipRanking = RankingUtil.getRankingByUid(Constants.FRIENDSHIP_RANKING, place, uid); + //今日新增玩家还没有进行排行 + if (moneyRanking == -1) { + //获取对应话术 + String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_self_no_ranking"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(700209); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //玩家未提供了榜单和地区,即查看世界排名 if (StringUtils.isEmpty(rankingName) && StringUtils.isEmpty(place)) { //获取对应话术 @@ -546,6 +560,18 @@ public class RankingServiceImpl implements RankingService { int fightRanking = RankingUtil.getRankingByUid(Constants.FIGHT_RANKING, place, uidSide); //友情榜名次 int friendshipRanking = RankingUtil.getRankingByUid(Constants.FRIENDSHIP_RANKING, place, uidSide); + //今日新增玩家还没有进行排行 + if (moneyRanking == -1) { + //获取对应话术 + String text = SpeechUtil.getRankingSpeech(Constants.SPEECH_ASIDE, "check_player_no_ranking"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(700311); + resultResponse.set反馈文本(text); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } //玩家未提供了榜单和地区,即查看世界排名 if (StringUtils.isEmpty(rankingName) && StringUtils.isEmpty(place)) { //获取对应话术 diff --git a/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java b/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java index 73b36b3..6fa4863 100644 --- a/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/socialService/impl/SocialServiceImpl.java @@ -18,6 +18,7 @@ import com.qiwuai.garden.service.taskService.impl.TaskServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -32,7 +33,8 @@ import java.util.stream.Stream; public class SocialServiceImpl implements SocialService { Logger log = LoggerFactory.getLogger(SocialServiceImpl.class); //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; @Autowired private TaskServiceImpl taskServiceImpl; @@ -6009,7 +6011,7 @@ public class SocialServiceImpl implements SocialService { //留言内容为空,提示玩家输入留言内容 if (StringUtils.isEmpty(message)) { //获取对应话术 - String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_check"); + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_check_context"); commonResponse.setCode(1); commonResponse.setMsg("成功"); resultResponse.set反馈ID(501101); @@ -6019,28 +6021,76 @@ public class SocialServiceImpl implements SocialService { commonResponse.setData(resultVarsResponse); return commonResponse; } - //留言内容包含敏感词汇,判定失败 - List sensitiveWordList = PersistenceUtil.getContentFromFile("sensitiveWords.xls"); - for (String sensitive : sensitiveWordList) { - if (message.contains(sensitive)) { - log.info(uid + "的留言内容包含敏感词汇:" + sensitive); - //保存玩家这轮的请求信息,用于下一步操作 - operationReq.setAddress(address); - operationReq.setMessage(null); - operationReq.setOperationLabel(Constants.LEAVE_MESSAGE); - CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); - //获取对应话术 - String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_sensitive_words"); - commonResponse.setCode(1); - commonResponse.setMsg("成功"); - resultResponse.set反馈ID(501105); - resultResponse.set反馈文本(text); - resultResponse.set后台附加返回("请说明留言内容"); - resultVarsResponse.setVars(resultResponse); - commonResponse.setData(resultVarsResponse); - return commonResponse; - } + //当前留言只允许留qq、微信和电话 + int result = TypeConvertUtil.checkContext(message); + //留言内容格式不对 + if (result == 4) { + String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_check_context"); + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(501112); + resultResponse.set反馈文本(text); + resultResponse.set后台附加返回("请说明留言内容"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + //微信格式不对 + if (result == 1) { + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(501113); + resultResponse.set反馈文本("【旁白@正常】微信号格式不对哦。"); + resultResponse.set后台附加返回("请说明留言内容"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; } + //qq格式不对 + if (result == 2) { + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(501114); + resultResponse.set反馈文本("【旁白@正常】QQ号格式不对哦。"); + resultResponse.set后台附加返回("请说明留言内容"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + //手机号码格式不对 + if (result == 3) { + commonResponse.setCode(1); + commonResponse.setMsg("成功"); + resultResponse.set反馈ID(501115); + resultResponse.set反馈文本("【旁白@正常】手机号码格式不对哦。"); + resultResponse.set后台附加返回("请说明留言内容"); + resultVarsResponse.setVars(resultResponse); + commonResponse.setData(resultVarsResponse); + return commonResponse; + } + message = TypeConvertUtil.contextChange(message); + //留言内容包含敏感词汇,判定失败 +// List sensitiveWordList = PersistenceUtil.getContentFromFile("sensitiveWords.xls"); +// for (String sensitive : sensitiveWordList) { +// if (message.contains(sensitive)) { +// log.info(uid + "的留言内容包含敏感词汇:" + sensitive); +// //保存玩家这轮的请求信息,用于下一步操作 +// operationReq.setAddress(address); +// operationReq.setMessage(null); +// operationReq.setOperationLabel(Constants.LEAVE_MESSAGE); +// CacheUtil.put(uid, operationReq, Long.parseLong(expireTime)); +// //获取对应话术 +// String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_fail_sensitive_words"); +// commonResponse.setCode(1); +// commonResponse.setMsg("成功"); +// resultResponse.set反馈ID(501105); +// resultResponse.set反馈文本(text); +// resultResponse.set后台附加返回("请说明留言内容"); +// resultVarsResponse.setVars(resultResponse); +// commonResponse.setData(resultVarsResponse); +// return commonResponse; +// } +// } //获取对应话术 String text = SpeechUtil.getSocialSpeech(Constants.SPEECH_ASIDE, "leave_message_double_check"); text = SpeechUtil.speechReplaceNum(text, message); diff --git a/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java b/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java index 275b6d9..599af8e 100644 --- a/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java +++ b/src/main/java/com/qiwuai/garden/service/taskService/impl/TaskServiceImpl.java @@ -17,6 +17,7 @@ import com.qiwuai.garden.pojo.TaskTypePojo; import com.qiwuai.garden.service.taskService.TaskService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -29,7 +30,8 @@ import java.util.stream.Collectors; public class TaskServiceImpl implements TaskService { Logger log = LoggerFactory.getLogger(TaskServiceImpl.class); //从yml配置文件中取出对话过期时间 - String expireTime = YamlUtil.getValueByKey("expireTime"); + @Value("${expireTime}") + private String expireTime; @Override public CommonResponse checkTask(OperationRequest operationReq) { diff --git a/src/main/resources/application-crazyPro.yml b/src/main/resources/application-crazyPro.yml index 112f460..14d9eb4 100644 --- a/src/main/resources/application-crazyPro.yml +++ b/src/main/resources/application-crazyPro.yml @@ -12,7 +12,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/crazy_garden?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC username: root - password: 38A0O1jEPOE + password: R91jKARPj23dtqZ4wfc2F type: com.alibaba.druid.pool.DruidDataSource druid: initial-size: 5 @@ -53,15 +53,15 @@ expireTime: 180000 #玩家无操作时长,默认下线 offlineTime: 180000 -userFilePath: /home/crazyGarden/crazyGardenUser/ +userFilePath: /home/jiaoyou/projects/crazyGarden/crazyGardenUser/ -speechFilePath: /home/crazyGarden/crazyGardenSpeech/ +speechFilePath: /home/jiaoyou/projects/crazyGarden/crazyGardenSpeech/ -configFilePath: /home/crazyGarden/config/ +configFilePath: /home/jiaoyou/projects/crazyGarden/config/ -messageFilePath: /home/crazyGarden/message/ +messageFilePath: /home/jiaoyou/projects/crazyGarden/message/ -reportFilePath: /home/crazyGarden/report/ +reportFilePath: /home/jiaoyou/projects/crazyGarden/report/ #动态词组更新秘钥 appSecret: Wl4zX6mEAjK5uT2M diff --git a/src/main/resources/application-crazyUat.yml b/src/main/resources/application-crazyUat.yml index bd436c4..d22cc92 100644 --- a/src/main/resources/application-crazyUat.yml +++ b/src/main/resources/application-crazyUat.yml @@ -69,7 +69,7 @@ appSecret: nnPGsrbMriXdrRNISQeb updatePhraseUrl: http://hw-gz24.heyqiwu.cn:8082/out/phrase #分享关系查看地址 -shareRelationUrl: https://hw-gz26.heyqiwu.cn/api/tongyong/ +shareRelationUrl: http://tx-gz10.heyqiwu.cn/api/tongyong/ #分享链接通道 shareChannelId: zhuimenggarden-server-test #分享链接秘钥 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 6fabfd7..1f554aa 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -53,15 +53,15 @@ expireTime: 180000 #玩家无操作时长,默认下线 offlineTime: 180000 -userFilePath: /home/secretGarden/secretGardenUser/ +userFilePath: /home/jiaoyou/projects/secretGarden/secretGardenUser/ -speechFilePath: /home/secretGarden/secretGardenSpeech/ +speechFilePath: /home/jiaoyou/projects/secretGarden/secretGardenSpeech/ -configFilePath: /home/secretGarden/config/ +configFilePath: /home/jiaoyou/projects/secretGarden/config/ -messageFilePath: /home/secretGarden/message/ +messageFilePath: /home/jiaoyou/projects/secretGarden/message/ -reportFilePath: /home/secretGarden/report/ +reportFilePath: /home/jiaoyou/projects/secretGarden/report/ #动态词组更新秘钥 appSecret: nnPGsrbMriXdrRNISQeb @@ -69,7 +69,7 @@ appSecret: nnPGsrbMriXdrRNISQeb updatePhraseUrl: http://hw-gz24.heyqiwu.cn:8082/out/phrase #分享关系查看地址 -shareRelationUrl: https://hw-gz26.heyqiwu.cn/api/tongyong/ +shareRelationUrl: http://tx-gz10.heyqiwu.cn/api/tongyong/ #分享链接通道 shareChannelId: zhuimenggarden-server-test #分享链接秘钥 diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index 3655b84..138d4fd 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -12,7 +12,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/secret_garden?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC username: root - password: 38A0O1jEPOE + password: R91jKARPj23dtqZ4wfc2F type: com.alibaba.druid.pool.DruidDataSource druid: initial-size: 5 @@ -53,15 +53,15 @@ expireTime: 180000 #玩家无操作时长,默认下线 offlineTime: 180000 -userFilePath: /home/secretGarden/secretGardenUser/ +userFilePath: /home/jiaoyou/projects/secretGarden/secretGardenUser/ -speechFilePath: /home/secretGarden/secretGardenSpeech/ +speechFilePath: /home/jiaoyou/projects/secretGarden/secretGardenSpeech/ -configFilePath: /home/secretGarden/config/ +configFilePath: /home/jiaoyou/projects/secretGarden/config/ -messageFilePath: /home/secretGarden/message/ +messageFilePath: /home/jiaoyou/projects/secretGarden/message/ -reportFilePath: /home/secretGarden/report/ +reportFilePath: /home/jiaoyou/projects/secretGarden/report/ #动态词组更新秘钥 appSecret: Wl4zX6mEAjK5uT2M diff --git a/src/main/resources/application-uat.yml b/src/main/resources/application-uat.yml index 51e36ec..02b64e7 100644 --- a/src/main/resources/application-uat.yml +++ b/src/main/resources/application-uat.yml @@ -12,7 +12,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/secret_garden?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC username: root - password: 38A0O1jEPOE + password: dgKNTmt2iLHNjEQajkDEZkq8 type: com.alibaba.druid.pool.DruidDataSource druid: initial-size: 5 @@ -53,15 +53,15 @@ expireTime: 180000 #玩家无操作时长,默认下线 offlineTime: 180000 -userFilePath: /home/secretGarden/secretGardenUser/ +userFilePath: /home/jiaoyou/projects/secretGarden/secretGardenUser/ -speechFilePath: /home/secretGarden/secretGardenSpeech/ +speechFilePath: /home/jiaoyou/projects/secretGarden/secretGardenSpeech/ -configFilePath: /home/secretGarden/config/ +configFilePath: /home/jiaoyou/projects/secretGarden/config/ -messageFilePath: /home/secretGarden/message/ +messageFilePath: /home/jiaoyou/projects/secretGarden/message/ -reportFilePath: /home/secretGarden/report/ +reportFilePath: /home/jiaoyou/projects/secretGarden/report/ #动态词组更新秘钥 appSecret: nnPGsrbMriXdrRNISQeb @@ -69,7 +69,7 @@ appSecret: nnPGsrbMriXdrRNISQeb updatePhraseUrl: http://hw-gz24.heyqiwu.cn:8082/out/phrase #分享关系查看地址 -shareRelationUrl: https://hw-gz26.heyqiwu.cn/api/tongyong/ +shareRelationUrl: http://tx-gz10.heyqiwu.cn/api/tongyong/ #分享链接通道 shareChannelId: zhuimenggarden-server-test #分享链接秘钥 diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 1bbcdd8..1e3c5c2 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -2,7 +2,7 @@ - + diff --git a/src/main/resources/speech/ranking.yaml b/src/main/resources/speech/ranking.yaml index dd02397..e234703 100644 --- a/src/main/resources/speech/ranking.yaml +++ b/src/main/resources/speech/ranking.yaml @@ -39,6 +39,8 @@ aside: check_region_friendship_ranking: - 【旁白@正常】第【1】名是【2】,共帮助好友收获植物【3】次 #查看本人排名 + check_self_no_ranking: + - 【旁白@正常】榜单每天刷新一次,你当前还没有进行排名。 check_self_rich_ranking: - 【旁白@正常】你在富豪榜上排名为第【1】名。 check_self_fight_ranking: @@ -56,6 +58,8 @@ aside: check_self_local_ranking: - 【旁白@正常】你在本地区的富豪榜上排名为第【1】名。你在战斗榜上排名为第【2】名。你在友情榜上排名为第【3】名。 #查看玩家排名 + check_player_no_ranking: + - 【旁白@正常】榜单每天刷新一次,玩家【1】还未进行排名。 check_player_rich_ranking: - 【旁白@正常】玩家【1】在富豪榜上排名为第【2】名。 check_player_fight_ranking: diff --git a/src/main/resources/speech/social.yaml b/src/main/resources/speech/social.yaml index 70a7ab5..9404ecc 100644 --- a/src/main/resources/speech/social.yaml +++ b/src/main/resources/speech/social.yaml @@ -178,6 +178,8 @@ aside: address_self_check: - 【旁白@正常】你的地址为【1】。 #好友留言 + leave_message_check_context: + - 【旁白@正常】目前的留言功能尚未开放,您可以先给好友留下联系方式以便联系,暂且支持微信、QQ或者手机号码哦。请按以下方式说出要留言的内容:微信+微信号、QQ+QQ号、或者手机号码+手机号。如微信zhanghao123。 leave_message_check: - 【旁白@正常】好的,请留下你要留言的内容。 leave_message_double_check: -- libgit2 0.27.1