From 7524007b9c8f2741d42321a9bab482fd161efbd9 Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 23 Feb 2023 17:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20service->bot->update=20?= =?UTF-8?q?=E6=97=A0=E6=95=88=E6=9B=B4=E6=96=B0=E5=88=A4=E6=96=AD=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/user/bot/UpdateServiceImpl.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/kob/backend/service/impl/user/bot/UpdateServiceImpl.java b/backend/src/main/java/com/kob/backend/service/impl/user/bot/UpdateServiceImpl.java index 3a87148..931098d 100644 --- a/backend/src/main/java/com/kob/backend/service/impl/user/bot/UpdateServiceImpl.java +++ b/backend/src/main/java/com/kob/backend/service/impl/user/bot/UpdateServiceImpl.java @@ -19,6 +19,7 @@ public class UpdateServiceImpl implements UpdateService { @Autowired private BotMapper botMapper; + @Override public Map update(Map data) { // 先获取当前用户,用于判断更新对象是否有权限 @@ -62,13 +63,18 @@ public class UpdateServiceImpl implements UpdateService { Bot bot = botMapper.selectById(bot_id); - if(bot == null){ - map.put("error_message","所查 bot 不存在或已被删除"); + if (bot == null) { + map.put("error_message", "所查 bot 不存在或已被删除"); return map; } - if(!bot.getUserId().equals(user.getId())){ - map.put("error_message","你无权更改别人的 bot"); + if (!bot.getUserId().equals(user.getId())) { + map.put("error_message", "你无权更改别人的 bot"); + return map; + } + + if (bot.getTitle().equals(title) && bot.getDescription().equals(description) && bot.getContent().equals(content)) { + map.put("error_message", "未作出修改"); return map; } @@ -76,10 +82,10 @@ public class UpdateServiceImpl implements UpdateService { Date createTime = bot.getCreatetime(); int rating = bot.getRating(); - Bot newBot = new Bot(bot.getId(),user.getId(),title,description,content,rating,createTime,now); + Bot newBot = new Bot(bot.getId(), user.getId(), title, description, content, rating, createTime, now); botMapper.updateById(newBot); - map.put("error_message","success"); + map.put("error_message", "success"); return map; } }