Эх сурвалжийг харах

fix 新增小程序首页接口

Administrator 4 жил өмнө
parent
commit
7a8993cf22

+ 10 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java

@@ -202,6 +202,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return new Date(time);
     }
 
+
+    /**
+     * 转为年月日
+     * @param stamp 传入时间格式
+     * @return
+     */
+    public static String formatDate (Object date, String stamp) {
+        return new SimpleDateFormat(stamp).format(date);
+    }
+
     /**
      * 计算两个时间差
      */

+ 1 - 1
boman-modules/boman-system/src/main/resources/mapper/system/BomanGroupMapper.xml

@@ -59,7 +59,7 @@
 
     <select id="checkGroupNameUnique" resultMap="BomanGroupResult">
         <include refid="selectGroupVo"/>
-        where group_name=#{GroupName} and is_del = 'N' limit 1
+        where group_name=#{groupName} and is_del = 'N' limit 1
     </select>
 
     <insert id="insertGroup" parameterType="com.boman.domain.BomanGroup">

+ 12 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/BomanMessageReceiveController.java

@@ -28,4 +28,16 @@ public class BomanMessageReceiveController {
     public AjaxResult getUserNameAndDeptName(@PathVariable("messageId") String messageId) {
         return bomanMessageReceiveService.getUserNameAndDeptName(messageId);
     }
+
+    /**
+     * 小程序首页统计
+     * @param userId
+     * @return
+     */
+    @GetMapping("/index/{userId}")
+    public AjaxResult getIndexInfo(@PathVariable("userId") String userId) {
+        AjaxResult indexInfo = bomanMessageReceiveService.getIndexInfo(userId);
+        return indexInfo;
+    }
+
 }

+ 44 - 3
boman-web-core/src/main/java/com/boman/web/core/service/bomanMessageReceive/BomanMessageReceiveServiceImpl.java

@@ -1,15 +1,14 @@
 package com.boman.web.core.service.bomanMessageReceive;
 
 import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.utils.StringUtils;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.web.core.service.select.IBaseSelectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @author tjf
@@ -45,4 +44,46 @@ public class BomanMessageReceiveServiceImpl implements IBomanMessageReceiveServi
         }
         return Objects.requireNonNull(AjaxResult.success().put("receiveUserNameList", receiveUserNameList)).put("receiveDeptNameList",receiveDeptNameList);
     }
+
+    /**
+     * 小程序首页统计
+     * @param userId
+     * @return
+     */
+    @Override
+    public AjaxResult getIndexInfo(String userId) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("send_user_id",userId);
+        //备注,boman_message表中create_time需要在gen_table_column中设置like
+        jsonObject.put("create_time", DateUtils.getDate());
+        jsonObject.put("message_situation","1");
+        //查询今日发文
+        List<JSONObject> bomanMessage = selectService.getByMap("boman_message", jsonObject);
+        long toDaySend = 0;
+        if (bomanMessage != null && bomanMessage.size() > 0){
+            toDaySend = bomanMessage.size();
+        }
+        JSONObject jsonObjectTwo = new JSONObject();
+        jsonObjectTwo.put("receive_user_id",userId);
+        jsonObjectTwo.put("visible","Y");
+        List<JSONObject> bomanMessageReceive = selectService.getByMap("boman_message_receive", jsonObjectTwo);
+        long unread = 0L;
+        long read = 0L;
+        long todayReceipt = 0L;
+        if (bomanMessageReceive != null && bomanMessageReceive.size() > 0){
+            //未读
+             unread = bomanMessageReceive.stream().filter(e -> e.get("status") == "N").count();
+            //已读
+             read = bomanMessageReceive.stream().filter(e -> e.get("status") == "Y").count();
+            //今日收文
+             todayReceipt = bomanMessageReceive.stream().filter(e -> DateUtils.formatDate(e.get("send_message_time"), DateUtils.YYYY_MM_DD).equals(DateUtils.getDate())).count();
+        }
+
+        Map<String,Long> map = new HashMap<>();
+        map.put("toDaySend", toDaySend);
+        map.put("unread", unread);
+        map.put("read", read);
+        map.put("todayReceipt", todayReceipt);
+        return AjaxResult.success(map);
+    }
 }

+ 7 - 0
boman-web-core/src/main/java/com/boman/web/core/service/bomanMessageReceive/IBomanMessageReceiveService.java

@@ -14,4 +14,11 @@ public interface IBomanMessageReceiveService {
      * @return
      */
     AjaxResult getUserNameAndDeptName(String messageId);
+
+    /**
+     * 小程序首页统计
+     * @param userId
+     * @return
+     */
+    AjaxResult getIndexInfo(String userId);
 }