关卡删除和修改

This commit is contained in:
石皮幼鸟 2024-04-12 11:09:04 +08:00
parent a7442babbe
commit 4af5dae371
1 changed files with 3 additions and 20 deletions

View File

@ -32,29 +32,12 @@ public class LevelServiceImpl implements LevelService {
Level level = new Level();
level.setId(id);
DeleteResult deleteRequest = mongoTemplate.remove(level);
if (deleteRequest.getDeletedCount() > 0) {
return true;
} else {
return false;
}
return deleteRequest.getDeletedCount() > 0;
}
@Override
public boolean update(Level level) {
Query query=Query.query(Criteria.where("id").is(level.getId()));
Update update = new Update();
update.set("order",level.getOrder());
update.set("name",level.getName());
update.set("type",level.getType());
update.set("timeLimit",level.getTimeLimit());
update.set("targetScore",level.getTargetScore());
update.set("words",level.getWords());
UpdateResult updateResult=mongoTemplate.updateFirst(query, update, Level.class);
if (updateResult.getModifiedCount() > 0) {
return true;
} else {
return false;
}
var save = mongoTemplate.save(level);
return save.getId() != null;
}
}