shuhao il y a 5 mois
Parent
commit
939d2c87ff

+ 16 - 0
admin/src/main/java/com/flyer/foster/controller/app/AppFosterRecordController.java

@@ -1,7 +1,9 @@
 package com.flyer.foster.controller.app;
 
+import com.flyer.foster.dto.TreeUpdateDTO;
 import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
 import com.flyer.foster.entity.FosterRecord;
+import com.flyer.foster.entity.Tree;
 import com.flyer.foster.pojo.StpAppUtil;
 import com.flyer.foster.service.IFosterRecordService;
 import com.flyer.util.R;
@@ -39,6 +41,20 @@ public class AppFosterRecordController {
     }
 
     /**
+     * 修改树
+     */
+    @PutMapping("")
+    public R update(@RequestBody FosterRecord updateDTO) {
+        String appUserId = StpAppUtil.getLoginId().toString();
+        return R.ok().result(
+                iFosterRecordService.lambdaUpdate()
+                        .set(FosterRecord::getName, updateDTO.getName())
+                        .eq(FosterRecord::getGardenId, updateDTO.getGardenId())
+                        .eq(FosterRecord::getAppUserId, appUserId)
+                        .update());
+    }
+
+    /**
      * 确认领养
      *
      * @return

+ 24 - 0
admin/src/main/java/com/flyer/foster/controller/app/AppTreeController.java

@@ -10,6 +10,7 @@ import com.flyer.foster.pojo.StpAppUtil;
 import com.flyer.foster.service.IFosterRecordService;
 import com.flyer.foster.service.ITreeService;
 import com.flyer.util.R;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -42,6 +43,29 @@ public class AppTreeController {
     }
 
     /**
+     * 修改树
+     */
+    @PutMapping("")
+    public R update(@RequestBody TreeUpdateDTO updateDTO) {
+        return R.ok().result(
+                iTreeService.lambdaUpdate()
+                        .set(Tree::getName, updateDTO.getGardenId())
+                        .eq(Tree::getId, updateDTO.getId())
+                        .update());
+    }
+
+    /**
+     * get tree
+     */
+    @GetMapping("/{treeId}")
+    public R get(@PathVariable Integer treeId) {
+        Tree tree = iTreeService.lambdaQuery().eq(Tree::getName ,treeId).one();
+        TreeRespDTO dto = new TreeRespDTO();
+        BeanUtils.copyProperties(tree, dto);
+        return R.ok().result(dto);
+    }
+
+    /**
      * 返回区域随机的一棵树
      *
      * @return

+ 5 - 0
admin/src/main/java/com/flyer/foster/dto/TreeRespDTO.java

@@ -19,6 +19,11 @@ public class TreeRespDTO {
     private Integer id;
 
     /**
+     * name
+     */
+    private String name;
+
+    /**
      * 果园id
      */
     private Integer gardenId;

+ 6 - 0
admin/src/main/java/com/flyer/foster/dto/TreeUpdateDTO.java

@@ -22,6 +22,12 @@ public class TreeUpdateDTO {
     @NotNull(message = "果园id不能为空")
     private Integer gardenId;
 
+
+    /**
+     * 果shu name
+     */
+    private String name;
+
     /**
      * 区域id
      */

+ 5 - 0
admin/src/main/java/com/flyer/foster/entity/FosterRecord.java

@@ -36,6 +36,11 @@ public class FosterRecord implements Serializable {
     private Integer id;
 
     /**
+     * name
+     */
+    private String name;
+
+    /**
      * 小程序用户id
      */
     private Integer appUserId;

+ 5 - 0
admin/src/main/java/com/flyer/foster/entity/Tree.java

@@ -34,6 +34,11 @@ public class Tree implements Serializable {
     private Integer id;
 
     /**
+     * name
+     */
+    private String name;
+
+    /**
      * 果园id
      */
     private Integer gardenId;