MetaAwardDropController.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.izouma.nineth.web;
  2. import com.izouma.nineth.domain.MetaAwardDrop;
  3. import com.izouma.nineth.dto.PageQuery;
  4. import com.izouma.nineth.exception.BusinessException;
  5. import com.izouma.nineth.repo.MetaAwardDropRepo;
  6. import com.izouma.nineth.service.MetaAwardDropService;
  7. import com.izouma.nineth.utils.excel.ExcelUtils;
  8. import lombok.AllArgsConstructor;
  9. import org.springframework.data.domain.Page;
  10. import org.springframework.web.bind.annotation.*;
  11. import javax.servlet.http.HttpServletResponse;
  12. import java.io.IOException;
  13. import java.util.List;
  14. @RestController
  15. @RequestMapping("/metaAwardDrop")
  16. @AllArgsConstructor
  17. public class MetaAwardDropController extends BaseController {
  18. private MetaAwardDropService metaAwardDropService;
  19. private MetaAwardDropRepo metaAwardDropRepo;
  20. //@PreAuthorize("hasRole('ADMIN')")
  21. @PostMapping("/save")
  22. public MetaAwardDrop save(@RequestBody MetaAwardDrop record) {
  23. return metaAwardDropService.save(record);
  24. }
  25. //@PreAuthorize("hasRole('ADMIN')")
  26. @PostMapping("/all")
  27. public Page<MetaAwardDrop> all(@RequestBody PageQuery pageQuery) {
  28. return metaAwardDropService.all(pageQuery);
  29. }
  30. @GetMapping("/get/{id}")
  31. public MetaAwardDrop get(@PathVariable Long id) {
  32. return metaAwardDropRepo.findById(id).orElseThrow(new BusinessException("无记录"));
  33. }
  34. @GetMapping("/excel")
  35. @ResponseBody
  36. public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
  37. List<MetaAwardDrop> data = all(pageQuery).getContent();
  38. ExcelUtils.export(response, data);
  39. }
  40. }