初始代码
This commit is contained in:
21
yunzhupaas-message/pom.xml
Normal file
21
yunzhupaas-message/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-java-boot</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-message</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yunzhupaas-message-entity</module>
|
||||
<module>yunzhupaas-message-biz</module>
|
||||
<module>yunzhupaas-message-controller</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
36
yunzhupaas-message/yunzhupaas-message-biz/pom.xml
Normal file
36
yunzhupaas-message/yunzhupaas-message-biz/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-message</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-message-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-permission-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-system-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yunzhupaas.message.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWarDeployment;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableAutoConfiguration
|
||||
public class WebsocketConfig {
|
||||
|
||||
/**
|
||||
* 支持websocket
|
||||
* 如果不使用内置tomcat,则无需配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnNotWarDeployment
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.AccountConfigEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 账号配置功能
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface AccountConfigMapper extends SuperMapper<AccountConfigEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.ImContentEntity;
|
||||
import com.yunzhupaas.message.model.ImUnreadNumModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 聊天内容
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
public interface ImContentMapper extends SuperMapper<ImContentEntity> {
|
||||
|
||||
List<ImUnreadNumModel> getUnreadList(@Param("receiveUserId") String receiveUserId);
|
||||
|
||||
List<ImUnreadNumModel> getUnreadLists(@Param("receiveUserId") String receiveUserId);
|
||||
|
||||
int readMessage(@Param("map") Map<String, String> map);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.ImReplyEntity;
|
||||
import com.yunzhupaas.message.model.ImReplyListModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天会话
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-28
|
||||
*/
|
||||
public interface ImReplyMapper extends SuperMapper<ImReplyEntity> {
|
||||
|
||||
/**
|
||||
* 聊天会话列表
|
||||
* @return
|
||||
*/
|
||||
List<ImReplyListModel> getImReplyList();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.MessageEntity;
|
||||
import com.yunzhupaas.message.entity.MessageReceiveEntity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息实例
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
public interface MessageMapper extends SuperMapper<MessageEntity> {
|
||||
|
||||
List<MessageReceiveEntity> getMessageList(@Param("map") Map<String, Object> map);
|
||||
|
||||
int getUnreadCount(@Param("userId") String userId,@Param("type") Integer type);
|
||||
|
||||
List<MessageEntity> getInfoDefault(@Param("type") int type);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.MessageMonitorEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息监控
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-22
|
||||
*/
|
||||
public interface MessageMonitorMapper extends SuperMapper<MessageMonitorEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.MessageTemplateConfigEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface MessageTemplateConfigMapper extends SuperMapper<MessageTemplateConfigEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.MessageReceiveEntity;
|
||||
|
||||
/**
|
||||
* 消息接收
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
public interface MessagereceiveMapper extends SuperMapper<MessageReceiveEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.SendConfigTemplateEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息发送配置
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-19
|
||||
*/
|
||||
public interface SendConfigTemplateMapper extends SuperMapper<SendConfigTemplateEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.SendMessageConfigEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息发送配置
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-19
|
||||
*/
|
||||
public interface SendMessageConfigMapper extends SuperMapper<SendMessageConfigEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.ShortLinkEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface ShortLInkMapper extends SuperMapper<ShortLinkEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.SmsFieldEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface SmsFieldMapper extends SuperMapper<SmsFieldEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.SynThirdInfoEntity;
|
||||
|
||||
/**
|
||||
* 第三方工具对象同步表
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/23 17:25
|
||||
*/
|
||||
public interface SynThirdInfoMapper extends SuperMapper<SynThirdInfoEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.TemplateParamEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface TemplateParamMapper extends SuperMapper<TemplateParamEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.UserDeviceEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface UserDeviceMapper extends SuperMapper<UserDeviceEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.message.mapper;
|
||||
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.message.entity.WechatUserEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface WechatUserMapper extends SuperMapper<WechatUserEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.yunzhupaas.message.service;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yunzhupaas.base.PageModel;
|
||||
import com.yunzhupaas.message.entity.ImContentEntity;
|
||||
import com.yunzhupaas.message.model.ImUnreadNumModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天内容
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
public interface ImContentService extends SuperService<ImContentEntity> {
|
||||
|
||||
/**
|
||||
* 获取消息列表
|
||||
*
|
||||
* @param sendUserId 发送者
|
||||
* @param receiveUserId 接收者
|
||||
* @param pageModel
|
||||
* @return
|
||||
*/
|
||||
List<ImContentEntity> getMessageList(String sendUserId, String receiveUserId, PageModel pageModel);
|
||||
|
||||
/**
|
||||
* 获取未读消息
|
||||
*
|
||||
* @param receiveUserId 接收者
|
||||
* @return
|
||||
*/
|
||||
List<ImUnreadNumModel> getUnreadList(String receiveUserId);
|
||||
|
||||
/**
|
||||
* 获取未读消息
|
||||
*
|
||||
* @param receiveUserId 接收者
|
||||
* @return
|
||||
*/
|
||||
int getUnreadCount(String sendUserId, String receiveUserId);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param sendUserId 发送者
|
||||
* @param receiveUserId 接收者
|
||||
* @param message 消息内容
|
||||
* @param messageType 消息类型
|
||||
* @return
|
||||
*/
|
||||
void sendMessage(String sendUserId, String receiveUserId, String message, String messageType);
|
||||
|
||||
/**
|
||||
* 已读消息
|
||||
*
|
||||
* @param sendUserId 发送者
|
||||
* @param receiveUserId 接收者
|
||||
* @return
|
||||
*/
|
||||
void readMessage(String sendUserId, String receiveUserId);
|
||||
/**
|
||||
* 删除聊天记录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean deleteChatRecord(String sendUserId, String receiveUserId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.yunzhupaas.message.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yunzhupaas.message.entity.ImReplyEntity;
|
||||
import com.yunzhupaas.message.model.ImReplyListModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天会话
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
public interface ImReplyService extends SuperService<ImReplyEntity> {
|
||||
|
||||
/**
|
||||
* 获取消息会话列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<ImReplyEntity> getList();
|
||||
|
||||
/**
|
||||
* 保存聊天会话
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
boolean savaImReply(ImReplyEntity entity);
|
||||
|
||||
/**
|
||||
* 获取聊天会话列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<ImReplyListModel> getImReplyList();
|
||||
|
||||
/**
|
||||
* 移除聊天会话列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean relocation(String sendUserId,String receiveUserId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.message.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import com.yunzhupaas.message.entity.UserDeviceEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
public interface UserDeviceService extends SuperService<UserDeviceEntity> {
|
||||
|
||||
UserDeviceEntity getInfoByUserId(String userId);
|
||||
|
||||
List<String> getCidList(String userId);
|
||||
|
||||
UserDeviceEntity getInfoByClientId(String clientId);
|
||||
|
||||
void create(UserDeviceEntity entity);
|
||||
|
||||
boolean update(String id, UserDeviceEntity entity);
|
||||
|
||||
void delete(UserDeviceEntity entity);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.database.model.superQuery.ConditionJsonModel;
|
||||
import com.yunzhupaas.database.model.superQuery.SuperQueryConditionModel;
|
||||
import com.yunzhupaas.entity.*;
|
||||
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.AccountConfigEntity;
|
||||
import com.yunzhupaas.message.mapper.AccountConfigMapper;
|
||||
import com.yunzhupaas.message.model.accountconfig.*;
|
||||
import com.yunzhupaas.message.service.AccountConfigService;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
import java.lang.reflect.Field;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.yunzhupaas.util.visiual.YunzhupaasKeyConsts;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 账号配置功能
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class AccountConfigServiceImpl extends SuperServiceImpl<AccountConfigMapper, AccountConfigEntity>
|
||||
implements AccountConfigService {
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Override
|
||||
public List<AccountConfigEntity> getList(AccountConfigPagination accountConfigPagination) {
|
||||
return getTypeList(accountConfigPagination, accountConfigPagination.getDataType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountConfigEntity> getTypeList(AccountConfigPagination accountConfigPagination, String dataType) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
int total = 0;
|
||||
int accountConfigNum = 0;
|
||||
QueryWrapper<AccountConfigEntity> accountConfigQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
// 关键字
|
||||
if (StringUtil.isNotBlank(accountConfigPagination.getKeyword())
|
||||
&& !"null".equals(accountConfigPagination.getKeyword())) {
|
||||
accountConfigNum++;
|
||||
accountConfigQueryWrapper.lambda()
|
||||
.and(t -> t.like(AccountConfigEntity::getEnCode, accountConfigPagination.getKeyword())
|
||||
.or().like(AccountConfigEntity::getFullName, accountConfigPagination.getKeyword()).or()
|
||||
.like(AccountConfigEntity::getAddressorName, accountConfigPagination.getKeyword())
|
||||
.or().like(AccountConfigEntity::getSmtpUser, accountConfigPagination.getKeyword()).or()
|
||||
.like(AccountConfigEntity::getSmsSignature, accountConfigPagination.getKeyword()));
|
||||
}
|
||||
// webhook类型
|
||||
if (ObjectUtil.isNotEmpty(accountConfigPagination.getWebhookType())) {
|
||||
accountConfigNum++;
|
||||
accountConfigQueryWrapper.lambda().eq(AccountConfigEntity::getWebhookType,
|
||||
accountConfigPagination.getWebhookType());
|
||||
}
|
||||
// 渠道
|
||||
if (ObjectUtil.isNotEmpty(accountConfigPagination.getChannel())) {
|
||||
accountConfigNum++;
|
||||
accountConfigQueryWrapper.lambda().eq(AccountConfigEntity::getChannel,
|
||||
accountConfigPagination.getChannel());
|
||||
}
|
||||
// 状态
|
||||
if (ObjectUtil.isNotEmpty(accountConfigPagination.getEnabledMark())) {
|
||||
accountConfigNum++;
|
||||
int enabledMark = Integer.parseInt(accountConfigPagination.getEnabledMark());
|
||||
accountConfigQueryWrapper.lambda().eq(AccountConfigEntity::getEnabledMark, enabledMark);
|
||||
}
|
||||
// 配置类型
|
||||
if (ObjectUtil.isNotEmpty(accountConfigPagination.getType())) {
|
||||
accountConfigNum++;
|
||||
accountConfigQueryWrapper.lambda().eq(AccountConfigEntity::getType, accountConfigPagination.getType());
|
||||
}
|
||||
|
||||
// 排序
|
||||
if (StringUtil.isEmpty(accountConfigPagination.getSidx())) {
|
||||
accountConfigQueryWrapper.lambda().orderByAsc(AccountConfigEntity::getSortCode)
|
||||
.orderByDesc(AccountConfigEntity::getCreatorTime)
|
||||
.orderByDesc(AccountConfigEntity::getLastModifyTime);
|
||||
} else {
|
||||
try {
|
||||
String sidx = accountConfigPagination.getSidx();
|
||||
AccountConfigEntity accountConfigEntity = new AccountConfigEntity();
|
||||
Field declaredField = accountConfigEntity.getClass().getDeclaredField(sidx);
|
||||
declaredField.setAccessible(true);
|
||||
String value = declaredField.getAnnotation(TableField.class).value();
|
||||
accountConfigQueryWrapper = "asc".equals(accountConfigPagination.getSort().toLowerCase())
|
||||
? accountConfigQueryWrapper.orderByAsc(value)
|
||||
: accountConfigQueryWrapper.orderByDesc(value);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!"1".equals(dataType)) {
|
||||
if (total > 0 || total == 0) {
|
||||
Page<AccountConfigEntity> page = new Page<>(accountConfigPagination.getCurrentPage(),
|
||||
accountConfigPagination.getPageSize());
|
||||
IPage<AccountConfigEntity> userIPage = this.page(page, accountConfigQueryWrapper);
|
||||
return accountConfigPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
||||
} else {
|
||||
List<AccountConfigEntity> list = new ArrayList();
|
||||
return accountConfigPagination.setData(list, list.size());
|
||||
}
|
||||
} else {
|
||||
return this.list(accountConfigQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountConfigEntity getInfo(String id) {
|
||||
QueryWrapper<AccountConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(AccountConfigEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, AccountConfigEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(AccountConfigEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
// 子表方法
|
||||
|
||||
// 列表子表数据方法
|
||||
|
||||
// 验证表单唯一字段
|
||||
@Override
|
||||
public boolean checkForm(AccountConfigForm form, int i, String type, String id) {
|
||||
int total = 0;
|
||||
if (ObjectUtil.isNotEmpty(form.getEnCode())) {
|
||||
QueryWrapper<AccountConfigEntity> codeWrapper = new QueryWrapper<>();
|
||||
codeWrapper.lambda().eq(AccountConfigEntity::getEnCode, form.getEnCode());
|
||||
codeWrapper.lambda().eq(AccountConfigEntity::getType, type);
|
||||
if (StringUtil.isNotBlank(id) && !"null".equals(id)) {
|
||||
codeWrapper.lambda().ne(AccountConfigEntity::getId, id);
|
||||
}
|
||||
total += (int) this.count(codeWrapper);
|
||||
}
|
||||
int c = 0;
|
||||
if (total > i + c) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkGzhId(String gzhId, int i, String type, String id) {
|
||||
int total = 0;
|
||||
if (StringUtil.isNotEmpty(gzhId) && !"null".equals(gzhId)) {
|
||||
QueryWrapper<AccountConfigEntity> codeWrapper = new QueryWrapper<>();
|
||||
codeWrapper.lambda().eq(AccountConfigEntity::getAppKey, gzhId);
|
||||
codeWrapper.lambda().eq(AccountConfigEntity::getType, type);
|
||||
if (StringUtil.isNotBlank(id) && !"null".equals(id)) {
|
||||
codeWrapper.lambda().ne(AccountConfigEntity::getId, id);
|
||||
}
|
||||
total += (int) this.count(codeWrapper);
|
||||
}
|
||||
int c = 0;
|
||||
if (total > i + c) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountConfigEntity getInfoByType(String appKey, String type) {
|
||||
QueryWrapper<AccountConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getType, type);
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getAppKey, appKey);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountConfigEntity getInfoByEnCode(String enCode, String type) {
|
||||
QueryWrapper<AccountConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getType, type);
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getEnCode, enCode);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountConfigEntity> getListByType(String type) {
|
||||
QueryWrapper<AccountConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getType, type);
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getEnabledMark, 1);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByFullName(String fullName, String id) {
|
||||
QueryWrapper<AccountConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getFullName, fullName);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(AccountConfigEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByEnCode(String enCode, String id, String type) {
|
||||
QueryWrapper<AccountConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getEnCode, enCode);
|
||||
queryWrapper.lambda().eq(AccountConfigEntity::getType, type);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(AccountConfigEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult ImportData(AccountConfigEntity entity) throws DataException {
|
||||
if (entity != null) {
|
||||
// if (isExistByFullName(entity.getFullName(), entity.getId())) {
|
||||
// return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
// }
|
||||
if (isExistByEnCode(entity.getEnCode(), entity.getId(), entity.getType())) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
try {
|
||||
this.save(entity);
|
||||
} catch (Exception e) {
|
||||
throw new DataException(MsgCode.IMP003.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.IMP001.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.IMP006.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 高级查询
|
||||
*
|
||||
* @param conditionModel
|
||||
* @param entity
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
public Integer getCondition(SuperQueryConditionModel conditionModel, Object entity, int num) {
|
||||
QueryWrapper<?> queryWrapper = conditionModel.getObj();
|
||||
List<ConditionJsonModel> queryConditionModels = conditionModel.getConditionList();
|
||||
String op = conditionModel.getMatchLogic();
|
||||
String tableName = conditionModel.getTableName();
|
||||
List<ConditionJsonModel> useCondition = new ArrayList<>();
|
||||
for (ConditionJsonModel queryConditionModel : queryConditionModels) {
|
||||
if (queryConditionModel.getTableName().equalsIgnoreCase(tableName)) {
|
||||
if (queryConditionModel.getField().contains("yunzhupaas")) {
|
||||
String child = queryConditionModel.getField();
|
||||
String s1 = child.substring(child.lastIndexOf("yunzhupaas_")).replace("yunzhupaas_", "");
|
||||
queryConditionModel.setField(s1);
|
||||
}
|
||||
if (queryConditionModel.getField().toLowerCase().startsWith(YunzhupaasKeyConsts.CHILD_TABLE_PREFIX)) {
|
||||
String child = queryConditionModel.getField();
|
||||
String s1 = child.substring(child.indexOf("-") + 1);
|
||||
queryConditionModel.setField(s1);
|
||||
}
|
||||
useCondition.add(queryConditionModel);
|
||||
}
|
||||
}
|
||||
|
||||
if (queryConditionModels.size() < 1 || useCondition.size() < 1) {
|
||||
return num;
|
||||
}
|
||||
if (useCondition.size() > 0) {
|
||||
num += 1;
|
||||
}
|
||||
// 处理控件 转换为有效值
|
||||
for (ConditionJsonModel queryConditionModel : useCondition) {
|
||||
String yunzhupaasKey = queryConditionModel.getYunzhupaasKey();
|
||||
String fieldValue = queryConditionModel.getFieldValue();
|
||||
if (yunzhupaasKey.equals(YunzhupaasKeyConsts.DATE)) {
|
||||
Long o1 = Long.valueOf(fieldValue);
|
||||
String startTime = DateUtil.daFormat(o1);
|
||||
queryConditionModel.setFieldValue(startTime);
|
||||
} else if (yunzhupaasKey.equals(YunzhupaasKeyConsts.CREATETIME)
|
||||
|| yunzhupaasKey.equals(YunzhupaasKeyConsts.MODIFYTIME)) {
|
||||
Long o1 = Long.valueOf(fieldValue);
|
||||
String startTime = DateUtil.daFormatHHMMSS(o1);
|
||||
queryConditionModel.setFieldValue(startTime);
|
||||
} else if (yunzhupaasKey.equals(YunzhupaasKeyConsts.CURRORGANIZE)) {
|
||||
List<String> orgList = JsonUtil.getJsonToList(fieldValue, String.class);
|
||||
queryConditionModel.setFieldValue(orgList.get(orgList.size() - 1));
|
||||
}
|
||||
}
|
||||
// 反射获取数据库实际字段
|
||||
Class<?> aClass = entity.getClass();
|
||||
|
||||
queryWrapper.and(tw -> {
|
||||
for (ConditionJsonModel conditionJsonModel : useCondition) {
|
||||
String conditionField = conditionJsonModel.getField();
|
||||
Field declaredField = null;
|
||||
try {
|
||||
declaredField = aClass.getDeclaredField(conditionField);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
declaredField.setAccessible(true);
|
||||
String field = declaredField.getAnnotation(TableField.class).value();
|
||||
String fieldValue = conditionJsonModel.getFieldValue();
|
||||
String symbol = conditionJsonModel.getSymbol();
|
||||
if ("AND".equalsIgnoreCase(op)) {
|
||||
if (symbol.equals("==")) {
|
||||
tw.eq(field, fieldValue);
|
||||
} else if (symbol.equals(">=")) {
|
||||
tw.ge(field, fieldValue);
|
||||
} else if (symbol.equals("<=")) {
|
||||
tw.le(field, fieldValue);
|
||||
tw.and(
|
||||
qw -> qw.ne(field, ""));
|
||||
} else if (symbol.equals(">")) {
|
||||
tw.gt(field, fieldValue);
|
||||
} else if (symbol.equals("<")) {
|
||||
tw.lt(field, fieldValue);
|
||||
tw.and(
|
||||
qw -> qw.ne(field, ""));
|
||||
} else if (symbol.equals("<>")) {
|
||||
tw.ne(field, fieldValue);
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
}
|
||||
} else if (symbol.equals("like")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.like(field, fieldValue);
|
||||
} else {
|
||||
tw.isNull(field);
|
||||
}
|
||||
} else if (symbol.equals("notLike")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.notLike(field, fieldValue);
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
} else {
|
||||
tw.isNotNull(field);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (symbol.equals("==")) {
|
||||
tw.or(
|
||||
qw -> qw.eq(field, fieldValue));
|
||||
} else if (symbol.equals(">=")) {
|
||||
tw.or(
|
||||
qw -> qw.ge(field, fieldValue));
|
||||
} else if (symbol.equals("<=")) {
|
||||
tw.or(
|
||||
qw -> qw.le(field, fieldValue));
|
||||
} else if (symbol.equals(">")) {
|
||||
tw.or(
|
||||
qw -> qw.gt(field, fieldValue));
|
||||
} else if (symbol.equals("<")) {
|
||||
tw.or(
|
||||
qw -> qw.lt(field, fieldValue));
|
||||
} else if (symbol.equals("<>")) {
|
||||
tw.or(
|
||||
qw -> qw.ne(field, fieldValue));
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
}
|
||||
} else if (symbol.equals("like")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.like(field, fieldValue));
|
||||
} else {
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
}
|
||||
} else if (symbol.equals("notLike")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.notLike(field, fieldValue));
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
} else {
|
||||
tw.or(
|
||||
qw -> qw.isNotNull(field));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return num;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.base.PageModel;
|
||||
import com.yunzhupaas.message.entity.ImContentEntity;
|
||||
import com.yunzhupaas.message.entity.ImReplyEntity;
|
||||
import com.yunzhupaas.message.mapper.ImContentMapper;
|
||||
import com.yunzhupaas.message.model.ImReplySavaModel;
|
||||
import com.yunzhupaas.message.service.ImContentService;
|
||||
import com.yunzhupaas.message.model.ImUnreadNumModel;
|
||||
import com.yunzhupaas.message.service.ImReplyService;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 聊天内容
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Service
|
||||
public class ImContentServiceImpl extends SuperServiceImpl<ImContentMapper, ImContentEntity> implements ImContentService {
|
||||
|
||||
@Autowired
|
||||
private ImReplyService imReplyService;
|
||||
@Override
|
||||
public List<ImContentEntity> getMessageList(String sendUserId, String receiveUserId, PageModel pageModel) {
|
||||
QueryWrapper<ImContentEntity> queryWrapper = new QueryWrapper<>();
|
||||
//发件人、收件人
|
||||
if (!StringUtil.isEmpty(sendUserId) && !StringUtil.isEmpty(receiveUserId)) {
|
||||
|
||||
queryWrapper.lambda().and(wrapper -> {
|
||||
wrapper.eq(ImContentEntity::getSendUserId, sendUserId);
|
||||
wrapper.eq(ImContentEntity::getReceiveUserId, receiveUserId);
|
||||
wrapper.or().eq(ImContentEntity::getSendUserId, receiveUserId);
|
||||
wrapper.eq(ImContentEntity::getReceiveUserId, sendUserId);
|
||||
});
|
||||
queryWrapper.lambda().and(wrapper -> {
|
||||
wrapper.isNull(ImContentEntity::getDeleteUserId);
|
||||
wrapper.or(). ne(ImContentEntity::getDeleteUserId,receiveUserId);
|
||||
// wrapper.ne(ImContentEntity::getDeleteMark, 1);
|
||||
});
|
||||
|
||||
}
|
||||
//关键字查询
|
||||
if (pageModel != null && pageModel.getKeyword() != null) {
|
||||
queryWrapper.lambda().like(ImContentEntity::getContent, pageModel.getKeyword());
|
||||
//排序
|
||||
pageModel.setSidx("f_send_time");
|
||||
}
|
||||
|
||||
if (StringUtil.isEmpty(pageModel.getSidx())) {
|
||||
queryWrapper.lambda().orderByDesc(ImContentEntity::getSendTime);
|
||||
} else {
|
||||
queryWrapper = "asc".equals(pageModel.getSord().toLowerCase()) ? queryWrapper.orderByAsc(pageModel.getSidx()) : queryWrapper.orderByDesc(pageModel.getSidx());
|
||||
}
|
||||
Page<ImContentEntity> page = new Page<>(pageModel.getPage(), pageModel.getRows());
|
||||
IPage<ImContentEntity> iPage = this.page(page, queryWrapper);
|
||||
return pageModel.setData(iPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImUnreadNumModel> getUnreadList(String receiveUserId) {
|
||||
List<ImUnreadNumModel> list = this.baseMapper.getUnreadList(receiveUserId);
|
||||
List<ImUnreadNumModel> list1 = this.baseMapper.getUnreadLists(receiveUserId);
|
||||
for (ImUnreadNumModel item : list) {
|
||||
Optional<ImUnreadNumModel> first = list1.stream().filter(q -> q.getSendUserId().equals(item.getSendUserId())).findFirst();
|
||||
if(first.isPresent()){
|
||||
ImUnreadNumModel defaultItem = first.get();
|
||||
item.setDefaultMessage(defaultItem.getDefaultMessage());
|
||||
item.setDefaultMessageType(defaultItem.getDefaultMessageType());
|
||||
item.setDefaultMessageTime(defaultItem.getDefaultMessageTime());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnreadCount(String sendUserId, String receiveUserId) {
|
||||
QueryWrapper<ImContentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ImContentEntity::getSendUserId, sendUserId).eq(ImContentEntity::getReceiveUserId, receiveUserId).eq(ImContentEntity::getEnabledMark, 0);
|
||||
return (int) this.count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void sendMessage(String sendUserId, String receiveUserId, String message, String messageType) {
|
||||
ImContentEntity entity = new ImContentEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setSendUserId(sendUserId);
|
||||
entity.setSendTime(new Date());
|
||||
entity.setReceiveUserId(receiveUserId);
|
||||
entity.setEnabledMark(0);
|
||||
entity.setContent(message);
|
||||
entity.setContentType(messageType);
|
||||
this.save(entity);
|
||||
|
||||
//写入到会话表中
|
||||
ImReplySavaModel imReplySavaModel = new ImReplySavaModel(sendUserId, receiveUserId, entity.getSendTime());
|
||||
ImReplyEntity imReplyEntity = JsonUtil.getJsonToBean(imReplySavaModel, ImReplyEntity.class);
|
||||
imReplyService.savaImReply(imReplyEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readMessage(String sendUserId, String receiveUserId) {
|
||||
QueryWrapper<ImContentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ImContentEntity::getSendUserId, sendUserId);
|
||||
queryWrapper.lambda().eq(ImContentEntity::getReceiveUserId, receiveUserId);
|
||||
queryWrapper.lambda().eq(ImContentEntity::getEnabledMark, 0);
|
||||
List<ImContentEntity> list = this.list(queryWrapper);
|
||||
for (ImContentEntity entity : list) {
|
||||
entity.setEnabledMark(1);
|
||||
entity.setReceiveTime(new Date());
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ImContentEntity getList(String userId, String receiveUserId) {
|
||||
// QueryWrapper<ImContentEntity> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.lambda().eq(ImContentEntity::getSendUserId, userId)
|
||||
// .and(t -> t.eq(ImContentEntity::getReceiveUserId, receiveUserId)).orderByDesc(ImContentEntity::getReceiveTime);
|
||||
// List<ImContentEntity> list = this.list(queryWrapper);
|
||||
// return list.size() > 0 ? list.get(0) : null;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteChatRecord(String sendUserId, String receiveUserId) {
|
||||
QueryWrapper<ImContentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t-> {
|
||||
t.eq(ImContentEntity::getSendUserId, receiveUserId)
|
||||
.eq(ImContentEntity::getReceiveUserId, sendUserId).or();
|
||||
t.eq(ImContentEntity::getReceiveUserId, receiveUserId)
|
||||
.eq(ImContentEntity::getSendUserId, sendUserId);
|
||||
});
|
||||
List<ImContentEntity> list = this.list(queryWrapper);
|
||||
for (ImContentEntity entity : list) {
|
||||
if(entity.getDeleteUserId()!=null){
|
||||
if(!entity.getDeleteUserId().equals(sendUserId)) {
|
||||
entity.setDeleteMark(1);
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
entity.setDeleteUserId(sendUserId);
|
||||
this.updateById(entity);
|
||||
}
|
||||
QueryWrapper<ImContentEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(ImContentEntity::getDeleteMark,1);
|
||||
this.remove(wrapper);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.message.entity.ImContentEntity;
|
||||
import com.yunzhupaas.message.entity.ImReplyEntity;
|
||||
import com.yunzhupaas.message.mapper.ImReplyMapper;
|
||||
import com.yunzhupaas.message.model.ImReplyListModel;
|
||||
import com.yunzhupaas.message.service.ImReplyService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
@Service
|
||||
public class ImReplyServiceImpl extends SuperServiceImpl<ImReplyMapper, ImReplyEntity> implements ImReplyService {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public List<ImReplyEntity> getList() {
|
||||
QueryWrapper<ImReplyEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ImReplyEntity::getUserId, UserProvider.getUser().getUserId()).or()
|
||||
.eq(ImReplyEntity::getReceiveUserId, UserProvider.getUser().getUserId())
|
||||
.orderByDesc(ImReplyEntity::getUserId);
|
||||
return this.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean savaImReply(ImReplyEntity entity) {
|
||||
QueryWrapper<ImReplyEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ImReplyEntity::getUserId, entity.getUserId()).eq(ImReplyEntity::getReceiveUserId, entity.getReceiveUserId());
|
||||
//判断数据是否存在
|
||||
ImReplyEntity imReplyEntity = this.getOne(queryWrapper);
|
||||
if (imReplyEntity != null) {
|
||||
entity.setId(imReplyEntity.getId());
|
||||
this.updateById(entity);
|
||||
return true;
|
||||
}
|
||||
this.save(entity);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImReplyListModel> getImReplyList() {
|
||||
List<ImReplyListModel> imReplyList = this.baseMapper.getImReplyList();
|
||||
List<ImReplyListModel> imReplyLists = new ArrayList<>(imReplyList);
|
||||
// 过滤掉用户id和接收id相同的
|
||||
imReplyLists = imReplyList.stream().filter(t ->{
|
||||
if(t.getImreplySendDeleteMark() == null){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
// // 过滤掉用户id和接收id相同的
|
||||
// List<ImReplyListModel> imReplyListModels = new ArrayList<>(imReplyList);
|
||||
// for (int i = 0; i < imReplyList.size(); i++) {
|
||||
// ImReplyListModel imReplyListModel = imReplyList.get(i);
|
||||
// // 不和自己比
|
||||
// imReplyListModels.remove(imReplyList.get(i));
|
||||
// List<ImReplyListModel> irs = new ArrayList<>(imReplyListModels);
|
||||
// ImReplyListModel model = irs.stream().filter(t -> t.getUserId().equals(imReplyListModel.getUserId()) && t.getId().equals(imReplyListModel.getId())).findFirst().orElse(null);
|
||||
// if (model != null) {
|
||||
// imReplyLists.remove(model);
|
||||
// }
|
||||
// }
|
||||
//我发给别人
|
||||
List<ImReplyListModel> collect = imReplyLists.stream().filter(t -> t.getUserId().equals(UserProvider.getUser().getUserId())).collect(Collectors.toList());
|
||||
//头像替换成对方的
|
||||
for (ImReplyListModel imReplyListModel : collect) {
|
||||
UserEntity entity = userService.getInfo(imReplyListModel.getId());
|
||||
imReplyListModel.setHeadIcon(entity != null ? entity.getHeadIcon() : "");
|
||||
// imReplyListModel.setSendDeleteMark(imReplyListModel.getSendDeleteMark());
|
||||
// imReplyListModel.setImreplySendDeleteMark(imReplyListModel.getImreplySendDeleteMark());
|
||||
// imReplyListModel.setDeleteMark(imReplyListModel.getDeleteMark());
|
||||
}
|
||||
//别人发给我
|
||||
List<ImReplyListModel> list = imReplyLists.stream().filter(t -> t.getId().equals(UserProvider.getUser().getUserId())).collect(Collectors.toList());
|
||||
for (ImReplyListModel model : list) {
|
||||
//移除掉互发的
|
||||
List<ImReplyListModel> collect1 = collect.stream().filter(t -> t.getId().equals(model.getUserId())).collect(Collectors.toList());
|
||||
if (collect1.size() > 0) {
|
||||
//判断我发给别人的时间和接收的时间大小
|
||||
//接收的大于发送的
|
||||
if (model.getLatestDate().getTime() > collect1.get(0).getLatestDate().getTime()) {
|
||||
collect.remove(collect1.get(0));
|
||||
} else { //发送的大于接收的则跳过
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ImReplyListModel imReplyListModel = new ImReplyListModel();
|
||||
UserEntity entity = userService.getInfo(model.getUserId());
|
||||
if(entity != null) {
|
||||
imReplyListModel.setHeadIcon(entity.getHeadIcon());
|
||||
imReplyListModel.setUserId(UserProvider.getUser().getUserId());
|
||||
imReplyListModel.setId(entity.getId());
|
||||
imReplyListModel.setLatestDate(model.getLatestDate());
|
||||
imReplyListModel.setLatestMessage(model.getLatestMessage());
|
||||
imReplyListModel.setMessageType(model.getMessageType());
|
||||
if (model.getImreplySendDeleteMark() != null && !model.getImreplySendDeleteMark().equals(UserProvider.getUser().getUserId())) {
|
||||
imReplyListModel.setSendDeleteMark(model.getSendDeleteMark());
|
||||
imReplyListModel.setImreplySendDeleteMark(model.getImreplySendDeleteMark());
|
||||
imReplyListModel.setDeleteMark(model.getDeleteMark());
|
||||
}
|
||||
imReplyListModel.setDeleteUserId(model.getDeleteUserId());
|
||||
|
||||
collect.add(imReplyListModel);
|
||||
}
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relocation(String sendUserId, String receiveUserId) {
|
||||
QueryWrapper<ImReplyEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t-> {
|
||||
t.eq(ImReplyEntity::getUserId, receiveUserId)
|
||||
.eq(ImReplyEntity::getReceiveUserId, sendUserId).or();
|
||||
t.eq(ImReplyEntity::getReceiveUserId, receiveUserId)
|
||||
.eq(ImReplyEntity::getUserId, sendUserId);
|
||||
});
|
||||
List<ImReplyEntity> list = this.list(queryWrapper);
|
||||
for (ImReplyEntity entity : list) {
|
||||
if(entity.getDeleteUserId()!=null){
|
||||
if(!entity.getDeleteUserId().equals(sendUserId)) {
|
||||
entity.setDeleteMark(1);
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
entity.setDeleteUserId(sendUserId);
|
||||
this.updateById(entity);
|
||||
}
|
||||
QueryWrapper<ImReplyEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(ImReplyEntity::getDeleteMark,1);
|
||||
this.remove(wrapper);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.yunzhupaas.message.entity.MessageMonitorEntity;
|
||||
import com.yunzhupaas.message.mapper.MessageMonitorMapper;
|
||||
import com.yunzhupaas.message.model.messagemonitor.*;
|
||||
import com.yunzhupaas.message.service.MessageMonitorService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
import java.lang.reflect.Field;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息监控
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-22
|
||||
*/
|
||||
@Service
|
||||
public class MessageMonitorServiceImpl extends SuperServiceImpl<MessageMonitorMapper, MessageMonitorEntity> implements MessageMonitorService {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<MessageMonitorEntity> getList(MessageMonitorPagination messageMonitorPagination) {
|
||||
return getTypeList(messageMonitorPagination, messageMonitorPagination.getDataType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageMonitorEntity> getTypeList(MessageMonitorPagination messageMonitorPagination, String dataType) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
int total = 0;
|
||||
int messageMonitorNum = 0;
|
||||
QueryWrapper<MessageMonitorEntity> messageMonitorQueryWrapper = new QueryWrapper<>();
|
||||
//关键字
|
||||
if (ObjectUtil.isNotEmpty(messageMonitorPagination.getKeyword())) {
|
||||
messageMonitorNum++;
|
||||
messageMonitorQueryWrapper.lambda().and(t -> t.like(MessageMonitorEntity::getTitle, messageMonitorPagination.getKeyword()));
|
||||
}
|
||||
//消息类型
|
||||
if (ObjectUtil.isNotEmpty(messageMonitorPagination.getMessageType())) {
|
||||
messageMonitorNum++;
|
||||
messageMonitorQueryWrapper.lambda().eq(MessageMonitorEntity::getMessageType, messageMonitorPagination.getMessageType());
|
||||
}
|
||||
//发送时间
|
||||
if (ObjectUtil.isNotEmpty(messageMonitorPagination.getStartTime()) && ObjectUtil.isNotEmpty(messageMonitorPagination.getEndTime())) {
|
||||
messageMonitorNum++;
|
||||
|
||||
messageMonitorQueryWrapper.lambda().ge(MessageMonitorEntity::getSendTime, new Date(messageMonitorPagination.getStartTime()))
|
||||
.le(MessageMonitorEntity::getSendTime, new Date(messageMonitorPagination.getEndTime()));
|
||||
|
||||
}
|
||||
//消息来源
|
||||
if (ObjectUtil.isNotEmpty(messageMonitorPagination.getMessageSource())) {
|
||||
messageMonitorNum++;
|
||||
messageMonitorQueryWrapper.lambda().eq(MessageMonitorEntity::getMessageSource, messageMonitorPagination.getMessageSource());
|
||||
}
|
||||
//排序
|
||||
if (StringUtil.isEmpty(messageMonitorPagination.getSidx())) {
|
||||
messageMonitorQueryWrapper.lambda().orderByDesc(MessageMonitorEntity::getSendTime);
|
||||
} else {
|
||||
try {
|
||||
String sidx = messageMonitorPagination.getSidx();
|
||||
MessageMonitorEntity messageMonitorEntity = new MessageMonitorEntity();
|
||||
Field declaredField = messageMonitorEntity.getClass().getDeclaredField(sidx);
|
||||
declaredField.setAccessible(true);
|
||||
String value = declaredField.getAnnotation(TableField.class).value();
|
||||
messageMonitorQueryWrapper = "asc".equals(messageMonitorPagination.getSort().toLowerCase()) ? messageMonitorQueryWrapper.orderByAsc(value) : messageMonitorQueryWrapper.orderByDesc(value);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!"1".equals(dataType)) {
|
||||
if (total > 0 || total == 0) {
|
||||
Page<MessageMonitorEntity> page = new Page<>(messageMonitorPagination.getCurrentPage(), messageMonitorPagination.getPageSize());
|
||||
IPage<MessageMonitorEntity> userIPage = this.page(page, messageMonitorQueryWrapper);
|
||||
return messageMonitorPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
||||
} else {
|
||||
List<MessageMonitorEntity> list = new ArrayList();
|
||||
return messageMonitorPagination.setData(list, list.size());
|
||||
}
|
||||
} else {
|
||||
return this.list(messageMonitorQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MessageMonitorEntity getInfo(String id) {
|
||||
QueryWrapper<MessageMonitorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageMonitorEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(MessageMonitorEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, MessageMonitorEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(MessageMonitorEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
//子表方法
|
||||
|
||||
//列表子表数据方法
|
||||
|
||||
|
||||
//验证表单唯一字段
|
||||
@Override
|
||||
public boolean checkForm(MessageMonitorForm form, int i) {
|
||||
int total = 0;
|
||||
if (total > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void emptyMonitor(){
|
||||
QueryWrapper<MessageMonitorEntity> queryWrapper = new QueryWrapper<>();
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public boolean delete(String[] ids) {
|
||||
if (ids.length > 0) {
|
||||
QueryWrapper<MessageMonitorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(MessageMonitorEntity::getId, ids);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 用户id转名称(多选)
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String userSelectValues(String ids) {
|
||||
if (StringUtil.isEmpty(ids)) {
|
||||
return ids;
|
||||
}
|
||||
if (ids.contains("[")){
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> jsonToList = JsonUtil.getJsonToList(ids, String.class);
|
||||
for (String userId : jsonToList){
|
||||
UserEntity info = userService.getInfo(userId);
|
||||
nameList.add(Objects.nonNull(info) ? info.getRealName()+ "/" + info.getAccount() : userId);
|
||||
}
|
||||
return String.join(";", nameList);
|
||||
}else {
|
||||
List<String> userInfoList = new ArrayList<>();
|
||||
String[] idList = ids.split(",");
|
||||
if (idList.length > 0) {
|
||||
for (String id : idList) {
|
||||
UserEntity userEntity = userService.getInfo(id);
|
||||
if (ObjectUtil.isNotEmpty(userEntity)) {
|
||||
String info = userEntity.getRealName() + "/" + userEntity.getAccount();
|
||||
userInfoList.add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.join("-", userInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,806 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.Method;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.DictionaryTypeEntity;
|
||||
import com.yunzhupaas.base.entity.MessageTemplateEntity;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.DictionaryTypeService;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.base.util.SentMessageUtil;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.flowable.model.trigger.TriggerModel;
|
||||
import com.yunzhupaas.message.entity.*;
|
||||
import com.yunzhupaas.message.mapper.MessageMapper;
|
||||
import com.yunzhupaas.message.model.NoticePagination;
|
||||
import com.yunzhupaas.message.model.SentMessageForm;
|
||||
import com.yunzhupaas.message.model.message.NoticeVO;
|
||||
import com.yunzhupaas.message.model.message.PaginationMessage;
|
||||
import com.yunzhupaas.message.service.*;
|
||||
import com.yunzhupaas.message.util.OnlineUserProvider;
|
||||
import com.yunzhupaas.message.util.PushMessageUtil;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消息实例
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MessageServiceImpl extends SuperServiceImpl<MessageMapper, MessageEntity> implements MessageService {
|
||||
|
||||
@Autowired
|
||||
private MessagereceiveService messagereceiveService;
|
||||
@Autowired
|
||||
private MessageMonitorService messageMonitorService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private SentMessageUtil sentMessageUtil;
|
||||
@Autowired
|
||||
private SendMessageConfigService sendMessageConfigService;
|
||||
@Autowired
|
||||
private SendConfigTemplateService sendConfigTemplateService;
|
||||
@Autowired
|
||||
private MessageTemplateConfigService messageTemplateConfigService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private DictionaryTypeService dictionaryTypeService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataService;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
@Override
|
||||
public List<MessageEntity> getNoticeList(NoticePagination pagination) {
|
||||
// 定义变量判断是否需要使用修改时间倒序
|
||||
QueryWrapper<MessageEntity> queryWrapper = new QueryWrapper<>();
|
||||
//关键词(消息标题)
|
||||
if (!StringUtils.isEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().like(MessageEntity::getTitle, pagination.getKeyword());
|
||||
}
|
||||
// 类型
|
||||
if (CollectionUtil.isNotEmpty(pagination.getType())) {
|
||||
queryWrapper.lambda().in(MessageEntity::getCategory, pagination.getType());
|
||||
}
|
||||
// 状态
|
||||
if (CollectionUtil.isNotEmpty(pagination.getEnabledMark())) {
|
||||
queryWrapper.lambda().in(MessageEntity::getEnabledMark, pagination.getEnabledMark());
|
||||
} else {
|
||||
queryWrapper.lambda().and(t -> t.ne(MessageEntity::getEnabledMark, 3)
|
||||
.or().isNull(MessageEntity::getEnabledMark));
|
||||
queryWrapper.lambda().ne(MessageEntity::getEnabledMark, -1);
|
||||
}
|
||||
// 发布人
|
||||
if (CollectionUtil.isNotEmpty(pagination.getReleaseUser())) {
|
||||
queryWrapper.lambda().in(MessageEntity::getLastModifyUserId, pagination.getReleaseUser());
|
||||
}
|
||||
// 发布时间
|
||||
if (CollectionUtil.isNotEmpty(pagination.getReleaseTime())) {
|
||||
queryWrapper.lambda().between(MessageEntity::getLastModifyTime, new Date(pagination.getReleaseTime().get(0)), new Date(pagination.getReleaseTime().get(1)));
|
||||
}
|
||||
// 失效时间
|
||||
if (CollectionUtil.isNotEmpty(pagination.getExpirationTime())) {
|
||||
queryWrapper.lambda().between(MessageEntity::getExpirationTime, new Date(pagination.getExpirationTime().get(0)), new Date(pagination.getExpirationTime().get(1)));
|
||||
}
|
||||
// 创建人
|
||||
if (CollectionUtil.isNotEmpty(pagination.getCreatorUser())) {
|
||||
queryWrapper.lambda().in(MessageEntity::getCreatorUserId, pagination.getCreatorUser());
|
||||
}
|
||||
// 创建时间
|
||||
if (CollectionUtil.isNotEmpty(pagination.getCreatorTime())) {
|
||||
queryWrapper.lambda().between(MessageEntity::getCreatorTime, new Date(pagination.getCreatorTime().get(0)), new Date(pagination.getCreatorTime().get(1)));
|
||||
}
|
||||
//默认排序
|
||||
queryWrapper.lambda().orderByAsc(MessageEntity::getEnabledMark).orderByDesc(MessageEntity::getLastModifyTime).orderByDesc(MessageEntity::getCreatorTime);
|
||||
queryWrapper.lambda().select(MessageEntity::getId, MessageEntity::getCreatorUserId, MessageEntity::getEnabledMark,
|
||||
MessageEntity::getLastModifyTime, MessageEntity::getTitle, MessageEntity::getCreatorTime,
|
||||
MessageEntity::getLastModifyUserId, MessageEntity::getExpirationTime, MessageEntity::getCategory);
|
||||
Page<MessageEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<MessageEntity> userIPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(userIPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageEntity> getNoticeList() {
|
||||
QueryWrapper<MessageEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageEntity::getEnabledMark, 1);
|
||||
queryWrapper.lambda().orderByAsc(MessageEntity::getSortCode);
|
||||
return this.baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageEntity> getDashboardNoticeList(List<String> typeList) {
|
||||
List<MessageEntity> list = new ArrayList<>(16);
|
||||
// 判断哪些消息是自己接收的
|
||||
QueryWrapper<MessageReceiveEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getUserId, UserProvider.getUser().getUserId());
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getType, 1);
|
||||
List<MessageReceiveEntity> receiveEntities = messagereceiveService.list(queryWrapper);
|
||||
for (int i = 0; i < receiveEntities.size(); i++) {
|
||||
// 得到message
|
||||
MessageReceiveEntity messageReceiveEntity = receiveEntities.get(i);
|
||||
try{
|
||||
MessageEntity entity = JsonUtil.getJsonToBean(messageReceiveEntity.getBodyText(), MessageEntity.class);
|
||||
if (entity != null) {
|
||||
if (StringUtil.isNotEmpty(entity.getId())) {
|
||||
MessageEntity messageEntity = this.getInfo(entity.getId());
|
||||
if (messageEntity != null) {
|
||||
if ((typeList != null && typeList.size() > 0 && typeList.contains(messageEntity.getCategory()) || typeList == null || typeList.size() == 0)) {
|
||||
if (Objects.equals(messageEntity.getEnabledMark(), 1)
|
||||
&& (entity.getExpirationTime() == null || entity.getExpirationTime().getTime() > System.currentTimeMillis())) {
|
||||
messageEntity.setId(messageReceiveEntity.getId());
|
||||
list.add(messageEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
entity.setId(messageReceiveEntity.getId());
|
||||
list.add(entity);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
MessageEntity messageEntity = JsonUtil.getJsonToBean(messageReceiveEntity, MessageEntity.class);
|
||||
list.add(messageEntity);
|
||||
}
|
||||
if (list.size() > 49) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
list = list.stream().sorted(Comparator.comparing(MessageEntity::getLastModifyTime).reversed()).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageReceiveEntity> getMessageList3(Pagination pagination, Integer type, String user, Integer isRead) {
|
||||
PaginationMessage paginationMessage = BeanUtil.copyProperties(pagination, PaginationMessage.class);
|
||||
List<MessageReceiveEntity> messageColumnList = getMessageColumnList(paginationMessage,
|
||||
MessageReceiveEntity::getId,
|
||||
MessageReceiveEntity::getUserId,
|
||||
MessageReceiveEntity::getType,
|
||||
MessageReceiveEntity::getTitle,
|
||||
MessageReceiveEntity::getFlowType,
|
||||
MessageReceiveEntity::getIsRead,
|
||||
MessageReceiveEntity::getSortCode,
|
||||
MessageReceiveEntity::getCreatorTime,
|
||||
MessageReceiveEntity::getCreatorUserId);
|
||||
return pagination.setData(messageColumnList, paginationMessage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageReceiveEntity> getMessageColumnList(PaginationMessage pagination, SFunction<MessageReceiveEntity, ?>... columns) {
|
||||
QueryWrapper<MessageReceiveEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().select(MessageReceiveEntity::getId);
|
||||
if (StringUtil.isNotEmpty(pagination.getUserId())) {
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getUserId, pagination.getUserId());
|
||||
} else {
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getUserId, UserProvider.getLoginUserId());
|
||||
}
|
||||
if (pagination.getType() != null) {
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getType, pagination.getType());
|
||||
}
|
||||
if (pagination.getIsRead() != null) {
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getIsRead, pagination.getIsRead());
|
||||
}
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().like(MessageReceiveEntity::getTitle, pagination.getKeyword());
|
||||
}
|
||||
queryWrapper.lambda().orderByDesc(MessageReceiveEntity::getCreatorTime);
|
||||
Page<MessageReceiveEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<MessageReceiveEntity> userIPage = messagereceiveService.page(page, queryWrapper);
|
||||
|
||||
List<String> ids = userIPage.getRecords().stream().map(MessageReceiveEntity::getId).collect(Collectors.toList());
|
||||
List<MessageReceiveEntity> list = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
QueryWrapper<MessageReceiveEntity> wrapper = new QueryWrapper<>();
|
||||
if (columns != null && columns.length > 0) {
|
||||
wrapper.lambda().select(columns);
|
||||
}
|
||||
wrapper.lambda().in(MessageReceiveEntity::getId, ids);
|
||||
wrapper.lambda().orderByDesc(MessageReceiveEntity::getCreatorTime);
|
||||
list = messagereceiveService.list(wrapper);
|
||||
}
|
||||
return pagination.setData(list, page.getTotal());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<MessageReceiveEntity> getMessageList(Pagination pagination) {
|
||||
return this.getMessageList3(pagination, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageEntity getInfo(String id) {
|
||||
QueryWrapper<MessageEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageEntity getInfoDefault(int type) {
|
||||
QueryWrapper<MessageEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageEntity::getEnabledMark, 1);
|
||||
if (type == 1) {
|
||||
queryWrapper.lambda().orderByDesc(MessageEntity::getCreatorTime);
|
||||
} else {
|
||||
queryWrapper.lambda().orderByDesc(MessageEntity::getLastModifyTime);
|
||||
}
|
||||
// 只查询id
|
||||
queryWrapper.lambda().select(MessageEntity::getId, MessageEntity::getTitle, MessageEntity::getCreatorTime);
|
||||
List<MessageEntity> list = this.page(new Page<>(1, 1, false), queryWrapper).getRecords();
|
||||
MessageEntity entity = new MessageEntity();
|
||||
if (list.size() > 0) {
|
||||
entity = list.get(0);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void delete(MessageEntity entity) {
|
||||
entity.setEnabledMark(-1);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(MessageEntity entity) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setBodyText(XSSEscape.escapeImgOnlyBase64(entity.getBodyText()));
|
||||
entity.setEnabledMark(0);
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, MessageEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setBodyText(XSSEscape.escapeImgOnlyBase64(entity.getBodyText()));
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setLastModifyTime(null);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageReceiveEntity messageRead(String messageId) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
QueryWrapper<MessageReceiveEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getUserId, userId).eq(MessageReceiveEntity::getId, messageId);
|
||||
MessageReceiveEntity entity = messagereceiveService.getOne(queryWrapper);
|
||||
if (entity != null) {
|
||||
entity.setIsRead(1);
|
||||
messagereceiveService.updateById(entity);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void messageRead(List<String> idList) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
QueryWrapper<MessageReceiveEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().select(MessageReceiveEntity::getId)
|
||||
.eq(MessageReceiveEntity::getUserId, userId).eq(MessageReceiveEntity::getIsRead, 0);
|
||||
// queryWrapper.lambda().in(MessageReceiveEntity::getMessageId,idList);
|
||||
List<MessageReceiveEntity> entitys = messagereceiveService.list(queryWrapper);
|
||||
if (entitys.size() > 0) {
|
||||
for (MessageReceiveEntity entity : entitys) {
|
||||
entity.setIsRead(1);
|
||||
messagereceiveService.updateById(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void deleteRecord(List<String> messageIds) {
|
||||
// 删除已读表
|
||||
QueryWrapper<MessageReceiveEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (messageIds.size() > 0) {
|
||||
queryWrapper.lambda().in(MessageReceiveEntity::getId, messageIds);
|
||||
}
|
||||
// 通过id删除无需判断接收人
|
||||
queryWrapper.lambda().eq(MessageReceiveEntity::getUserId, UserProvider.getLoginUserId());
|
||||
messagereceiveService.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnreadCount(String userId, Integer type) {
|
||||
int result = this.baseMapper.getUnreadCount(userId, type);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sentNotice(List<String> toUserIds, MessageEntity entity) {
|
||||
// 存到redis中的key对象
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<String> idList = new ArrayList<>();
|
||||
// 修改发送状态
|
||||
entity.setEnabledMark(1);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(userInfo.getUserId());
|
||||
this.updateById(entity);
|
||||
// 存到redis,生成Redis的key
|
||||
Callable executeInsert = () -> {
|
||||
executeInsert(toUserIds, idList);
|
||||
return true;
|
||||
};
|
||||
Future<Boolean> submit = ThreadPoolExecutorUtil.getExecutor().submit(executeInsert);
|
||||
try {
|
||||
if (submit.get()) {
|
||||
// 执行发送公告操作
|
||||
Runnable runnable = () -> executeBatch(idList, entity, userInfo);
|
||||
ThreadPoolExecutorUtil.getExecutor().submit(runnable);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
// 还原公告状态
|
||||
entity.setEnabledMark(0);
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
this.updateById(entity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据存到redis中
|
||||
*
|
||||
* @param toUserIds 接受者id
|
||||
*/
|
||||
private void executeInsert(List<String> toUserIds, List<String> idList) throws Exception {
|
||||
List<String> key = new ArrayList<>();
|
||||
try {
|
||||
int frequency = 10000;
|
||||
int count = toUserIds.size() / frequency + 1;
|
||||
if (toUserIds.size() < 1) return;
|
||||
for (int i = 0; i < count; i++) {
|
||||
// 生成redis的key
|
||||
String cacheKey = RandomUtil.uuId() + toUserIds.get(i);
|
||||
// 存到redis
|
||||
int endSize = Math.min(((i + 1) * frequency), toUserIds.size());
|
||||
redisUtil.insert(cacheKey, toUserIds.subList(i * frequency, endSize));
|
||||
key.add(cacheKey);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
key.forEach(k -> redisUtil.remove(k));
|
||||
key.clear();
|
||||
throw new Exception();
|
||||
}
|
||||
idList.addAll(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行发送操作
|
||||
*
|
||||
* @param idList 存到redis中的key
|
||||
* @param entity
|
||||
* @param userInfo
|
||||
*/
|
||||
private void executeBatch(List<String> idList, MessageEntity entity, UserInfo userInfo) {
|
||||
if (idList.size() == 0 || "3".equals(String.valueOf(entity.getRemindCategory()))) {
|
||||
return;
|
||||
}
|
||||
SentMessageForm sentMessageForm = new SentMessageForm();
|
||||
List<String> toUserId = new ArrayList<>();
|
||||
for (String cacheKey : idList) {
|
||||
List<String> cacheValue = (List) redisUtil.get(cacheKey, 0, -1);
|
||||
toUserId.addAll(cacheValue);
|
||||
}
|
||||
sentMessageForm.setToUserIds(toUserId);
|
||||
sentMessageForm.setTitle(entity.getTitle());
|
||||
sentMessageForm.setContent(entity.getBodyText());
|
||||
sentMessageForm.setContentMsg(Collections.EMPTY_MAP);
|
||||
sentMessageForm.setUserInfo(userInfo);
|
||||
sentMessageForm.setType(1);
|
||||
sentMessageForm.setId(entity.getId());
|
||||
|
||||
// 站内信
|
||||
if ("1".equals(String.valueOf(entity.getRemindCategory()))) {
|
||||
message(sentMessageForm);
|
||||
} else if ("2".equals(String.valueOf(entity.getRemindCategory()))) {
|
||||
SendMessageConfigEntity sendMessageConfigEntity = sendMessageConfigService.getInfo(entity.getSendConfigId());
|
||||
if (sendMessageConfigEntity != null) {
|
||||
List<SendConfigTemplateEntity> configTemplateEntityList = sendConfigTemplateService.getDetailListByParentId(sendMessageConfigEntity.getId());
|
||||
for (SendConfigTemplateEntity sendConfigTemplateEntity : configTemplateEntityList) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("Title", entity.getTitle());
|
||||
map.put("Content", entity.getBodyText());
|
||||
map.put("Remark", entity.getExcerpt());
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("@title", entity.getTitle());
|
||||
paramMap.put("@Content", entity.getBodyText());
|
||||
paramMap.put("@Remark", entity.getExcerpt());
|
||||
switch (sendConfigTemplateEntity.getMessageType()) {
|
||||
case "1":
|
||||
MessageTemplateConfigEntity configEntity = messageTemplateConfigService.getInfo(sendConfigTemplateEntity.getTemplateId());
|
||||
if (configEntity != null) {
|
||||
sentMessageForm.setTitle(configEntity.getTitle());
|
||||
}
|
||||
message(sentMessageForm);
|
||||
break;
|
||||
case "2":
|
||||
// 邮件
|
||||
sentMessageUtil.SendMail(toUserId, userInfo, "2", sendConfigTemplateEntity, new HashMap<>(), map);
|
||||
break;
|
||||
case "3":
|
||||
// 发送短信
|
||||
sentMessageUtil.sendSms(toUserId, userInfo, sendConfigTemplateEntity, paramMap, new HashMap<>());
|
||||
break;
|
||||
case "4":
|
||||
// 钉钉
|
||||
JSONObject jsonObject1 = sentMessageUtil.SendDingTalk(toUserId, userInfo, "4", sendConfigTemplateEntity, new HashMap<>(), map);
|
||||
if (!(Boolean) jsonObject1.get("code")) {
|
||||
log.error("发送企业微信消息失败,错误:" + jsonObject1.get("error"));
|
||||
}
|
||||
break;
|
||||
case "5":
|
||||
// 企业微信
|
||||
JSONObject jsonObject = sentMessageUtil.SendQyWebChat(toUserId, userInfo, "5", sendConfigTemplateEntity, new HashMap<>(), map);
|
||||
if (!(Boolean) jsonObject.get("code")) {
|
||||
log.error("发送企业微信消息失败,错误:" + jsonObject.get("error"));
|
||||
}
|
||||
break;
|
||||
case "6":
|
||||
// webhook
|
||||
sentMessageUtil.SendWebHook(null, userInfo, sendConfigTemplateEntity, new HashMap<>(), map);
|
||||
break;
|
||||
case "7":
|
||||
// 微信公众号
|
||||
sentMessageUtil.SendWXGzhChat(toUserId, userInfo, "7", sendConfigTemplateEntity, new HashMap<>(), paramMap);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sentMessage(List<String> toUserIds, String title) {
|
||||
this.sentMessage(toUserIds, title, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void sentMessage(List<String> toUserIds, String title, String bodyText) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
|
||||
MessageReceiveEntity messageReceiveEntity = new MessageReceiveEntity();
|
||||
messageReceiveEntity.setTitle(title);
|
||||
messageReceiveEntity.setType(2);
|
||||
messageReceiveEntity.setFlowType(1);
|
||||
messageReceiveEntity.setIsRead(0);
|
||||
Map<String, MessageReceiveEntity> map = new HashMap<>();
|
||||
for (String item : toUserIds) {
|
||||
MessageReceiveEntity messageReceiveEntitys = new MessageReceiveEntity();
|
||||
BeanUtils.copyProperties(messageReceiveEntity, messageReceiveEntitys);
|
||||
messageReceiveEntitys.setId(RandomUtil.uuId());
|
||||
messageReceiveEntitys.setUserId(item);
|
||||
messageReceiveEntitys.setBodyText(bodyText);
|
||||
messagereceiveService.save(messageReceiveEntitys);
|
||||
map.put(messageReceiveEntitys.getUserId(), messageReceiveEntitys);
|
||||
}
|
||||
//消息推送 - PC端
|
||||
PushMessageUtil.pushMessage(map, userInfo, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void sentMessage(List<String> toUserIds, String title, String bodyText, Map<String, String> contentMsg, UserInfo userInfo) {
|
||||
MessageReceiveEntity messageReceiveEntity = new MessageReceiveEntity();
|
||||
messageReceiveEntity.setTitle(title);
|
||||
messageReceiveEntity.setType(2);
|
||||
messageReceiveEntity.setFlowType(1);
|
||||
messageReceiveEntity.setIsRead(0);
|
||||
Map<String, MessageReceiveEntity> map = new HashMap<>();
|
||||
for (String item : toUserIds) {
|
||||
MessageReceiveEntity messageReceiveEntitys = new MessageReceiveEntity();
|
||||
BeanUtils.copyProperties(messageReceiveEntity, messageReceiveEntitys);
|
||||
messageReceiveEntitys.setId(RandomUtil.uuId());
|
||||
messageReceiveEntitys.setUserId(item);
|
||||
String msg = contentMsg.get(item) != null ? contentMsg.get(item) : "{}" ;
|
||||
messageReceiveEntitys.setBodyText(msg);
|
||||
messageReceiveEntitys.setCreatorUserId(userInfo.getUserId());
|
||||
messageReceiveEntitys.setCreatorTime(new Date());
|
||||
messagereceiveService.save(messageReceiveEntitys);
|
||||
map.put(messageReceiveEntitys.getUserId(), messageReceiveEntitys);
|
||||
}
|
||||
|
||||
//消息推送 - PC端
|
||||
PushMessageUtil.pushMessage(map, userInfo, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void sentMessage(List<String> toUserIds, String title, String bodyText, UserInfo userInfo, Integer source, Integer type) {
|
||||
sentMessage(toUserIds, title, bodyText, userInfo, source, type, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void sentMessage(List<String> toUserIds, String title, String bodyText, UserInfo userInfo, Integer source, Integer type, boolean testMessage) {
|
||||
MessageReceiveEntity messageReceiveEntity = new MessageReceiveEntity();
|
||||
messageReceiveEntity.setTitle(title);
|
||||
messageReceiveEntity.setType(source);
|
||||
messageReceiveEntity.setFlowType(1);
|
||||
messageReceiveEntity.setBodyText(bodyText);
|
||||
messageReceiveEntity.setIsRead(0);
|
||||
Map<String, MessageReceiveEntity> map = new HashMap<>();
|
||||
for (String item : toUserIds) {
|
||||
MessageReceiveEntity messageReceiveEntitys = new MessageReceiveEntity();
|
||||
BeanUtils.copyProperties(messageReceiveEntity, messageReceiveEntitys);
|
||||
messageReceiveEntitys.setId(RandomUtil.uuId());
|
||||
messageReceiveEntitys.setUserId(item);
|
||||
messagereceiveService.save(messageReceiveEntitys);
|
||||
map.put(messageReceiveEntitys.getUserId(), messageReceiveEntitys);
|
||||
}
|
||||
//消息监控写入
|
||||
MessageMonitorEntity monitorEntity = new MessageMonitorEntity();
|
||||
monitorEntity.setId(RandomUtil.uuId());
|
||||
monitorEntity.setTitle(title);
|
||||
monitorEntity.setMessageType(String.valueOf(type));
|
||||
monitorEntity.setMessageSource(String.valueOf(source));
|
||||
monitorEntity.setReceiveUser(JsonUtil.getObjectToString(toUserIds));
|
||||
monitorEntity.setSendTime(DateUtil.getNowDate());
|
||||
monitorEntity.setCreatorTime(DateUtil.getNowDate());
|
||||
monitorEntity.setCreatorUserId(userInfo.getUserId());
|
||||
messageMonitorService.create(monitorEntity);
|
||||
PushMessageUtil.pushMessage(map, userInfo, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sentFlowMessage(List<String> toUserIds, MessageTemplateEntity entity, String content) {
|
||||
if (entity != null) {
|
||||
// 消息标题
|
||||
String title = entity.getTitle();
|
||||
this.sentMessage(toUserIds, title, content);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logoutWebsocketByToken(String token, String userId) {
|
||||
if (StringUtil.isNotEmpty(token)) {
|
||||
OnlineUserProvider.removeWebSocketByToken(token.split(","));
|
||||
} else {
|
||||
OnlineUserProvider.removeWebSocketByUser(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> sentScheduleMessage(SentMessageForm sentMessageForm, String type) {
|
||||
List<String> errList = new ArrayList<>();
|
||||
UserInfo userInfo = sentMessageForm.getUserInfo();
|
||||
String templateId = sentMessageForm.getTemplateId();
|
||||
String title = sentMessageForm.getTitle();
|
||||
List<String> toUserIds = sentMessageForm.getToUserIds();
|
||||
//获取发送配置详情
|
||||
SendMessageConfigEntity configEntity = sendMessageConfigService.getInfoByEnCode(templateId);
|
||||
if (configEntity != null) {
|
||||
templateId = configEntity.getId();
|
||||
} else {
|
||||
configEntity = sendMessageConfigService.getInfo(templateId);
|
||||
}
|
||||
List<SendConfigTemplateEntity> list = sendConfigTemplateService.getDetailListByParentId(templateId);
|
||||
if (configEntity != null) {
|
||||
for (SendConfigTemplateEntity sendConfigTemplateEntity : list) {
|
||||
Map<String, Object> objectMap = new HashMap<>(sentMessageForm.getParameterMap());
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
for (String key : objectMap.keySet()) {
|
||||
if (key.contains(sendConfigTemplateEntity.getId())) {
|
||||
parameterMap.put(key.substring(sendConfigTemplateEntity.getId().length()), objectMap.get(key));
|
||||
}
|
||||
}
|
||||
parameterMap.putAll(objectMap);
|
||||
Map<String, String> contentMsg = new HashMap<>();
|
||||
for (String key : parameterMap.keySet()) {
|
||||
contentMsg.put(key, String.valueOf(parameterMap.get(key)));
|
||||
}
|
||||
String sendType = sendConfigTemplateEntity.getMessageType();
|
||||
switch (sendType) {
|
||||
case "1":
|
||||
MessageTemplateConfigEntity templateConfigEntity = messageTemplateConfigService.getInfo(sendConfigTemplateEntity.getTemplateId());
|
||||
String messageTitle = StringUtil.isNotEmpty(templateConfigEntity.getTitle()) ? templateConfigEntity.getTitle() : "" ;
|
||||
String content = StringUtil.isNotEmpty(templateConfigEntity.getContent()) ? templateConfigEntity.getContent() : "" ;
|
||||
StringSubstitutor strSubstitutor = new StringSubstitutor(parameterMap, "{", "}");
|
||||
messageTitle = strSubstitutor.replace(messageTitle);
|
||||
content = strSubstitutor.replace(content);
|
||||
sentMessageForm.setTitle(messageTitle);
|
||||
sentMessageForm.setContent(content);
|
||||
// 站内消息
|
||||
message(sentMessageForm);
|
||||
// 通知触发
|
||||
String url = configValueUtil.getApiDomain() + "/api/workflow/trigger/MsgExecute";
|
||||
TriggerModel model = new TriggerModel();
|
||||
model.setUserInfo(userInfo);
|
||||
model.setId(templateConfigEntity.getId());
|
||||
HttpRequest request = HttpRequest.of(url).method(Method.POST).body(JsonUtil.getObjectToString(model));
|
||||
request.header(Constants.AUTHORIZATION, userInfo.getToken());
|
||||
request.execute().body();
|
||||
break;
|
||||
case "2":
|
||||
// 邮件
|
||||
List<String> mailErrs = sentMessageUtil.SendMail(toUserIds, userInfo, sendType, sendConfigTemplateEntity, new HashMap<>(), contentMsg);
|
||||
errList.addAll(mailErrs.stream().distinct().collect(Collectors.toList()));
|
||||
break;
|
||||
case "3":
|
||||
// 发送短信
|
||||
List<String> smsErrs = sentMessageUtil.sendSms(toUserIds, userInfo, sendConfigTemplateEntity, parameterMap, new HashMap<>());
|
||||
errList.addAll(smsErrs.stream().distinct().collect(Collectors.toList()));
|
||||
break;
|
||||
case "4":
|
||||
// 钉钉
|
||||
JSONObject jsonObject1 = sentMessageUtil.SendDingTalk(toUserIds, userInfo, sendType, sendConfigTemplateEntity, new HashMap<>(), contentMsg);
|
||||
if (!(Boolean) jsonObject1.get("code")) {
|
||||
log.error("发送企业微信消息失败,错误:" + jsonObject1.get("error"));
|
||||
errList.add("发送钉钉消息失败,错误:" + jsonObject1.get("error"));
|
||||
}
|
||||
break;
|
||||
case "5":
|
||||
// 企业微信
|
||||
JSONObject jsonObject = sentMessageUtil.SendQyWebChat(toUserIds, userInfo, sendType, sendConfigTemplateEntity, new HashMap<>(), contentMsg);
|
||||
if (!(Boolean) jsonObject.get("code")) {
|
||||
log.error("发送企业微信消息失败,错误:" + jsonObject.get("error"));
|
||||
errList.add("发送企业微信消息失败,错误:" + jsonObject.get("error"));
|
||||
}
|
||||
break;
|
||||
case "6":
|
||||
// webhook
|
||||
sentMessageUtil.SendWebHook(sendType, userInfo, sendConfigTemplateEntity, new HashMap<>(), contentMsg);
|
||||
break;
|
||||
case "7":
|
||||
// 微信公众号
|
||||
JSONObject jsonObject2 = sentMessageUtil.SendWXGzhChat(toUserIds, userInfo, sendType, sendConfigTemplateEntity, new HashMap<>(), parameterMap);
|
||||
if (!(Boolean) jsonObject2.get("code")) {
|
||||
errList.add("发送微信公众号消息失败,错误:" + jsonObject2.get("error"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return errList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateEnabledMark() {
|
||||
QueryWrapper<MessageEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t -> t.eq(MessageEntity::getEnabledMark, 1).lt(MessageEntity::getExpirationTime, new Date()));
|
||||
List<MessageEntity> list = this.list(queryWrapper);
|
||||
list.forEach(t -> {
|
||||
t.setEnabledMark(2);
|
||||
this.updateById(t);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private void message(SentMessageForm sentMessageForm) {
|
||||
List<String> toUserIds = sentMessageForm.getToUserIds();
|
||||
Integer type = sentMessageForm.getType();
|
||||
String title = sentMessageForm.getTitle();
|
||||
String content = sentMessageForm.getContent();
|
||||
String bodyText = Objects.equals(type, 3) ? content : JsonUtil.getObjectToString(sentMessageForm.getContentMsg());
|
||||
UserInfo userInfo = sentMessageForm.getUserInfo();
|
||||
MessageReceiveEntity messageReceiveEntity = new MessageReceiveEntity();
|
||||
messageReceiveEntity.setIsRead(0);
|
||||
messageReceiveEntity.setId(RandomUtil.uuId());
|
||||
messageReceiveEntity.setType(sentMessageForm.getType());
|
||||
if (type != null) {
|
||||
messageReceiveEntity.setId(sentMessageForm.getId());
|
||||
messageReceiveEntity.setType(type);
|
||||
messageReceiveEntity.setCreatorUserId(userInfo.getUserId());
|
||||
messageReceiveEntity.setCreatorTime(DateUtil.getNowDate());
|
||||
}
|
||||
//消息监控写入
|
||||
MessageMonitorEntity monitorEntity = new MessageMonitorEntity();
|
||||
MessageEntity messageEntity = this.getInfo(sentMessageForm.getId());
|
||||
if (!"1".equals(String.valueOf(messageReceiveEntity.getType()))) {
|
||||
monitorEntity.setMessageSource(sentMessageForm.getType() + "");
|
||||
messageReceiveEntity.setFlowType(sentMessageForm.getFlowType());
|
||||
monitorEntity.setTitle(title);
|
||||
} else {
|
||||
monitorEntity.setMessageSource("1");
|
||||
title = title.replaceAll("\\{@Title}", messageEntity.getTitle())
|
||||
.replaceAll("\\{@CreatorUserName}", userInfo.getUserName())
|
||||
.replaceAll("\\{@SendTime}", DateUtil.getNow().substring(11))
|
||||
.replaceAll("\\{@Content}", messageEntity.getBodyText())
|
||||
.replaceAll("\\{@Remark}", StringUtil.isNotEmpty(messageEntity.getExcerpt()) ? messageEntity.getExcerpt() : "");
|
||||
monitorEntity.setTitle(title);
|
||||
|
||||
MessageEntity messageEntity2 = new MessageEntity();
|
||||
messageEntity2.setId(messageEntity.getId());
|
||||
bodyText = JsonUtil.getObjectToString(messageEntity2);
|
||||
}
|
||||
Map<String, MessageReceiveEntity> map = new HashMap<>();
|
||||
for (String item : toUserIds) {
|
||||
MessageReceiveEntity messageReceiveEntitys = new MessageReceiveEntity();
|
||||
BeanUtils.copyProperties(messageReceiveEntity, messageReceiveEntitys);
|
||||
messageReceiveEntitys.setId(RandomUtil.uuId());
|
||||
messageReceiveEntitys.setUserId(item);
|
||||
messageReceiveEntitys.setTitle(title);
|
||||
// if(ObjectUtil.isNotEmpty(messageEntity)) {
|
||||
// messageReceiveEntitys.setTitle(title.replaceAll("\\{@Title}", messageEntity.getTitle())
|
||||
// .replaceAll("\\{@CreatorUserName}", userInfo.getUserName())
|
||||
// .replaceAll("\\{@Content}", messageEntity.getBodyText())
|
||||
// .replaceAll("\\{@Remark}", StringUtil.isNotEmpty(messageEntity.getExcerpt()) ? messageEntity.getExcerpt() : ""));
|
||||
// }
|
||||
messageReceiveEntitys.setBodyText(bodyText);
|
||||
messagereceiveService.save(messageReceiveEntitys);
|
||||
map.put(messageReceiveEntitys.getUserId(), messageReceiveEntitys);
|
||||
}
|
||||
monitorEntity.setId(RandomUtil.uuId());
|
||||
monitorEntity.setMessageType("1");
|
||||
monitorEntity.setReceiveUser(JsonUtil.getObjectToString(toUserIds));
|
||||
monitorEntity.setSendTime(DateUtil.getNowDate());
|
||||
monitorEntity.setCreatorTime(DateUtil.getNowDate());
|
||||
monitorEntity.setCreatorUserId(userInfo.getUserId());
|
||||
monitorEntity.setContent(content);
|
||||
messageMonitorService.create(monitorEntity);
|
||||
//消息推送 - PC端
|
||||
PushMessageUtil.pushMessage(map, userInfo, type != null ? type : 2);
|
||||
}
|
||||
|
||||
|
||||
public List<NoticeVO> getNoticeList(List<String> list) {
|
||||
List<MessageEntity> dashboardNoticeList = this.getDashboardNoticeList(list);
|
||||
List<UserEntity> userList = userService.getUserName(dashboardNoticeList.stream().map(MessageEntity::getCreatorUserId).collect(Collectors.toList()));
|
||||
DictionaryTypeEntity dictionaryTypeEntity = dictionaryTypeService.getInfoByEnCode("NoticeType");
|
||||
List<DictionaryDataEntity> noticeType = dictionaryDataService.getDicList(dictionaryTypeEntity.getId());
|
||||
dashboardNoticeList.forEach(t -> {
|
||||
// 转换创建人、发布人
|
||||
UserEntity user = userList.stream().filter(ul -> ul.getId().equals(t.getCreatorUserId())).findFirst().orElse(null);
|
||||
t.setCreatorUserId(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
if (t.getEnabledMark() != null && t.getEnabledMark() != 0) {
|
||||
UserEntity entity = userService.getInfo(t.getLastModifyUserId());
|
||||
t.setLastModifyUserId(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
|
||||
}
|
||||
DictionaryDataEntity dictionaryDataEntity = noticeType.stream().filter(notice -> notice.getEnCode().equals(t.getCategory())).findFirst().orElse(new DictionaryDataEntity());
|
||||
t.setCategory(dictionaryDataEntity.getFullName());
|
||||
});
|
||||
List<NoticeVO> jsonToList = new ArrayList<>();
|
||||
dashboardNoticeList.forEach(t -> {
|
||||
NoticeVO vo = JsonUtil.getJsonToBean(t, NoticeVO.class);
|
||||
vo.setReleaseTime(t.getLastModifyTime() != null ? t.getLastModifyTime().getTime() : null);
|
||||
vo.setReleaseUser(t.getLastModifyUserId());
|
||||
vo.setCreatorUser(t.getCreatorUserId());
|
||||
jsonToList.add(vo);
|
||||
});
|
||||
return jsonToList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,494 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.database.model.superQuery.ConditionJsonModel;
|
||||
import com.yunzhupaas.database.model.superQuery.SuperQueryConditionModel;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.MessageTemplateConfigEntity;
|
||||
import com.yunzhupaas.message.entity.SmsFieldEntity;
|
||||
import com.yunzhupaas.message.entity.TemplateParamEntity;
|
||||
import com.yunzhupaas.message.mapper.MessageTemplateConfigMapper;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigForm;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigPagination;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.TemplateParamModel;
|
||||
import com.yunzhupaas.message.service.MessageTemplateConfigService;
|
||||
import com.yunzhupaas.message.service.SmsFieldService;
|
||||
import com.yunzhupaas.message.service.TemplateParamService;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
import java.lang.reflect.Field;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.visiual.YunzhupaasKeyConsts;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class MessageTemplateConfigServiceImpl
|
||||
extends SuperServiceImpl<MessageTemplateConfigMapper, MessageTemplateConfigEntity>
|
||||
implements MessageTemplateConfigService {
|
||||
|
||||
@Autowired
|
||||
private TemplateParamService templateParamService;
|
||||
|
||||
@Autowired
|
||||
private SmsFieldService smsFieldService;
|
||||
|
||||
@Override
|
||||
public List<MessageTemplateConfigEntity> getList(MessageTemplateConfigPagination MessageTemplateConfigPagination) {
|
||||
return getTypeList(MessageTemplateConfigPagination, MessageTemplateConfigPagination.getDataType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageTemplateConfigEntity> getTypeList(
|
||||
MessageTemplateConfigPagination MessageTemplateConfigPagination, String dataType) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
int total = 0;
|
||||
int messageTemplateNewNum = 0;
|
||||
QueryWrapper<MessageTemplateConfigEntity> messageTemplateNewQueryWrapper = new QueryWrapper<>();
|
||||
int templateParamNum = 0;
|
||||
QueryWrapper<TemplateParamEntity> templateParamQueryWrapper = new QueryWrapper<>();
|
||||
int smsFieldNum = 0;
|
||||
QueryWrapper<SmsFieldEntity> smsFieldQueryWrapper = new QueryWrapper<>();
|
||||
// 关键字
|
||||
if (ObjectUtil.isNotEmpty(MessageTemplateConfigPagination.getKeyword())) {
|
||||
messageTemplateNewNum++;
|
||||
messageTemplateNewQueryWrapper.lambda().and(t -> t
|
||||
.like(MessageTemplateConfigEntity::getEnCode, MessageTemplateConfigPagination.getKeyword()).or()
|
||||
.like(MessageTemplateConfigEntity::getFullName, MessageTemplateConfigPagination.getKeyword()));
|
||||
}
|
||||
// 模板类型
|
||||
if (ObjectUtil.isNotEmpty(MessageTemplateConfigPagination.getTemplateType())) {
|
||||
messageTemplateNewNum++;
|
||||
messageTemplateNewQueryWrapper.lambda().eq(MessageTemplateConfigEntity::getTemplateType,
|
||||
MessageTemplateConfigPagination.getTemplateType());
|
||||
}
|
||||
// 消息类型
|
||||
if (ObjectUtil.isNotEmpty(MessageTemplateConfigPagination.getMessageType())) {
|
||||
messageTemplateNewNum++;
|
||||
messageTemplateNewQueryWrapper.lambda().eq(MessageTemplateConfigEntity::getMessageType,
|
||||
MessageTemplateConfigPagination.getMessageType());
|
||||
}
|
||||
// 消息来源
|
||||
if (ObjectUtil.isNotEmpty(MessageTemplateConfigPagination.getMessageSource())) {
|
||||
messageTemplateNewNum++;
|
||||
messageTemplateNewQueryWrapper.lambda().eq(MessageTemplateConfigEntity::getMessageSource,
|
||||
MessageTemplateConfigPagination.getMessageSource());
|
||||
}
|
||||
// 状态
|
||||
if (ObjectUtil.isNotEmpty(MessageTemplateConfigPagination.getEnabledMark())) {
|
||||
messageTemplateNewNum++;
|
||||
int enabledMark = Integer.parseInt(MessageTemplateConfigPagination.getEnabledMark());
|
||||
messageTemplateNewQueryWrapper.lambda().eq(MessageTemplateConfigEntity::getEnabledMark, enabledMark);
|
||||
}
|
||||
|
||||
// 排序
|
||||
if (StringUtil.isEmpty(MessageTemplateConfigPagination.getSidx())) {
|
||||
messageTemplateNewQueryWrapper.lambda().orderByAsc(MessageTemplateConfigEntity::getSortCode)
|
||||
.orderByDesc(MessageTemplateConfigEntity::getCreatorTime)
|
||||
.orderByDesc(MessageTemplateConfigEntity::getLastModifyTime);
|
||||
} else {
|
||||
try {
|
||||
String sidx = MessageTemplateConfigPagination.getSidx();
|
||||
MessageTemplateConfigEntity MessageTemplateConfigEntity = new MessageTemplateConfigEntity();
|
||||
Field declaredField = MessageTemplateConfigEntity.getClass().getDeclaredField(sidx);
|
||||
declaredField.setAccessible(true);
|
||||
String value = declaredField.getAnnotation(TableField.class).value();
|
||||
messageTemplateNewQueryWrapper = "asc".equals(MessageTemplateConfigPagination.getSort().toLowerCase())
|
||||
? messageTemplateNewQueryWrapper.orderByAsc(value)
|
||||
: messageTemplateNewQueryWrapper.orderByDesc(value);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!"1".equals(dataType)) {
|
||||
if (total > 0 || total == 0) {
|
||||
Page<MessageTemplateConfigEntity> page = new Page<>(MessageTemplateConfigPagination.getCurrentPage(),
|
||||
MessageTemplateConfigPagination.getPageSize());
|
||||
IPage<MessageTemplateConfigEntity> userIPage = this.page(page, messageTemplateNewQueryWrapper);
|
||||
return MessageTemplateConfigPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
||||
} else {
|
||||
List<MessageTemplateConfigEntity> list = new ArrayList();
|
||||
return MessageTemplateConfigPagination.setData(list, list.size());
|
||||
}
|
||||
} else {
|
||||
return this.list(messageTemplateNewQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageTemplateConfigEntity getInfo(String id) {
|
||||
QueryWrapper<MessageTemplateConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageTemplateConfigEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageTemplateConfigEntity getInfoByEnCode(String enCode, String messageType) {
|
||||
QueryWrapper<MessageTemplateConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageTemplateConfigEntity::getEnCode, enCode);
|
||||
queryWrapper.lambda().eq(MessageTemplateConfigEntity::getMessageType, messageType);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(MessageTemplateConfigEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, MessageTemplateConfigEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(MessageTemplateConfigEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// 子表方法
|
||||
@Override
|
||||
public List<TemplateParamEntity> getTemplateParamList(String id,
|
||||
MessageTemplateConfigPagination MessageTemplateConfigPagination) {
|
||||
QueryWrapper<TemplateParamEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateParamEntity::getTemplateId, id);
|
||||
return templateParamService.list(templateParamService.getChild(MessageTemplateConfigPagination, queryWrapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateParamEntity> getTemplateParamList(String id) {
|
||||
QueryWrapper<TemplateParamEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateParamEntity::getTemplateId, id);
|
||||
return templateParamService.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsFieldEntity> getSmsFieldList(String id,
|
||||
MessageTemplateConfigPagination MessageTemplateConfigPagination) {
|
||||
QueryWrapper<SmsFieldEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SmsFieldEntity::getTemplateId, id);
|
||||
return smsFieldService.list(smsFieldService.getChild(MessageTemplateConfigPagination, queryWrapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsFieldEntity> getSmsFieldList(String id) {
|
||||
QueryWrapper<SmsFieldEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SmsFieldEntity::getTemplateId, id);
|
||||
return smsFieldService.list(queryWrapper);
|
||||
}
|
||||
|
||||
// 验证表单唯一字段
|
||||
@Override
|
||||
public boolean checkForm(MessageTemplateConfigForm form, int i, String id) {
|
||||
int total = 0;
|
||||
if (ObjectUtil.isNotEmpty(form.getEnCode())) {
|
||||
QueryWrapper<MessageTemplateConfigEntity> codeWrapper = new QueryWrapper<>();
|
||||
codeWrapper.lambda().eq(MessageTemplateConfigEntity::getEnCode, form.getEnCode());
|
||||
if (StringUtil.isNotBlank(id) && !"null".equals(id)) {
|
||||
codeWrapper.lambda().ne(MessageTemplateConfigEntity::getId, id);
|
||||
}
|
||||
if ((int) this.count(codeWrapper) > i) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
if (form.getTemplateParamList() != null) {
|
||||
}
|
||||
if (form.getSmsFieldList() != null) {
|
||||
}
|
||||
if (total > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByFullName(String fullName, String id) {
|
||||
QueryWrapper<MessageTemplateConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageTemplateConfigEntity::getFullName, fullName);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(MessageTemplateConfigEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByEnCode(String enCode, String id) {
|
||||
QueryWrapper<MessageTemplateConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(MessageTemplateConfigEntity::getEnCode, enCode);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(MessageTemplateConfigEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult ImportData(MessageTemplateConfigEntity entity) throws DataException {
|
||||
if (entity != null) {
|
||||
// if (isExistByFullName(entity.getFullName(), null)) {
|
||||
// return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
// }
|
||||
if (isExistByEnCode(entity.getEnCode(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
try {
|
||||
this.save(entity);
|
||||
} catch (Exception e) {
|
||||
throw new DataException(MsgCode.IMP003.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.IMP001.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.IMP006.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateParamModel> getParamJson(String id) {
|
||||
MessageTemplateConfigEntity entity = getInfo(id);
|
||||
List<TemplateParamModel> paramModelList = new ArrayList<>();
|
||||
List<String> smsField = new ArrayList<>();
|
||||
List<String> paramList = new ArrayList<>();
|
||||
if (entity != null) {
|
||||
if ("3".equals(entity.getMessageType()) || "7".equals(entity.getMessageType())) {
|
||||
List<SmsFieldEntity> smsFieldList = smsFieldService.getDetailListByParentId(id);
|
||||
for (SmsFieldEntity entity1 : smsFieldList) {
|
||||
if (!"@flowLink".equals(entity1.getField())) {
|
||||
smsField.add(entity1.getField());
|
||||
}
|
||||
}
|
||||
List<TemplateParamEntity> paramFieldList = templateParamService.getDetailListByParentId(id);
|
||||
for (TemplateParamEntity entity1 : paramFieldList) {
|
||||
if (smsField.contains(entity1.getField())) {
|
||||
TemplateParamModel paramModel = new TemplateParamModel();
|
||||
paramModel.setTemplateId(entity.getId());
|
||||
paramModel.setTemplateCode(entity.getEnCode());
|
||||
paramModel.setTemplateType(entity.getTemplateType());
|
||||
paramModel.setField(entity1.getField());
|
||||
paramModel.setFieldName(entity1.getFieldName());
|
||||
paramModel.setId(entity1.getId());
|
||||
paramModel.setTemplateName(entity.getFullName());
|
||||
paramModelList.add(paramModel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String content = StringUtil.isNotEmpty(entity.getContent()) ? entity.getContent() : "";
|
||||
String title = StringUtil.isNotEmpty(entity.getTitle()) ? entity.getTitle() : "";
|
||||
Set<String> list = new HashSet<>();
|
||||
list.addAll(regexContent(content));
|
||||
list.addAll(regexContent(title));
|
||||
List<TemplateParamEntity> paramFieldList = templateParamService.getDetailListByParentId(id);
|
||||
for (TemplateParamEntity entity1 : paramFieldList) {
|
||||
TemplateParamModel paramModel = new TemplateParamModel();
|
||||
paramModel.setTemplateId(entity.getId());
|
||||
paramModel.setTemplateCode(entity.getEnCode());
|
||||
paramModel.setTemplateType(entity.getTemplateType());
|
||||
paramModel.setField(entity1.getField());
|
||||
paramModel.setFieldName(entity1.getFieldName());
|
||||
paramModel.setId(entity1.getId());
|
||||
paramModel.setTemplateName(entity.getFullName());
|
||||
if (list.contains(entity1.getField())) {
|
||||
if (!"@FlowLink".equals(entity1.getField())
|
||||
&& !"@CreatorUserName".equals(entity1.getField())
|
||||
&& !"@SendTime".equals(entity1.getField())
|
||||
&& !"@Mandator".equals(entity1.getField())
|
||||
&& !"@Mandatary".equals(entity1.getField())) {
|
||||
paramModelList.add(paramModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 将参数模板转为json格式数据
|
||||
// String data = JsonUtil.getObjectToString(paramModelList);
|
||||
return paramModelList;
|
||||
}
|
||||
|
||||
// 获取消息内容参数
|
||||
public List<String> regexContent(String content) {
|
||||
List<String> list = new ArrayList<>();
|
||||
String pattern = "[{]([^}]+)[}]";
|
||||
Pattern patternList = Pattern.compile(pattern);
|
||||
Matcher m = patternList.matcher(content);
|
||||
while (m.find()) {
|
||||
String group = m.group().replaceAll("\\{", "").replaceAll("}", "");
|
||||
list.add(group);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 高级查询
|
||||
*
|
||||
* @param conditionModel
|
||||
* @param entity
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
public Integer getCondition(SuperQueryConditionModel conditionModel, Object entity, int num) {
|
||||
QueryWrapper<?> queryWrapper = conditionModel.getObj();
|
||||
List<ConditionJsonModel> queryConditionModels = conditionModel.getConditionList();
|
||||
String op = conditionModel.getMatchLogic();
|
||||
String tableName = conditionModel.getTableName();
|
||||
List<ConditionJsonModel> useCondition = new ArrayList<>();
|
||||
for (ConditionJsonModel queryConditionModel : queryConditionModels) {
|
||||
if (queryConditionModel.getTableName().equalsIgnoreCase(tableName)) {
|
||||
if (queryConditionModel.getField().contains("yunzhupaas")) {
|
||||
String child = queryConditionModel.getField();
|
||||
String s1 = child.substring(child.lastIndexOf("yunzhupaas_")).replace("yunzhupaas_", "");
|
||||
queryConditionModel.setField(s1);
|
||||
}
|
||||
if (queryConditionModel.getField().toLowerCase().startsWith(YunzhupaasKeyConsts.CHILD_TABLE_PREFIX)) {
|
||||
String child = queryConditionModel.getField();
|
||||
String s1 = child.substring(child.indexOf("-") + 1);
|
||||
queryConditionModel.setField(s1);
|
||||
}
|
||||
useCondition.add(queryConditionModel);
|
||||
}
|
||||
}
|
||||
|
||||
if (queryConditionModels.size() < 1 || useCondition.size() < 1) {
|
||||
return num;
|
||||
}
|
||||
if (useCondition.size() > 0) {
|
||||
num += 1;
|
||||
}
|
||||
// 处理控件 转换为有效值
|
||||
for (ConditionJsonModel queryConditionModel : useCondition) {
|
||||
String yunzhupaasKey = queryConditionModel.getYunzhupaasKey();
|
||||
String fieldValue = queryConditionModel.getFieldValue();
|
||||
if (yunzhupaasKey.equals(YunzhupaasKeyConsts.DATE)) {
|
||||
Long o1 = Long.valueOf(fieldValue);
|
||||
String startTime = DateUtil.daFormat(o1);
|
||||
queryConditionModel.setFieldValue(startTime);
|
||||
} else if (yunzhupaasKey.equals(YunzhupaasKeyConsts.CREATETIME)
|
||||
|| yunzhupaasKey.equals(YunzhupaasKeyConsts.MODIFYTIME)) {
|
||||
Long o1 = Long.valueOf(fieldValue);
|
||||
String startTime = DateUtil.daFormatHHMMSS(o1);
|
||||
queryConditionModel.setFieldValue(startTime);
|
||||
} else if (yunzhupaasKey.equals(YunzhupaasKeyConsts.CURRORGANIZE)) {
|
||||
List<String> orgList = JsonUtil.getJsonToList(fieldValue, String.class);
|
||||
queryConditionModel.setFieldValue(orgList.get(orgList.size() - 1));
|
||||
}
|
||||
}
|
||||
// 反射获取数据库实际字段
|
||||
Class<?> aClass = entity.getClass();
|
||||
|
||||
queryWrapper.and(tw -> {
|
||||
for (ConditionJsonModel conditionJsonModel : useCondition) {
|
||||
String conditionField = conditionJsonModel.getField();
|
||||
Field declaredField = null;
|
||||
try {
|
||||
declaredField = aClass.getDeclaredField(conditionField);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
declaredField.setAccessible(true);
|
||||
String field = declaredField.getAnnotation(TableField.class).value();
|
||||
String fieldValue = conditionJsonModel.getFieldValue();
|
||||
String symbol = conditionJsonModel.getSymbol();
|
||||
if ("AND".equalsIgnoreCase(op)) {
|
||||
if (symbol.equals("==")) {
|
||||
tw.eq(field, fieldValue);
|
||||
} else if (symbol.equals(">=")) {
|
||||
tw.ge(field, fieldValue);
|
||||
} else if (symbol.equals("<=")) {
|
||||
tw.le(field, fieldValue);
|
||||
tw.and(
|
||||
qw -> qw.ne(field, ""));
|
||||
} else if (symbol.equals(">")) {
|
||||
tw.gt(field, fieldValue);
|
||||
} else if (symbol.equals("<")) {
|
||||
tw.lt(field, fieldValue);
|
||||
tw.and(
|
||||
qw -> qw.ne(field, ""));
|
||||
} else if (symbol.equals("<>")) {
|
||||
tw.ne(field, fieldValue);
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
}
|
||||
} else if (symbol.equals("like")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.like(field, fieldValue);
|
||||
} else {
|
||||
tw.isNull(field);
|
||||
}
|
||||
} else if (symbol.equals("notLike")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.notLike(field, fieldValue);
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
} else {
|
||||
tw.isNotNull(field);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (symbol.equals("==")) {
|
||||
tw.or(
|
||||
qw -> qw.eq(field, fieldValue));
|
||||
} else if (symbol.equals(">=")) {
|
||||
tw.or(
|
||||
qw -> qw.ge(field, fieldValue));
|
||||
} else if (symbol.equals("<=")) {
|
||||
tw.or(
|
||||
qw -> qw.le(field, fieldValue));
|
||||
} else if (symbol.equals(">")) {
|
||||
tw.or(
|
||||
qw -> qw.gt(field, fieldValue));
|
||||
} else if (symbol.equals("<")) {
|
||||
tw.or(
|
||||
qw -> qw.lt(field, fieldValue));
|
||||
} else if (symbol.equals("<>")) {
|
||||
tw.or(
|
||||
qw -> qw.ne(field, fieldValue));
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
}
|
||||
} else if (symbol.equals("like")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.like(field, fieldValue));
|
||||
} else {
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
}
|
||||
} else if (symbol.equals("notLike")) {
|
||||
if (StringUtil.isNotEmpty(fieldValue)) {
|
||||
tw.or(
|
||||
qw -> qw.notLike(field, fieldValue));
|
||||
tw.or(
|
||||
qw -> qw.isNull(field));
|
||||
} else {
|
||||
tw.or(
|
||||
qw -> qw.isNotNull(field));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return num;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.message.entity.MessageReceiveEntity;
|
||||
import com.yunzhupaas.message.mapper.MessagereceiveMapper;
|
||||
import com.yunzhupaas.message.service.MessagereceiveService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 消息接收 服务实现类
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Service
|
||||
public class MessagereceiveServiceImpl extends SuperServiceImpl<MessagereceiveMapper, MessageReceiveEntity> implements MessagereceiveService {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.message.entity.SendConfigTemplateEntity;
|
||||
import com.yunzhupaas.message.mapper.SendConfigTemplateMapper;
|
||||
import com.yunzhupaas.message.model.sendmessageconfig.SendMessageConfigPagination;
|
||||
import com.yunzhupaas.message.service.SendConfigTemplateService;
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息发送配置
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-19
|
||||
*/
|
||||
@Service
|
||||
public class SendConfigTemplateServiceImpl extends SuperServiceImpl<SendConfigTemplateMapper, SendConfigTemplateEntity> implements SendConfigTemplateService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<SendConfigTemplateEntity> getChild(SendMessageConfigPagination pagination, QueryWrapper<SendConfigTemplateEntity> sendConfigTemplateQueryWrapper) {
|
||||
// boolean pcPermission = false;
|
||||
// boolean appPermission = false;
|
||||
// boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
|
||||
// if (isPc) {
|
||||
// }
|
||||
|
||||
return sendConfigTemplateQueryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendConfigTemplateEntity getInfo(String id) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SendConfigTemplateEntity> getDetailListByParentId(String id) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getSendConfigId, id);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SendConfigTemplateEntity> getConfigTemplateListByConfigId(String id) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getSendConfigId, id);
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getEnabledMark, 1);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsedAccount(String accountId) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getAccountConfigId, accountId);
|
||||
if (this.list(queryWrapper) != null && this.list(queryWrapper).size() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsedTemplate(String templateId) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getTemplateId, templateId);
|
||||
if (this.list(queryWrapper) != null && this.list(queryWrapper).size() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.SendConfigTemplateEntity;
|
||||
import com.yunzhupaas.message.entity.SendMessageConfigEntity;
|
||||
import com.yunzhupaas.message.mapper.SendMessageConfigMapper;
|
||||
import com.yunzhupaas.message.model.sendmessageconfig.*;
|
||||
import com.yunzhupaas.message.service.SendConfigTemplateService;
|
||||
import com.yunzhupaas.message.service.SendMessageConfigService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息发送配置
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-19
|
||||
*/
|
||||
@Service
|
||||
public class SendMessageConfigServiceImpl extends SuperServiceImpl<SendMessageConfigMapper, SendMessageConfigEntity> implements SendMessageConfigService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private SendConfigTemplateService sendConfigTemplateService;
|
||||
|
||||
@Override
|
||||
public List<SendMessageConfigEntity> getList(SendMessageConfigPagination sendMessageConfigPagination, String dataType) {
|
||||
String userId = UserProvider.getUser().getUserId();
|
||||
int total = 0;
|
||||
int sendMessageConfigNum = 0;
|
||||
QueryWrapper<SendMessageConfigEntity> sendMessageConfigQueryWrapper = new QueryWrapper<>();
|
||||
int sendConfigTemplateNum = 0;
|
||||
QueryWrapper<SendConfigTemplateEntity> sendConfigTemplateQueryWrapper = new QueryWrapper<>();
|
||||
//关键字
|
||||
if (ObjectUtil.isNotEmpty(sendMessageConfigPagination.getKeyword())) {
|
||||
sendMessageConfigNum++;
|
||||
sendMessageConfigQueryWrapper.lambda().and(t -> t.like(SendMessageConfigEntity::getEnCode, sendMessageConfigPagination.getKeyword()).
|
||||
or().like(SendMessageConfigEntity::getFullName, sendMessageConfigPagination.getKeyword()));
|
||||
}
|
||||
//模板类型
|
||||
if (ObjectUtil.isNotEmpty(sendMessageConfigPagination.getTemplateType())) {
|
||||
sendMessageConfigNum++;
|
||||
sendMessageConfigQueryWrapper.lambda().eq(SendMessageConfigEntity::getTemplateType, sendMessageConfigPagination.getTemplateType());
|
||||
}
|
||||
//状态
|
||||
if (ObjectUtil.isNotEmpty(sendMessageConfigPagination.getEnabledMark())) {
|
||||
sendMessageConfigNum++;
|
||||
int enabledMark = Integer.parseInt(sendMessageConfigPagination.getEnabledMark());
|
||||
sendMessageConfigQueryWrapper.lambda().eq(SendMessageConfigEntity::getEnabledMark, enabledMark);
|
||||
}
|
||||
//消息来源
|
||||
if (ObjectUtil.isNotEmpty(sendMessageConfigPagination.getMessageSource())) {
|
||||
sendMessageConfigNum++;
|
||||
sendMessageConfigQueryWrapper.lambda().eq(SendMessageConfigEntity::getMessageSource, sendMessageConfigPagination.getMessageSource());
|
||||
}
|
||||
|
||||
//排序
|
||||
if (StringUtil.isEmpty(sendMessageConfigPagination.getSidx())) {
|
||||
sendMessageConfigQueryWrapper.lambda().orderByAsc(SendMessageConfigEntity::getSortCode).orderByDesc(SendMessageConfigEntity::getCreatorTime).orderByDesc(SendMessageConfigEntity::getLastModifyTime);;
|
||||
} else {
|
||||
try {
|
||||
String sidx = sendMessageConfigPagination.getSidx();
|
||||
SendMessageConfigEntity sendMessageConfigEntity = new SendMessageConfigEntity();
|
||||
Field declaredField = sendMessageConfigEntity.getClass().getDeclaredField(sidx);
|
||||
declaredField.setAccessible(true);
|
||||
String value = declaredField.getAnnotation(TableField.class).value();
|
||||
sendMessageConfigQueryWrapper = "asc".equals(sendMessageConfigPagination.getSort().toLowerCase()) ? sendMessageConfigQueryWrapper.orderByAsc(value) : sendMessageConfigQueryWrapper.orderByDesc(value);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!"1".equals(dataType)) {
|
||||
if (total > 0 || total == 0) {
|
||||
Page<SendMessageConfigEntity> page = new Page<>(sendMessageConfigPagination.getCurrentPage(), sendMessageConfigPagination.getPageSize());
|
||||
IPage<SendMessageConfigEntity> userIPage = this.page(page, sendMessageConfigQueryWrapper);
|
||||
return sendMessageConfigPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
||||
} else {
|
||||
List<SendMessageConfigEntity> list = new ArrayList();
|
||||
return sendMessageConfigPagination.setData(list, list.size());
|
||||
}
|
||||
} else {
|
||||
return this.list(sendMessageConfigQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SendMessageConfigEntity> getSelectorList(SendMessageConfigPagination sendMessageConfigPagination) {
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getMessageSource, 5).eq(SendMessageConfigEntity::getEnabledMark, 1);
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getTemplateType, 0);
|
||||
Page<SendMessageConfigEntity> page = new Page<>(sendMessageConfigPagination.getCurrentPage(), sendMessageConfigPagination.getPageSize());
|
||||
IPage<SendMessageConfigEntity> userIPage = this.page(page, queryWrapper);
|
||||
return sendMessageConfigPagination.setData(userIPage.getRecords(), userIPage.getTotal());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SendMessageConfigEntity getInfo(String id) {
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageConfigEntity getInfoByEnCode(String enCode){
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getEnCode, enCode);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageConfigEntity getSysConfig(String enCode,String type){
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getTemplateType, type);
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getEnCode,enCode);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SendMessageConfigEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, SendMessageConfigEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SendMessageConfigEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
//子表方法
|
||||
@Override
|
||||
public List<SendConfigTemplateEntity> getSendConfigTemplateList(String id, SendMessageConfigPagination sendMessageConfigPagination) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getSendConfigId, id);
|
||||
return sendConfigTemplateService.list(sendConfigTemplateService.getChild(sendMessageConfigPagination, queryWrapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SendConfigTemplateEntity> getSendConfigTemplateList(String id) {
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendConfigTemplateEntity::getSendConfigId, id);
|
||||
queryWrapper.lambda().orderByDesc(SendConfigTemplateEntity::getSortCode);
|
||||
return sendConfigTemplateService.list(queryWrapper);
|
||||
}
|
||||
|
||||
//列表子表数据方法
|
||||
|
||||
|
||||
//验证表单唯一字段
|
||||
@Override
|
||||
public boolean checkForm(SendMessageConfigForm form, int i,String id) {
|
||||
int total = 0;
|
||||
if (ObjectUtil.isNotEmpty(form.getEnCode())) {
|
||||
QueryWrapper<SendMessageConfigEntity> enCodeWrapper = new QueryWrapper<>();
|
||||
enCodeWrapper.lambda().eq(SendMessageConfigEntity::getEnCode, form.getEnCode());
|
||||
if(StringUtil.isNotBlank(id) && !"null".equals(id)) {
|
||||
enCodeWrapper.lambda().ne(SendMessageConfigEntity::getId, id);
|
||||
}
|
||||
if ((int) this.count(enCodeWrapper) > i) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
if (form.getSendConfigTemplateList() != null) {
|
||||
}
|
||||
if (total > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByFullName(String fullName, String id) {
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getFullName, fullName);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(SendMessageConfigEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByEnCode(String enCode, String id) {
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SendMessageConfigEntity::getEnCode, enCode);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(SendMessageConfigEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult ImportData(SendMessageConfigEntity entity) throws DataException {
|
||||
if (entity != null) {
|
||||
// if (isExistByFullName(entity.getFullName(), null)) {
|
||||
// return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
// }
|
||||
if (isExistByEnCode(entity.getEnCode(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
try {
|
||||
this.save(entity);
|
||||
} catch (Exception e) {
|
||||
throw new DataException(MsgCode.IMP003.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.IMP001.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.IMP006.get());
|
||||
}
|
||||
@Override
|
||||
public List<SendMessageConfigEntity> getList(List<String> idList){
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(SendMessageConfigEntity::getId,idList);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getIdList(String usedId){
|
||||
List<String> idList = new ArrayList<>();
|
||||
QueryWrapper<SendMessageConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||
if(this.list(queryWrapper) != null && this.list(queryWrapper).size()>0){
|
||||
idList = this.list(queryWrapper).stream().distinct().map(t->t.getId()).collect(Collectors.toList());
|
||||
}
|
||||
return idList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUsed(String id,List<String> sendConfigIdList){
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<String> oldSendConfigList = this.getIdList(id);
|
||||
if(oldSendConfigList != null && oldSendConfigList.size()>0){
|
||||
List<String> subSendConfigIdList = this.subList(oldSendConfigList,sendConfigIdList);
|
||||
this.removeUsed(id,subSendConfigIdList);
|
||||
}
|
||||
if(sendConfigIdList != null && sendConfigIdList.size()>0) {
|
||||
List<SendMessageConfigEntity> sendConfigList = this.getList(sendConfigIdList);
|
||||
if (sendConfigIdList != null && sendConfigIdList.size() > 0) {
|
||||
// for (SendMessageConfigEntity entity : sendConfigList) {
|
||||
// SendConfigRecordEntity recordEntity = new SendConfigRecordEntity();
|
||||
// recordEntity = sendConfigRecordService.getRecord(entity.getId(),id);
|
||||
// if(recordEntity != null){
|
||||
// recordEntity.setLastModifyTime(DateUtil.getNowDate());
|
||||
// recordEntity.setLastModifyUserId(userInfo.getUserId());
|
||||
// sendConfigRecordService.update(recordEntity.getId(),recordEntity);
|
||||
// }else {
|
||||
// recordEntity = new SendConfigRecordEntity();
|
||||
// recordEntity.setId(RandomUtil.uuId());
|
||||
// recordEntity.setSendConfigId(entity.getId());
|
||||
// recordEntity.setMessageSource(entity.getMessageSource());
|
||||
// recordEntity.setUsedId(id);
|
||||
// recordEntity.setCreatorTime(DateUtil.getNowDate());
|
||||
// recordEntity.setCreatorUserId(userInfo.getUserId());
|
||||
// sendConfigRecordService.create(recordEntity);
|
||||
// }
|
||||
// }
|
||||
this.updateBatchById(sendConfigList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUsed(String id,List<String> sendConfigIdList){
|
||||
if(sendConfigIdList != null && sendConfigIdList.size()>0){
|
||||
List<SendMessageConfigEntity> subConfigList = this.getList(sendConfigIdList);
|
||||
// if(subConfigList != null && subConfigList.size()>0){
|
||||
// for(SendMessageConfigEntity subEntity : subConfigList) {
|
||||
// SendConfigRecordEntity recordEntity = sendConfigRecordService.getRecord(subEntity.getId(),id);
|
||||
// if(recordEntity != null){
|
||||
// sendConfigRecordService.delete(recordEntity);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
this.updateBatchById(subConfigList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> subList(List<String> list1, List<String> list2) {
|
||||
//空间换时间 降低时间复杂度
|
||||
Map<String, String> tempMap = new HashMap<>();
|
||||
for(String str:list2){
|
||||
tempMap.put(str,str);
|
||||
}
|
||||
//LinkedList 频繁添加删除 也可以ArrayList容量初始化为List1.size(),防止数据量过大时频繁扩容以及数组复制
|
||||
List<String> resList = new LinkedList<>();
|
||||
for(String str:list1){
|
||||
if(!tempMap.containsKey(str)){
|
||||
resList.add(str);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
@Override
|
||||
public boolean idUsed(String id){
|
||||
boolean flag = false;
|
||||
SendMessageConfigEntity entity = this.getInfo(id);
|
||||
// TODO 删除逻辑重新设置
|
||||
return flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.message.entity.ShortLinkEntity;
|
||||
import com.yunzhupaas.message.mapper.ShortLInkMapper;
|
||||
import com.yunzhupaas.message.service.ShortLinkService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class ShortLinkServiceImpl extends SuperServiceImpl<ShortLInkMapper, ShortLinkEntity> implements ShortLinkService {
|
||||
|
||||
|
||||
@Override
|
||||
public ShortLinkEntity getInfoByLink(String link){
|
||||
QueryWrapper<ShortLinkEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ShortLinkEntity::getShortLink,link);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String shortLink (String link){
|
||||
String shortUrl = null;
|
||||
if(StringUtil.isNotBlank(link)) {
|
||||
String[] aResult = shortUrl(link);//将产生4组6位字符串
|
||||
// 打印出结果
|
||||
Random random = new Random();
|
||||
int j = random.nextInt(4);//产成4以内随机数
|
||||
shortUrl = aResult[j];
|
||||
if(StringUtil.isNotBlank(shortUrl)) {
|
||||
QueryWrapper<ShortLinkEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotEmpty(shortUrl)) {
|
||||
queryWrapper.lambda().eq(ShortLinkEntity::getShortLink, shortUrl);
|
||||
}
|
||||
if (this.list(queryWrapper) != null && this.list(queryWrapper).size() > 0) {
|
||||
shortUrl = shortUrl + j;
|
||||
}
|
||||
}
|
||||
}
|
||||
return shortUrl;
|
||||
}
|
||||
|
||||
|
||||
public static String[] shortUrl(String url) {
|
||||
// 可以自定义生成 MD5 加密字符传前的混合 KEY
|
||||
String key = "test";
|
||||
// 要使用生成 URL 的字符
|
||||
String[] chars = new String[] { "a", "b", "c", "d", "e", "f", "g", "h",
|
||||
"i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
|
||||
"u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
|
||||
"6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
|
||||
"U", "V", "W", "X", "Y", "Z"
|
||||
|
||||
};
|
||||
// 对传入网址进行 MD5 加密
|
||||
String hex = md5ByHex(key + url);
|
||||
|
||||
String[] resUrl = new String[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
// 把加密字符按照 8 位一组 16 进制与 0x3FFFFFFF 进行位与运算
|
||||
String sTempSubString = hex.substring(i * 8, i * 8 + 8);
|
||||
|
||||
// 这里需要使用 long 型来转换,因为 Inteper .parseInt() 只能处理 31 位 , 首位为符号位 , 如果不用long ,则会越界
|
||||
long lHexLong = 0x3FFFFFFF & Long.parseLong(sTempSubString, 16);
|
||||
String outChars = "";
|
||||
for (int j = 0; j < 6; j++) {
|
||||
// 把得到的值与 0x0000003D 进行位与运算,取得字符数组 chars 索引
|
||||
long index = 0x0000003D & lHexLong;
|
||||
// 把取得的字符相加
|
||||
outChars += chars[(int) index];
|
||||
// 每次循环按位右移 5 位
|
||||
lHexLong = lHexLong >> 5;
|
||||
}
|
||||
// 把字符串存入对应索引的输出数组
|
||||
resUrl[i] = outChars;
|
||||
}
|
||||
return resUrl;
|
||||
}
|
||||
/**
|
||||
* MD5加密(32位大写)
|
||||
* @param src
|
||||
* @return
|
||||
*/
|
||||
public static String md5ByHex(String src) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] b = src.getBytes();
|
||||
md.reset();
|
||||
md.update(b);
|
||||
byte[] hash = md.digest();
|
||||
String hs = "";
|
||||
String stmp = "";
|
||||
for (int i = 0; i < hash.length; i++) {
|
||||
stmp = Integer.toHexString(hash[i] & 0xFF);
|
||||
if (stmp.length() == 1)
|
||||
hs = hs + "0" + stmp;
|
||||
else {
|
||||
hs = hs + stmp;
|
||||
}
|
||||
}
|
||||
return hs.toUpperCase();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.message.entity.SmsFieldEntity;
|
||||
import com.yunzhupaas.message.mapper.SmsFieldMapper;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigPagination;
|
||||
import com.yunzhupaas.message.service.SmsFieldService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class SmsFieldServiceImpl extends SuperServiceImpl<SmsFieldMapper, SmsFieldEntity> implements SmsFieldService {
|
||||
|
||||
|
||||
@Override
|
||||
public QueryWrapper<SmsFieldEntity> getChild(MessageTemplateConfigPagination pagination, QueryWrapper<SmsFieldEntity> smsFieldQueryWrapper) {
|
||||
// boolean pcPermission = false;
|
||||
// boolean appPermission = false;
|
||||
// boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
|
||||
// if (isPc) {
|
||||
// }
|
||||
|
||||
return smsFieldQueryWrapper;
|
||||
}
|
||||
@Override
|
||||
public SmsFieldEntity getInfo(String id) {
|
||||
QueryWrapper<SmsFieldEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SmsFieldEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsFieldEntity> getDetailListByParentId(String id) {
|
||||
QueryWrapper<SmsFieldEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SmsFieldEntity::getTemplateId, id);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsFieldEntity> getParamList(String id,List<String> params) {
|
||||
QueryWrapper<SmsFieldEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SmsFieldEntity::getTemplateId, id);
|
||||
queryWrapper.lambda().in(SmsFieldEntity::getField,params);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> getParamMap(String templateId,Map<String,Object> map) {
|
||||
Map<String,Object> paramMap = new HashMap<>();
|
||||
List<SmsFieldEntity> list = this.getDetailListByParentId(templateId);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (SmsFieldEntity entity : list) {
|
||||
if (map.containsKey(entity.getField())) {
|
||||
for (String key : map.keySet()) {
|
||||
if (key.equals(entity.getField())) {
|
||||
paramMap.put(entity.getSmsField(), map.get(key));
|
||||
if(StringUtil.isNotEmpty(String.valueOf(entity.getIsTitle())) &&!"null".equals(String.valueOf(entity.getIsTitle())) && entity.getIsTitle()==1){
|
||||
paramMap.put("title",map.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(entity.getField().equals("@FlowLink")){
|
||||
paramMap.put(entity.getSmsField(),"@FlowLink");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return paramMap;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,303 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
|
||||
import com.yunzhupaas.message.entity.SynThirdInfoEntity;
|
||||
import com.yunzhupaas.message.mapper.SynThirdInfoMapper;
|
||||
import com.yunzhupaas.message.model.message.DingTalkDeptModel;
|
||||
import com.yunzhupaas.message.service.SynThirdDingTalkService;
|
||||
import com.yunzhupaas.message.service.SynThirdInfoService;
|
||||
import com.yunzhupaas.base.util.SynDingTalkUtil;
|
||||
import com.yunzhupaas.message.util.SynThirdConsts;
|
||||
import com.yunzhupaas.message.util.SynThirdTotal;
|
||||
import com.yunzhupaas.permission.service.OrganizeService;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 第三方工具的公司-部门-用户同步表模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/23 17:33
|
||||
*/
|
||||
@Service
|
||||
public class SynThirdInfoServiceImpl extends SuperServiceImpl<SynThirdInfoMapper, SynThirdInfoEntity> implements SynThirdInfoService {
|
||||
@Autowired
|
||||
private OrganizeService organizeApi;
|
||||
@Autowired
|
||||
private UserService userApi;
|
||||
@Autowired
|
||||
SynThirdDingTalkService synThirdDingTalkService;
|
||||
|
||||
@Override
|
||||
public List<SynThirdInfoEntity> getList(String thirdType, String dataType) {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getThirdType, Integer.valueOf(thirdType)));
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getDataType, Integer.valueOf(dataType)));
|
||||
queryWrapper.lambda().orderByAsc(SynThirdInfoEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynThirdInfoEntity getInfo(String id) {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SynThirdInfoEntity::getId,id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SynThirdInfoEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, SynThirdInfoEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SynThirdInfoEntity entity) {
|
||||
if(entity!=null){
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynThirdInfoEntity getInfoBySysObjId(String thirdType,String dataType,String id) {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getThirdType,thirdType));
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getDataType,dataType));
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getSysObjId,id));
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynThirdTotal getSynTotal(String thirdType, String dataType) {
|
||||
String synType = dataType.equals(SynThirdConsts.DATA_TYPE_ORG) ? "组织" : "用户";
|
||||
Integer recordTotal = 0;
|
||||
Long synSuccessCount = 0L;
|
||||
Long synFailCount = 0L;
|
||||
Long unSynCount = 0L;
|
||||
Date synDate = null;
|
||||
|
||||
// 获取列表数据
|
||||
List<SynThirdInfoEntity> synList = getList(thirdType, dataType).stream().filter(t->t.getLastModifyTime() != null).collect(Collectors.toList());
|
||||
if(synList!=null && synList.size()>0){
|
||||
synSuccessCount = synList.stream().filter(t -> t.getEnabledMark().equals(SynThirdConsts.SYN_STATE_OK)).count();
|
||||
synFailCount = synList.stream().filter(t -> t.getEnabledMark().equals(SynThirdConsts.SYN_STATE_FAIL)).count();
|
||||
unSynCount = synList.stream().filter(t -> t.getEnabledMark().equals(SynThirdConsts.SYN_STATE_NO)).count();
|
||||
synDate = synList.stream().max(Comparator.comparing(u -> u.getLastModifyTime())).isPresent() ? synList.stream().max(Comparator.comparing(u -> u.getLastModifyTime())).get().getLastModifyTime() : null;
|
||||
}
|
||||
|
||||
// 获取本系统的组织、用户表的记录数
|
||||
if(dataType.equals(SynThirdConsts.DATA_TYPE_ORG)){
|
||||
// 获取组织(公司和部门)的记录数
|
||||
recordTotal = organizeApi.getList(false).size();
|
||||
}else{
|
||||
// 获取用户的记录数
|
||||
recordTotal = userApi.getList(false).size();
|
||||
}
|
||||
|
||||
// 写入同步统计模型对象
|
||||
SynThirdTotal synThirdTotal = new SynThirdTotal();
|
||||
synThirdTotal.setSynType(synType);
|
||||
synThirdTotal.setRecordTotal(recordTotal);
|
||||
synThirdTotal.setSynSuccessCount(synSuccessCount);
|
||||
synThirdTotal.setSynFailCount(synFailCount);
|
||||
synThirdTotal.setUnSynCount(unSynCount);
|
||||
synThirdTotal.setSynDate(synDate);
|
||||
|
||||
return synThirdTotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SynThirdInfoEntity> syncThirdInfoByType(String thirdToSysType, String dataTypeOrg, String SysToThirdType) {
|
||||
|
||||
HashMap<String,String> typeMap = new HashMap<>();
|
||||
typeMap.put(SysToThirdType,thirdToSysType);
|
||||
typeMap.put(thirdToSysType,SysToThirdType);
|
||||
|
||||
List<SynThirdInfoEntity> synThirdInfoList = this.getList(thirdToSysType, dataTypeOrg);
|
||||
List<SynThirdInfoEntity> synThirdInfoDingList = this.getList( typeMap.get(thirdToSysType), dataTypeOrg);
|
||||
|
||||
|
||||
List<String> collectSource = synThirdInfoList.stream().filter(t -> StringUtil.isBlank(t.getThirdObjId()) || StringUtil.isBlank(t.getSysObjId())).map(t->t.getId()).collect(Collectors.toList());
|
||||
List<String> collectTarget = synThirdInfoDingList.stream().filter(t -> StringUtil.isBlank(t.getThirdObjId()) || StringUtil.isBlank(t.getSysObjId())).map(t->t.getId()).collect(Collectors.toList());
|
||||
List<String> deleteList = new ArrayList<>();
|
||||
deleteList.addAll(collectSource);
|
||||
deleteList.addAll(collectTarget);
|
||||
// List<String> fails = this.selectAllFail();
|
||||
// deleteList.addAll(fails);
|
||||
if(!deleteList.isEmpty()){
|
||||
|
||||
this.getBaseMapper().deleteBatchIds(deleteList);
|
||||
}
|
||||
|
||||
|
||||
synThirdInfoList = this.getList(thirdToSysType, dataTypeOrg);
|
||||
synThirdInfoDingList = this.getList( typeMap.get(thirdToSysType), dataTypeOrg);
|
||||
// 记录已经存在的组合
|
||||
HashMap<String,Boolean> existingMap = new HashMap<>();
|
||||
synThirdInfoList.forEach(k->{
|
||||
String tag = k.getThirdType() + "-" + k.getDataType() + "-" +k.getSysObjId() +"-"+k.getThirdObjId();
|
||||
existingMap.put(tag,true);
|
||||
});
|
||||
synThirdInfoDingList.forEach(k->{
|
||||
String tag = k.getThirdType() + "-" + k.getDataType() + "-" +k.getSysObjId() +"-"+k.getThirdObjId();
|
||||
existingMap.put(tag,true);
|
||||
});
|
||||
|
||||
|
||||
HashMap<String, SynThirdInfoEntity> mapSource = new HashMap<>();
|
||||
HashMap<String, SynThirdInfoEntity> mapTarget = new HashMap<>();
|
||||
String tag = "";
|
||||
for(SynThirdInfoEntity entity :synThirdInfoList){
|
||||
// if(collectSource.size()>0 && !collectSource.contains(entity.getId())){
|
||||
tag =entity.getSysObjId() +"-" + entity.getThirdObjId();
|
||||
mapSource.put(tag,entity);
|
||||
// }
|
||||
}
|
||||
for(SynThirdInfoEntity entity :synThirdInfoDingList){
|
||||
// if(collectTarget.size()>0 && !collectTarget.contains(entity.getId())){
|
||||
tag =entity.getSysObjId() +"-" + entity.getThirdObjId();
|
||||
mapTarget.put(tag,entity);
|
||||
// }
|
||||
}
|
||||
|
||||
// 同步记录
|
||||
List<SynThirdInfoEntity> synThirdInfoAddList = new ArrayList<>();
|
||||
SynThirdInfoEntity addEntity = null;
|
||||
if(mapSource.size()==0 && mapTarget.size()==0){
|
||||
return new ArrayList<>();
|
||||
}else if (mapSource.size()>0 && mapTarget.size()==0){
|
||||
for(String key : mapSource.keySet()){
|
||||
SynThirdInfoEntity synThirdInfoEntity = mapSource.get(key);
|
||||
addEntity = JsonUtil.getJsonToBean(synThirdInfoEntity,SynThirdInfoEntity.class);
|
||||
addEntity.setId(RandomUtil.uuId());
|
||||
addEntity.setThirdType(Integer.valueOf(typeMap.get(thirdToSysType)));
|
||||
synThirdInfoAddList.add(addEntity);
|
||||
}
|
||||
|
||||
}else if (mapSource.size()==0 && mapTarget.size()>0){
|
||||
for(String key : mapTarget.keySet()){
|
||||
SynThirdInfoEntity synThirdInfoEntity = mapTarget.get(key);
|
||||
addEntity = JsonUtil.getJsonToBean(synThirdInfoEntity,SynThirdInfoEntity.class);
|
||||
addEntity.setId(RandomUtil.uuId());
|
||||
addEntity.setThirdType(Integer.valueOf(thirdToSysType));
|
||||
synThirdInfoAddList.add(addEntity);
|
||||
}
|
||||
}else{
|
||||
for(String key : mapSource.keySet()){
|
||||
if(!mapTarget.containsKey(key)){
|
||||
SynThirdInfoEntity synThirdInfoEntity = mapSource.get(key);
|
||||
addEntity = JsonUtil.getJsonToBean(synThirdInfoEntity,SynThirdInfoEntity.class);
|
||||
addEntity.setId(RandomUtil.uuId());
|
||||
addEntity.setThirdType(Integer.valueOf(typeMap.get(thirdToSysType)));
|
||||
synThirdInfoAddList.add(addEntity);
|
||||
}
|
||||
}
|
||||
for(String key : mapTarget.keySet()){
|
||||
if(!mapSource.containsKey(key)){
|
||||
SynThirdInfoEntity synThirdInfoEntity = mapTarget.get(key);
|
||||
addEntity = JsonUtil.getJsonToBean(synThirdInfoEntity,SynThirdInfoEntity.class);
|
||||
addEntity.setId(RandomUtil.uuId());
|
||||
addEntity.setThirdType(Integer.valueOf(thirdToSysType));
|
||||
synThirdInfoAddList.add(addEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ArrayList<SynThirdInfoEntity> addList = new ArrayList<>();
|
||||
if(synThirdInfoAddList.size() > 0 ){
|
||||
// 过滤
|
||||
synThirdInfoAddList.forEach(k->{
|
||||
String addTag = k.getThirdType() + "-" + k.getDataType() + "-" +k.getSysObjId() +"-"+k.getThirdObjId();
|
||||
if (existingMap.get(addTag)==null) {
|
||||
addList.add(k);
|
||||
}
|
||||
});
|
||||
this.saveBatch(addList);
|
||||
}
|
||||
// 查找对应的数据
|
||||
synThirdInfoList = this.getList(thirdToSysType, dataTypeOrg);
|
||||
return synThirdInfoList;
|
||||
}
|
||||
|
||||
private List<String> selectAllFail() {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getEnabledMark,"2"));
|
||||
List<SynThirdInfoEntity> lists = this.getBaseMapper().selectList(queryWrapper);
|
||||
return lists.stream().map(t->t.getId()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initBaseDept(Long dingRootDeptId, String access_token, String thirdType) {
|
||||
final String sysByThird = this.getSysByThird("1");
|
||||
// 判断是否在中间表存在
|
||||
JSONObject retMsg = new JSONObject();
|
||||
|
||||
if(StringUtil.isBlank(sysByThird)){
|
||||
if("22".equals(thirdType)){
|
||||
retMsg = SynDingTalkUtil.getDepartmentInfo(SynThirdConsts.DING_ROOT_DEPT_ID, access_token);
|
||||
OapiV2DepartmentGetResponse.DeptGetResponse departmentInfo = (OapiV2DepartmentGetResponse.DeptGetResponse) retMsg.get("departmentInfo");
|
||||
DingTalkDeptModel model = JsonUtil.getJsonToBean(departmentInfo, DingTalkDeptModel.class);
|
||||
retMsg = synThirdDingTalkService.createDepartmentDingToSys(true, model, access_token);
|
||||
}
|
||||
// if("11".equals(thirdType)){
|
||||
// retMsg = SynDingTalkUtil.getDepartmentInfo(SynThirdConsts.QY_ROOT_DEPT_ID, access_token);
|
||||
// OapiV2DepartmentGetResponse.DeptGetResponse departmentInfo = (OapiV2DepartmentGetResponse.DeptGetResponse) retMsg.get("departmentInfo");
|
||||
// DingTalkDeptModel model = JsonUtil.getJsonToBean(departmentInfo, DingTalkDeptModel.class);
|
||||
// retMsg = synThirdDingTalkService.createDepartmentDingToSys(true, model, access_token);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBySysObjId(String id) {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SynThirdInfoEntity::getEnabledMark,"1");
|
||||
queryWrapper.lambda().eq(SynThirdInfoEntity::getSysObjId,id);
|
||||
List<SynThirdInfoEntity> list = this.getBaseMapper().selectList(queryWrapper);
|
||||
if(list!=null && list.size() > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSysByThird(String valueOf) {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().isNotNull(SynThirdInfoEntity::getSysObjId);
|
||||
queryWrapper.lambda().eq(SynThirdInfoEntity::getThirdObjId,valueOf);
|
||||
List<SynThirdInfoEntity> list = this.getBaseMapper().selectList(queryWrapper);
|
||||
if(list!=null && !list.isEmpty()){
|
||||
return list.get(0).getSysObjId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SynThirdInfoEntity getInfoByThirdObjId(String thirdType,String dataType,String thirdObjId) {
|
||||
QueryWrapper<SynThirdInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getThirdType,thirdType));
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getDataType,dataType));
|
||||
queryWrapper.lambda().and(t->t.eq(SynThirdInfoEntity::getThirdObjId,thirdObjId));
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.message.entity.TemplateParamEntity;
|
||||
import com.yunzhupaas.message.mapper.TemplateParamMapper;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigPagination;
|
||||
import com.yunzhupaas.message.service.TemplateParamService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class TemplateParamServiceImpl extends SuperServiceImpl<TemplateParamMapper, TemplateParamEntity> implements TemplateParamService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<TemplateParamEntity> getChild(MessageTemplateConfigPagination pagination, QueryWrapper<TemplateParamEntity> templateParamQueryWrapper) {
|
||||
// boolean pcPermission = false;
|
||||
// boolean appPermission = false;
|
||||
// boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
|
||||
// if (isPc) {
|
||||
// }
|
||||
|
||||
return templateParamQueryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateParamEntity getInfo(String id) {
|
||||
QueryWrapper<TemplateParamEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateParamEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateParamEntity> getDetailListByParentId(String id) {
|
||||
QueryWrapper<TemplateParamEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateParamEntity::getTemplateId, id);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateParamEntity> getParamList(String id,List<String> params) {
|
||||
QueryWrapper<TemplateParamEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateParamEntity::getTemplateId, id);
|
||||
queryWrapper.lambda().in(TemplateParamEntity::getField,params);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.message.entity.UserDeviceEntity;
|
||||
import com.yunzhupaas.message.mapper.UserDeviceMapper;
|
||||
|
||||
import com.yunzhupaas.message.service.UserDeviceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class UserDeviceServiceImpl extends SuperServiceImpl<UserDeviceMapper, UserDeviceEntity> implements UserDeviceService {
|
||||
|
||||
|
||||
@Override
|
||||
public UserDeviceEntity getInfoByUserId(String userId){
|
||||
QueryWrapper<UserDeviceEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserDeviceEntity::getUserId,userId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCidList(String userId){
|
||||
List<String> cidList = new ArrayList<>();
|
||||
QueryWrapper<UserDeviceEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserDeviceEntity::getUserId,userId);
|
||||
if(this.list(queryWrapper) != null && this.list(queryWrapper).size()>0) {
|
||||
cidList = this.list(queryWrapper).stream().map(t -> t.getClientId()).distinct().collect(Collectors.toList());
|
||||
}
|
||||
return cidList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDeviceEntity getInfoByClientId(String clientId){
|
||||
QueryWrapper<UserDeviceEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserDeviceEntity::getClientId,clientId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(UserDeviceEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, UserDeviceEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(UserDeviceEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yunzhupaas.message.service.impl;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.message.entity.WechatUserEntity;
|
||||
import com.yunzhupaas.message.mapper.WechatUserMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
import com.yunzhupaas.message.service.WechatUserService;
|
||||
import com.yunzhupaas.permission.service.AuthorizeService;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
* 版本: V3.2.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2022-08-18
|
||||
*/
|
||||
@Service
|
||||
public class WechatUserServiceImpl extends SuperServiceImpl<WechatUserMapper, WechatUserEntity> implements WechatUserService {
|
||||
|
||||
|
||||
@Override
|
||||
public WechatUserEntity getInfoByGzhId(String userId,String gzhId){
|
||||
QueryWrapper<WechatUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(WechatUserEntity::getUserId,userId);
|
||||
queryWrapper.lambda().eq(WechatUserEntity::getGzhId,gzhId);
|
||||
queryWrapper.lambda().eq(WechatUserEntity::getCloseMark,1);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(WechatUserEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, WechatUserEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(WechatUserEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yunzhupaas.message.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.message.entity.MessageReceiveEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 消息推送工具类
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-07-07
|
||||
*/
|
||||
@Component
|
||||
public class PushMessageUtil {
|
||||
|
||||
/**
|
||||
* 工作流消息发送
|
||||
*
|
||||
*
|
||||
* @param userInfo
|
||||
*/
|
||||
public static void pushMessage(Map<String, MessageReceiveEntity> map, UserInfo userInfo, int messageType){
|
||||
for (String userId : map.keySet()) {
|
||||
for (OnlineUserModel item : OnlineUserProvider.getOnlineUserList()) {
|
||||
if (userId.equals(item.getUserId()) && Objects.equals(userInfo.getTenantId(), item.getTenantId())) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("method", "messagePush");
|
||||
jsonObject.put("unreadNoticeCount", 1);
|
||||
jsonObject.put("messageType", messageType);
|
||||
jsonObject.put("userId", userInfo.getUserId());
|
||||
jsonObject.put("toUserId", userId);
|
||||
jsonObject.put("title", map.get(userId).getTitle());
|
||||
jsonObject.put("id",map.get(userId).getId());
|
||||
jsonObject.put("messageDefaultTime", map.get(userId).getLastModifyTime() != null ? map.get(userId).getLastModifyTime().getTime() : null);
|
||||
OnlineUserProvider.sendMessage(item, jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
22
yunzhupaas-message/yunzhupaas-message-controller/pom.xml
Normal file
22
yunzhupaas-message/yunzhupaas-message-controller/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-message</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-message-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-message-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,531 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.service.BillRuleService;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.DictionaryTypeService;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.AccountConfigEntity;
|
||||
import com.yunzhupaas.message.model.accountconfig.*;
|
||||
import com.yunzhupaas.message.model.message.EmailModel;
|
||||
import com.yunzhupaas.message.service.AccountConfigService;
|
||||
import com.yunzhupaas.message.service.SendConfigTemplateService;
|
||||
import com.yunzhupaas.message.util.EmailUtil;
|
||||
import com.yunzhupaas.message.util.QyWebChatUtil;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.emnus.ModuleTypeEnum;
|
||||
import com.yunzhupaas.util.FileExport;
|
||||
import com.yunzhupaas.util.third.DingTalkUtil;
|
||||
import com.yunzhupaas.util.wxutil.HttpUtil;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 账号配置功能
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "账号配置功能", description = "message")
|
||||
@RequestMapping("/api/message/AccountConfig")
|
||||
public class AccountConfigController extends SuperController<AccountConfigService, AccountConfigEntity> {
|
||||
|
||||
@Autowired
|
||||
private FileExport fileExport;
|
||||
|
||||
@Autowired
|
||||
private BillRuleService billRuleService;
|
||||
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
@Autowired
|
||||
private UserService userApi;
|
||||
|
||||
@Autowired
|
||||
private AccountConfigService accountConfigService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private SendConfigTemplateService sendConfigTemplateService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param accountConfigPagination 账号配置分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<AccountConfigListVO>> list(AccountConfigPagination accountConfigPagination) throws IOException {
|
||||
List<AccountConfigEntity> list = accountConfigService.getList(accountConfigPagination);
|
||||
List<DictionaryDataEntity> smsSendTypeList = dictionaryDataApi.getListByTypeDataCode("smsSendType");
|
||||
List<DictionaryDataEntity> webHookList = dictionaryDataApi.getListByTypeDataCode("msgWebHookSendType");
|
||||
//处理id字段转名称,若无需转或者为空可删除
|
||||
UserEntity userEntity;
|
||||
List<AccountConfigListVO> listVO = JsonUtil.getJsonToList(list, AccountConfigListVO.class);
|
||||
for (AccountConfigListVO accountConfigVO : listVO) {
|
||||
//渠道
|
||||
if (StringUtil.isNotEmpty(accountConfigVO.getChannel())) {
|
||||
smsSendTypeList.stream().filter(t -> accountConfigVO.getChannel().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> accountConfigVO.setChannel(dataTypeEntity.getFullName()));
|
||||
}
|
||||
//webhook类型
|
||||
if (accountConfigVO.getWebhookType() != null) {
|
||||
webHookList.stream().filter(t -> accountConfigVO.getWebhookType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> accountConfigVO.setWebhookType(dataTypeEntity.getFullName()));
|
||||
}
|
||||
|
||||
if (StringUtil.isNotEmpty(accountConfigVO.getCreatorUserId())) {
|
||||
userEntity = userApi.getInfo(accountConfigVO.getCreatorUserId());
|
||||
if (userEntity != null) {
|
||||
accountConfigVO.setCreatorUser(userEntity.getRealName() + "/" + userEntity.getAccount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(accountConfigPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param accountConfigForm 新建账号配置模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "新建")
|
||||
@Parameters({
|
||||
@Parameter(name = "accountConfigForm", description = "新建账号配置模型")
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@PostMapping
|
||||
@Transactional
|
||||
public ActionResult create(@RequestBody @Valid AccountConfigForm accountConfigForm) throws DataException {
|
||||
boolean b = accountConfigService.checkForm(accountConfigForm, 0,accountConfigForm.getType(),"");
|
||||
if (b) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
boolean c = accountConfigService.checkGzhId(accountConfigForm.getAppKey(),0, "7", "");
|
||||
if("7".equals(accountConfigForm.getType())) {
|
||||
if (c) {
|
||||
return ActionResult.fail(MsgCode.FA048.get());
|
||||
}
|
||||
}
|
||||
String mainId = RandomUtil.uuId();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
AccountConfigEntity entity = JsonUtil.getJsonToBean(accountConfigForm, AccountConfigEntity.class);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setId(mainId);
|
||||
accountConfigService.save(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
public ActionResult<AccountConfigInfoVO> info(@PathVariable("id") String id) {
|
||||
AccountConfigEntity entity = accountConfigService.getInfo(id);
|
||||
AccountConfigInfoVO vo = JsonUtil.getJsonToBean(entity, AccountConfigInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单信息(详情页)
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "表单信息(详情页)")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@GetMapping("/detail/{id}")
|
||||
public ActionResult<AccountConfigInfoVO> detailInfo(@PathVariable("id") String id) {
|
||||
return info(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param accountConfigForm 修改账号配置模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "更新")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "accountConfigForm", description = "修改账号配置模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@Transactional
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid AccountConfigForm accountConfigForm) throws DataException {
|
||||
|
||||
boolean b = accountConfigService.checkForm(accountConfigForm, 0,accountConfigForm.getType(),accountConfigForm.getId());
|
||||
if (b) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
boolean c = accountConfigService.checkGzhId(accountConfigForm.getAppKey(),0, "7", id);
|
||||
if("7".equals(accountConfigForm.getType())) {
|
||||
if (c) {
|
||||
return ActionResult.fail(MsgCode.FA048.get());
|
||||
}
|
||||
}
|
||||
//判断配置是否被引用
|
||||
if(Objects.equals(0, accountConfigForm.getEnabledMark())){
|
||||
if(sendConfigTemplateService.isUsedAccount(accountConfigForm.getId())) {
|
||||
return ActionResult.fail(MsgCode.FA049.get());
|
||||
}
|
||||
}
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
AccountConfigEntity entity = accountConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
AccountConfigEntity subentity = JsonUtil.getJsonToBean(accountConfigForm, AccountConfigEntity.class);
|
||||
subentity.setCreatorTime(entity.getCreatorTime());
|
||||
subentity.setCreatorUserId(entity.getCreatorUserId());
|
||||
subentity.setLastModifyTime(DateUtil.getNowDate());
|
||||
subentity.setLastModifyUserId(userInfo.getUserId());
|
||||
boolean b1 = accountConfigService.updateById(subentity);
|
||||
if (!b1) {
|
||||
return ActionResult.fail(MsgCode.VS405.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@Transactional
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
AccountConfigEntity entity = accountConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
//判断是否与消息发送配置关联
|
||||
//判断配置是否被引用
|
||||
if(sendConfigTemplateService.isUsedAccount(entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.FA050.get());
|
||||
}
|
||||
|
||||
accountConfigService.delete(entity);
|
||||
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开启或禁用
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "开启或禁用")
|
||||
@PostMapping("/unable/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@Transactional
|
||||
public ActionResult unable(@PathVariable("id") String id) {
|
||||
AccountConfigEntity entity = accountConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
if("1".equals(String.valueOf(entity.getEnabledMark()))){
|
||||
entity.setEnabledMark(0);
|
||||
return ActionResult.success(MsgCode.WF027.get());
|
||||
}else {
|
||||
//判断是否被引用
|
||||
|
||||
entity.setEnabledMark(1);
|
||||
return ActionResult.success(MsgCode.WF026.get());
|
||||
}
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "复制")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@PostMapping("/{id}/Actions/Copy")
|
||||
@Transactional
|
||||
public ActionResult copy(@PathVariable("id") String id) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
AccountConfigEntity entity = accountConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
entity.setEnabledMark(0);
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName()+".副本"+copyNum);
|
||||
entity.setEnCode(entity.getEnCode()+copyNum);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
if("7".equals(entity.getType())){
|
||||
entity.setAppKey(entity.getAppKey()+"副本"+copyNum);
|
||||
}
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
AccountConfigEntity copyEntity = JsonUtil.getJsonToBean(entity, AccountConfigEntity.class);
|
||||
if(copyEntity.getEnCode().length()>50 || copyEntity.getFullName().length()>50){
|
||||
return ActionResult.fail(MsgCode.PRI006.get());
|
||||
}
|
||||
accountConfigService.create(copyEntity);
|
||||
return ActionResult.success(MsgCode.SU007.get());
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.FA004.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出账号配置
|
||||
*
|
||||
* @param id 账号配置id
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "导出")
|
||||
@GetMapping("/{id}/Action/Export")
|
||||
public ActionResult export(@PathVariable String id) {
|
||||
AccountConfigEntity entity = accountConfigService.getInfo(id);
|
||||
//导出文件
|
||||
DownloadVO downloadVO = fileExport.exportFile(entity, configValueUtil.getTemporaryFilePath(), entity.getFullName(), ModuleTypeEnum.ACCOUNT_CONFIG.getTableName());
|
||||
return ActionResult.success(downloadVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入账号配置
|
||||
*
|
||||
* @param multipartFile 备份json文件
|
||||
* @return 执行结果标识
|
||||
*/
|
||||
@Operation(summary = "导入")
|
||||
@PostMapping(value = "/Action/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ActionResult importData(@RequestPart("file") MultipartFile multipartFile) throws DataException {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
//判断是否为.json结尾
|
||||
if (FileUtil.existsSuffix(multipartFile, ModuleTypeEnum.ACCOUNT_CONFIG.getTableName())) {
|
||||
return ActionResult.fail(MsgCode.IMP002.get());
|
||||
}
|
||||
//获取文件内容
|
||||
String fileContent = FileUtil.getFileContent(multipartFile);
|
||||
AccountConfigEntity entity = JsonUtil.getJsonToBean(fileContent, AccountConfigEntity.class);
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
return accountConfigService.ImportData(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试发送邮件
|
||||
*
|
||||
* @param accountConfigForm 账号测试模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "测试发送邮箱")
|
||||
@Parameters({
|
||||
@Parameter(name = "accountConfigForm", description = "账号测试模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@PostMapping("/testSendMail")
|
||||
@Transactional
|
||||
public ActionResult testSendMail(@RequestBody @Valid AccountConfigForm accountConfigForm) {
|
||||
List<String> toMails = accountConfigForm.getTestSendEmail();
|
||||
// 获取邮箱配置
|
||||
Map<String, String> objModel = new HashMap<>();
|
||||
objModel.put("emailSmtpHost",accountConfigForm.getSmtpServer());
|
||||
objModel.put("emailSmtpPort",accountConfigForm.getSmtpPort().toString());
|
||||
objModel.put("emailSenderName",accountConfigForm.getAddressorName());
|
||||
objModel.put("emailAccount",accountConfigForm.getSmtpUser());
|
||||
objModel.put("emailPassword",accountConfigForm.getSmtpPassword());
|
||||
objModel.put("emailSsl",accountConfigForm.getSslLink()== 1 ? "true" : "false");
|
||||
|
||||
|
||||
EmailModel emailModel = JsonUtil.getJsonToBean(objModel, EmailModel.class);
|
||||
StringBuilder toUserMail = new StringBuilder();
|
||||
String userEmailAll = "";
|
||||
String userEmail = "";
|
||||
String userName = "";
|
||||
|
||||
// 相关参数验证
|
||||
if (StringUtil.isEmpty(emailModel.getEmailSmtpHost())) {
|
||||
return ActionResult.fail(MsgCode.MSERR101.get());
|
||||
} else if (StringUtil.isEmpty(emailModel.getEmailSmtpPort())) {
|
||||
return ActionResult.fail(MsgCode.MSERR101.get());
|
||||
} else if (StringUtil.isEmpty(emailModel.getEmailAccount())) {
|
||||
return ActionResult.fail(MsgCode.MSERR102.get());
|
||||
} else if (StringUtil.isEmpty(emailModel.getEmailPassword())) {
|
||||
return ActionResult.fail(MsgCode.MSERR103.get());
|
||||
} else if (toMails == null || toMails.size() < 1) {
|
||||
return ActionResult.fail(MsgCode.MSERR104.get());
|
||||
} else {
|
||||
// 设置邮件标题
|
||||
emailModel.setEmailTitle(accountConfigForm.getTestEmailTitle());
|
||||
// 设置邮件内容
|
||||
String content = accountConfigForm.getTestEmailContent();
|
||||
emailModel.setEmailContent(content);
|
||||
|
||||
// 获取收件人的邮箱地址、创建消息用户实体
|
||||
for (String userId : toMails) {
|
||||
UserEntity userEntity = userApi.getInfo(userId);
|
||||
if (userEntity != null) {
|
||||
userEmail = StringUtil.isEmpty(userEntity.getEmail()) ? "" : userEntity.getEmail();
|
||||
userName = userEntity.getRealName();
|
||||
}
|
||||
if (StringUtil.isNotBlank(userEmail) && !"null".equals(userEmail)) {
|
||||
//校验用户邮箱格式
|
||||
if(!isEmail(userEmail)){
|
||||
return ActionResult.fail(MsgCode.MSERR105.get(userName));
|
||||
}
|
||||
toUserMail = toUserMail.append(",").append(userName).append("<").append(userEmail).append(">");
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.MSERR106.get(userName));
|
||||
}
|
||||
}
|
||||
// 处理接收人员的邮箱信息串并验证
|
||||
userEmailAll = toUserMail.toString();
|
||||
if (StringUtil.isNotEmpty(userEmailAll)) {
|
||||
userEmailAll = userEmailAll.substring(1);
|
||||
}
|
||||
if (StringUtil.isEmpty(userEmailAll)) {
|
||||
return ActionResult.fail(MsgCode.MSERR107.get());
|
||||
} else {
|
||||
// 设置接收人员
|
||||
emailModel.setEmailToUsers(userEmailAll);
|
||||
// 发送邮件
|
||||
JSONObject retJson = EmailUtil.sendMail(emailModel);
|
||||
if (!retJson.getBoolean("code")) {
|
||||
return ActionResult.fail(MsgCode.MSERR108.get(retJson.get("error")));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResult.success(MsgCode.MSERR111.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试企业微信配置的连接功能
|
||||
*
|
||||
* @param accountConfigForm 账号测试模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "测试企业微信配置的连接")
|
||||
@Parameters({
|
||||
@Parameter(name = "accountConfigForm", description = "账号测试模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@PostMapping("/testQyWebChatConnect")
|
||||
public ActionResult testQyWebChatConnect(@RequestBody @Valid AccountConfigForm accountConfigForm) {
|
||||
JSONObject retMsg;
|
||||
// 测试发送消息、组织同步的连接
|
||||
//企业微信企业id
|
||||
String corpId = accountConfigForm.getEnterpriseId();
|
||||
//企业微信应用secret
|
||||
String agentSecret = accountConfigForm.getAppSecret();
|
||||
// String corpSecret = testAccountConfigForm.getQyhCorpSecret();
|
||||
// 测试发送消息的连接
|
||||
retMsg = QyWebChatUtil.getAccessToken(corpId, agentSecret);
|
||||
if (HttpUtil.isWxError(retMsg)) {
|
||||
return ActionResult.fail(MsgCode.MSERR110.get(retMsg.getString("errmsg")));
|
||||
}
|
||||
return ActionResult.success(MsgCode.MSERR109.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试钉钉配置的连接功能
|
||||
*
|
||||
* @param accountConfigForm 账号测试模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "测试钉钉配置的连接")
|
||||
@Parameters({
|
||||
@Parameter(name = "accountConfigForm", description = "账号测试模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.accountConfig")
|
||||
@PostMapping("/testDingTalkConnect")
|
||||
public ActionResult testDingTalkConnect(@RequestBody @Valid AccountConfigForm accountConfigForm) {
|
||||
JSONObject retMsg;
|
||||
// 测试钉钉配置的连接
|
||||
String appKey = accountConfigForm.getAppId();
|
||||
String appSecret = accountConfigForm.getAppSecret();
|
||||
///
|
||||
// String agentId = dingTalkModel.getDingAgentId();
|
||||
// 测试钉钉的连接
|
||||
retMsg = DingTalkUtil.getAccessToken(appKey, appSecret);
|
||||
if (!retMsg.getBoolean("code")) {
|
||||
return ActionResult.fail(MsgCode.MSERR110.get(retMsg.getString("error")));
|
||||
}
|
||||
return ActionResult.success(MsgCode.MSERR109.get());
|
||||
}
|
||||
|
||||
public boolean isEmail(String email){
|
||||
String EMAIL_REGEX = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
|
||||
Boolean b = email.matches(EMAIL_REGEX);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.ImReplyEntity;
|
||||
import com.yunzhupaas.message.model.ImReplyListModel;
|
||||
import com.yunzhupaas.message.model.ImReplyListVo;
|
||||
import com.yunzhupaas.message.service.ImContentService;
|
||||
import com.yunzhupaas.message.service.ImReplyService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UploaderUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消息会话接口
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
@Tag(name = "消息会话接口", description = "imreply")
|
||||
@RestController
|
||||
@RequestMapping("/api/message/imreply")
|
||||
public class ImReplyController extends SuperController<ImReplyService, ImReplyEntity> {
|
||||
@Autowired
|
||||
private ImReplyService imReplyService;
|
||||
@Autowired
|
||||
private ImContentService imContentService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 获取消息会话列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取消息会话列表")
|
||||
@GetMapping
|
||||
public ActionResult<ListVO<ImReplyListVo>> getList() {
|
||||
List<ImReplyListModel> imReplyList = imReplyService.getImReplyList();
|
||||
//过滤 发送者删除标记
|
||||
imReplyList = imReplyList.stream().filter(t ->{
|
||||
List<String> deleteId = StringUtil.isNotEmpty(t.getDeleteUserId())? Arrays.asList(t.getDeleteUserId().split(",")):new ArrayList<>();
|
||||
return !deleteId.contains(UserProvider.getUser().getUserId());
|
||||
}).collect(Collectors.toList());
|
||||
List<ImReplyListModel> imReplyLists = new ArrayList<>(imReplyList);
|
||||
for (ImReplyListModel vo : imReplyList) {
|
||||
UserEntity entity = userService.getInfo(vo.getId());
|
||||
if (entity == null || entity.getEnabledMark() == 0) {
|
||||
imReplyLists.remove(vo);
|
||||
continue;
|
||||
}
|
||||
//拼接账号和名称
|
||||
vo.setRealName(entity.getRealName());
|
||||
vo.setAccount(entity.getAccount());
|
||||
//头像路径拼接
|
||||
vo.setHeadIcon(UploaderUtil.uploaderImg(vo.getHeadIcon()));
|
||||
//获取未读消息
|
||||
vo.setUnreadMessage(imContentService.getUnreadCount(vo.getId(), UserProvider.getUser().getUserId()));
|
||||
if(vo.getSendDeleteMark()!=null && vo.getSendDeleteMark().equals(UserProvider.getUser().getUserId()) || vo.getDeleteMark()==1){
|
||||
vo.setLatestMessage("");
|
||||
vo.setMessageType("");
|
||||
}
|
||||
}
|
||||
//排序
|
||||
imReplyLists = imReplyLists.stream().sorted(Comparator.comparing(ImReplyListModel::getLatestDate).reversed()).collect(Collectors.toList());
|
||||
List<ImReplyListVo> imReplyListVoList = JsonUtil.getJsonToList(imReplyLists, ImReplyListVo.class);
|
||||
ListVO listVO = new ListVO();
|
||||
listVO.setList(imReplyListVoList);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除聊天记录
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "删除聊天记录")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@DeleteMapping("/deleteChatRecord/{id}")
|
||||
public ActionResult deleteChatRecord(@PathVariable("id") String id){
|
||||
imContentService.deleteChatRecord(UserProvider.getUser().getUserId(),id);
|
||||
return ActionResult.success("");
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除会话列表
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "移除会话列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@DeleteMapping("/relocation/{id}")
|
||||
public ActionResult relocation(@PathVariable("id") String id){
|
||||
imReplyService.relocation(UserProvider.getUser().getUserId(),id);
|
||||
return ActionResult.success("");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.SuperBaseEntity;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.DictionaryTypeService;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.message.entity.MessageEntity;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.MessageReceiveEntity;
|
||||
import com.yunzhupaas.message.model.NoticePagination;
|
||||
import com.yunzhupaas.message.service.MessageService;
|
||||
import com.yunzhupaas.message.model.message.*;
|
||||
import com.yunzhupaas.message.service.UserDeviceService;
|
||||
import com.yunzhupaas.message.util.unipush.UinPush;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.JsonUtilEx;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统公告
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Tag(name = "系统公告", description = "Message")
|
||||
@RestController
|
||||
@RequestMapping("/api/message")
|
||||
public class MessageController extends SuperController<MessageService, MessageEntity> {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
@Autowired
|
||||
private UserService userApi;
|
||||
@Autowired
|
||||
private UinPush uinPush;
|
||||
@Autowired
|
||||
private UserDeviceService userDeviceService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private DictionaryTypeService dictionaryTypeService;
|
||||
|
||||
/**
|
||||
* 列表(通知公告)
|
||||
*
|
||||
* @param pagination
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取系统公告列表(带分页)")
|
||||
@SaCheckPermission("system.notice")
|
||||
@PostMapping("/Notice/List")
|
||||
public ActionResult<PageListVO<MessageNoticeVO>> NoticeList(@RequestBody NoticePagination pagination) {
|
||||
messageService.updateEnabledMark();
|
||||
List<MessageEntity> list = messageService.getNoticeList(pagination);
|
||||
List<UserEntity> userList = userApi.getUserName(list.stream().map(MessageEntity::getCreatorUserId).collect(Collectors.toList()));
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
List<DictionaryDataEntity> noticeType = dictionaryDataApi.getListByTypeDataCode("NoticeType");
|
||||
List<MessageNoticeVO> voList = new ArrayList<>();
|
||||
// 判断是否过期
|
||||
list.forEach(t -> {
|
||||
MessageNoticeVO vo = JsonUtil.getJsonToBean(t, MessageNoticeVO.class);
|
||||
// 处理是否过期
|
||||
if (t.getExpirationTime() != null) {
|
||||
// 已发布的情况下
|
||||
if (t.getEnabledMark() == 1) {
|
||||
if (t.getExpirationTime().getTime() < System.currentTimeMillis()) {
|
||||
vo.setEnabledMark(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
DictionaryDataEntity dictionaryDataEntity = noticeType.stream().filter(notice -> notice.getEnCode().equals(t.getCategory())).findFirst().orElse(new DictionaryDataEntity());
|
||||
vo.setCategory(dictionaryDataEntity.getFullName());
|
||||
// 转换创建人、发布人
|
||||
UserEntity user = userList.stream().filter(ul -> ul.getId().equals(t.getCreatorUserId())).findFirst().orElse(null);
|
||||
vo.setCreatorUser(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
if (t.getEnabledMark() != null && t.getEnabledMark() != 0) {
|
||||
UserEntity entity = userApi.getInfo(t.getLastModifyUserId());
|
||||
vo.setLastModifyUserId(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
|
||||
vo.setReleaseTime(t.getLastModifyTime() != null ? t.getLastModifyTime().getTime() : null);
|
||||
vo.setReleaseUser(vo.getLastModifyUserId());
|
||||
}
|
||||
voList.add(vo);
|
||||
});
|
||||
return ActionResult.page(voList, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统公告
|
||||
*
|
||||
* @param noticeCrForm 实体对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "添加系统公告")
|
||||
@Parameters({
|
||||
@Parameter(name = "noticeCrForm", description = "新建系统公告模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("system.notice")
|
||||
@PostMapping("/Notice")
|
||||
public ActionResult create(@RequestBody @Valid NoticeCrForm noticeCrForm) {
|
||||
MessageEntity entity = JsonUtil.getJsonToBean(noticeCrForm, MessageEntity.class);
|
||||
if(entity != null && StringUtil.isNotEmpty(entity.getBodyText()) && (entity.getBodyText().contains("<") || entity.getBodyText().contains("&lt;"))){
|
||||
return ActionResult.fail(MsgCode.MSERR112.get());
|
||||
}
|
||||
messageService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改系统公告
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param messageUpForm 实体对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改系统公告")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "messageUpForm", description = "修改系统公告模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("system.notice")
|
||||
@PutMapping("/Notice/{id}")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid NoticeUpForm messageUpForm) {
|
||||
MessageEntity entity = JsonUtil.getJsonToBean(messageUpForm, MessageEntity.class);
|
||||
if(entity != null && StringUtil.isNotEmpty(entity.getBodyText()) && (entity.getBodyText().contains("<") || entity.getBodyText().contains("&lt;"))){
|
||||
return ActionResult.fail(MsgCode.MSERR112.get());
|
||||
}
|
||||
boolean flag = messageService.update(id, entity);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取/查看系统公告信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("system.notice")
|
||||
@GetMapping("/Notice/{id}")
|
||||
public ActionResult<NoticeInfoVO> Info(@PathVariable("id") String id) throws DataException {
|
||||
MessageEntity entity = messageService.getInfo(id);
|
||||
NoticeInfoVO vo = null;
|
||||
if (entity != null) {
|
||||
UserEntity info = userApi.getInfo(entity.getCreatorUserId());
|
||||
entity.setCreatorUserId(info != null ? info.getRealName() + "/" + info.getAccount() : "");
|
||||
vo = JsonUtilEx.getJsonToBeanEx(entity, NoticeInfoVO.class);
|
||||
vo.setReleaseUser(entity.getCreatorUserId());
|
||||
vo.setReleaseTime(entity.getLastModifyTime() != null ? entity.getLastModifyTime().getTime() : null);
|
||||
UserEntity userEntity = userApi.getInfo(entity.getLastModifyUserId());
|
||||
if (userEntity != null && StringUtil.isNotEmpty(userEntity.getId())) {
|
||||
String realName = userEntity.getRealName();
|
||||
String account = userEntity.getAccount();
|
||||
if (StringUtil.isNotEmpty(realName)) {
|
||||
vo.setReleaseUser(realName + "/" + account);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除系统公告")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("system.notice")
|
||||
@DeleteMapping("/Notice/{id}")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
MessageEntity entity = messageService.getInfo(id);
|
||||
if (entity != null) {
|
||||
messageService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发布公告
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "发布系统公告")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("system.notice")
|
||||
@PutMapping("/Notice/{id}/Actions/Release")
|
||||
public ActionResult release(@PathVariable("id") String id) {
|
||||
MessageEntity entity = messageService.getInfo(id);
|
||||
if (entity != null) {
|
||||
List<String> userIds = null;
|
||||
if (StringUtil.isNotEmpty(entity.getToUserIds())) {
|
||||
userIds = Arrays.asList(entity.getToUserIds().split(","));
|
||||
} else {
|
||||
userIds = userApi.getListId();
|
||||
}
|
||||
List<String> userIdList = userApi.getUserIdList(userIds, null);
|
||||
if (messageService.sentNotice(userIdList, entity)) {
|
||||
/*if(userIdList != null && userIdList.size()>0) {
|
||||
for (String userId : userIdList) {
|
||||
List<String> cidList = userDeviceService.getCidList(userId);
|
||||
if(cidList != null && cidList.size()>0){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type","1");
|
||||
jsonObject.put("id",entity.getId());
|
||||
jsonObject.put("title",entity.getTitle());
|
||||
String text = JSONObject.toJSONString(jsonObject);
|
||||
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||
text = Base64.getEncoder().encodeToString(bytes);
|
||||
uinPush.sendUniPush(cidList, entity.getTitle(), "你有一条公告消息", "1", text);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return ActionResult.success(MsgCode.SU011.get());
|
||||
}
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA011.get());
|
||||
}
|
||||
//=======================================站内消息、消息中心=================================================
|
||||
|
||||
|
||||
/**
|
||||
* 获取消息中心列表
|
||||
*
|
||||
* @param pagination
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表(通知公告/系统消息/私信消息)")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<MessageInfoVO>> messageList(PaginationMessage pagination) {
|
||||
List<MessageInfoVO> listVO = new ArrayList<>();
|
||||
List<MessageReceiveEntity> list = messageService.getMessageList3(pagination, pagination.getType(), null, pagination.getIsRead());
|
||||
List<UserEntity> userList = userApi.getUserName(list.stream().map(SuperBaseEntity.SuperCBaseEntity::getCreatorUserId).collect(Collectors.toList()));
|
||||
list.forEach(t -> {
|
||||
MessageInfoVO vo = JsonUtil.getJsonToBean(t, MessageInfoVO.class);
|
||||
UserEntity user = userList.stream().filter(ul -> ul.getId().equals(t.getCreatorUserId())).findFirst().orElse(null);
|
||||
if (user != null) {
|
||||
vo.setReleaseTime(t.getCreatorTime() != null ? t.getCreatorTime().getTime() : null);
|
||||
UserEntity entity = userApi.getInfo(t.getCreatorUserId());
|
||||
vo.setReleaseUser(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
|
||||
vo.setCreatorUser(entity != null ? entity.getRealName() + "/" + entity.getAccount() : "");
|
||||
}
|
||||
listVO.add(vo);
|
||||
});
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVO, paginationVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取消息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "读取消息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true)
|
||||
})
|
||||
@GetMapping("/ReadInfo/{id}")
|
||||
public ActionResult<NoticeInfoVO> readInfo(@PathVariable("id") String id) throws DataException {
|
||||
MessageReceiveEntity receive = messageService.messageRead(id);
|
||||
if (receive != null) {
|
||||
UserEntity user = userApi.getInfo(receive.getCreatorUserId());
|
||||
receive.setCreatorUserId(user != null ? user.getRealName() + "/" + user.getAccount() : "");
|
||||
receive.setBodyText(receive.getBodyText());
|
||||
// if (entity.getType() == 2) {
|
||||
// entity.setBodyText(receive.getBodyText());
|
||||
// }
|
||||
}
|
||||
NoticeInfoVO vo = JsonUtil.getJsonToBean(receive, NoticeInfoVO.class);
|
||||
if (Objects.equals(receive.getType() , 1)) {
|
||||
try{
|
||||
MessageEntity jsonToBean = JsonUtil.getJsonToBean(receive.getBodyText(), MessageEntity.class);
|
||||
if (jsonToBean !=null) {
|
||||
vo.setCategory(jsonToBean.getCategory());
|
||||
vo.setCoverImage(jsonToBean.getCoverImage());
|
||||
vo.setExcerpt(jsonToBean.getExcerpt());
|
||||
vo.setExpirationTime(jsonToBean.getExpirationTime() != null ? jsonToBean.getExpirationTime().getTime() : null);
|
||||
vo.setFiles(jsonToBean.getFiles());
|
||||
vo.setBodyText(jsonToBean.getBodyText());
|
||||
if (jsonToBean.getId() != null) {
|
||||
MessageEntity info = messageService.getInfo(jsonToBean.getId());
|
||||
if (info != null) {
|
||||
vo.setCategory(info.getCategory());
|
||||
vo.setCoverImage(info.getCoverImage());
|
||||
vo.setExcerpt(info.getExcerpt());
|
||||
vo.setExpirationTime(info.getExpirationTime() != null ? info.getExpirationTime().getTime() : null);
|
||||
vo.setFiles(info.getFiles());
|
||||
vo.setBodyText(info.getBodyText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
vo.setBodyText(receive.getBodyText());
|
||||
}
|
||||
|
||||
}
|
||||
vo.setReleaseTime(receive.getCreatorTime() != null ? receive.getCreatorTime().getTime() : null);
|
||||
// UserEntity info = usersApi.getInfoById(receive.getCreatorUserId());
|
||||
vo.setReleaseUser(receive.getCreatorUserId());
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 全部已读
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "全部已读")
|
||||
@Parameters({
|
||||
@Parameter(name = "pagination", description = "分页模型", required = true)
|
||||
})
|
||||
@PostMapping("/Actions/ReadAll")
|
||||
public ActionResult allRead(@RequestBody PaginationMessage pagination) {
|
||||
List<MessageReceiveEntity> list = messageService.getMessageList3(pagination, pagination.getType(),null,pagination.getIsRead());
|
||||
if(list != null && list.size()>0) {
|
||||
List<String> idList = list.stream().map(SuperBaseEntity.SuperIBaseEntity::getId).collect(Collectors.toList());
|
||||
messageService.messageRead(idList);
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.MSERR113.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* app端获取未读数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "app端获取未读数据")
|
||||
@GetMapping("/getUnReadMsgNum")
|
||||
public ActionResult getUnReadMsgNum() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
Integer unReadMsg = messageService.getUnreadCount(userInfo.getUserId(), 2);
|
||||
Integer unReadSchedule = messageService.getUnreadCount(userInfo.getUserId(),4);
|
||||
Integer unReadNotice = messageService.getUnreadCount(userInfo.getUserId(), 1);
|
||||
Integer unReadSystemMsg = messageService.getUnreadCount(userInfo.getUserId(), 3);
|
||||
Integer unReadNum = unReadMsg+unReadNotice+unReadSchedule+unReadSystemMsg;
|
||||
map.put("unReadMsg",unReadMsg.toString());
|
||||
map.put("unReadNotice",unReadNotice.toString());
|
||||
map.put("unReadSchedule",unReadSchedule.toString());
|
||||
map.put("unReadSystemMsg",unReadSystemMsg.toString());
|
||||
map.put("unReadNum",unReadNum.toString());
|
||||
return ActionResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param recordForm 已读模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除消息")
|
||||
@Parameters({
|
||||
@Parameter(name = "recordForm", description = "已读模型", required = true)
|
||||
})
|
||||
@DeleteMapping("/Record")
|
||||
public ActionResult deleteRecord(@RequestBody MessageRecordForm recordForm) {
|
||||
String[] id = recordForm.getIds().split(",");
|
||||
List<String> list = Arrays.asList(id);
|
||||
messageService.deleteRecord(list);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.MessageMonitorEntity;
|
||||
import com.yunzhupaas.message.model.messagemonitor.*;
|
||||
import com.yunzhupaas.message.service.MessageMonitorService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息监控
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-22
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "消息监控", description = "message")
|
||||
@RequestMapping("/api/message/MessageMonitor")
|
||||
public class MessageMonitorController extends SuperController<MessageMonitorService, MessageMonitorEntity> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MessageMonitorService messageMonitorService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param messageMonitorPagination 消息监控分页模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<MessageMonitorListVO>> list(MessageMonitorPagination messageMonitorPagination) throws IOException {
|
||||
List<MessageMonitorEntity> list = messageMonitorService.getList(messageMonitorPagination);
|
||||
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
List<DictionaryDataEntity> msgSourceTypeList = dictionaryDataApi.getListByTypeDataCode("msgSourceType");
|
||||
|
||||
//处理id字段转名称,若无需转或者为空可删除
|
||||
List<MessageMonitorListVO> listVO = JsonUtil.getJsonToList(list, MessageMonitorListVO.class);
|
||||
for (MessageMonitorListVO messageMonitorVO : listVO) {
|
||||
//消息类型
|
||||
if (StringUtil.isNotEmpty(messageMonitorVO.getMessageType())) {
|
||||
msgSendTypeList.stream().filter(t -> messageMonitorVO.getMessageType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> messageMonitorVO.setMessageType(dataTypeEntity.getFullName()));
|
||||
}
|
||||
//消息来源
|
||||
if (StringUtil.isNotEmpty(messageMonitorVO.getMessageSource())) {
|
||||
msgSourceTypeList.stream().filter(t -> messageMonitorVO.getMessageSource().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> messageMonitorVO.setMessageSource(dataTypeEntity.getFullName()));
|
||||
}
|
||||
//子表数据转换
|
||||
}
|
||||
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(messageMonitorPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param messageMonitorForm 消息监控模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = ("创建"))
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "messageMonitorForm", description = "消息监控模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@Transactional
|
||||
public ActionResult create(@RequestBody @Valid MessageMonitorForm messageMonitorForm) throws DataException {
|
||||
String mainId = RandomUtil.uuId();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
MessageMonitorEntity entity = JsonUtil.getJsonToBean(messageMonitorForm, MessageMonitorEntity.class);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setId(mainId);
|
||||
messageMonitorService.save(entity);
|
||||
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param msgDelForm 消息删除模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = ("批量删除"))
|
||||
@DeleteMapping("/batchRemove")
|
||||
@Parameters({
|
||||
@Parameter(name = "msgDelForm", description = "消息删除模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@Transactional
|
||||
public ActionResult batchRemove(@RequestBody MsgDelForm msgDelForm) {
|
||||
boolean flag = messageMonitorService.delete(msgDelForm.getIds());
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 一键清空消息监控记录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "一键清空消息监控记录")
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@DeleteMapping("/empty")
|
||||
public ActionResult deleteHandelLog() {
|
||||
messageMonitorService.emptyMonitor();
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<MessageMonitorInfoVO> info(@PathVariable("id") String id) {
|
||||
MessageMonitorEntity entity = messageMonitorService.getInfo(id);
|
||||
MessageMonitorInfoVO vo = JsonUtil.getJsonToBean(entity, MessageMonitorInfoVO.class);
|
||||
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单信息(详情页)
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "表单信息(详情页)")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@GetMapping("/detail/{id}")
|
||||
public ActionResult<MessageMonitorInfoVO> detailInfo(@PathVariable("id") String id) {
|
||||
MessageMonitorEntity entity = messageMonitorService.getInfo(id);
|
||||
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
List<DictionaryDataEntity> msgSourceTypeList = dictionaryDataApi.getListByTypeDataCode("msgSourceType");
|
||||
|
||||
MessageMonitorInfoVO vo = JsonUtil.getJsonToBean(entity, MessageMonitorInfoVO.class);
|
||||
if (StringUtil.isNotEmpty(vo.getMessageType())) {
|
||||
msgSendTypeList.stream().filter(t -> vo.getMessageType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> vo.setMessageType(dataTypeEntity.getFullName()));
|
||||
}
|
||||
if (StringUtil.isNotEmpty(vo.getMessageSource())) {
|
||||
msgSourceTypeList.stream().filter(t -> vo.getMessageSource().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> vo.setMessageSource(dataTypeEntity.getFullName()));
|
||||
}
|
||||
if (!"webhook".equals(vo.getMessageType())) {
|
||||
vo.setReceiveUser(messageMonitorService.userSelectValues(vo.getReceiveUser()));
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgMonitor")
|
||||
@Transactional
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
MessageMonitorEntity entity = messageMonitorService.getInfo(id);
|
||||
if (entity != null) {
|
||||
messageMonitorService.delete(entity);
|
||||
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,611 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.service.BillRuleService;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.MessageTemplateConfigEntity;
|
||||
import com.yunzhupaas.message.entity.SmsFieldEntity;
|
||||
import com.yunzhupaas.message.entity.TemplateParamEntity;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigForm;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigInfoVO;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigListVO;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.MessageTemplateConfigPagination;
|
||||
import com.yunzhupaas.message.service.MessageTemplateConfigService;
|
||||
import com.yunzhupaas.message.service.SendConfigTemplateService;
|
||||
import com.yunzhupaas.message.service.SmsFieldService;
|
||||
import com.yunzhupaas.message.service.TemplateParamService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.emnus.ModuleTypeEnum;
|
||||
import com.yunzhupaas.util.FileExport;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息模板(新)
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "消息模板(新)", description = "message")
|
||||
@RequestMapping("/api/message/MessageTemplateConfig")
|
||||
public class MessageTemplateConfigController extends SuperController<MessageTemplateConfigService, MessageTemplateConfigEntity> {
|
||||
|
||||
@Autowired
|
||||
private FileExport fileExport;
|
||||
|
||||
@Autowired
|
||||
private BillRuleService billRuleService;
|
||||
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
|
||||
@Autowired
|
||||
private UserService userApi;
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateConfigService messageTemplateConfigService;
|
||||
|
||||
@Autowired
|
||||
private TemplateParamService templateParamService;
|
||||
@Autowired
|
||||
private SmsFieldService smsFieldService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
@Autowired
|
||||
private SendConfigTemplateService sendConfigTemplateService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param messageTemplateConfigPagination 消息模板分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@SaCheckPermission(value = {"msgCenter.msgTemplate", "msgCenter.accountConfig"}, mode = SaMode.OR)
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<MessageTemplateConfigListVO>> list(MessageTemplateConfigPagination messageTemplateConfigPagination) throws IOException {
|
||||
List<MessageTemplateConfigEntity> list = messageTemplateConfigService.getList(messageTemplateConfigPagination);
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
List<DictionaryDataEntity> msgSourceTypeList = dictionaryDataApi.getListByTypeDataCode("msgSourceType");
|
||||
//处理id字段转名称,若无需转或者为空可删除
|
||||
UserEntity userEntity = new UserEntity();
|
||||
List<MessageTemplateConfigListVO> listVO = JsonUtil.getJsonToList(list, MessageTemplateConfigListVO.class);
|
||||
for (MessageTemplateConfigListVO messageTemplateNewVO : listVO) {
|
||||
//消息类型
|
||||
if(StringUtil.isNotEmpty(messageTemplateNewVO.getMessageType())){
|
||||
msgSendTypeList.stream().filter(t -> messageTemplateNewVO.getMessageType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> messageTemplateNewVO.setMessageType(dataTypeEntity.getFullName()));
|
||||
}
|
||||
//创建人员
|
||||
if(StringUtil.isNotBlank(messageTemplateNewVO.getCreatorUserId()) && !"null".equals(messageTemplateNewVO.getCreatorUserId())){
|
||||
userEntity = userApi.getInfo(messageTemplateNewVO.getCreatorUserId());
|
||||
if(userEntity != null){
|
||||
messageTemplateNewVO.setCreatorUser(userEntity.getRealName() +"/"+ userEntity.getAccount());
|
||||
}
|
||||
}
|
||||
//消息来源
|
||||
if(StringUtil.isNotEmpty(messageTemplateNewVO.getMessageSource())) {
|
||||
msgSourceTypeList.stream().filter(t -> messageTemplateNewVO.getMessageSource().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> messageTemplateNewVO.setMessageSource(dataTypeEntity.getFullName()));
|
||||
}
|
||||
}
|
||||
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(messageTemplateConfigPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param messageTemplateConfigForm 消息模板页模型
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "创建")
|
||||
@Parameters({
|
||||
@Parameter(name = "messageTemplateConfigForm", description = "消息模板页模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgTemplate")
|
||||
@PostMapping
|
||||
@Transactional
|
||||
public ActionResult create(@RequestBody @Valid MessageTemplateConfigForm messageTemplateConfigForm) throws DataException {
|
||||
boolean b = messageTemplateConfigService.checkForm(messageTemplateConfigForm, 0,"");
|
||||
if (b) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
if(!"1".equals(messageTemplateConfigForm.getTemplateType())){
|
||||
if(messageTemplateConfigForm.getEnCode().contains("MBXT")){
|
||||
return ActionResult.fail(MsgCode.MSERR114.get());
|
||||
}
|
||||
}
|
||||
if (messageTemplateConfigForm.getSmsFieldList() != null && "7".equals(messageTemplateConfigForm.getMessageType())) {
|
||||
List<SmsFieldEntity> SmsFieldList = JsonUtil.getJsonToList(messageTemplateConfigForm.getSmsFieldList(), SmsFieldEntity.class);
|
||||
List<SmsFieldEntity> list = SmsFieldList.stream().filter(t->StringUtil.isNotEmpty(String.valueOf(t.getIsTitle())) &&!"null".equals(String.valueOf(t.getIsTitle())) && t.getIsTitle()==1).collect(Collectors.toList());
|
||||
if (list != null) {
|
||||
if(list.size() > 1) {
|
||||
return ActionResult.fail(MsgCode.MSERR115.get());
|
||||
}
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.MSERR116.get());
|
||||
}
|
||||
}
|
||||
String mainId = RandomUtil.uuId();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
MessageTemplateConfigEntity entity = JsonUtil.getJsonToBean(messageTemplateConfigForm, MessageTemplateConfigEntity.class);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setId(mainId);
|
||||
if("1".equals(entity.getMessageType()) && "2".equals(entity.getMessageSource())){
|
||||
entity.setContent(null);
|
||||
}
|
||||
messageTemplateConfigService.save(entity);
|
||||
if (messageTemplateConfigForm.getTemplateParamList() != null) {
|
||||
List<TemplateParamEntity> TemplateParamList = JsonUtil.getJsonToList(messageTemplateConfigForm.getTemplateParamList(), TemplateParamEntity.class);
|
||||
for (TemplateParamEntity entitys : TemplateParamList) {
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setTemplateId(entity.getId());
|
||||
templateParamService.save(entitys);
|
||||
}
|
||||
}
|
||||
if (messageTemplateConfigForm.getSmsFieldList() != null) {
|
||||
List<SmsFieldEntity> SmsFieldList = JsonUtil.getJsonToList(messageTemplateConfigForm.getSmsFieldList(), SmsFieldEntity.class);
|
||||
for (SmsFieldEntity entitys : SmsFieldList) {
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setTemplateId(entity.getId());
|
||||
smsFieldService.save(entitys);
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission(value = {"msgCenter.msgTemplate", "msgCenter.accountConfig"}, mode = SaMode.OR)
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<MessageTemplateConfigInfoVO> info(@PathVariable("id") String id) {
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
MessageTemplateConfigInfoVO vo = JsonUtil.getJsonToBean(entity, MessageTemplateConfigInfoVO.class);
|
||||
//子表
|
||||
List<TemplateParamEntity> BaseTemplateParamList = messageTemplateConfigService.getTemplateParamList(id);
|
||||
// for (TemplateParamEntity basetemplateparamEntity : BaseTemplateParamList) {
|
||||
// }
|
||||
vo.setTemplateParamList(BaseTemplateParamList);
|
||||
List<SmsFieldEntity> BaseSmsFieldList = messageTemplateConfigService.getSmsFieldList(id);
|
||||
// for (SmsFieldEntity basesmsfieldEntity : BaseSmsFieldList) {
|
||||
// }
|
||||
vo.setSmsFieldList(BaseSmsFieldList);
|
||||
//副表
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单信息(详情页)
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "表单信息(详情页)")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgTemplate")
|
||||
@GetMapping("/detail/{id}")
|
||||
public ActionResult<MessageTemplateConfigInfoVO> detailInfo(@PathVariable("id") String id) {
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
UserEntity userEntity = new UserEntity();
|
||||
MessageTemplateConfigInfoVO vo = JsonUtil.getJsonToBean(entity, MessageTemplateConfigInfoVO.class);
|
||||
|
||||
//子表数据转换
|
||||
List<TemplateParamEntity> BaseTemplateParamList = messageTemplateConfigService.getTemplateParamList(id);
|
||||
// for (TemplateParamEntity basetemplateparamEntity : BaseTemplateParamList) {
|
||||
// }
|
||||
vo.setTemplateParamList(BaseTemplateParamList);
|
||||
List<SmsFieldEntity> BaseSmsFieldList = messageTemplateConfigService.getSmsFieldList(id);
|
||||
// for (SmsFieldEntity basesmsfieldEntity : BaseSmsFieldList) {
|
||||
// }
|
||||
vo.setSmsFieldList(BaseSmsFieldList);
|
||||
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param messageTemplateConfigForm 消息模板页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "messageTemplateConfigForm", description = "消息模板页模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgTemplate")
|
||||
@PutMapping("/{id}")
|
||||
@Transactional
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid MessageTemplateConfigForm messageTemplateConfigForm) throws DataException {
|
||||
|
||||
boolean b = messageTemplateConfigService.checkForm(messageTemplateConfigForm, 0, messageTemplateConfigForm.getId());
|
||||
if (b) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
if(!"1".equals(messageTemplateConfigForm.getTemplateType())){
|
||||
if(messageTemplateConfigForm.getEnCode().contains("MBXT")){
|
||||
return ActionResult.fail(MsgCode.MSERR114.get());
|
||||
}
|
||||
}
|
||||
//判断配置是否被引用
|
||||
if("0".equals(String.valueOf(messageTemplateConfigForm.getEnabledMark()))){
|
||||
if(sendConfigTemplateService.isUsedTemplate(messageTemplateConfigForm.getId())) {
|
||||
return ActionResult.fail(MsgCode.FA049.get());
|
||||
}
|
||||
}
|
||||
if (messageTemplateConfigForm.getSmsFieldList() != null && "7".equals(messageTemplateConfigForm.getMessageType())) {
|
||||
List<SmsFieldEntity> SmsFieldList = JsonUtil.getJsonToList(messageTemplateConfigForm.getSmsFieldList(), SmsFieldEntity.class);
|
||||
List<SmsFieldEntity> list = SmsFieldList.stream().filter(t->StringUtil.isNotEmpty(String.valueOf(t.getIsTitle())) &&!"null".equals(String.valueOf(t.getIsTitle())) && t.getIsTitle()==1).collect(Collectors.toList());
|
||||
if (list != null) {
|
||||
if(list.size() > 1) {
|
||||
return ActionResult.fail(MsgCode.MSERR117.get());
|
||||
}
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.MSERR118.get());
|
||||
}
|
||||
}
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
MessageTemplateConfigEntity subentity = JsonUtil.getJsonToBean(messageTemplateConfigForm, MessageTemplateConfigEntity.class);
|
||||
subentity.setCreatorTime(entity.getCreatorTime());
|
||||
subentity.setCreatorUserId(entity.getCreatorUserId());
|
||||
subentity.setLastModifyTime(DateUtil.getNowDate());
|
||||
subentity.setLastModifyUserId(userInfo.getUserId());
|
||||
if("1".equals(subentity.getMessageType()) && "2".equals(subentity.getMessageSource())){
|
||||
subentity.setContent(null);
|
||||
}
|
||||
boolean b1 = messageTemplateConfigService.updateById(subentity);
|
||||
if (!b1) {
|
||||
return ActionResult.fail(MsgCode.VS405.get());
|
||||
}
|
||||
|
||||
//明细表数据更新
|
||||
List<TemplateParamEntity> addParamList = new ArrayList<>();
|
||||
List<TemplateParamEntity> updParamList = new ArrayList<>();
|
||||
List<TemplateParamEntity> delParamList = new ArrayList<>();
|
||||
if (messageTemplateConfigForm.getTemplateParamList() != null) {
|
||||
List<TemplateParamEntity> templateParamList = JsonUtil.getJsonToList(messageTemplateConfigForm.getTemplateParamList(), TemplateParamEntity.class);
|
||||
for (TemplateParamEntity entitys : templateParamList) {
|
||||
if (StringUtil.isNotBlank(entitys.getId()) && !"null".equals(entitys.getId())) {
|
||||
TemplateParamEntity paramEntity = templateParamService.getInfo(entitys.getId());
|
||||
if (paramEntity != null) {
|
||||
paramEntity.setId(entitys.getId());
|
||||
paramEntity.setTemplateId(entitys.getTemplateId());
|
||||
paramEntity.setField(entitys.getField());
|
||||
paramEntity.setFieldName(entitys.getFieldName());
|
||||
paramEntity.setCreatorUserId(entity.getCreatorUserId());
|
||||
paramEntity.setCreatorTime(entitys.getCreatorTime());
|
||||
paramEntity.setLastModifyUserId(userInfo.getUserId());
|
||||
paramEntity.setLastModifyTime(DateUtil.getNowDate());
|
||||
updParamList.add(paramEntity);
|
||||
}
|
||||
} else {
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setTemplateId(entity.getId());
|
||||
entitys.setCreatorUserId(userInfo.getUserId());
|
||||
entitys.setCreatorTime(DateUtil.getNowDate());
|
||||
addParamList.add(entitys);
|
||||
}
|
||||
}
|
||||
|
||||
//删除参数记录
|
||||
List<TemplateParamEntity> paramEntityList = templateParamService.getDetailListByParentId(entity.getId());
|
||||
if (paramEntityList != null) {
|
||||
for (TemplateParamEntity paramEntity : paramEntityList) {
|
||||
TemplateParamEntity paramEntity1 = templateParamList.stream().filter(t -> t.getId().equals(paramEntity.getId())).findFirst().orElse(null);
|
||||
if (paramEntity1 == null) {
|
||||
delParamList.add(paramEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addParamList != null && addParamList.size() > 0) {
|
||||
templateParamService.saveBatch(addParamList);
|
||||
}
|
||||
if (updParamList != null && updParamList.size() > 0) {
|
||||
templateParamService.updateBatchById(updParamList);
|
||||
}
|
||||
if (delParamList != null && delParamList.size() > 0) {
|
||||
templateParamService.removeByIds(delParamList.stream().map(TemplateParamEntity::getId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
//短信参数明细表数据更新
|
||||
List<SmsFieldEntity> addSmsList = new ArrayList<>();
|
||||
List<SmsFieldEntity> updSmsList = new ArrayList<>();
|
||||
List<SmsFieldEntity> delSmsList = new ArrayList<>();
|
||||
if (messageTemplateConfigForm.getSmsFieldList() != null) {
|
||||
List<SmsFieldEntity> smsFieldList = JsonUtil.getJsonToList(messageTemplateConfigForm.getSmsFieldList(), SmsFieldEntity.class);
|
||||
for (SmsFieldEntity entitys : smsFieldList) {
|
||||
if (StringUtil.isNotBlank(entitys.getId()) && !"null".equals(entitys.getId())) {
|
||||
SmsFieldEntity smsFieldEntity = smsFieldService.getInfo(entitys.getId());
|
||||
if (smsFieldEntity != null) {
|
||||
smsFieldEntity.setId(entitys.getId());
|
||||
smsFieldEntity.setTemplateId(entity.getId());
|
||||
smsFieldEntity.setFieldId(entitys.getFieldId());
|
||||
smsFieldEntity.setField(entitys.getField());
|
||||
smsFieldEntity.setSmsField(entitys.getSmsField());
|
||||
smsFieldEntity.setCreatorTime(entitys.getCreatorTime());
|
||||
smsFieldEntity.setCreatorUserId(entitys.getCreatorUserId());
|
||||
smsFieldEntity.setLastModifyTime(DateUtil.getNowDate());
|
||||
smsFieldEntity.setLastModifyUserId(userInfo.getUserId());
|
||||
smsFieldEntity.setIsTitle(entitys.getIsTitle());
|
||||
updSmsList.add(smsFieldEntity);
|
||||
}
|
||||
} else {
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setTemplateId(entity.getId());
|
||||
entitys.setCreatorTime(DateUtil.getNowDate());
|
||||
entitys.setCreatorUserId(userInfo.getUserId());
|
||||
addSmsList.add(entitys);
|
||||
}
|
||||
}
|
||||
//删除短信参数明细表
|
||||
List<SmsFieldEntity> smsFieldEntityList = smsFieldService.getDetailListByParentId(entity.getId());
|
||||
if (smsFieldEntityList != null && smsFieldEntityList.size() > 0) {
|
||||
for (SmsFieldEntity smsFieldEntity : smsFieldEntityList) {
|
||||
SmsFieldEntity smsFieldEntity1 = smsFieldList.stream().filter(t -> t.getId().equals(smsFieldEntity.getId())).findFirst().orElse(null);
|
||||
if (smsFieldEntity1 == null) {
|
||||
delSmsList.add(smsFieldEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addSmsList != null && addSmsList.size() > 0) {
|
||||
smsFieldService.saveBatch(addSmsList);
|
||||
}
|
||||
if (updSmsList != null && updSmsList.size() > 0) {
|
||||
smsFieldService.updateBatchById(updSmsList);
|
||||
}
|
||||
if (delSmsList != null && delSmsList.size() > 0) {
|
||||
smsFieldService.removeByIds(delSmsList.stream().map(SmsFieldEntity::getId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgTemplate")
|
||||
@DeleteMapping("/{id}")
|
||||
@Transactional
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
if(sendConfigTemplateService.isUsedTemplate(entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.FA050.get());
|
||||
}
|
||||
messageTemplateConfigService.delete(entity);
|
||||
QueryWrapper<TemplateParamEntity> queryWrapperTemplateParam = new QueryWrapper<>();
|
||||
queryWrapperTemplateParam.lambda().eq(TemplateParamEntity::getTemplateId, entity.getId());
|
||||
templateParamService.remove(queryWrapperTemplateParam);
|
||||
QueryWrapper<SmsFieldEntity> queryWrapperSmsField = new QueryWrapper<>();
|
||||
queryWrapperSmsField.lambda().eq(SmsFieldEntity::getTemplateId, entity.getId());
|
||||
smsFieldService.remove(queryWrapperSmsField);
|
||||
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启或禁用
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "开启或禁用")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgTemplate")
|
||||
@PostMapping("/unable/{id}")
|
||||
@Transactional
|
||||
public ActionResult unable(@PathVariable("id") String id) {
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
if("1".equals(String.valueOf(entity.getEnabledMark()))){
|
||||
entity.setEnabledMark(0);
|
||||
return ActionResult.success(MsgCode.WF027.get());
|
||||
}else {
|
||||
//判断是否被引用
|
||||
|
||||
entity.setEnabledMark(1);
|
||||
return ActionResult.success(MsgCode.WF026.get());
|
||||
}
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "复制")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.msgTemplate")
|
||||
@PostMapping("/{id}/Actions/Copy")
|
||||
@Transactional
|
||||
public ActionResult copy(@PathVariable("id") String id) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
entity.setEnabledMark(0);
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName()+".副本"+copyNum);
|
||||
entity.setEnCode(entity.getEnCode()+copyNum);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setTemplateType("0");
|
||||
entity.setId(RandomUtil.uuId());
|
||||
MessageTemplateConfigEntity copyEntity = JsonUtil.getJsonToBean(entity, MessageTemplateConfigEntity.class);
|
||||
if(copyEntity.getEnCode().length()>50 || copyEntity.getFullName().length()>50){
|
||||
return ActionResult.fail(MsgCode.PRI006.get());
|
||||
}
|
||||
messageTemplateConfigService.create(copyEntity);
|
||||
List<TemplateParamEntity> copyParamList = new ArrayList<>();
|
||||
List<TemplateParamEntity> baseParamList = templateParamService.getDetailListByParentId(id);
|
||||
if(baseParamList != null && baseParamList.size()>0){
|
||||
for(TemplateParamEntity entitys : baseParamList){
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setTemplateId(copyEntity.getId());
|
||||
entitys.setCreatorTime(DateUtil.getNowDate());
|
||||
entitys.setCreatorUserId(userInfo.getUserId());
|
||||
entitys.setLastModifyTime(null);
|
||||
entitys.setLastModifyUserId(null);
|
||||
copyParamList.add(entitys);
|
||||
}
|
||||
}
|
||||
if(copyParamList != null && copyParamList.size()>0) {
|
||||
templateParamService.saveBatch(copyParamList);
|
||||
}
|
||||
List<SmsFieldEntity> copySmsList = new ArrayList<>();
|
||||
List<SmsFieldEntity> baseSmsFieldList = smsFieldService.getDetailListByParentId(id);
|
||||
if(baseSmsFieldList != null && baseSmsFieldList.size()>0){
|
||||
for(SmsFieldEntity entitys : baseSmsFieldList){
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setTemplateId(copyEntity.getId());
|
||||
entitys.setCreatorTime(DateUtil.getNowDate());
|
||||
entitys.setCreatorUserId(userInfo.getUserId());
|
||||
entitys.setLastModifyTime(null);
|
||||
entitys.setLastModifyUserId(null);
|
||||
copySmsList.add(entitys);
|
||||
}
|
||||
}
|
||||
if(copySmsList != null && copySmsList.size()>0){
|
||||
smsFieldService.saveBatch(copySmsList);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU007.get());
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.FA004.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出消息模板
|
||||
*
|
||||
* @param id 消息模板id
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "导出")
|
||||
@GetMapping("/{id}/Action/Export")
|
||||
public ActionResult export(@PathVariable String id) {
|
||||
MessageTemplateConfigEntity entity = messageTemplateConfigService.getInfo(id);
|
||||
MessageTemplateConfigInfoVO vo = JsonUtil.getJsonToBean(entity, MessageTemplateConfigInfoVO.class);
|
||||
//子表
|
||||
List<TemplateParamEntity> BaseTemplateParamList = messageTemplateConfigService.getTemplateParamList(id);
|
||||
vo.setTemplateParamList(BaseTemplateParamList);
|
||||
List<SmsFieldEntity> BaseSmsFieldList = messageTemplateConfigService.getSmsFieldList(id);
|
||||
vo.setSmsFieldList(BaseSmsFieldList);
|
||||
//导出文件
|
||||
DownloadVO downloadVO = fileExport.exportFile(vo, configValueUtil.getTemporaryFilePath(), entity.getFullName(), ModuleTypeEnum.MESSAGE_TEMPLATE.getTableName());
|
||||
return ActionResult.success(downloadVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入消息模板
|
||||
*
|
||||
* @param multipartFile 备份json文件
|
||||
* @return 执行结果标识
|
||||
*/
|
||||
@Operation(summary = "导入")
|
||||
@PostMapping(value = "/Action/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ActionResult importData(@RequestPart("file") MultipartFile multipartFile) throws DataException {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
//判断是否为.json结尾
|
||||
if (FileUtil.existsSuffix(multipartFile, ModuleTypeEnum.MESSAGE_TEMPLATE.getTableName())) {
|
||||
return ActionResult.fail(MsgCode.IMP002.get());
|
||||
}
|
||||
//获取文件内容
|
||||
String fileContent = FileUtil.getFileContent(multipartFile);
|
||||
MessageTemplateConfigInfoVO infoVO = JsonUtil.getJsonToBean(fileContent, MessageTemplateConfigInfoVO.class);
|
||||
MessageTemplateConfigEntity entity = JsonUtil.getJsonToBean(infoVO, MessageTemplateConfigEntity.class);
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
//子表数据导入
|
||||
if (infoVO.getTemplateParamList() != null && infoVO.getTemplateParamList().size()>0) {
|
||||
List<TemplateParamEntity> templateParamList = JsonUtil.getJsonToList(infoVO.getTemplateParamList(), TemplateParamEntity.class);
|
||||
templateParamService.saveBatch(templateParamList);
|
||||
}
|
||||
if(infoVO.getSmsFieldList() != null && infoVO.getSmsFieldList().size()>0){
|
||||
List<SmsFieldEntity> smsFieldList = JsonUtil.getJsonToList(infoVO.getSmsFieldList(), SmsFieldEntity.class);
|
||||
smsFieldService.saveBatch(smsFieldList);
|
||||
}
|
||||
return messageTemplateConfigService.ImportData(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,779 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.SysConfigEntity;
|
||||
import com.yunzhupaas.base.service.BillRuleService;
|
||||
import com.yunzhupaas.base.service.DictionaryDataService;
|
||||
import com.yunzhupaas.base.service.SysconfigService;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.message.entity.*;
|
||||
import com.yunzhupaas.message.model.message.DingTalkModel;
|
||||
import com.yunzhupaas.message.model.messagetemplateconfig.TemplateParamModel;
|
||||
import com.yunzhupaas.message.model.sendmessageconfig.*;
|
||||
import com.yunzhupaas.message.service.*;
|
||||
import com.yunzhupaas.base.util.TestSendConfigUtil;
|
||||
import com.yunzhupaas.model.BaseSystemInfo;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.emnus.ModuleTypeEnum;
|
||||
import com.yunzhupaas.util.FileExport;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 消息发送配置
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-19
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "消息发送配置", description = "message")
|
||||
@RequestMapping("/api/message/SendMessageConfig")
|
||||
public class SendMessageConfigController extends SuperController<SendMessageConfigService, SendMessageConfigEntity> {
|
||||
@Autowired
|
||||
private FileExport fileExport;
|
||||
|
||||
@Autowired
|
||||
private BillRuleService billRuleService;
|
||||
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private UserService userApi;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysconfigService sysconfigService;
|
||||
@Autowired
|
||||
private SendMessageConfigService sendMessageConfigService;
|
||||
|
||||
@Autowired
|
||||
private SendConfigTemplateService sendConfigTemplateService;
|
||||
|
||||
@Autowired
|
||||
private AccountConfigService accountConfigService;
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateConfigService messageTemplateConfigService;
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataApi;
|
||||
|
||||
@Autowired
|
||||
private TestSendConfigUtil testSendConfigUtil;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param sendMessageConfigPagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "消息发送配置列表")
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<SendMessageConfigListVO>> list(SendMessageConfigPagination sendMessageConfigPagination) throws IOException {
|
||||
List<SendMessageConfigEntity> list = sendMessageConfigService.getList(sendMessageConfigPagination, null);
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
List<DictionaryDataEntity> msgSourceTypeList = dictionaryDataApi.getListByTypeDataCode("msgSourceType");
|
||||
//处理id字段转名称,若无需转或者为空可删除
|
||||
UserEntity userEntity = new UserEntity();
|
||||
List<SendMessageConfigListVO> listVO = JsonUtil.getJsonToList(list, SendMessageConfigListVO.class);
|
||||
for (SendMessageConfigListVO sendMessageConfigVO : listVO) {
|
||||
List<Map<String,String>> mapList = new ArrayList<>();
|
||||
//子表数据转换
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = sendConfigTemplateService.getDetailListByParentId(sendMessageConfigVO.getId());
|
||||
if (sendConfigTemplateList != null && sendConfigTemplateList.size()>0) {
|
||||
sendConfigTemplateList = sendConfigTemplateList.stream().sorted((a,b)->a.getMessageType().compareTo(b.getMessageType())).collect(Collectors.toList());
|
||||
List<String> typeList = sendConfigTemplateList.stream().map(t -> t.getMessageType()).distinct().collect(Collectors.toList());
|
||||
if (typeList != null && typeList.size()>0) {
|
||||
for(String type : typeList) {
|
||||
String messageType = "";
|
||||
Map<String,String> map = new HashMap<>();
|
||||
DictionaryDataEntity dataTypeEntity = msgSendTypeList.stream().filter(t -> t.getEnCode().equals(type)).findFirst().orElse(null);
|
||||
if (dataTypeEntity != null) {
|
||||
messageType = dataTypeEntity.getFullName();
|
||||
map.put("fullName",messageType);
|
||||
map.put("type",type);
|
||||
mapList.add(map);
|
||||
}
|
||||
}
|
||||
sendMessageConfigVO.setMessageType(mapList);
|
||||
}
|
||||
}
|
||||
if(StringUtil.isNotEmpty(sendMessageConfigVO.getCreatorUserId())){
|
||||
userEntity = userApi.getInfo(sendMessageConfigVO.getCreatorUserId());
|
||||
if(userEntity != null){
|
||||
sendMessageConfigVO.setCreatorUser(userEntity.getRealName() +"/"+ userEntity.getAccount());
|
||||
}
|
||||
}
|
||||
//消息来源
|
||||
if(StringUtil.isNotBlank(sendMessageConfigVO.getMessageSource())) {
|
||||
msgSourceTypeList.stream().filter(t -> sendMessageConfigVO.getMessageSource().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> sendMessageConfigVO.setMessageSource(dataTypeEntity.getFullName()));
|
||||
}
|
||||
}
|
||||
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(sendMessageConfigPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发送配置下拉框
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取发送配置下拉框")
|
||||
@GetMapping("/Selector")
|
||||
public ActionResult<PageListVO<SendMessageConfigListVO>> selector(SendMessageConfigPagination sendMessageConfigPagination) {
|
||||
List<SendMessageConfigEntity> list = sendMessageConfigService.getSelectorList(sendMessageConfigPagination);
|
||||
List<SendMessageConfigListVO> listVO = JsonUtil.getJsonToList(list, SendMessageConfigListVO.class);
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(sendMessageConfigPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发送配置弹窗列表
|
||||
*
|
||||
* @param sendMessageConfigPagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "消息发送配置弹窗列表")
|
||||
@GetMapping("/getSendConfigList")
|
||||
public ActionResult<PageListVO<SendConfigListVO>> getSendConfigList(SendMessageConfigPagination sendMessageConfigPagination) throws IOException {
|
||||
if(StringUtil.isBlank(sendMessageConfigPagination.getEnabledMark())) {
|
||||
sendMessageConfigPagination.setEnabledMark("1");
|
||||
}
|
||||
if(StringUtil.isBlank(sendMessageConfigPagination.getTemplateType())){
|
||||
sendMessageConfigPagination.setTemplateType("0");
|
||||
}
|
||||
List<SendMessageConfigEntity> list = sendMessageConfigService.getList(sendMessageConfigPagination, null);
|
||||
//处理id字段转名称,若无需转或者为空可删除
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
List<SendConfigListVO> listVO = JsonUtil.getJsonToList(list, SendConfigListVO.class);
|
||||
for (SendConfigListVO sendConfigVO : listVO) {
|
||||
//子表数据转换
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = sendConfigTemplateService.getDetailListByParentId(sendConfigVO.getId());
|
||||
sendConfigTemplateList = sendConfigTemplateList.stream().filter(t->"1".equals(String.valueOf(t.getEnabledMark()))).collect(Collectors.toList());
|
||||
List<SendConfigTemplateModel> modelList = JsonUtil.getJsonToList(sendConfigTemplateList, SendConfigTemplateModel.class);
|
||||
for(SendConfigTemplateModel model:modelList) {
|
||||
if (modelList != null && modelList.size() > 0) {
|
||||
List<TemplateParamModel> list1 = messageTemplateConfigService.getParamJson(model.getTemplateId());
|
||||
// if (list != null && list.size() > 0) {
|
||||
// model.setParamJson(JsonUtil.getObjectToString(list1));
|
||||
// }
|
||||
List<MsgTemplateJsonModel> jsonModels = new ArrayList<>();
|
||||
for(TemplateParamModel paramModel : list1){
|
||||
MsgTemplateJsonModel jsonModel = new MsgTemplateJsonModel();
|
||||
jsonModel.setField(paramModel.getField());
|
||||
jsonModel.setFieldName(paramModel.getFieldName());
|
||||
jsonModel.setMsgTemplateId(model.getId());
|
||||
jsonModels.add(jsonModel);
|
||||
}
|
||||
model.setParamJson(jsonModels);
|
||||
MessageTemplateConfigEntity msgTemEntity = messageTemplateConfigService.getInfo(model.getTemplateId());
|
||||
if (msgTemEntity != null) {
|
||||
model.setMsgTemplateName(msgTemEntity.getFullName());
|
||||
}
|
||||
if (StringUtil.isNotEmpty(model.getMessageType())) {
|
||||
msgSendTypeList.stream().filter(t -> model.getMessageType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> model.setMessageType(dataTypeEntity.getFullName()));
|
||||
}
|
||||
}
|
||||
sendConfigVO.setTemplateJson(modelList);
|
||||
}
|
||||
}
|
||||
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(listVO);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(sendMessageConfigPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param sendMessageConfigForm 发送消息配置模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "创建")
|
||||
@Parameters({
|
||||
@Parameter(name = "sendMessageConfigForm", description = "发送消息配置模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@PostMapping
|
||||
@Transactional
|
||||
public ActionResult create(@RequestBody @Valid SendMessageConfigForm sendMessageConfigForm) throws DataException {
|
||||
boolean b = sendMessageConfigService.checkForm(sendMessageConfigForm, 0,"");
|
||||
if (b) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
if(!"1".equals(sendMessageConfigForm.getTemplateType())){
|
||||
if(sendMessageConfigForm.getEnCode().contains("PZXT")){
|
||||
return ActionResult.fail(MsgCode.MSERR114.get());
|
||||
}
|
||||
}
|
||||
String mainId = RandomUtil.uuId();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
SendMessageConfigEntity entity = JsonUtil.getJsonToBean(sendMessageConfigForm, SendMessageConfigEntity.class);
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setId(mainId);
|
||||
|
||||
if (sendMessageConfigForm.getSendConfigTemplateList() != null) {
|
||||
List<SendConfigTemplateEntity> SendConfigTemplateList = JsonUtil.getJsonToList(sendMessageConfigForm.getSendConfigTemplateList(), SendConfigTemplateEntity.class);
|
||||
long dd = SendConfigTemplateList.stream().filter(t->t.getMessageType().equals("4")).count();
|
||||
long qy = SendConfigTemplateList.stream().filter(t->t.getMessageType().equals("5")).count();
|
||||
boolean isQy = true;
|
||||
boolean isDd = true;
|
||||
Map<String, String> objModel = getSysConfig();
|
||||
if(qy > 0){
|
||||
BaseSystemInfo baseSystemInfo = JsonUtil.getJsonToBean(objModel, BaseSystemInfo.class);
|
||||
// 企业号id
|
||||
String corpId = baseSystemInfo.getQyhCorpId();
|
||||
// 应用凭证
|
||||
String agentId = baseSystemInfo.getQyhAgentId();
|
||||
// 凭证密钥
|
||||
String agentSecret = baseSystemInfo.getQyhAgentSecret();
|
||||
// 同步密钥
|
||||
String corpSecret = baseSystemInfo.getQyhCorpSecret();
|
||||
if(StringUtil.isNotEmpty(corpId) && StringUtil.isNotEmpty(agentId) && StringUtil.isNotEmpty(corpSecret) && StringUtil.isNotEmpty(agentSecret)){
|
||||
isQy = true;
|
||||
}else {
|
||||
isQy = false;
|
||||
}
|
||||
}
|
||||
if(dd > 0){
|
||||
DingTalkModel dingTalkModel = JsonUtil.getJsonToBean(objModel, DingTalkModel.class);
|
||||
// 钉钉企业号Id
|
||||
String dingAgentId = dingTalkModel.getDingAgentId();
|
||||
// 应用凭证
|
||||
String dingSynAppKey = dingTalkModel.getDingSynAppKey();
|
||||
// 凭证密钥
|
||||
String dingSynAppSecret = dingTalkModel.getDingSynAppSecret();
|
||||
if(StringUtil.isNotEmpty(dingSynAppKey) && StringUtil.isNotEmpty(dingSynAppSecret) && StringUtil.isNotEmpty(dingAgentId)){
|
||||
isDd = true;
|
||||
}else {
|
||||
isDd = false;
|
||||
}
|
||||
}
|
||||
if(!isQy){
|
||||
return ActionResult.fail(MsgCode.MSERR120.get());
|
||||
}
|
||||
if(!isDd){
|
||||
return ActionResult.fail(MsgCode.MSERR119.get());
|
||||
}
|
||||
for (SendConfigTemplateEntity entitys : SendConfigTemplateList) {
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setSendConfigId(entity.getId());
|
||||
sendConfigTemplateService.save(entitys);
|
||||
}
|
||||
}
|
||||
sendMessageConfigService.save(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<SendMessageConfigInfoVO> info(@PathVariable("id") String id) {
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfo(id);
|
||||
SendMessageConfigInfoVO vo = JsonUtil.getJsonToBean(entity, SendMessageConfigInfoVO.class);
|
||||
List<DictionaryDataEntity> msgSourceTypeList = dictionaryDataApi.getListByTypeDataCode("msgSourceType");
|
||||
if (StringUtil.isNotEmpty(vo.getMessageSource())) {
|
||||
msgSourceTypeList.stream().filter(t -> vo.getMessageSource().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> vo.setMessageSourceName(dataTypeEntity.getFullName()));
|
||||
}
|
||||
//子表
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = sendMessageConfigService.getSendConfigTemplateList(id);
|
||||
for (SendConfigTemplateEntity sendconfigtemplateEntity : sendConfigTemplateList) {
|
||||
AccountConfigEntity accountConfigEntity = accountConfigService.getInfo(sendconfigtemplateEntity.getAccountConfigId());
|
||||
if(accountConfigEntity != null){
|
||||
sendconfigtemplateEntity.setAccountCode(accountConfigEntity.getEnCode());
|
||||
sendconfigtemplateEntity.setAccountName(accountConfigEntity.getFullName());
|
||||
}
|
||||
MessageTemplateConfigEntity messageTemplateConfigEntity = messageTemplateConfigService.getInfo(sendconfigtemplateEntity.getTemplateId());
|
||||
if(messageTemplateConfigEntity != null){
|
||||
sendconfigtemplateEntity.setTemplateCode(messageTemplateConfigEntity.getEnCode());
|
||||
sendconfigtemplateEntity.setTemplateName(messageTemplateConfigEntity.getFullName());
|
||||
}
|
||||
}
|
||||
vo.setSendConfigTemplateList(sendConfigTemplateList);
|
||||
//副表
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编码获取信息
|
||||
*
|
||||
* @param enCode 编码
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "根据编码获取信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "enCode", description = "编码", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@GetMapping("/getInfoByEnCode/{enCode}")
|
||||
public ActionResult<SendMessageConfigInfoVO> getInfo(@PathVariable("enCode") String enCode) {
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfoByEnCode(enCode);
|
||||
SendMessageConfigInfoVO vo = JsonUtil.getJsonToBean(entity, SendMessageConfigInfoVO.class);
|
||||
//子表
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = sendMessageConfigService.getSendConfigTemplateList(entity.getId());
|
||||
for (SendConfigTemplateEntity sendconfigtemplateEntity : sendConfigTemplateList) {
|
||||
AccountConfigEntity accountConfigEntity = accountConfigService.getInfo(sendconfigtemplateEntity.getAccountConfigId());
|
||||
if(accountConfigEntity != null){
|
||||
sendconfigtemplateEntity.setAccountCode(accountConfigEntity.getEnCode());
|
||||
sendconfigtemplateEntity.setAccountName(accountConfigEntity.getFullName());
|
||||
}
|
||||
MessageTemplateConfigEntity messageTemplateConfigEntity = messageTemplateConfigService.getInfo(sendconfigtemplateEntity.getTemplateId());
|
||||
if(messageTemplateConfigEntity != null){
|
||||
sendconfigtemplateEntity.setTemplateCode(messageTemplateConfigEntity.getEnCode());
|
||||
sendconfigtemplateEntity.setTemplateName(messageTemplateConfigEntity.getFullName());
|
||||
}
|
||||
}
|
||||
vo.setSendConfigTemplateList(sendConfigTemplateList);
|
||||
//副表
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单信息(详情页)
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "表单信息(详情页)")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@GetMapping("/detail/{id}")
|
||||
public ActionResult<SendMessageConfigInfoVO> detailInfo(@PathVariable("id") String id) {
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfo(id);
|
||||
SendMessageConfigInfoVO vo = JsonUtil.getJsonToBean(entity, SendMessageConfigInfoVO.class);
|
||||
|
||||
//子表数据转换
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = sendMessageConfigService.getSendConfigTemplateList(id);
|
||||
for(SendConfigTemplateEntity sendconfigtemplateEntity : sendConfigTemplateList){
|
||||
AccountConfigEntity accountConfigEntity = accountConfigService.getInfo(sendconfigtemplateEntity.getAccountConfigId());
|
||||
if(accountConfigEntity != null){
|
||||
sendconfigtemplateEntity.setAccountCode(accountConfigEntity.getEnCode());
|
||||
sendconfigtemplateEntity.setAccountName(accountConfigEntity.getFullName());
|
||||
}
|
||||
MessageTemplateConfigEntity messageTemplateConfigEntity = messageTemplateConfigService.getInfo(sendconfigtemplateEntity.getTemplateId());
|
||||
if(messageTemplateConfigEntity != null){
|
||||
sendconfigtemplateEntity.setTemplateCode(messageTemplateConfigEntity.getEnCode());
|
||||
sendconfigtemplateEntity.setTemplateName(messageTemplateConfigEntity.getFullName());
|
||||
}
|
||||
}
|
||||
vo.setSendConfigTemplateList(sendConfigTemplateList);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键
|
||||
* @param sendMessageConfigForm 发送信息配置模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
@Parameter(name = "sendMessageConfigForm", description = "发送信息配置模型", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@PutMapping("/{id}")
|
||||
@Transactional
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid SendMessageConfigForm sendMessageConfigForm) throws DataException {
|
||||
|
||||
boolean b = sendMessageConfigService.checkForm(sendMessageConfigForm, 0,sendMessageConfigForm.getId());
|
||||
if (b) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
if("0".equals(sendMessageConfigForm.getEnabledMark())){
|
||||
if(sendMessageConfigService.idUsed(id)){
|
||||
return ActionResult.fail(MsgCode.FA049.get());
|
||||
}
|
||||
}
|
||||
if(!"1".equals(sendMessageConfigForm.getTemplateType())){
|
||||
if(sendMessageConfigForm.getEnCode().contains("PZXT")){
|
||||
return ActionResult.fail(MsgCode.MSERR114.get());
|
||||
}
|
||||
}
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
SendMessageConfigEntity subentity = JsonUtil.getJsonToBean(sendMessageConfigForm, SendMessageConfigEntity.class);
|
||||
subentity.setCreatorUserId(entity.getCreatorUserId());
|
||||
subentity.setCreatorTime(entity.getCreatorTime());
|
||||
subentity.setLastModifyUserId(userInfo.getUserId());
|
||||
subentity.setLastModifyTime(DateUtil.getNowDate());
|
||||
|
||||
//明细表数据更新
|
||||
List<SendConfigTemplateEntity> addTemplateList = new ArrayList<>();
|
||||
List<SendConfigTemplateEntity> updTemplateList = new ArrayList<>();
|
||||
List<SendConfigTemplateEntity> delTemplateList = new ArrayList<>();
|
||||
if (sendMessageConfigForm.getSendConfigTemplateList() != null) {
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateEntityList = JsonUtil.getJsonToList(sendMessageConfigForm.getSendConfigTemplateList(), SendConfigTemplateEntity.class);
|
||||
long dd = sendConfigTemplateEntityList.stream().filter(t->t.getMessageType().equals("4")).count();
|
||||
long qy = sendConfigTemplateEntityList.stream().filter(t->t.getMessageType().equals("5")).count();
|
||||
boolean isQy = true;
|
||||
boolean isDd = true;
|
||||
Map<String, String> objModel = getSysConfig();
|
||||
if(qy > 0){
|
||||
BaseSystemInfo baseSystemInfo = JsonUtil.getJsonToBean(objModel, BaseSystemInfo.class);
|
||||
// 企业号id
|
||||
String corpId = baseSystemInfo.getQyhCorpId();
|
||||
// 应用凭证
|
||||
String agentId = baseSystemInfo.getQyhAgentId();
|
||||
// 凭证密钥
|
||||
String agentSecret = baseSystemInfo.getQyhAgentSecret();
|
||||
// 同步密钥
|
||||
String corpSecret = baseSystemInfo.getQyhCorpSecret();
|
||||
if(StringUtil.isNotEmpty(corpId) && StringUtil.isNotEmpty(agentId) && StringUtil.isNotEmpty(corpSecret) && StringUtil.isNotEmpty(agentSecret)){
|
||||
isQy = true;
|
||||
}else {
|
||||
isQy = false;
|
||||
}
|
||||
}
|
||||
if(dd > 0){
|
||||
DingTalkModel dingTalkModel = JsonUtil.getJsonToBean(objModel, DingTalkModel.class);
|
||||
// 钉钉企业号Id
|
||||
String dingAgentId = dingTalkModel.getDingAgentId();
|
||||
// 应用凭证
|
||||
String dingSynAppKey = dingTalkModel.getDingSynAppKey();
|
||||
// 凭证密钥
|
||||
String dingSynAppSecret = dingTalkModel.getDingSynAppSecret();
|
||||
if(StringUtil.isNotEmpty(dingSynAppKey) && StringUtil.isNotEmpty(dingSynAppSecret) && StringUtil.isNotEmpty(dingAgentId)){
|
||||
isDd = true;
|
||||
}else {
|
||||
isDd = false;
|
||||
}
|
||||
}
|
||||
if(!isQy){
|
||||
return ActionResult.fail(MsgCode.MSERR120.get());
|
||||
}
|
||||
if(!isDd){
|
||||
return ActionResult.fail(MsgCode.MSERR119.get());
|
||||
}
|
||||
for (SendConfigTemplateEntity entitys : sendConfigTemplateEntityList) {
|
||||
SendConfigTemplateEntity templateEntity = StringUtil.isNotEmpty(entitys.getId())?sendConfigTemplateService.getInfo(entitys.getId()):null;
|
||||
if(templateEntity != null){
|
||||
templateEntity.setSendConfigId(entity.getId());
|
||||
templateEntity.setId(entitys.getId());
|
||||
templateEntity.setEnabledMark(entitys.getEnabledMark());
|
||||
templateEntity.setCreatorTime(entitys.getCreatorTime());
|
||||
templateEntity.setCreatorUserId(entitys.getCreatorUserId());
|
||||
templateEntity.setDescription(entitys.getDescription());
|
||||
templateEntity.setAccountConfigId(entitys.getAccountConfigId());
|
||||
templateEntity.setSortCode(entitys.getSortCode());
|
||||
templateEntity.setLastModifyTime(DateUtil.getNowDate());
|
||||
templateEntity.setLastModifyUserId(userInfo.getUserId());
|
||||
templateEntity.setTemplateId(entitys.getTemplateId());
|
||||
updTemplateList.add(templateEntity);
|
||||
}else {
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setSendConfigId(entity.getId());
|
||||
entitys.setCreatorUserId(userInfo.getUserId());
|
||||
entitys.setCreatorTime(DateUtil.getNowDate());
|
||||
addTemplateList.add(entitys);
|
||||
}
|
||||
}
|
||||
//删除参数记录
|
||||
List<SendConfigTemplateEntity> paramEntityList = sendConfigTemplateService.getDetailListByParentId(entity.getId());
|
||||
if (paramEntityList != null) {
|
||||
for (SendConfigTemplateEntity templateEntity : paramEntityList) {
|
||||
SendConfigTemplateEntity templateEntity1 = sendConfigTemplateEntityList.stream().filter(t -> t.getId().equals(templateEntity.getId())).findFirst().orElse(null);
|
||||
if (templateEntity1 == null) {
|
||||
delTemplateList.add(templateEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addTemplateList != null && addTemplateList.size() > 0) {
|
||||
sendConfigTemplateService.saveBatch(addTemplateList);
|
||||
}
|
||||
if (updTemplateList != null && updTemplateList.size() > 0) {
|
||||
sendConfigTemplateService.updateBatchById(updTemplateList);
|
||||
}
|
||||
if (delTemplateList != null && delTemplateList.size() > 0) {
|
||||
sendConfigTemplateService.removeByIds(delTemplateList.stream().map(SendConfigTemplateEntity::getId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
boolean b1 = sendMessageConfigService.updateById(subentity);
|
||||
if (!b1) {
|
||||
return ActionResult.fail(MsgCode.VS405.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@DeleteMapping("/{id}")
|
||||
@Transactional
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
if(sendMessageConfigService.idUsed(id)){
|
||||
return ActionResult.fail(MsgCode.FA050.get());
|
||||
}
|
||||
sendMessageConfigService.delete(entity);
|
||||
QueryWrapper<SendConfigTemplateEntity> queryWrapperSendConfigTemplate = new QueryWrapper<>();
|
||||
queryWrapperSendConfigTemplate.lambda().eq(SendConfigTemplateEntity::getSendConfigId, entity.getId());
|
||||
sendConfigTemplateService.remove(queryWrapperSendConfigTemplate);
|
||||
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送配置
|
||||
*
|
||||
* @param id 发送配置id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取消息发送配置")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@PostMapping("/getTestConfig/{id}")
|
||||
@Transactional
|
||||
public ActionResult getTestConfig(@PathVariable("id") String id){
|
||||
List<SendConfigTemplateEntity> configTemplateList = sendConfigTemplateService.getConfigTemplateListByConfigId(id);
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
if(configTemplateList != null && configTemplateList.size()>0){
|
||||
List<SendConfigTemplateModel> modelList = JsonUtil.getJsonToList(configTemplateList, SendConfigTemplateModel.class);
|
||||
for(SendConfigTemplateModel model:modelList){
|
||||
List<TemplateParamModel> list = messageTemplateConfigService.getParamJson(model.getTemplateId());
|
||||
if(list!=null && list.size()>0){
|
||||
model.setParamJson(list);
|
||||
}
|
||||
MessageTemplateConfigEntity msgTemEntity = messageTemplateConfigService.getInfo(model.getTemplateId());
|
||||
if(msgTemEntity != null){
|
||||
model.setMsgTemplateName(msgTemEntity.getFullName());
|
||||
}
|
||||
if(StringUtil.isNotEmpty(model.getMessageType())){
|
||||
msgSendTypeList.stream().filter(t -> model.getMessageType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> model.setMessageType(dataTypeEntity.getFullName()));
|
||||
}
|
||||
}
|
||||
return ActionResult.success(modelList);
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.MSERR121.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试消息发送配置
|
||||
*
|
||||
* @param modelList 发送配置
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "测试消息发送配置")
|
||||
@Parameters({
|
||||
@Parameter(name = "modelList", description = "发送配置", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@PostMapping("/testSendConfig")
|
||||
@Transactional
|
||||
public ActionResult testSendConfig(@RequestBody @Valid List<SendConfigTemplateModel> modelList) throws NoSuchAlgorithmException, InvalidKeyException {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<SendConfigTestResultModel> resultList = new ArrayList<>();
|
||||
List<DictionaryDataEntity> msgSendTypeList = dictionaryDataApi.getListByTypeDataCode("msgSendType");
|
||||
if(modelList != null && modelList.size()>0){
|
||||
for(SendConfigTemplateModel model: modelList){
|
||||
SendConfigTestResultModel resultModel = new SendConfigTestResultModel();
|
||||
String result = testSendConfigUtil.sendMessage(model,userInfo);
|
||||
MessageTemplateConfigEntity msgTemEntity = messageTemplateConfigService.getInfo(model.getTemplateId());
|
||||
if(msgTemEntity != null) {
|
||||
msgSendTypeList.stream().filter(t -> msgTemEntity.getMessageType().equals(t.getEnCode())).findFirst()
|
||||
.ifPresent(dataTypeEntity -> resultModel.setMessageType("消息类型:" + dataTypeEntity.getFullName()));
|
||||
resultModel.setResult(result);
|
||||
if (result != null) {
|
||||
resultModel.setIsSuccess("0");
|
||||
} else {
|
||||
resultModel.setIsSuccess("1");
|
||||
}
|
||||
}
|
||||
resultList.add(resultModel);
|
||||
}
|
||||
}
|
||||
return ActionResult.success(resultList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "复制")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@SaCheckPermission("msgCenter.sendConfig")
|
||||
@PostMapping("/{id}/Actions/Copy")
|
||||
@Transactional
|
||||
public ActionResult copy(@PathVariable("id") String id) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfo(id);
|
||||
if (entity != null) {
|
||||
entity.setEnabledMark(0);
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName()+".副本"+copyNum);
|
||||
entity.setEnCode(entity.getEnCode()+copyNum);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setTemplateType("0");
|
||||
entity.setId(RandomUtil.uuId());
|
||||
SendMessageConfigEntity copyEntity = JsonUtil.getJsonToBean(entity, SendMessageConfigEntity.class);
|
||||
if(copyEntity.getEnCode().length()>50 || copyEntity.getFullName().length()>50){
|
||||
return ActionResult.fail(MsgCode.PRI006.get());
|
||||
}
|
||||
sendMessageConfigService.create(copyEntity);
|
||||
List<SendConfigTemplateEntity> copyConfigTemplateList = new ArrayList<>();
|
||||
List<SendConfigTemplateEntity> configTemplateList = sendConfigTemplateService.getDetailListByParentId(id);
|
||||
if(configTemplateList != null && configTemplateList.size()>0){
|
||||
for(SendConfigTemplateEntity entitys : configTemplateList){
|
||||
entitys.setId(RandomUtil.uuId());
|
||||
entitys.setSendConfigId(copyEntity.getId());
|
||||
entitys.setCreatorTime(DateUtil.getNowDate());
|
||||
entitys.setCreatorUserId(userInfo.getUserId());
|
||||
entitys.setLastModifyTime(null);
|
||||
entitys.setLastModifyUserId(null);
|
||||
copyConfigTemplateList.add(entitys);
|
||||
}
|
||||
}
|
||||
if(copyConfigTemplateList != null && copyConfigTemplateList.size()>0) {
|
||||
sendConfigTemplateService.saveBatch(copyConfigTemplateList);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU007.get());
|
||||
}else {
|
||||
return ActionResult.fail(MsgCode.FA004.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出消息发送配置
|
||||
*
|
||||
* @param id 账号配置id
|
||||
* @return ignore
|
||||
*/
|
||||
@Operation(summary = "导出")
|
||||
@GetMapping("/{id}/Action/Export")
|
||||
public ActionResult export(@PathVariable String id) {
|
||||
SendMessageConfigEntity entity = sendMessageConfigService.getInfo(id);
|
||||
SendMessageConfigInfoVO vo = JsonUtil.getJsonToBean(entity, SendMessageConfigInfoVO.class);
|
||||
|
||||
//子表数据
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = sendMessageConfigService.getSendConfigTemplateList(id);
|
||||
vo.setSendConfigTemplateList(sendConfigTemplateList);
|
||||
//导出文件
|
||||
DownloadVO downloadVO = fileExport.exportFile(vo, configValueUtil.getTemporaryFilePath(), entity.getFullName(), ModuleTypeEnum.MESSAGE_SEND_CONFIG.getTableName());
|
||||
return ActionResult.success(downloadVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入账号配置
|
||||
*
|
||||
* @param multipartFile 备份json文件
|
||||
* @return 执行结果标识
|
||||
*/
|
||||
@Operation(summary = "导入")
|
||||
@PostMapping(value = "/Action/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ActionResult importData(@RequestPart("file") MultipartFile multipartFile) throws DataException {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
//判断是否为.json结尾
|
||||
if (FileUtil.existsSuffix(multipartFile, ModuleTypeEnum.MESSAGE_SEND_CONFIG.getTableName())) {
|
||||
return ActionResult.fail(MsgCode.IMP002.get());
|
||||
}
|
||||
//获取文件内容
|
||||
String fileContent = FileUtil.getFileContent(multipartFile);
|
||||
SendMessageConfigInfoVO infoVO = JsonUtil.getJsonToBean(fileContent, SendMessageConfigInfoVO.class);
|
||||
SendMessageConfigEntity entity = JsonUtil.getJsonToBean(infoVO, SendMessageConfigEntity.class);
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
if (infoVO.getSendConfigTemplateList() != null) {
|
||||
List<SendConfigTemplateEntity> sendConfigTemplateList = JsonUtil.getJsonToList(infoVO.getSendConfigTemplateList(), SendConfigTemplateEntity.class);
|
||||
sendConfigTemplateService.saveBatch(sendConfigTemplateList);
|
||||
}
|
||||
return sendMessageConfigService.ImportData(entity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getSysConfig() {
|
||||
Map<String, String> objModel = new HashMap<>();
|
||||
List<SysConfigEntity> configList = sysconfigService.getList("SysConfig");
|
||||
for (SysConfigEntity entity : configList) {
|
||||
objModel.put(entity.getFkey(), entity.getValue());
|
||||
}
|
||||
return objModel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.consts.DeviceType;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.exception.LoginException;
|
||||
import com.yunzhupaas.message.entity.ShortLinkEntity;
|
||||
import com.yunzhupaas.message.service.ShortLinkService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "短链接跳转", description = "message")
|
||||
@RequestMapping("/api/message/ShortLink")
|
||||
public class ShortLinkController extends SuperController<ShortLinkService, ShortLinkEntity> {
|
||||
@Autowired
|
||||
private ShortLinkService shortLinkService;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
protected AuthUtil authUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 消息发送配置弹窗列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@NoDataSourceBind
|
||||
@Operation(summary = "根据短链接获取实际链接地址")
|
||||
@Parameters({
|
||||
@Parameter(name = "shortLink", description = "短链接", required = true),
|
||||
@Parameter(name = "tenant", description = "租户")
|
||||
})
|
||||
@GetMapping(value = {"/{shortLink}/{tenant}", "/{shortLink}"})
|
||||
public ActionResult getShortUrl(@PathVariable("shortLink") String shortLink, @PathVariable(value = "tenant", required = false) String tenant, HttpServletResponse response) throws LoginException, IOException {
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
if (StringUtil.isNotEmpty(tenant)) {
|
||||
//切换成租户库
|
||||
TenantDataSourceUtil.switchTenant(tenant);
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.LOG115.get());
|
||||
}
|
||||
}
|
||||
String link = new String();
|
||||
ShortLinkEntity entity = shortLinkService.getInfoByLink(shortLink);
|
||||
String frontDomain = configValueUtil.getFrontDomain();
|
||||
String appDomain = configValueUtil.getAppDomain();
|
||||
String realPcLink = entity.getRealPcLink();
|
||||
String realAppLink = entity.getRealAppLink();
|
||||
if (!realPcLink.contains("http")) {
|
||||
realPcLink = frontDomain + realPcLink;
|
||||
}
|
||||
if (!realAppLink.contains("http")) {
|
||||
realAppLink = appDomain + realAppLink;
|
||||
}
|
||||
DeviceType type = UserProvider.getDeviceForAgent();
|
||||
if (entity != null) {
|
||||
// String encode = "";
|
||||
String token = authUtil.loginTempUser(entity.getUserId(), tenant);
|
||||
if (StringUtil.isEmpty(token)) {
|
||||
return ActionResult.fail(MsgCode.AD104.get());
|
||||
}
|
||||
|
||||
if (entity.getIsUsed() == 1) {
|
||||
if (entity.getClickNum() < entity.getUnableNum() && entity.getUnableTime().after(DateUtil.getNowDate())) {
|
||||
if (DeviceType.PC.equals(type)) {
|
||||
link = realPcLink + "&token=" + token;
|
||||
entity.setClickNum(entity.getClickNum() + 1);
|
||||
shortLinkService.updateById(entity);
|
||||
} else {
|
||||
link = realAppLink + "&token=" + token;
|
||||
entity.setClickNum(entity.getClickNum() + 1);
|
||||
shortLinkService.updateById(entity);
|
||||
}
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA039.get());
|
||||
}
|
||||
} else {
|
||||
if (entity.getUnableTime().after(DateUtil.getNowDate())) {
|
||||
if (DeviceType.PC.equals(type)) {
|
||||
link = realPcLink + "&token=" + token;
|
||||
entity.setClickNum(entity.getClickNum() + 1);
|
||||
shortLinkService.updateById(entity);
|
||||
} else {
|
||||
link = realAppLink + "&token=" + token;
|
||||
entity.setClickNum(entity.getClickNum() + 1);
|
||||
shortLinkService.updateById(entity);
|
||||
}
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA039.get());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA039.get());
|
||||
}
|
||||
response.sendRedirect(link);
|
||||
return ActionResult.success("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
package com.yunzhupaas.message.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import com.yunzhupaas.base.entity.SysConfigEntity;
|
||||
import com.yunzhupaas.base.service.SysconfigService;
|
||||
import com.yunzhupaas.message.entity.AccountConfigEntity;
|
||||
import com.yunzhupaas.message.entity.WechatUserEntity;
|
||||
import com.yunzhupaas.message.service.AccountConfigService;
|
||||
import com.yunzhupaas.message.service.WechatUserService;
|
||||
import com.yunzhupaas.message.util.weixingzh.WXGZHWebChatUtil;
|
||||
import com.yunzhupaas.message.util.weixingzh.aes.WXBizMsgCrypt;
|
||||
import com.yunzhupaas.permission.entity.SocialsUserEntity;
|
||||
import com.yunzhupaas.permission.service.SocialsUserService;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发送消息模型
|
||||
*/
|
||||
@Tag(name = "微信公众号事件接收", description = "WechatOpen")
|
||||
@Controller
|
||||
@RequestMapping("/api/message/WechatOpen")
|
||||
@Slf4j
|
||||
public class WxGZHFunctionController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private SysconfigService sysconfigService;
|
||||
@Autowired
|
||||
private AccountConfigService accountConfigService;
|
||||
@Autowired
|
||||
private SocialsUserService socialsUserService;
|
||||
@Autowired
|
||||
private WechatUserService wechatUserService;
|
||||
|
||||
/**
|
||||
* 服务器基本配置链接微信公众号验证
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param response 响应对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "服务器基本配置链接微信公众号验证")
|
||||
@ResponseBody
|
||||
@Parameters({
|
||||
@Parameter(name = "enCode", description = "微信公众号账号配置编码", required = true)
|
||||
})
|
||||
@GetMapping("/token/{enCode}")
|
||||
public String token(@PathVariable("enCode") String enCode, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
//获取微信公众号账号配置
|
||||
AccountConfigEntity accountConfigEntity = accountConfigService.getInfoByEnCode(enCode,"7");
|
||||
if(ObjectUtil.isEmpty(accountConfigEntity)){
|
||||
log.info("未找到与编码相对应的微信公众号配置");
|
||||
return "";
|
||||
}
|
||||
//微信公众号服务器配置token
|
||||
String wxToken = accountConfigEntity.getAgentId();
|
||||
String signature = request.getParameter("signature");
|
||||
String echostr = XSSEscape.escape(request.getParameter("echostr"));
|
||||
String timestamp = request.getParameter("timestamp");
|
||||
String nonce = request.getParameter("nonce");
|
||||
|
||||
String sortStr = WXGZHWebChatUtil.sort(wxToken,timestamp,nonce);
|
||||
String mySinStr = WXGZHWebChatUtil.shal(sortStr);
|
||||
if(StringUtil.isNotBlank(signature) && mySinStr.equals(signature)){
|
||||
return echostr;
|
||||
}else {
|
||||
log.info("微信公众号链接失败");
|
||||
return echostr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信公众号事件请求
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param response 响应对象
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(summary = "微信公众号事件请求")
|
||||
@ResponseBody
|
||||
@PostMapping("/token/{enCode}")
|
||||
/**
|
||||
* 微信公众号事件请求
|
||||
*/
|
||||
public String tokenPost(@PathVariable("enCode") String enCode,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
log.info("微信公众号请求事件");
|
||||
//获取微信公众号账号配置
|
||||
AccountConfigEntity accountConfigEntity = accountConfigService.getInfoByEnCode(enCode,"7");
|
||||
if(ObjectUtil.isEmpty(accountConfigEntity)){
|
||||
log.info("未找到与编码相对应的微信公众号配置");
|
||||
return "";
|
||||
}
|
||||
//微信公众号服务器配置token
|
||||
String wxToken = accountConfigEntity.getAgentId();
|
||||
//微信公众号服务器配置EncodingAesKey
|
||||
String encodingAesKey = accountConfigEntity.getBearer();
|
||||
//微信公众号AppId
|
||||
String wxAppId = accountConfigEntity.getAppId();
|
||||
|
||||
// 获取系统配置
|
||||
String msgSignature = request.getParameter("msg_signature");
|
||||
String encrypt_type = request.getParameter("encrypt_type");
|
||||
String signature = request.getParameter("signature");
|
||||
String echostr = XSSEscape.escape(request.getParameter("echostr"));
|
||||
String timestamp = request.getParameter("timestamp");
|
||||
String nonce = request.getParameter("nonce");
|
||||
|
||||
String sortStr = WXGZHWebChatUtil.sort(wxToken,timestamp,nonce);
|
||||
String mySinStr = WXGZHWebChatUtil.shal(sortStr);
|
||||
//验签
|
||||
if(StringUtil.isNotBlank(signature) && mySinStr.equals(signature)){
|
||||
//事件信息
|
||||
Map<String ,String> map = WXGZHWebChatUtil.parseXml(request);
|
||||
//事件信息
|
||||
String Event = map.get("Event");
|
||||
String openid = map.get("FromUserName");
|
||||
//公众号原始id
|
||||
String gzhId = map.get("ToUserName");
|
||||
if("aes".equals(encrypt_type)) {
|
||||
WXBizMsgCrypt pc = new WXBizMsgCrypt(wxToken, encodingAesKey, wxAppId);
|
||||
String encrypt = map.get("Encrypt");
|
||||
String format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>";
|
||||
String fromXML = String.format(format, encrypt);
|
||||
// 获取解密后消息明文
|
||||
String result = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML);
|
||||
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
resultMap = WXGZHWebChatUtil.xmlToMap(result);
|
||||
// 获取解密后事件信息
|
||||
Event = resultMap.get("Event");
|
||||
openid = resultMap.get("FromUserName");
|
||||
gzhId = resultMap.get("ToUserName");
|
||||
}
|
||||
|
||||
String appId = accountConfigEntity.getAppId();
|
||||
String appsecret = accountConfigEntity.getAppSecret();
|
||||
String token = WXGZHWebChatUtil.getAccessToken(appId,appsecret);
|
||||
if("subscribe".equals(Event)){
|
||||
//用户关注事件
|
||||
if(StringUtil.isNotBlank(token)){
|
||||
JSONObject rstObj = WXGZHWebChatUtil.getUsetInfo(token,openid);
|
||||
if(rstObj.containsKey("unionid")){
|
||||
String unionid = rstObj.getString("unionid");
|
||||
SocialsUserEntity socialsUserEntity = socialsUserService.getInfoBySocialId(unionid,"wechat_open");
|
||||
if(socialsUserEntity==null){
|
||||
log.info("微信公众号未绑定系统账号,请登录小程序绑定");
|
||||
return "";
|
||||
}else{
|
||||
WechatUserEntity wechatUserEntity = wechatUserService.getInfoByGzhId(socialsUserEntity.getUserId(),gzhId);
|
||||
if(wechatUserEntity==null){
|
||||
WechatUserEntity entity = new WechatUserEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setUserId(socialsUserEntity.getUserId());
|
||||
entity.setGzhId(gzhId);
|
||||
entity.setCloseMark(1);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setOpenId(openid);
|
||||
wechatUserService.create(entity);
|
||||
return "";
|
||||
}else {
|
||||
if(wechatUserEntity.getCloseMark()==0){
|
||||
wechatUserEntity.setCloseMark(1);
|
||||
}
|
||||
wechatUserEntity.setOpenId(openid);
|
||||
wechatUserEntity.setLastModifyTime(DateUtil.getNowDate());
|
||||
wechatUserService.update(wechatUserEntity.getId(),wechatUserEntity);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}else{
|
||||
log.info("微信公众号未绑定系统账号,请登录小程序绑定");
|
||||
return "";
|
||||
}
|
||||
}else{
|
||||
log.error("微信公众号token错误,请查看配置");
|
||||
return "";
|
||||
}
|
||||
}else if("unsubscribe".equals(Event)){
|
||||
//用户取消关注事件
|
||||
if(StringUtil.isNotBlank(token)){
|
||||
JSONObject rstObj = WXGZHWebChatUtil.getUsetInfo(token,openid);
|
||||
if(rstObj.containsKey("unionid")){
|
||||
String unionid = rstObj.getString("unionid");
|
||||
SocialsUserEntity socialsUserEntity = socialsUserService.getInfoBySocialId(unionid,"wechat_open");
|
||||
if(socialsUserEntity==null){
|
||||
log.info("微信公众号未绑定系统账号,请登录小程序绑定");
|
||||
}else{
|
||||
WechatUserEntity wechatUserEntity = wechatUserService.getInfoByGzhId(socialsUserEntity.getUserId(),gzhId);
|
||||
if(wechatUserEntity==null){
|
||||
WechatUserEntity entity = new WechatUserEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setUserId(socialsUserEntity.getUserId());
|
||||
entity.setGzhId(gzhId);
|
||||
entity.setCloseMark(0);
|
||||
entity.setCreatorTime(DateUtil.getNowDate());
|
||||
entity.setOpenId(openid);
|
||||
wechatUserService.create(entity);
|
||||
return "";
|
||||
}else {
|
||||
if(wechatUserEntity.getCloseMark()==1){
|
||||
wechatUserEntity.setCloseMark(0);
|
||||
}
|
||||
wechatUserEntity.setOpenId(openid);
|
||||
wechatUserEntity.setLastModifyTime(DateUtil.getNowDate());
|
||||
wechatUserService.update(wechatUserEntity.getId(),wechatUserEntity);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
log.info("微信公众号未绑定系统账号,请登录小程序绑定");
|
||||
return "";
|
||||
}
|
||||
}else{
|
||||
log.error("微信公众号token错误,请查看配置");
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
}else {
|
||||
log.info("微信公众号事件请求失败");
|
||||
return echostr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统配置
|
||||
*/
|
||||
private Map<String, String> getSystemConfig() {
|
||||
// 获取系统配置
|
||||
List<SysConfigEntity> configList = sysconfigService.getList("SysConfig");
|
||||
Map<String, String> objModel = new HashMap<>(16);
|
||||
for (SysConfigEntity entity : configList) {
|
||||
objModel.put(entity.getFkey(), entity.getValue());
|
||||
}
|
||||
return objModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,477 @@
|
||||
package com.yunzhupaas.message.websocket;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.yunzhupaas.base.PageModel;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SysconfigService;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.message.entity.MessageReceiveEntity;
|
||||
import com.yunzhupaas.message.service.UserDeviceService;
|
||||
import com.yunzhupaas.message.util.*;
|
||||
import com.yunzhupaas.message.util.unipush.UinPush;
|
||||
import com.yunzhupaas.message.entity.ImContentEntity;
|
||||
import com.yunzhupaas.message.entity.MessageEntity;
|
||||
import com.yunzhupaas.message.model.message.PaginationMessage;
|
||||
import com.yunzhupaas.message.model.websocket.onconnettion.OnConnectionModel;
|
||||
import com.yunzhupaas.message.model.websocket.onconnettion.OnLineModel;
|
||||
import com.yunzhupaas.message.model.websocket.receivemessage.ReceiveMessageModel;
|
||||
import com.yunzhupaas.message.model.websocket.savafile.ImageMessageModel;
|
||||
import com.yunzhupaas.message.model.websocket.savafile.VoiceMessageModel;
|
||||
import com.yunzhupaas.message.model.websocket.savamessage.SavaMessageModel;
|
||||
import com.yunzhupaas.message.service.ImContentService;
|
||||
import com.yunzhupaas.message.service.MessageService;
|
||||
import com.yunzhupaas.message.model.ImUnreadNumModel;
|
||||
import com.yunzhupaas.model.BaseSystemInfo;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.context.SpringContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.websocket.*;
|
||||
import jakarta.websocket.server.PathParam;
|
||||
import jakarta.websocket.server.ServerEndpoint;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消息聊天
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@ServerEndpoint(value = "/api/message/websocket/{token}")
|
||||
@Scope("prototype")
|
||||
public class WebSocket {
|
||||
|
||||
private ImContentService imContentService;
|
||||
private MessageService messageService;
|
||||
private ConfigValueUtil configValueUtil;
|
||||
private UserInfo userInfo;
|
||||
private UserService userApi;
|
||||
private SysconfigService sysConfigApi;
|
||||
private UinPush uinPush;
|
||||
private UserDeviceService userDeviceService;
|
||||
|
||||
|
||||
/**
|
||||
* 连接建立成功调用的方法
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("token") String token) {
|
||||
this.init();
|
||||
this.userInfo = UserProvider.getUser(token);
|
||||
if (this.userInfo.getUserId() == null) {
|
||||
try{
|
||||
OnlineUserProvider.closeFrontWs(null, session);
|
||||
session.close();
|
||||
}catch (Exception e){}
|
||||
log.info("WS建立链接, TOKEN无效:{}, {}", session.getId(), token);
|
||||
}else {
|
||||
log.info("WS建立链接:{}, {}", session.getId(), token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接关闭调用的方法
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose(Session session) {
|
||||
OnlineUserModel user = OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getConnectionId().equals(session.getId())).findFirst().orElse(null);
|
||||
if (user != null) {
|
||||
OnlineUserProvider.removeWebSocketByToken(user.getToken());
|
||||
log.info("WS连接断开: {}, {}, {}, {}", user.getTenantId(), user.getUserId(), session.getId(), user.getToken());
|
||||
}else{
|
||||
log.debug("WS连接断开, 无用户信息: {}", session.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到客户端消息后调用的方法
|
||||
*
|
||||
* @param message 客户端发送过来的消息
|
||||
*/
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session) {
|
||||
try{
|
||||
processMessage(message, session);
|
||||
}finally {
|
||||
//多租户切换后清除缓存
|
||||
UserProvider.clearLocalUser();
|
||||
TenantDataSourceUtil.clearLocalTenantInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private void processMessage(String message, Session session){
|
||||
log.debug("WS消息内容: {}, {}", session.getId(), message);
|
||||
JSONObject receivedMessage = JSONObject.parseObject(message);
|
||||
String receivedMethod = receivedMessage.getString(MessageParameterEnum.PARAMETER_METHOD.getValue());
|
||||
String receivedToken = receivedMessage.getString(MessageParameterEnum.PARAMETER_TOKEN.getValue());
|
||||
//验证TOKEN
|
||||
this.userInfo = UserProvider.getUser(receivedMessage.getString(MessageParameterEnum.PARAMETER_TOKEN.getValue()));
|
||||
if (this.userInfo.getUserId() == null) {
|
||||
log.info("WSToken无效: {}, {}", session.getId(), message);
|
||||
OnlineUserProvider.closeFrontWs(null, session);
|
||||
return;
|
||||
}
|
||||
//判断是否为多租户
|
||||
if(!isMultiTenancy()){
|
||||
log.info("WS切库失败: {}, {}, {}, {}", userInfo.getTenantId(), userInfo.getUserId(), session.getId(), receivedToken);
|
||||
//切库失败
|
||||
OnlineUserProvider.closeFrontWs(null, session);
|
||||
}
|
||||
UserProvider.setLocalLoginUser(userInfo);
|
||||
switch (receivedMethod) {
|
||||
case ConnectionType.CONNECTION_ONCONNECTION:
|
||||
//建立连接
|
||||
log.info("WS开启连接: {}, {}, {}, {}", userInfo.getTenantId(), userInfo.getUserId(), session.getId(), receivedToken);
|
||||
if(OnlineUserProvider.getOnlineUserList().stream().anyMatch(t -> t.getWebSocket().getId().equals(session.getId()))){
|
||||
//WS已存在
|
||||
log.info("WS已存在: {}, {}, {}, {}", userInfo.getTenantId(), userInfo.getUserId(), session.getId(), receivedToken);
|
||||
return;
|
||||
}
|
||||
//Token已存在, 关闭之前的WebSocket, 继续执行后续代码添加新的WebSocket
|
||||
List<OnlineUserModel> tokenList = OnlineUserProvider.getOnlineUserList().stream().filter(t-> {
|
||||
if(receivedToken.equals(t.getToken())){
|
||||
OnlineUserProvider.closeFrontWs(t, t.getWebSocket());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
OnlineUserProvider.getOnlineUserList().removeAll(tokenList);
|
||||
|
||||
//app-true, PC-false
|
||||
Boolean isMobileDevice = receivedMessage.getBoolean(MessageParameterEnum.PARAMETER_MOBILEDEVICE.getValue());
|
||||
if (userInfo != null && userInfo.getUserId() != null) {
|
||||
OnlineUserModel model = new OnlineUserModel();
|
||||
model.setConnectionId(session.getId());
|
||||
model.setUserId(userInfo.getUserId());
|
||||
model.setTenantId(userInfo.getTenantId());
|
||||
model.setIsMobileDevice(isMobileDevice);
|
||||
model.setWebSocket(session);
|
||||
model.setToken(receivedToken);
|
||||
model.setSystemId(model.getIsMobileDevice() ? userInfo.getAppSystemId() : userInfo.getSystemId());
|
||||
BaseSystemInfo sysInfo = sysConfigApi.getSysInfo();
|
||||
//判断是否在线
|
||||
isOnLine(sysInfo, model);
|
||||
|
||||
List<OnlineUserModel> onlineUserList = OnlineUserProvider.getOnlineUserList().stream().filter(q -> !q.getUserId().equals(userInfo.getUserId()) && q.getTenantId().equals(userInfo.getTenantId())).collect(Collectors.toList());
|
||||
//反馈信息给登录者
|
||||
List<String> onlineUsers = onlineUserList.stream().map(t -> t.getUserId()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
||||
List<ImUnreadNumModel> unreadNums = imContentService.getUnreadList(userInfo.getUserId());
|
||||
int unreadNoticeCount = messageService.getUnreadCount(userInfo.getUserId(), 1);
|
||||
int unreadMessageCount = messageService.getUnreadCount(userInfo.getUserId(), 2);
|
||||
int unreadScheduleCount = messageService.getUnreadCount(userInfo.getUserId(),4);
|
||||
int unreadSystemMessageCount = messageService.getUnreadCount(userInfo.getUserId(), 3);
|
||||
MessageEntity noticeDefaultText = messageService.getInfoDefault(1);
|
||||
PaginationMessage pagination = new PaginationMessage();
|
||||
pagination.setCurrentPage(1);
|
||||
pagination.setPageSize(1);
|
||||
List<MessageReceiveEntity> list = messageService.getMessageList3(pagination, pagination.getType(),userInfo.getUserId(), null);
|
||||
MessageReceiveEntity messageDefaultText = new MessageReceiveEntity();
|
||||
if(list.size()>0){
|
||||
messageDefaultText = list.get(0);
|
||||
}
|
||||
String noticeText = noticeDefaultText.getTitle() != null ? noticeDefaultText.getTitle() : "";
|
||||
String messageText = messageDefaultText.getTitle() != null ? messageDefaultText.getTitle() : "";
|
||||
Long noticeTime = noticeDefaultText.getCreatorTime() != null ? noticeDefaultText.getCreatorTime().getTime() : 0;
|
||||
Long messageTime = messageDefaultText.getCreatorTime() != null ? messageDefaultText.getCreatorTime().getTime() : 0;
|
||||
//转model后上传到mq服务器上
|
||||
OnConnectionModel onConnectionModel = new OnConnectionModel();
|
||||
onConnectionModel.setMethod(MessageChannelType.CHANNEL_INITMESSAGE);
|
||||
onConnectionModel.setOnlineUsers(onlineUsers);
|
||||
onConnectionModel.setUnreadNums(JsonUtil.listToJsonField(unreadNums));
|
||||
onConnectionModel.setUnreadNoticeCount(unreadNoticeCount);
|
||||
// onConnectionModel.setNoticeDefaultText(noticeText);
|
||||
onConnectionModel.setUnreadMessageCount(unreadMessageCount);
|
||||
onConnectionModel.setUnreadSystemMessageCount(unreadSystemMessageCount);
|
||||
onConnectionModel.setUnreadScheduleCount(unreadScheduleCount);
|
||||
onConnectionModel.setMessageDefaultText(messageText);
|
||||
onConnectionModel.setMessageDefaultTime(messageTime);
|
||||
onConnectionModel.setUserId(userInfo.getUserId());
|
||||
int total = unreadNoticeCount+unreadMessageCount+unreadSystemMessageCount+unreadScheduleCount;
|
||||
onConnectionModel.setUnreadTotalCount(total);
|
||||
OnlineUserProvider.sendMessage(session, onConnectionModel);
|
||||
//通知所有在线用户,有用户在线
|
||||
for (OnlineUserModel item : onlineUserList) {
|
||||
if (!item.getUserId().equals(userInfo.getUserId())) {
|
||||
//创建模型
|
||||
OnLineModel remindUserModel = new OnLineModel(MessageChannelType.CHANNEL_ONLINE, userInfo.getUserId());
|
||||
OnlineUserProvider.sendMessage(item, remindUserModel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ConnectionType.CONNECTION_SENDMESSAGE:
|
||||
//发送消息
|
||||
String toUserId = receivedMessage.getString(MessageParameterEnum.PARAMETER_TOUSERID.getValue());
|
||||
//text/voice/image
|
||||
String messageType = receivedMessage.getString(MessageParameterEnum.PARAMETER_MESSAGETYPE.getValue());
|
||||
String messageContent = receivedMessage.getString(MessageParameterEnum.PARAMETER_MESSAGECONTENT.getValue());
|
||||
String tenantId = UserProvider.getUser(receivedMessage.getString(MessageParameterEnum.PARAMETER_TOKEN.getValue())).getTenantId();
|
||||
|
||||
String fileName = "";
|
||||
if (!SendMessageTypeEnum.MESSAGE_TEXT.getMessage().equals(messageType)) {
|
||||
JSONObject object = JSONObject.parseObject(messageContent);
|
||||
fileName = object.getString("name");
|
||||
}
|
||||
List<OnlineUserModel> user = OnlineUserProvider.getOnlineUserList().stream().filter(q -> String.valueOf(q.getUserId()).equals(String.valueOf(userInfo.getUserId())) && String.valueOf(q.getTenantId()).equals(tenantId)).collect(Collectors.toList());
|
||||
OnlineUserModel onlineUser = user.size() > 0 ? user.get(0) : null;
|
||||
List<OnlineUserModel> toUser = OnlineUserProvider.getOnlineUserList().stream().filter(q -> String.valueOf(q.getTenantId()).equals(String.valueOf(onlineUser.getTenantId())) && String.valueOf(q.getUserId()).equals(String.valueOf(toUserId))).collect(Collectors.toList());
|
||||
if (user.size() != 0) {
|
||||
//saveMessage
|
||||
if (SendMessageTypeEnum.MESSAGE_TEXT.getMessage().equals(messageType)) {
|
||||
messageContent = XSSEscape.escape(messageContent);
|
||||
imContentService.sendMessage(onlineUser.getUserId(), toUserId, messageContent, messageType);
|
||||
} else if (SendMessageTypeEnum.MESSAGE_IMAGE.getMessage().equals(messageType)) {
|
||||
JSONObject image = new JSONObject();
|
||||
image.put("path", UploaderUtil.uploaderImg("/api/file/Image/IM/", fileName));
|
||||
image.put("width", JSONObject.parseObject(messageContent).getString("width"));
|
||||
image.put("height", JSONObject.parseObject(messageContent).getString("height"));
|
||||
imContentService.sendMessage(onlineUser.getUserId(), toUserId, image.toJSONString(), messageType);
|
||||
} else if (SendMessageTypeEnum.MESSAGE_VOICE.getMessage().equals(messageType)) {
|
||||
JSONObject voice = new JSONObject();
|
||||
voice.put("path", UploaderUtil.uploaderImg("/api/file/Image/IM/", fileName));
|
||||
voice.put("length", JSONObject.parseObject(messageContent).getString("length"));
|
||||
imContentService.sendMessage(onlineUser.getUserId(), toUserId, voice.toJSONString(), messageType);
|
||||
}
|
||||
for (int i = 0; i < user.size(); i++) {
|
||||
OnlineUserModel model = user.get(i);
|
||||
//组装model
|
||||
SavaMessageModel savaMessageModel = new SavaMessageModel();
|
||||
savaMessageModel.setMethod(MessageChannelType.CHANNEL_SENDMESSAGE);
|
||||
savaMessageModel.setUserId(model.getUserId());
|
||||
savaMessageModel.setToUserId(toUserId);
|
||||
savaMessageModel.setDateTime(DateUtil.getNowDate().getTime());
|
||||
//头像
|
||||
savaMessageModel.setHeadIcon(UploaderUtil.uploaderImg(userInfo.getUserIcon()));
|
||||
//最新消息
|
||||
savaMessageModel.setLatestDate(DateUtil.getNowDate().getTime());
|
||||
//用户姓名
|
||||
savaMessageModel.setRealName(userInfo.getUserName());
|
||||
savaMessageModel.setAccount(userInfo.getUserAccount());
|
||||
//对方的名称账号头像
|
||||
Map<String, String> headers = ImmutableMap.of(Constants.AUTHORIZATION.toLowerCase(), receivedToken);
|
||||
UserEntity entity = userApi.getInfo(toUserId);
|
||||
savaMessageModel.setToAccount(entity.getAccount());
|
||||
savaMessageModel.setToRealName(entity.getRealName());
|
||||
savaMessageModel.setToHeadIcon(UploaderUtil.uploaderImg(entity.getHeadIcon()));
|
||||
|
||||
if (SendMessageTypeEnum.MESSAGE_TEXT.getMessage().equals(messageType)) {
|
||||
savaMessageModel.setMessageType(messageType);
|
||||
savaMessageModel.setToMessage(messageContent);
|
||||
} else if (SendMessageTypeEnum.MESSAGE_IMAGE.getMessage().equals(messageType)) {
|
||||
//构建图片模型
|
||||
ImageMessageModel messageModel = getImageModel(messageContent, UploaderUtil.uploaderImg("/api/file/Image/IM/", fileName));
|
||||
savaMessageModel.setToMessage(messageModel);
|
||||
savaMessageModel.setMessageType(messageType);
|
||||
} else if (SendMessageTypeEnum.MESSAGE_VOICE.getMessage().equals(messageType)) {
|
||||
//构建语音模型
|
||||
VoiceMessageModel messageModel = getVoiceMessageModel(messageContent, UploaderUtil.uploaderImg("/api/file/Image/IM/", fileName));
|
||||
savaMessageModel.setMessageType(messageType);
|
||||
savaMessageModel.setToMessage(messageModel);
|
||||
}
|
||||
/*List<String> cidList = userDeviceService.getCidList(toUserId);
|
||||
if(cidList != null && cidList.size()>0){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type","3");
|
||||
jsonObject.put("name",userInfo.getUserName() + "/"+userInfo.getUserAccount());
|
||||
jsonObject.put("formUserId",userInfo.getUserId());
|
||||
jsonObject.put("headIcon",UploaderUtil.uploaderImg(userInfo.getUserIcon()));
|
||||
// jsonObject.put("title",userInfo.getUserName() + "/"+userInfo.getUserAccount());
|
||||
String text = JSONObject.toJSONString(jsonObject);
|
||||
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||
text = Base64.getEncoder().encodeToString(bytes);
|
||||
uinPush.sendUniPush(cidList, userInfo.getUserName(), "你有一条看聊天消息", "3", text);
|
||||
}*/
|
||||
OnlineUserProvider.sendMessage(model, savaMessageModel);
|
||||
}
|
||||
}
|
||||
|
||||
//接受消息
|
||||
ReceiveMessageModel receiveMessageModel = new ReceiveMessageModel();
|
||||
receiveMessageModel.setMethod(MessageChannelType.CHANNEL_RECEIVEMESSAGE);
|
||||
receiveMessageModel.setFormUserId(onlineUser.getUserId());
|
||||
receiveMessageModel.setDateTime(DateUtil.getNowDate().getTime());
|
||||
//头像
|
||||
receiveMessageModel.setHeadIcon(UploaderUtil.uploaderImg(userInfo.getUserIcon()));
|
||||
//最新消息
|
||||
receiveMessageModel.setLatestDate(DateUtil.getNowDate().getTime());
|
||||
//用户姓名
|
||||
receiveMessageModel.setRealName(userInfo.getUserName());
|
||||
receiveMessageModel.setAccount(userInfo.getUserAccount());
|
||||
receiveMessageModel.setUserId(toUserId);
|
||||
if (toUser.size() != 0) {
|
||||
for (int i = 0; i < toUser.size(); i++) {
|
||||
OnlineUserModel onlineToUser = toUser.get(i);
|
||||
if (SendMessageTypeEnum.MESSAGE_TEXT.getMessage().equals(messageType)) {
|
||||
receiveMessageModel.setMessageType(messageType);
|
||||
receiveMessageModel.setFormMessage(messageContent);
|
||||
} else if (SendMessageTypeEnum.MESSAGE_IMAGE.getMessage().equals(messageType)) {
|
||||
//构建图片模型
|
||||
ImageMessageModel messageModel = getImageModel(messageContent, UploaderUtil.uploaderImg("/api/file/Image/IM/", fileName));
|
||||
receiveMessageModel.setMessageType(messageType);
|
||||
receiveMessageModel.setFormMessage(messageModel);
|
||||
} else if (SendMessageTypeEnum.MESSAGE_VOICE.getMessage().equals(messageType)) {
|
||||
//构建语音模型
|
||||
VoiceMessageModel messageModel = getVoiceMessageModel(messageContent, UploaderUtil.uploaderImg("/api/file/Image/IM/", fileName));
|
||||
receiveMessageModel.setMessageType(messageType);
|
||||
receiveMessageModel.setFormMessage(messageModel);
|
||||
}
|
||||
OnlineUserProvider.sendMessage(onlineToUser, receiveMessageModel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "UpdateReadMessage":
|
||||
//更新已读
|
||||
String formUserId = receivedMessage.getString("formUserId");
|
||||
onlineUser = OnlineUserProvider.getOnlineUserList().stream().filter(q -> String.valueOf(q.getConnectionId()).equals(String.valueOf(session.getId()))).findFirst().orElse(new OnlineUserModel());
|
||||
if (onlineUser != null) {
|
||||
imContentService.readMessage(formUserId, onlineUser.getUserId());
|
||||
}
|
||||
break;
|
||||
case "MessageList":
|
||||
//获取消息列表
|
||||
String sendUserId = receivedMessage.getString("toUserId");
|
||||
String receiveUserId = receivedMessage.getString("formUserId");
|
||||
PageModel pageModel = new PageModel();
|
||||
pageModel.setPage(receivedMessage.getInteger("currentPage"));
|
||||
pageModel.setRows(receivedMessage.getInteger("pageSize"));
|
||||
pageModel.setSord(receivedMessage.getString("sord"));
|
||||
pageModel.setKeyword(receivedMessage.getString("keyword"));
|
||||
List<ImContentEntity> data = imContentService.getMessageList(sendUserId, receiveUserId, pageModel).stream().sorted(Comparator.comparing(ImContentEntity::getSendTime)).collect(Collectors.toList());
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("method", "messageList");
|
||||
object.put("list", JsonUtil.getListToJsonArray(data));
|
||||
JSONObject pagination = new JSONObject();
|
||||
pagination.put("total", pageModel.getRecords());
|
||||
pagination.put("currentPage", pageModel.getPage());
|
||||
pagination.put("pageSize", receivedMessage.getInteger("pageSize"));
|
||||
object.put("pagination", pagination);
|
||||
OnlineUserProvider.sendMessage(session, object);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否在线
|
||||
*
|
||||
* @param model
|
||||
*/
|
||||
private void isOnLine(BaseSystemInfo systemInfo, OnlineUserModel model) {
|
||||
// 不允许多人登录
|
||||
if ("1".equals(String.valueOf(systemInfo.getSingleLogin()))) {
|
||||
Long userAll = OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getUserId().equals(userInfo.getUserId()) && t.getTenantId().equals(userInfo.getTenantId())).count();
|
||||
Long userAllMobile = OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getUserId().equals(userInfo.getUserId()) && t.getTenantId().equals(userInfo.getTenantId()) && t.getIsMobileDevice().equals(true)).count();
|
||||
Long userAllWeb = OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getUserId().equals(userInfo.getUserId()) && t.getTenantId().equals(userInfo.getTenantId()) && t.getIsMobileDevice().equals(false)).count();
|
||||
//都不在线
|
||||
if (userAll == 0) {
|
||||
OnlineUserProvider.addModel(model);
|
||||
}
|
||||
//手机在线
|
||||
else if (userAllMobile != 0 && userAllWeb == 0) {
|
||||
if (!model.getIsMobileDevice()) {
|
||||
OnlineUserProvider.addModel(model);
|
||||
}
|
||||
}
|
||||
//电脑在线
|
||||
else {
|
||||
if (model.getIsMobileDevice()) {
|
||||
OnlineUserProvider.addModel(model);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//同时登录不限制
|
||||
OnlineUserProvider.addModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为多租户
|
||||
*
|
||||
*/
|
||||
private boolean isMultiTenancy() {
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
//多租户需要切库
|
||||
if (StringUtil.isNotEmpty(userInfo.getTenantId())) {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建图片消息模型
|
||||
*
|
||||
* @param messageContent
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
private ImageMessageModel getImageModel(String messageContent, String fileName) {
|
||||
String width = JSONObject.parseObject(messageContent).getString("width");
|
||||
String height = JSONObject.parseObject(messageContent).getString("height");
|
||||
return new ImageMessageModel(width, height, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建语音模型
|
||||
*
|
||||
* @param messageContent
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
private VoiceMessageModel getVoiceMessageModel(String messageContent, String fileName) {
|
||||
String length = JSONObject.parseObject(messageContent).getString("length");
|
||||
return new VoiceMessageModel(length, fileName);
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(Session session, Throwable error) {
|
||||
// OnlineUserModel user = OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getConnectionId().equals(session.getId())).findFirst().isPresent() ? OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getConnectionId().equals(session.getId())).findFirst().get() : null;
|
||||
// if (user != null) {
|
||||
// log.error("调用onError,租户:" + user.getTenantId() + ",用户:" + user.getUserId());
|
||||
// }
|
||||
try {
|
||||
onClose(session);
|
||||
} catch (Exception e) {
|
||||
// log.error("发生error,调用onclose失败,session为:" + session);
|
||||
}
|
||||
if (error.getMessage() != null) {
|
||||
OnlineUserModel user = OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getConnectionId().equals(session.getId())).findFirst().isPresent() ? OnlineUserProvider.getOnlineUserList().stream().filter(t -> t.getConnectionId().equals(session.getId())).findFirst().get() : null;
|
||||
if(user != null){
|
||||
log.error("WS发生错误: {}, {}, {}, {}, {}", user.getTenantId(), user.getUserId(), session.getId(), error.getMessage(), user.getToken());
|
||||
}else{
|
||||
log.error("WS发生错误", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
private void init() {
|
||||
messageService = SpringContext.getBean(MessageService.class);
|
||||
imContentService = SpringContext.getBean(ImContentService.class);
|
||||
configValueUtil = SpringContext.getBean(ConfigValueUtil.class);
|
||||
userApi = SpringContext.getBean(UserService.class);
|
||||
sysConfigApi = SpringContext.getBean(SysconfigService.class);
|
||||
uinPush = SpringContext.getBean(UinPush.class);
|
||||
userDeviceService = SpringContext.getBean(UserDeviceService.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
54
yunzhupaas-message/yunzhupaas-message-entity/pom.xml
Normal file
54
yunzhupaas-message/yunzhupaas-message-entity/pom.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-message</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-message-entity</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-system-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>boot3</id>
|
||||
<activation>
|
||||
<jdk>[17,)</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>jakarta.mail</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>boot2</id>
|
||||
<activation>
|
||||
<jdk>(,17)</jdk>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* 账号配置表
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_account")
|
||||
public class AccountConfigEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
@TableField("f_category")
|
||||
private String type;
|
||||
|
||||
@TableField("f_full_name")
|
||||
private String fullName;
|
||||
|
||||
@TableField("f_en_code")
|
||||
private String enCode;
|
||||
|
||||
@TableField("f_addressor_name")
|
||||
private String addressorName;
|
||||
|
||||
// @TableField("F_SEND_EMAIL")
|
||||
//
|
||||
// private String sendEmail;
|
||||
|
||||
@TableField("f_smtp_server")
|
||||
private String smtpServer;
|
||||
|
||||
@TableField("f_smtp_port")
|
||||
private Integer smtpPort;
|
||||
|
||||
@TableField("f_ssl_link")
|
||||
private Integer sslLink;
|
||||
|
||||
@TableField("f_smtp_user")
|
||||
private String smtpUser;
|
||||
|
||||
@TableField("f_smtp_password")
|
||||
private String smtpPassword;
|
||||
|
||||
@TableField("f_channel")
|
||||
private Integer channel;
|
||||
|
||||
@TableField("f_sms_signature")
|
||||
private String smsSignature;
|
||||
|
||||
@TableField("f_app_id")
|
||||
private String appId;
|
||||
|
||||
@TableField("f_app_secret")
|
||||
private String appSecret;
|
||||
|
||||
@TableField("f_end_point")
|
||||
private String endPoint;
|
||||
|
||||
@TableField("f_sdk_app_id")
|
||||
private String sdkAppId;
|
||||
|
||||
@TableField("f_app_key")
|
||||
private String appKey;
|
||||
|
||||
@TableField("f_zone_name")
|
||||
private String zoneName;
|
||||
|
||||
@TableField("f_zone_param")
|
||||
private String zoneParam;
|
||||
|
||||
@TableField("f_enterprise_id")
|
||||
private String enterpriseId;
|
||||
|
||||
@TableField("f_agent_id")
|
||||
private String agentId;
|
||||
|
||||
@TableField("f_webhook_type")
|
||||
private Integer webhookType;
|
||||
|
||||
@TableField("f_webhook_address")
|
||||
private String webhookAddress;
|
||||
|
||||
@TableField("f_approve_type")
|
||||
private Integer approveType;
|
||||
|
||||
@TableField("f_bearer")
|
||||
private String bearer;
|
||||
|
||||
@TableField("f_user_name")
|
||||
private String userName;
|
||||
|
||||
@TableField("f_password")
|
||||
private String password;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 聊天内容
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_im_content")
|
||||
public class ImContentEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/**
|
||||
* 发送者
|
||||
*/
|
||||
@TableField("f_send_user_id")
|
||||
private String sendUserId;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@TableField("f_send_time")
|
||||
private Date sendTime;
|
||||
|
||||
/**
|
||||
* 接收者
|
||||
*/
|
||||
@TableField("f_receive_user_id")
|
||||
private String receiveUserId;
|
||||
|
||||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
@TableField("f_receive_time")
|
||||
private Date receiveTime;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@TableField("f_content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@TableField("f_content_type")
|
||||
private String contentType;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 聊天会话表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-28
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_im_reply")
|
||||
public class ImReplyEntity extends SuperExtendEntity<String> {
|
||||
|
||||
/**
|
||||
* 发送者
|
||||
*/
|
||||
@TableField("f_user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 接收者
|
||||
*/
|
||||
@TableField("f_receive_user_id")
|
||||
private String receiveUserId;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@TableField("f_receive_time")
|
||||
private Date receiveTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.yunzhupaas.base.entity.SuperBaseEntity;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 消息实例
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_notice")
|
||||
public class MessageEntity extends SuperBaseEntity.SuperCBaseEntity<String> {
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@TableField("f_title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 正文
|
||||
*/
|
||||
@TableField("f_body_text")
|
||||
private String bodyText;
|
||||
|
||||
/**
|
||||
* 收件用户
|
||||
*/
|
||||
@TableField("f_to_user_ids")
|
||||
private String toUserIds;
|
||||
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
@TableField("f_files")
|
||||
private String files;
|
||||
|
||||
/**
|
||||
* 封面图片
|
||||
*/
|
||||
@TableField("f_cover_image")
|
||||
private String coverImage;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
@TableField("f_expiration_time")
|
||||
private Date expirationTime;
|
||||
|
||||
/**
|
||||
* 分类 1-公告 2-通知
|
||||
*/
|
||||
@TableField("f_category")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 提醒方式 1-站内信 2-自定义 3-不通知
|
||||
*/
|
||||
@TableField("f_type")
|
||||
private Integer remindCategory;
|
||||
|
||||
/**
|
||||
* 发送配置
|
||||
*/
|
||||
@TableField("f_send_config_id")
|
||||
private String sendConfigId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField("f_description")
|
||||
private String excerpt;
|
||||
|
||||
/**
|
||||
* 有效标志 (-1-删除,0-草稿,1-已发送,2-已过期,)
|
||||
*/
|
||||
@TableField(value ="f_enabled_mark",fill = FieldFill.INSERT)
|
||||
private Integer enabledMark;
|
||||
|
||||
/**
|
||||
* 排序码
|
||||
*/
|
||||
@TableField("f_sort_code")
|
||||
private Long sortCode;
|
||||
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@TableField(value = "f_delete_mark" , updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer deleteMark;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableField(value = "f_delete_time" , fill = FieldFill.UPDATE)
|
||||
private Date deleteTime;
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
@TableField(value = "f_delete_user_id" , fill = FieldFill.UPDATE)
|
||||
private String deleteUserId;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(value = "f_last_modify_time" , updateStrategy = FieldStrategy.IGNORED)
|
||||
private Date lastModifyTime;
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@TableField(value = "f_last_modify_user_id" , updateStrategy = FieldStrategy.IGNORED)
|
||||
private String lastModifyUserId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
*
|
||||
* 消息监控表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-22
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_monitor")
|
||||
public class MessageMonitorEntity extends SuperExtendEntity<String> {
|
||||
|
||||
@TableField("f_account_id")
|
||||
private String accountId;
|
||||
|
||||
@TableField("f_account_name")
|
||||
private String accountName;
|
||||
|
||||
@TableField("f_account_code")
|
||||
private String accountCode;
|
||||
|
||||
@TableField("f_message_type")
|
||||
private String messageType;
|
||||
|
||||
@TableField("f_message_source")
|
||||
private String messageSource;
|
||||
|
||||
@TableField("f_send_time")
|
||||
private Date sendTime;
|
||||
|
||||
@TableField("f_message_template_id")
|
||||
private String messageTemplateId;
|
||||
|
||||
@TableField("f_title")
|
||||
private String title;
|
||||
|
||||
@TableField("f_receive_user")
|
||||
private String receiveUser;
|
||||
|
||||
@TableField("f_content")
|
||||
private String content;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 消息接收
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2023/09/27
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_message")
|
||||
public class MessageReceiveEntity extends SuperExtendEntity<String> {
|
||||
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@TableField("f_user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 是否阅读
|
||||
*/
|
||||
@TableField("f_is_read")
|
||||
private Integer isRead;
|
||||
|
||||
/**
|
||||
* 站内信息
|
||||
*/
|
||||
@TableField("f_body_text")
|
||||
private String bodyText;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@TableField("f_title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 类型(1-公告 2-流程 3-系统 4-日程)
|
||||
*/
|
||||
@TableField("f_type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 流程类型(1:审批 2:委托)
|
||||
*/
|
||||
@TableField("f_flow_type")
|
||||
private Integer flowType;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
*
|
||||
* 消息模板表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_template")
|
||||
public class MessageTemplateConfigEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
@TableField("f_full_name")
|
||||
private String fullName;
|
||||
|
||||
@TableField("f_en_code")
|
||||
private String enCode;
|
||||
|
||||
@TableField("f_template_type")
|
||||
private String templateType;
|
||||
|
||||
@TableField("f_message_source")
|
||||
private String messageSource;
|
||||
|
||||
@TableField("f_message_type")
|
||||
private String messageType;
|
||||
|
||||
@TableField("f_title")
|
||||
private String title;
|
||||
|
||||
@TableField("f_content")
|
||||
private String content;
|
||||
|
||||
@TableField("f_template_code")
|
||||
private String templateCode;
|
||||
|
||||
@TableField("f_wx_skip")
|
||||
private String wxSkip;
|
||||
|
||||
@TableField("f_xcx_app_id")
|
||||
private String xcxAppId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 企业微信的模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/5/25 14:18
|
||||
*/
|
||||
@Data
|
||||
public class QyWebChatModel {
|
||||
@Schema(description = "CorpId")
|
||||
private String qyhCorpId;
|
||||
@Schema(description = "AgentId")
|
||||
private String qyhAgentId;
|
||||
@Schema(description = "AgentSecret")
|
||||
private String qyhAgentSecret;
|
||||
@Schema(description = "CorpSecret")
|
||||
private String qyhCorpSecret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
*
|
||||
* 账号配置使用记录表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-09-21
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_message_send_record")
|
||||
public class SendConfigRecordEntity extends SuperEntity<String> {
|
||||
|
||||
@TableField("F_SENDCONFIGID")
|
||||
private String sendConfigId;
|
||||
|
||||
@TableField("F_MESSAGESOURCE")
|
||||
private String messageSource;
|
||||
|
||||
@TableField("F_USEDID")
|
||||
private String usedId;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@TableField("F_ENABLEDMARK")
|
||||
private Integer enabledMark;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* 发送配置模板表
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-19
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_send_template")
|
||||
public class SendConfigTemplateEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/** 发送配置id **/
|
||||
@TableField("f_send_config_id")
|
||||
private String sendConfigId;
|
||||
/** 消息类型 **/
|
||||
@TableField("f_message_type")
|
||||
private String messageType;
|
||||
/** 消息模板id **/
|
||||
@TableField("f_template_id")
|
||||
private String templateId;
|
||||
/** 账号配置id **/
|
||||
@TableField("f_account_config_id")
|
||||
private String accountConfigId;
|
||||
|
||||
/** 消息模板编号 **/
|
||||
@TableField(exist = false)
|
||||
private String templateCode;
|
||||
|
||||
/** 消息模板名称 **/
|
||||
@TableField(exist = false)
|
||||
private String templateName;
|
||||
|
||||
/** 账号编码 **/
|
||||
@TableField(exist = false)
|
||||
private String accountCode;
|
||||
|
||||
/** 账号名称 **/
|
||||
@TableField(exist = false)
|
||||
private String accountName;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* 消息发送配置表
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-19
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_send")
|
||||
public class SendMessageConfigEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
@TableField("f_full_name")
|
||||
private String fullName;
|
||||
|
||||
@TableField("f_en_code")
|
||||
private String enCode;
|
||||
|
||||
// @TableField("F_MESSAGETYPE")
|
||||
//
|
||||
// private String messageType;
|
||||
|
||||
@TableField("f_template_type")
|
||||
private String templateType;
|
||||
|
||||
@TableField("f_message_source")
|
||||
private String messageSource;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* 短信变量表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_short_link")
|
||||
public class ShortLinkEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/** 短链接 **/
|
||||
@TableField("f_short_link")
|
||||
private String shortLink;
|
||||
|
||||
/** PC端链接 **/
|
||||
@TableField("f_real_pc_link")
|
||||
private String realPcLink;
|
||||
|
||||
/** App端链接 **/
|
||||
@TableField("f_real_app_link")
|
||||
private String realAppLink;
|
||||
|
||||
/** 流程内容 **/
|
||||
@TableField("f_body_text")
|
||||
private String bodyText;
|
||||
|
||||
/** 是否点击后失效 **/
|
||||
@TableField("f_is_used")
|
||||
private Integer isUsed;
|
||||
|
||||
/** 点击次数 **/
|
||||
@TableField("f_click_num")
|
||||
private Integer clickNum;
|
||||
|
||||
/** 失效次数 **/
|
||||
@TableField("f_unable_num")
|
||||
private Integer unableNum;
|
||||
|
||||
/** 失效时间 **/
|
||||
@TableField("f_unable_time")
|
||||
private Date unableTime;
|
||||
|
||||
/** 用户id **/
|
||||
@TableField("f_user_id")
|
||||
private String userId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* 短信变量表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_sms_field")
|
||||
public class SmsFieldEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/** 模板 **/
|
||||
@TableField("F_TEMPLATE_ID")
|
||||
private String templateId;
|
||||
|
||||
/** 参数id **/
|
||||
@TableField("F_FIELD_ID")
|
||||
private String fieldId;
|
||||
|
||||
/** 短信变量 **/
|
||||
@TableField("F_SMS_FIELD")
|
||||
private String smsField;
|
||||
|
||||
/** 参数 **/
|
||||
@TableField("F_FIELD")
|
||||
private String field;
|
||||
|
||||
/** 是否标题 **/
|
||||
@TableField("F_IS_TITLE")
|
||||
private Integer isTitle;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 第三方工具的公司-部门-用户同步表模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/23 17:06
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_syn_third_info")
|
||||
public class SynThirdInfoEntity extends SuperExtendEntity.SuperExtendDEEntity<String> implements Serializable {
|
||||
|
||||
/**
|
||||
* 第三方类型(1:企业微信;2:钉钉)
|
||||
*/
|
||||
@TableField("F_THIRD_TYPE")
|
||||
private Integer thirdType;
|
||||
|
||||
/**
|
||||
* 数据类型(1:组织(公司与部门);2:用户)
|
||||
*/
|
||||
@TableField("F_DATA_TYPE")
|
||||
private Integer dataType;
|
||||
|
||||
/**
|
||||
* 系统对象ID(公司ID、部门ID、用户ID)
|
||||
*/
|
||||
@TableField("F_SYS_OBJ_ID")
|
||||
private String sysObjId;
|
||||
|
||||
/**
|
||||
* 第三对象ID(公司ID、部门ID、用户ID)
|
||||
*/
|
||||
@TableField("F_THIRD_OBJ_ID")
|
||||
private String thirdObjId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
/**
|
||||
*
|
||||
* 消息模板参数表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_template_param")
|
||||
public class TemplateParamEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/** 消息模板id **/
|
||||
@TableField("f_template_id")
|
||||
private String templateId;
|
||||
|
||||
/** 参数 **/
|
||||
@TableField("f_field")
|
||||
private String field;
|
||||
|
||||
/** 参数说明 **/
|
||||
@TableField("f_field_name")
|
||||
private String fieldName;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 短信变量表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_user_device")
|
||||
public class UserDeviceEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/** 用户id **/
|
||||
@TableField("F_USERID")
|
||||
private String userId;
|
||||
|
||||
/** 设备id **/
|
||||
@TableField("F_CLIENTID")
|
||||
private String clientId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.message.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* 短信变量表
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_msg_wechat_user")
|
||||
public class WechatUserEntity extends SuperExtendEntity.SuperExtendEnabledEntity<String> {
|
||||
|
||||
/** 公众号元素id **/
|
||||
@TableField("f_gzh_id")
|
||||
private String gzhId;
|
||||
|
||||
/** 用户id **/
|
||||
@TableField("f_user_id")
|
||||
private String userId;
|
||||
|
||||
/** 公众号用户id **/
|
||||
@TableField("f_open_id")
|
||||
private String openId;
|
||||
|
||||
/** 是否关注公众号 **/
|
||||
@TableField("f_close_mark")
|
||||
private Integer closeMark;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.yunzhupaas.message.enums;
|
||||
|
||||
/**
|
||||
* 消息类型枚举
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/23 17:45
|
||||
*/
|
||||
public enum MessageTypeEnum {
|
||||
/**
|
||||
* 站内消息
|
||||
*/
|
||||
SysMessage("1", "站内消息"),
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
MailMessage("2", "发送邮件"),
|
||||
/**
|
||||
* 发送短信
|
||||
*/
|
||||
SmsMessage("3", "发送短信"),
|
||||
/**
|
||||
* 钉钉消息
|
||||
*/
|
||||
DingMessage("4", "发送钉钉消息"),
|
||||
/**
|
||||
* 企业微信
|
||||
*/
|
||||
QyMessage("5", "发送企业微信消息"),
|
||||
/**
|
||||
* webhook
|
||||
*/
|
||||
WebHookMessage("6", "发送webhook消息"),
|
||||
/**
|
||||
* 微信公众号
|
||||
*/
|
||||
WechatMessage("7", "发送微信公众号消息");
|
||||
|
||||
/**
|
||||
* 为防止与系统后续更新的功能的消息类型code冲突,客户自定义添加的消息类型code请以ZDY开头。例如:ZDY1
|
||||
*/
|
||||
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
MessageTypeEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态code获取枚举值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static MessageTypeEnum getByCode(String code) {
|
||||
for (MessageTypeEnum status : MessageTypeEnum.values()) {
|
||||
if (status.getCode().equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-31
|
||||
*/
|
||||
@Data
|
||||
public class ImReplyListModel {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String headIcon;
|
||||
|
||||
/**
|
||||
* 最新消息
|
||||
*/
|
||||
private String latestMessage;
|
||||
|
||||
/**
|
||||
* 最新时间
|
||||
*/
|
||||
private Date latestDate;
|
||||
|
||||
/**
|
||||
* 未读消息
|
||||
*/
|
||||
private Integer unreadMessage;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* UserId
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* sendDeleteMark
|
||||
*/
|
||||
private String sendDeleteMark;
|
||||
|
||||
/**
|
||||
* imreplySendDeleteMark
|
||||
*/
|
||||
private String imreplySendDeleteMark;
|
||||
|
||||
/**
|
||||
* deleteMark
|
||||
*/
|
||||
private int deleteMark;
|
||||
|
||||
private String deleteUserId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 消息会话列表
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
@Data
|
||||
public class ImReplyListVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Schema(description = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Schema(description = "名称")
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
@Schema(description = "头像")
|
||||
private String headIcon;
|
||||
|
||||
/**
|
||||
* 最新消息
|
||||
*/
|
||||
@Schema(description = "最新消息")
|
||||
private String latestMessage;
|
||||
|
||||
/**
|
||||
* 最新时间
|
||||
*/
|
||||
@Schema(description = "最新时间")
|
||||
private Long latestDate;
|
||||
|
||||
/**
|
||||
* 未读消息
|
||||
*/
|
||||
@Schema(description = "未读消息")
|
||||
private Integer unreadMessage;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@Schema(description = "消息类型")
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* Account
|
||||
*/
|
||||
@Schema(description = "Account")
|
||||
private String account;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
@Data
|
||||
public class ImReplySavaModel {
|
||||
|
||||
private String userId;
|
||||
|
||||
private String receiveUserId;
|
||||
|
||||
private Date receiveTime;
|
||||
|
||||
public ImReplySavaModel(String userId, String receiveUserId, Date receiveTime) {
|
||||
this.userId = userId;
|
||||
this.receiveUserId = receiveUserId;
|
||||
this.receiveTime = receiveTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 未读消息模型
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024-09-26 上午9:18
|
||||
*/
|
||||
@Data
|
||||
public class ImUnreadNumModel {
|
||||
/**
|
||||
* 发送者Id
|
||||
*/
|
||||
private String sendUserId;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 未读数量
|
||||
*/
|
||||
private int unreadNum;
|
||||
|
||||
/**
|
||||
* 默认消息
|
||||
*/
|
||||
private String defaultMessage;
|
||||
|
||||
/**
|
||||
* 默认消息类型
|
||||
*/
|
||||
private String defaultMessageType;
|
||||
|
||||
/**
|
||||
* 默认消息时间
|
||||
*/
|
||||
private String defaultMessageTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class NoticeModel implements Serializable {
|
||||
private List<String> typeList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页模型
|
||||
*/
|
||||
@Data
|
||||
public class NoticePagination extends Pagination {
|
||||
@Schema(description = "类型")
|
||||
private List<String> type;
|
||||
@Schema(description = "状态")
|
||||
private List<Integer> enabledMark;
|
||||
@Schema(description = "创建人")
|
||||
private List<String> creatorUser;
|
||||
@Schema(description = "发布人")
|
||||
private List<String> releaseUser;
|
||||
@Schema(description = "发布时间")
|
||||
private List<Long> releaseTime;
|
||||
@Schema(description = "创建时间")
|
||||
private List<Long> creatorTime;
|
||||
@Schema(description = "过期时间")
|
||||
private List<Long> expirationTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/20 11:44
|
||||
*/
|
||||
@Data
|
||||
public class SentMessageForm {
|
||||
/**
|
||||
* 接收人员用户ID组
|
||||
*/
|
||||
private List<String> toUserIds;
|
||||
|
||||
/**
|
||||
* 消息模板Id
|
||||
*/
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private Map<String, Object> parameterMap;
|
||||
|
||||
/**
|
||||
* 是否发送站内信
|
||||
*/
|
||||
private boolean sysMessage;
|
||||
|
||||
/**
|
||||
* 站内信
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 流程信息
|
||||
*/
|
||||
private String flowName;
|
||||
|
||||
/**
|
||||
* 发起人
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 站内信
|
||||
*/
|
||||
private Map<String,String> contentMsg;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private UserInfo userInfo;
|
||||
|
||||
/**
|
||||
* 消息类别
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 流程类型(1:审批 2:委托)
|
||||
*/
|
||||
private Integer flowType = 1;
|
||||
|
||||
/**
|
||||
* 消息类别
|
||||
*/
|
||||
private String id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class UserOnlineModel {
|
||||
private String userId;
|
||||
private String userAccount;
|
||||
private String userName;
|
||||
private String loginTime;
|
||||
private String loginIPAddress;
|
||||
private String loginSystem;
|
||||
private String tenantId;
|
||||
private String token;
|
||||
private String device;
|
||||
private String organize;
|
||||
private String loginBrowser;
|
||||
private String loginAddress;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class UserOnlineVO {
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String loginTime;
|
||||
private String loginIPAddress;
|
||||
private String loginSystem;
|
||||
@Schema(description = "所属组织")
|
||||
private String organize;
|
||||
@Schema(description = "浏览器")
|
||||
private String loginBrowser;
|
||||
@Schema(description = "登录地址")
|
||||
private String loginAddress;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.message.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Data
|
||||
public class WxgzhMessageModel implements Serializable {
|
||||
//模板ID
|
||||
@JSONField(name = "template_id")
|
||||
private String templateId;
|
||||
//模板标题
|
||||
private String title;
|
||||
//模板所属行业的一级行业
|
||||
@JSONField(name = "primary_industry")
|
||||
private String primaryIndustry;
|
||||
//模板所属行业的二级行业
|
||||
@JSONField(name = "deputy_industry")
|
||||
private String deputyIndustry;
|
||||
//模板内容
|
||||
private String content;
|
||||
//模板示例
|
||||
private String example;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.yunzhupaas.message.model.accountconfig;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
public class AccountConfigForm {
|
||||
/** 主键 */
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
/** 名称 **/
|
||||
@Schema(description = "名称")
|
||||
@JsonProperty("fullName")
|
||||
private String fullName;
|
||||
|
||||
/** 配置类型 **/
|
||||
@Schema(description = "配置类型")
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
|
||||
/** 编码 **/
|
||||
@Schema(description = "编码")
|
||||
@JsonProperty("enCode")
|
||||
private String enCode;
|
||||
|
||||
/** 发件人昵称 **/
|
||||
@Schema(description = "发件人昵称")
|
||||
@JsonProperty("addressorName")
|
||||
private String addressorName;
|
||||
|
||||
// /** 发件人邮箱 **/
|
||||
// @JsonProperty("sendEmail")
|
||||
// private String sendEmail;
|
||||
|
||||
/** SMTP服务器 **/
|
||||
@Schema(description = "SMTP服务器")
|
||||
@JsonProperty("smtpServer")
|
||||
private String smtpServer;
|
||||
|
||||
/** SMTP端口 **/
|
||||
@Schema(description = "SMTP端口")
|
||||
@JsonProperty("smtpPort")
|
||||
private Integer smtpPort;
|
||||
|
||||
/** SSL安全链接 **/
|
||||
@Schema(description = "SSL安全链接")
|
||||
@JsonProperty("sslLink")
|
||||
private Integer sslLink;
|
||||
|
||||
/** SMTP用户名 **/
|
||||
@Schema(description = "SMTP用户名")
|
||||
@JsonProperty("smtpUser")
|
||||
private String smtpUser;
|
||||
|
||||
/** SMTP密码 **/
|
||||
@Schema(description = "SMTP密码")
|
||||
@JsonProperty("smtpPassword")
|
||||
private String smtpPassword;
|
||||
|
||||
/** 渠道 **/
|
||||
@Schema(description = "渠道")
|
||||
@JsonProperty("channel")
|
||||
private Integer channel;
|
||||
|
||||
/** 短信签名 **/
|
||||
@Schema(description = "短信签名")
|
||||
@JsonProperty("smsSignature")
|
||||
private String smsSignature;
|
||||
|
||||
/** 应用ID **/
|
||||
@Schema(description = "应用ID")
|
||||
@JsonProperty("appId")
|
||||
private String appId;
|
||||
|
||||
/** 应用Secret **/
|
||||
@Schema(description = "应用Secret")
|
||||
@JsonProperty("appSecret")
|
||||
private String appSecret;
|
||||
|
||||
/** EndPoint(阿里云) **/
|
||||
@Schema(description = "EndPoint(阿里云)")
|
||||
@JsonProperty("endPoint")
|
||||
private String endPoint;
|
||||
|
||||
/** SDK AppID(腾讯云) **/
|
||||
@Schema(description = "SDK AppID(腾讯云)")
|
||||
@JsonProperty("sdkAppId")
|
||||
private String sdkAppId;
|
||||
|
||||
/** AppKey(腾讯云) **/
|
||||
@Schema(description = "AppKey(腾讯云)")
|
||||
@JsonProperty("appKey")
|
||||
private String appKey;
|
||||
|
||||
/** 地域域名(腾讯云) **/
|
||||
@Schema(description = "地域域名(腾讯云)")
|
||||
@JsonProperty("zoneName")
|
||||
private String zoneName;
|
||||
|
||||
/** 地域参数(腾讯云) **/
|
||||
@Schema(description = "地域参数(腾讯云)")
|
||||
@JsonProperty("zoneParam")
|
||||
private String zoneParam;
|
||||
|
||||
/** 企业id **/
|
||||
@Schema(description = "企业id")
|
||||
@JsonProperty("enterpriseId")
|
||||
private String enterpriseId;
|
||||
|
||||
/** AgentID **/
|
||||
@Schema(description = "AgentID")
|
||||
@JsonProperty("agentId")
|
||||
private String agentId;
|
||||
|
||||
/** WebHook类型 **/
|
||||
@Schema(description = "WebHook类型")
|
||||
@JsonProperty("webhookType")
|
||||
private Integer webhookType;
|
||||
|
||||
/** WebHook地址 **/
|
||||
@Schema(description = "WebHook地址")
|
||||
@JsonProperty("webhookAddress")
|
||||
private String webhookAddress;
|
||||
|
||||
/** 认证类型 **/
|
||||
@Schema(description = "认证类型")
|
||||
@JsonProperty("approveType")
|
||||
private Integer approveType;
|
||||
|
||||
/** bearer令牌 **/
|
||||
@Schema(description = "bearer令牌")
|
||||
@JsonProperty("bearer")
|
||||
private String bearer;
|
||||
|
||||
/** 用户名(基本认证) **/
|
||||
@Schema(description = "用户名(基本认证)")
|
||||
@JsonProperty("userName")
|
||||
private String userName;
|
||||
|
||||
/** 密码(基本认证) **/
|
||||
@Schema(description = "密码(基本认证)")
|
||||
@JsonProperty("password")
|
||||
private String password;
|
||||
|
||||
/** 排序 **/
|
||||
@Schema(description = "排序")
|
||||
@JsonProperty("sortCode")
|
||||
private Integer sortCode;
|
||||
|
||||
/** 状态 **/
|
||||
@Schema(description = "状态")
|
||||
@JsonProperty("enabledMark")
|
||||
private Integer enabledMark;
|
||||
|
||||
/** 说明 **/
|
||||
@Schema(description = "说明")
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
|
||||
// /** 创建时间 **/
|
||||
// @JsonProperty("creatorTime")
|
||||
// private String creatorTime;
|
||||
//
|
||||
// /** 创建用户 **/
|
||||
// @JsonProperty("creatorUserId")
|
||||
// private String creatorUserId;
|
||||
//
|
||||
// /** 修改时间 **/
|
||||
// @JsonProperty("lastModifyTime")
|
||||
// private String lastModifyTime;
|
||||
//
|
||||
// /** 修改用户 **/
|
||||
// @JsonProperty("lastModifyUserId")
|
||||
// private String lastModifyUserId;
|
||||
|
||||
/**
|
||||
* 邮件内容
|
||||
*/
|
||||
@Schema(description = "邮件内容")
|
||||
private String testEmailContent;
|
||||
|
||||
/**
|
||||
* 收件人
|
||||
*/
|
||||
@Schema(description = "收件人")
|
||||
private List<String> testSendEmail;
|
||||
|
||||
/**
|
||||
* 邮箱标题
|
||||
*/
|
||||
@Schema(description = "邮箱标题")
|
||||
private String testEmailTitle;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.yunzhupaas.message.model.accountconfig;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
public class AccountConfigInfoVO{
|
||||
/** 主键 **/
|
||||
@Schema(description = "主键")
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
|
||||
/** 名称 **/
|
||||
@Schema(description = "名称")
|
||||
@JsonProperty("fullName")
|
||||
private String fullName;
|
||||
|
||||
/** 配置类型 **/
|
||||
@Schema(description = "配置类型")
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
|
||||
/** 编码 **/
|
||||
@Schema(description = "编码")
|
||||
@JsonProperty("enCode")
|
||||
private String enCode;
|
||||
|
||||
/** 发件人昵称 **/
|
||||
@Schema(description = "发件人昵称")
|
||||
@JsonProperty("addressorName")
|
||||
private String addressorName;
|
||||
|
||||
// /** 发件人邮箱 **/
|
||||
// @JsonProperty("sendEmail")
|
||||
// private String sendEmail;
|
||||
|
||||
/** SMTP服务器 **/
|
||||
@Schema(description = "SMTP服务器")
|
||||
@JsonProperty("smtpServer")
|
||||
private String smtpServer;
|
||||
|
||||
/** SMTP端口 **/
|
||||
@Schema(description = "SMTP端口")
|
||||
@JsonProperty("smtpPort")
|
||||
private Integer smtpPort;
|
||||
|
||||
/** SSL安全链接 **/
|
||||
@Schema(description = "SSL安全链接")
|
||||
@JsonProperty("sslLink")
|
||||
private Integer sslLink;
|
||||
|
||||
/** SMTP用户名 **/
|
||||
@Schema(description = "SMTP用户名")
|
||||
@JsonProperty("smtpUser")
|
||||
private String smtpUser;
|
||||
|
||||
/** SMTP密码 **/
|
||||
@Schema(description = "SMTP密码")
|
||||
@JsonProperty("smtpPassword")
|
||||
private String smtpPassword;
|
||||
|
||||
/** 渠道 **/
|
||||
@Schema(description = "渠道")
|
||||
@JsonProperty("channel")
|
||||
private Integer channel;
|
||||
|
||||
/** 短信签名 **/
|
||||
@Schema(description = "短信签名")
|
||||
@JsonProperty("smsSignature")
|
||||
private String smsSignature;
|
||||
|
||||
/** 应用ID **/
|
||||
@Schema(description = "应用ID")
|
||||
@JsonProperty("appId")
|
||||
private String appId;
|
||||
|
||||
/** 应用Secret **/
|
||||
@Schema(description = "应用Secret")
|
||||
@JsonProperty("appSecret")
|
||||
private String appSecret;
|
||||
|
||||
/** EndPoint(阿里云) **/
|
||||
@Schema(description = "EndPoint(阿里云)")
|
||||
@JsonProperty("endPoint")
|
||||
private String endpoint;
|
||||
|
||||
/** SDK AppID(腾讯云) **/
|
||||
@Schema(description = "SDK AppID(腾讯云)")
|
||||
@JsonProperty("sdkAppId")
|
||||
private String sdkAppId;
|
||||
|
||||
/** AppKey(腾讯云) **/
|
||||
@Schema(description = "AppKey(腾讯云)")
|
||||
@JsonProperty("appKey")
|
||||
private String appKey;
|
||||
|
||||
/** 地域域名(腾讯云) **/
|
||||
@Schema(description = "地域域名(腾讯云)")
|
||||
@JsonProperty("zoneName")
|
||||
private String zoneName;
|
||||
|
||||
/** 地域参数(腾讯云) **/
|
||||
@Schema(description = "地域参数(腾讯云)")
|
||||
@JsonProperty("zoneParam")
|
||||
private String zoneParam;
|
||||
|
||||
/** 企业id **/
|
||||
@Schema(description = "企业id")
|
||||
@JsonProperty("enterpriseId")
|
||||
private String enterpriseId;
|
||||
|
||||
/** AgentID **/
|
||||
@Schema(description = "AgentID")
|
||||
@JsonProperty("agentId")
|
||||
private String agentId;
|
||||
|
||||
/** WebHook类型 **/
|
||||
@Schema(description = "WebHook类型")
|
||||
@JsonProperty("webhookType")
|
||||
private String webhookType;
|
||||
|
||||
/** WebHook地址 **/
|
||||
@Schema(description = "WebHook地址")
|
||||
@JsonProperty("webhookAddress")
|
||||
private String webhookAddress;
|
||||
|
||||
/** 认证类型 **/
|
||||
@Schema(description = "认证类型")
|
||||
@JsonProperty("approveType")
|
||||
private String approveType;
|
||||
|
||||
/** bearer令牌 **/
|
||||
@Schema(description = "bearer令牌")
|
||||
@JsonProperty("bearer")
|
||||
private String bearer;
|
||||
|
||||
/** 用户名(基本认证) **/
|
||||
@Schema(description = "用户名(基本认证)")
|
||||
@JsonProperty("userName")
|
||||
private String userName;
|
||||
|
||||
/** 密码(基本认证) **/
|
||||
@Schema(description = "密码(基本认证)")
|
||||
@JsonProperty("password")
|
||||
private String password;
|
||||
|
||||
/** 排序 **/
|
||||
@Schema(description = "排序")
|
||||
@JsonProperty("sortCode")
|
||||
private Integer sortCode;
|
||||
|
||||
/** 状态 **/
|
||||
@Schema(description = "状态")
|
||||
@JsonProperty("enabledMark")
|
||||
private Integer enabledMark;
|
||||
|
||||
/** 说明 **/
|
||||
@Schema(description = "说明")
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.yunzhupaas.message.model.accountconfig;
|
||||
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
public class AccountConfigListVO{
|
||||
|
||||
@Schema(description = "id")
|
||||
private String id;
|
||||
|
||||
/** 名称 **/
|
||||
@Schema(description = "名称")
|
||||
@JSONField(name = "fullName")
|
||||
private String fullName;
|
||||
|
||||
/** 配置类型 **/
|
||||
@Schema(description = "配置类型")
|
||||
@JSONField(name = "type")
|
||||
private String type;
|
||||
|
||||
/** 编码 **/
|
||||
@Schema(description = "编码")
|
||||
@JSONField(name = "enCode")
|
||||
private String enCode;
|
||||
|
||||
/** 发件人昵称 **/
|
||||
@Schema(description = "发件人昵称")
|
||||
@JSONField(name = "addressorName")
|
||||
private String addressorName;
|
||||
|
||||
// /** 发件人邮箱 **/
|
||||
// @JSONField(name = "sendEmail")
|
||||
// private String sendEmail;
|
||||
|
||||
|
||||
/** SMTP用户名 **/
|
||||
@Schema(description = "SMTP用户名")
|
||||
@JSONField(name = "smtpUser")
|
||||
private String smtpUser;
|
||||
//
|
||||
// /** SMTP密码 **/
|
||||
// @JSONField(name = "smtpPassword")
|
||||
// private String smtpPassword;
|
||||
|
||||
/** 渠道 **/
|
||||
@Schema(description = "渠道")
|
||||
@JSONField(name = "channel")
|
||||
private String channel;
|
||||
|
||||
/** 短信签名 **/
|
||||
@Schema(description = "短信签名")
|
||||
@JSONField(name = "smsSignature")
|
||||
private String smsSignature;
|
||||
|
||||
|
||||
/** WebHook类型 **/
|
||||
@Schema(description = "WebHook类型")
|
||||
@JSONField(name = "webhookType")
|
||||
private String webhookType;
|
||||
|
||||
/** 排序 **/
|
||||
@Schema(description = "排序")
|
||||
@JSONField(name = "sortCode")
|
||||
private Integer sortCode;
|
||||
/** 状态 **/
|
||||
@Schema(description = "状态")
|
||||
@JSONField(name = "enabledMark")
|
||||
private String enabledMark;
|
||||
|
||||
|
||||
/** 创建时间 **/
|
||||
@Schema(description = "创建时间")
|
||||
@JSONField(name = "creatorTime")
|
||||
private Date creatorTime;
|
||||
|
||||
/** 创建用户 **/
|
||||
@Schema(description = "创建用户")
|
||||
@JSONField(name = "creatorUserId")
|
||||
private String creatorUserId;
|
||||
|
||||
/** 修改时间 **/
|
||||
@Schema(description = "修改时间")
|
||||
@JSONField(name = "lastModifyTime")
|
||||
private Date lastModifyTime;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creatorUser;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.yunzhupaas.message.model.accountconfig;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
public class AccountConfigPagination extends Pagination {
|
||||
|
||||
/**
|
||||
* selectKey
|
||||
*/
|
||||
@Schema(description = "selectKey")
|
||||
private String selectKey;
|
||||
|
||||
@Schema(description = "json")
|
||||
private String json;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型")
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 特别查询Json
|
||||
*/
|
||||
@Schema(description = "特别查询Json")
|
||||
private String superQueryJson;
|
||||
|
||||
/**
|
||||
* WebHook类型
|
||||
*/
|
||||
@Schema(description = "WebHook类型")
|
||||
private Integer webhookType;
|
||||
|
||||
/**
|
||||
* 渠道
|
||||
*/
|
||||
@Schema(description = "渠道")
|
||||
private Integer channel;
|
||||
|
||||
/**
|
||||
* 配置类型(2:邮箱,3:短信,4:钉钉,5:企业,6:飞书,7:webhook)
|
||||
*/
|
||||
@Schema(description = "配置类型(2:邮箱,3:短信,4:钉钉,5:企业,6:飞书,7:webhook)")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "状态")
|
||||
private String enabledMark;
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
**/
|
||||
@Schema(description = "关键字")
|
||||
private String keyword;
|
||||
|
||||
/**
|
||||
* 菜单id
|
||||
*/
|
||||
@Schema(description = "菜单id")
|
||||
private String menuId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 钉钉的部门模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/5/6 9:28
|
||||
*/
|
||||
@Data
|
||||
public class DingTalkDeptModel {
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableField("dept_id")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 上级部门(必填项)
|
||||
*/
|
||||
@TableField("parent_id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 部门名称(必填项)
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否隐藏本部门 false(默认值)
|
||||
*/
|
||||
@TableField("hide_dept")
|
||||
private Boolean hideDept;
|
||||
|
||||
/**
|
||||
* 指定可以查看本部门的其他部门列表,总数不能超过200
|
||||
* 当hide_dept为true时,则此值生效
|
||||
*/
|
||||
@TableField("dept_permits")
|
||||
private String deptPermits;
|
||||
|
||||
/**
|
||||
* 指定可以查看本部门的人员userid列表,总数不能超过200
|
||||
* 当hide_dept为true时,则此值生效
|
||||
*/
|
||||
@TableField("user_permits")
|
||||
private String userPermits;
|
||||
|
||||
/**
|
||||
* 是否限制本部门成员查看通讯录 false(默认值)
|
||||
*/
|
||||
@TableField("outer_dept")
|
||||
private Boolean outerDept;
|
||||
|
||||
/**
|
||||
* 本部门成员是否只能看到所在部门及下级部门通讯录:
|
||||
* true:只能看到所在部门及下级部门通讯录
|
||||
* false:不能查看所有通讯录,在通讯录中仅能看到自己
|
||||
* 当outer_dept为true时,此参数生效
|
||||
*/
|
||||
@TableField("outer_dept_only_self")
|
||||
private Boolean outerDeptOnlySelf;
|
||||
|
||||
/**
|
||||
* 指定本部门成员可查看的通讯录用户userid列表,总数不能超过200。
|
||||
* 当outer_dept为true时,此参数生效
|
||||
*/
|
||||
@TableField("outer_permit_users")
|
||||
private String outerPermitUsers;
|
||||
|
||||
/**
|
||||
* 指定本部门成员可查看的通讯录部门ID列表,总数不能超过200
|
||||
* 当outer_dept为true时,此参数生效
|
||||
*/
|
||||
@TableField("outer_permit_depts")
|
||||
private String outerPermitDepts;
|
||||
|
||||
/**
|
||||
* 是否创建一个关联此部门的企业群,默认为false即不创建
|
||||
*/
|
||||
@TableField("create_dept_group")
|
||||
private Boolean createDeptGroup;
|
||||
|
||||
/**
|
||||
* 在父部门中的排序值,order值小的排序靠前
|
||||
*/
|
||||
@TableField("order")
|
||||
private Long order;
|
||||
|
||||
/**
|
||||
* 部门标识字段,开发者可用该字段来唯一标识一个部门,并与钉钉外部通讯录里的部门做映射
|
||||
*/
|
||||
@TableField("source_identifier")
|
||||
private String sourceIdentifier;
|
||||
|
||||
/**
|
||||
* 扩展属性,Json格式
|
||||
*/
|
||||
@TableField("extension")
|
||||
private String extension;
|
||||
|
||||
/**
|
||||
* 当部门群已经创建后,有新人加入部门时是否会自动加入该群
|
||||
*/
|
||||
@TableField("auto_add_user")
|
||||
private Boolean autoAddUser;
|
||||
|
||||
/**
|
||||
* 部门的主管userid列表
|
||||
*/
|
||||
@TableField("dept_manager_userid_list")
|
||||
private String deptManagerUseridList;
|
||||
|
||||
/**
|
||||
* 部门群是否包含子部门(没什么用)
|
||||
*/
|
||||
@TableField("group_contain_sub_dept")
|
||||
private Boolean groupContainSubDept;
|
||||
|
||||
/**
|
||||
* 部门群是否包含外包部门(没什么用)
|
||||
*/
|
||||
@TableField("group_contain_outer_dept")
|
||||
private Boolean groupContainOuterDept;
|
||||
|
||||
/**
|
||||
* 部门群是否包含隐藏部门(没什么用)
|
||||
*/
|
||||
@TableField("group_contain_hidden_dept")
|
||||
private Boolean groupContainHiddenDept;
|
||||
|
||||
/**
|
||||
* 企业群群主的userid(没什么用)
|
||||
*/
|
||||
@TableField("org_dept_owner")
|
||||
private String orgDeptOwner;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 钉钉发送信息配置模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/22 14:12
|
||||
*/
|
||||
@Data
|
||||
public class DingTalkModel {
|
||||
@NotBlank(message = "应用凭证必填")
|
||||
private String dingSynAppKey;
|
||||
@NotBlank(message = "凭证密钥必填")
|
||||
private String dingSynAppSecret;
|
||||
private String dingAgentId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 钉钉的用户模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/5/6 9:29
|
||||
*/
|
||||
@Data
|
||||
public class DingTalkUserModel {
|
||||
/**
|
||||
* 员工唯一标识ID(不可修改),企业内必须唯一
|
||||
* 长度为1~64个字符,如果不传,将自动生成一个userid
|
||||
*/
|
||||
@TableField("userid")
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
*员工名称,长度最大80个字符 (必填项)
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号码,企业内必须唯一,不可重复
|
||||
* 如果是国际号码,请使用+xx-xxxxxx的格式
|
||||
*/
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 是否号码隐藏 通常不隐藏:false
|
||||
*/
|
||||
@TableField("hide_mobile")
|
||||
private Boolean hideMobile;
|
||||
|
||||
|
||||
/**
|
||||
* 分机号,长度最大50个字符
|
||||
* 企业内必须唯一,不可重复
|
||||
*/
|
||||
@TableField("telephone")
|
||||
private String telephone;
|
||||
|
||||
/**
|
||||
* 员工工号,长度最大为50个字符
|
||||
*/
|
||||
@TableField("job_number")
|
||||
private String jobNumber;
|
||||
|
||||
/**
|
||||
* 职位,长度最大为200个字符
|
||||
*/
|
||||
@TableField("title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 员工邮箱,长度最大50个字符。企业内必须唯一,不可重复
|
||||
*/
|
||||
@TableField("email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 员工的企业邮箱,长度最大100个字符
|
||||
* 员工的企业邮箱已开通,才能增加此字段,通常不用
|
||||
*/
|
||||
@TableField("org_email")
|
||||
private String orgEmail;
|
||||
|
||||
/**
|
||||
* 办公地点,长度最大100个字符
|
||||
*/
|
||||
@TableField("work_place")
|
||||
private String workPlace;
|
||||
|
||||
/**
|
||||
* 备注,长度最大2000个字符
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 所属部门id列表,如:"2,3,4"
|
||||
*/
|
||||
@TableField("dept_id_list")
|
||||
private String deptIdList;
|
||||
|
||||
/**
|
||||
* 员工在对应的部门中的排序 DeptOrder[]
|
||||
*/
|
||||
@TableField("dept_order_list")
|
||||
private String deptOrderList;
|
||||
|
||||
/**
|
||||
* 员工在对应的部门中的职位 DeptTitle[]
|
||||
*/
|
||||
@TableField("dept_title_list")
|
||||
private String deptTitleList;
|
||||
|
||||
|
||||
/**
|
||||
* 扩展属性,可以设置多种属性,最大长度2000个字符
|
||||
* 格式:{"爱好":"旅游","年龄":"24"}
|
||||
*/
|
||||
@TableField("extension")
|
||||
private String extension;
|
||||
|
||||
/**
|
||||
* 是否开启高管模式
|
||||
* true:开启
|
||||
* 开启后,手机号码对所有员工隐藏。普通员工无法对其发DING、发起钉钉免费商务电话。高管之间不受影响。
|
||||
* false:不开启
|
||||
*/
|
||||
@TableField("senior_mode")
|
||||
private Boolean seniorMode;
|
||||
|
||||
/**
|
||||
* 入职时间,Unix时间戳,单位毫秒
|
||||
*/
|
||||
@TableField("hired_date")
|
||||
private Long hiredDate;
|
||||
|
||||
/**
|
||||
* 登录邮箱
|
||||
*/
|
||||
@TableField("login_email")
|
||||
private String loginEmail;
|
||||
|
||||
/**
|
||||
* 是否专属帐号
|
||||
* 为true时,不能指定loginEmail或mobile
|
||||
*/
|
||||
@TableField("exclusive_account")
|
||||
private Boolean exclusiveAccount;
|
||||
|
||||
/**
|
||||
* 专属帐号类型:
|
||||
* sso:企业自建专属帐号
|
||||
* dingtalk:钉钉自建专属帐号
|
||||
*/
|
||||
@TableField("exclusive_account_type")
|
||||
private String exclusiveAccountType;
|
||||
|
||||
/**
|
||||
* 钉钉专属帐号登录名
|
||||
*/
|
||||
@TableField("login_id")
|
||||
private String loginId;
|
||||
|
||||
/**
|
||||
* 钉钉专属帐号初始密码
|
||||
*/
|
||||
@TableField("init_password")
|
||||
private String initPassword;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 发送邮件配置模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/20 14:27
|
||||
*/
|
||||
@Data
|
||||
public class EmailModel {
|
||||
private String emailPop3Host;
|
||||
private String emailPop3Port;
|
||||
private String emailSmtpHost;
|
||||
private String emailSmtpPort;
|
||||
private String emailSenderName;
|
||||
private String emailAccount;
|
||||
private String emailPassword;
|
||||
private String emailSsl;
|
||||
|
||||
private String emailToUsers;
|
||||
private String emailContent;
|
||||
private String emailTitle;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class MessageInfoVO {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
@Schema(description = "类型")
|
||||
private Integer type;
|
||||
@Schema(description = "修改时间")
|
||||
private long lastModifyTime;
|
||||
@Schema(description = "创建用户")
|
||||
private String creatorUser;
|
||||
@Schema(description = "是否已读")
|
||||
private Integer isRead;
|
||||
|
||||
@Schema(description = "有效标志")
|
||||
private Integer enabledMark;
|
||||
|
||||
/**
|
||||
* 发布人员
|
||||
*/
|
||||
@Schema(description = "发布人员")
|
||||
private String releaseUser;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@Schema(description = "发布时间")
|
||||
private Long releaseTime;
|
||||
|
||||
@Schema(description = "修改用户")
|
||||
private String lastModifyUserId;
|
||||
@Schema(description = "流程类型")
|
||||
private Integer flowType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class MessageNoticeVO {
|
||||
@Schema(description = "id")
|
||||
private String id;
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "创建人员")
|
||||
private String creatorUser;
|
||||
|
||||
@Schema(description = "发布时间",example = "1")
|
||||
private Long lastModifyTime;
|
||||
|
||||
@Schema(description = "状态(0-存草稿,1-已发布,2-已过期)",example = "1")
|
||||
private Integer enabledMark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Long creatorTime;
|
||||
|
||||
/**
|
||||
* 发布人员
|
||||
*/
|
||||
@Schema(description = "发布人员")
|
||||
private String releaseUser;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@Schema(description = "发布时间")
|
||||
private Long releaseTime;
|
||||
|
||||
@Schema(description = "修改用户")
|
||||
private String lastModifyUserId;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private Long expirationTime;
|
||||
|
||||
@Schema(description = "摘要")
|
||||
private String excerpt;
|
||||
|
||||
/**
|
||||
* 分类 1-公告 2-通知
|
||||
*/
|
||||
@Schema(description = "分类")
|
||||
private String category;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class MessageRecordForm {
|
||||
@Schema(description = "id集合")
|
||||
private String ids;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class NoticeCrForm {
|
||||
@Schema(description = "内容")
|
||||
private String bodyText;
|
||||
@NotBlank(message = "必填")
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
@Schema(description = "接收人")
|
||||
private String toUserIds;
|
||||
@Schema(description = "附件")
|
||||
private String files;
|
||||
|
||||
@Schema(description = "封面图片")
|
||||
private String coverImage;
|
||||
@Schema(description = "过期时间")
|
||||
private Long expirationTime;
|
||||
@Schema(description = "分类")
|
||||
private String category;
|
||||
@Schema(description = "提醒方式")
|
||||
private Integer remindCategory;
|
||||
@Schema(description = "发送配置")
|
||||
private String sendConfigId;
|
||||
|
||||
@Schema(description = "摘要")
|
||||
private String excerpt;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class NoticeInfoVO {
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
@Schema(description = "内容")
|
||||
private String bodyText;
|
||||
@Schema(description = "创建用户")
|
||||
private String creatorUser;
|
||||
@Schema(description = "修改时间")
|
||||
private Long lastModifyTime;
|
||||
@Schema(description = "接收人id集合")
|
||||
private String toUserIds;
|
||||
|
||||
@Schema(description = "文件")
|
||||
private String files;
|
||||
|
||||
/**
|
||||
* 发布人员
|
||||
*/
|
||||
@Schema(description = "发布人员")
|
||||
private String releaseUser;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@Schema(description = "发布时间")
|
||||
private Long releaseTime;
|
||||
|
||||
@Schema(description = "封面图片")
|
||||
private String coverImage;
|
||||
@Schema(description = "过期时间")
|
||||
private Long expirationTime;
|
||||
@Schema(description = "分类")
|
||||
private String category;
|
||||
@Schema(description = "提醒方式")
|
||||
private Integer remindCategory;
|
||||
@Schema(description = "发送配置")
|
||||
private String sendConfigId;
|
||||
|
||||
@Schema(description = "摘要")
|
||||
private String excerpt;
|
||||
|
||||
/**
|
||||
* 流程类型(1:审批 2:委托)
|
||||
*/
|
||||
private Integer flowType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class NoticeUpForm extends NoticeCrForm {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NoticeVO {
|
||||
private String id;
|
||||
@JSONField(name="title")
|
||||
private String fullName;
|
||||
private Long creatorTime;
|
||||
@Schema(description = "创建用户")
|
||||
private String creatorUser;
|
||||
|
||||
/**
|
||||
* 发布人员
|
||||
*/
|
||||
@Schema(description = "发布人员")
|
||||
private String releaseUser;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@Schema(description = "发布时间")
|
||||
private Long releaseTime;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@Schema(description ="分类")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "封面图片")
|
||||
private String coverImage;
|
||||
|
||||
@Schema(description = "摘要")
|
||||
private String excerpt;
|
||||
|
||||
@JsonIgnore
|
||||
@Schema(description = "修改时间")
|
||||
private Long lastModifyTime;
|
||||
|
||||
@JsonIgnore
|
||||
@Schema(description = "修改用户")
|
||||
private String lastModifyUserId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OraganizeListVO {
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
@Schema(description = "父主键")
|
||||
private String parentId;
|
||||
@Schema(description = "名称")
|
||||
private String fullName;
|
||||
@Schema(description = "编码")
|
||||
private String enCode;
|
||||
@Schema(description = "备注")
|
||||
private String description;
|
||||
@Schema(description = "状态")
|
||||
private int enabledMark;
|
||||
private Long creatorTime;
|
||||
@Schema(description = "是否有下级菜单")
|
||||
private boolean hasChildren = true;
|
||||
@Schema(description = "下级菜单列表")
|
||||
private List<OraganizeListVO> children = new ArrayList<>();
|
||||
@Schema(description = "排序")
|
||||
private Long sortCode;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/12 15:31
|
||||
*/
|
||||
@Data
|
||||
public class PaginationMessage extends Pagination {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
@Schema(description = "是否已读")
|
||||
private Integer isRead;
|
||||
|
||||
|
||||
/**
|
||||
* 所属用户
|
||||
*/
|
||||
@Schema(description = "所属用户")
|
||||
private String userId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 企业微信获取部门的对象模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/25 11:10
|
||||
*/
|
||||
@Data
|
||||
public class QyWebChatDeptModel {
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 部门中文名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 部门英文名称
|
||||
*/
|
||||
private String name_en;
|
||||
/**
|
||||
* 部门的上级部门
|
||||
*/
|
||||
private Integer parentid;
|
||||
/**
|
||||
* 部门排序
|
||||
*/
|
||||
private Integer order;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业微信获取成员的对象模型
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/25 16:29
|
||||
*/
|
||||
@Data
|
||||
public class QyWebChatUserModel {
|
||||
/**
|
||||
* 执行返回执行代码
|
||||
*/
|
||||
private String errcode;
|
||||
/**
|
||||
* 执行返回执行消息
|
||||
*/
|
||||
private String errmsg;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userid;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 成员别名
|
||||
*/
|
||||
private String alias;
|
||||
/**
|
||||
* 手机号码。企业内必须唯一,mobile/email二者不能同时为空
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 成员所属部门id列表,不超过100个
|
||||
*/
|
||||
private List<Long> department;
|
||||
/**
|
||||
* 部门内的排序值,默认为0,成员次序以创建时间从小到大排列
|
||||
* 个数必须和参数department的个数一致,数值越大排序越前面
|
||||
*/
|
||||
private String order;
|
||||
/**
|
||||
* 职务信息
|
||||
*/
|
||||
private String position;
|
||||
/**
|
||||
* 性别。1表示男性,2表示女性
|
||||
*/
|
||||
private String gender;
|
||||
/**
|
||||
* 邮箱。长度6~64个字节,且为有效的email格式。
|
||||
* 企业内必须唯一,mobile/email二者不能同时为空
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 座机。32字节以内,由纯数字或’-‘号组成。
|
||||
*/
|
||||
private String telephone;
|
||||
/**
|
||||
* 个数必须和参数department的个数一致,表示在所在的部门内是否为上级。1表示为上级,0表示非上级。
|
||||
* 在审批等应用里可以用来标识上级审批人
|
||||
*/
|
||||
private String is_leader_in_dept;
|
||||
/**
|
||||
* 成员头像的mediaid,通过素材管理接口上传图片获得的mediaid
|
||||
*/
|
||||
private String avatar_mediaid;
|
||||
/**
|
||||
* 启用/禁用成员。1表示启用成员,0表示禁用成员
|
||||
*/
|
||||
private String enable;
|
||||
/**
|
||||
* 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业。
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 自定义字段
|
||||
*/
|
||||
private String extattr;
|
||||
/**
|
||||
* 是否邀请该成员使用企业微信(将通过微信服务通知或短信或邮件下发邀请,每天自动下发一次,最多持续3个工作日),默认值为true。
|
||||
*/
|
||||
private boolean to_invite;
|
||||
/**
|
||||
* 成员对外属性
|
||||
*/
|
||||
private String external_profile;
|
||||
/**
|
||||
* 对外职务,如果设置了该值,则以此作为对外展示的职务,否则以position来展示。
|
||||
* 长度12个汉字内
|
||||
*/
|
||||
private String external_position;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 主部门
|
||||
*/
|
||||
private String main_department;
|
||||
|
||||
/**
|
||||
* 部门列表
|
||||
*/
|
||||
private LinkedList<Long> deptIdList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 第三方工具的对象同步表
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/25 9:35
|
||||
*/
|
||||
@Data
|
||||
public class SynThirdInfoCrForm {
|
||||
|
||||
/**
|
||||
* 第三方类型(1:企业微信;2:钉钉)
|
||||
*/
|
||||
@Schema(description = "第三方类型(1:企业微信;2:钉钉)")
|
||||
private Integer thirdtype;
|
||||
|
||||
/**
|
||||
* 数据类型(1:公司;2:部门;3:用户)
|
||||
*/
|
||||
@Schema(description = "数据类型(1:公司;2:部门;3:用户)")
|
||||
private Integer datatype;
|
||||
|
||||
/**
|
||||
* 本地对象ID(公司ID、部门ID、用户ID)
|
||||
*/
|
||||
@Schema(description = "本地对象ID(公司ID、部门ID、用户ID)")
|
||||
private String sysObjId;
|
||||
|
||||
/**
|
||||
* 第三方对象ID(公司ID、部门ID、用户ID)
|
||||
*/
|
||||
@Schema(description = "第三方对象ID(公司ID、部门ID、用户ID)")
|
||||
private String thirdObjId;
|
||||
|
||||
/**
|
||||
* 同步状态(0:未同步;1:同步成功;2:同步失败)
|
||||
*/
|
||||
@Schema(description = "同步状态(0:未同步;1:同步成功;2:同步失败)")
|
||||
private Integer synstate;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
// /**
|
||||
// * 创建时间
|
||||
// */
|
||||
// @TableField(value = "F_CREATORTIME",fill = FieldFill.INSERT)
|
||||
// private Date creatorTime;
|
||||
//
|
||||
// /**
|
||||
// * 创建用户
|
||||
// */
|
||||
// @TableField(value = "F_CREATORUSERID",fill = FieldFill.INSERT)
|
||||
// private String creatorUserId;
|
||||
//
|
||||
// /**
|
||||
// * 修改用户
|
||||
// */
|
||||
// @TableField(value = "F_LASTMODIFYUSERID",fill = FieldFill.UPDATE)
|
||||
// private String lastModifyUserId;
|
||||
//
|
||||
// /**
|
||||
// * 修改时间
|
||||
// */
|
||||
// @TableField(value = "F_LASTMODIFYTIME",fill = FieldFill.UPDATE)
|
||||
// @JSONField(name = "F_LastModifyTime")
|
||||
// private Date lastModifyTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.message.model.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 第三方工具的对象同步表
|
||||
*
|
||||
* @版本: V3.1.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2021/4/25 9:35
|
||||
*/
|
||||
@Data
|
||||
public class SynThirdInfoUpForm extends SynThirdInfoCrForm{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.yunzhupaas.message.model.messagedatatype;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @版本: V3.2.0
|
||||
* @版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @作者: 云筑产品开发平台组
|
||||
* @日期: 2022-08-18
|
||||
*/
|
||||
@Data
|
||||
public class MessageDataTypeForm {
|
||||
/** 主键 */
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
/** 数据类型 **/
|
||||
@Schema(description = "数据类型")
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
|
||||
/** 数据名称 **/
|
||||
@Schema(description = "数据名称")
|
||||
@JsonProperty("fullName")
|
||||
private String fullName;
|
||||
|
||||
/** 数据编码(为防止与系统后续更新的功能的数据编码冲突,客户自定义添加的功能编码请以ZDY开头。例如:ZDY1) **/
|
||||
@Schema(description = "数据编码")
|
||||
@JsonProperty("enCode")
|
||||
private String enCode;
|
||||
|
||||
/** 创建时间 **/
|
||||
@Schema(description = "创建时间")
|
||||
@JsonProperty("creatorTime")
|
||||
private String creatorTime;
|
||||
|
||||
/** 创建人员 **/
|
||||
@Schema(description = "创建人员")
|
||||
@JsonProperty("creatorUserId")
|
||||
private String creatorUserId;
|
||||
|
||||
/** 修改时间 **/
|
||||
@Schema(description = "修改时间")
|
||||
@JsonProperty("lastModifyTime")
|
||||
private String lastModifyTime;
|
||||
|
||||
/** 修改人员 **/
|
||||
@Schema(description = "修改人员")
|
||||
@JsonProperty("lastModifyUserId")
|
||||
private String lastModifyUserId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user