mirror of https://github.com/halo-dev/halo
feat: add a batch creation api for photos (#1564)
* feat: add an api of batch creation photos * feat: add an api verificationpull/1568/head
parent
9801bc7a20
commit
a802572128
|
@ -4,12 +4,14 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
|
|||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Valid;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -32,6 +34,7 @@ import run.halo.app.service.PhotoService;
|
|||
* @author ryanwang
|
||||
* @date 2019-03-21
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/photos")
|
||||
public class PhotoController {
|
||||
|
@ -75,6 +78,18 @@ public class PhotoController {
|
|||
return new PhotoDTO().convertFrom(photoService.createBy(photoParam));
|
||||
}
|
||||
|
||||
@PostMapping("/batch")
|
||||
@ApiOperation("Batch creation photos")
|
||||
public List<PhotoDTO> createBatchBy(@RequestBody List<@Valid PhotoParam> photoParams) {
|
||||
return photoParams.stream()
|
||||
.map(photoParam -> {
|
||||
PhotoDTO photoDto = new PhotoDTO();
|
||||
photoDto.convertFrom(photoService.createBy(photoParam));
|
||||
return photoDto;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@PutMapping("{photoId:\\d+}")
|
||||
@ApiOperation("Updates a photo")
|
||||
public PhotoDTO updateBy(@PathVariable("photoId") Integer photoId,
|
||||
|
|
Loading…
Reference in New Issue