消息组件-邮件
This commit is contained in:
parent
a33cb19f4b
commit
ee51fca98c
|
@ -3,7 +3,7 @@ plugins {
|
|||
id 'org.springframework.boot'
|
||||
}
|
||||
|
||||
group 'com-commons-excel'
|
||||
group 'com-component-excel'
|
||||
version '2.0-SNAPSHOT'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
@ -17,7 +17,7 @@ mybatisStarterVersion = "2.0.1"
|
|||
mybatisPlusVersion = "3.1.1"
|
||||
}
|
||||
dependencies {
|
||||
compile project(":dibo-commons-file")
|
||||
compile project(":diboot-component-file")
|
||||
compile project(":diboot-core")
|
||||
|
||||
//easyexcel
|
|
@ -1,22 +1,22 @@
|
|||
package com.diboot.excel.controller;
|
||||
package com.diboot.component.excel.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.diboot.commons.entity.BaseFile;
|
||||
import com.diboot.commons.file.FileHelper;
|
||||
import com.diboot.commons.service.BaseFileService;
|
||||
import com.diboot.commons.utils.S;
|
||||
import com.diboot.commons.utils.V;
|
||||
import com.diboot.commons.vo.JsonResult;
|
||||
import com.diboot.commons.vo.Pagination;
|
||||
import com.diboot.commons.vo.Status;
|
||||
import com.diboot.component.file.entity.BaseFile;
|
||||
import com.diboot.component.file.file.FileHelper;
|
||||
import com.diboot.component.file.service.BaseFileService;
|
||||
import com.diboot.component.file.utils.S;
|
||||
import com.diboot.component.file.utils.V;
|
||||
import com.diboot.component.file.vo.JsonResult;
|
||||
import com.diboot.component.file.vo.Pagination;
|
||||
import com.diboot.component.file.vo.Status;
|
||||
import com.diboot.core.entity.BaseEntity;
|
||||
import com.diboot.core.service.BaseService;
|
||||
import com.diboot.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.excel.entity.ExcelColumn;
|
||||
import com.diboot.excel.listener.BaseExcelDataListener;
|
||||
import com.diboot.excel.service.ExcelColumnService;
|
||||
import com.diboot.excel.service.ExcelImportRecordService;
|
||||
import com.diboot.excel.utils.EasyExcelHelper;
|
||||
import com.diboot.component.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.component.excel.entity.ExcelColumn;
|
||||
import com.diboot.component.excel.listener.BaseExcelDataListener;
|
||||
import com.diboot.component.excel.service.ExcelColumnService;
|
||||
import com.diboot.component.excel.service.ExcelImportRecordService;
|
||||
import com.diboot.component.excel.utils.EasyExcelHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -75,7 +75,7 @@ public abstract class BaseExcelImportController <T extends BaseExcelDataEntity>
|
|||
*/
|
||||
protected abstract BaseExcelDataListener getExcelDataListener();
|
||||
|
||||
protected com.diboot.commons.service.BaseService getService() {
|
||||
protected com.diboot.component.file.service.BaseService getService() {
|
||||
return baseFileService;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public abstract class BaseExcelImportController <T extends BaseExcelDataEntity>
|
|||
// 查询当前页的数据
|
||||
List entityList = getService().getEntityList(queryWrapper, pagination);
|
||||
// 返回结果
|
||||
return new JsonResult(com.diboot.commons.vo.Status.OK, entityList).bindPagination(pagination);
|
||||
return new JsonResult(com.diboot.component.file.vo.Status.OK, entityList).bindPagination(pagination);
|
||||
}
|
||||
|
||||
/***
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.converter;
|
||||
package com.diboot.component.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.converter;
|
||||
package com.diboot.component.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.converter;
|
||||
package com.diboot.component.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.converter;
|
||||
package com.diboot.component.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.converter;
|
||||
package com.diboot.component.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.entity;
|
||||
package com.diboot.component.excel.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.entity;
|
||||
package com.diboot.component.excel.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.diboot.core.entity.BaseEntity;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.entity;
|
||||
package com.diboot.component.excel.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.diboot.core.entity.BaseEntity;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.excel.listener;
|
||||
package com.diboot.component.excel.listener;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
|
@ -9,9 +9,9 @@ import com.diboot.core.service.BaseService;
|
|||
import com.diboot.core.util.BeanUtils;
|
||||
import com.diboot.core.util.JSON;
|
||||
import com.diboot.core.util.V;
|
||||
import com.diboot.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.excel.entity.ExcelColumn;
|
||||
import com.diboot.excel.service.ExcelColumnService;
|
||||
import com.diboot.component.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.component.excel.entity.ExcelColumn;
|
||||
import com.diboot.component.excel.service.ExcelColumnService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -1,7 +1,7 @@
|
|||
package com.diboot.excel.mapper;
|
||||
package com.diboot.component.excel.mapper;
|
||||
|
||||
import com.diboot.core.mapper.BaseCrudMapper;
|
||||
import com.diboot.excel.entity.ExcelColumn;
|
||||
import com.diboot.component.excel.entity.ExcelColumn;
|
||||
|
||||
/**
|
||||
* @author Lishuaifei
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"./mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.diboot.excel.mapper.ExcelColumnMapper">
|
||||
<mapper namespace="com.diboot.component.excel.mapper.ExcelColumnMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,7 +1,7 @@
|
|||
package com.diboot.excel.mapper;
|
||||
package com.diboot.component.excel.mapper;
|
||||
|
||||
import com.diboot.core.mapper.BaseCrudMapper;
|
||||
import com.diboot.excel.entity.ExcelImportRecord;
|
||||
import com.diboot.component.excel.entity.ExcelImportRecord;
|
||||
|
||||
/**
|
||||
* @author Lishuaifei
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"./mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.diboot.excel.mapper.ExcelImportRecordMapper">
|
||||
<mapper namespace="com.diboot.component.excel.mapper.ExcelImportRecordMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,7 +1,7 @@
|
|||
package com.diboot.excel.service;
|
||||
package com.diboot.component.excel.service;
|
||||
|
||||
import com.diboot.core.service.BaseService;
|
||||
import com.diboot.excel.entity.ExcelColumn;
|
||||
import com.diboot.component.excel.entity.ExcelColumn;
|
||||
|
||||
/**
|
||||
* @author Lishuaifei
|
|
@ -1,8 +1,8 @@
|
|||
package com.diboot.excel.service;
|
||||
package com.diboot.component.excel.service;
|
||||
|
||||
import com.diboot.core.entity.BaseEntity;
|
||||
import com.diboot.core.service.BaseService;
|
||||
import com.diboot.excel.entity.ExcelImportRecord;
|
||||
import com.diboot.component.excel.entity.ExcelImportRecord;
|
||||
|
||||
|
||||
import java.util.List;
|
|
@ -1,9 +1,9 @@
|
|||
package com.diboot.excel.service.impl;
|
||||
package com.diboot.component.excel.service.impl;
|
||||
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import com.diboot.excel.entity.ExcelColumn;
|
||||
import com.diboot.excel.mapper.ExcelColumnMapper;
|
||||
import com.diboot.excel.service.ExcelColumnService;
|
||||
import com.diboot.component.excel.entity.ExcelColumn;
|
||||
import com.diboot.component.excel.mapper.ExcelColumnMapper;
|
||||
import com.diboot.component.excel.service.ExcelColumnService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
|
@ -1,11 +1,11 @@
|
|||
package com.diboot.excel.service.impl;
|
||||
package com.diboot.component.excel.service.impl;
|
||||
|
||||
import com.diboot.core.entity.BaseEntity;
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import com.diboot.excel.entity.ExcelImportRecord;
|
||||
import com.diboot.excel.mapper.ExcelImportRecordMapper;
|
||||
import com.diboot.excel.service.ExcelImportRecordService;
|
||||
import com.diboot.commons.utils.V;
|
||||
import com.diboot.component.excel.entity.ExcelImportRecord;
|
||||
import com.diboot.component.excel.mapper.ExcelImportRecordMapper;
|
||||
import com.diboot.component.excel.service.ExcelImportRecordService;
|
||||
import com.diboot.component.file.utils.V;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
|
@ -1,9 +1,9 @@
|
|||
package com.diboot.excel.utils;
|
||||
package com.diboot.component.excel.utils;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.diboot.core.util.V;
|
||||
import com.diboot.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.excel.listener.BaseExcelDataListener;
|
||||
import com.diboot.component.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.component.excel.listener.BaseExcelDataListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -28,7 +28,7 @@ dependencies {
|
|||
compile("org.apache.httpcomponents:httpclient:4.5.9")
|
||||
// apache commons
|
||||
compile("commons-fileupload:commons-fileupload:1.3.3",
|
||||
"org.apache.commons:commons-lang3:3.6",
|
||||
"org.apache.commons:commons-lang3:3.8.1",
|
||||
"commons-io:commons-io:2.6")
|
||||
|
||||
// 引入validator jar
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.commons.config;
|
||||
package com.diboot.component.file.config;
|
||||
|
||||
import com.diboot.commons.utils.PropertiesUtils;
|
||||
import com.diboot.component.file.utils.PropertiesUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.config;
|
||||
package com.diboot.component.file.config;
|
||||
|
||||
public class BaseCons {
|
||||
|
|
@ -1,18 +1,16 @@
|
|||
package com.diboot.commons.entity;
|
||||
package com.diboot.component.file.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.diboot.commons.utils.JSON;
|
||||
import com.diboot.commons.utils.V;
|
||||
import com.diboot.component.file.utils.JSON;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.entity;
|
||||
package com.diboot.component.file.entity;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.diboot.commons.file;
|
||||
package com.diboot.component.file.file;
|
||||
|
||||
import com.diboot.commons.file.http.CustomSSLSocketFactory;
|
||||
import com.diboot.commons.utils.PropertiesUtils;
|
||||
import com.diboot.commons.utils.S;
|
||||
import com.diboot.component.file.file.http.CustomSSLSocketFactory;
|
||||
import com.diboot.component.file.utils.PropertiesUtils;
|
||||
import com.diboot.component.file.utils.S;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.io.FileUtils;
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.commons.file.audio;
|
||||
package com.diboot.component.file.file.audio;
|
||||
|
||||
import com.diboot.commons.utils.RuntimeHelper;
|
||||
import com.diboot.component.file.utils.RuntimeHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.file.http;
|
||||
package com.diboot.component.file.file.http;
|
||||
|
||||
import org.apache.http.HttpVersion;
|
||||
import org.apache.http.client.HttpClient;
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.commons.file.image;
|
||||
package com.diboot.component.file.file.image;
|
||||
|
||||
import com.diboot.commons.utils.Base64;
|
||||
import com.diboot.component.file.utils.Base64;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import net.coobird.thumbnailator.geometry.Positions;
|
||||
import org.apache.commons.io.FileUtils;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.file.zip;
|
||||
package com.diboot.component.file.file.zip;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
|
@ -1,9 +1,9 @@
|
|||
package com.diboot.commons.mapper;
|
||||
package com.diboot.component.file.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.diboot.commons.entity.BaseFile;
|
||||
import com.diboot.component.file.entity.BaseFile;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"./mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.diboot.commons.mapper.BaseFileMapper">
|
||||
<mapper namespace="com.diboot.component.file.mapper.BaseFileMapper">
|
||||
|
||||
<sql id="setValues">
|
||||
<set>
|
|
@ -1,10 +1,7 @@
|
|||
package com.diboot.commons.service;
|
||||
package com.diboot.component.file.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.diboot.commons.entity.BaseFile;
|
||||
import com.diboot.component.file.entity.BaseFile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
|
@ -1,8 +1,8 @@
|
|||
package com.diboot.commons.service;
|
||||
package com.diboot.component.file.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.diboot.commons.vo.KeyValue;
|
||||
import com.diboot.commons.vo.Pagination;
|
||||
import com.diboot.component.file.vo.KeyValue;
|
||||
import com.diboot.component.file.vo.Pagination;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
|
@ -1,9 +1,9 @@
|
|||
package com.diboot.commons.service.impl;
|
||||
package com.diboot.component.file.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.diboot.commons.entity.BaseFile;
|
||||
import com.diboot.commons.mapper.BaseFileMapper;
|
||||
import com.diboot.commons.service.BaseFileService;
|
||||
import com.diboot.component.file.entity.BaseFile;
|
||||
import com.diboot.component.file.mapper.BaseFileMapper;
|
||||
import com.diboot.component.file.service.BaseFileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.service.impl;
|
||||
package com.diboot.component.file.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
@ -7,13 +7,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.diboot.commons.config.BaseConfig;
|
||||
import com.diboot.commons.config.BaseCons;
|
||||
import com.diboot.commons.service.BaseService;
|
||||
import com.diboot.commons.utils.S;
|
||||
import com.diboot.commons.utils.V;
|
||||
import com.diboot.commons.vo.KeyValue;
|
||||
import com.diboot.commons.vo.Pagination;
|
||||
import com.diboot.component.file.config.BaseConfig;
|
||||
import com.diboot.component.file.config.BaseCons;
|
||||
import com.diboot.component.file.service.BaseService;
|
||||
import com.diboot.component.file.utils.S;
|
||||
import com.diboot.component.file.utils.V;
|
||||
import com.diboot.component.file.vo.KeyValue;
|
||||
import com.diboot.component.file.vo.Pagination;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import com.diboot.commons.config.BaseCons;
|
||||
import com.diboot.commons.entity.BaseEntity;
|
||||
import com.diboot.component.file.config.BaseCons;
|
||||
import com.diboot.component.file.entity.BaseEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanWrapper;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import com.diboot.commons.config.BaseConfig;
|
||||
import com.diboot.component.file.config.BaseConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,12 +1,9 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import com.diboot.commons.config.BaseConfig;
|
||||
import com.diboot.commons.config.BaseCons;
|
||||
import com.diboot.component.file.config.BaseConfig;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
/***
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.utils;
|
||||
package com.diboot.component.file.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.commons.vo;
|
||||
package com.diboot.component.file.vo;
|
||||
|
||||
import com.diboot.commons.utils.V;
|
||||
import com.diboot.component.file.utils.V;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.vo;
|
||||
package com.diboot.component.file.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.diboot.commons.vo;
|
||||
package com.diboot.component.file.vo;
|
||||
|
||||
import com.diboot.commons.config.BaseConfig;
|
||||
import com.diboot.commons.config.BaseCons;
|
||||
import com.diboot.commons.utils.S;
|
||||
import com.diboot.commons.utils.V;
|
||||
import com.diboot.component.file.config.BaseConfig;
|
||||
import com.diboot.component.file.config.BaseCons;
|
||||
import com.diboot.component.file.utils.S;
|
||||
import com.diboot.component.file.utils.V;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.vo;
|
||||
package com.diboot.component.file.vo;
|
||||
|
||||
/**
|
||||
* JSON返回结果
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.commons.vo;
|
||||
package com.diboot.component.file.vo;
|
||||
|
||||
/**
|
||||
* 状态码定义
|
|
@ -1,6 +1,6 @@
|
|||
apply plugin: 'org.springframework.boot'
|
||||
dependencies {
|
||||
compile project(":diboot-core")
|
||||
compile project(":diboot-component-msg")
|
||||
|
||||
// java mail
|
||||
compile("javax.mail:mail:1.4.7",
|
|
@ -0,0 +1,7 @@
|
|||
package com.diboot.component.msg.email.service;
|
||||
|
||||
import com.diboot.component.msg.service.BaseSendService;
|
||||
|
||||
public interface EmailSendService extends BaseSendService {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.diboot.component.msg.email.service;
|
||||
|
||||
import com.diboot.component.msg.email.utils.EmailUtil;
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.component.msg.service.impl.BaseSendServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EmailSendServiceImpl extends BaseSendServiceImpl implements EmailSendService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmailSendServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public boolean sendMsg(Message message) throws Exception {
|
||||
String to = message.getReceiver();
|
||||
String toName = String.valueOf(message.getFromExt("toName"));
|
||||
String title = message.getTitle();
|
||||
String content = message.getContent();
|
||||
String[] ccEmails = (String[])message.getFromExt("ccEmails");
|
||||
String[] filePaths = (String[])message.getFromExt("filePaths");
|
||||
return EmailUtil.send(to, toName, title, content, ccEmails, filePaths);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.diboot.component.msg.email.utils;
|
||||
|
||||
import com.diboot.core.config.Cons;
|
||||
import com.diboot.core.util.PropertiesUtils;
|
||||
import com.diboot.core.util.V;
|
||||
import org.apache.commons.mail.EmailAttachment;
|
||||
import org.apache.commons.mail.HtmlEmail;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class EmailUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmailUtil.class);
|
||||
|
||||
private static final String EMAIL_NAME = PropertiesUtils.get("email.name");// 发送方称呼
|
||||
private static final String EMAIL_ADDRESS = PropertiesUtils.get("email.address");// 发送方email地址
|
||||
private static final String EMAIL_PASSWORD = PropertiesUtils.get("email.password");// 发送方授权码
|
||||
private static final String EMAIL_HOST = PropertiesUtils.get("email.host");//发送方smptHost
|
||||
private static final String EMAIL_SSLPORT = PropertiesUtils.get("email.sslport");// 发送端口
|
||||
|
||||
/*
|
||||
* 邮件发送
|
||||
* */
|
||||
public static boolean send(String to, String toName, String title, String content, String[] ccEmails, String... filePaths) throws Exception{
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.debug(">>>发送邮件开始, 收件人:" + to);
|
||||
}
|
||||
// Create the email message
|
||||
HtmlEmail email = new HtmlEmail();
|
||||
email.setHostName(EMAIL_HOST);
|
||||
email.setCharset(Cons.CHARSET_UTF8);
|
||||
email.setSSLOnConnect(true);
|
||||
if(V.notEmpty(EMAIL_SSLPORT)){
|
||||
email.setSslSmtpPort(EMAIL_SSLPORT);
|
||||
}
|
||||
email.setAuthentication(EMAIL_ADDRESS, EMAIL_PASSWORD);
|
||||
email.addTo(to, toName);
|
||||
if(V.notEmpty(ccEmails)){
|
||||
for(String cc : ccEmails){
|
||||
email.addCc(cc);
|
||||
}
|
||||
}
|
||||
email.setFrom(EMAIL_ADDRESS, EMAIL_NAME);
|
||||
email.setSubject(title);
|
||||
// set the html message
|
||||
email.setHtmlMsg(content);
|
||||
// 发送附件
|
||||
if(V.notEmpty(filePaths)){
|
||||
for(String path : filePaths){
|
||||
File file = new File(path);
|
||||
if(!file.exists()){
|
||||
logger.warn("附件文件不存在,无法发送!path="+path);
|
||||
return false;
|
||||
}
|
||||
EmailAttachment attachment = new EmailAttachment();
|
||||
attachment.setName(file.getName());
|
||||
attachment.setPath(path);
|
||||
attachment.setDisposition(EmailAttachment.ATTACHMENT);
|
||||
email.attach(attachment);
|
||||
}
|
||||
}
|
||||
// send the email
|
||||
email.send();
|
||||
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.debug("<<<发送邮件结束");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
apply plugin: 'org.springframework.boot'
|
||||
dependencies {
|
||||
compile project(":diboot-core")
|
||||
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
package com.diboot.components.msg.config;
|
||||
package com.diboot.component.msg.config;
|
||||
|
||||
public class MsgCons {
|
||||
|
||||
/*
|
||||
* 消息类型
|
||||
* */
|
||||
public enum MSG_TYPE{
|
||||
EMAIL, //邮件消息
|
||||
SMS, //短信消息
|
||||
SMS, //短信消息
|
||||
WECHAT //微信消息
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.diboot.components.msg.controller;
|
||||
package com.diboot.component.msg.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
import com.diboot.components.msg.service.MessageService;
|
||||
import com.diboot.components.msg.vo.MessageVO;
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.component.msg.service.MessageService;
|
||||
import com.diboot.component.msg.vo.MessageVO;
|
||||
import com.diboot.core.binding.RelationsBinder;
|
||||
import com.diboot.core.controller.BaseCrudRestController;
|
||||
import com.diboot.core.service.BaseService;
|
||||
|
@ -88,14 +88,4 @@ public class MessageController extends BaseCrudRestController {
|
|||
return super.deleteEntity(id);
|
||||
}
|
||||
|
||||
/***
|
||||
* 创建并发送消息
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/createAndSendMsg")
|
||||
public JsonResult createAndSendMsg(@RequestBody Message message, HttpServletRequest request) throws Exception{
|
||||
boolean success = messageService.createAndSendMsg(message);
|
||||
return new JsonResult(success);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +1,29 @@
|
|||
package com.diboot.components.msg.controller;
|
||||
package com.diboot.component.msg.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.diboot.components.msg.entity.MessageTemplate;
|
||||
import com.diboot.components.msg.service.MessageTemplateService;
|
||||
import com.diboot.component.msg.entity.MessageTemplate;
|
||||
import com.diboot.component.msg.service.MessageTemplateService;
|
||||
import com.diboot.core.controller.BaseCrudRestController;
|
||||
import com.diboot.core.service.BaseService;
|
||||
import com.diboot.core.service.DictionaryService;
|
||||
import com.diboot.core.util.V;
|
||||
import com.diboot.core.vo.JsonResult;
|
||||
import com.diboot.core.vo.KeyValue;
|
||||
import com.diboot.core.vo.Pagination;
|
||||
import com.diboot.core.vo.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* 消息模板相关service
|
||||
* @author:wangyl
|
||||
* */
|
||||
@RestController
|
||||
@RequestMapping("/messageTemplate")
|
||||
public class MessageTemplateController extends BaseCrudRestController {
|
||||
|
@ -22,6 +31,9 @@ public class MessageTemplateController extends BaseCrudRestController {
|
|||
@Autowired
|
||||
private MessageTemplateService messageTemplateService;
|
||||
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
@Override
|
||||
protected BaseService getService() {
|
||||
return messageTemplateService;
|
||||
|
@ -84,4 +96,29 @@ public class MessageTemplateController extends BaseCrudRestController {
|
|||
return super.deleteEntity(id);
|
||||
}
|
||||
|
||||
/***
|
||||
* 加载更多数据
|
||||
* @param request
|
||||
* @param modelMap
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/attachMore")
|
||||
public JsonResult attachMore(HttpServletRequest request, ModelMap modelMap){
|
||||
Wrapper wrapper = null;
|
||||
//消息模板元数据
|
||||
List<KeyValue> msgTempCodeKvList = dictionaryService.getKeyValueList(MessageTemplate.METADATA_TYPE.MSG_TEMP_CODE.name());
|
||||
modelMap.put("msgTempCodeKvList", msgTempCodeKvList);
|
||||
|
||||
return new JsonResult(modelMap);
|
||||
}
|
||||
|
||||
@GetMapping("/getTemplateVaribles/{code}")
|
||||
public JsonResult getTemplateVaribles(@PathVariable("code")String code, HttpServletRequest request) throws Exception{
|
||||
String[] varibles = messageTemplateService.getTemplateVaribles(code);
|
||||
if(V.isEmpty(varibles)){
|
||||
return new JsonResult(Status.FAIL_OPERATION, "获取变量列表为空");
|
||||
}
|
||||
return new JsonResult(Status.OK, varibles,"获取变量列表成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.components.msg.entity;
|
||||
package com.diboot.component.msg.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.diboot.core.entity.BaseExtEntity;
|
|
@ -1,4 +1,4 @@
|
|||
package com.diboot.components.msg.entity;
|
||||
package com.diboot.component.msg.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.diboot.core.entity.BaseExtEntity;
|
||||
|
@ -7,6 +7,11 @@ import lombok.Data;
|
|||
@Data
|
||||
public class MessageTemplate extends BaseExtEntity {
|
||||
|
||||
public static enum METADATA_TYPE{
|
||||
MSG_TEMP_CODE, // 消息模板
|
||||
MSG_TEMP_VARIBLES // 消息模板变量
|
||||
}
|
||||
|
||||
@TableField
|
||||
private String type;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.components.msg.mapper;
|
||||
package com.diboot.component.msg.mapper;
|
||||
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.core.mapper.BaseCrudMapper;
|
||||
|
||||
public interface MessageMapper extends BaseCrudMapper<Message> {
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "./mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.diboot.components.msg.mapper.MessageMapper">
|
||||
<mapper namespace="com.diboot.component.msg.mapper.MessageMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,6 +1,6 @@
|
|||
package com.diboot.components.msg.mapper;
|
||||
package com.diboot.component.msg.mapper;
|
||||
|
||||
import com.diboot.components.msg.entity.MessageTemplate;
|
||||
import com.diboot.component.msg.entity.MessageTemplate;
|
||||
import com.diboot.core.mapper.BaseCrudMapper;
|
||||
|
||||
public interface MessageTemplateMapper extends BaseCrudMapper<MessageTemplate> {
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "./mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.diboot.components.msg.mapper.MessageTemplateMapper">
|
||||
<mapper namespace="com.diboot.component.msg.mapper.MessageTemplateMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,25 @@
|
|||
package com.diboot.component.msg.service;
|
||||
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
|
||||
/*
|
||||
* 消息发送基础service
|
||||
* @author:wangyl
|
||||
* */
|
||||
public interface BaseSendService {
|
||||
|
||||
/***
|
||||
* 保存并发送消息
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
boolean createAndSendMsg(Message msg) throws Exception;
|
||||
|
||||
/***
|
||||
* 发送消息
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
boolean sendMsg(Message msg) throws Exception;
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.diboot.component.msg.service;
|
||||
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.core.service.BaseService;
|
||||
|
||||
/*
|
||||
* 消息相关service
|
||||
* @author:wangyl
|
||||
* */
|
||||
public interface MessageService extends BaseService<Message> {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.diboot.component.msg.service;
|
||||
|
||||
import com.diboot.component.msg.entity.MessageTemplate;
|
||||
import com.diboot.core.service.BaseService;
|
||||
|
||||
/*
|
||||
* 消息模板相关service
|
||||
* @author:wangyl
|
||||
* */
|
||||
public interface MessageTemplateService extends BaseService<MessageTemplate> {
|
||||
|
||||
/**
|
||||
* 根据code获取唯一的消息模板
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
MessageTemplate getMessageTemplate(String code);
|
||||
|
||||
/**
|
||||
* 根据code获取消息模板变量
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
String[] getTemplateVaribles(String code);
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.diboot.component.msg.service.impl;
|
||||
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.component.msg.mapper.MessageMapper;
|
||||
import com.diboot.component.msg.service.BaseSendService;
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 消息发送基础service
|
||||
* @author:wangyl
|
||||
* */
|
||||
@Service
|
||||
@Slf4j
|
||||
public abstract class BaseSendServiceImpl extends BaseServiceImpl<MessageMapper, Message> implements BaseSendService {
|
||||
|
||||
@Override
|
||||
public boolean createAndSendMsg(Message msg) throws Exception {
|
||||
boolean success = super.createEntity(msg);
|
||||
if(success){
|
||||
success = sendMsg(msg);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.diboot.component.msg.service.impl;
|
||||
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.component.msg.mapper.MessageMapper;
|
||||
import com.diboot.component.msg.service.MessageService;
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
* 消息相关service实现
|
||||
* @author:wangyl
|
||||
* */
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MessageServiceImpl extends BaseServiceImpl<MessageMapper, Message> implements MessageService {
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.diboot.component.msg.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.diboot.component.msg.entity.MessageTemplate;
|
||||
import com.diboot.component.msg.mapper.MessageTemplateMapper;
|
||||
import com.diboot.component.msg.service.MessageTemplateService;
|
||||
import com.diboot.core.entity.Dictionary;
|
||||
import com.diboot.core.service.DictionaryService;
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import com.diboot.core.util.S;
|
||||
import com.diboot.core.util.V;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* 消息模板相关service
|
||||
* @author:wangyl
|
||||
* */
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MessageTemplateServiceImpl extends BaseServiceImpl<MessageTemplateMapper, MessageTemplate> implements MessageTemplateService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MessageTemplateServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
@Override
|
||||
public MessageTemplate getMessageTemplate(String code) {
|
||||
LambdaQueryWrapper<MessageTemplate> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MessageTemplate::getCode, code);
|
||||
List<MessageTemplate> list = this.getEntityList(wrapper);
|
||||
return V.notEmpty(list)? list.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateVaribles(String code) {
|
||||
LambdaQueryWrapper<Dictionary> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.ne(Dictionary::getParentId, 0)
|
||||
.eq(Dictionary::getItemName, code)
|
||||
.eq(Dictionary::getType, MessageTemplate.METADATA_TYPE.MSG_TEMP_VARIBLES.name());
|
||||
List<Dictionary> list = dictionaryService.getEntityList(wrapper);
|
||||
if (V.isEmpty(list)){
|
||||
return null;
|
||||
}
|
||||
return S.split(list.get(0).getItemValue());
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.diboot.components.msg.vo;
|
||||
package com.diboot.component.msg.vo;
|
||||
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
import com.diboot.components.msg.entity.MessageTemplate;
|
||||
import com.diboot.component.msg.entity.Message;
|
||||
import com.diboot.component.msg.entity.MessageTemplate;
|
||||
import com.diboot.core.binding.annotation.BindDict;
|
||||
import com.diboot.core.binding.annotation.BindEntity;
|
||||
import lombok.Data;
|
|
@ -1,11 +0,0 @@
|
|||
package com.diboot.components.msg.config;
|
||||
|
||||
/*
|
||||
* 配置基类,之后的邮件,短信等实现时都需要需要继承此类
|
||||
* 并在此基础上扩展
|
||||
* */
|
||||
public abstract class BaseConfig {
|
||||
|
||||
//关键配置是否为空
|
||||
public abstract boolean isEmpty();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.diboot.components.msg.config;
|
||||
|
||||
import com.diboot.core.util.V;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author : wangyongliang@dibo.ltd
|
||||
* @version v2.0
|
||||
* @Description: 读取配置文件类
|
||||
* @Date 2019-07-8
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(EmailConfig.class)
|
||||
@ConfigurationProperties("email.sender")
|
||||
@Data
|
||||
public class EmailConfig extends BaseConfig {
|
||||
|
||||
private String name;
|
||||
|
||||
private String address;
|
||||
|
||||
private String password;
|
||||
|
||||
private String host;
|
||||
|
||||
private String sslport;
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
if(V.notEmpty(address) && V.notEmpty(password)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package com.diboot.components.msg.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* 消息基类,之后的邮件,短信等实现时都需要需要继承此类
|
||||
* 并在此基础上扩展
|
||||
* */
|
||||
@Data
|
||||
public class BaseMessage {
|
||||
|
||||
//接收人
|
||||
private String receiver;
|
||||
|
||||
//消息内容
|
||||
private String content;
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.diboot.components.msg.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
*
|
||||
* */
|
||||
@Data
|
||||
public class EmailMessage extends BaseMessage {
|
||||
|
||||
private String receiverName;
|
||||
|
||||
private String[] ccEmails;
|
||||
|
||||
private String title;
|
||||
|
||||
private String[] filePaths;
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.diboot.components.msg.service;
|
||||
|
||||
import com.diboot.components.msg.entity.BaseMessage;
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
|
||||
public interface BaseSendService {
|
||||
|
||||
//发送消息
|
||||
boolean send(BaseMessage message) throws Exception;
|
||||
|
||||
//转化为可发送的消息对象
|
||||
BaseMessage parseToSendMessage(Message message);
|
||||
|
||||
//获取发送消息类型(邮件,短信,微信等类型)
|
||||
String getType();
|
||||
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package com.diboot.components.msg.service;
|
||||
|
||||
public interface EmailSendService extends BaseSendService {
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.diboot.components.msg.service;
|
||||
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
import com.diboot.core.service.BaseService;
|
||||
|
||||
public interface MessageService extends BaseService<Message> {
|
||||
|
||||
/***
|
||||
* 保存并发送消息
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
boolean createAndSendMsg(Message msg);
|
||||
|
||||
/***
|
||||
* 发送消息
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
boolean sendMsg(Message msg);
|
||||
|
||||
/***
|
||||
* 根据消息类型获取对应的发送消息service
|
||||
*/
|
||||
BaseSendService getSendService(String type);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package com.diboot.components.msg.service;
|
||||
|
||||
import com.diboot.components.msg.entity.MessageTemplate;
|
||||
import com.diboot.core.service.BaseService;
|
||||
|
||||
public interface MessageTemplateService extends BaseService<MessageTemplate> {
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
package com.diboot.components.msg.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.diboot.components.msg.config.EmailConfig;
|
||||
import com.diboot.components.msg.config.MsgCons;
|
||||
import com.diboot.components.msg.entity.BaseMessage;
|
||||
import com.diboot.components.msg.entity.EmailMessage;
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
import com.diboot.components.msg.service.EmailSendService;
|
||||
import com.diboot.core.config.Cons;
|
||||
import com.diboot.core.util.V;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.mail.EmailAttachment;
|
||||
import org.apache.commons.mail.HtmlEmail;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EmailSendServiceImpl implements EmailSendService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmailSendServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
EmailConfig emailConfig;
|
||||
|
||||
@Override
|
||||
public boolean send(BaseMessage message) throws Exception {
|
||||
EmailMessage emailMessage = (EmailMessage)message;
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.debug("发送邮件开始, 收件人:" + message.getReceiver() + ", message=" + message.getContent());
|
||||
}
|
||||
if(emailConfig.isEmpty()){
|
||||
logger.warn("发送邮件相关配置为空,发送失败");
|
||||
return false;
|
||||
}
|
||||
// Create the email message
|
||||
HtmlEmail email = new HtmlEmail();
|
||||
email.setHostName(emailConfig.getHost());
|
||||
email.setCharset(Cons.CHARSET_UTF8);
|
||||
email.setSSLOnConnect(true);
|
||||
if(V.notEmpty(emailConfig.getSslport())){
|
||||
email.setSslSmtpPort(emailConfig.getSslport());
|
||||
}
|
||||
email.setAuthentication(emailConfig.getAddress(), emailConfig.getPassword());
|
||||
email.addTo(emailMessage.getReceiver(), emailMessage.getReceiverName());
|
||||
if(V.notEmpty(emailMessage.getCcEmails())){
|
||||
for(String cc : emailMessage.getCcEmails()){
|
||||
email.addCc(cc);
|
||||
}
|
||||
}
|
||||
email.setFrom(emailConfig.getAddress(), emailConfig.getName());
|
||||
email.setSubject(emailMessage.getTitle());
|
||||
// set the html message
|
||||
email.setHtmlMsg(message.getContent());
|
||||
|
||||
// 发送附件
|
||||
if(V.notEmpty(emailMessage.getFilePaths())){
|
||||
for(String path : emailMessage.getFilePaths()){
|
||||
File file = new File(path);
|
||||
if(!file.exists()){
|
||||
logger.warn("附件文件不存在,无法发送!path="+path);
|
||||
return false;
|
||||
}
|
||||
EmailAttachment attachment = new EmailAttachment();
|
||||
attachment.setName(file.getName());
|
||||
attachment.setPath(path);
|
||||
attachment.setDisposition(EmailAttachment.ATTACHMENT);
|
||||
email.attach(attachment);
|
||||
}
|
||||
}
|
||||
|
||||
// send the email
|
||||
email.send();
|
||||
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.debug("发送邮件完成, 收件人:" + message.getReceiver());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailMessage parseToSendMessage(Message message) {
|
||||
EmailMessage email = new EmailMessage();
|
||||
email.setReceiver(message.getReceiver());
|
||||
email.setReceiverName(message.getReceiver());
|
||||
email.setTitle(message.getTitle());
|
||||
email.setContent(message.getContent());
|
||||
JSONArray jsonArray = (JSONArray)message.getFromExt("filePaths");
|
||||
List<String> filePathList = JSONArray.parseArray(jsonArray.toString(), String.class);
|
||||
String[] filePaths = filePathList.toArray(new String[0]);
|
||||
email.setFilePaths(filePaths);
|
||||
|
||||
return email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return MsgCons.MSG_TYPE.EMAIL.name();
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package com.diboot.components.msg.service.impl;
|
||||
|
||||
import com.diboot.components.msg.entity.BaseMessage;
|
||||
import com.diboot.components.msg.entity.Message;
|
||||
import com.diboot.components.msg.mapper.MessageMapper;
|
||||
import com.diboot.components.msg.service.BaseSendService;
|
||||
import com.diboot.components.msg.service.MessageService;
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import com.diboot.core.util.V;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MessageServiceImpl extends BaseServiceImpl<MessageMapper, Message> implements MessageService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MessageServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private Map<String, BaseSendService> sendServiceMap;
|
||||
|
||||
@Override
|
||||
public boolean createAndSendMsg(Message msg) {
|
||||
boolean success = super.createEntity(msg);
|
||||
if(success){
|
||||
success = sendMsg(msg);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendMsg(Message msg) {
|
||||
boolean success = false;
|
||||
try {
|
||||
//根据消息类型获取发送消息service
|
||||
BaseSendService sendService = getSendService(msg.getType());
|
||||
if(V.isEmpty(sendService)){
|
||||
logger.warn("没获取到相应发送消息的service");
|
||||
return false;
|
||||
}
|
||||
//将Message对象转化为可发送的消息对象
|
||||
BaseMessage baseMessage = sendService.parseToSendMessage(msg);
|
||||
//发送消息
|
||||
success = sendService.send(baseMessage);
|
||||
} catch (Exception e) {
|
||||
logger.warn("消息发送失败", e);
|
||||
return false;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseSendService getSendService(String type) {
|
||||
if(V.notEmpty(sendServiceMap)){
|
||||
for(BaseSendService sendService : sendServiceMap.values()){
|
||||
if(type.equals(sendService.getType())){
|
||||
return sendService;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.diboot.components.msg.service.impl;
|
||||
|
||||
import com.diboot.components.msg.entity.MessageTemplate;
|
||||
import com.diboot.components.msg.mapper.MessageTemplateMapper;
|
||||
import com.diboot.components.msg.service.MessageTemplateService;
|
||||
import com.diboot.core.service.impl.BaseServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MessageTemplateServiceImpl extends BaseServiceImpl<MessageTemplateMapper, MessageTemplate> implements MessageTemplateService {
|
||||
}
|
|
@ -4,9 +4,10 @@ dependencies {
|
|||
// compile("com.diboot:diboot-shiro:2.0.1")
|
||||
compile project(":diboot-shiro-wx-mp")
|
||||
// compile project(":diboot-shiro-wx-cp")
|
||||
compile project(":diboot-components-msg")
|
||||
compile project(":dibo-commons-file")
|
||||
compile project(":dibo-commons-excel")
|
||||
compile project(":diboot-component-msg")
|
||||
compile project(":diboot-component-msg-email")
|
||||
compile project(":diboot-component-file")
|
||||
compile project(":diboot-component-file-excel")
|
||||
|
||||
// 七牛
|
||||
compile ("com.qiniu:qiniu-java-sdk:7.2.7")
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.diboot.example.controller;
|
||||
|
||||
import com.diboot.commons.entity.BaseFile;
|
||||
import com.diboot.commons.file.FileHelper;
|
||||
import com.diboot.commons.service.BaseFileService;
|
||||
import com.diboot.component.file.entity.BaseFile;
|
||||
import com.diboot.component.file.file.FileHelper;
|
||||
import com.diboot.component.file.service.BaseFileService;
|
||||
import com.diboot.core.util.S;
|
||||
import com.diboot.core.util.V;
|
||||
import com.diboot.core.vo.JsonResult;
|
||||
import com.diboot.core.vo.Status;
|
||||
|
@ -35,7 +36,7 @@ public class FileUploadController {
|
|||
public JsonResult imageUpload(@RequestParam("image") MultipartFile image, ModelMap modelMap, HttpServletRequest request){
|
||||
String fileName = image.getOriginalFilename();
|
||||
String ext = fileName.substring(fileName.lastIndexOf(".")+1);
|
||||
String newFileName = com.diboot.commons.utils.S.newUuid() + "." + ext;
|
||||
String newFileName = S.newUuid() + "." + ext;
|
||||
String filePath = FileHelper.saveImage(image, newFileName);
|
||||
BaseFile file = new BaseFile();
|
||||
file.setName(image.getOriginalFilename());
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.diboot.example.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.diboot.commons.entity.BaseFile;
|
||||
import com.diboot.commons.file.FileHelper;
|
||||
import com.diboot.commons.vo.JsonResult;
|
||||
import com.diboot.commons.vo.Pagination;
|
||||
import com.diboot.component.file.entity.BaseFile;
|
||||
import com.diboot.component.file.file.FileHelper;
|
||||
import com.diboot.component.file.vo.JsonResult;
|
||||
import com.diboot.component.file.vo.Pagination;
|
||||
import com.diboot.core.entity.Dictionary;
|
||||
import com.diboot.core.service.BaseService;
|
||||
import com.diboot.core.service.DictionaryService;
|
||||
|
@ -12,9 +12,9 @@ import com.diboot.core.util.BeanUtils;
|
|||
import com.diboot.core.vo.Status;
|
||||
import com.diboot.example.entity.DictionaryExcelData;
|
||||
import com.diboot.example.listener.DictionaryExcelDataListener;
|
||||
import com.diboot.excel.controller.BaseExcelImportController;
|
||||
import com.diboot.excel.listener.BaseExcelDataListener;
|
||||
import com.diboot.excel.utils.EasyExcelHelper;
|
||||
import com.diboot.component.excel.controller.BaseExcelImportController;
|
||||
import com.diboot.component.excel.listener.BaseExcelDataListener;
|
||||
import com.diboot.component.excel.utils.EasyExcelHelper;
|
||||
import com.diboot.shiro.service.RoleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.diboot.example.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.diboot.excel.converter.StringConverter;
|
||||
import com.diboot.excel.entity.BaseExcelDataEntity;
|
||||
import com.diboot.component.excel.converter.StringConverter;
|
||||
import com.diboot.component.excel.entity.BaseExcelDataEntity;
|
||||
import lombok.Data;
|
||||
/*
|
||||
* dictionary数据导入导出实体类
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.diboot.core.service.BaseService;
|
|||
import com.diboot.core.service.DictionaryService;
|
||||
import com.diboot.core.util.V;
|
||||
import com.diboot.example.entity.DictionaryExcelData;
|
||||
import com.diboot.excel.listener.BaseExcelDataListener;
|
||||
import com.diboot.component.excel.listener.BaseExcelDataListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -77,15 +77,15 @@ logging.level.org.mybatis=debug
|
|||
|
||||
#邮件发送配置
|
||||
#发送方邮箱
|
||||
email.sender.address=
|
||||
email.address=
|
||||
#发送方授权码
|
||||
email.sender.password=
|
||||
email.password=
|
||||
#SMTP发送服务器的名字
|
||||
email.sender.host=smtp.163.com
|
||||
email.host=smtp.163.com
|
||||
#发送端口
|
||||
email.sender.sslport=
|
||||
email.sslport=
|
||||
#发送方称呼
|
||||
email.sender.name=
|
||||
email.name=
|
||||
|
||||
|
||||
#权限配置
|
||||
|
|
|
@ -14,8 +14,9 @@ include 'diboot-shiro'
|
|||
include 'diboot-shiro-wx-mp'
|
||||
include 'diboot-docs'
|
||||
include 'diboot-shiro-wx-cp'
|
||||
include 'diboot-components-msg'
|
||||
include 'diboot-component-msg'
|
||||
include 'diboot-report'
|
||||
include 'dibo-commons-file'
|
||||
include 'dibo-commons-excel'
|
||||
include 'diboot-component-file'
|
||||
include 'diboot-component-file-excel'
|
||||
include 'diboot-component-msg-email'
|
||||
|
||||
|
|
Loading…
Reference in New Issue