Ver Fonte

Merge remote-tracking branch 'origin/master'

李进 há 2 anos atrás
pai
commit
0b82a64d98

+ 3 - 0
sys-api-service/src/main/java/com/xy/entity/MsgSysMonitorNotice.java

@@ -50,6 +50,9 @@ public class MsgSysMonitorNotice implements Serializable {
 
     @ApiModelProperty(value = "发送类型")
     private String channelType;
+    
+    @ApiModelProperty(value = "事件编码")
+    private String eventCode;
 
     @ApiModelProperty(value = "发布状态")
     private Integer pubState;

+ 31 - 4
sys-api-service/src/main/java/com/xy/service/MsgUserMessageServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xy.service;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -47,13 +48,24 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
     public R<MsgUserMessageDto.Vo> obj(MsgUserMessageDto.Vo vo) {
         MsgUserMessageDto.SelectList selectList = copy(MsgUserMessageDto.SelectList.class, vo);
         List<MsgUserMessageDto.Vo> list = list(selectList).getData();
+        MsgUserMessageDto.Vo myMsg = new MsgUserMessageDto.Vo();
         if (Emptys.check(list)) {
-            MsgUserMessageDto.Vo myMsg = list.get(0);
+            myMsg = list.get(0);
             //更新已读
-            this.updateById(new MsgUserMessage().setId(myMsg.getId()).setReadState(MsgReadStatus.READ.getCode().toString()));
+            MsgUserMessage msgUserMessage = new MsgUserMessage();
+            msgUserMessage.setId(myMsg.getId()).setReadState(MsgReadStatus.READ.getCode().toString());
+            if (ObjectUtil.isNotEmpty(myMsg)) {
+                Long msgId = myMsg.getMsgId();
+                MsgSysMonitorNotice msgSysMonitorNotice = msgSysMonitorNoticeService.getById(msgId);
+                if (ObjectUtil.isNotEmpty(msgSysMonitorNotice)) {
+                    myMsg.setContent(msgSysMonitorNotice.getContent());
+                    myMsg.setTitle(msgSysMonitorNotice.getTitle());
+                }
+            }
+            this.updateById(msgUserMessage);
             return R.ok(myMsg);
         }
-        return R.ok();
+        return R.ok(myMsg);
     }
 
     public R<List<MsgUserMessageDto.Vo>> list(MsgUserMessageDto.SelectList selectList) {
@@ -71,6 +83,21 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
         return R.ok(count);
     }
 
+    @ApiOperation("我的消息-标记全部已读")
+    @Override
+    public R<Boolean> readAll() {
+        Long loginId = AuthorizeUtils.getLoginId(Long.class);
+        List<MsgUserMessage> list = this.list(Wrappers.<MsgUserMessage>lambdaQuery()
+                .eq(MsgUserMessage::getUserId, loginId)
+                .eq(MsgUserMessage::getReadState, MsgReadStatus.UN_READ.getCode()));
+        if (CollUtil.isNotEmpty(list)) {
+            list.forEach(mum -> {
+                mum.setReadState(String.valueOf(MsgReadStatus.READ.getCode()));
+            });
+            this.saveOrUpdateBatch(list);
+        }
+        return R.ok(Boolean.TRUE);
+    }
 
     @ApiOperation("我的消息")
     @Override
@@ -80,7 +107,7 @@ public class MsgUserMessageServiceImpl extends ServiceImpl<MsgUserMessageMapper,
         LambdaQueryWrapper<MsgUserMessage> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, MsgUserMessage.class)
                 .ge(MsgUserMessage::getCreateTime, page.getBeginCreateTime())
                 .le(MsgUserMessage::getCreateTime, page.getEndCreateTime())
-                .build().orderByAsc(MsgUserMessage::getPriority);
+                .build().orderByDesc(MsgUserMessage::getCreateTime);
         IPage<MsgUserMessage> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
         PageBean<MsgUserMessageDto.PageVO> pageVo = toPageBean(MsgUserMessageDto.PageVO.class, iPage);
         List<MsgUserMessageDto.PageVO> records = pageVo.getRecords();

+ 3 - 0
sys-api/src/main/java/com/xy/dto/MsgSysMonitorNoticeDto.java

