关卡删除和修改
This commit is contained in:
parent
a7442babbe
commit
4af5dae371
|
@ -32,29 +32,12 @@ public class LevelServiceImpl implements LevelService {
|
||||||
Level level = new Level();
|
Level level = new Level();
|
||||||
level.setId(id);
|
level.setId(id);
|
||||||
DeleteResult deleteRequest = mongoTemplate.remove(level);
|
DeleteResult deleteRequest = mongoTemplate.remove(level);
|
||||||
if (deleteRequest.getDeletedCount() > 0) {
|
return deleteRequest.getDeletedCount() > 0;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(Level level) {
|
public boolean update(Level level) {
|
||||||
Query query=Query.query(Criteria.where("id").is(level.getId()));
|
var save = mongoTemplate.save(level);
|
||||||
Update update = new Update();
|
return save.getId() != null;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue