gongchunyi
3 天以前 469a106cf617efd2e9fbe02937c355fa392ae7bc
feat: 消息通知添加APP跳转路由
已修改4个文件
18 ■■■■ 文件已修改
src/main/java/com/ruoyi/project/system/domain/SysNotice.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/system/SysNoticeMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/project/system/domain/SysNotice.java
@@ -48,6 +48,9 @@
    /** 跳转路径 */
    private String jumpPath;
    /** APP跳转路径 */
    private String appJumpPath;
    /** 创建者 */
    @TableField(fill = FieldFill.INSERT)
    private String createBy;
src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
@@ -144,10 +144,12 @@
    }
    @Override
    public void simpleNoticeByUser(String title, String message,  List<Long> consigneeId, String jumpPath) {
    public void simpleNoticeByUser(String title, String message, List<Long> consigneeId, String jumpPath) {
        Long userId = SecurityUtils.getLoginUser().getUserId();
        Long tenantId = SecurityUtils.getLoginUser().getTenantId();
        List<SysNotice> sysNotices = consigneeId.stream().map(it -> convertSysNotice(title, message, it,tenantId, jumpPath, userId)).collect(Collectors.toList());
        List<SysNotice> sysNotices = consigneeId.stream()
                .map(it -> convertSysNotice(title, message, it, tenantId, jumpPath, unipushService.convertWebPathToAppPath(jumpPath), userId))
                .collect(Collectors.toList());
        sysNoticeService.saveBatch(sysNotices);
        try {
            unipushService.sendClientMessage(sysNotices);
@@ -200,6 +202,7 @@
                        it.getUserId(),
                        it.getTenantId(),
                        jumpPath,
                        unipushService.convertWebPathToAppPath(jumpPath),
                        userId
                ))
                .collect(Collectors.toList());
@@ -213,7 +216,7 @@
    }
    private SysNotice convertSysNotice(String title,String message,Long consigneeId, Long tenantId,String jumpPath,Long currentUserId) {
    private SysNotice convertSysNotice(String title,String message,Long consigneeId, Long tenantId,String jumpPath,String appJumpPath,Long currentUserId) {
        SysNotice sysNotice = new SysNotice();
        sysNotice.setNoticeType("1");
        sysNotice.setNoticeTitle(title);//标题
@@ -222,6 +225,7 @@
        sysNotice.setConsigneeId(consigneeId);
        sysNotice.setSenderId(currentUserId);
        sysNotice.setJumpPath(jumpPath);
        sysNotice.setAppJumpPath(appJumpPath);
        sysNotice.setTenantId(tenantId);
        return sysNotice;
    }
src/main/java/com/ruoyi/project/system/service/impl/UnipushService.java
@@ -95,7 +95,7 @@
    /**
     * 将 Web 端分层全路径转换为 App 端组件路由
     */
    private String convertWebPathToAppPath(String webPath) {
    public String convertWebPathToAppPath(String webPath) {
        if (StringUtils.isEmpty(webPath)) {
            return DEFAULT_APP_PAGE;
        }
src/main/resources/mapper/system/SysNoticeMapper.xml
@@ -31,6 +31,7 @@
               sender_id,
               consignee_id,
               jump_path,
               app_jump_path,
               tenant_id
        from sys_notice
    </sql>
@@ -75,6 +76,7 @@
        <if test="senderId != null and senderId != ''">sender_id,</if>
        <if test="consigneeId != null and consigneeId != ''">consignee_id,</if>
        <if test="jumpPath != null and jumpPath != ''">jump_path,</if>
        <if test="appJumpPath != null and appJumpPath != ''">app_jump_path,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="tenantId != null and tenantId != ''">tenant_id,</if>
             create_time
@@ -87,6 +89,7 @@
        <if test="senderId != null and senderId != ''">#{senderId},</if>
        <if test="consigneeId != null and consigneeId != ''">#{consigneeId},</if>
        <if test="jumpPath != null and jumpPath != ''">#{jumpPath},</if>
        <if test="appJumpPath != null and appJumpPath != ''">#{appJumpPath},</if>
        <if test="pathParms != null and pathParms != ''">#{queryParms},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="tenantId != null and tenantId != ''">#{tenantId},</if>