提交 e3189e71 authored 作者: mooncake's avatar mooncake

email

上级 af2a984d
......@@ -18,6 +18,7 @@ import (
xsfUtils "gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gorm.io/gorm"
"gopkg.in/gomail.v2"
......@@ -124,6 +125,8 @@ type oEmail struct {
var OEmail = &oEmail{}
type Params struct {
UType int
UID xsf.ID
TplCode string
TplParams map[string]string
Attachments []*config.Attachment
......@@ -165,6 +168,8 @@ func (x *oEmail) SendTLS(ctx context.Context, in *Params) (err error) {
email := models.Email{}
email.ID = xsfUtils.EmailID(ctx)
email.TplID = et.ID
email.UType = in.UType
email.UID = in.UID
email.From = from
email.Subject = subjectBuf.String()
email.Content = contentBuf.String()
......
drop table if exists `email_tpl`;
CREATE TABLE `email_tpl` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户主键id eg[1]',
`code` tinyint(8) DEFAULT NULL COMMENT '模板代码 eg[SMS_NOTICE]',
`subject` varchar(255) default NULL COMMENT '主题 eg[验证码]',
`tpl` text default NULL COMMENT '模板 eg[<div>hello moon! </div>]',
`code` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '模板代码 eg[SMS_NOTICE]',
`subject` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主题 eg[验证码]',
`tpl` text COLLATE utf8mb4_unicode_ci COMMENT '模板 eg[<div>hello moon! </div>]',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间 eg[2024-03-27 17:11:00]',
`updated_at` datetime DEFAULT NULL COMMENT '更新时间 eg[2024-03-27 17:11:00]',
PRIMARY KEY (`id`),
KEY `idx_code` (`code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='邮件模板';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='邮件模板';
drop table if exists `email_tpl_receiver`;
CREATE TABLE `email_tpl_receiver` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户主键id eg[1]',
......@@ -23,13 +23,18 @@ drop table if exists `email`;
CREATE TABLE `email` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户主键id eg[1]',
`tpl_id` bigint(20) NOT NULL COMMENT '模板id eg[1]',
`utype` int NOT NULL COMMENT 'utype eg[1]',
`uid` bigint(20) NOT NULL COMMENT 'uid eg[1]',
`from` varchar(255) DEFAULT NULL COMMENT '发件人 eg[月饼<mooncake2026@163.com>]',
`subject` varchar(255) default NULL COMMENT '主题 eg[验证码]',
`content` text default NULL COMMENT '邮件内容 eg[<div>hello moon! </div>]',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间 eg[2024-03-27 17:11:00]',
`updated_at` datetime DEFAULT NULL COMMENT '更新时间 eg[2024-03-27 17:11:00]',
PRIMARY KEY (`id`),
KEY `idx_from` (`from`) USING BTREE
KEY `idx_from` (`from`) USING BTREE,
KEY `idx_uid` (`uid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='邮件';
drop table if exists `email_receiver`;
CREATE TABLE `email_receiver` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户主键id eg[1]',
......
......@@ -10,9 +10,11 @@ import (
// Email 邮件
type Email struct {
ID xsf.ID `json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"` //主键
UID xsf.ID `json:"uid" form:"uid" swaggertype:"string" gorm:"column:uid;type:bigint(20);comment:uid" example:"1" csv:"uid"` //uid
UType int `json:"utype" form:"utype" gorm:"column:utype;type:int(11);comment:utype" example:"1" csv:"utype"` //utype
TplID xsf.ID `json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"` //模板id
Subject string `json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"subject"` //主题
From string `json:"from" form:"from" gorm:"column:from;type:varchar(255);comment:发件人" example:"月饼<mooncake2026@163.com>" csv:"发件人"` //发件人
Subject string `json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"主题"` //主题
Content string `json:"content" form:"content" gorm:"column:content;type:text;comment:邮件内容" example:"<div>hello moon! </div>" csv:"邮件内容"` //邮件内容
CreatedAt xtime.DateTime `json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"` //创建时间
UpdatedAt xtime.DateTime `json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"` //更新时间
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论