关卡删除和修改
This commit is contained in:
parent
a7442babbe
commit
4af5dae371
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue