mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-17 12:35:07 +08:00
Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/dev-yunai
This commit is contained in:
@ -0,0 +1,154 @@
|
||||
package cn.iocoder.yudao.module.system.service.mail;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountCreateReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.mail.MailAccountMapper;
|
||||
import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_ACCOUNT_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* {@link MailAccountServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(MailAccountServiceImpl.class)
|
||||
public class MailAccountServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private MailAccountServiceImpl mailAccountService;
|
||||
|
||||
@Resource
|
||||
private MailAccountMapper mailAccountMapper;
|
||||
|
||||
@MockBean
|
||||
private MailTemplateService mailTemplateService;
|
||||
@MockBean
|
||||
private MailProducer mailProducer;
|
||||
|
||||
@Test
|
||||
public void testInitLocalCache() {
|
||||
MailAccountDO accountDO1 = randomPojo(MailAccountDO.class);
|
||||
mailAccountMapper.insert(accountDO1);
|
||||
MailAccountDO accountDO02 = randomPojo(MailAccountDO.class);
|
||||
mailAccountMapper.insert(accountDO02);
|
||||
|
||||
// 调用
|
||||
mailAccountService.initLocalCache();
|
||||
// 断言 mailAccountCache 缓存
|
||||
Map<Long, MailAccountDO> mailAccountCache = mailAccountService.getMailAccountCache();
|
||||
assertPojoEquals(accountDO1, mailAccountCache.get(accountDO1.getId()));
|
||||
assertPojoEquals(accountDO02, mailAccountCache.get(accountDO02.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMailAccount_success() {
|
||||
// 准备参数
|
||||
MailAccountCreateReqVO reqVO = randomPojo(MailAccountCreateReqVO.class, o -> o.setMail(randomEmail()));
|
||||
|
||||
// 调用
|
||||
Long mailAccountId = mailAccountService.createMailAccount(reqVO);
|
||||
// 断言
|
||||
assertNotNull(mailAccountId);
|
||||
// 校验记录的属性是否正确
|
||||
MailAccountDO mailAccount = mailAccountMapper.selectById(mailAccountId);
|
||||
assertPojoEquals(reqVO, mailAccount);
|
||||
verify(mailProducer).sendMailAccountRefreshMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMailAccount_success() {
|
||||
// mock 数据
|
||||
MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class);
|
||||
mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
MailAccountUpdateReqVO reqVO = randomPojo(MailAccountUpdateReqVO.class, o -> {
|
||||
o.setId(dbMailAccount.getId()); // 设置更新的 ID
|
||||
o.setMail(randomEmail());
|
||||
});
|
||||
|
||||
// 调用
|
||||
mailAccountService.updateMailAccount(reqVO);
|
||||
// 校验是否更新正确
|
||||
MailAccountDO mailAccount = mailAccountMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, mailAccount);
|
||||
verify(mailProducer).sendMailAccountRefreshMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMailAccount_notExists() {
|
||||
// 准备参数
|
||||
MailAccountUpdateReqVO reqVO = randomPojo(MailAccountUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> mailAccountService.updateMailAccount(reqVO), MAIL_ACCOUNT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMailAccount_success() {
|
||||
// mock 数据
|
||||
MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class);
|
||||
mailAccountMapper.insert(dbMailAccount);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbMailAccount.getId();
|
||||
|
||||
// 调用
|
||||
mailAccountService.deleteMailAccount(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(mailAccountMapper.selectById(id));
|
||||
verify(mailProducer).sendMailAccountRefreshMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMailAccount_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> mailAccountService.deleteMailAccount(id), MAIL_ACCOUNT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMailAccountPage() {
|
||||
// mock 数据
|
||||
MailAccountDO dbMailAccount = randomPojo(MailAccountDO.class, o -> { // 等会查询到
|
||||
o.setMail("768@qq.com");
|
||||
o.setUsername("yunai");
|
||||
});
|
||||
mailAccountMapper.insert(dbMailAccount);
|
||||
// 测试 mail 不匹配
|
||||
mailAccountMapper.insert(cloneIgnoreId(dbMailAccount, o -> o.setMail("788@qq.com")));
|
||||
// 测试 username 不匹配
|
||||
mailAccountMapper.insert(cloneIgnoreId(dbMailAccount, o -> o.setUsername("tudou")));
|
||||
// 准备参数
|
||||
MailAccountPageReqVO reqVO = new MailAccountPageReqVO();
|
||||
reqVO.setMail("768");
|
||||
reqVO.setUsername("yu");
|
||||
|
||||
// 调用
|
||||
PageResult<MailAccountDO> pageResult = mailAccountService.getMailAccountPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbMailAccount, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
package cn.iocoder.yudao.module.system.service.mail;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.log.MailLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailLogDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.mail.MailLogMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.mail.MailSendStatusEnum;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link MailLogServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(MailLogServiceImpl.class)
|
||||
public class MailLogServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private MailLogServiceImpl mailLogService;
|
||||
|
||||
@Resource
|
||||
private MailLogMapper mailLogMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateMailLog() {
|
||||
// 准备参数
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
String toMail = randomEmail();
|
||||
MailAccountDO account = randomPojo(MailAccountDO.class);
|
||||
MailTemplateDO template = randomPojo(MailTemplateDO.class);
|
||||
String templateContent = randomString();
|
||||
Map<String, Object> templateParams = randomTemplateParams();
|
||||
Boolean isSend = true;
|
||||
// mock 方法
|
||||
|
||||
// 调用
|
||||
Long logId = mailLogService.createMailLog(userId, userType, toMail, account, template, templateContent, templateParams, isSend);
|
||||
// 断言
|
||||
MailLogDO log = mailLogMapper.selectById(logId);
|
||||
assertNotNull(log);
|
||||
assertEquals(MailSendStatusEnum.INIT.getStatus(), log.getSendStatus());
|
||||
assertEquals(userId, log.getUserId());
|
||||
assertEquals(userType, log.getUserType());
|
||||
assertEquals(toMail, log.getToMail());
|
||||
assertEquals(account.getId(), log.getAccountId());
|
||||
assertEquals(account.getMail(), log.getFromMail());
|
||||
assertEquals(template.getId(), log.getTemplateId());
|
||||
assertEquals(template.getCode(), log.getTemplateCode());
|
||||
assertEquals(template.getNickname(), log.getTemplateNickname());
|
||||
assertEquals(template.getTitle(), log.getTemplateTitle());
|
||||
assertEquals(templateContent, log.getTemplateContent());
|
||||
assertEquals(templateParams, log.getTemplateParams());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMailSendResult_success() {
|
||||
// mock 数据
|
||||
MailLogDO log = randomPojo(MailLogDO.class, o -> {
|
||||
o.setSendStatus(MailSendStatusEnum.INIT.getStatus());
|
||||
o.setSendTime(null).setSendMessageId(null).setSendException(null)
|
||||
.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
mailLogMapper.insert(log);
|
||||
// 准备参数
|
||||
Long logId = log.getId();
|
||||
String messageId = randomString();
|
||||
|
||||
// 调用
|
||||
mailLogService.updateMailSendResult(logId, messageId, null);
|
||||
// 断言
|
||||
MailLogDO dbLog = mailLogMapper.selectById(logId);
|
||||
assertEquals(MailSendStatusEnum.SUCCESS.getStatus(), dbLog.getSendStatus());
|
||||
assertNotNull(dbLog.getSendTime());
|
||||
assertEquals(messageId, dbLog.getSendMessageId());
|
||||
assertNull(dbLog.getSendException());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMailSendResult_exception() {
|
||||
// mock 数据
|
||||
MailLogDO log = randomPojo(MailLogDO.class, o -> {
|
||||
o.setSendStatus(MailSendStatusEnum.INIT.getStatus());
|
||||
o.setSendTime(null).setSendMessageId(null).setSendException(null)
|
||||
.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
mailLogMapper.insert(log);
|
||||
// 准备参数
|
||||
Long logId = log.getId();
|
||||
Exception exception = new NullPointerException("测试异常");
|
||||
|
||||
// 调用
|
||||
mailLogService.updateMailSendResult(logId, null, exception);
|
||||
// 断言
|
||||
MailLogDO dbLog = mailLogMapper.selectById(logId);
|
||||
assertEquals(MailSendStatusEnum.FAILURE.getStatus(), dbLog.getSendStatus());
|
||||
assertNotNull(dbLog.getSendTime());
|
||||
assertNull(dbLog.getSendMessageId());
|
||||
assertEquals("NullPointerException: 测试异常", dbLog.getSendException());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMailLogPage() {
|
||||
// mock 数据
|
||||
MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setToMail("768@qq.com");
|
||||
o.setAccountId(10L);
|
||||
o.setTemplateId(100L);
|
||||
o.setSendStatus(MailSendStatusEnum.INIT.getStatus());
|
||||
o.setSendTime(buildTime(2023, 2, 10));
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
mailLogMapper.insert(dbMailLog);
|
||||
// 测试 userId 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 toMail 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setToMail("788@.qq.com")));
|
||||
// 测试 accountId 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setAccountId(11L)));
|
||||
// 测试 templateId 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setTemplateId(101L)));
|
||||
// 测试 sendStatus 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendStatus(MailSendStatusEnum.SUCCESS.getStatus())));
|
||||
// 测试 sendTime 不匹配
|
||||
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendTime(buildTime(2023, 3, 10))));
|
||||
// 准备参数
|
||||
MailLogPageReqVO reqVO = new MailLogPageReqVO();
|
||||
reqVO.setUserId(1L);
|
||||
reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
reqVO.setToMail("768");
|
||||
reqVO.setAccountId(10L);
|
||||
reqVO.setTemplateId(100L);
|
||||
reqVO.setSendStatus(MailSendStatusEnum.INIT.getStatus());
|
||||
reqVO.setSendTime((buildBetweenTime(2023, 2, 1, 2023, 2, 15)));
|
||||
|
||||
// 调用
|
||||
PageResult<MailLogDO> pageResult = mailLogService.getMailLogPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbMailLog, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
private static Map<String, Object> randomTemplateParams() {
|
||||
return MapUtil.<String, Object>builder().put(randomString(), randomString())
|
||||
.put(randomString(), randomString()).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package cn.iocoder.yudao.module.system.service.mail;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.extra.mail.MailAccount;
|
||||
import cn.hutool.extra.mail.MailUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class MailSendServiceImplTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private MailSendServiceImpl mailSendService;
|
||||
|
||||
@Mock
|
||||
private MailAccountService mailAccountService;
|
||||
@Mock
|
||||
private MailTemplateService mailTemplateService;
|
||||
@Mock
|
||||
private MailLogService mailLogService;
|
||||
@Mock
|
||||
private MailProducer mailProducer;
|
||||
|
||||
/**
|
||||
* 用于快速测试你的邮箱账号是否正常
|
||||
*/
|
||||
@Test
|
||||
@Disabled
|
||||
public void testDemo() {
|
||||
MailAccount mailAccount = new MailAccount()
|
||||
// .setFrom("奥特曼 <ydym_test@163.com>")
|
||||
.setFrom("ydym_test@163.com") // 邮箱地址
|
||||
.setHost("smtp.163.com").setPort(465).setSslEnable(true) // SMTP 服务器
|
||||
.setAuth(true).setUser("ydym_test@163.com").setPass("WBZTEINMIFVRYSOE"); // 登录账号密码
|
||||
String messageId = MailUtil.send(mailAccount, "7685413@qq.com", "主题", "内容", false);
|
||||
System.out.println("发送结果:" + messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送成功,当短信模板开启时
|
||||
*/
|
||||
@Test
|
||||
public void testSendSingleMail_successWhenMailTemplateEnable() {
|
||||
// 准备参数
|
||||
String mail = randomEmail();
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
String templateCode = randomString();
|
||||
Map<String, Object> templateParams = MapUtil.<String, Object>builder().put("code", "1234")
|
||||
.put("op", "login").build();
|
||||
// mock MailTemplateService 的方法
|
||||
MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> {
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setContent("验证码为{code}, 操作为{op}");
|
||||
o.setParams(Lists.newArrayList("code", "op"));
|
||||
});
|
||||
when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
|
||||
String content = randomString();
|
||||
when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
|
||||
.thenReturn(content);
|
||||
// mock MailAccountService 的方法
|
||||
MailAccountDO account = randomPojo(MailAccountDO.class);
|
||||
when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account);
|
||||
// mock MailLogService 的方法
|
||||
Long mailLogId = randomLongId();
|
||||
when(mailLogService.createMailLog(eq(userId), eq(userType), eq(mail),
|
||||
eq(account), eq(template), eq(content), eq(templateParams), eq(true))).thenReturn(mailLogId);
|
||||
|
||||
// 调用
|
||||
Long resultMailLogId = mailSendService.sendSingleMail(mail, userId, userType, templateCode, templateParams);
|
||||
// 断言
|
||||
assertEquals(mailLogId, resultMailLogId);
|
||||
// 断言调用
|
||||
verify(mailProducer).sendMailSendMessage(eq(mailLogId), eq(mail),
|
||||
eq(account.getId()), eq(template.getNickname()), eq(template.getTitle()), eq(content));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送成功,当短信模板关闭时
|
||||
*/
|
||||
@Test
|
||||
public void testSendSingleMail_successWhenSmsTemplateDisable() {
|
||||
// 准备参数
|
||||
String mail = randomEmail();
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
String templateCode = randomString();
|
||||
Map<String, Object> templateParams = MapUtil.<String, Object>builder().put("code", "1234")
|
||||
.put("op", "login").build();
|
||||
// mock MailTemplateService 的方法
|
||||
MailTemplateDO template = randomPojo(MailTemplateDO.class, o -> {
|
||||
o.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||
o.setContent("验证码为{code}, 操作为{op}");
|
||||
o.setParams(Lists.newArrayList("code", "op"));
|
||||
});
|
||||
when(mailTemplateService.getMailTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
|
||||
String content = randomString();
|
||||
when(mailTemplateService.formatMailTemplateContent(eq(template.getContent()), eq(templateParams)))
|
||||
.thenReturn(content);
|
||||
// mock MailAccountService 的方法
|
||||
MailAccountDO account = randomPojo(MailAccountDO.class);
|
||||
when(mailAccountService.getMailAccountFromCache(eq(template.getAccountId()))).thenReturn(account);
|
||||
// mock MailLogService 的方法
|
||||
Long mailLogId = randomLongId();
|
||||
when(mailLogService.createMailLog(eq(userId), eq(userType), eq(mail),
|
||||
eq(account), eq(template), eq(content), eq(templateParams), eq(false))).thenReturn(mailLogId);
|
||||
|
||||
// 调用
|
||||
Long resultMailLogId = mailSendService.sendSingleMail(mail, userId, userType, templateCode, templateParams);
|
||||
// 断言
|
||||
assertEquals(mailLogId, resultMailLogId);
|
||||
// 断言调用
|
||||
verify(mailProducer, times(0)).sendMailSendMessage(anyLong(), anyString(),
|
||||
anyLong(), anyString(), anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckMailTemplateValid_notExists() {
|
||||
// 准备参数
|
||||
String templateCode = randomString();
|
||||
// mock 方法
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> mailSendService.checkMailTemplateValid(templateCode),
|
||||
MAIL_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckTemplateParams_paramMiss() {
|
||||
// 准备参数
|
||||
MailTemplateDO template = randomPojo(MailTemplateDO.class,
|
||||
o -> o.setParams(Lists.newArrayList("code")));
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
// mock 方法
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> mailSendService.checkTemplateParams(template, templateParams),
|
||||
MAIL_SEND_TEMPLATE_PARAM_MISS, "code");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckMail_notExists() {
|
||||
// 准备参数
|
||||
// mock 方法
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> mailSendService.checkMail(null),
|
||||
MAIL_SEND_MAIL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
package cn.iocoder.yudao.module.system.service.mail;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateCreateReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplatePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.MailTemplateUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.mail.MailTemplateMapper;
|
||||
import cn.iocoder.yudao.module.system.mq.producer.mail.MailProducer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.MAIL_TEMPLATE_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link MailTemplateServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(MailTemplateServiceImpl.class)
|
||||
public class MailTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private MailTemplateServiceImpl mailTemplateService;
|
||||
|
||||
@Resource
|
||||
private MailTemplateMapper mailTemplateMapper;
|
||||
|
||||
@MockBean
|
||||
private MailProducer mailProducer;
|
||||
|
||||
@Test
|
||||
public void testInitLocalCache() {
|
||||
MailTemplateDO templateDO01 = randomPojo(MailTemplateDO.class);
|
||||
mailTemplateMapper.insert(templateDO01);
|
||||
MailTemplateDO templateDO02 = randomPojo(MailTemplateDO.class);
|
||||
mailTemplateMapper.insert(templateDO02);
|
||||
|
||||
// 调用
|
||||
mailTemplateService.initLocalCache();
|
||||
// 断言 mailTemplateCache 缓存
|
||||
Map<String, MailTemplateDO> mailTemplateCache = mailTemplateService.getMailTemplateCache();
|
||||
assertPojoEquals(templateDO01, mailTemplateCache.get(templateDO01.getCode()));
|
||||
assertPojoEquals(templateDO02, mailTemplateCache.get(templateDO02.getCode()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMailTemplate_success() {
|
||||
// 准备参数
|
||||
MailTemplateCreateReqVO reqVO = randomPojo(MailTemplateCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long mailTemplateId = mailTemplateService.createMailTemplate(reqVO);
|
||||
// 断言
|
||||
assertNotNull(mailTemplateId);
|
||||
// 校验记录的属性是否正确
|
||||
MailTemplateDO mailTemplate = mailTemplateMapper.selectById(mailTemplateId);
|
||||
assertPojoEquals(reqVO, mailTemplate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMailTemplate_success() {
|
||||
// mock 数据
|
||||
MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class);
|
||||
mailTemplateMapper.insert(dbMailTemplate);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
MailTemplateUpdateReqVO reqVO = randomPojo(MailTemplateUpdateReqVO.class, o -> {
|
||||
o.setId(dbMailTemplate.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
mailTemplateService.updateMailTemplate(reqVO);
|
||||
// 校验是否更新正确
|
||||
MailTemplateDO mailTemplate = mailTemplateMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, mailTemplate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMailTemplate_notExists() {
|
||||
// 准备参数
|
||||
MailTemplateUpdateReqVO reqVO = randomPojo(MailTemplateUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> mailTemplateService.updateMailTemplate(reqVO), MAIL_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMailTemplate_success() {
|
||||
// mock 数据
|
||||
MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class);
|
||||
mailTemplateMapper.insert(dbMailTemplate);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbMailTemplate.getId();
|
||||
|
||||
// 调用
|
||||
mailTemplateService.deleteMailTemplate(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(mailTemplateMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMailTemplate_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> mailTemplateService.deleteMailTemplate(id), MAIL_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMailTemplatePage() {
|
||||
// mock 数据
|
||||
MailTemplateDO dbMailTemplate = randomPojo(MailTemplateDO.class, o -> { // 等会查询到
|
||||
o.setName("源码");
|
||||
o.setCode("test_01");
|
||||
o.setAccountId(1L);
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setCreateTime(buildTime(2023, 2, 3));
|
||||
});
|
||||
mailTemplateMapper.insert(dbMailTemplate);
|
||||
// 测试 name 不匹配
|
||||
mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setName("芋道")));
|
||||
// 测试 code 不匹配
|
||||
mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setCode("test_02")));
|
||||
// 测试 accountId 不匹配
|
||||
mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setAccountId(2L)));
|
||||
// 测试 status 不匹配
|
||||
mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
||||
// 测试 createTime 不匹配
|
||||
mailTemplateMapper.insert(cloneIgnoreId(dbMailTemplate, o -> o.setCreateTime(buildTime(2023, 1, 5))));
|
||||
// 准备参数
|
||||
MailTemplatePageReqVO reqVO = new MailTemplatePageReqVO();
|
||||
reqVO.setName("源");
|
||||
reqVO.setCode("est_01");
|
||||
reqVO.setAccountId(1L);
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 5));
|
||||
|
||||
// 调用
|
||||
PageResult<MailTemplateDO> pageResult = mailTemplateService.getMailTemplatePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbMailTemplate, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
package cn.iocoder.yudao.module.system.service.notify;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link NotifyMessageServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(NotifyMessageServiceImpl.class)
|
||||
public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private NotifyMessageServiceImpl notifyMessageService;
|
||||
|
||||
@Resource
|
||||
private NotifyMessageMapper notifyMessageMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateNotifyMessage_success() {
|
||||
// 准备参数
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class);
|
||||
String templateContent = randomString();
|
||||
Map<String, Object> templateParams = randomTemplateParams();
|
||||
// mock 方法
|
||||
|
||||
// 调用
|
||||
Long messageId = notifyMessageService.createNotifyMessage(userId, userType,
|
||||
template, templateContent, templateParams);
|
||||
// 断言
|
||||
NotifyMessageDO message = notifyMessageMapper.selectById(messageId);
|
||||
assertNotNull(message);
|
||||
assertEquals(userId, message.getUserId());
|
||||
assertEquals(userType, message.getUserType());
|
||||
assertEquals(template.getId(), message.getTemplateId());
|
||||
assertEquals(template.getCode(), message.getTemplateCode());
|
||||
assertEquals(template.getType(), message.getTemplateType());
|
||||
assertEquals(template.getNickname(), message.getTemplateNickname());
|
||||
assertEquals(templateContent, message.getTemplateContent());
|
||||
assertEquals(templateParams, message.getTemplateParams());
|
||||
assertEquals(false, message.getReadStatus());
|
||||
assertNull(message.getReadTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNotifyMessagePage() {
|
||||
// mock 数据
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setTemplateCode("test_01");
|
||||
o.setTemplateType(10);
|
||||
o.setCreateTime(buildTime(2022, 1, 2));
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
// 测试 userId 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 templateCode 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateCode("test_11")));
|
||||
// 测试 templateType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateType(20)));
|
||||
// 测试 createTime 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1))));
|
||||
// 准备参数
|
||||
NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
|
||||
reqVO.setUserId(1L);
|
||||
reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
reqVO.setTemplateCode("est_01");
|
||||
reqVO.setTemplateType(10);
|
||||
reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10));
|
||||
|
||||
// 调用
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMyNotifyMessagePage() {
|
||||
// mock 数据
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setReadStatus(true);
|
||||
o.setCreateTime(buildTime(2022, 1, 2));
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
// 测试 userId 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 readStatus 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(false)));
|
||||
// 测试 createTime 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1))));
|
||||
// 准备参数
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
NotifyMessageMyPageReqVO reqVO = new NotifyMessageMyPageReqVO();
|
||||
reqVO.setReadStatus(true);
|
||||
reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10));
|
||||
|
||||
// 调用
|
||||
PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO, userId, userType);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUnreadNotifyMessageList() {
|
||||
SqlConstants.init(DbType.MYSQL);
|
||||
// mock 数据
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setReadStatus(false);
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
// 测试 userId 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 readStatus 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
|
||||
// 准备参数
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
Integer size = 10;
|
||||
|
||||
// 调用
|
||||
List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(userId, userType, size);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbNotifyMessage, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUnreadNotifyMessageCount() {
|
||||
SqlConstants.init(DbType.MYSQL);
|
||||
// mock 数据
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setReadStatus(false);
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
// 测试 userId 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 readStatus 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
|
||||
// 准备参数
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
|
||||
// 调用,并断言
|
||||
assertEquals(1, notifyMessageService.getUnreadNotifyMessageCount(userId, userType));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNotifyMessageRead() {
|
||||
// mock 数据
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setReadStatus(false);
|
||||
o.setReadTime(null);
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
// 测试 userId 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 readStatus 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
|
||||
// 准备参数
|
||||
Collection<Long> ids = Arrays.asList(dbNotifyMessage.getId(), dbNotifyMessage.getId() + 1,
|
||||
dbNotifyMessage.getId() + 2, dbNotifyMessage.getId() + 3);
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
|
||||
// 调用
|
||||
int updateCount = notifyMessageService.updateNotifyMessageRead(ids, userId, userType);
|
||||
// 断言
|
||||
assertEquals(1, updateCount);
|
||||
NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId());
|
||||
assertTrue(notifyMessage.getReadStatus());
|
||||
assertNotNull(notifyMessage.getReadTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAllNotifyMessageRead() {
|
||||
// mock 数据
|
||||
NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
|
||||
o.setUserId(1L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setReadStatus(false);
|
||||
o.setReadTime(null);
|
||||
o.setTemplateParams(randomTemplateParams());
|
||||
});
|
||||
notifyMessageMapper.insert(dbNotifyMessage);
|
||||
// 测试 userId 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
|
||||
// 测试 userType 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 readStatus 不匹配
|
||||
notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
|
||||
// 准备参数
|
||||
Long userId = 1L;
|
||||
Integer userType = UserTypeEnum.ADMIN.getValue();
|
||||
|
||||
// 调用
|
||||
int updateCount = notifyMessageService.updateAllNotifyMessageRead(userId, userType);
|
||||
// 断言
|
||||
assertEquals(1, updateCount);
|
||||
NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId());
|
||||
assertTrue(notifyMessage.getReadStatus());
|
||||
assertNotNull(notifyMessage.getReadTime());
|
||||
}
|
||||
|
||||
private static Map<String, Object> randomTemplateParams() {
|
||||
return MapUtil.<String, Object>builder().put(randomString(), randomString())
|
||||
.put(randomString(), randomString()).build();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package cn.iocoder.yudao.module.system.service.notify;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class NotifySendServiceImplTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private NotifySendServiceImpl notifySendService;
|
||||
|
||||
@Mock
|
||||
private NotifyTemplateService notifyTemplateService;
|
||||
@Mock
|
||||
private NotifyMessageService notifyMessageService;
|
||||
|
||||
/**
|
||||
* 发送成功,当短信模板开启时
|
||||
*/
|
||||
@Test
|
||||
public void testSendSingleNotify_successWhenMailTemplateEnable() {
|
||||
// 准备参数
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
String templateCode = randomString();
|
||||
Map<String, Object> templateParams = MapUtil.<String, Object>builder().put("code", "1234")
|
||||
.put("op", "login").build();
|
||||
// mock NotifyTemplateService 的方法
|
||||
NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> {
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setContent("验证码为{code}, 操作为{op}");
|
||||
o.setParams(Lists.newArrayList("code", "op"));
|
||||
});
|
||||
when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
|
||||
String content = randomString();
|
||||
when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams)))
|
||||
.thenReturn(content);
|
||||
// mock NotifyMessageService 的方法
|
||||
Long messageId = randomLongId();
|
||||
when(notifyMessageService.createNotifyMessage(eq(userId), eq(userType),
|
||||
eq(template), eq(content), eq(templateParams))).thenReturn(messageId);
|
||||
|
||||
// 调用
|
||||
Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams);
|
||||
// 断言
|
||||
assertEquals(messageId, resultMessageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送成功,当短信模板关闭时
|
||||
*/
|
||||
@Test
|
||||
public void testSendSingleMail_successWhenSmsTemplateDisable() {
|
||||
// 准备参数
|
||||
Long userId = randomLongId();
|
||||
Integer userType = randomEle(UserTypeEnum.values()).getValue();
|
||||
String templateCode = randomString();
|
||||
Map<String, Object> templateParams = MapUtil.<String, Object>builder().put("code", "1234")
|
||||
.put("op", "login").build();
|
||||
// mock NotifyTemplateService 的方法
|
||||
NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> {
|
||||
o.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||
o.setContent("验证码为{code}, 操作为{op}");
|
||||
o.setParams(Lists.newArrayList("code", "op"));
|
||||
});
|
||||
when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
|
||||
|
||||
// 调用
|
||||
Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams);
|
||||
// 断言
|
||||
assertNull(resultMessageId);
|
||||
verify(notifyTemplateService, never()).formatNotifyTemplateContent(anyString(), anyMap());
|
||||
verify(notifyMessageService, never()).createNotifyMessage(anyLong(), anyInt(), any(), anyString(), anyMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckMailTemplateValid_notExists() {
|
||||
// 准备参数
|
||||
String templateCode = randomString();
|
||||
// mock 方法
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> notifySendService.checkNotifyTemplateValid(templateCode),
|
||||
NOTICE_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckTemplateParams_paramMiss() {
|
||||
// 准备参数
|
||||
NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class,
|
||||
o -> o.setParams(Lists.newArrayList("code")));
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
// mock 方法
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> notifySendService.checkTemplateParams(template, templateParams),
|
||||
NOTIFY_SEND_TEMPLATE_PARAM_MISS, "code");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package cn.iocoder.yudao.module.system.service.notify;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
|
||||
import cn.iocoder.yudao.module.system.mq.producer.notify.NotifyProducer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_TEMPLATE_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* {@link NotifyTemplateServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(NotifyTemplateServiceImpl.class)
|
||||
public class NotifyTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private NotifyTemplateServiceImpl notifyTemplateService;
|
||||
|
||||
@Resource
|
||||
private NotifyTemplateMapper notifyTemplateMapper;
|
||||
|
||||
@MockBean
|
||||
private NotifyProducer notifyProducer;
|
||||
|
||||
@Test
|
||||
public void testCreateNotifyTemplate_success() {
|
||||
// 准备参数
|
||||
NotifyTemplateCreateReqVO reqVO = randomPojo(NotifyTemplateCreateReqVO.class,
|
||||
o -> o.setStatus(randomCommonStatus()));
|
||||
|
||||
// 调用
|
||||
Long notifyTemplateId = notifyTemplateService.createNotifyTemplate(reqVO);
|
||||
// 断言
|
||||
assertNotNull(notifyTemplateId);
|
||||
// 校验记录的属性是否正确
|
||||
NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(notifyTemplateId);
|
||||
assertPojoEquals(reqVO, notifyTemplate);
|
||||
verify(notifyProducer).sendNotifyTemplateRefreshMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNotifyTemplate_success() {
|
||||
// mock 数据
|
||||
NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class);
|
||||
notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
NotifyTemplateUpdateReqVO reqVO = randomPojo(NotifyTemplateUpdateReqVO.class, o -> {
|
||||
o.setId(dbNotifyTemplate.getId()); // 设置更新的 ID
|
||||
o.setStatus(randomCommonStatus());
|
||||
});
|
||||
|
||||
// 调用
|
||||
notifyTemplateService.updateNotifyTemplate(reqVO);
|
||||
// 校验是否更新正确
|
||||
NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, notifyTemplate);
|
||||
verify(notifyProducer).sendNotifyTemplateRefreshMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateNotifyTemplate_notExists() {
|
||||
// 准备参数
|
||||
NotifyTemplateUpdateReqVO reqVO = randomPojo(NotifyTemplateUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> notifyTemplateService.updateNotifyTemplate(reqVO), NOTIFY_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteNotifyTemplate_success() {
|
||||
// mock 数据
|
||||
NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class);
|
||||
notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbNotifyTemplate.getId();
|
||||
|
||||
// 调用
|
||||
notifyTemplateService.deleteNotifyTemplate(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(notifyTemplateMapper.selectById(id));
|
||||
verify(notifyProducer).sendNotifyTemplateRefreshMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteNotifyTemplate_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> notifyTemplateService.deleteNotifyTemplate(id), NOTIFY_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNotifyTemplatePage() {
|
||||
// mock 数据
|
||||
NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class, o -> { // 等会查询到
|
||||
o.setName("芋头");
|
||||
o.setCode("test_01");
|
||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
o.setCreateTime(buildTime(2022, 2, 3));
|
||||
});
|
||||
notifyTemplateMapper.insert(dbNotifyTemplate);
|
||||
// 测试 name 不匹配
|
||||
notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setName("投")));
|
||||
// 测试 code 不匹配
|
||||
notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCode("test_02")));
|
||||
// 测试 status 不匹配
|
||||
notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
||||
// 测试 createTime 不匹配
|
||||
notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCreateTime(buildTime(2022, 1, 5))));
|
||||
// 准备参数
|
||||
NotifyTemplatePageReqVO reqVO = new NotifyTemplatePageReqVO();
|
||||
reqVO.setName("芋");
|
||||
reqVO.setCode("est_01");
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 5));
|
||||
|
||||
// 调用
|
||||
PageResult<NotifyTemplateDO> pageResult = notifyTemplateService.getNotifyTemplatePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbNotifyTemplate, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -235,7 +235,6 @@ public class SmsLogServiceTest extends BaseDbUnitTest {
|
||||
return randomPojo(SmsLogDO.class, ArrayUtils.append(consumer, consumers));
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, Object> randomTemplateParams() {
|
||||
return MapUtil.<String, Object>builder().put(randomString(), randomString())
|
||||
.put(randomString(), randomString()).build();
|
||||
|
@ -25,3 +25,8 @@ DELETE FROM "system_oauth2_approve";
|
||||
DELETE FROM "system_oauth2_access_token";
|
||||
DELETE FROM "system_oauth2_refresh_token";
|
||||
DELETE FROM "system_oauth2_code";
|
||||
DELETE FROM "system_mail_account";
|
||||
DELETE FROM "system_mail_template";
|
||||
DELETE FROM "system_mail_log";
|
||||
DELETE FROM "system_notify_template";
|
||||
DELETE FROM "system_notify_message";
|
||||
|
@ -566,3 +566,103 @@ CREATE TABLE IF NOT EXISTS "system_oauth2_code" (
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT 'OAuth2 刷新令牌';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "system_mail_account" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"mail" varchar NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"password" varchar NOT NULL,
|
||||
"host" varchar NOT NULL,
|
||||
"port" int NOT NULL,
|
||||
"ssl_enable" bit NOT NULL,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '邮箱账号表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "system_mail_template" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"name" varchar NOT NULL,
|
||||
"code" varchar NOT NULL,
|
||||
"account_id" bigint NOT NULL,
|
||||
"nickname" varchar,
|
||||
"title" varchar NOT NULL,
|
||||
"content" varchar NOT NULL,
|
||||
"params" varchar NOT NULL,
|
||||
"status" varchar NOT NULL,
|
||||
"remark" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '邮件模版表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "system_mail_log" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"user_id" bigint,
|
||||
"user_type" varchar,
|
||||
"to_mail" varchar NOT NULL,
|
||||
"account_id" bigint NOT NULL,
|
||||
"from_mail" varchar NOT NULL,
|
||||
"template_id" bigint NOT NULL,
|
||||
"template_code" varchar NOT NULL,
|
||||
"template_nickname" varchar,
|
||||
"template_title" varchar NOT NULL,
|
||||
"template_content" varchar NOT NULL,
|
||||
"template_params" varchar NOT NULL,
|
||||
"send_status" varchar NOT NULL,
|
||||
"send_time" datetime,
|
||||
"send_message_id" varchar,
|
||||
"send_exception" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '邮件日志表';
|
||||
|
||||
-- 将该建表 SQL 语句,添加到 yudao-module-system-biz 模块的 test/resources/sql/create_tables.sql 文件里
|
||||
CREATE TABLE IF NOT EXISTS "system_notify_template" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"name" varchar NOT NULL,
|
||||
"code" varchar NOT NULL,
|
||||
"nickname" varchar NOT NULL,
|
||||
"content" varchar NOT NULL,
|
||||
"type" varchar NOT NULL,
|
||||
"params" varchar,
|
||||
"status" varchar NOT NULL,
|
||||
"remark" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '站内信模板表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "system_notify_message" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"user_id" bigint NOT NULL,
|
||||
"user_type" varchar NOT NULL,
|
||||
"template_id" bigint NOT NULL,
|
||||
"template_code" varchar NOT NULL,
|
||||
"template_nickname" varchar NOT NULL,
|
||||
"template_content" varchar NOT NULL,
|
||||
"template_type" int NOT NULL,
|
||||
"template_params" varchar NOT NULL,
|
||||
"read_status" bit NOT NULL,
|
||||
"read_time" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
"tenant_id" bigint not null default '0',
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '站内信消息表';
|
||||
|
Reference in New Issue
Block a user