Sfoglia il codice sorgente

[update] message:1.添加认养天数接口;2.积分查询条件优化,去掉当天时间的判断

kelei 5 mesi fa
parent
commit
1b96eb5e5f

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

@@ -58,8 +58,8 @@ public class AppFosterRecordController {
     }
 
     /**
-
      * 领养记录-分页
+     *
      * @param current
      * @param size
      * @param queryDTO
@@ -71,11 +71,22 @@ public class AppFosterRecordController {
     }
 
     /**
-* 确认领养     *
+     * 确认领养
+     *
      * @return
      */
     @PostMapping("")
     public R addFosterRecord(@Valid @RequestBody AppFosterRecordAddDTO addDTO) {
         return R.ok().result(iFosterRecordService.addFosterRecord(addDTO));
     }
+
+    /**
+     * 认养天数
+     *
+     * @return
+     */
+    @GetMapping("/foster-days")
+    public R getFosterDays(AppFosterRecordQueryDTO queryDTO) {
+        return R.ok().result(iFosterRecordService.getFosterDays(queryDTO));
+    }
 }

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

@@ -32,4 +32,6 @@ public interface IFosterRecordService extends IService<FosterRecord> {
      * @return
      */
     IPage<AppFosterRecordRespDTO> getPageList(Page<AppFosterRecordRespDTO> page, AppFosterRecordQueryDTO queryDTO);
+
+    Integer getFosterDays(AppFosterRecordQueryDTO queryDTO);
 }

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

@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.Duration;
 import java.time.LocalDateTime;
 import java.util.Collections;
 import java.util.List;
@@ -93,4 +94,16 @@ public class FosterRecordServiceImpl extends ServiceImpl<IFosterRecordMapper, Fo
     public IPage<AppFosterRecordRespDTO> getPageList(Page<AppFosterRecordRespDTO> page, AppFosterRecordQueryDTO queryDTO) {
         return baseMapper.getPageList(page, queryDTO);
     }
+
+    @Override
+    public Integer getFosterDays(AppFosterRecordQueryDTO queryDTO) {
+        FosterRecord fosterRecord = this.lambdaQuery()
+                .eq(FosterRecord::getAppUserId, queryDTO.getAppUserId())
+                .eq(FosterRecord::getGardenId, queryDTO.getGardenId())
+                .eq(FosterRecord::getTreeId, queryDTO.getTreeId())
+                .one();
+        LocalDateTime createdTime = fosterRecord.getCreatedTime();
+        Duration between = Duration.between(createdTime, LocalDateTime.now());
+        return between.toDays() == 0 ? 1 : (int) between.toDays();
+    }
 }

+ 0 - 1
admin/src/main/resources/mapper/ScoreMapper.xml

@@ -8,6 +8,5 @@
         from tb_score
         where app_user_id = #{queryDTO.appUserId}
           and action = #{queryDTO.action}
-          and DATE_FORMAT(created_time, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
     </select>
 </mapper>