@@ -57,6 +57,9 @@ public class MsgSysMonitorNoticeDto {
         @ApiModelProperty(value = "消息类型")
         private Integer msgType;
 
+        @ApiModelProperty(value = "事件编码")
+        private String eventCode;
+
         @ApiModelProperty(value = "消息标题")
         private String title;
 

+ 6 - 0
sys-api/src/main/java/com/xy/dto/MsgUserMessageDto.java

@@ -147,6 +147,12 @@ public class MsgUserMessageDto {
         @ApiModelProperty("优先级")
         private Integer priority;
 
+        @ApiModelProperty(value = "消息标题")
+        private String title;
+
+        @ApiModelProperty(value = "内容")
+        private String content;
+
 
     }
 

+ 3 - 0
sys-api/src/main/java/com/xy/service/MsgUserMessageService.java

@@ -25,6 +25,9 @@ public interface MsgUserMessageService {
     @PostMapping("unRead")
     R<Long> myMsgUnRead();
 
+    @PostMapping("readAll")
+    R<Boolean> readAll();
+
     @PostMapping("myMsg")
     R<PageBean<MsgUserMessageDto.PageVO>> myMsgPage(@RequestBody MsgUserMessageDto.Page page);
 

+ 168 - 3
sys-sdk/src/main/java/com/xy/utils/SysCodeConfigureUtils.java

@@ -1,10 +1,14 @@
 package com.xy.utils;
 
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.xy.entity.SysCodeConfigureRedis;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 系统编码工具类
@@ -53,4 +57,165 @@ public class SysCodeConfigureUtils {
     public static Map<String, SysCodeConfigureRedis> all() {
         return getRedisService().getMap(SYS_CODE_CONFIGURE_PREFIX);
     }
+
+    /**
+     * 递归获取子类
+     *
+     * @param code
+     * @param stringSysCodeConfigureRedisMap
+     * @return {@link Map}<{@link String}, {@link SysCodeConfigureRedis}>
+     */
+    public static Map<String, SysCodeConfigureRedis> getChildrenMap(String code, Map<String, SysCodeConfigureRedis> stringSysCodeConfigureRedisMap) {
+        Map<String, SysCodeConfigureRedis> childrenMap = MapUtil.newHashMap();
+        if (Emptys.check(code)) {
+            stringSysCodeConfigureRedisMap.forEach((codeStr, sysCodeConfigureRedis) -> {
+                if (!Emptys.check(sysCodeConfigureRedis.getPaterCode())) {
+                    return;
+                }
+                if (sysCodeConfigureRedis.getPaterCode().equals(code)) {
+                    childrenMap.put(codeStr, sysCodeConfigureRedis);
+                    Map<String, SysCodeConfigureRedis> map = getChildrenMap(codeStr, stringSysCodeConfigureRedisMap);
+                    if (MapUtil.isNotEmpty(map)) {
+                        childrenMap.putAll(map);
+                    }
+                }
+            });
+        }
+        return childrenMap;
+    }
+
+
+    /**
+     * 根据父代码获取其子类(排除自身)
+     *
+     * @param parentCode 父代码
+     * @return {@link Map}<{@link String}, {@link SysCodeConfigureRedis}>
+     */
+    public static Map<String, SysCodeConfigureRedis> getChildrenByParentCode(String parentCode) {
+        Map<String, SysCodeConfigureRedis> all = all();
+        return getChildrenMap(parentCode, all);
+    }
+
+
+    /**
+     * 获取扩展参数
+     *
+     * @param expand 扩大
+     * @return {@link JSONObject}
+     */
+    public static JSONObject getExpand(String expand) {
+        return JSONUtil.parseObj(expand);
+    }
+
+    /**
+     * 获取扩展通知设置
+     *
+     * @param expand 扩大
+     * @return {@link JSONObject}
+     */
+    public static JSONObject getExpandNoticeSet(String expand) {
+        return JSONUtil.parseObj(expand).getJSONObject("noticeSets");
+    }
+
+    /**
+     * 是否展示给商户
+     *
+     * @param expand
+     * @return {@link Boolean}
+     */
+    public static Boolean getExpShow2Merc(String expand) {
+        JSONObject exp = getExpandNoticeSet(expand);
+        return exp.getBool("show2merc");
+    }
+
+    /**
+     * 是否推送给商户
+     *
+     * @param expand
+     * @return {@link Boolean}
+     */
+    public static Boolean getExpPush2Merc(String expand) {
+        JSONObject exp = getExpandNoticeSet(expand);
+        return exp.getBool("push2merc");
+    }
+
+    /**
+     * 是否可取消订阅
+     *
+     * @param expand
+     * @return {@link Boolean}
+     */
+    public static Boolean getExpCanUnSubscribe(String expand) {
+        JSONObject exp = getExpandNoticeSet(expand);
+        return exp.getBool("canUnsubscribe");
+    }
+
+    /**
+     * 得到标记
+     *
+     * @param expand
+     * @return {@link String}
+     */
+    public static String getMarker(String expand) {
+        JSONObject exp = getExpandNoticeSet(expand);
+        return exp.getStr("marker");
+    }
+
+    /**
+     * 获取是否可推送
+     *
+     * @param expand 扩大
+     * @return {@link Boolean}
+     */
+    public static Boolean getExpCanPush(String expand) {
+        JSONObject exp = getExpandNoticeSet(expand);
+        //禁止推送时间段,只针对公众号消息,短信等 (为了免打扰!)
+        String unPushTime = exp.getStr("unpushtime");
+        if (StrUtil.isEmpty(unPushTime)) {
+            //没有配置。默认可推送
+            return Boolean.TRUE;
+        }
+        //有配置按配置来,获取配置 如: "23:00-24:00,00:00-06:00"
+        String[] timeArray = unPushTime.split(StrUtil.COMMA);
+        if (timeArray.length == 1) {
+            //1个时间段
+            String timeStr = timeArray[0];
+            if (!timeCheck(timeStr)) {
+                return Boolean.FALSE;
+            }
+        }
+        if (timeArray.length == 2) {
+            //2个时间段
+            String timeStr = timeArray[0];
+            // 判断当前时间是否在时间范围内
+            if (!timeCheck(timeStr)) {
+                return Boolean.FALSE;
+            }
+            String timeStr2 = timeArray[1];
+            if (!timeCheck(timeStr2)) {
+                return Boolean.FALSE;
+            }
+
+        }
+        return Boolean.TRUE;
+    }
+
+    /**
+     * 时间检查
+     *
+     * @param timeStr
+     * @return {@link Boolean}
+     */
+    public static Boolean timeCheck(String timeStr) {
+        String monthDate = DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN) + " ";
+        String startTime = monthDate + timeStr.split(StrUtil.DASHED)[0] + ":00";
+        String endTime = monthDate + timeStr.split(StrUtil.DASHED)[1] + ":00";
+        // 判断当前时间是否在时间范围内
+        if (DateUtil.isIn(DateUtil.date(), DateUtil.parseDateTime(startTime), DateUtil.parseDateTime(endTime))) {
+            return Boolean.FALSE;
+        }
+        return Boolean.TRUE;
+    }
+
+
 }