package com.izouma.nineth.web; import com.izouma.nineth.domain.MetaAwardDrop; import com.izouma.nineth.dto.PageQuery; import com.izouma.nineth.exception.BusinessException; import com.izouma.nineth.repo.MetaAwardDropRepo; import com.izouma.nineth.service.MetaAwardDropService; import com.izouma.nineth.utils.excel.ExcelUtils; import lombok.AllArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @RestController @RequestMapping("/metaAwardDrop") @AllArgsConstructor public class MetaAwardDropController extends BaseController { private MetaAwardDropService metaAwardDropService; private MetaAwardDropRepo metaAwardDropRepo; //@PreAuthorize("hasRole('ADMIN')") @PostMapping("/save") public MetaAwardDrop save(@RequestBody MetaAwardDrop record) { return metaAwardDropService.save(record); } //@PreAuthorize("hasRole('ADMIN')") @PostMapping("/all") public Page all(@RequestBody PageQuery pageQuery) { return metaAwardDropService.all(pageQuery); } @GetMapping("/get/{id}") public MetaAwardDrop get(@PathVariable Long id) { return metaAwardDropRepo.findById(id).orElseThrow(new BusinessException("无记录")); } @GetMapping("/excel") @ResponseBody public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException { List data = all(pageQuery).getContent(); ExcelUtils.export(response, data); } }