1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.nosum.deliver.author.controller;
- import com.nosum.common.base.domain.PageInfo;
- import com.nosum.common.base.domain.Result;
- import com.nosum.deliver.author.domain.po.Author;
- import com.nosum.deliver.author.service.AuthorService;
- import org.bson.types.ObjectId;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- import java.util.UUID;
- /**
- * 作者信息接口层.
- *
- * @author Young
- */
- @RestController
- @RequestMapping("/admin/author")
- public class AuthorAdminController {
- @Autowired
- private AuthorService authorService;
- @PostMapping("/save")
- public Result<Void> save(@RequestBody Author author) {
- authorService.save(author);
- return Result.createWithSuccessMessage();
- }
- @GetMapping("/saveBatch")
- public Result<Void> saveBatch() {
- Result<Author> page = page(new Author());
- List<Author> models = page.getModels();
- Author author1 = models.get(0);
- for (int i = 0; i < 1000; i++) {
- author1.setId(ObjectId.get());
- author1.setFinderUin(i + UUID.randomUUID().toString());
- save(author1);
- }
- return Result.createWithSuccessMessage();
- }
- @GetMapping("/{id}")
- public Result<Author> get(@PathVariable("id") ObjectId id) {
- return Result.createWithModel(authorService.getById(id));
- }
- @GetMapping("/page")
- public Result<Author> page(Author author) {
- PageInfo<Author> pageInfo = authorService.getPage(PageInfo.withRequest(), author);
- return Result.createWithPaging(pageInfo.getRecord(), pageInfo);
- }
- @DeleteMapping("/{id}")
- public Result<Void> remove(@PathVariable("id") ObjectId id) {
- authorService.remove(id);
- return Result.createWithSuccessMessage();
- }
- }
|