Pārlūkot izejas kodu

[update] message:1.获取最新一张海报(小程序)

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

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

@@ -1,6 +1,6 @@
 package com.flyer.foster.controller.app;
 
-import com.flyer.foster.dto.app.FosterRecordAddDTO;
+import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.flyer.foster.pojo.StpAppUtil;
 import com.flyer.foster.service.IFosterRecordService;
@@ -44,7 +44,7 @@ public class AppFosterRecordController {
      * @return
      */
     @PostMapping("")
-    public R addFosterRecord(@Valid @RequestBody FosterRecordAddDTO addDTO) {
+    public R addFosterRecord(@Valid @RequestBody AppFosterRecordAddDTO addDTO) {
         return R.ok().result(iFosterRecordService.addFosterRecord(addDTO));
     }
 }

+ 32 - 0
admin/src/main/java/com/flyer/foster/controller/app/AppPosterLibController.java

@@ -0,0 +1,32 @@
+package com.flyer.foster.controller.app;
+
+import com.flyer.foster.dto.app.AppPosterLibQueryDTO;
+import com.flyer.foster.service.IPosterLibService;
+import com.flyer.util.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 小程序海报
+ *
+ * @author kelei
+ * @since 2024/5/15/9:32
+ */
+@RestController
+@RequestMapping("/app/poster-lib")
+public class AppPosterLibController {
+    @Autowired
+    private IPosterLibService iPosterLibService;
+
+    /**
+     * 获取最新海报(小程序)
+     *
+     * @return
+     */
+    @GetMapping("/latest")
+    public R getLatestPoster(AppPosterLibQueryDTO queryDTO) {
+        return R.ok().result(iPosterLibService.getLatestPoster(queryDTO));
+    }
+}

+ 26 - 0
admin/src/main/java/com/flyer/foster/controller/app/AppTreePosterContentController.java

@@ -0,0 +1,26 @@
+package com.flyer.foster.controller.app;
+
+import com.flyer.foster.service.ITreePosterContentService;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 小程序果树海报悄悄话
+ *
+ * @author flyer
+ * @since 2024-05-09
+ */
+@RestController
+@RequestMapping("/app/tree-poster-content")
+public class AppTreePosterContentController {
+    @Autowired
+    private ITreePosterContentService iTreePosterContentService;
+
+    @PostMapping("")
+    public R addTreePosterContent() {
+        return R.ok();
+    }
+}

+ 1 - 1
admin/src/main/java/com/flyer/foster/dto/app/FosterRecordAddDTO.java → admin/src/main/java/com/flyer/foster/dto/app/AppFosterRecordAddDTO.java

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
  * @since 2024/5/13/13:50
  */
 @Data
-public class FosterRecordAddDTO {
+public class AppFosterRecordAddDTO {
     /**
      * 用户id
      */

+ 34 - 0
admin/src/main/java/com/flyer/foster/dto/app/AppPosterLibQueryDTO.java

@@ -0,0 +1,34 @@
+package com.flyer.foster.dto.app;
+
+import lombok.Data;
+
+/**
+ * PosterLibAddDTO
+ *
+ * @author kelei
+ * @since 2024/5/10/10:41
+ */
+@Data
+public class AppPosterLibQueryDTO {
+    private Integer id;
+
+    /**
+     * 海报名称
+     */
+    private String name;
+
+    /**
+     * 海报url
+     */
+    private String url;
+
+    /**
+     * 开始时间
+     */
+    private String startTime;
+
+    /**
+     * 结束时间
+     */
+    private String endTime;
+}

+ 67 - 0
admin/src/main/java/com/flyer/foster/dto/app/AppPosterLibRespDTO.java

@@ -0,0 +1,67 @@
+package com.flyer.foster.dto.app;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+ * PosterLibAddDTO
+ *
+ * @author kelei
+ * @since 2024/5/10/10:41
+ */
+@Data
+public class AppPosterLibRespDTO {
+    private Integer id;
+
+    /**
+     * 海报名称
+     */
+    private String name;
+
+    /**
+     * 海报url
+     */
+    private String url;
+
+    /**
+     * 开始时间
+     */
+    private String startTime;
+
+    /**
+     * 结束时间
+     */
+    private String endTime;
+
+    /**
+     * 状态-{0.不可用 1.可用}
+     */
+    private Integer status;
+
+    /**
+     * 租户号
+     */
+    private Integer tenantId;
+
+
+    /**
+     * 创建人
+     */
+    private String createdBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createdTime;
+
+    /**
+     * 更新人
+     */
+    private String updatedBy;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updatedTime;
+}

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

@@ -1,6 +1,6 @@
 package com.flyer.foster.service;
 
-import com.flyer.foster.dto.app.FosterRecordAddDTO;
+import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -19,5 +19,5 @@ public interface IFosterRecordService extends IService<FosterRecord> {
      * @param addDTO
      * @return
      */
-    Integer addFosterRecord(FosterRecordAddDTO addDTO);
+    Integer addFosterRecord(AppFosterRecordAddDTO addDTO);
 }

+ 5 - 0
admin/src/main/java/com/flyer/foster/service/IPosterLibService.java

@@ -5,6 +5,8 @@ import com.flyer.foster.dto.AreaQueryDTO;
 import com.flyer.foster.dto.PosterLibAddDTO;
 import com.flyer.foster.dto.PosterLibQueryDTO;
 import com.flyer.foster.dto.PosterLibRespDTO;
+import com.flyer.foster.dto.app.AppPosterLibQueryDTO;
+import com.flyer.foster.dto.app.AppPosterLibRespDTO;
 import com.flyer.foster.entity.PosterLib;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -21,10 +23,13 @@ import java.util.List;
 public interface IPosterLibService extends IService<PosterLib> {
     /**
      * 物理删除
+     *
      * @param idList
      * @return
      */
     boolean deleteByIdList(List<Integer> idList);
 
     IPage<PosterLibRespDTO> getPageList(IPage<PosterLib> page, PosterLibQueryDTO queryDTO);
+
+    AppPosterLibRespDTO getLatestPoster(AppPosterLibQueryDTO queryDTO);
 }

+ 0 - 2
admin/src/main/java/com/flyer/foster/service/IWhisperService.java

@@ -1,8 +1,6 @@
 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.PosterLibQueryDTO;
 import com.flyer.foster.dto.WhisperQueryDTO;
 import com.flyer.foster.dto.WhisperRespDTO;
 import com.flyer.foster.entity.Whisper;

+ 2 - 4
admin/src/main/java/com/flyer/foster/service/impl/FosterRecordServiceImpl.java

@@ -2,9 +2,8 @@ package com.flyer.foster.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.flyer.exception.BusinessException;
-import com.flyer.foster.dto.app.FosterRecordAddDTO;
+import com.flyer.foster.dto.app.AppFosterRecordAddDTO;
 import com.flyer.foster.entity.FosterRecord;
 import com.flyer.foster.entity.Garden;
 import com.flyer.foster.mapper.IFosterRecordMapper;
@@ -19,7 +18,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -43,7 +41,7 @@ public class FosterRecordServiceImpl extends ServiceImpl<IFosterRecordMapper, Fo
 
     @Transactional
     @Override
-    public Integer addFosterRecord(FosterRecordAddDTO addDTO) {
+    public Integer addFosterRecord(AppFosterRecordAddDTO addDTO) {
         int tenantId = StpAppUtil.getTokenSession().getInt("tenantId");
         // 一个用户在同一个果园只能认领一棵树
         FosterRecord fosterRecord = this.lambdaQuery()

+ 17 - 0
admin/src/main/java/com/flyer/foster/service/impl/PosterLibServiceImpl.java

@@ -6,12 +6,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.flyer.foster.dto.PosterLibQueryDTO;
 import com.flyer.foster.dto.PosterLibRespDTO;
+import com.flyer.foster.dto.app.AppPosterLibQueryDTO;
+import com.flyer.foster.dto.app.AppPosterLibRespDTO;
 import com.flyer.foster.entity.PosterLib;
 import com.flyer.foster.mapper.IPosterLibMapper;
 import com.flyer.foster.service.IPosterLibService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -49,4 +52,18 @@ public class PosterLibServiceImpl extends ServiceImpl<IPosterLibMapper, PosterLi
         pageResult.setTotal(pageInfo.getTotal());
         return pageResult;
     }
+
+    @Override
+    public AppPosterLibRespDTO getLatestPoster(AppPosterLibQueryDTO queryDTO) {
+        LocalDateTime now = LocalDateTime.now();
+        PosterLib posterLib = this.lambdaQuery()
+                .le(PosterLib::getStartTime, now)
+                .ge(PosterLib::getEndTime, now)
+                .orderByDesc(PosterLib::getId)
+                .last("limit 1")
+                .one();
+        AppPosterLibRespDTO respDTO = new AppPosterLibRespDTO();
+        BeanUtil.copyProperties(posterLib, respDTO);
+        return respDTO;
+    }
 }

+ 0 - 2
admin/src/main/java/com/flyer/foster/service/impl/WhisperServiceImpl.java

@@ -4,10 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.flyer.foster.dto.PosterLibRespDTO;
 import com.flyer.foster.dto.WhisperQueryDTO;
 import com.flyer.foster.dto.WhisperRespDTO;
-import com.flyer.foster.entity.PosterLib;
 import com.flyer.foster.entity.Whisper;
 import com.flyer.foster.mapper.IWhisperMapper;
 import com.flyer.foster.service.IWhisperService;