Explorar o código

[update] message:1.果园表增加白天背景、夜晚背景字段;2.增加一个生成飞鸟可能园token的接口;

kelei hai 6 meses
pai
achega
2da81e2772

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

@@ -24,10 +24,10 @@ public class AppFosterRecordController {
     private IFosterRecordService iFosterRecordService;
 
     /**
-     * 领养记录列表
+     * 根据果园id查询领养记录
      * @return
      */
-    @GetMapping("/list/{gardenId}/")
+    @GetMapping("/list/{gardenId}")
     public R list(@PathVariable Integer gardenId) {
 //        Integer appUserId = (Integer)StpAppUtil.getLoginId();
         Integer appUserId = 4;

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

@@ -25,7 +25,7 @@ public class AppTreeController {
     private ITreeService iTreeService;
 
     /**
-     * 根据gardenId获取详情
+     * 根据果园id查询树
      * @param gardenId
      * @return
      */

+ 23 - 0
admin/src/main/java/com/flyer/foster/controller/app/AppUserController.java

@@ -2,12 +2,17 @@ package com.flyer.foster.controller.app;
 
 import com.flyer.foster.dto.app.AppUserQueryDTO;
 import com.flyer.foster.service.IAppUserService;
+import com.flyer.util.JwtUtil;
 import com.flyer.util.R;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 小程序用户
  *
@@ -18,10 +23,28 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/app/user")
 public class AppUserController {
     @Autowired
+    private JwtUtil jwtUtil;
+
+    @Autowired
     private IAppUserService iAppUserService;
 
     @RequestMapping("/login")
     public R login(@RequestBody AppUserQueryDTO dto) {
         return R.ok().result(iAppUserService.login(dto));
     }
+
+    /**
+     * 生成飞鸟看园token
+     *
+     * @return
+     */
+    @PostMapping("/generate-birdseye-token")
+    public R generateBirdseyeToken() {
+        String audience = "sysuimars";
+        String subject = "api";
+        Map<String, Object> claims = new HashMap<>();
+        claims.put("userid", 12);
+        String birdseyeToken = jwtUtil.createBirdseyeToken(claims, audience, subject);
+        return R.ok().result(birdseyeToken);
+    }
 }

+ 12 - 0
admin/src/main/java/com/flyer/foster/dto/GardenAddDTO.java

@@ -21,6 +21,18 @@ public class GardenAddDTO {
     @NotBlank(message = "果园名称不能为空")
     private String name;
 
+    /**
+     * 果园白天背景
+     */
+    @NotBlank(message = "白天背景不能为空")
+    private String dayBg;
+
+    /**
+     * 果园夜晚背景
+     */
+    @NotBlank(message = "夜晚背景不能为空")
+    private String nightBg;
+
     @NotNull(message = "飞鸟看园果园id不能为空")
     private Integer birdseyeGardenId;
 

+ 10 - 0
admin/src/main/java/com/flyer/foster/dto/GardenUpdateDTO.java

@@ -22,6 +22,16 @@ public class GardenUpdateDTO {
     private String name;
 
     /**
+     * 果园白天背景
+     */
+    private String dayBg;
+
+    /**
+     * 果园夜晚背景
+     */
+    private String nightBg;
+
+    /**
      * 用户id
      */
     private Integer userId;

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

@@ -10,6 +10,8 @@ import lombok.Data;
  */
 @Data
 public class AppUserRespDTO {
+    private Integer id;
+
     private String gardenId;
 
     private String unionId;

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

@@ -41,6 +41,16 @@ public class Garden implements Serializable {
     private String name;
 
     /**
+     * 果园白天背景
+     */
+    private String dayBg;
+
+    /**
+     * 果园夜晚背景
+     */
+    private String nightBg;
+
+    /**
      * 飞鸟看园果园id
      */
     private Integer birdseyeGardenId;

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

@@ -118,7 +118,9 @@ public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implem
             throw new BusinessException("无效的果园id");
         }
         return this.lambdaUpdate()
-                .set(Garden::getName, updateDTO.getName())
+                .set(StrUtil.isNotBlank(updateDTO.getName()), Garden::getName, updateDTO.getName())
+                .set(StrUtil.isNotBlank(updateDTO.getDayBg()), Garden::getDayBg, updateDTO.getDayBg())
+                .set(StrUtil.isNotBlank(updateDTO.getNightBg()), Garden::getNightBg, updateDTO.getNightBg())
                 .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())

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

@@ -311,4 +311,16 @@ alter table tb_garden
     add column cover_url4_content varchar(500) default '' comment '描述4' after cover_url4;
 
 alter table tb_foster_record
-    add column birdseye_tree_id int default 0 comment '飞鸟看园树id' after tree_id;
+    add column birdseye_tree_id int default 0 comment '飞鸟看园树id' after tree_id;
+
+alter table tb_poster_lib
+    modify start_time varchar(20) default '' comment '开始时间',
+    modify end_time varchar(20) default '' comment '结束时间';
+
+alter table tb_whisper
+    modify start_time varchar(20) default '' comment '开始时间',
+    modify end_time varchar(20) default '' comment '结束时间';
+
+alter table tb_garden
+    add column day_bg   varchar(255) default '' comment '果园白天背景' after name,
+    add column night_bg varchar(255) default '' comment '果园夜晚背景' after day_bg;

+ 39 - 0
common/src/main/java/com/flyer/util/JwtUtil.java

@@ -0,0 +1,39 @@
+package com.flyer.util;
+
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.stereotype.Component;
+
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * JwtUtil
+ *
+ * @author kelei
+ * @since 2022/3/25/10:32
+ */
+@Component
+public class JwtUtil {
+    /**
+     * 使用jwt根据用户名生成token
+     *
+     * @return token
+     */
+    public String createBirdseyeToken(Map<String, Object> claims, String audience, String subject) {
+        return Jwts.builder()
+                .addClaims(claims)
+                .setAudience(audience)
+                .setSubject(subject)
+                .setExpiration(new Date(System.currentTimeMillis() + 604800000))
+                .signWith(SignatureAlgorithm.HS256, this.key()).compact();
+    }
+
+    private SecretKey key() {
+        byte[] encodedKey = Base64.decodeBase64("fast-jwt");
+        return new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES");
+    }
+}