Pārlūkot izejas kodu

[update] message:1.果园增加字段

kelei 6 mēneši atpakaļ
vecāks
revīzija
3b14c95059

+ 1 - 1
admin/src/main/java/com/flyer/foster/controller/UserController.java

@@ -50,7 +50,7 @@ public class UserController {
      * @return
      */
     @GetMapping("/generate-key")
-    public R getRsaKey(String username) {
+    public R getRsaKey(@RequestParam String username) {
         return R.ok().result(iUserService.getRsaKey(username));
     }
 

+ 15 - 4
admin/src/main/java/com/flyer/foster/dto/GardenAddDTO.java

@@ -41,8 +41,19 @@ public class GardenAddDTO {
      */
     private String qrCode;
 
-    /**
-     * 状态-{0.不可用 1.可用}
-     */
-    private Integer status;
+    private String coverUrl1;
+
+    private String coverUrl1Content;
+
+    private String coverUrl2;
+
+    private String coverUrl2Content;
+
+    private String coverUrl3;
+
+    private String coverUrl3Content;
+
+    private String coverUrl4;
+
+    private String coverUrl4Content;
 }

+ 16 - 4
admin/src/main/java/com/flyer/foster/dto/GardenUpdateDTO.java

@@ -41,8 +41,20 @@ public class GardenUpdateDTO {
      */
     private String qrCode;
 
-    /**
-     * 状态-{0.不可用 1.可用}
-     */
-    private Integer status;
+
+    private String coverUrl1;
+
+    private String coverUrl1Content;
+
+    private String coverUrl2;
+
+    private String coverUrl2Content;
+
+    private String coverUrl3;
+
+    private String coverUrl3Content;
+
+    private String coverUrl4;
+
+    private String coverUrl4Content;
 }

+ 2 - 2
admin/src/main/java/com/flyer/foster/dto/app/FosterRecordAddDTO.java

@@ -18,7 +18,7 @@ public class FosterRecordAddDTO {
     @NotNull(message = "用户id不能为空")
     private Integer appUserId;
 
-    @NotNull(message = "id不能为空")
-    private Integer treeId;
+    @NotNull(message = "果园id不能为空")
+    private Integer gardenId;
 
 }

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

@@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.Version;
+
 import java.io.Serializable;
 import java.time.LocalDateTime;
+
 import lombok.Getter;
 import lombok.Setter;
 
@@ -49,6 +51,11 @@ public class FosterRecord implements Serializable {
     private Integer treeId;
 
     /**
+     * 飞鸟看园树id
+     */
+    private Integer birdseyeTreeId;
+
+    /**
      * 状态-{0.不可用 1.可用}
      */
     private Integer status;

+ 16 - 0
admin/src/main/java/com/flyer/foster/entity/Garden.java

@@ -60,6 +60,22 @@ public class Garden implements Serializable {
      */
     private String qrCode;
 
+    private String coverUrl1;
+
+    private String coverUrl1Content;
+
+    private String coverUrl2;
+
+    private String coverUrl2Content;
+
+    private String coverUrl3;
+
+    private String coverUrl3Content;
+
+    private String coverUrl4;
+
+    private String coverUrl4Content;
+
     /**
      * 状态-{0.不可用 1.可用}
      */

+ 25 - 1
admin/src/main/java/com/flyer/foster/service/impl/FosterRecordServiceImpl.java

@@ -1,15 +1,22 @@
 package com.flyer.foster.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.flyer.exception.BusinessException;
 import com.flyer.foster.dto.app.FosterRecordAddDTO;
 import com.flyer.foster.entity.FosterRecord;
+import com.flyer.foster.entity.Garden;
 import com.flyer.foster.mapper.IFosterRecordMapper;
 import com.flyer.foster.pojo.StpAppUtil;
 import com.flyer.foster.service.IFosterRecordService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.flyer.foster.service.IGardenService;
+import com.flyer.util.RedisUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Map;
+
 /**
  * <p>
  * 领养记录 服务实现类
@@ -21,13 +28,30 @@ import org.springframework.transaction.annotation.Transactional;
 @Service
 public class FosterRecordServiceImpl extends ServiceImpl<IFosterRecordMapper, FosterRecord> implements IFosterRecordService {
 
+    @Autowired
+    private IGardenService iGardenService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
     @Transactional
     @Override
     public boolean addFosterRecord(FosterRecordAddDTO addDTO) {
         int tenantId = StpAppUtil.getTokenSession().getInt("tenantId");
+        // 根据果园id找到配置的飞鸟看园果园id
+        Garden garden = iGardenService.getById(addDTO.getGardenId());
+        if (garden == null) {
+            throw new BusinessException("无效的果园id");
+        }
+        // 飞鸟看园果园id
+        Integer birdseyeGardenId = garden.getBirdseyeGardenId();
+        // 从缓存中取出果园下的树,获取一个未曾分配的树id,
+        Map<Object, Object> treeCache = redisUtil.hmget("birdseye:tree");
+
         FosterRecord fosterRecord = new FosterRecord();
         BeanUtil.copyProperties(addDTO, fosterRecord);
         fosterRecord.setTenantId(tenantId);
-        return this.save(fosterRecord);
+//        return this.save(fosterRecord);
+        return true;
     }
 }

+ 8 - 1
admin/src/main/java/com/flyer/foster/service/impl/GardenServiceImpl.java

@@ -122,7 +122,14 @@ public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implem
                 .set(updateDTO.getBirdseyeGardenId() != null, Garden::getBirdseyeGardenId, updateDTO.getBirdseyeGardenId())
                 .set(updateDTO.getUserId() != null, Garden::getUserId, updateDTO.getUserId())
                 .set(StrUtil.isNotBlank(updateDTO.getBaseMapUrl()), Garden::getBaseMapUrl, updateDTO.getBaseMapUrl())
-                .set(updateDTO.getStatus() != null, Garden::getStatus, updateDTO.getStatus())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl1()), Garden::getCoverUrl1, updateDTO.getCoverUrl1())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl1Content()), Garden::getCoverUrl1Content, updateDTO.getCoverUrl1Content())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl2()), Garden::getCoverUrl2, updateDTO.getCoverUrl2())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl2Content()), Garden::getCoverUrl2Content, updateDTO.getCoverUrl2Content())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl3()), Garden::getCoverUrl3, updateDTO.getCoverUrl3())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl3Content()), Garden::getCoverUrl3Content, updateDTO.getCoverUrl3Content())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl4()), Garden::getCoverUrl4, updateDTO.getCoverUrl4())
+                .set(StrUtil.isNotBlank(updateDTO.getCoverUrl4Content()), Garden::getCoverUrl4Content, updateDTO.getCoverUrl4Content())
                 .eq(Garden::getId, updateDTO.getId())
                 .update();
     }

+ 14 - 1
admin/src/main/resources/mysql/ddl/init-table.sql

@@ -298,4 +298,17 @@ alter table tb_foster_record
     add column garden_id int default 0 comment '果园id' after app_user_id;
 
 alter table tb_garden
-    add column birdseye_garden_id int default 0 comment '飞鸟看园果园id' after name;
+    add column birdseye_garden_id int default 0 comment '飞鸟看园果园id' after name;
+
+alter table tb_garden
+    add column cover_url1         varchar(255) default '' comment '封面图片1' after qr_code,
+    add column cover_url1_content varchar(500) default '' comment '描述1' after cover_url1,
+    add column cover_url2         varchar(255) default '' comment '封面图片2' after cover_url1_content,
+    add column cover_url2_content varchar(500) default '' comment '描述2' after cover_url2,
+    add column cover_url3         varchar(255) default '' comment '封面图片3' after cover_url2_content,
+    add column cover_url3_content varchar(500) default '' comment '描述3' after cover_url3,
+    add column cover_url4         varchar(255) default '' comment '封面图片4' after cover_url3_content,
+    add column cover_url4_content varchar(500) default '' comment '描述4' after cover_url4;
+
+alter table tb_foster_record
+    add column birdseyeTreeId int default 0 comment '飞鸟看园树id' after tree_id;