Commit eafbca4e by chentianzhong

111111

parent 049e2d9c
......@@ -13,7 +13,7 @@
<artifactId>email-server</artifactId>
<version>1.0.0</version>
<name>platform-seal</name>
<name>email-server</name>
<description>内部邮件后端服务</description>
<properties>
......
......@@ -11,7 +11,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@MapperScan("com.zq.email.mapper")
@EnableTransactionManagement
public class EmailApplication {
public static void main(String[] args) {
SpringApplication.run(EmailApplication.class, args);
}
}
......@@ -18,8 +18,8 @@ package com.zq.email.config;
import com.zq.common.annotation.AnonymousAccess;
import com.zq.common.config.redis.RedisUtils;
import com.zq.common.config.security.SecurityProperties;
import com.zq.common.utils.RequestMethodEnum;
import com.zq.sealPlatform.feign.AdminFeignClient;
import com.zq.common.constant.RequestMethodEnum;
import com.zq.email.feign.AdminFeignClient;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
......
package com.zq.email.config;
import com.zq.sealPlatform.webService.service.SealWebService;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;
/**
* 注意:
* org.apache.cxf.Bus
* org.apache.cxf.bus.spring.SpringBus
* org.apache.cxf.jaxws.EndpointImpl
* javax.xml.ws.Endpoint
*/
@Configuration
@Slf4j
public class WebServiceConfig {
@Autowired
private SealWebService sealWebService;
@Autowired
private Bus bus;
@Bean(name=Bus.DEFAULT_BUS_ID)
public SpringBus springBus(){
return new SpringBus();
}
/**
* 设置Webservice接口访问前缀
* @return
*/
@Bean(name= "cxfServlet")
public ServletRegistrationBean dispatcherServlet(){
return new ServletRegistrationBean(new CXFServlet(),"/sealPlatform/ws/*");
}
/**
* 将Webservice接口进行暴露
* 访问路径:ip+端口+/app+/webservice
* @return
*/
@Bean
public Endpoint endpointHelloService(){
EndpointImpl endpoint=new EndpointImpl(bus,sealWebService);
endpoint.publish("/getSeal");
return endpoint;
}
}
......@@ -2,24 +2,8 @@ package com.zq.email.constants;
public class EmailConstant {
//邮件文件夹通用id(默认)
/**所有公共文件夹父级id*/
public static final String PUBLIC_PARENT_ID="0";
/**个人邮箱(收件箱)*/
public static final String MY_EMAIL_BOX="1";
/**部门公共收件箱*/
public static final String DEPT_EMAIL_BOX="2";
/**发件箱(未成功发动或者撤回的邮件)*/
public static final String OUT_EMAIL_BOX="3";
/**个人已发送(已被阅读。不能撤回的邮件)*/
public static final String ALREADY_SEND_EMAIL_BOX="4";
/**已删除邮件*/
public static final String ALREADY_DEL_EMAIL_BOX="5";
/**其它文件夹*/
public static final String OTHER_FOLDER_EMAIL_BOX="6";
/**邮件标签*/
public static final String EMAIL_LABEL_BOX="7";
//邮件类型
/**个人邮件*/
......@@ -27,25 +11,12 @@ public class EmailConstant {
/**部门邮件*/
public static final String TYPE_EMAIL_DEPT="1";
//邮件状态
/**未读(默认)*/
public static final String STATE_EMAIL_UNREAD="0";
/**已读*/
public static final String STATE_EMAIL_READ="1";
//人员类型
/**发送人*/
public static final String TYPE_EMAIL_SEND="1";
/**接收人*/
public static final String TYPE_EMAIL_RECEIVE="2";
//邮件发送状态
/** 未发送 */
public static final String TYPE_EMAIL_NOTSTATE ="0";
/** 已发送 */
public static final String TYPE_EMAIL_STATE ="1";
//邮件服务系统标识
public static final String SYSTEM_TAG = "oa-email";
......@@ -53,16 +24,4 @@ public class EmailConstant {
public static final String EMAIL_REMIND_TITLE ="新邮件提醒";
//新邮件提醒内容(测试)
public static final String EMAIL_RECEIVE_REMIND ="您有一封新的邮件,请及时查收。";
//是个人邮件
public static final String IS_PERSONAL = "1";
//是部门邮件
public static final String IS_DEPT = "1";
//不是个人邮件
public static final String NO_PERSONAL = "0";
//不是部门邮件
public static final String NO_DEPT = "0";
/**是否任务邮件*/
public static final Integer IS_TASK=1;
public static final Integer NO_TASK=0;
}
package com.zq.email.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@RestController
@RequestMapping("/email/businessSystem")
public class BusinessSystemController {
}
package com.zq.email.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@RestController
@RequestMapping("/email/emailAttach")
public class EmailAttachController {
}
package com.zq.email.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@RestController
@RequestMapping("/email/emailContent")
public class EmailContentController {
}
package com.zq.email.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.enums.EmailFolderEnum;
import com.zq.email.enums.WhetherEnum;
import com.zq.email.service.IEmailPersonService;
import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Api(tags = "邮件接口")
@RestController
@RequestMapping("/email")
@Slf4j
@RequiredArgsConstructor
public class EmailController {
private final IEmailPersonService emailPersonService;
@ApiOperation("列表总数")
@PostMapping("total")
public ResultVo total(@RequestBody EmailReqVo vo) {
return ResultVo.success(emailPersonService.emailPage(vo));
}
@ApiOperation("列表分页")
@PostMapping("page")
public ResultVo page(@RequestBody EmailReqVo vo) {
return ResultVo.success(emailPersonService.emailPage(vo));
}
@ApiOperation("写邮件")
@PostMapping("edit")
public ResultVo edit(@RequestBody EmailEditVo vo) {
AssertUtils.hasText(vo.getTitle(), "缺少参数:title");
AssertUtils.isTrue(CollectionUtil.isNotEmpty(vo.getReceiver()) || CollectionUtil.isNotEmpty(vo.getReceiver()), "缺少参数:receiver和 receiveDeptList");
emailPersonService.emailEditVo(vo);
return ResultVo.success();
}
//
// @ApiOperation("公共(部门)邮件分页")
// @PostMapping("inboxDeptPage")
// public ResultVo inboxDeptPage(@RequestBody EmailReqVo vo) {
// vo.setFolderId(EmailFolderEnum.FOLDER_DEPT_INBOX.getKey());
// vo.setIsPerson(WhetherEnum.NO.getKey());
// return ResultVo.success(emailPersonService.emailPage(vo));
// }
//
// @ApiOperation("发件箱分页")
// @PostMapping("outboxPage")
// public ResultVo outboxPage(@RequestBody EmailReqVo vo) {
// vo.setFolderId(EmailFolderEnum.FOLDER_OUTBOX.getKey());
// vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
// vo.setIsSend(WhetherEnum.NO.getKey());
// return ResultVo.success(emailPersonService.emailPage(vo));
// }
//
// @ApiOperation("已发送分页")
// @PostMapping("sendPage")
// public ResultVo sendPage(@RequestBody EmailReqVo vo) {
// vo.setFolderId(EmailFolderEnum.FOLDER_OUTBOX.getKey());
// vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
// vo.setIsSend(WhetherEnum.YES.getKey());
// return ResultVo.success(emailPersonService.emailPage(vo));
// }
//
// @ApiOperation("其他文件夹分页")
// @PostMapping("folderPage")
// public ResultVo folderPage(@RequestBody EmailReqVo vo) {
// log.info(">>>>>folderId:{}", vo.getFolderId());
// vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
// vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
// vo.setIsSend(WhetherEnum.YES.getKey());
// return ResultVo.success(emailPersonService.emailPage(vo));
// }
}
package com.zq.email.controller;
import com.zq.common.utils.AssertUtils;
import com.zq.common.utils.TokenUtils;
import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.service.IEmailFolderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Api(tags = "文件夹接口")
@RestController
@RequestMapping("/email/emailFolder")
@Slf4j
@RequiredArgsConstructor
public class EmailFolderController {
private final IEmailFolderService emailFolderService;
@ApiOperation("获取个人所有的文件夹")
@PostMapping("selfFolderList")
public ResultVo selfFolderList() {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
return ResultVo.success(emailFolderService.selfFolderList(adminContext.getUserId()));
}
}
package com.zq.email.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@RestController
@RequestMapping("/email/emailLabel")
public class EmailLabelController {
}
package com.zq.email.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@RestController
@RequestMapping("/email/emailPerson")
public class EmailPersonController {
}
package com.zq.email.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.*;
import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="EmailFolderDto对象", description="")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class EmailFolderDto {
private Integer folderId;
private String folderName;
private Integer sort;
private Integer emailSize;
private List<EmailFolderDto> children;
}
package com.zq.email.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("business_system")
@ApiModel(value="BusinessSystem对象", description="")
public class BusinessSystem implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "密码")
private String pwd;
@ApiModelProperty(value = "名称")
private String systemName;
@ApiModelProperty(value = "0无效 1有效")
private Integer status;
}
package com.zq.email.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("email_attach")
@ApiModel(value="EmailAttach对象", description="")
public class EmailAttach implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private Integer id;
private Long emailContentId;
private String attachId;
private String attachName;
private Long attachSize;
private String downloadPath;
private LocalDateTime sendTime;
}
package com.zq.email.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("email_content")
@ApiModel(value="EmailContent对象", description="")
public class EmailContent implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private Integer id;
private String title;
private String content;
private Integer degree;
private Long sendUserId;
private String sendUserEmail;
private String sendUserName;
private LocalDateTime sendTime;
private Integer smsRemind;
private Integer messageRemind;
private Long replId;
private String deptList;
}
package com.zq.email.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("email_folder")
@ApiModel(value="EmailFolder对象", description="")
public class EmailFolder implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "folder_id", type = IdType.ASSIGN_UUID)
private Integer folderId;
private Long userId;
private String userEmail;
private String folderName;
private Integer sort;
private Integer emailSize;
}
package com.zq.email.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("email_label")
@ApiModel(value="EmailLabel对象", description="")
public class EmailLabel implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private Integer id;
private String labelName;
private Long personEmailId;
}
package com.zq.email.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("email_person")
@ApiModel(value="EmailPerson对象", description="")
public class EmailPerson implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private Integer id;
private Long emailContentId;
private Long userId;
private String userEmail;
private Long deptId;
private String deptName;
private String courtCode;
private Integer personType;
private LocalDateTime sendTime;
private Long folderId;
private Integer isRead;
private Integer isSend;
private Integer isPerson;
private Integer isTask;
@TableField(exist = false)
private EmailContent emailContent;
}
package com.zq.email.enums;
import com.zq.common.utils.AssertUtils;
import com.zq.email.dto.EmailFolderDto;
import java.util.ArrayList;
import java.util.List;
/**
* 文件夹
*/
public enum EmailFolderEnum {
FOLDER_INBOX(1, "收件箱"),
FOLDER_DEPT_INBOX(2, "部门邮件"),
FOLDER_OUTBOX(3, "发件箱"),
FOLDER_ALREADY_SEND(4, "已发送"),
FOLDER_ALREADY_DELETE(5, "已删除"),
FOLDER_OTHER(6, "其他文件夹"),
FOLDER_LABEL(7, "邮件标签"),
;
private Integer key;
private String value;
EmailFolderEnum(Integer key, String value) {
this.key = key;
this.value = value;
}
public static EmailFolderEnum getEnumByKey(Integer key){
for (EmailFolderEnum value : EmailFolderEnum.values()) {
if(value.getKey() == key){
return value;
}
}
return null;
}
/**
* 根据keu获取秘密级别值
* @param key
* @return
*/
public static String getValueByKey(Integer key) {
for (EmailFolderEnum value : EmailFolderEnum.values()) {
if (value.getKey().equals(key)) {
return value.getValue();
}
}
return null;
}
public static List<EmailFolderDto> toList(){
List<EmailFolderDto> list = new ArrayList<>();
for (EmailFolderEnum emailFolderEnum : EmailFolderEnum.values()) {
EmailFolderDto folder = EmailFolderDto.builder()
.folderId(emailFolderEnum.getKey())
.folderName(emailFolderEnum.getValue())
.sort(emailFolderEnum.getKey())
.build();
list.add(folder);
}
return list;
}
public Integer getKey() {
return key;
}
public void setKey(Integer key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.zq.email.enums;
import com.zq.common.utils.AssertUtils;
/**
* 是否
*/
public enum RemindEnum {
MESSAGE_REMIND(0, "内部信息提醒"),
SMS_REMIND(1, "手机短信提醒")
;
private Integer key;
private String value;
RemindEnum(Integer key, String value) {
this.key = key;
this.value = value;
}
public static RemindEnum getEnumByKey(Integer key){
for (RemindEnum value : RemindEnum.values()) {
if(value.getKey() == key){
return value;
}
}
return null;
}
/**
* 根据keu获取秘密级别值
* @param key
* @return
*/
public static String getValueByKey(Integer key) {
for (RemindEnum value : RemindEnum.values()) {
if (value.getKey().equals(key)) {
return value.getValue();
}
}
return null;
}
public static Integer getByByValue(String value){
AssertUtils.hasText(value, "value不为空");
for (RemindEnum whetherEnum : RemindEnum.values()) {
if(whetherEnum.getValue().equals(value)){
return whetherEnum.getKey();
}
}
return null;
}
public Integer getKey() {
return key;
}
public void setKey(Integer key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.zq.email.enums;
import com.zq.common.utils.AssertUtils;
/**
* 是否
*/
public enum SearchRangeEnum {
LAST_THREE_MONTHS(0, "最近三个月"),
LAST_SIX_MONTHS(1, "最近六个月"),
LAST_ONE_YEAR(2, "最近一年"),
All(3, "所有邮件"),
;
private Integer key;
private String value;
SearchRangeEnum(Integer key, String value) {
this.key = key;
this.value = value;
}
public static SearchRangeEnum getEnumByKey(Integer key){
for (SearchRangeEnum value : SearchRangeEnum.values()) {
if(value.getKey() == key){
return value;
}
}
return null;
}
/**
* 根据keu获取秘密级别值
* @param key
* @return
*/
public static String getValueByKey(Integer key) {
for (SearchRangeEnum value : SearchRangeEnum.values()) {
if (value.getKey().equals(key)) {
return value.getValue();
}
}
return null;
}
public static Integer getByByValue(String value){
AssertUtils.hasText(value, "value不为空");
for (SearchRangeEnum whetherEnum : SearchRangeEnum.values()) {
if(whetherEnum.getValue().equals(value)){
return whetherEnum.getKey();
}
}
return null;
}
public Integer getKey() {
return key;
}
public void setKey(Integer key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
......@@ -7,8 +7,9 @@ import com.zq.common.utils.AssertUtils;
*/
public enum WhetherEnum {
NO(0, "否"),
YES(1, "是");
YES(1, "是"),
NO(0, "否")
;
private Integer key;
private String value;
......
package com.zq.email.mapper;
import com.zq.email.entity.BusinessSystem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface BusinessSystemMapper extends BaseMapper<BusinessSystem> {
}
package com.zq.email.mapper;
import com.zq.email.entity.EmailAttach;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface EmailAttachMapper extends BaseMapper<EmailAttach> {
}
package com.zq.email.mapper;
import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface EmailContentMapper extends BaseMapper<EmailContent> {
}
package com.zq.email.mapper;
import com.zq.email.entity.EmailFolder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface EmailFolderMapper extends BaseMapper<EmailFolder> {
}
package com.zq.email.mapper;
import com.zq.email.entity.EmailLabel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface EmailLabelMapper extends BaseMapper<EmailLabel> {
}
package com.zq.email.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.email.entity.EmailPerson;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zq.email.vo.EmailReqVo;
/**
* <p>
* Mapper 接口
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface EmailPersonMapper extends BaseMapper<EmailPerson> {
}
package com.zq.email.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* Created by Chen Tianzhong in 2023/3/5
*/
@Data
@Component
@ConfigurationProperties(prefix = "sms")
public class SmsProperties {
/**
* 短信APP_ID
*/
private String appId;
/**
* 短信密钥
*/
private String appKey;
/**
* 内网地址
*/
private String insideUrl;
/**
* 外网地址
*/
private String outsideUrl;
}
package com.zq.email.service;
import com.zq.email.entity.BusinessSystem;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface IBusinessSystemService extends IService<BusinessSystem> {
}
package com.zq.email.service;
import com.zq.email.entity.EmailAttach;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface IEmailAttachService extends IService<EmailAttach> {
}
package com.zq.email.service;
import com.zq.common.vo.OnlineUserDto;
import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.EmailEditVo;
/**
* <p>
* 服务类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface IEmailContentService extends IService<EmailContent> {
EmailContent saveContent(EmailEditVo vo, OnlineUserDto adminContext);
}
package com.zq.email.service;
import com.zq.email.entity.EmailFolder;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface IEmailFolderService extends IService<EmailFolder> {
List selfFolderList(Long userId);
}
package com.zq.email.service;
import com.zq.email.entity.EmailLabel;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface IEmailLabelService extends IService<EmailLabel> {
}
package com.zq.email.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.email.entity.EmailPerson;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailReqVo;
/**
* <p>
* 服务类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
public interface IEmailPersonService extends IService<EmailPerson> {
Integer emailCount(EmailReqVo vo);
Page<EmailPerson> emailPage(EmailReqVo vo);
void emailEditVo(EmailEditVo vo);
}
package com.zq.email.service.impl;
import com.zq.email.entity.BusinessSystem;
import com.zq.email.mapper.BusinessSystemMapper;
import com.zq.email.service.IBusinessSystemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Service
public class BusinessSystemServiceImpl extends ServiceImpl<BusinessSystemMapper, BusinessSystem> implements IBusinessSystemService {
}
package com.zq.email.service.impl;
import com.zq.email.entity.EmailAttach;
import com.zq.email.mapper.EmailAttachMapper;
import com.zq.email.service.IEmailAttachService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Service
public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, EmailAttach> implements IEmailAttachService {
}
package com.zq.email.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.OnlineUserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.enums.RemindEnum;
import com.zq.email.enums.WhetherEnum;
import com.zq.email.mapper.EmailContentMapper;
import com.zq.email.service.IEmailContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.email.vo.EmailEditVo;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
/**
* <p>
* 服务实现类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Service
public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, EmailContent> implements IEmailContentService {
@Override
public EmailContent saveContent(EmailEditVo vo, OnlineUserDto adminContext) {
EmailContent content = null;
if (vo.getId()!=null){
content = this.getById(vo.getId());
AssertUtils.notNull(content, 500, "业务逻辑错误, 参数:contentId传参错误!");
}
content = (content == null) ? new EmailContent() : content;
content.setTitle(vo.getTitle());
content.setContent(vo.getContent());
content.setDegree(vo.getDegree());
content.setSendUserId(adminContext.getUserId());
content.setSendUserEmail(adminContext.getUserName());
content.setSendUserName(adminContext.getNickName());
content.setSendTime(LocalDateTime.now());
content.setReplId(vo.getReplId());
if (vo.getRemind().contains(RemindEnum.SMS_REMIND.getKey())){
content.setSmsRemind(WhetherEnum.YES.getKey());
}else{
content.setSmsRemind(WhetherEnum.NO.getKey());
}
if (vo.getRemind().contains(RemindEnum.MESSAGE_REMIND.getKey())){
content.setMessageRemind(WhetherEnum.YES.getKey());
}else{
content.setMessageRemind(WhetherEnum.NO.getKey());
}
if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())){
content.setDeptList(vo.getReceiveDeptList().toString());
}
this.saveOrUpdate(content);
return content;
}
}
package com.zq.email.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.zq.email.dto.EmailFolderDto;
import com.zq.email.entity.EmailFolder;
import com.zq.email.enums.EmailFolderEnum;
import com.zq.email.mapper.EmailFolderMapper;
import com.zq.email.service.IEmailFolderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Service
public class EmailFolderServiceImpl extends ServiceImpl<EmailFolderMapper, EmailFolder> implements IEmailFolderService {
@Override
public List selfFolderList(Long userId) {
List<EmailFolder> folderList = this.lambdaQuery().eq(EmailFolder::getUserId, userId).orderByAsc(EmailFolder::getSort).list();
List<EmailFolderDto> folderDtoList = toEmailFolderDto(folderList);
List<EmailFolderDto> list = EmailFolderEnum.toList();
if (CollectionUtil.isNotEmpty(folderDtoList)){
for (EmailFolderDto folderDto : list) {
if (folderDto.getFolderId().equals(EmailFolderEnum.FOLDER_OTHER.getKey())){
folderDto.setChildren(folderDtoList);
}
}
}
return list;
}
private List<EmailFolderDto> toEmailFolderDto(List<EmailFolder> folderList) {
List<EmailFolderDto> folderDtoList = new ArrayList<>();
if (CollectionUtil.isNotEmpty(folderList)){
for (EmailFolder emailFolder : folderList) {
EmailFolderDto folder = EmailFolderDto.builder()
.folderId(emailFolder.getFolderId())
.folderName(emailFolder.getFolderName())
.sort(emailFolder.getSort())
.build();
folderDtoList.add(folder);
}
}
return folderDtoList;
}
}
package com.zq.email.service.impl;
import com.zq.email.entity.EmailLabel;
import com.zq.email.mapper.EmailLabelMapper;
import com.zq.email.service.IEmailLabelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Service
public class EmailLabelServiceImpl extends ServiceImpl<EmailLabelMapper, EmailLabel> implements IEmailLabelService {
}
package com.zq.email.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.utils.AssertUtils;
import com.zq.common.utils.TokenUtils;
import com.zq.common.vo.OnlineUserDto;
import com.zq.email.constants.EmailConstant;
import com.zq.email.entity.EmailContent;
import com.zq.email.entity.EmailPerson;
import com.zq.email.enums.EmailFolderEnum;
import com.zq.email.enums.WhetherEnum;
import com.zq.email.mapper.EmailPersonMapper;
import com.zq.email.service.IEmailContentService;
import com.zq.email.service.IEmailPersonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.email.utils.DateUtils;
import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailReqVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author chentianzhong
* @since 2023-03-06
*/
@Service
@RequiredArgsConstructor
public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, EmailPerson> implements IEmailPersonService {
private final IEmailContentService emailContentService;
@Override
public Integer emailCount(EmailReqVo vo) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
Integer count = this.lambdaQuery()
.eq(EmailPerson::getUserId, adminContext.getUserId())
.eq(vo.getFolderId()!=null, EmailPerson::getFolderId, vo.getFolderId())
.eq(vo.getPersonType()!=null, EmailPerson::getPersonType, vo.getPersonType())
.eq(vo.getIsPerson()!=null, EmailPerson::getIsPerson, vo.getIsPerson())
.eq(vo.getIsSend()!=null, EmailPerson::getIsSend, vo.getIsSend()).count();
return count!=null?count:0;
}
@Override
public Page<EmailPerson> emailPage(EmailReqVo vo) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
Page<EmailPerson> page = new Page<>(vo.getPage(), vo.getSize());
page.setSearchCount(false).setOptimizeCountSql(false);
LambdaQueryChainWrapper<EmailPerson> eq = this.lambdaQuery()
.eq(EmailPerson::getUserId, adminContext.getUserId())
.eq(vo.getFolderId()!=null, EmailPerson::getFolderId, vo.getFolderId())
.eq(vo.getPersonType()!=null, EmailPerson::getPersonType, vo.getPersonType())
.eq(vo.getIsPerson()!=null, EmailPerson::getIsPerson, vo.getIsPerson())
.eq(vo.getIsSend()!=null, EmailPerson::getIsSend, vo.getIsSend());
if (DateUtils.getRangeStart(vo.getSearchRange()) !=null){
eq.ge(EmailPerson::getSendTime, DateUtils.getRangeStart(vo.getSearchRange()));
eq.le(EmailPerson::getSendTime, LocalDateTime.now());
}
page = this.page(page, eq);
if (page!=null && CollectionUtil.isNotEmpty(page.getRecords())){
for (EmailPerson record : page.getRecords()) {
record.setEmailContent(this.emailContentService.getById(record.getEmailContentId()));
}
}
return page;
}
@Override
public void emailEditVo(EmailEditVo vo) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
//邮件
EmailContent content = emailContentService.saveContent(vo, adminContext);
//附件
if (CollectionUtil.isNotEmpty(vo.getFileId())){
}
//person,先删除
this.lambdaUpdate().eq(EmailPerson::getEmailContentId, content.getId()).remove();
//增加收件人
if (CollectionUtil.isNotEmpty(vo.getReceiver())){
this.saveEmailReceiver(vo.getReceiver(), content, vo);
}
//增加收件部门
if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())){
this.saveEmailReceiveDept(vo.getReceiveDeptList(), content, vo);
}
}
private void saveEmailReceiveDept(List<Long> receiveDeptList, EmailContent content, EmailEditVo vo) {
}
private void saveEmailReceiver(List<Long> receiver, EmailContent content, EmailEditVo vo) {
}
}
......@@ -15,14 +15,14 @@ import java.util.List;
// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
public class CodeGenerator {
public static String url = "jdbc:kingbase8://172.18.3.137:54321/SEAL_PLATFOMR";
public static String url = "jdbc:kingbase8://172.18.4.84:54321/EMAIL_NEW";
public static String driver = "com.kingbase8.Driver";
public static String username = "SYSTEM";
public static String username = "oa_system";
public static String password = "123456";
public static String module = "sealPlatform";
public static String module = "email";
public static String parent = "com.zq";
public static String[] tables = {"COURT_CERT","COURT_SEAL","REVOKE_SEAL_RECORD","SEAL_SYSTEM_INFO","UNIFY_SEAL","UNIFY_SEAL_FILE"};
public static String[] tables = {"business_system","email_attach","email_content","email_folder","email_label","email_person"};
public static void main(String[] args) {
// 代码生成器
......
package com.zq.email.utils;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zq.email.entity.EmailPerson;
import com.zq.email.enums.SearchRangeEnum;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.function.Consumer;
public class DateUtils {
......@@ -14,4 +21,25 @@ public class DateUtils {
return flag;
}
/**
* 获取xx月之间某一天 凌晨0点
* @param monthNum
* @return
*/
public static Consumer<LambdaQueryWrapper<EmailPerson>> getRangeStart(Integer monthNum) {
LocalDateTime localDateTime = null;
if (monthNum.equals(SearchRangeEnum.LAST_THREE_MONTHS.getKey())){
localDateTime = DateUtil.offsetMonth(new Date(), -3).toLocalDateTime();
}else if (monthNum.equals(SearchRangeEnum.LAST_SIX_MONTHS.getKey())){
localDateTime = DateUtil.offsetMonth(new Date(), -6).toLocalDateTime();
}else if (monthNum.equals(SearchRangeEnum.LAST_ONE_YEAR.getKey())){
localDateTime = DateUtil.offsetMonth(new Date(), -12).toLocalDateTime();
}else{
localDateTime = null;
}
return localDateTime;
}
}
package com.zq.email.utils;
import com.zq.email.properties.SmsProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @author wilmiam
* @since 2022-12-10 17:09
*/
@Slf4j
@Component
public class SmsUtil {
@Resource
public SmsProperties smsProperties;
// /**
// * 发送短信
// *
// * @return
// */
// public ResultVo sendSms(Map<String, Object> params) {
// ResultVo resultVo = ResultVo.success();
// if ("wantest".equals(active) || "wanpro".equals(active)) {
// String url = smsConfig.getOutsideUrl() + "/outside/send";
// resultVo = sendRequest(url, params);
// }
// if ("test".equals(active) || "product".equals(active)) {
// String url = smsConfig.getInsideUrl() + "/inside/send";
// resultVo = sendRequest(url, params);
// }
// return resultVo;
// }
//
// /**
// * 发送批量短信
// *
// * @return
// */
// public ResultVo sendBatchSms(Map<String, Object> params) {
// ResultVo resultVo = ResultVo.success();
// if ("wantest".equals(active) || "wanpro".equals(active)) {
// String url = smsConfig.getOutsideUrl() + "/outside/sendBatch";
// resultVo = sendRequest(url, params);
// }
// if ("test".equals(active) || "product".equals(active)) {
// String url = smsConfig.getInsideUrl() + "/inside/sendBatch";
// resultVo = sendRequest(url, params);
// }
// return resultVo;
// }
//
// private ResultVo sendRequest(String url, Map<String, Object> params) {
// log.debug("发送短信请求 => {} \nRequest Body:\n\t{}\n", url, UrlQuery.of(params));
//
// HttpRequest request = HttpUtil.createPost(url)
// .header("APP_ID", smsConfig.getAppId())
// .header("APP_KEY", smsConfig.getAppKey())
// .body(JSONUtil.toJsonStr(params));
//
// HttpResponse response;
// try {
// response = request.execute();
// } catch (Exception e) {
// log.error("调用短信接口失败", e);
// return ResultVo.fail("调用短信接口失败:" + e.getMessage());
// }
//
// String body = response.body();
//
// log.debug("发送短信响应 => {}", body);
//
// try {
// return JSONUtil.toBean(body, ResultVo.class);
// } catch (Exception e) {
// log.error("调用短信接口解析失败", e);
// return ResultVo.fail("调用短信接口失败:" + e.getMessage());
// }
// }
}
package com.zq.email.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Api("新建邮件对应VO")
@Data
public class EmailEditVo {
@ApiModelProperty("邮箱id")
private Long id;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("内容")
private String content;
@ApiModelProperty("重要程度")
private Integer degree;
@ApiModelProperty("收件人")
private List<Long> receiver;
@ApiModelProperty("收件部门")
private List<Long> receiveDeptList;
@ApiModelProperty("提醒方式")
private List<Integer> remind;
@ApiModelProperty("附件id")
private List<String> fileId;
@ApiModelProperty("回复短信id")
private Long replId;
@ApiModelProperty("是否任务邮件")
private Boolean isTask;
@ApiModelProperty("是否发送 0:发件箱 1:发送")
private Integer isSend;
}
package com.zq.email.vo;
import com.zq.common.vo.PageReqVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.enums.EmailFolderEnum;
import com.zq.email.enums.WhetherEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@ApiModel(description = "收件箱前端Vo")
@Data
public class EmailReqVo extends PageReqVo {
@ApiModelProperty(value = "文件夹ID,默认收件箱")
private Integer folderId = EmailFolderEnum.FOLDER_INBOX.getKey();
@ApiModelProperty("人员类型, 默认接收人")
private String personType = EmailConstant.TYPE_EMAIL_RECEIVE;
@ApiModelProperty("是否个人邮件,默认是")
private Integer isPerson = WhetherEnum.YES.getKey();
@ApiModelProperty("是否已发送, 默认是")
private Integer isSend = WhetherEnum.YES.getKey();
@ApiModelProperty("查询范围,默认最近三个月")
private Integer searchRange;
}
package com.zq.email.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@ApiModel(description = "收件箱前端Vo")
@Data
public class InboxReqVo {
@ApiModelProperty("用户ID")
private Long userId;
@ApiModelProperty("邮件id集合")
private List<Long> idList;
@ApiModelProperty("文件夹ID")
private Integer folderId;
@ApiModelProperty("人员类型")
private String personType;
@ApiModelProperty("邮件类型")
private String emailType;
@ApiModelProperty("发送状态")
//"发送状态:0未发送/1已发送"
private String sendState;
@ApiModelProperty("labelId 标签id")
private Long labelId;
@ApiModelProperty("年度")
private Integer year;
@ApiModelProperty("开始")
private Date startDate;
@ApiModelProperty("结束")
private Date endDate;
private int page;
private int size;
private String isReade;
private String isDept;
private String sendTime;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.BusinessSystemMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailAttachMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailContentMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailFolderMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailLabelMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailPersonMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment