本文整理汇总了Java中play.mvc.BodyParser.Empty方法的典型用法代码示例。如果您正苦于以下问题:Java BodyParser.Empty方法的具体用法?Java BodyParser.Empty怎么用?Java BodyParser.Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.mvc.BodyParser
的用法示例。
在下文中一共展示了BodyParser.Empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: search
import play.mvc.BodyParser; //导入方法依赖的package包/类
/**
* Returns a list of entities matching the search criteria.
* <p>
* Retrieves all entities where the attribute defined matches
* the value defined.
*
* @param attribute the attribute
* @param value the value for the attribute
* @return A JSON representation if the matching entities.N
*/
@Transactional(readOnly = true) @BodyParser.Of(BodyParser.Empty.class) public Result search(
final String attribute, final String value) {
final List<T> entities;
try {
entities = this.searchEntity(attribute, value);
} catch (IllegalSearchException e) {
return badRequest(e.getMessage());
}
List<Dto> dtos = new ArrayList<>(entities.size());
dtos.addAll(entities.stream().map(this::convertToDto).collect(Collectors.toList()));
return ok(Json.toJson(dtos));
}
示例2: delete
import play.mvc.BodyParser; //导入方法依赖的package包/类
/**
* Deletes the entity identified by the given id.
* <p>
* Deletes the entity with the given id from the model
* service.
* <p>
* If the entity is not found, a 404 NOT FOUND is returned.
*
* @param id the id of the resource which shall be deleted.
* @return OK if the resource was deleted, 404 if the resource
* could not be found.
*/
@Transactional @BodyParser.Of(BodyParser.Empty.class) public Result delete(final Long id) {
T entity = this.loadEntity(id);
if (entity == null) {
return this.notFound(id);
}
if (preDelete(entity)) {
this.modelService.delete(entity);
postDelete();
}
return ok();
}
示例3: list
import play.mvc.BodyParser; //导入方法依赖的package包/类
/**
* Returns a json list of all models.
* <p>
* Retrieves the models using the model service,
* converts them to DTOs and returns their json
* representation.
*
* @return A json representation of all entities.
*/
@Transactional(readOnly = true) @BodyParser.Of(BodyParser.Empty.class) public Result list() {
List<T> entities = this.loadEntities();
List<Dto> dtos = new ArrayList<>(entities.size());
dtos.addAll(entities.stream().map(this::convertToDto).collect(Collectors.toList()));
return ok(Json.toJson(dtos));
}
示例4: get
import play.mvc.BodyParser; //导入方法依赖的package包/类
/**
* Returns a single json representation of an entity.
* <p>
* Retrieves the entity identified by the given id,
* converts it to its DTO and returns a JSON representation
* of the DTO.
* <p>
* If the entity is not found, a 404 NOT FOUND is instead
* returned.
*
* @param id the id of the entity.
* @return A JSON representation of the requested entity. 404 if
* entity does not exist.
*/
@Transactional(readOnly = true) @BodyParser.Of(BodyParser.Empty.class) public Result get(
final Long id) {
final T entity = this.loadEntity(id);
if (entity == null) {
return this.notFound(id);
}
return ok(Json.toJson(this.convertToDto(entity)));
}