|
|
@@ -0,0 +1,60 @@
|
|
|
+package com.izouma.nineth.web;
|
|
|
+import com.izouma.nineth.domain.RiceUserWaterDropRecord;
|
|
|
+import com.izouma.nineth.service.RiceUserWaterDropRecordService;
|
|
|
+import com.izouma.nineth.dto.PageQuery;
|
|
|
+import com.izouma.nineth.exception.BusinessException;
|
|
|
+import com.izouma.nineth.repo.RiceUserWaterDropRecordRepo;
|
|
|
+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("/riceUserWaterDropRecord")
|
|
|
+@AllArgsConstructor
|
|
|
+public class RiceUserWaterDropRecordController extends BaseController {
|
|
|
+ private RiceUserWaterDropRecordService riceUserWaterDropRecordService;
|
|
|
+ private RiceUserWaterDropRecordRepo riceUserWaterDropRecordRepo;
|
|
|
+
|
|
|
+ //@PreAuthorize("hasRole('ADMIN')")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public RiceUserWaterDropRecord save(@RequestBody RiceUserWaterDropRecord record) {
|
|
|
+ if (record.getId() != null) {
|
|
|
+ RiceUserWaterDropRecord orig = riceUserWaterDropRecordRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
+ ObjUtils.merge(orig, record);
|
|
|
+ return riceUserWaterDropRecordRepo.save(orig);
|
|
|
+ }
|
|
|
+ return riceUserWaterDropRecordRepo.save(record);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //@PreAuthorize("hasRole('ADMIN')")
|
|
|
+ @PostMapping("/all")
|
|
|
+ public Page<RiceUserWaterDropRecord> all(@RequestBody PageQuery pageQuery) {
|
|
|
+ return riceUserWaterDropRecordService.all(pageQuery);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get/{id}")
|
|
|
+ public RiceUserWaterDropRecord get(@PathVariable Long id) {
|
|
|
+ return riceUserWaterDropRecordRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/del/{id}")
|
|
|
+ public void del(@PathVariable Long id) {
|
|
|
+ riceUserWaterDropRecordRepo.softDelete(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/excel")
|
|
|
+ @ResponseBody
|
|
|
+ public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
|
+ List<RiceUserWaterDropRecord> data = all(pageQuery).getContent();
|
|
|
+ ExcelUtils.export(response, data);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|