shuhao пре 5 месеци
родитељ
комит
bd4ecfc3e6

+ 14 - 13
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
+import com.flyer.foster.dto.TreeUpdateDTO;
+import com.flyer.foster.dto.app.AppFosterRecordQueryDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.flyer.foster.entity.Tree;
 import com.flyer.foster.pojo.StpAppUtil;
@@ -28,6 +30,7 @@ public class AppFosterRecordController {
 
     /**
      * 根据果园id查询领养记录
+     *
      * @return
      */
     @GetMapping("/list/{gardenId}")
@@ -41,22 +44,20 @@ public class AppFosterRecordController {
     }
 
     /**
-     * 修改树
+
+     * 领养记录-分页
+     * @param current
+     * @param size
+     * @param queryDTO
+     * @return
      */
-    @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());
+    @GetMapping("/list/{current}/{size}")
+    public R getPageList(@PathVariable Integer current, @PathVariable Integer size, AppFosterRecordQueryDTO queryDTO) {
+        return R.ok().result(iFosterRecordService.getPageList(new Page<>(current, size), queryDTO));
     }
 
     /**
-     * 确认领养
-     *
+* 确认领养     *
      * @return
      */
     @PostMapping("")

+ 24 - 0
admin/src/main/java/com/flyer/foster/dto/app/AppFosterRecordQueryDTO.java

@@ -0,0 +1,24 @@
+package com.flyer.foster.dto.app;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * FosterRecordAddDTO
+ *
+ * @author kelei
+ * @since 2024/5/13/13:50
+ */
+@Data
+public class AppFosterRecordQueryDTO {
+    /**
+     * 用户id
+     */
+    private Integer appUserId;
+
+    private Integer gardenId;
+
+    private Integer treeId;
+
+}

+ 52 - 0
admin/src/main/java/com/flyer/foster/dto/app/AppFosterRecordRespDTO.java

@@ -0,0 +1,52 @@
+package com.flyer.foster.dto.app;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * FosterRecordAddDTO
+ *
+ * @author kelei
+ * @since 2024/5/13/13:50
+ */
+@Data
+public class AppFosterRecordRespDTO {
+    private Integer id;
+
+    /**
+     * 小程序用户id
+     */
+    private Integer appUserId;
+
+    /**
+     * 用户名
+     */
+    private String appUserName;
+
+    /**
+     * 果园id
+     */
+    private Integer gardenId;
+
+    /**
+     * 果园名
+     */
+    private String gardenName;
+
+    /**
+     * 领养树id
+     */
+    private Integer treeId;
+
+    /**
+     * 飞鸟看园树id
+     */
+    private Integer birdseyeTreeId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createdTime;
+
+}

+ 5 - 0
admin/src/main/java/com/flyer/foster/mapper/IFosterRecordMapper.java

@@ -1,5 +1,9 @@
 package com.flyer.foster.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.flyer.foster.dto.app.AppFosterRecordQueryDTO;
+import com.flyer.foster.dto.app.AppFosterRecordRespDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface IFosterRecordMapper extends BaseMapper<FosterRecord> {
 
+    IPage<AppFosterRecordRespDTO> getPageList(Page<AppFosterRecordRespDTO> page, AppFosterRecordQueryDTO queryDTO);
 }

+ 12 - 0
admin/src/main/java/com/flyer/foster/service/IFosterRecordService.java

@@ -1,6 +1,10 @@
 package com.flyer.foster.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
+import com.flyer.foster.dto.app.AppFosterRecordQueryDTO;
+import com.flyer.foster.dto.app.AppFosterRecordRespDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -20,4 +24,12 @@ public interface IFosterRecordService extends IService<FosterRecord> {
      * @return
      */
     Integer addFosterRecord(AppFosterRecordAddDTO addDTO);
+
+    /**
+     * 领养列表-分页
+     * @param page
+     * @param queryDTO
+     * @return
+     */
+    IPage<AppFosterRecordRespDTO> getPageList(Page<AppFosterRecordRespDTO> page, AppFosterRecordQueryDTO queryDTO);
 }

+ 9 - 0
admin/src/main/java/com/flyer/foster/service/impl/FosterRecordServiceImpl.java

@@ -2,8 +2,12 @@ package com.flyer.foster.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.flyer.exception.BusinessException;
 import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
+import com.flyer.foster.dto.app.AppFosterRecordQueryDTO;
+import com.flyer.foster.dto.app.AppFosterRecordRespDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.flyer.foster.entity.Garden;
 import com.flyer.foster.mapper.IFosterRecordMapper;
@@ -84,4 +88,9 @@ public class FosterRecordServiceImpl extends ServiceImpl<IFosterRecordMapper, Fo
         }
         return fosterRecord.getBirdseyeTreeId();
     }
+
+    @Override
+    public IPage<AppFosterRecordRespDTO> getPageList(Page<AppFosterRecordRespDTO> page, AppFosterRecordQueryDTO queryDTO) {
+        return baseMapper.getPageList(page, queryDTO);
+    }
 }

+ 12 - 0
admin/src/main/resources/mapper/FosterRecordMapper.xml

@@ -2,4 +2,16 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.flyer.foster.mapper.IFosterRecordMapper">
 
+    <select id="getPageList" resultType="com.flyer.foster.dto.app.AppFosterRecordRespDTO">
+        select a.id,
+               a.app_user_id  as appUserId,
+               a.garden_id    as gardenId,
+               c.name         as gardenName,
+               a.tree_id      as treeId,
+               a.created_time as createdTime,
+               b.name         as appUserName
+        from tb_foster_record a
+                 inner join tb_app_user b on a.app_user_id = b.id
+                 left join tb_garden c on a.garden_id = c.id
+    </select>
 </mapper>