|
|
@@ -1,60 +0,0 @@
|
|
|
-package com.izouma.nineth.web;
|
|
|
-import com.izouma.nineth.domain.RiceWaterTypeForWatreing;
|
|
|
-import com.izouma.nineth.service.RiceWaterTypeForWatreingService;
|
|
|
-import com.izouma.nineth.dto.PageQuery;
|
|
|
-import com.izouma.nineth.exception.BusinessException;
|
|
|
-import com.izouma.nineth.repo.RiceWaterTypeForWatreingRepo;
|
|
|
-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.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping("/riceWaterTypeForWatreing")
|
|
|
-@AllArgsConstructor
|
|
|
-public class RiceWaterTypeForWatreingController extends BaseController {
|
|
|
- private RiceWaterTypeForWatreingService riceWaterTypeForWatreingService;
|
|
|
- private RiceWaterTypeForWatreingRepo riceWaterTypeForWatreingRepo;
|
|
|
-
|
|
|
- //@PreAuthorize("hasRole('ADMIN')")
|
|
|
- @PostMapping("/save")
|
|
|
- public RiceWaterTypeForWatreing save(@RequestBody RiceWaterTypeForWatreing record) {
|
|
|
- if (record.getId() != null) {
|
|
|
- RiceWaterTypeForWatreing orig = riceWaterTypeForWatreingRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
- ObjUtils.merge(orig, record);
|
|
|
- return riceWaterTypeForWatreingRepo.save(orig);
|
|
|
- }
|
|
|
- return riceWaterTypeForWatreingRepo.save(record);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //@PreAuthorize("hasRole('ADMIN')")
|
|
|
- @PostMapping("/all")
|
|
|
- public Page<RiceWaterTypeForWatreing> all(@RequestBody PageQuery pageQuery) {
|
|
|
- return riceWaterTypeForWatreingService.all(pageQuery);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/get/{id}")
|
|
|
- public RiceWaterTypeForWatreing get(@PathVariable Long id) {
|
|
|
- return riceWaterTypeForWatreingRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/del/{id}")
|
|
|
- public void del(@PathVariable Long id) {
|
|
|
- riceWaterTypeForWatreingRepo.softDelete(id);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/excel")
|
|
|
- @ResponseBody
|
|
|
- public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
|
- List<RiceWaterTypeForWatreing> data = all(pageQuery).getContent();
|
|
|
- ExcelUtils.export(response, data);
|
|
|
- }
|
|
|
-}
|
|
|
-
|