添加 service->bot->update 无效更新判断规则
This commit is contained in:
parent
3de67ee47c
commit
7524007b9c
|
@ -19,6 +19,7 @@ public class UpdateServiceImpl implements UpdateService {
|
|||
|
||||
@Autowired
|
||||
private BotMapper botMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, String> update(Map<String, String> 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue