feat(oa): 添加知识管理和邮件功能模块

- 新增知识分类和知识文章的完整CRUD接口- 实现知识文章预览组件,支持富文本和附件展示
- 添加动态邮件配置功能,支持多种邮箱类型自动识别
- 实现邮件模板管理功能,提供多种商务邮件模板- 添加邮件发送功能,支持批量发送和附件上传
- 完善邮件工具类,支持富文本、附件和内嵌图片发送- 新增发件人邮箱账号管理功能
- 添加家具信息管理相关接口- 配置默认邮件服务参数
This commit is contained in:
JR
2025-10-22 22:36:10 +08:00
parent 429081460a
commit a8b0206cce
61 changed files with 7055 additions and 0 deletions

View File

@@ -97,6 +97,19 @@ spring:
deserialization:
# 允许对象忽略json中不存在的属性
fail_on_unknown_properties: false
mail:
host: smtp.163.com
port: 465
username: dummy@dummy.com # 占位用,随便写
password: dummy # 占位用,随便写
properties:
mail:
smtp:
auth: true
ssl:
enable: true
starttls:
enable: true
# Sa-Token配置
sa-token:

View File

@@ -21,6 +21,29 @@
<groupId>com.gear</groupId>
<artifactId>gear-common</artifactId>
</dependency>
<!-- 邮件发送相关依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.20</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dm</artifactId>
<version>3.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.larksuite.oapi</groupId>
<artifactId>oapi-sdk</artifactId>
<version>2.4.19</version>
<scope>compile</scope>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>

View File

@@ -0,0 +1,201 @@
package com.gear.oa.config;
import com.gear.oa.domain.OaEmailAccount;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import java.util.Properties;
/**
* 动态邮件配置类
* 支持根据不同的邮箱账号动态配置邮件发送器
*
* @author ruoyi
*/
@Configuration
public class DynamicMailConfig {
/**
* 根据邮箱账号创建JavaMailSender
*
* @param account 邮箱账号信息
* @return JavaMailSender
*/
public JavaMailSender createMailSender(OaEmailAccount account) {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
// 设置SMTP服务器 - 根据邮箱域名自动识别企业邮箱
String email = account.getEmail();
String smtpHost = getSmtpHostByEmail(email, account.getSmtpHost());
mailSender.setHost(smtpHost);
mailSender.setPort(account.getSmtpPort() == null ? 465 : account.getSmtpPort().intValue());
mailSender.setUsername(account.getEmail());
mailSender.setPassword(account.getPassword());
// 设置邮件属性
Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.connectiontimeout", "10000");
props.put("mail.smtp.timeout", "10000");
props.put("mail.smtp.writetimeout", "10000");
props.put("mail.debug", "false");
return mailSender;
}
/**
* 根据邮箱类型获取默认配置
*
* @param type 邮箱类型 0=网易 1=QQ 2=阿里云 3=飞书
* @return 默认配置
*/
public OaEmailAccount getDefaultConfig(int type) {
OaEmailAccount config = new OaEmailAccount();
switch (type) {
case 0: // 网易邮箱
config.setSmtpHost("smtp.163.com");
config.setSmtpPort(465L);
break;
case 1: // QQ邮箱
config.setSmtpHost("smtp.qq.com");
config.setSmtpPort(465L);
break;
case 2: // 阿里云邮箱
config.setSmtpHost("smtp.aliyun.com");
config.setSmtpPort(465L);
break;
case 3: // 飞书邮箱
config.setSmtpHost("smtp.feishu.cn");
config.setSmtpPort(465L);
break;
default:
config.setSmtpHost("smtp.163.com");
config.setSmtpPort(465L);
break;
}
return config;
}
// 测试方法
public static void main(String[] args) {
DynamicMailConfig config = new DynamicMailConfig();
// 测试各种邮箱类型
String[] testEmails = {
"test@freeqiye.com", // 网易企业邮箱
"test@qiye.163.com", // 网易企业邮箱
"test@163.com", // 网易个人邮箱
"test@126.com", // 网易126邮箱
"test@qq.com", // QQ邮箱
"test@exmail.qq.com", // QQ企业邮箱
"test@aliyun.com", // 阿里云邮箱
"test@sina.com", // 新浪邮箱
"test@vip.sina.com", // 新浪VIP邮箱
"test@sohu.com", // 搜狐邮箱
"test@139.com", // 139邮箱
"test@189.cn", // 189邮箱
"test@feishu.cn", // 飞书邮箱
"test@gmail.com", // Gmail邮箱
"test@outlook.com", // Outlook邮箱
"test@hotmail.com", // Hotmail邮箱
"test@company.com" // 自定义企业邮箱
};
System.out.println("邮箱SMTP服务器识别测试");
System.out.println("==========================================");
for (String email : testEmails) {
String smtpHost = config.getSmtpHostByEmail(email, null);
System.out.printf("%-20s -> %s%n", email, smtpHost);
}
System.out.println("==========================================");
}
/**
* 根据邮箱地址自动识别SMTP服务器
*
* @param email 邮箱地址
* @param defaultSmtpHost 默认SMTP服务器
* @return SMTP服务器地址
*/
public String getSmtpHostByEmail(String email, String defaultSmtpHost) {
if (email == null) {
return defaultSmtpHost != null ? defaultSmtpHost : "smtp.163.com";
}
String domain = email.toLowerCase();
// 网易企业邮箱
if (domain.contains("@freeqiye.com") || domain.contains("@qiye.163.com")) {
return "smtp.qiye.163.com";
}
// 网易个人邮箱
else if (domain.contains("@163.com")) {
return "smtp.163.com";
}
// 网易126邮箱
else if (domain.contains("@126.com")) {
return "smtp.126.com";
}
// QQ邮箱
else if (domain.contains("@qq.com")) {
return "smtp.qq.com";
}
// QQ企业邮箱
else if (domain.contains("@exmail.qq.com")) {
return "smtp.exmail.qq.com";
}
// 阿里云邮箱
else if (domain.contains("@aliyun.com")) {
return "smtp.aliyun.com";
}
// 新浪邮箱
else if (domain.contains("@sina.com")) {
return "smtp.sina.com";
}
// 新浪VIP邮箱
else if (domain.contains("@vip.sina.com")) {
return "smtp.vip.sina.com";
}
// 搜狐邮箱
else if (domain.contains("@sohu.com")) {
return "smtp.sohu.com";
}
// 139邮箱
else if (domain.contains("@139.com")) {
return "smtp.139.com";
}
// 189邮箱
else if (domain.contains("@189.cn")) {
return "smtp.189.cn";
}
// 飞书邮箱
else if (domain.contains("@feishu.cn")) {
return "smtp.feishu.cn";
}
// Gmail邮箱
else if (domain.contains("@gmail.com")) {
return "smtp.gmail.com";
}
// Outlook邮箱
else if (domain.contains("@outlook.com") || domain.contains("@hotmail.com")) {
return "smtp-mail.outlook.com";
}
// 企业邮箱通用域名识别(可以根据需要添加更多)
else if (domain.contains("@qiye.") || domain.contains("@corp.") || domain.contains("@enterprise.")) {
// 对于企业邮箱优先使用配置的SMTP服务器如果没有配置则使用通用企业邮箱SMTP
return defaultSmtpHost != null ? defaultSmtpHost : "smtp." + domain.split("@")[1];
}
// 如果都不匹配使用配置的SMTP服务器或默认服务器
return defaultSmtpHost != null ? defaultSmtpHost : "smtp.163.com";
}
}

View File

@@ -0,0 +1,111 @@
package com.gear.oa.controller;
import com.gear.common.annotation.Log;
import com.gear.common.annotation.RepeatSubmit;
import com.gear.common.core.controller.BaseController;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.domain.R;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import com.gear.common.enums.BusinessType;
import com.gear.common.utils.poi.ExcelUtil;
import com.gear.oa.domain.bo.OaEmailAccountBo;
import com.gear.oa.domain.request.EmailSendRequest;
import com.gear.oa.domain.vo.OaEmailAccountVo;
import com.gear.oa.service.IOaEmailAccountService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* 发件人邮箱账号管理
*
* @author Joshi
* @date 2025-07-10
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/emailAccount")
public class OaEmailAccountController extends BaseController {
private final IOaEmailAccountService iOaEmailAccountService;
/**
* 查询发件人邮箱账号管理列表
*/
@GetMapping("/list")
public TableDataInfo<OaEmailAccountVo> list(OaEmailAccountBo bo, PageQuery pageQuery) {
return iOaEmailAccountService.queryPageList(bo, pageQuery);
}
/**
* 导出发件人邮箱账号管理列表
*/
@Log(title = "发件人邮箱账号管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(OaEmailAccountBo bo, HttpServletResponse response) {
List<OaEmailAccountVo> list = iOaEmailAccountService.queryList(bo);
ExcelUtil.exportExcel(list, "发件人邮箱账号管理", OaEmailAccountVo.class, response);
}
/**
* 获取发件人邮箱账号管理详细信息
*
* @param emailId 主键
*/
@GetMapping("/{emailId}")
public R<OaEmailAccountVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long emailId) {
return R.ok(iOaEmailAccountService.queryById(emailId));
}
/**
* 新增发件人邮箱账号管理
*/
@Log(title = "发件人邮箱账号管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaEmailAccountBo bo) {
return toAjax(iOaEmailAccountService.insertByBo(bo));
}
/**
* 修改发件人邮箱账号管理
*/
@Log(title = "发件人邮箱账号管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaEmailAccountBo bo) {
return toAjax(iOaEmailAccountService.updateByBo(bo));
}
/**
* 删除发件人邮箱账号管理
*
* @param emailIds 主键串
*/
@Log(title = "发件人邮箱账号管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{emailIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] emailIds) {
return toAjax(iOaEmailAccountService.deleteWithValidByIds(Arrays.asList(emailIds), true));
}
/**
* 批量发送邮件支持网易企业邮箱、飞书SMTP
*/
@PostMapping("/sendBatchEmail")
public R<String> sendBatchEmail(@RequestBody EmailSendRequest request) {
// 调用Service批量发送邮件
String result = iOaEmailAccountService.sendBatchEmail(request);
return R.ok(result);
}
}

View File

@@ -0,0 +1,100 @@
package com.gear.oa.controller;
import com.gear.common.annotation.Log;
import com.gear.common.annotation.RepeatSubmit;
import com.gear.common.core.controller.BaseController;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.domain.R;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import com.gear.common.enums.BusinessType;
import com.gear.common.utils.poi.ExcelUtil;
import com.gear.oa.domain.bo.OaEmailTemplateBo;
import com.gear.oa.domain.vo.OaEmailTemplateVo;
import com.gear.oa.service.IOaEmailTemplateService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* 邮件模板
*
* @author ruoyi
* @date 2025-07-16
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/emailTemplate")
public class OaEmailTemplateController extends BaseController {
private final IOaEmailTemplateService iOaEmailTemplateService;
/**
* 查询邮件模板列表
*/
@GetMapping("/list")
public TableDataInfo<OaEmailTemplateVo> list(OaEmailTemplateBo bo, PageQuery pageQuery) {
return iOaEmailTemplateService.queryPageList(bo, pageQuery);
}
/**
* 导出邮件模板列表
*/
@Log(title = "邮件模板", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(OaEmailTemplateBo bo, HttpServletResponse response) {
List<OaEmailTemplateVo> list = iOaEmailTemplateService.queryList(bo);
ExcelUtil.exportExcel(list, "邮件模板", OaEmailTemplateVo.class, response);
}
/**
* 获取邮件模板详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<OaEmailTemplateVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(iOaEmailTemplateService.queryById(id));
}
/**
* 新增邮件模板
*/
@Log(title = "邮件模板", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaEmailTemplateBo bo) {
return toAjax(iOaEmailTemplateService.insertByBo(bo));
}
/**
* 修改邮件模板
*/
@Log(title = "邮件模板", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaEmailTemplateBo bo) {
return toAjax(iOaEmailTemplateService.updateByBo(bo));
}
/**
* 删除邮件模板
*
* @param ids 主键串
*/
@Log(title = "邮件模板", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(iOaEmailTemplateService.deleteWithValidByIds(Arrays.asList(ids), true));
}
}

View File

@@ -0,0 +1,100 @@
package com.gear.oa.controller;
import com.gear.common.annotation.Log;
import com.gear.common.annotation.RepeatSubmit;
import com.gear.common.core.controller.BaseController;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.domain.R;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import com.gear.common.enums.BusinessType;
import com.gear.common.utils.poi.ExcelUtil;
import com.gear.oa.domain.bo.OaFurnitureTableBo;
import com.gear.oa.domain.vo.OaFurnitureTableVo;
import com.gear.oa.service.IOaFurnitureTableService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* 家具
*
* @author liujingchao
* @date 2025-07-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/furnitureTable")
public class OaFurnitureTableController extends BaseController {
private final IOaFurnitureTableService iOaFurnitureTableService;
/**
* 查询家具列表
*/
@GetMapping("/list")
public TableDataInfo<OaFurnitureTableVo> list(OaFurnitureTableBo bo, PageQuery pageQuery) {
return iOaFurnitureTableService.queryPageList(bo, pageQuery);
}
/**
* 导出家具列表
*/
@Log(title = "家具", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(OaFurnitureTableBo bo, HttpServletResponse response) {
List<OaFurnitureTableVo> list = iOaFurnitureTableService.queryList(bo);
ExcelUtil.exportExcel(list, "家具", OaFurnitureTableVo.class, response);
}
/**
* 获取家具详细信息
*
* @param furnitureId 主键
*/
@GetMapping("/{furnitureId}")
public R<OaFurnitureTableVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long furnitureId) {
return R.ok(iOaFurnitureTableService.queryById(furnitureId));
}
/**
* 新增家具
*/
@Log(title = "家具", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaFurnitureTableBo bo) {
return toAjax(iOaFurnitureTableService.insertByBo(bo));
}
/**
* 修改家具
*/
@Log(title = "家具", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaFurnitureTableBo bo) {
return toAjax(iOaFurnitureTableService.updateByBo(bo));
}
/**
* 删除家具
*
* @param furnitureIds 主键串
*/
@Log(title = "家具", businessType = BusinessType.DELETE)
@DeleteMapping("/{furnitureIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] furnitureIds) {
return toAjax(iOaFurnitureTableService.deleteWithValidByIds(Arrays.asList(furnitureIds), true));
}
}

View File

@@ -0,0 +1,118 @@
package com.gear.oa.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.gear.common.annotation.Log;
import com.gear.common.annotation.RepeatSubmit;
import com.gear.common.core.controller.BaseController;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.domain.R;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import com.gear.common.enums.BusinessType;
import com.gear.common.utils.poi.ExcelUtil;
import com.gear.oa.domain.SysOaArticle;
import com.gear.oa.domain.bo.SysOaArticleBo;
import com.gear.oa.domain.vo.SysOaArticleVo;
import com.gear.oa.service.ISysOaArticleService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* 知识管理
*
* @author huangxing
* @date 2024-01-17
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/article")
public class SysOaArticleController extends BaseController {
private final ISysOaArticleService iSysOaArticleService;
/**
* 查询知识管理列表
*/
@SaCheckPermission("oa:article:list")
@GetMapping("/list")
public TableDataInfo<SysOaArticleVo> list(SysOaArticleBo bo, PageQuery pageQuery) {
return iSysOaArticleService.queryPageList(bo, pageQuery);
}
/**
* 自定义查询知识管理列表
*/
@SaCheckPermission("oa:article:list")
@GetMapping("/listArticle")
public TableDataInfo<SysOaArticleVo> listArticle(SysOaArticleBo bo, PageQuery pageQuery) {
return iSysOaArticleService.selectArticlePageList(bo, pageQuery);
}
/**
* 导出知识管理列表
*/
@SaCheckPermission("oa:article:export")
@Log(title = "知识管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(SysOaArticleBo bo, HttpServletResponse response) {
List<SysOaArticleVo> list = iSysOaArticleService.queryList(bo);
ExcelUtil.exportExcel(list, "知识管理", SysOaArticleVo.class, response);
}
/**
* 获取知识管理详细信息
*
* @param articleId 主键
*/
@SaCheckPermission("oa:article:query")
@GetMapping("/{articleId}")
public R<SysOaArticle> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long articleId) {
SysOaArticle sysOaArticle = iSysOaArticleService.selectArticleById(articleId);
return R.ok(sysOaArticle);
}
/**
* 新增知识管理
*/
@SaCheckPermission("oa:article:add")
@Log(title = "知识管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOaArticleBo bo) {
return toAjax(iSysOaArticleService.insertByBo(bo));
}
/**
* 修改知识管理
*/
@SaCheckPermission("oa:article:edit")
@Log(title = "知识管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOaArticleBo bo) {
return toAjax(iSysOaArticleService.updateByBo(bo));
}
/**
* 删除知识管理
*
* @param articleIds 主键串
*/
@SaCheckPermission("oa:article:remove")
@Log(title = "知识管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{articleIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] articleIds) {
return toAjax(iSysOaArticleService.deleteWithValidByIds(Arrays.asList(articleIds), true));
}
}

View File

@@ -0,0 +1,106 @@
package com.gear.oa.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.gear.common.annotation.Log;
import com.gear.common.annotation.RepeatSubmit;
import com.gear.common.core.controller.BaseController;
import com.gear.common.core.domain.R;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import com.gear.common.enums.BusinessType;
import com.gear.common.utils.poi.ExcelUtil;
import com.gear.oa.domain.bo.SysOaCategoryBo;
import com.gear.oa.domain.vo.SysOaCategoryVo;
import com.gear.oa.service.ISysOaCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* 知识分类
*
* @author huangxing
* @date 2024-01-17
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/category")
public class SysOaCategoryController extends BaseController {
private final ISysOaCategoryService iSysOaCategoryService;
/**
* 查询知识分类列表
*/
@SaCheckPermission("oa:category:list")
@GetMapping("/list")
public R<List<SysOaCategoryVo>> list(SysOaCategoryBo bo) {
List<SysOaCategoryVo> list = iSysOaCategoryService.queryList(bo);
return R.ok(list);
}
/**
* 导出知识分类列表
*/
@SaCheckPermission("oa:category:export")
@Log(title = "知识分类", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(SysOaCategoryBo bo, HttpServletResponse response) {
List<SysOaCategoryVo> list = iSysOaCategoryService.queryList(bo);
ExcelUtil.exportExcel(list, "知识分类", SysOaCategoryVo.class, response);
}
/**
* 获取知识分类详细信息
*
* @param categoryId 主键
*/
@SaCheckPermission("oa:category:query")
@GetMapping("/{categoryId}")
public R<SysOaCategoryVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long categoryId) {
return R.ok(iSysOaCategoryService.queryById(categoryId));
}
/**
* 新增知识分类
*/
@SaCheckPermission("oa:category:add")
@Log(title = "知识分类", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOaCategoryBo bo) {
return toAjax(iSysOaCategoryService.insertByBo(bo));
}
/**
* 修改知识分类
*/
@SaCheckPermission("oa:category:edit")
@Log(title = "知识分类", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOaCategoryBo bo) {
return toAjax(iSysOaCategoryService.updateByBo(bo));
}
/**
* 删除知识分类
*
* @param categoryIds 主键串
*/
@SaCheckPermission("oa:category:remove")
@Log(title = "知识分类", businessType = BusinessType.DELETE)
@DeleteMapping("/{categoryIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] categoryIds) {
return toAjax(iSysOaCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true));
}
}

View File

@@ -0,0 +1,66 @@
package com.gear.oa.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 发件人邮箱账号管理对象 oa_email_account
*
* @author Joshi
* @date 2025-07-10
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oa_email_account")
public class OaEmailAccount extends BaseEntity {
private static final long serialVersionUID=1L;
/**
*
*/
@TableId(value = "email_id")
private Long emailId;
/**
* 邮箱账号
*/
private String email;
/**
* 邮箱授权码/密码SMTP方式用
*/
private String password;
/**
* SMTP服务器地址SMTP方式用
*/
private String smtpHost;
/**
* SMTP端口SMTP方式用
*/
private Long smtpPort;
/**
* API方式用accessKey
*/
private String accessKey;
/**
* API方式用secretKey
*/
private String secretKey;
/**
* 邮箱类型0网易 1QQ 2阿里云API 3SendGridAPI等
*/
private Long type;
/**
* 备注
*/
private String remark;
/**
* 删除标志0正常1已删除
*/
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,54 @@
package com.gear.oa.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 邮件模板对象 oa_email_template
*
* @author ruoyi
* @date 2025-07-16
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oa_email_template")
public class OaEmailTemplate extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "id")
private Long id;
/**
* 模板名称
*/
private String templateName;
/**
* 模板分类
*/
private String category;
/**
* 模板内容富文本HTML
*/
private String content;
/**
* 附件信息逗号分隔或JSON
*/
private String attachments;
/**
* 删除标志0正常1已删除
*/
@TableLogic
private Long delFlag;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,96 @@
package com.gear.oa.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 家具对象 oa_furniture_table
*
* @author liujingchao
* @date 2025-07-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oa_furniture_table")
public class OaFurnitureTable extends BaseEntity {
private static final long serialVersionUID=1L;
/**
*
*/
@TableId(value = "furniture_id")
private Long furnitureId;
/**
*
*/
private String companyName;
/**
*
*/
private String state;
/**
*
*/
private String procurementOfProducts;
/**
*
*/
private String contactGroup;
/**
*
*/
private String phone;
/**
*
*/
private String fax;
/**
*
*/
private String address;
/**
*
*/
private String zip;
/**
*
*/
private String email;
/**
*
*/
private String website;
/**
* 发送邮件次数
*/
private Long emailSendCount;
/**
* 上次发邮件时间
*/
private Date lastEmailSendTime;
/**
* 跟单人
*/
private String contactPerson;
/**
* 接收次数
*/
private Long receiveCount;
/**
* 删除标志0正常1已删除
*/
@TableLogic
private Integer delFlag;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,62 @@
package com.gear.oa.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 知识管理对象 sys_oa_article
*
* @author huangxing
* @date 2024-01-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_oa_article")
public class SysOaArticle extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 文章id
*/
@TableId(value = "article_id")
private Long articleId;
/**
* 文章分类
*/
private Long categoryId;
/**
* 文章标题
*/
private String articleTitle;
/**
* 副标题
*/
private String subhead;
/**
* 来源
*/
private String source;
/**
* 内容
*/
private String content;
/**
* 查看数
*/
private Integer checkNum;
/**
* 附件
*/
private String accessory;
/**
* 备注
*/
private String remark;
private SysOaCategory category;
}

View File

@@ -0,0 +1,40 @@
package com.gear.oa.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gear.common.core.domain.TreeEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 知识分类对象 sys_oa_category
*
* @author huangxing
* @date 2024-01-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_oa_category")
public class SysOaCategory extends TreeEntity<SysOaCategory> {
private static final long serialVersionUID=1L;
/**
* 产品id
*/
@TableId(value = "category_id")
private Long categoryId;
/**
* 分类名称
*/
private String categoryName;
/**
* 状态
*/
private String status;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,64 @@
package com.gear.oa.domain.bo;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 发件人邮箱账号管理业务对象 oa_email_account
*
* @author Joshi
* @date 2025-07-10
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OaEmailAccountBo extends BaseEntity {
/**
*
*/
private Long emailId;
/**
* 邮箱账号
*/
private String email;
/**
* 邮箱授权码/密码SMTP方式用
*/
private String password;
/**
* SMTP服务器地址SMTP方式用
*/
private String smtpHost;
/**
* SMTP端口SMTP方式用
*/
private Long smtpPort;
/**
* API方式用accessKey
*/
private String accessKey;
/**
* API方式用secretKey
*/
private String secretKey;
/**
* 邮箱类型0网易 1QQ 2阿里云API 3SendGridAPI等
*/
private Long type;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,49 @@
package com.gear.oa.domain.bo;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 邮件模板业务对象 oa_email_template
*
* @author ruoyi
* @date 2025-07-16
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OaEmailTemplateBo extends BaseEntity {
/**
* 主键
*/
private Long id;
/**
* 模板名称
*/
private String templateName;
/**
* 模板分类
*/
private String category;
/**
* 模板内容富文本HTML
*/
private String content;
/**
* 附件信息逗号分隔或JSON
*/
private String attachments;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,106 @@
package com.gear.oa.domain.bo;
import com.gear.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 家具业务对象 oa_furniture_table
*
* @author liujingchao
* @date 2025-07-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OaFurnitureTableBo extends BaseEntity {
/**
*
*/
private Long furnitureId;
/**
*
*/
private String companyName;
/**
*
*/
private String state;
/**
*
*/
private String procurementOfProducts;
/**
*
*/
private String contactGroup;
/**
*
*/
private String phone;
/**
*
*/
private String fax;
/**
*
*/
private String address;
/**
*
*/
private String zip;
/**
*
*/
private String email;
/**
*
*/
private String website;
/**
* 发送邮件次数
*/
private Long emailSendCount;
/**
* 上次发邮件时间
*/
private Date lastEmailSendTime;
/**
* 跟单人
*/
private String contactPerson;
/**
* 接收次数
*/
private Long receiveCount;
/**
* 备注
*/
private String remark;
/**
* 优质筛选true表示只查询邮箱不为空的记录
*/
private Boolean qualityFilter;
}

View File

@@ -0,0 +1,75 @@
package com.gear.oa.domain.bo;
import com.gear.common.core.domain.BaseEntity;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import com.gear.oa.domain.SysOaCategory;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 知识管理业务对象 sys_oa_article
*
* @author huangxing
* @date 2024-01-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysOaArticleBo extends BaseEntity {
/**
* 文章id
*/
@NotNull(message = "文章id不能为空", groups = { EditGroup.class })
private Long articleId;
/**
* 文章分类
*/
@NotNull(message = "文章分类不能为空", groups = { AddGroup.class, EditGroup.class })
private Long categoryId;
/**
* 文章标题
*/
@NotBlank(message = "文章标题不能为空", groups = { AddGroup.class, EditGroup.class })
private String articleTitle;
/**
* 副标题
*/
private String subhead;
/**
* 来源
*/
private String source;
/**
* 内容
*/
private String content;
/**
* 查看数
*/
private Integer checkNum;
/**
* 附件
*/
private String accessory;
/**
* 备注
*/
private String remark;
private SysOaCategory category;
}

View File

@@ -0,0 +1,47 @@
package com.gear.oa.domain.bo;
import com.gear.common.core.domain.TreeEntity;
import com.gear.common.core.validate.AddGroup;
import com.gear.common.core.validate.EditGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 知识分类业务对象 sys_oa_category
*
* @author huangxing
* @date 2024-01-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysOaCategoryBo extends TreeEntity<SysOaCategoryBo> {
/**
* 产品id
*/
@NotNull(message = "产品id不能为空", groups = { EditGroup.class })
private Long categoryId;
/**
* 分类名称
*/
@NotBlank(message = "分类名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String categoryName;
/**
* 状态
*/
@NotBlank(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
private String status;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,26 @@
package com.gear.oa.domain.request;
import lombok.Data;
import java.util.List;
/**
* 邮件批量发送请求参数
*/
@Data
public class EmailSendRequest {
/** 发件人邮箱账号ID */
private Long emailAccountId;
/** 收件人邮箱列表 */
private List<String> toList;
/** 邮件主题 */
private String subject;
/** 邮件正文 */
private String content;
/** 附件文件路径列表 */
private List<String> attachmentPaths;
/** 内嵌图片路径列表 */
private List<String> inlineImagePaths;
/** 家具ID列表发送邮件时关联的多个家具 */
private List<Long> furnitureIds;
}

View File

@@ -0,0 +1,81 @@
package com.gear.oa.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.gear.common.annotation.ExcelDictFormat;
import com.gear.common.convert.ExcelDictConvert;
import lombok.Data;
/**
* 发件人邮箱账号管理视图对象 oa_email_account
*
* @author Joshi
* @date 2025-07-10
*/
@Data
@ExcelIgnoreUnannotated
public class OaEmailAccountVo {
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "")
private Long emailId;
/**
* 邮箱账号
*/
@ExcelProperty(value = "邮箱账号")
private String email;
/**
* 邮箱授权码/密码SMTP方式用
*/
@ExcelProperty(value = "邮箱授权码/密码", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "S=MTP方式用")
private String password;
/**
* SMTP服务器地址SMTP方式用
*/
@ExcelProperty(value = "SMTP服务器地址", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "S=MTP方式用")
private String smtpHost;
/**
* SMTP端口SMTP方式用
*/
@ExcelProperty(value = "SMTP端口", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "S=MTP方式用")
private Long smtpPort;
/**
* API方式用accessKey
*/
@ExcelProperty(value = "API方式用accessKey")
private String accessKey;
/**
* API方式用secretKey
*/
@ExcelProperty(value = "API方式用secretKey")
private String secretKey;
/**
* 邮箱类型0网易 1QQ 2阿里云API 3SendGridAPI等
*/
@ExcelProperty(value = "邮箱类型", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=网易,1=QQ,2=阿里云API,3=SendGridAPI等")
private Long type;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}

View File

@@ -0,0 +1,61 @@
package com.gear.oa.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.gear.common.annotation.ExcelDictFormat;
import com.gear.common.convert.ExcelDictConvert;
import lombok.Data;
/**
* 邮件模板视图对象 oa_email_template
*
* @author ruoyi
* @date 2025-07-16
*/
@Data
@ExcelIgnoreUnannotated
public class OaEmailTemplateVo {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ExcelProperty(value = "主键")
private Long id;
/**
* 模板名称
*/
@ExcelProperty(value = "模板名称")
private String templateName;
/**
* 模板分类
*/
@ExcelProperty(value = "模板分类")
private String category;
/**
* 模板内容富文本HTML
*/
@ExcelProperty(value = "模板内容", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "富=文本HTML")
private String content;
/**
* 附件信息逗号分隔或JSON
*/
@ExcelProperty(value = "附件信息", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "逗=号分隔或JSON")
private String attachments;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}

View File

@@ -0,0 +1,119 @@
package com.gear.oa.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
/**
* 家具视图对象 oa_furniture_table
*
* @author liujingchao
* @date 2025-07-08
*/
@Data
@ExcelIgnoreUnannotated
public class OaFurnitureTableVo {
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "")
private Long furnitureId;
/**
*
*/
@ExcelProperty(value = "")
private String companyName;
/**
*
*/
@ExcelProperty(value = "")
private String state;
/**
*
*/
@ExcelProperty(value = "")
private String procurementOfProducts;
/**
*
*/
@ExcelProperty(value = "")
private String contactGroup;
/**
*
*/
@ExcelProperty(value = "")
private String phone;
/**
*
*/
@ExcelProperty(value = "")
private String fax;
/**
*
*/
@ExcelProperty(value = "")
private String address;
/**
*
*/
@ExcelProperty(value = "")
private String zip;
/**
*
*/
@ExcelProperty(value = "")
private String email;
/**
*
*/
@ExcelProperty(value = "")
private String website;
/**
* 发送邮件次数
*/
@ExcelProperty(value = "发送邮件次数")
private Long emailSendCount;
/**
* 上次发邮件时间
*/
@ExcelProperty(value = "上次发邮件时间")
private Date lastEmailSendTime;
/**
* 跟单人
*/
@ExcelProperty(value = "跟单人")
private String contactPerson;
/**
* 接收次数
*/
@ExcelProperty(value = "接收次数")
private Long receiveCount;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
}

View File

@@ -0,0 +1,81 @@
package com.gear.oa.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.gear.oa.domain.SysOaCategory;
import lombok.Data;
import java.util.Date;
/**
* 知识管理视图对象 sys_oa_article
*
* @author huangxing
* @date 2024-01-17
*/
@Data
@ExcelIgnoreUnannotated
public class SysOaArticleVo {
private static final long serialVersionUID = 1L;
/**
* 文章id
*/
@ExcelProperty(value = "文章id")
private Long articleId;
/**
* 文章分类
*/
@ExcelProperty(value = "文章分类")
private Long categoryId;
/**
* 文章标题
*/
@ExcelProperty(value = "文章标题")
private String articleTitle;
/**
* 文章标题
*/
@ExcelProperty(value = "文章副标题")
private String subhead;
/**
* 来源
*/
@ExcelProperty(value = "来源")
private String source;
/**
* 备注
*/
@ExcelProperty(value = "描述")
private String remark;
/**
* 查看数
*/
@ExcelProperty(value = "查看数")
private Integer checkNum;
/**
* 创建者
*/
@ExcelProperty(value = "创建者")
private String createBy;
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间")
private Date createTime;
@ExcelProperty(value = "分类实体")
private SysOaCategory category;
}

View File

@@ -0,0 +1,65 @@
package com.gear.oa.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
/**
* 知识分类视图对象 sys_oa_category
*
* @author huangxing
* @date 2024-01-17
*/
@Data
@ExcelIgnoreUnannotated
public class SysOaCategoryVo {
private static final long serialVersionUID = 1L;
/**
* 产品id
*/
@ExcelProperty(value = "产品id")
private Long categoryId;
/**
* 父级分类id
*/
@ExcelProperty(value = "父级分类id")
private Long parentId;
/**
* 分类名称
*/
@ExcelProperty(value = "分类名称")
private String categoryName;
/**
* 状态
*/
@ExcelProperty(value = "状态")
private String status;
/**
* 备注
*/
@ExcelProperty(value = "备注")
private String remark;
/**
* 创建者
*/
@ExcelProperty(value = "创建者")
private String createBy;
/**
* 创建时间
*/
@ExcelProperty(value = "创建时间")
private Date createTime;
}

View File

@@ -0,0 +1,15 @@
package com.gear.oa.mapper;
import com.gear.common.core.mapper.BaseMapperPlus;
import com.gear.oa.domain.OaEmailAccount;
import com.gear.oa.domain.vo.OaEmailAccountVo;
/**
* 发件人邮箱账号管理Mapper接口
*
* @author Joshi
* @date 2025-07-10
*/
public interface OaEmailAccountMapper extends BaseMapperPlus<OaEmailAccountMapper, OaEmailAccount, OaEmailAccountVo> {
}

View File

@@ -0,0 +1,15 @@
package com.gear.oa.mapper;
import com.gear.common.core.mapper.BaseMapperPlus;
import com.gear.oa.domain.OaEmailTemplate;
import com.gear.oa.domain.vo.OaEmailTemplateVo;
/**
* 邮件模板Mapper接口
*
* @author ruoyi
* @date 2025-07-16
*/
public interface OaEmailTemplateMapper extends BaseMapperPlus<OaEmailTemplateMapper, OaEmailTemplate, OaEmailTemplateVo> {
}

View File

@@ -0,0 +1,26 @@
package com.gear.oa.mapper;
import com.gear.common.core.mapper.BaseMapperPlus;
import com.gear.oa.domain.OaFurnitureTable;
import com.gear.oa.domain.vo.OaFurnitureTableVo;
import java.util.List;
/**
* 家具Mapper接口
*
* @author liujingchao
* @date 2025-07-08
*/
public interface OaFurnitureTableMapper extends BaseMapperPlus<OaFurnitureTableMapper, OaFurnitureTable, OaFurnitureTableVo> {
/**
* 邮件发送成功后,更新发送次数和上次发送时间
*/
int updateEmailSendInfo(Long furnitureId);
/**
* 根据家具ID列表批量查询邮箱地址
*/
List<String> selectEmailsByFurnitureIds(List<Long> furnitureIds);
}

View File

@@ -0,0 +1,32 @@
package com.gear.oa.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gear.common.annotation.DataColumn;
import com.gear.common.annotation.DataPermission;
import com.gear.common.core.mapper.BaseMapperPlus;
import com.gear.oa.domain.SysOaArticle;
import com.gear.oa.domain.vo.SysOaArticleVo;
import org.apache.ibatis.annotations.Param;
/**
* 知识管理Mapper接口
*
* @author huangxing
* @date 2024-01-17
*/
public interface SysOaArticleMapper extends BaseMapperPlus<SysOaArticleMapper, SysOaArticle, SysOaArticleVo> {
@DataPermission({
@DataColumn(key = "categoryName", value = "c.category_id"),
@DataColumn(key = "articleTitle", value = "a.article_id")
})
Page<SysOaArticleVo> selectArticlePageList(@Param("page") Page<SysOaArticle> page, @Param(Constants.WRAPPER)Wrapper<SysOaArticle> queryWrapper);
SysOaArticle selectArticleById(Long articleId);
}

View File

@@ -0,0 +1,15 @@
package com.gear.oa.mapper;
import com.gear.common.core.mapper.BaseMapperPlus;
import com.gear.oa.domain.SysOaCategory;
import com.gear.oa.domain.vo.SysOaCategoryVo;
/**
* 知识分类Mapper接口
*
* @author huangxing
* @date 2024-01-17
*/
public interface SysOaCategoryMapper extends BaseMapperPlus<SysOaCategoryMapper, SysOaCategory, SysOaCategoryVo> {
}

View File

@@ -0,0 +1,54 @@
package com.gear.oa.service;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.oa.domain.bo.OaEmailAccountBo;
import com.gear.oa.domain.request.EmailSendRequest;
import com.gear.oa.domain.vo.OaEmailAccountVo;
import java.util.Collection;
import java.util.List;
/**
* 发件人邮箱账号管理Service接口
*
* @author Joshi
* @date 2025-07-10
*/
public interface IOaEmailAccountService {
/**
* 查询发件人邮箱账号管理
*/
OaEmailAccountVo queryById(Long emailId);
/**
* 查询发件人邮箱账号管理列表
*/
TableDataInfo<OaEmailAccountVo> queryPageList(OaEmailAccountBo bo, PageQuery pageQuery);
/**
* 查询发件人邮箱账号管理列表
*/
List<OaEmailAccountVo> queryList(OaEmailAccountBo bo);
/**
* 新增发件人邮箱账号管理
*/
Boolean insertByBo(OaEmailAccountBo bo);
/**
* 修改发件人邮箱账号管理
*/
Boolean updateByBo(OaEmailAccountBo bo);
/**
* 校验并批量删除发件人邮箱账号管理信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 批量发送邮件支持网易企业邮箱、飞书SMTP
*/
String sendBatchEmail(EmailSendRequest request);
}

View File

@@ -0,0 +1,48 @@
package com.gear.oa.service;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.oa.domain.bo.OaEmailTemplateBo;
import com.gear.oa.domain.vo.OaEmailTemplateVo;
import java.util.Collection;
import java.util.List;
/**
* 邮件模板Service接口
*
* @author ruoyi
* @date 2025-07-16
*/
public interface IOaEmailTemplateService {
/**
* 查询邮件模板
*/
OaEmailTemplateVo queryById(Long id);
/**
* 查询邮件模板列表
*/
TableDataInfo<OaEmailTemplateVo> queryPageList(OaEmailTemplateBo bo, PageQuery pageQuery);
/**
* 查询邮件模板列表
*/
List<OaEmailTemplateVo> queryList(OaEmailTemplateBo bo);
/**
* 新增邮件模板
*/
Boolean insertByBo(OaEmailTemplateBo bo);
/**
* 修改邮件模板
*/
Boolean updateByBo(OaEmailTemplateBo bo);
/**
* 校验并批量删除邮件模板信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,48 @@
package com.gear.oa.service;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.oa.domain.bo.OaFurnitureTableBo;
import com.gear.oa.domain.vo.OaFurnitureTableVo;
import java.util.Collection;
import java.util.List;
/**
* 家具Service接口
*
* @author liujingchao
* @date 2025-07-08
*/
public interface IOaFurnitureTableService {
/**
* 查询家具
*/
OaFurnitureTableVo queryById(Long furnitureId);
/**
* 查询家具列表
*/
TableDataInfo<OaFurnitureTableVo> queryPageList(OaFurnitureTableBo bo, PageQuery pageQuery);
/**
* 查询家具列表
*/
List<OaFurnitureTableVo> queryList(OaFurnitureTableBo bo);
/**
* 新增家具
*/
Boolean insertByBo(OaFurnitureTableBo bo);
/**
* 修改家具
*/
Boolean updateByBo(OaFurnitureTableBo bo);
/**
* 校验并批量删除家具信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,52 @@
package com.gear.oa.service;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.oa.domain.SysOaArticle;
import com.gear.oa.domain.bo.SysOaArticleBo;
import com.gear.oa.domain.vo.SysOaArticleVo;
import java.util.Collection;
import java.util.List;
/**
* 知识管理Service接口
*
* @author huangxing
* @date 2024-01-17
*/
public interface ISysOaArticleService {
/**
* 查询知识管理
*/
SysOaArticle selectArticleById(Long articleId);
/**
* 查询知识管理列表
*/
TableDataInfo<SysOaArticleVo> queryPageList(SysOaArticleBo bo, PageQuery pageQuery);
/**
* 查询知识管理列表
*/
List<SysOaArticleVo> queryList(SysOaArticleBo bo);
TableDataInfo<SysOaArticleVo> selectArticlePageList(SysOaArticleBo bo, PageQuery pageQuery);
/**
* 新增知识管理
*/
Boolean insertByBo(SysOaArticleBo bo);
/**
* 修改知识管理
*/
Boolean updateByBo(SysOaArticleBo bo);
/**
* 校验并批量删除知识管理信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,42 @@
package com.gear.oa.service;
import com.gear.oa.domain.bo.SysOaCategoryBo;
import com.gear.oa.domain.vo.SysOaCategoryVo;
import java.util.Collection;
import java.util.List;
/**
* 知识分类Service接口
*
* @author huangxing
* @date 2024-01-17
*/
public interface ISysOaCategoryService {
/**
* 查询知识分类
*/
SysOaCategoryVo queryById(Long categoryId);
/**
* 查询知识分类列表
*/
List<SysOaCategoryVo> queryList(SysOaCategoryBo bo);
/**
* 新增知识分类
*/
Boolean insertByBo(SysOaCategoryBo bo);
/**
* 修改知识分类
*/
Boolean updateByBo(SysOaCategoryBo bo);
/**
* 校验并批量删除知识分类信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,331 @@
package com.gear.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dm.model.v20151123.SingleSendMailRequest;
import com.aliyuncs.dm.model.v20151123.SingleSendMailResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lark.oapi.Client;
import com.lark.oapi.service.mail.v1.model.MailAddress;
import com.lark.oapi.service.mail.v1.model.Message;
import com.lark.oapi.service.mail.v1.model.SendUserMailboxMessageReq;
import com.lark.oapi.service.mail.v1.model.SendUserMailboxMessageResp;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.utils.StringUtils;
import com.gear.oa.config.DynamicMailConfig;
import com.gear.oa.domain.OaEmailAccount;
import com.gear.oa.domain.bo.OaEmailAccountBo;
import com.gear.oa.domain.request.EmailSendRequest;
import com.gear.oa.domain.vo.OaEmailAccountVo;
import com.gear.oa.mapper.OaEmailAccountMapper;
import com.gear.oa.mapper.OaFurnitureTableMapper;
import com.gear.oa.service.IOaEmailAccountService;
import com.gear.oa.utils.EmailUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 发件人邮箱账号管理Service业务层处理
*
* @author Joshi
* @date 2025-07-10
*/
@RequiredArgsConstructor
@Service
public class OaEmailAccountServiceImpl implements IOaEmailAccountService {
private final OaEmailAccountMapper baseMapper;
@Autowired
private EmailUtil emailUtil;
@Autowired
private OaFurnitureTableMapper oaFurnitureTableMapper;
@Autowired
private DynamicMailConfig dynamicMailConfig;
/**
* 查询发件人邮箱账号管理
*/
@Override
public OaEmailAccountVo queryById(Long emailId){
return baseMapper.selectVoById(emailId);
}
/**
* 查询发件人邮箱账号管理列表
*/
@Override
public TableDataInfo<OaEmailAccountVo> queryPageList(OaEmailAccountBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<OaEmailAccount> lqw = buildQueryWrapper(bo);
Page<OaEmailAccountVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询发件人邮箱账号管理列表
*/
@Override
public List<OaEmailAccountVo> queryList(OaEmailAccountBo bo) {
LambdaQueryWrapper<OaEmailAccount> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<OaEmailAccount> buildQueryWrapper(OaEmailAccountBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<OaEmailAccount> lqw = Wrappers.lambdaQuery();
lqw.eq(StringUtils.isNotBlank(bo.getEmail()), OaEmailAccount::getEmail, bo.getEmail());
lqw.eq(StringUtils.isNotBlank(bo.getPassword()), OaEmailAccount::getPassword, bo.getPassword());
lqw.eq(StringUtils.isNotBlank(bo.getSmtpHost()), OaEmailAccount::getSmtpHost, bo.getSmtpHost());
lqw.eq(bo.getSmtpPort() != null, OaEmailAccount::getSmtpPort, bo.getSmtpPort());
lqw.eq(StringUtils.isNotBlank(bo.getAccessKey()), OaEmailAccount::getAccessKey, bo.getAccessKey());
lqw.eq(StringUtils.isNotBlank(bo.getSecretKey()), OaEmailAccount::getSecretKey, bo.getSecretKey());
lqw.eq(bo.getType() != null, OaEmailAccount::getType, bo.getType());
return lqw;
}
/**
* 新增发件人邮箱账号管理
*/
@Override
public Boolean insertByBo(OaEmailAccountBo bo) {
OaEmailAccount add = BeanUtil.toBean(bo, OaEmailAccount.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setEmailId(add.getEmailId());
}
return flag;
}
/**
* 修改发件人邮箱账号管理
*/
@Override
public Boolean updateByBo(OaEmailAccountBo bo) {
OaEmailAccount update = BeanUtil.toBean(bo, OaEmailAccount.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(OaEmailAccount entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除发件人邮箱账号管理
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
@Override
public String sendBatchEmail(EmailSendRequest request) {
OaEmailAccount account = baseMapper.selectById(request.getEmailAccountId());
if (account == null) {
return "发件人邮箱账号不存在";
}
// 输出SMTP服务器信息
String smtpHost = dynamicMailConfig.getSmtpHostByEmail(account.getEmail(), account.getSmtpHost());
System.out.println("使用邮箱: " + account.getEmail() + ", SMTP服务器: " + smtpHost);
List<String> emailList = oaFurnitureTableMapper.selectEmailsByFurnitureIds(request.getFurnitureIds());
int type = account.getType() == null ? -1 : account.getType().intValue();
int success = 0, fail = 0;
StringBuilder failList = new StringBuilder();
// 处理附件如果是http/https链接先下载
List<File> attachmentFiles = new ArrayList<>();
try {
if (request.getAttachmentPaths() != null && !request.getAttachmentPaths().isEmpty()) {
for (String path : request.getAttachmentPaths()) {
if (path.startsWith("http://") || path.startsWith("https://")) {
attachmentFiles.add(EmailUtil.downloadUrlToTempFile(path));
} else {
attachmentFiles.add(new File(path));
}
}
}
if (type == 0 || type == 1) {
for (String to : emailList) {
try {
boolean isHtml = request.getContent() != null &&
(request.getContent().contains("<html") ||
request.getContent().contains("<div") ||
request.getContent().contains("<p>"));
boolean hasAttachments = !attachmentFiles.isEmpty();
boolean hasInlineImages = request.getInlineImagePaths() != null && !request.getInlineImagePaths().isEmpty();
if (hasAttachments && hasInlineImages) {
if (isHtml) {
String processedContent = emailUtil.processHtmlWithInlineImages(request.getContent(), request.getInlineImagePaths());
emailUtil.sendHtmlMailWithAttachmentsAndDynamicConfig(account, to, request.getSubject(), processedContent, toPathList(attachmentFiles));
} else {
emailUtil.sendMailWithAttachmentAndDynamicConfig(account, to, request.getSubject(), request.getContent(), attachmentFiles.get(0).getAbsolutePath());
}
} else if (hasAttachments) {
if (isHtml) {
emailUtil.sendHtmlMailWithAttachmentsAndDynamicConfig(account, to, request.getSubject(), request.getContent(), toPathList(attachmentFiles));
} else {
emailUtil.sendMailWithAttachmentAndDynamicConfig(account, to, request.getSubject(), request.getContent(), attachmentFiles.get(0).getAbsolutePath());
}
} else if (hasInlineImages) {
if (isHtml) {
emailUtil.sendHtmlMailWithInlineImagesAndDynamicConfig(account, to, request.getSubject(), request.getContent(), request.getInlineImagePaths());
} else {
emailUtil.sendMailWithDynamicConfig(account, to, request.getSubject(), request.getContent());
}
} else {
if (isHtml) {
emailUtil.sendHtmlMailWithDynamicConfig(account, to, request.getSubject(), request.getContent());
} else {
emailUtil.sendMailWithDynamicConfig(account, to, request.getSubject(), request.getContent());
}
}
success++;
} catch (Exception e) {
fail++;
failList.append(to).append(", ");
}
}
} else if (type == 2) {
for (String to : emailList) {
try {
boolean result = sendAliyunMail(account, to, request.getSubject(), request.getContent());
if (result) {
success++;
} else {
fail++;
failList.append(to).append(", ");
}
} catch (Exception e) {
fail++;
failList.append(to).append(", ");
}
}
} else if (type == 3) {
for (String to : emailList) {
try {
boolean result = sendFeishuMail(account, to, request.getSubject(), request.getContent());
if (result) {
success++;
} else {
fail++;
failList.append(to).append(", ");
}
} catch (Exception e) {
fail++;
failList.append(to).append(", ");
}
}
} else {
return "不支持的邮箱类型";
}
} catch (Exception e) {
return "附件处理失败:" + e.getMessage();
} finally {
// 删除所有临时文件
for (File file : attachmentFiles) {
if (file != null && file.exists() && file.getName().startsWith("mail_attach_")) {
file.delete();
}
}
}
if (success > 0 && request.getFurnitureIds() != null) {
for (Long furnitureId : request.getFurnitureIds()) {
oaFurnitureTableMapper.updateEmailSendInfo(furnitureId);
}
}
return "发送成功" + success + "封,失败" + fail + "" + (fail > 0 ? (",失败邮箱:" + failList) : "");
}
// 辅助方法File列表转路径列表
private List<String> toPathList(List<File> files) {
List<String> paths = new ArrayList<>();
for (File f : files) {
if (f != null) paths.add(f.getAbsolutePath());
}
return paths;
}
private boolean sendAliyunMail(OaEmailAccount account, String to, String subject, String content) {
try {
DefaultProfile profile = DefaultProfile.getProfile(
"cn-hangzhou",
account.getAccessKey(),
account.getSecretKey()
);
IAcsClient client = new DefaultAcsClient(profile);
SingleSendMailRequest request = new SingleSendMailRequest();
request.setAccountName(account.getEmail());
request.setFromAlias("发件人昵称");
request.setAddressType(1);
request.setReplyToAddress(true);
request.setToAddress(to);
request.setSubject(subject);
request.setHtmlBody(content);
SingleSendMailResponse response = client.getAcsResponse(request);
//打印这个响应
System.out.println(response.getRequestId());
return true;
} catch (ClientException e) {
// 打印日志 e.getErrCode() + e.getErrMsg()
return false;
}
}
private boolean sendFeishuMail(OaEmailAccount account, String to, String subject, String content) {
try {
// 1. 构建飞书Client
Client client = Client.newBuilder(account.getAccessKey(), account.getSecretKey()).build();
// 2. 构建收件人
MailAddress[] toList = new MailAddress[]{
MailAddress.newBuilder().mailAddress(to).name(to).build()
};
// 3. 构建请求
SendUserMailboxMessageReq req = SendUserMailboxMessageReq.newBuilder()
.userMailboxId("me") // 推荐用 "me"
.message(Message.newBuilder()
.subject(subject)
.to(toList)
.bodyHtml(content)
.build())
.build();
// 4. 发送请求
SendUserMailboxMessageResp resp = client.mail().v1().userMailboxMessage().send(req);
// 5. 判断结果
if (!resp.success()) {
// 可加日志 resp.getCode(), resp.getMsg()
return false;
}
return true;
} catch (Exception e) {
// 可加日志 e.getMessage()
return false;
}
}
}

View File

@@ -0,0 +1,112 @@
package com.gear.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.utils.StringUtils;
import com.gear.oa.domain.OaEmailTemplate;
import com.gear.oa.domain.bo.OaEmailTemplateBo;
import com.gear.oa.domain.vo.OaEmailTemplateVo;
import com.gear.oa.mapper.OaEmailTemplateMapper;
import com.gear.oa.service.IOaEmailTemplateService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 邮件模板Service业务层处理
*
* @author ruoyi
* @date 2025-07-16
*/
@RequiredArgsConstructor
@Service
public class OaEmailTemplateServiceImpl implements IOaEmailTemplateService {
private final OaEmailTemplateMapper baseMapper;
/**
* 查询邮件模板
*/
@Override
public OaEmailTemplateVo queryById(Long id){
return baseMapper.selectVoById(id);
}
/**
* 查询邮件模板列表
*/
@Override
public TableDataInfo<OaEmailTemplateVo> queryPageList(OaEmailTemplateBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<OaEmailTemplate> lqw = buildQueryWrapper(bo);
Page<OaEmailTemplateVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询邮件模板列表
*/
@Override
public List<OaEmailTemplateVo> queryList(OaEmailTemplateBo bo) {
LambdaQueryWrapper<OaEmailTemplate> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<OaEmailTemplate> buildQueryWrapper(OaEmailTemplateBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<OaEmailTemplate> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getTemplateName()), OaEmailTemplate::getTemplateName, bo.getTemplateName());
lqw.eq(StringUtils.isNotBlank(bo.getCategory()), OaEmailTemplate::getCategory, bo.getCategory());
lqw.eq(StringUtils.isNotBlank(bo.getContent()), OaEmailTemplate::getContent, bo.getContent());
lqw.eq(StringUtils.isNotBlank(bo.getAttachments()), OaEmailTemplate::getAttachments, bo.getAttachments());
return lqw;
}
/**
* 新增邮件模板
*/
@Override
public Boolean insertByBo(OaEmailTemplateBo bo) {
OaEmailTemplate add = BeanUtil.toBean(bo, OaEmailTemplate.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改邮件模板
*/
@Override
public Boolean updateByBo(OaEmailTemplateBo bo) {
OaEmailTemplate update = BeanUtil.toBean(bo, OaEmailTemplate.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(OaEmailTemplate entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除邮件模板
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -0,0 +1,131 @@
package com.gear.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.utils.StringUtils;
import com.gear.oa.domain.OaFurnitureTable;
import com.gear.oa.domain.bo.OaFurnitureTableBo;
import com.gear.oa.domain.vo.OaFurnitureTableVo;
import com.gear.oa.mapper.OaFurnitureTableMapper;
import com.gear.oa.service.IOaFurnitureTableService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 家具Service业务层处理
*
* @author liujingchao
* @date 2025-07-08
*/
@RequiredArgsConstructor
@Service
public class OaFurnitureTableServiceImpl implements IOaFurnitureTableService {
private final OaFurnitureTableMapper baseMapper;
/**
* 查询家具
*/
@Override
public OaFurnitureTableVo queryById(Long furnitureId){
return baseMapper.selectVoById(furnitureId);
}
/**
* 查询家具列表
*/
@Override
public TableDataInfo<OaFurnitureTableVo> queryPageList(OaFurnitureTableBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<OaFurnitureTable> lqw = buildQueryWrapper(bo);
Page<OaFurnitureTableVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询家具列表
*/
@Override
public List<OaFurnitureTableVo> queryList(OaFurnitureTableBo bo) {
LambdaQueryWrapper<OaFurnitureTable> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<OaFurnitureTable> buildQueryWrapper(OaFurnitureTableBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<OaFurnitureTable> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), OaFurnitureTable::getCompanyName, bo.getCompanyName());
lqw.eq(StringUtils.isNotBlank(bo.getState()), OaFurnitureTable::getState, bo.getState());
lqw.eq(StringUtils.isNotBlank(bo.getProcurementOfProducts()), OaFurnitureTable::getProcurementOfProducts, bo.getProcurementOfProducts());
lqw.eq(StringUtils.isNotBlank(bo.getContactGroup()), OaFurnitureTable::getContactGroup, bo.getContactGroup());
lqw.eq(StringUtils.isNotBlank(bo.getPhone()), OaFurnitureTable::getPhone, bo.getPhone());
lqw.eq(StringUtils.isNotBlank(bo.getFax()), OaFurnitureTable::getFax, bo.getFax());
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), OaFurnitureTable::getAddress, bo.getAddress());
lqw.eq(StringUtils.isNotBlank(bo.getZip()), OaFurnitureTable::getZip, bo.getZip());
lqw.eq(StringUtils.isNotBlank(bo.getEmail()), OaFurnitureTable::getEmail, bo.getEmail());
lqw.eq(StringUtils.isNotBlank(bo.getWebsite()), OaFurnitureTable::getWebsite, bo.getWebsite());
lqw.eq(bo.getEmailSendCount() != null, OaFurnitureTable::getEmailSendCount, bo.getEmailSendCount());
lqw.eq(bo.getLastEmailSendTime() != null, OaFurnitureTable::getLastEmailSendTime, bo.getLastEmailSendTime());
lqw.eq(StringUtils.isNotBlank(bo.getContactPerson()), OaFurnitureTable::getContactPerson, bo.getContactPerson());
lqw.eq(bo.getReceiveCount() != null, OaFurnitureTable::getReceiveCount, bo.getReceiveCount());
// 优质筛选:只查询邮箱不为空的记录
if (Boolean.TRUE.equals(bo.getQualityFilter())) {
lqw.isNotNull(OaFurnitureTable::getEmail);
lqw.ne(OaFurnitureTable::getEmail, "");
}
// 按邮件发送次数升序排序,发送次数少的靠前显示
lqw.orderByAsc(OaFurnitureTable::getEmailSendCount);
return lqw;
}
/**
* 新增家具
*/
@Override
public Boolean insertByBo(OaFurnitureTableBo bo) {
OaFurnitureTable add = BeanUtil.toBean(bo, OaFurnitureTable.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setFurnitureId(add.getFurnitureId());
}
return flag;
}
/**
* 修改家具
*/
@Override
public Boolean updateByBo(OaFurnitureTableBo bo) {
OaFurnitureTable update = BeanUtil.toBean(bo, OaFurnitureTable.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(OaFurnitureTable entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除家具
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -0,0 +1,134 @@
package com.gear.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gear.common.core.domain.PageQuery;
import com.gear.common.core.page.TableDataInfo;
import com.gear.common.utils.StringUtils;
import com.gear.oa.domain.SysOaArticle;
import com.gear.oa.domain.bo.SysOaArticleBo;
import com.gear.oa.domain.vo.SysOaArticleVo;
import com.gear.oa.mapper.SysOaArticleMapper;
import com.gear.oa.service.ISysOaArticleService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 知识管理Service业务层处理
*
* @author huangxing
* @date 2024-01-17
*/
@RequiredArgsConstructor
@Service
public class SysOaArticleServiceImpl implements ISysOaArticleService {
private final SysOaArticleMapper baseMapper;
/**
* 查询知识管理
*/
@Override
public SysOaArticle selectArticleById(Long articleId){
SysOaArticle sysOaArticleInfo = baseMapper.selectArticleById(articleId);
//更新阅读数量
SysOaArticleBo sysOaArticleBo = new SysOaArticleBo();
sysOaArticleBo.setArticleId(articleId);
sysOaArticleBo.setCheckNum(sysOaArticleInfo.getCheckNum() + 1);
this.updateByBo(sysOaArticleBo);
return sysOaArticleInfo;
}
/**
* 查询知识管理列表
*/
@Override
public TableDataInfo<SysOaArticleVo> queryPageList(SysOaArticleBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<SysOaArticle> lqw = buildQueryWrapper(bo);
Page<SysOaArticleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 自定义-查询知识管理列表
* @param bo
* @param pageQuery
* @return
*/
@Override
public TableDataInfo<SysOaArticleVo> selectArticlePageList(SysOaArticleBo bo, PageQuery pageQuery){
LambdaQueryWrapper<SysOaArticle> lqw = buildQueryWrapper(bo);
Page<SysOaArticleVo> articlePageList = baseMapper.selectArticlePageList(pageQuery.build(), lqw);
return TableDataInfo.build(articlePageList);
}
/**
* 查询知识管理列表
*/
@Override
public List<SysOaArticleVo> queryList(SysOaArticleBo bo) {
LambdaQueryWrapper<SysOaArticle> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<SysOaArticle> buildQueryWrapper(SysOaArticleBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysOaArticle> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getCategoryId() != null, SysOaArticle::getCategoryId, bo.getCategoryId());
lqw.eq(StringUtils.isNotBlank(bo.getArticleTitle()), SysOaArticle::getArticleTitle, bo.getArticleTitle());
lqw.orderByDesc(SysOaArticle::getCreateTime);
return lqw;
}
/**
* 新增知识管理
*/
@Override
public Boolean insertByBo(SysOaArticleBo bo) {
SysOaArticle add = BeanUtil.toBean(bo, SysOaArticle.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setArticleId(add.getArticleId());
}
return flag;
}
/**
* 修改知识管理
*/
@Override
public Boolean updateByBo(SysOaArticleBo bo) {
SysOaArticle update = BeanUtil.toBean(bo, SysOaArticle.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(SysOaArticle entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除知识管理
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -0,0 +1,99 @@
package com.gear.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gear.common.utils.StringUtils;
import com.gear.oa.domain.SysOaCategory;
import com.gear.oa.domain.bo.SysOaCategoryBo;
import com.gear.oa.domain.vo.SysOaCategoryVo;
import com.gear.oa.mapper.SysOaCategoryMapper;
import com.gear.oa.service.ISysOaCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 知识分类Service业务层处理
*
* @author huangxing
* @date 2024-01-17
*/
@RequiredArgsConstructor
@Service
public class SysOaCategoryServiceImpl implements ISysOaCategoryService {
private final SysOaCategoryMapper baseMapper;
/**
* 查询知识分类
*/
@Override
public SysOaCategoryVo queryById(Long categoryId){
return baseMapper.selectVoById(categoryId);
}
/**
* 查询知识分类列表
*/
@Override
public List<SysOaCategoryVo> queryList(SysOaCategoryBo bo) {
LambdaQueryWrapper<SysOaCategory> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<SysOaCategory> buildQueryWrapper(SysOaCategoryBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysOaCategory> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getCategoryName()), SysOaCategory::getCategoryName, bo.getCategoryName());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysOaCategory::getStatus, bo.getStatus());
lqw.orderByDesc(SysOaCategory::getCreateTime);
return lqw;
}
/**
* 新增知识分类
*/
@Override
public Boolean insertByBo(SysOaCategoryBo bo) {
SysOaCategory add = BeanUtil.toBean(bo, SysOaCategory.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setCategoryId(add.getCategoryId());
}
return flag;
}
/**
* 修改知识分类
*/
@Override
public Boolean updateByBo(SysOaCategoryBo bo) {
SysOaCategory update = BeanUtil.toBean(bo, SysOaCategory.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(SysOaCategory entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除知识分类
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@@ -0,0 +1,382 @@
package com.gear.oa.utils;
import com.gear.oa.config.DynamicMailConfig;
import com.gear.oa.domain.OaEmailAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.util.List;
/**
* 邮件发送工具类
*
* @author ruoyi
*/
@Component
public class EmailUtil {
@Autowired
private JavaMailSender javaMailSender;
@Autowired
private DynamicMailConfig dynamicMailConfig;
/**
* 发送纯文本邮件
*
* @param from 发件人邮箱
* @param to 收件人邮箱
* @param subject 邮件主题
* @param text 纯文本内容
*/
public void sendMail(String from, String to, String subject, String text) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(text);
javaMailSender.send(message);
}
/**
* 使用动态配置发送纯文本邮件
*
* @param account 邮箱账号信息
* @param to 收件人邮箱
* @param subject 邮件主题
* @param text 纯文本内容
*/
public void sendMailWithDynamicConfig(OaEmailAccount account, String to, String subject, String text) {
JavaMailSender dynamicMailSender = dynamicMailConfig.createMailSender(account);
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(account.getEmail());
message.setTo(to);
message.setSubject(subject);
message.setText(text);
dynamicMailSender.send(message);
}
/**
* 发送纯文本邮件(批量)
*
* @param from 发件人邮箱
* @param toList 收件人邮箱列表
* @param subject 邮件主题
* @param text 纯文本内容
*/
public void sendMailBatch(String from, List<String> toList, String subject, String text) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from);
message.setTo(toList.toArray(new String[0]));
message.setSubject(subject);
message.setText(text);
javaMailSender.send(message);
}
/**
* 发送富文本邮件
*
* @param from 发件人邮箱
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容
*/
public void sendHtmlMail(String from, String to, String subject, String htmlContent) throws MessagingException {
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true); // 第二个参数true表示这是HTML内容
javaMailSender.send(mimeMessage);
}
/**
* 使用动态配置发送富文本邮件
*
* @param account 邮箱账号信息
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容
*/
public void sendHtmlMailWithDynamicConfig(OaEmailAccount account, String to, String subject, String htmlContent) throws MessagingException {
JavaMailSender dynamicMailSender = dynamicMailConfig.createMailSender(account);
MimeMessage mimeMessage = dynamicMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(account.getEmail());
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
dynamicMailSender.send(mimeMessage);
}
/**
* 发送富文本邮件(批量)
*
* @param from 发件人邮箱
* @param toList 收件人邮箱列表
* @param subject 邮件主题
* @param htmlContent HTML内容
*/
public void sendHtmlMailBatch(String from, List<String> toList, String subject, String htmlContent) throws MessagingException {
for (String to : toList) {
sendHtmlMail(from, to, subject, htmlContent);
}
}
/**
* 发送带附件的邮件
*
* @param from 发件人邮箱
* @param to 收件人邮箱
* @param subject 邮件主题
* @param text 邮件内容
* @param filePath 附件文件路径
*/
public void sendMailWithAttachment(String from, String to, String subject, String text, String filePath) throws MessagingException {
File attachment = new File(filePath);
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(text);
helper.addAttachment(attachment.getName(), attachment);
javaMailSender.send(mimeMessage);
}
/**
* 使用动态配置发送带附件的邮件
*
* @param account 邮箱账号信息
* @param to 收件人邮箱
* @param subject 邮件主题
* @param text 邮件内容
* @param filePath 附件文件路径
*/
public void sendMailWithAttachmentAndDynamicConfig(OaEmailAccount account, String to, String subject, String text, String filePath) throws MessagingException {
JavaMailSender dynamicMailSender = dynamicMailConfig.createMailSender(account);
File attachment = new File(filePath);
MimeMessage mimeMessage = dynamicMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(account.getEmail());
helper.setTo(to);
helper.setSubject(subject);
helper.setText(text);
helper.addAttachment(attachment.getName(), attachment);
dynamicMailSender.send(mimeMessage);
}
/**
* 发送带附件的富文本邮件
*
* @param from 发件人邮箱
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容
* @param filePath 附件文件路径
*/
public void sendHtmlMailWithAttachment(String from, String to, String subject, String htmlContent, String filePath) throws MessagingException {
File attachment = new File(filePath);
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
helper.addAttachment(attachment.getName(), attachment);
javaMailSender.send(mimeMessage);
}
/**
* 使用动态配置发送带附件的富文本邮件
*
* @param account 邮箱账号信息
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容
* @param filePath 附件文件路径
*/
public void sendHtmlMailWithAttachmentAndDynamicConfig(OaEmailAccount account, String to, String subject, String htmlContent, String filePath) throws MessagingException {
JavaMailSender dynamicMailSender = dynamicMailConfig.createMailSender(account);
File attachment = new File(filePath);
MimeMessage mimeMessage = dynamicMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(account.getEmail());
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
helper.addAttachment(attachment.getName(), attachment);
dynamicMailSender.send(mimeMessage);
}
/**
* 发送带多个附件的邮件
*
* @param from 发件人邮箱
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容
* @param filePaths 附件文件路径列表
*/
public void sendHtmlMailWithAttachments(String from, String to, String subject, String htmlContent, List<String> filePaths) throws MessagingException {
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
for (String filePath : filePaths) {
File attachment = new File(filePath);
if (attachment.exists()) {
helper.addAttachment(attachment.getName(), attachment);
}
}
javaMailSender.send(mimeMessage);
}
/**
* 使用动态配置发送带多个附件的邮件
*
* @param account 邮箱账号信息
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容
* @param filePaths 附件文件路径列表
*/
public void sendHtmlMailWithAttachmentsAndDynamicConfig(OaEmailAccount account, String to, String subject, String htmlContent, List<String> filePaths) throws MessagingException {
JavaMailSender dynamicMailSender = dynamicMailConfig.createMailSender(account);
MimeMessage mimeMessage = dynamicMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(account.getEmail());
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
for (String filePath : filePaths) {
File attachment = new File(filePath);
if (attachment.exists()) {
helper.addAttachment(attachment.getName(), attachment);
}
}
dynamicMailSender.send(mimeMessage);
}
/**
* 发送带内嵌图片的邮件
*
* @param from 发件人邮箱
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容包含cid:xxx的图片引用
* @param imagePaths 内嵌图片路径列表
*/
public void sendHtmlMailWithInlineImages(String from, String to, String subject, String htmlContent, List<String> imagePaths) throws MessagingException {
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(from);
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
for (int i = 0; i < imagePaths.size(); i++) {
String imagePath = imagePaths.get(i);
File imageFile = new File(imagePath);
if (imageFile.exists()) {
String cid = "image" + i;
helper.addInline(cid, imageFile);
}
}
javaMailSender.send(mimeMessage);
}
/**
* 使用动态配置发送带内嵌图片的邮件
*
* @param account 邮箱账号信息
* @param to 收件人邮箱
* @param subject 邮件主题
* @param htmlContent HTML内容包含cid:xxx的图片引用
* @param imagePaths 内嵌图片路径列表
*/
public void sendHtmlMailWithInlineImagesAndDynamicConfig(OaEmailAccount account, String to, String subject, String htmlContent, List<String> imagePaths) throws MessagingException {
JavaMailSender dynamicMailSender = dynamicMailConfig.createMailSender(account);
MimeMessage mimeMessage = dynamicMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
helper.setFrom(account.getEmail());
helper.setTo(to);
helper.setSubject(subject);
helper.setText(htmlContent, true);
for (int i = 0; i < imagePaths.size(); i++) {
String imagePath = imagePaths.get(i);
File imageFile = new File(imagePath);
if (imageFile.exists()) {
String cid = "image" + i;
helper.addInline(cid, imageFile);
}
}
dynamicMailSender.send(mimeMessage);
}
/**
* 处理HTML内容中的图片将外链图片转为内嵌
*
* @param htmlContent 原始HTML内容
* @param imagePaths 图片路径列表
* @return 处理后的HTML内容
*/
public String processHtmlWithInlineImages(String htmlContent, List<String> imagePaths) {
if (imagePaths == null || imagePaths.isEmpty()) {
return htmlContent;
}
String processedHtml = htmlContent;
for (int i = 0; i < imagePaths.size(); i++) {
String imagePath = imagePaths.get(i);
String cid = "image" + i;
// 这里可以根据需要替换图片URL为cid引用
// 例如:将 <img src="path/to/image.jpg"> 替换为 <img src="cid:image0">
processedHtml = processedHtml.replace("image" + i + ".jpg", "cid:" + cid);
processedHtml = processedHtml.replace("image" + i + ".png", "cid:" + cid);
}
return processedHtml;
}
/**
* 下载网络文件到本地临时文件,保留原始文件后缀
* @param url 文件的http/https链接
* @return 本地临时文件
*/
public static File downloadUrlToTempFile(String url) throws Exception {
// 提取文件名和后缀
String fileName = url.substring(url.lastIndexOf('/') + 1);
String suffix = "";
int dotIdx = fileName.lastIndexOf('.');
if (dotIdx != -1) {
suffix = fileName.substring(dotIdx);
}
File tempFile = File.createTempFile("mail_attach_", suffix);
try (java.io.InputStream in = new java.net.URL(url).openStream();
java.io.OutputStream out = new java.io.FileOutputStream(tempFile)) {
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
}
return tempFile;
}
}

View File

@@ -0,0 +1,25 @@
<?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.gear.oa.mapper.OaEmailAccountMapper">
<resultMap type="com.gear.oa.domain.OaEmailAccount" id="OaEmailAccountResult">
<result property="emailId" column="email_id"/>
<result property="email" column="email"/>
<result property="password" column="password"/>
<result property="smtpHost" column="smtp_host"/>
<result property="smtpPort" column="smtp_port"/>
<result property="accessKey" column="access_key"/>
<result property="secretKey" column="secret_key"/>
<result property="type" column="type"/>
<result property="remark" column="remark"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.gear.oa.mapper.OaEmailTemplateMapper">
<resultMap type="com.gear.oa.domain.OaEmailTemplate" id="OaEmailTemplateResult">
<result property="id" column="id"/>
<result property="templateName" column="template_name"/>
<result property="category" column="category"/>
<result property="content" column="content"/>
<result property="attachments" column="attachments"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag"/>
<result property="remark" column="remark"/>
</resultMap>
</mapper>

View File

@@ -0,0 +1,48 @@
<?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.gear.oa.mapper.OaFurnitureTableMapper">
<resultMap type="com.gear.oa.domain.OaFurnitureTable" id="OaFurnitureTableResult">
<result property="furnitureId" column="furniture_id"/>
<result property="companyName" column="company_name"/>
<result property="state" column="state"/>
<result property="procurementOfProducts" column="procurement_of_products"/>
<result property="contactGroup" column="contact_group"/>
<result property="phone" column="phone"/>
<result property="fax" column="fax"/>
<result property="address" column="address"/>
<result property="zip" column="zip"/>
<result property="email" column="email"/>
<result property="website" column="website"/>
<result property="emailSendCount" column="email_send_count"/>
<result property="lastEmailSendTime" column="last_email_send_time"/>
<result property="contactPerson" column="contact_person"/>
<result property="receiveCount" column="receive_count"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag"/>
<result property="remark" column="remark"/>
</resultMap>
<update id="updateEmailSendInfo">
UPDATE oa_furniture_table
SET email_send_count = IFNULL(email_send_count,0) + 1,
last_email_send_time = NOW()
WHERE furniture_id = #{furnitureId}
</update>
<select id="selectEmailsByFurnitureIds" resultType="java.lang.String">
SELECT email FROM oa_furniture_table
WHERE furniture_id IN
<foreach collection="list" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND del_flag = 0
AND email IS NOT NULL AND email != ''
</select>
</mapper>

View File

@@ -0,0 +1,61 @@
<?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.gear.oa.mapper.SysOaArticleMapper">
<resultMap type="com.gear.oa.domain.SysOaArticle" id="SysOaArticleResult">
<result property="articleId" column="article_id"/>
<result property="categoryId" column="category_id"/>
<result property="articleTitle" column="article_title"/>
<result property="subhead" column="subhead"/>
<result property="source" column="source"/>
<result property="content" column="content"/>
<result property="checkNum" column="check_num"/>
<result property="accessory" column="accessory"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<!--一对一关联-->
<association property="category" column="category_id" javaType="SysOaCategory" resultMap="SysOaCategoryResult"/>
</resultMap>
<resultMap id="SysOaCategoryResult" type="SysOaCategory">
<result property="categoryId" column="category_id"/>
<result property="categoryName" column="category_name"/>
</resultMap>
<sql id="selectArticleSql">
select a.article_id,
a.category_id,
a.article_title,
a.subhead,
a.source,
a.content,
a.check_num,
a.accessory,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
c.category_id,
c.category_name
from sys_oa_article a
left join sys_oa_category c on a.category_id = c.category_id
</sql>
<select id="selectArticlePageList" resultMap="SysOaArticleResult">
<include refid="selectArticleSql" />
${ew.getCustomSqlSegment}
</select>
<select id="selectArticleById" resultMap="SysOaArticleResult">
<include refid="selectArticleSql" />
where a.article_id = #{articleId}
</select>
</mapper>

View File

@@ -0,0 +1,20 @@
<?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.gear.oa.mapper.SysOaCategoryMapper">
<resultMap type="com.gear.oa.domain.SysOaCategory" id="SysOaCategoryResult">
<result property="categoryId" column="category_id"/>
<result property="parentId" column="parent_id"/>
<result property="categoryName" column="category_name"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>

View File

@@ -37,6 +37,7 @@
"vue": "3.5.16",
"vue-cropper": "1.1.1",
"vue-router": "4.5.1",
"vue3-treeselect": "^0.1.10",
"vuedraggable": "4.1.0"
},
"devDependencies": {

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询知识管理列表
export function listArticle(query) {
return request({
url: '/oa/article/listArticle',
method: 'get',
params: query
})
}
// 查询知识管理详细
export function getArticle(articleId) {
return request({
url: '/oa/article/' + articleId,
method: 'get'
})
}
// 新增知识管理
export function addArticle(data) {
return request({
url: '/oa/article',
method: 'post',
data: data
})
}
// 修改知识管理
export function updateArticle(data) {
return request({
url: '/oa/article',
method: 'put',
data: data
})
}
// 删除知识管理
export function delArticle(articleId) {
return request({
url: '/oa/article/' + articleId,
method: 'delete'
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询知识分类列表
export function listCategory(query) {
return request({
url: '/oa/category/list',
method: 'get',
params: query
})
}
// 查询知识分类详细
export function getCategory(categoryId) {
return request({
url: '/oa/category/' + categoryId,
method: 'get'
})
}
// 新增知识分类
export function addCategory(data) {
return request({
url: '/oa/category',
method: 'post',
data: data
})
}
// 修改知识分类
export function updateCategory(data) {
return request({
url: '/oa/category',
method: 'put',
data: data
})
}
// 删除知识分类
export function delCategory(categoryId) {
return request({
url: '/oa/category/' + categoryId,
method: 'delete'
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询家具列表
export function listFurnitureTable(query) {
return request({
url: '/oa/furnitureTable/list',
method: 'get',
params: query
})
}
// 查询家具详细
export function getFurnitureTable(furnitureId) {
return request({
url: '/oa/furnitureTable/' + furnitureId,
method: 'get'
})
}
// 新增家具
export function addFurnitureTable(data) {
return request({
url: '/oa/furnitureTable',
method: 'post',
data: data
})
}
// 修改家具
export function updateFurnitureTable(data) {
return request({
url: '/oa/furnitureTable',
method: 'put',
data: data
})
}
// 删除家具
export function delFurnitureTable(furnitureId) {
return request({
url: '/oa/furnitureTable/' + furnitureId,
method: 'delete'
})
}

View File

@@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询发件人邮箱账号管理列表
export function listEmailAccount(query) {
return request({
url: '/oa/emailAccount/list',
method: 'get',
params: query
})
}
// 查询发件人邮箱账号管理详细
export function getEmailAccount(emailId) {
return request({
url: '/oa/emailAccount/' + emailId,
method: 'get'
})
}
// 新增发件人邮箱账号管理
export function addEmailAccount(data) {
return request({
url: '/oa/emailAccount',
method: 'post',
data: data
})
}
// 修改发件人邮箱账号管理
export function updateEmailAccount(data) {
return request({
url: '/oa/emailAccount',
method: 'put',
data: data
})
}
// 删除发件人邮箱账号管理
export function delEmailAccount(emailId) {
return request({
url: '/oa/emailAccount/' + emailId,
method: 'delete'
})
}
// 发送邮件(单条和批量共用)
export function sendEmail(data) {
return request({
url: '/oa/emailAccount/sendBatchEmail',
method: 'post',
data
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询邮件模板列表
export function listEmailTemplate(query) {
return request({
url: '/oa/emailTemplate/list',
method: 'get',
params: query
})
}
// 查询邮件模板详细
export function getEmailTemplate(id) {
return request({
url: '/oa/emailTemplate/' + id,
method: 'get'
})
}
// 新增邮件模板
export function addEmailTemplate(data) {
return request({
url: '/oa/emailTemplate',
method: 'post',
data: data
})
}
// 修改邮件模板
export function updateEmailTemplate(data) {
return request({
url: '/oa/emailTemplate',
method: 'put',
data: data
})
}
// 删除邮件模板
export function delEmailTemplate(id) {
return request({
url: '/oa/emailTemplate/' + id,
method: 'delete'
})
}

View File

@@ -0,0 +1,347 @@
<template>
<div class="article-preview">
<!-- 文章标题区 -->
<div class="article-header">
<div class="title-area">
<h1 class="article-title">{{ article.articleTitle }}</h1>
<div class="meta-info">
<span class="category">
<i class="el-icon-folder"></i>
{{ article.category.categoryName || '未分类' }}
</span>
<span class="create-time">
<i class="el-icon-time"></i>
{{ parseTime(article.createTime) }}
</span>
<span class="source" v-if="article.source">
<i class="el-icon-link"></i>
{{ article.source }}
</span>
<span class="views">
<i class="el-icon-view"></i>
浏览 {{ article.checkNum }}
</span>
</div>
</div>
<div class="subtitle-area" v-if="article.subhead">
<div class="subtitle">{{ article.subhead }}</div>
</div>
</div>
<!-- 文章摘要 -->
<div class="article-summary" v-if="article.remark">
<p>{{ article.remark }}</p>
</div>
<!-- 文章正文 -->
<div class="article-content">
<div v-html="article.content" class="rich-content"></div>
</div>
<!-- 文章附件 -->
<div class="article-attachments" v-if="article.accessory">
<div class="attachments-header">附件下载</div>
<div class="attachment-item">
<i class="el-icon-paperclip"></i>
<span>{{ getAttachmentName(article.accessory) }}</span>
<a :href="article.accessory" target="_blank" class="download-btn">
下载 <i class="el-icon-download"></i>
</a>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'ArticlePreview',
props: {
article: {
type: Object,
required: true,
default: () => ({
articleTitle: '',
subhead: '',
remark: '',
content: '',
accessory: '',
category: {},
source: '',
checkNum: 0,
createTime: ''
})
}
},
methods: {
getAttachmentName(url) {
if (!url) return '未命名文件';
// 提取URL最后的文件名部分
const segments = url.split('/');
return segments.pop() || '未命名文件';
}
}
}
</script>
<style lang="scss" scoped>
.article-preview {
font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
color: #333;
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
.article-header {
padding-bottom: 20px;
border-bottom: 1px solid #f0f2f5;
margin-bottom: 25px;
.title-area {
margin-bottom: 15px;
.article-title {
font-size: 28px;
font-weight: 700;
line-height: 1.4;
margin: 0 0 15px;
color: #1f2f3d;
}
.meta-info {
display: flex;
flex-wrap: wrap;
font-size: 14px;
color: #909399;
gap: 20px;
span {
display: flex;
align-items: center;
i {
margin-right: 6px;
}
}
.category {
color: #409EFF;
font-weight: 500;
}
.views {
color: #67C23A;
}
}
}
.subtitle-area {
background: #f5f7fa;
border-left: 4px solid #409EFF;
padding: 12px 20px;
border-radius: 4px;
.subtitle {
font-size: 16px;
line-height: 1.6;
color: #606266;
}
}
}
.article-summary {
background-color: #f9f9f9;
border: 1px solid #ebeef5;
padding: 16px 20px;
margin-bottom: 25px;
border-radius: 4px;
p {
font-size: 16px;
line-height: 1.6;
color: #555;
margin: 0;
}
}
.article-content {
margin-bottom: 30px;
.rich-content {
font-size: 16px;
line-height: 1.8;
color: #303133;
:deep(*) {
p {
margin-bottom: 1.2em;
}
h2, h3, h4 {
margin-top: 1.5em;
margin-bottom: 0.8em;
color: #1f2f3d;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
h3 {
font-size: 20px;
}
blockquote {
background: #f9f9f9;
border-left: 4px solid #ddd;
margin: 1.5em 0;
padding: 0.5em 15px;
color: #5a5a5a;
}
img {
max-width: 100%;
height: auto;
display: block;
margin: 1.2em auto;
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
table {
width: 100%;
border-collapse: collapse;
margin: 1.5em 0;
th {
background: #f5f7fa;
font-weight: 600;
}
th, td {
border: 1px solid #dfe6ec;
padding: 10px 12px;
text-align: left;
}
}
a {
color: #409EFF;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
code {
background: #f9f2f4;
color: #c7254e;
padding: 2px 4px;
border-radius: 3px;
font-size: 90%;
}
pre {
background: #2d2d2d;
color: #ccc;
padding: 15px;
border-radius: 4px;
overflow: auto;
margin: 1.5em 0;
code {
background: transparent;
color: inherit;
padding: 0;
font-size: 14px;
}
}
ul, ol {
padding-left: 2em;
margin-bottom: 1.2em;
li {
margin-bottom: 0.5em;
}
}
}
}
}
.article-attachments {
background-color: #f5f7fa;
border-radius: 6px;
padding: 15px 20px;
margin-top: 30px;
.attachments-header {
font-size: 16px;
font-weight: 600;
color: #606266;
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px dashed #dcdfe6;
}
.attachment-item {
display: flex;
align-items: center;
padding: 8px 10px;
background-color: #fff;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
i {
color: #909399;
margin-right: 10px;
}
span {
flex: 1;
color: #606266;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.download-btn {
padding: 5px 12px;
background-color: #ecf5ff;
color: #409EFF;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
text-decoration: none;
transition: all 0.2s;
&:hover {
background-color: #409EFF;
color: #fff;
}
}
}
}
@media (max-width: 768px) {
padding: 20px 15px;
.article-header .title-area .article-title {
font-size: 22px;
}
.article-header .meta-info {
gap: 10px;
font-size: 12px;
}
.article-summary p,
.article-content .rich-content {
font-size: 15px;
}
}
}
</style>

View File

@@ -0,0 +1,519 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['oa:article:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['oa:article:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['oa:article:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['oa:article:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<div class="card-container" v-loading="loading">
<el-row :gutter="20">
<el-col
v-for="(item, index) in articleList"
:key="index"
:xs="24"
:sm="12"
:md="8"
:lg="6"
:xl="4"
class="mb20"
>
<el-card
class="article-card"
:body-style="{ padding: '16px', height: '100%', display: 'flex', flexDirection: 'column' }"
>
<div class="card-header">
<span class="card-title">{{ item.articleTitle }}</span>
<el-tag type="info" size="mini" class="category-tag">
{{ item.category.categoryName }}
</el-tag>
</div>
<div class="card-subtitle">{{ item.subhead }}</div>
<div class="card-content">
<div class="card-stat">
<i class="el-icon-view"></i>
<span>浏览 {{ item.checkNum }} </span>
</div>
<div class="card-meta">
<div><i class="el-icon-user"></i> {{ item.createBy }}</div>
<div><i class="el-icon-time"></i> {{ parseTime(item.createTime, '{y}-{m}-{d}') }}</div>
</div>
</div>
<div class="card-footer">
<el-button-group>
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handlePreview(item)"
>预览</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(item)"
>编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(item)"
>删除</el-button>
</el-button-group>
</div>
</el-card>
</el-col>
</el-row>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改知识管理对话框 -->
<el-dialog :title="title" v-model="open" width="60%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="16">
<el-form-item label="文章标题" prop="articleTitle">
<el-input v-model="form.articleTitle" placeholder="请输入文章标题" />
</el-form-item>
</el-col>
<!-- <el-col :span="8">
<el-form-item label="文章分类" prop="categoryId">
<el-input v-model="form.categoryId" placeholder="请输入文章分类" />
</el-form-item>
</el-col>-->
<el-col :span="8">
<el-form-item label="文章分类" prop="categoryId">
<!-- <el-input v-model="form.categoryId" placeholder="请输入文章分类" />-->
<treeselect v-model="form.categoryId" :options="categoryList" :normalizer="normalizer" placeholder="选择分类" />
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="副标题" prop="subhead">
<el-input v-model="form.subhead" placeholder="请输入副标题" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="来源" prop="source">
<el-input v-model="form.source" placeholder="请输入来源" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="内容">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="附件" prop="accessory">
<file-upload v-model="form.accessory"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 查看公告对话框 -->
<el-dialog :title="title" v-model="openPreview" v-if="openPreview" width="65%" @close="closeDialog" append-to-body>
<ArticlePreview :article="form"/>
</el-dialog>
</div>
</template>
<script>
import { addArticle, delArticle, getArticle, listArticle, updateArticle } from "@/api/oa/article";
import { listCategory } from "@/api/oa/category";
import Treeselect from 'vue3-treeselect'
import 'vue3-treeselect/dist/vue3-treeselect.css'
import ArticlePreview from "./components/ArticlePreview.vue";
export default {
name: "Article",
components: { Treeselect, ArticlePreview },
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 知识管理表格数据
articleList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
categoryId: undefined,
articleTitle: undefined,
},
categoryList: [],
//查看弹出层
openPreview: false,
categoryName: '',
// 表单参数
form: {},
// 表单校验
rules: {
articleId: [
{ required: true, message: "文章id不能为空", trigger: "blur" }
],
categoryId: [
{ required: true, message: "文章分类不能为空", trigger: "blur" }
],
articleTitle: [
{ required: true, message: "文章标题不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询知识管理列表 */
getList() {
this.loading = true;
listArticle(this.queryParams).then(response => {
this.articleList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
articleId: undefined,
categoryId: undefined,
articleTitle: undefined,
subhead: undefined,
source: undefined,
content: undefined,
checkNum: undefined,
accessory: undefined,
remark: undefined,
createBy: undefined,
createTime: undefined,
updateBy: undefined,
updateTime: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.articleId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加知识管理";
listCategory().then(response => {
this.categoryList = this.handleTree(response.data, "categoryId", "parentId");
})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const articleId = row.articleId || this.ids
listCategory().then(response => {
this.categoryList = this.handleTree(response.data, "categoryId", "parentId");
})
getArticle(articleId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改知识管理";
});
},
/** 查看按钮操作 */
handlePreview(row){
this.reset();
this.openPreview = true;
this.categoryName= row.category.categoryName;
const articleId = row.articleId || this.ids
listCategory().then(response => {
this.categoryList = this.handleTree(response.data, "categoryId", "parentId");
})
getArticle(articleId).then(response => {
this.loading = false;
this.form = response.data;
this.title = "文章预览";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
//删除project关联表属性
delete this.form.category;
if (this.form.articleId != null) {
updateArticle(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addArticle(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/**关闭预览弹出层**/
closeDialog(){
this.getList();
},
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.categoryId,
label: node.categoryName,
children: node.children
};
},
/** 删除按钮操作 */
handleDelete(row) {
const articleIds = row.articleId || this.ids;
this.$modal.confirm('是否确认删除知识管理编号为"' + articleIds + '"的数据项?').then(() => {
this.loading = true;
return delArticle(articleIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('oa/article/export', {
...this.queryParams
}, `article_${new Date().getTime()}.xlsx`)
}
}
};
</script>
<style lang="scss" scoped>
.app-container {
.card-container {
padding: 0 10px;
}
.article-card {
height: 100%;
transition: all 0.3s ease;
border-radius: 8px;
overflow: hidden;
border: 1px solid #ebeef5;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
&:hover {
transform: translateY(-5px);
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 12px;
.card-title {
font-weight: bold;
font-size: 16px;
color: #303133;
flex: 1;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.category-tag {
margin-left: 8px;
flex-shrink: 0;
}
}
.card-subtitle {
font-size: 13px;
color: #606266;
margin-bottom: 12px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
min-height: 36px;
}
.card-content {
flex: 1;
margin-bottom: 12px;
.card-stat {
display: flex;
align-items: center;
font-size: 12px;
color: #909399;
margin-bottom: 8px;
i {
margin-right: 4px;
}
}
.card-meta {
font-size: 12px;
color: #909399;
div {
display: flex;
align-items: center;
margin-bottom: 4px;
i {
margin-right: 4px;
}
}
}
}
.card-footer {
border-top: 1px solid #f0f2f5;
padding-top: 12px;
text-align: center;
.el-button-group {
display: flex;
justify-content: space-around;
}
}
}
}
/* 响应式调整 */
@media screen and (max-width: 768px) {
.article-card {
.card-header {
flex-direction: column;
.category-tag {
align-self: flex-start;
margin-top: 5px;
margin-left: 0;
}
}
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
/**
* 商务邮件模板
* 适用于商务合作、客户沟通等场景
*/
export const businessTemplate = {
name: "商务模板",
description: "专业的商务合作邮件模板,适合客户沟通和商务洽谈",
category: "business",
html: `
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 30px; text-align: center;">
<h1 style="color: white; margin: 0; font-size: 28px; font-weight: 300; font-family: Arial, sans-serif;">商务合作</h1>
<p style="color: rgba(255,255,255,0.8); margin: 10px 0 0 0; font-size: 16px; font-family: Arial, sans-serif;">Professional Business Communication</p>
</td>
</tr>
<tr>
<td style="padding: 40px 30px; background-color: #ffffff;">
<div style="margin-bottom: 30px;">
<h2 style="color: #333; font-size: 24px; margin-bottom: 20px; border-bottom: 2px solid #667eea; padding-bottom: 10px; font-family: Arial, sans-serif;">
尊敬的客户
</h2>
<div style="line-height: 1.8; color: #555; font-size: 16px; font-family: Arial, sans-serif;">
</div>
</div>
</td>
</tr>
</table>
`
};
export default businessTemplate;

View File

@@ -0,0 +1,32 @@
/**
* 邮件模板索引文件
* 统一管理所有邮件模板
*/
import { businessTemplate } from './business.js';
import { marketingTemplate } from './marketing.js';
import { notificationTemplate } from './notification.js';
import { productTemplate } from './product.js';
// 所有模板集合
export const emailTemplates = {
business: businessTemplate,
product: productTemplate,
marketing: marketingTemplate,
notification: notificationTemplate
};
// 根据模板键获取模板
export function getTemplate(templateKey) {
return emailTemplates[templateKey] || null;
}
// 获取所有模板
export function getAllTemplates() {
return emailTemplates;
}
export default {
emailTemplates,
getTemplate,
getAllTemplates
};

View File

@@ -0,0 +1,103 @@
/**
* 营销邮件模板
* 适用于产品推广、活动宣传等营销场景
*/
export const marketingTemplate = {
name: "营销推广模板",
description: "专业的营销推广邮件模板,适合产品推广和活动宣传",
category: "marketing",
html: `
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<!-- 头部横幅 -->
<tr>
<td style="background: linear-gradient(45deg, #ff6b6b, #ffa726); padding: 40px 30px; text-align: center;">
<h1 style="color: white; margin: 0; font-size: 32px; font-weight: 600; font-family: Arial, sans-serif;">限时优惠</h1>
<p style="color: rgba(255,255,255,0.9); margin: 15px 0 0 0; font-size: 18px; font-family: Arial, sans-serif;">Special Offer</p>
</td>
</tr>
<!-- 主要内容 -->
<tr>
<td style="padding: 40px 30px; background-color: #ffffff;">
<!-- 优惠信息 -->
<div style="margin-bottom: 30px;">
<h2 style="color: #2c3e50; font-size: 26px; margin-bottom: 20px; text-align: center; font-family: Arial, sans-serif;">
🎉 特别优惠活动
</h2>
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: linear-gradient(135deg, #ff6b6b 0%, #ffa726 100%); border-radius: 12px; margin-bottom: 30px;">
<tr>
<td style="padding: 25px; color: white; text-align: center;">
<h3 style="margin: 0 0 15px 0; font-size: 24px; font-family: Arial, sans-serif;">限时折扣</h3>
<p style="margin: 0; font-size: 18px; font-family: Arial, sans-serif;">全场商品 <strong>8折优惠</strong></p>
<p style="margin: 10px 0 0 0; font-size: 14px; font-family: Arial, sans-serif;">活动时间2024年1月1日 - 2024年1月31日</p>
</td>
</tr>
</table>
</div>
<!-- 产品推荐 -->
<div style="margin-bottom: 30px;">
<h3 style="color: #2c3e50; margin: 0 0 20px 0; font-size: 20px; text-align: center; font-family: Arial, sans-serif;">🔥 热门推荐</h3>
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="width: 50%; padding-right: 10px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: #f8f9fa; border-radius: 8px;">
<tr>
<td style="padding: 20px; text-align: center;">
<div style="width: 80px; height: 80px; background: linear-gradient(45deg, #ff6b6b, #ffa726); border-radius: 50%; margin: 0 auto 15px; display: inline-block; line-height: 80px; font-size: 32px; color: white;">🏠</div>
<h4 style="margin: 0 0 10px 0; color: #2c3e50; font-family: Arial, sans-serif;">精品家具</h4>
<p style="margin: 0 0 15px 0; color: #7f8c8d; font-size: 14px; font-family: Arial, sans-serif;">现代简约风格,品质保证</p>
<div style="background: #ff6b6b; color: white; padding: 8px 16px; border-radius: 20px; font-weight: bold; font-family: Arial, sans-serif;">
原价 ¥2999 现价 ¥2399
</div>
</td>
</tr>
</table>
</td>
<td style="width: 50%; padding-left: 10px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: #f8f9fa; border-radius: 8px;">
<tr>
<td style="padding: 20px; text-align: center;">
<div style="width: 80px; height: 80px; background: linear-gradient(45deg, #4ecdc4, #44a08d); border-radius: 50%; margin: 0 auto 15px; display: inline-block; line-height: 80px; font-size: 32px; color: white;">🛋️</div>
<h4 style="margin: 0 0 10px 0; color: #2c3e50; font-family: Arial, sans-serif;">办公用品</h4>
<p style="margin: 0 0 15px 0; color: #7f8c8d; font-size: 14px; font-family: Arial, sans-serif;">专业办公环境解决方案</p>
<div style="background: #4ecdc4; color: white; padding: 8px 16px; border-radius: 20px; font-weight: bold; font-family: Arial, sans-serif;">
原价 ¥1999 现价 ¥1599
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- 行动号召 -->
<div style="text-align: center; margin-bottom: 30px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" style="margin: 0 auto;">
<tr>
<td style="background: linear-gradient(45deg, #ff6b6b, #ffa726); border-radius: 25px; padding: 15px 30px;">
<a href="#" style="color: white; text-decoration: none; font-size: 18px; font-weight: bold; font-family: Arial, sans-serif;">
🛒 立即购买
</a>
</td>
</tr>
</table>
</div>
<!-- 邮件正文内容 -->
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color: #f8f9fa; border-radius: 8px; border-left: 4px solid #ff6b6b;">
<tr>
<td style="padding: 25px;">
<h3 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 18px; font-family: Arial, sans-serif;">📧 详细信息</h3>
<div style="line-height: 1.8; color: #555; font-size: 16px; font-family: Arial, sans-serif;">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
`
};

View File

@@ -0,0 +1,82 @@
/**
* 通知邮件模板
* 适用于系统通知、状态更新等场景
*/
export const notificationTemplate = {
name: "系统通知模板",
description: "简洁专业的系统通知邮件模板,适合状态更新和重要通知",
category: "notification",
html: `
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<!-- 头部 -->
<tr>
<td style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 30px; text-align: center;">
<h1 style="color: white; margin: 0; font-size: 28px; font-weight: 300; font-family: Arial, sans-serif;">系统通知</h1>
<p style="color: rgba(255,255,255,0.8); margin: 10px 0 0 0; font-size: 16px; font-family: Arial, sans-serif;">System Notification</p>
</td>
</tr>
<!-- 主要内容 -->
<tr>
<td style="padding: 40px 30px; background-color: #ffffff;">
<!-- 通知图标 -->
<div style="text-align: center; margin-bottom: 30px;">
<div style="width: 80px; height: 80px; background: linear-gradient(45deg, #667eea, #764ba2); border-radius: 50%; margin: 0 auto; display: inline-block; line-height: 80px; font-size: 36px; color: white;">📢</div>
</div>
<!-- 通知标题 -->
<div style="text-align: center; margin-bottom: 30px;">
<h2 style="color: #2c3e50; font-size: 24px; margin-bottom: 15px; font-family: Arial, sans-serif;">
重要通知
</h2>
<p style="color: #7f8c8d; font-size: 16px; margin: 0; font-family: Arial, sans-serif;">
请仔细阅读以下内容
</p>
</div>
<!-- 通知内容卡片 -->
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: #f8f9fa; border-radius: 12px; margin-bottom: 30px;">
<tr>
<td style="padding: 30px;">
<div style="background: white; border-radius: 8px; padding: 25px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<h3 style="color: #2c3e50; margin: 0 0 20px 0; font-size: 20px; font-family: Arial, sans-serif;">
📋 通知详情
</h3>
<div style="line-height: 1.8; color: #555; font-size: 16px; font-family: Arial, sans-serif;">
</div>
</div>
</td>
</tr>
</table>
<!-- 重要信息提示 -->
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 8px; margin-bottom: 30px;">
<tr>
<td style="padding: 20px; color: white;">
<h4 style="margin: 0 0 10px 0; font-size: 18px; font-family: Arial, sans-serif;">⚠️ 重要提醒</h4>
<ul style="margin: 0; padding-left: 20px; line-height: 1.6; font-family: Arial, sans-serif;">
<li>请及时处理相关事项</li>
<li>如有疑问请联系客服</li>
<li>感谢您的配合与支持</li>
</ul>
</td>
</tr>
</table>
<!-- 联系信息 -->
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: #ecf0f1; border-radius: 8px;">
<tr>
<td style="padding: 20px; text-align: center;">
<h4 style="margin: 0 0 15px 0; color: #2c3e50; font-family: Arial, sans-serif;">📞 联系我们</h4>
<p style="margin: 0; color: #7f8c8d; font-family: Arial, sans-serif;">
客服电话400-123-4567 | 邮箱support@company.com
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
`
};

View File

@@ -0,0 +1,94 @@
/**
* 产品介绍邮件模板
* 适用于产品展示、新品发布等场景
*/
export const productTemplate = {
name: "产品介绍模板",
description: "现代化的产品展示邮件模板,适合产品介绍和新品发布",
category: "product",
html: `
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<!-- 头部横幅 -->
<tr>
<td style="background: linear-gradient(45deg, #ff6b6b, #4ecdc4); padding: 40px 30px; text-align: center;">
<h1 style="color: white; margin: 0; font-size: 32px; font-weight: 600; font-family: Arial, sans-serif;">产品展示</h1>
<p style="color: rgba(255,255,255,0.9); margin: 15px 0 0 0; font-size: 18px; font-family: Arial, sans-serif;">Product Showcase</p>
</td>
</tr>
<!-- 主要内容 -->
<tr>
<td style="padding: 40px 30px; background-color: #ffffff;">
<!-- 产品介绍 -->
<div style="margin-bottom: 40px;">
<h2 style="color: #2c3e50; font-size: 26px; margin-bottom: 25px; text-align: center; font-family: Arial, sans-serif;">
🚀 产品特色
</h2>
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 12px; margin-bottom: 30px;">
<tr>
<td style="padding: 25px; color: white;">
<h3 style="margin: 0 0 15px 0; font-size: 20px; font-family: Arial, sans-serif;">✨ 核心优势</h3>
<ul style="margin: 0; padding-left: 20px; line-height: 1.8; font-family: Arial, sans-serif;">
<li>高质量材料,确保产品耐用性</li>
<li>创新设计,满足现代审美需求</li>
<li>环保认证,符合国际标准</li>
<li>专业服务,全程技术支持</li>
</ul>
</td>
</tr>
</table>
<!-- 邮件正文内容 -->
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color: #f8f9fa; border-radius: 8px; border-left: 4px solid #4ecdc4;">
<tr>
<td style="padding: 25px;">
<h3 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 18px; font-family: Arial, sans-serif;">📧 详细信息</h3>
<div style="line-height: 1.8; color: #555; font-size: 16px; font-family: Arial, sans-serif;">
</div>
</td>
</tr>
</table>
</div>
<!-- 产品图片展示区域 -->
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color: #ecf0f1; border-radius: 8px; margin-bottom: 30px;">
<tr>
<td style="padding: 25px;">
<h3 style="color: #2c3e50; margin: 0 0 20px 0; font-size: 20px; text-align: center; font-family: Arial, sans-serif;">📸 产品展示</h3>
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="width: 50%; padding-right: 7px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: white; border-radius: 6px;">
<tr>
<td style="padding: 15px; text-align: center;">
<div style="width: 60px; height: 60px; background: linear-gradient(45deg, #ff6b6b, #4ecdc4); border-radius: 50%; margin: 0 auto 10px; display: inline-block; line-height: 60px; font-size: 24px; color: white;">🏠</div>
<h4 style="margin: 0 0 5px 0; color: #2c3e50; font-family: Arial, sans-serif;">家居系列</h4>
<p style="margin: 0; color: #7f8c8d; font-size: 14px; font-family: Arial, sans-serif;">现代简约风格</p>
</td>
</tr>
</table>
</td>
<td style="width: 50%; padding-left: 7px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background: white; border-radius: 6px;">
<tr>
<td style="padding: 15px; text-align: center;">
<div style="width: 60px; height: 60px; background: linear-gradient(45deg, #667eea, #764ba2); border-radius: 50%; margin: 0 auto 10px; display: inline-block; line-height: 60px; font-size: 24px; color: white;">🛋️</div>
<h4 style="margin: 0 0 5px 0; color: #2c3e50; font-family: Arial, sans-serif;">办公系列</h4>
<p style="margin: 0; color: #7f8c8d; font-size: 14px; font-family: Arial, sans-serif;">专业办公环境</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
`
};
export default productTemplate;

View File

@@ -0,0 +1,483 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="邮箱账号" prop="email">
<el-input
v-model="queryParams.email"
placeholder="请输入邮箱账号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="邮箱类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择邮箱类型" clearable>
<el-option
v-for="dict in email_type"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 表格部分多级表头分组 -->
<el-table v-loading="loading" :data="emailAccountList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="邮箱账号" align="center" prop="email" />
<el-table-column label="基本信息" align="center">
<el-table-column label="邮箱账号" align="center" prop="email" />
<el-table-column label="邮箱类型" align="center" prop="type">
<template #default="scope">
<dict-tag :options="email_type" :value="scope.row.type" />
</template>
</el-table-column>
</el-table-column>
<el-table-column label="API方式" align="center">
<el-table-column label="accessKey" align="center" prop="accessKey" />
<el-table-column label="secretKey" align="center" prop="secretKey" />
</el-table-column>
<el-table-column label="SMTP类型" align="center">
<el-table-column label="邮箱授权码/密码" align="center" prop="password" />
<el-table-column label="SMTP服务器地址" align="center" prop="smtpHost" />
<el-table-column label="SMTP端口" align="center" prop="smtpPort" />
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改发件人邮箱账号管理对话框 -->
<el-dialog :title="title" v-model="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="130px">
<!-- 基本信息组 -->
<el-divider>基本信息</el-divider>
<el-form-item label="邮箱账号" prop="email">
<el-input
v-model="form.email"
placeholder="请输入邮箱账号输入后会自动填写SMTP配置"
@blur="autoFillSmtpConfig"
>
<el-tooltip slot="append" content="支持自动填写常见邮箱的SMTP配置" placement="top">
<i class="el-icon-question" style="cursor: pointer; color: #909399;"></i>
</el-tooltip>
</el-input>
</el-form-item>
<el-form-item label="邮箱类型" prop="type">
<el-select v-model="form.type" placeholder="请选择邮箱类型">
<el-option
v-for="dict in email_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<!-- 方式切换提示 -->
<el-form-item label-width="0">
<el-radio-group v-model="emailMode" size="small">
<el-radio-button label="smtp">SMTP方式</el-radio-button>
<el-radio-button label="api">API方式</el-radio-button>
</el-radio-group>
</el-form-item>
<!-- API方式组 -->
<template v-if="emailMode === 'api'">
<el-divider>API方式</el-divider>
<el-form-item label="accessKey" prop="accessKey">
<el-input v-model="form.accessKey" placeholder="请输入API方式用accessKey" />
</el-form-item>
<el-form-item label="secretKey" prop="secretKey">
<el-input v-model="form.secretKey" placeholder="请输入API方式用secretKey" />
</el-form-item>
</template>
<!-- SMTP类型组 -->
<template v-else>
<el-divider>SMTP类型</el-divider>
<el-form-item label="邮箱授权码/密码" prop="password">
<el-input v-model="form.password" placeholder="请输入邮箱授权码/密码" />
</el-form-item>
<el-form-item label="SMTP服务器地址" prop="smtpHost">
<el-input
v-model="form.smtpHost"
placeholder="请输入SMTP服务器地址支持自动填写常见邮箱配置"
/>
</el-form-item>
<el-form-item label="SMTP端口" prop="smtpPort">
<el-input
v-model="form.smtpPort"
placeholder="请输入SMTP端口支持自动填写常见邮箱配置"
/>
</el-form-item>
</template>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { addEmailAccount, delEmailAccount, getEmailAccount, listEmailAccount, updateEmailAccount } from "@/api/oa/emailAccount";
export default {
name: "EmailAccount",
dicts: ['email_type'],
setup() {
const { proxy } = getCurrentInstance();
const { email_type } = proxy.useDict('email_type');
return {
email_type
}
},
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 发件人邮箱账号管理表格数据
emailAccountList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
email: undefined,
type: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
},
emailMode: 'smtp', // 新增:用于切换表单分组
// SMTP配置映射表
smtpConfigs: {
'163.com': {
host: 'smtp.163.com',
port: '465'
},
'126.com': {
host: 'smtp.126.com',
port: '465'
},
'qq.com': {
host: 'smtp.qq.com',
port: '465'
},
'sina.com': {
host: 'smtp.sina.com',
port: '465'
},
'sina.cn': {
host: 'smtp.sina.cn',
port: '465'
},
'sohu.com': {
host: 'smtp.sohu.com',
port: '465'
},
'gmail.com': {
host: 'smtp.gmail.com',
port: '587'
},
'outlook.com': {
host: 'smtp-mail.outlook.com',
port: '587'
},
'hotmail.com': {
host: 'smtp-mail.outlook.com',
port: '587'
}
}
};
},
watch: {
// 根据字段自动切换分组
'form.accessKey'(val) {
this.updateEmailMode();
},
'form.secretKey'(val) {
this.updateEmailMode();
},
'form.password'(val) {
this.updateEmailMode();
},
'form.smtpHost'(val) {
this.updateEmailMode();
},
'form.smtpPort'(val) {
this.updateEmailMode();
},
},
created() {
this.getList();
},
methods: {
/** 查询发件人邮箱账号管理列表 */
getList() {
this.loading = true;
listEmailAccount(this.queryParams).then(response => {
this.emailAccountList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
emailId: undefined,
email: undefined,
password: undefined,
smtpHost: undefined,
smtpPort: undefined,
accessKey: undefined,
secretKey: undefined,
remark: undefined,
createTime: undefined,
updateTime: undefined,
createBy: undefined,
updateBy: undefined,
delFlag: undefined
};
this.emailMode = 'smtp';
this.resetForm("form");
// 如果邮箱字段有值尝试自动填写SMTP配置
if (this.form.email) {
this.$nextTick(() => {
this.autoFillSmtpConfig();
});
}
},
updateEmailMode() {
// 只要API字段有值就是API方式否则为SMTP
if ((this.form.accessKey && this.form.accessKey.trim()) || (this.form.secretKey && this.form.secretKey.trim())) {
this.emailMode = 'api';
// 清空SMTP相关字段
this.form.password = undefined;
this.form.smtpHost = undefined;
this.form.smtpPort = undefined;
} else if ((this.form.password && this.form.password.trim()) || (this.form.smtpHost && this.form.smtpHost.trim()) || (this.form.smtpPort && this.form.smtpPort.trim())) {
this.emailMode = 'smtp';
// 清空API相关字段
this.form.accessKey = undefined;
this.form.secretKey = undefined;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.emailId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加发件人邮箱账号管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const emailId = row.emailId || this.ids
getEmailAccount(emailId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改发件人邮箱账号管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
// 提交时不带type字段
const submitForm = { ...this.form };
// delete submitForm.type;
if (submitForm.emailId != null) {
updateEmailAccount(submitForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addEmailAccount(submitForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const emailIds = row.emailId || this.ids;
this.$modal.confirm('是否确认删除发件人邮箱账号管理编号为"' + emailIds + '"的数据项?').then(() => {
this.loading = true;
return delEmailAccount(emailIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('oa/emailAccount/export', {
...this.queryParams
}, `emailAccount_${new Date().getTime()}.xlsx`)
},
/** 自动填写SMTP配置 */
autoFillSmtpConfig() {
if (!this.form.email) return;
// 提取邮箱域名
const emailDomain = this.form.email.split('@')[1];
if (!emailDomain) return;
// 查找匹配的SMTP配置
const smtpConfig = this.smtpConfigs[emailDomain.toLowerCase()];
if (smtpConfig) {
// 只有在SMTP模式下才自动填写
if (this.emailMode === 'smtp') {
let filled = false;
// 如果SMTP服务器地址为空则自动填写
if (!this.form.smtpHost || this.form.smtpHost.trim() === '') {
this.form.smtpHost = smtpConfig.host;
filled = true;
}
// 如果SMTP端口为空则自动填写
if (!this.form.smtpPort || this.form.smtpPort.trim() === '') {
this.form.smtpPort = smtpConfig.port;
filled = true;
}
// 只有在实际填写了内容时才显示提示
if (filled) {
this.$message({
message: `已自动填写${emailDomain}的SMTP配置`,
type: 'success',
duration: 2000
});
}
}
}
}
}
};
</script>

View File

@@ -0,0 +1,418 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="模板名称" prop="templateName">
<el-input
v-model="queryParams.templateName"
placeholder="请输入模板名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="模板分类" prop="category">
<el-input
v-model="queryParams.category"
placeholder="请输入模板分类"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="emailTemplateList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" v-if="false" />
<el-table-column label="模板名称" align="center" prop="templateName" />
<el-table-column label="模板分类" align="center" prop="category" />
<!-- <el-table-column label="模板内容" align="center" prop="content" /> -->
<!-- <el-table-column label="附件信息" align="center" prop="attachments" /> -->
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleDetail(scope.row)"
>详情</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改邮件模板对话框 -->
<el-dialog :title="title" v-model="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="模板名称" prop="templateName">
<el-input v-model="form.templateName" placeholder="请输入模板名称" />
</el-form-item>
<el-form-item label="模板分类" prop="category">
<el-input v-model="form.category" placeholder="请输入模板分类" />
</el-form-item>
<el-form-item label="模板内容">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
<el-form-item label="附件" prop="attachments" v-if="!form.id">
<FileUpload v-model="form.attachments" multiple :limit="10" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 模板详情对话框 -->
<el-dialog :title="'模板详情'" v-model="detailOpen" width="800px" append-to-body>
<el-descriptions :column="1" border>
<el-descriptions-item label="模板名称">{{ detailData.templateName }}</el-descriptions-item>
<el-descriptions-item label="模板分类">{{ detailData.category }}</el-descriptions-item>
<el-descriptions-item label="模板内容">
<div style="white-space: pre-wrap; word-break: break-all;" v-html="detailData.content"></div>
</el-descriptions-item>
<el-descriptions-item label="附件">
<div v-if="detailData.attachments" class="attachment-list">
<template>
<div v-for="(url, idx) in attachmentUrlList" :key="idx" class="attachment-item">
<template v-if="isImage(url)">
<a :href="url" target="_blank" class="attachment-img-link">
<img :src="url" alt="图片附件" class="attachment-img" />
</a>
</template>
<template v-else>
<el-link :href="url" target="_blank" class="attachment-file-link">
<i class="el-icon-paperclip" style="margin-right:4px;"></i>附件{{idx+1}}
</el-link>
</template>
</div>
</template>
</div>
<div v-else></div>
</el-descriptions-item>
<el-descriptions-item label="备注">
<div style="white-space: pre-wrap; word-break: break-all;">{{ detailData.remark }}</div>
</el-descriptions-item>
</el-descriptions>
<div slot="footer" class="dialog-footer">
<el-button @click="detailOpen = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { addEmailTemplate, delEmailTemplate, getEmailTemplate, listEmailTemplate, updateEmailTemplate } from "@/api/oa/emailTemplate";
import { listByIds } from '@/api/system/oss';
import FileUpload from '@/components/FileUpload';
export default {
name: "EmailTemplate",
components: {
FileUpload
},
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 邮件模板表格数据
emailTemplateList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
templateName: undefined,
category: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
},
detailOpen: false,
detailData: {},
attachmentUrlList: [],
};
},
created() {
this.getList();
},
methods: {
/** 查询邮件模板列表 */
getList() {
this.loading = true;
listEmailTemplate(this.queryParams).then(response => {
this.emailTemplateList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: undefined,
templateName: undefined,
category: undefined,
content: undefined,
attachments: undefined,
createTime: undefined,
updateTime: undefined,
createBy: undefined,
updateBy: undefined,
delFlag: undefined,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加邮件模板";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const id = row.id || this.ids
getEmailTemplate(id).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改邮件模板";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(async valid => {
if (valid) {
this.buttonLoading = true;
// attachments字段为url拼成的csv字符串
let attachmentsCsv = '';
if (this.form.attachments) {
try {
const ossIds = this.form.attachments.split(',').filter(id => id);
if (ossIds.length > 0) {
console.log(ossIds)
const res = await listByIds(ossIds.join(','));
console.log(res)
attachmentsCsv = (res.data || []).map(item => item.url).join(',');
}
} catch (e) {
this.$modal.msgError('附件获取失败');
this.buttonLoading = false;
return;
}
}
const submitData = {
...this.form,
attachments: attachmentsCsv
};
const request = this.form.id != null ? updateEmailTemplate : addEmailTemplate;
request(submitData).then(response => {
this.$modal.msgSuccess(this.form.id != null ? "修改成功" : "新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除邮件模板编号为"' + ids + '"的数据项?').then(() => {
this.loading = true;
return delEmailTemplate(ids);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('oa/emailTemplate/export', {
...this.queryParams
}, `emailTemplate_${new Date().getTime()}.xlsx`)
},
handleDetail(row) {
this.detailData = { ...row };
// 解析csv字符串为url数组
if (row.attachments && typeof row.attachments === 'string') {
this.attachmentUrlList = row.attachments.split(',').map(s => s.trim()).filter(Boolean);
} else if (Array.isArray(row.attachments)) {
this.attachmentUrlList = row.attachments;
} else {
this.attachmentUrlList = [];
}
this.detailOpen = true;
},
isImage(url) {
return /\.(png|jpe?g|gif|bmp|webp|svg)(\?.*)?$/i.test(url);
}
}
};
</script>
<style scoped>
.attachment-list {
background: #f8f9fa;
border: 1px solid #e4e7ed;
border-radius: 6px;
padding: 16px 12px 8px 12px;
margin-bottom: 8px;
display: flex;
flex-wrap: wrap;
gap: 16px 24px;
}
.attachment-item {
display: flex;
flex-direction: column;
align-items: flex-start;
min-width: 120px;
max-width: 180px;
}
.attachment-img-link {
display: block;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
transition: transform 0.2s;
}
.attachment-img-link:hover .attachment-img {
transform: scale(1.08);
box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.attachment-img {
max-width: 120px;
max-height: 80px;
border-radius: 8px;
transition: transform 0.2s, box-shadow 0.2s;
border: 1px solid #ebeef5;
}
.attachment-file-link {
font-weight: 500;
color: #409EFF;
transition: color 0.2s, background 0.2s;
padding: 4px 8px;
border-radius: 4px;
background: #fff;
margin-top: 8px;
display: inline-flex;
align-items: center;
}
.attachment-file-link:hover {
color: #fff;
background: #409EFF;
text-decoration: none;
}
</style>