| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.izouma.nineth.web;
- import com.izouma.nineth.domain.MetaAtomTask;
- import com.izouma.nineth.dto.PageQuery;
- import com.izouma.nineth.exception.BusinessException;
- import com.izouma.nineth.repo.MetaAtomTaskRepo;
- import com.izouma.nineth.service.MetaAtomTaskService;
- import com.izouma.nineth.utils.ObjUtils;
- 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("/metaAtomTask")
- @AllArgsConstructor
- public class MetaAtomTaskController extends BaseController {
- private MetaAtomTaskService metaAtomTaskService;
- private MetaAtomTaskRepo metaAtomTaskRepo;
- //@PreAuthorize("hasRole('ADMIN')")
- @PostMapping("/save")
- public MetaAtomTask save(@RequestBody MetaAtomTask record) {
- if (record.getId() != null) {
- MetaAtomTask orig = metaAtomTaskRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
- ObjUtils.merge(orig, record);
- return metaAtomTaskRepo.save(orig);
- }
- return metaAtomTaskRepo.save(record);
- }
- //@PreAuthorize("hasRole('ADMIN')")
- @PostMapping("/all")
- public Page<MetaAtomTask> all(@RequestBody PageQuery pageQuery) {
- return metaAtomTaskService.all(pageQuery);
- }
- @GetMapping("/get/{id}")
- public MetaAtomTask get(@PathVariable Long id) {
- return metaAtomTaskRepo.findById(id).orElseThrow(new BusinessException("无记录"));
- }
- @PostMapping("/del/{id}")
- public void del(@PathVariable Long id) {
- metaAtomTaskRepo.softDelete(id);
- }
- @GetMapping("/excel")
- @ResponseBody
- public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
- List<MetaAtomTask> data = all(pageQuery).getContent();
- ExcelUtils.export(response, data);
- }
- @GetMapping("/findAll")
- public List<MetaAtomTask> findAll() {
- return metaAtomTaskRepo.findAllByDel(false);
- }
- }
|