Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xpkg
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
屠思豪
xpkg
Commits
a4765858
提交
a4765858
authored
10月 14, 2025
作者:
mooncake
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
email
上级
4c2a0b25
隐藏空白字符变更
内嵌
并排
正在显示
69 个修改的文件
包含
1571 行增加
和
1726 行删除
+1571
-1726
init_app.go
application/init_app.go
+1
-0
cmd.go
cmd/email/cmd.go
+5
-1
config.go
config/config.go
+2
-0
consul.go
config/consul.go
+6
-0
init.go
config/init.go
+9
-2
local.go
config/local.go
+13
-4
nacos.go
config/nacos.go
+8
-1
go.mod
go.mod
+1
-0
go.sum
go.sum
+1
-0
email.go
pkg/email/biz/email.go
+6
-10
email_receiver.go
pkg/email/biz/email_receiver.go
+6
-10
email_send.go
pkg/email/biz/email_send.go
+6
-10
email_send_log.go
pkg/email/biz/email_send_log.go
+6
-10
email_tpl.go
pkg/email/biz/email_tpl.go
+4
-8
email_tpl_receiver.go
pkg/email/biz/email_tpl_receiver.go
+6
-10
email.go
pkg/email/cache/email.go
+5
-5
email_receiver.go
pkg/email/cache/email_receiver.go
+5
-5
email_send.go
pkg/email/cache/email_send.go
+5
-5
email_send_log.go
pkg/email/cache/email_send_log.go
+5
-5
email_tpl.go
pkg/email/cache/email_tpl.go
+5
-5
email_tpl_receiver.go
pkg/email/cache/email_tpl_receiver.go
+5
-5
var.go
pkg/email/config/var.go
+33
-3
email.go
pkg/email/controller/email.go
+11
-34
email_receiver.go
pkg/email/controller/email_receiver.go
+11
-34
email_send.go
pkg/email/controller/email_send.go
+12
-34
email_send_log.go
pkg/email/controller/email_send_log.go
+11
-34
email_tpl.go
pkg/email/controller/email_tpl.go
+11
-34
email_tpl_receiver.go
pkg/email/controller/email_tpl_receiver.go
+11
-34
email.go
pkg/email/dao/email.go
+11
-22
email_receiver.go
pkg/email/dao/email_receiver.go
+11
-22
email_send.go
pkg/email/dao/email_send.go
+25
-36
email_send_log.go
pkg/email/dao/email_send_log.go
+14
-42
email_tpl.go
pkg/email/dao/email_tpl.go
+8
-14
email_tpl_receiver.go
pkg/email/dao/email_tpl_receiver.go
+11
-22
ecode.go
pkg/email/ecode/ecode.go
+17
-0
email_http.go
pkg/email/ecode/email_http.go
+0
-27
email_receiver_http.go
pkg/email/ecode/email_receiver_http.go
+0
-27
email_send_http.go
pkg/email/ecode/email_send_http.go
+0
-27
email_send_log_http.go
pkg/email/ecode/email_send_log_http.go
+0
-27
email_tpl_http.go
pkg/email/ecode/email_tpl_http.go
+0
-27
email_tpl_receiver_http.go
pkg/email/ecode/email_tpl_receiver_http.go
+0
-27
email.go
pkg/email/email.go
+274
-37
email.sql
pkg/email/email.sql
+61
-0
email_send.go
pkg/email/enums/email_send.go
+30
-33
email_send_log.go
pkg/email/enums/email_send_log.go
+30
-33
init.go
pkg/email/init.go
+41
-0
email.go
pkg/email/models/email.go
+16
-14
email_receiver.go
pkg/email/models/email_receiver.go
+14
-13
email_send.go
pkg/email/models/email_send.go
+15
-14
email_send_log.go
pkg/email/models/email_send_log.go
+15
-14
email_tpl.go
pkg/email/models/email_tpl.go
+13
-11
email_tpl_receiver.go
pkg/email/models/email_tpl_receiver.go
+14
-13
common.go
pkg/email/service/common.go
+24
-0
email.go
pkg/email/service/email.go
+58
-89
email_receiver.go
pkg/email/service/email_receiver.go
+57
-89
email_send.go
pkg/email/service/email_send.go
+75
-107
email_send_log.go
pkg/email/service/email_send_log.go
+57
-136
email_tpl.go
pkg/email/service/email_tpl.go
+54
-72
email_tpl_receiver.go
pkg/email/service/email_tpl_receiver.go
+57
-89
email.go
pkg/email/types/email.go
+51
-49
email_receiver.go
pkg/email/types/email_receiver.go
+46
-44
email_send.go
pkg/email/types/email_send.go
+59
-55
email_send_log.go
pkg/email/types/email_send_log.go
+59
-55
email_tpl.go
pkg/email/types/email_tpl.go
+36
-35
email_tpl_receiver.go
pkg/email/types/email_tpl_receiver.go
+46
-44
xsf_utils.go
pkg/email/xsf_utils/xsf_utils.go
+57
-56
init.go
pkg/eventbus/init.go
+1
-0
dxsf.go
utils/dxsf/dxsf.go
+1
-1
xsf.go
utils/xsf/xsf.go
+3
-0
没有找到文件。
application/init_app.go
浏览文件 @
a4765858
...
@@ -68,6 +68,7 @@ func parseInit() {
...
@@ -68,6 +68,7 @@ func parseInit() {
if
err
:=
dxsf
.
Init
();
err
!=
nil
{
if
err
:=
dxsf
.
Init
();
err
!=
nil
{
logger
.
Fatal
(
err
.
Error
())
logger
.
Fatal
(
err
.
Error
())
}
}
logger
.
Info
(
"[dxsf] initialized."
)
}
}
type
Application
struct
{
type
Application
struct
{
...
...
cmd/email/cmd.go
浏览文件 @
a4765858
package
email
package
main
func
main
()
{
}
config/config.go
浏览文件 @
a4765858
package
config
package
config
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/config"
"strings"
"strings"
"sync"
"sync"
"time"
"time"
...
@@ -120,6 +121,7 @@ type Config struct {
...
@@ -120,6 +121,7 @@ type Config struct {
Redis
Redis
`yaml:"redis" json:"redis" mapstructure:"redis"`
Redis
Redis
`yaml:"redis" json:"redis" mapstructure:"redis"`
Cron
Cron
`yaml:"cron" json:"cron" mapstructure:"cron"`
Cron
Cron
`yaml:"cron" json:"cron" mapstructure:"cron"`
Oss
oss
.
AliOssConfig
`yaml:"oss" json:"oss" mapstructure:"oss"`
Oss
oss
.
AliOssConfig
`yaml:"oss" json:"oss" mapstructure:"oss"`
Email
config
.
Config
`yaml:"email" json:"email" mapstructure:"email"`
Content
[]
byte
`yaml:"-" json:"-"`
Content
[]
byte
`yaml:"-" json:"-"`
}
}
...
...
config/consul.go
浏览文件 @
a4765858
...
@@ -3,6 +3,7 @@ package config
...
@@ -3,6 +3,7 @@ package config
import
(
import
(
"bytes"
"bytes"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"time"
"time"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/api"
...
@@ -13,6 +14,7 @@ import (
...
@@ -13,6 +14,7 @@ import (
)
)
type
ConsulConfFetcher
struct
{
type
ConsulConfFetcher
struct
{
count
int
isNew
bool
isNew
bool
confKey
string
confKey
string
err
error
err
error
...
@@ -51,6 +53,7 @@ func (x *ConsulConfFetcher) sync() *ConsulConfFetcher {
...
@@ -51,6 +53,7 @@ func (x *ConsulConfFetcher) sync() *ConsulConfFetcher {
return
x
return
x
}
}
if
hashUtils
.
Md5
(
kv
.
Value
)
!=
hashUtils
.
Md5
(
x
.
cfg
.
GetContent
())
{
if
hashUtils
.
Md5
(
kv
.
Value
)
!=
hashUtils
.
Md5
(
x
.
cfg
.
GetContent
())
{
x
.
count
++
x
.
isNew
=
true
x
.
isNew
=
true
x
.
cfg
.
SetContent
(
kv
.
Value
)
x
.
cfg
.
SetContent
(
kv
.
Value
)
}
}
...
@@ -78,6 +81,9 @@ func (x *ConsulConfFetcher) parse() *ConsulConfFetcher {
...
@@ -78,6 +81,9 @@ func (x *ConsulConfFetcher) parse() *ConsulConfFetcher {
for
_
,
load
:=
range
x
.
loads
{
for
_
,
load
:=
range
x
.
loads
{
load
(
x
.
cfg
.
GetContent
())
load
(
x
.
cfg
.
GetContent
())
}
}
if
x
.
count
>
1
{
eventbus
.
Eb
.
Publish
(
context
.
Background
(),
eventbus
.
TopicConfChange
)
}
logger
.
Debug
(
"[consul] conf updated"
)
logger
.
Debug
(
"[consul] conf updated"
)
return
x
return
x
}
}
...
...
config/init.go
浏览文件 @
a4765858
...
@@ -29,7 +29,8 @@ func ParseConf() (err error) {
...
@@ -29,7 +29,8 @@ func ParseConf() (err error) {
if
confType
==
"local"
{
if
confType
==
"local"
{
localConf
()
localConf
()
logger
.
Infof
(
"[conf]conf:%s"
,
Cfg
.
ConfCenter
.
Local
.
Conf
)
logger
.
Infof
(
"[conf]conf:%s"
,
Cfg
.
ConfCenter
.
Local
.
Conf
)
if
err
:=
parseLocal
(
Cfg
.
ConfCenter
.
Local
.
Conf
,
Cfg
,
func
()
{
lp
:=
&
localParser
{}
if
err
:=
lp
.
parseLocal
(
Cfg
.
ConfCenter
.
Local
.
Conf
,
Cfg
,
func
()
{
ParseExtend
()
ParseExtend
()
});
err
!=
nil
{
});
err
!=
nil
{
return
err
return
err
...
@@ -48,6 +49,9 @@ func ParseConf() (err error) {
...
@@ -48,6 +49,9 @@ func ParseConf() (err error) {
if
confType
==
"nacos"
{
if
confType
==
"nacos"
{
nacosConf
()
nacosConf
()
nc
:=
NewNacos
(
&
Cfg
.
ConfCenter
.
Nacos
,
func
(
content
[]
byte
)
(
err
error
)
{
nc
:=
NewNacos
(
&
Cfg
.
ConfCenter
.
Nacos
,
func
(
content
[]
byte
)
(
err
error
)
{
if
bytes
.
Compare
(
content
,
Cfg
.
GetContent
())
==
0
{
return
nil
}
Cfg
.
SetContent
(
content
)
Cfg
.
SetContent
(
content
)
v
:=
viper
.
New
()
v
:=
viper
.
New
()
v
.
SetConfigType
(
"yaml"
)
v
.
SetConfigType
(
"yaml"
)
...
@@ -57,7 +61,10 @@ func ParseConf() (err error) {
...
@@ -57,7 +61,10 @@ func ParseConf() (err error) {
if
err
:=
v
.
Unmarshal
(
&
Cfg
);
err
!=
nil
{
if
err
:=
v
.
Unmarshal
(
&
Cfg
);
err
!=
nil
{
return
err
return
err
}
}
return
ParseExtend
()
if
err
:=
ParseExtend
();
err
!=
nil
{
return
err
}
return
nil
},
logger
.
Get
())
},
logger
.
Get
())
if
err
:=
nc
.
Connect
()
.
Watch
()
.
Fetch
()
.
Parse
()
.
Err
();
err
!=
nil
{
if
err
:=
nc
.
Connect
()
.
Watch
()
.
Fetch
()
.
Parse
()
.
Err
();
err
!=
nil
{
return
err
return
err
...
...
config/local.go
浏览文件 @
a4765858
...
@@ -4,8 +4,10 @@ package config
...
@@ -4,8 +4,10 @@ package config
import
(
import
(
"bufio"
"bufio"
"bytes"
"bytes"
"context"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"os"
"os"
"path"
"path"
"path/filepath"
"path/filepath"
...
@@ -17,8 +19,11 @@ import (
...
@@ -17,8 +19,11 @@ import (
"github.com/spf13/viper"
"github.com/spf13/viper"
)
)
// parseLocal configuration files to struct, including yaml, toml, json, etc., and turn on listening for configuration file changes if fs is not empty
type
localParser
struct
{
func
parseLocal
(
configFile
string
,
obj
ICfg
,
reloads
...
func
())
error
{
count
int
}
func
(
x
*
localParser
)
parseLocal
(
configFile
string
,
obj
ICfg
,
reloads
...
func
())
error
{
confFileAbs
,
err
:=
filepath
.
Abs
(
configFile
)
confFileAbs
,
err
:=
filepath
.
Abs
(
configFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -50,13 +55,13 @@ func parseLocal(configFile string, obj ICfg, reloads ...func()) error {
...
@@ -50,13 +55,13 @@ func parseLocal(configFile string, obj ICfg, reloads ...func()) error {
for
_
,
reload
:=
range
reloads
{
for
_
,
reload
:=
range
reloads
{
reload
()
reload
()
}
}
watchConfig
(
configFile
,
obj
,
reloads
...
)
x
.
watchConfig
(
configFile
,
obj
,
reloads
...
)
}
}
return
nil
return
nil
}
}
func
watchConfig
(
confFile
string
,
obj
ICfg
,
reloads
...
func
())
{
func
(
x
*
localParser
)
watchConfig
(
confFile
string
,
obj
ICfg
,
reloads
...
func
())
{
viper
.
WatchConfig
()
viper
.
WatchConfig
()
// Note: OnConfigChange is called twice on Windows
// Note: OnConfigChange is called twice on Windows
...
@@ -78,6 +83,10 @@ func watchConfig(confFile string, obj ICfg, reloads ...func()) {
...
@@ -78,6 +83,10 @@ func watchConfig(confFile string, obj ICfg, reloads ...func()) {
reload
()
reload
()
}
}
}
}
x
.
count
++
if
x
.
count
>
1
{
eventbus
.
Eb
.
Publish
(
context
.
Background
(),
eventbus
.
TopicConfChange
)
}
})
})
}
}
...
...
config/nacos.go
浏览文件 @
a4765858
package
config
package
config
import
(
import
(
"context"
"errors"
"errors"
"fmt"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/clients/config_client"
"github.com/nacos-group/nacos-sdk-go/clients/config_client"
...
@@ -21,6 +23,7 @@ type NacosClient struct {
...
@@ -21,6 +23,7 @@ type NacosClient struct {
parseFn
func
(
content
[]
byte
)
(
err
error
)
parseFn
func
(
content
[]
byte
)
(
err
error
)
e
error
e
error
l
*
zap
.
Logger
l
*
zap
.
Logger
count
int
}
}
type
Parser
func
(
content
[]
byte
)
(
err
error
)
type
Parser
func
(
content
[]
byte
)
(
err
error
)
...
@@ -98,7 +101,11 @@ func (x *NacosClient) Parse() *NacosClient {
...
@@ -98,7 +101,11 @@ func (x *NacosClient) Parse() *NacosClient {
if
x
.
e
!=
nil
{
if
x
.
e
!=
nil
{
return
x
return
x
}
}
x
.
e
=
x
.
parseFn
([]
byte
(
x
.
content
))
x
.
e
=
x
.
parseFn
(
x
.
content
)
x
.
count
++
if
x
.
count
>
1
{
eventbus
.
Eb
.
Publish
(
context
.
Background
(),
eventbus
.
TopicConfChange
)
}
return
x
return
x
}
}
...
...
go.mod
浏览文件 @
a4765858
...
@@ -90,6 +90,7 @@ require (
...
@@ -90,6 +90,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/nyaruka/phonenumbers v1.0.55 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/image v0.23.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
...
...
go.sum
浏览文件 @
a4765858
...
@@ -459,6 +459,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
...
@@ -459,6 +459,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
github.com/nacos-group/nacos-sdk-go v1.1.6 h1:zjn7CIoz0RxPHCalWc9kXOQx94oUFQl5J1rctbq2mYU=
github.com/nacos-group/nacos-sdk-go v1.1.6 h1:zjn7CIoz0RxPHCalWc9kXOQx94oUFQl5J1rctbq2mYU=
github.com/nacos-group/nacos-sdk-go v1.1.6/go.mod h1:cBv9wy5iObs7khOqov1ERFQrCuTR4ILpgaiaVMxEmGI=
github.com/nacos-group/nacos-sdk-go v1.1.6/go.mod h1:cBv9wy5iObs7khOqov1ERFQrCuTR4ILpgaiaVMxEmGI=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuwcCl3yg=
github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
...
...
pkg/email/biz/email.go
浏览文件 @
a4765858
package
biz
package
biz
import
(
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
Email
struct
{
type
Email
struct
{
models
.
Email
models
.
Email
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
Email
,
Email
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
Email
,
Email
]
}
}
var
EmailTool
=
&
Email
{}
var
EmailTool
=
&
Email
{}
...
@@ -22,7 +19,7 @@ var EmailTool = &Email{}
...
@@ -22,7 +19,7 @@ var EmailTool = &Email{}
func
(
*
Email
)
GetIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
func
(
*
Email
)
GetIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
}
}
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
...
@@ -33,7 +30,6 @@ func (x *Email) GetTplIDs(rs []*Email) []xsf.ID{
...
@@ -33,7 +30,6 @@ func (x *Email) GetTplIDs(rs []*Email) []xsf.ID{
type
EmailOpts
struct
{
type
EmailOpts
struct
{
}
}
func
(
Email
)
NewFromModel
(
m
*
models
.
Email
)
*
Email
{
func
(
Email
)
NewFromModel
(
m
*
models
.
Email
)
*
Email
{
if
m
==
nil
{
if
m
==
nil
{
return
nil
return
nil
...
...
pkg/email/biz/email_receiver.go
浏览文件 @
a4765858
package
biz
package
biz
import
(
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
EmailReceiver
struct
{
type
EmailReceiver
struct
{
models
.
EmailReceiver
models
.
EmailReceiver
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailReceiver
,
EmailReceiver
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailReceiver
,
EmailReceiver
]
}
}
var
EmailReceiverTool
=
&
EmailReceiver
{}
var
EmailReceiverTool
=
&
EmailReceiver
{}
...
@@ -22,7 +19,7 @@ var EmailReceiverTool = &EmailReceiver{}
...
@@ -22,7 +19,7 @@ var EmailReceiverTool = &EmailReceiver{}
func
(
*
EmailReceiver
)
GetIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
func
(
*
EmailReceiver
)
GetIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
}
}
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
...
@@ -33,7 +30,6 @@ func (x *EmailReceiver) GetEmailIDs(rs []*EmailReceiver) []xsf.ID{
...
@@ -33,7 +30,6 @@ func (x *EmailReceiver) GetEmailIDs(rs []*EmailReceiver) []xsf.ID{
type
EmailReceiverOpts
struct
{
type
EmailReceiverOpts
struct
{
}
}
func
(
EmailReceiver
)
NewFromModel
(
m
*
models
.
EmailReceiver
)
*
EmailReceiver
{
func
(
EmailReceiver
)
NewFromModel
(
m
*
models
.
EmailReceiver
)
*
EmailReceiver
{
if
m
==
nil
{
if
m
==
nil
{
return
nil
return
nil
...
...
pkg/email/biz/email_send.go
浏览文件 @
a4765858
package
biz
package
biz
import
(
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
EmailSend
struct
{
type
EmailSend
struct
{
models
.
EmailSend
models
.
EmailSend
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSend
,
EmailSend
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSend
,
EmailSend
]
}
}
var
EmailSendTool
=
&
EmailSend
{}
var
EmailSendTool
=
&
EmailSend
{}
...
@@ -22,7 +19,7 @@ var EmailSendTool = &EmailSend{}
...
@@ -22,7 +19,7 @@ var EmailSendTool = &EmailSend{}
func
(
*
EmailSend
)
GetIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
func
(
*
EmailSend
)
GetIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
}
}
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
...
@@ -33,7 +30,6 @@ func (x *EmailSend) GetEmailIDs(rs []*EmailSend) []xsf.ID{
...
@@ -33,7 +30,6 @@ func (x *EmailSend) GetEmailIDs(rs []*EmailSend) []xsf.ID{
type
EmailSendOpts
struct
{
type
EmailSendOpts
struct
{
}
}
func
(
EmailSend
)
NewFromModel
(
m
*
models
.
EmailSend
)
*
EmailSend
{
func
(
EmailSend
)
NewFromModel
(
m
*
models
.
EmailSend
)
*
EmailSend
{
if
m
==
nil
{
if
m
==
nil
{
return
nil
return
nil
...
...
pkg/email/biz/email_send_log.go
浏览文件 @
a4765858
package
biz
package
biz
import
(
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
EmailSendLog
struct
{
type
EmailSendLog
struct
{
models
.
EmailSendLog
models
.
EmailSendLog
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSendLog
,
EmailSendLog
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSendLog
,
EmailSendLog
]
}
}
var
EmailSendLogTool
=
&
EmailSendLog
{}
var
EmailSendLogTool
=
&
EmailSendLog
{}
...
@@ -22,7 +19,7 @@ var EmailSendLogTool = &EmailSendLog{}
...
@@ -22,7 +19,7 @@ var EmailSendLogTool = &EmailSendLog{}
func
(
*
EmailSendLog
)
GetIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
func
(
*
EmailSendLog
)
GetIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
}
}
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailSendID
())
set
.
Add
(
r
.
GetEmailSendID
())
...
@@ -33,7 +30,6 @@ func (x *EmailSendLog) GetEmailSendIDs(rs []*EmailSendLog) []xsf.ID{
...
@@ -33,7 +30,6 @@ func (x *EmailSendLog) GetEmailSendIDs(rs []*EmailSendLog) []xsf.ID{
type
EmailSendLogOpts
struct
{
type
EmailSendLogOpts
struct
{
}
}
func
(
EmailSendLog
)
NewFromModel
(
m
*
models
.
EmailSendLog
)
*
EmailSendLog
{
func
(
EmailSendLog
)
NewFromModel
(
m
*
models
.
EmailSendLog
)
*
EmailSendLog
{
if
m
==
nil
{
if
m
==
nil
{
return
nil
return
nil
...
...
pkg/email/biz/email_tpl.go
浏览文件 @
a4765858
package
biz
package
biz
import
(
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
EmailTpl
struct
{
type
EmailTpl
struct
{
models
.
EmailTpl
models
.
EmailTpl
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTpl
,
EmailTpl
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTpl
,
EmailTpl
]
}
}
var
EmailTplTool
=
&
EmailTpl
{}
var
EmailTplTool
=
&
EmailTpl
{}
...
@@ -25,7 +22,6 @@ func (*EmailTpl) GetIDs(rs []*EmailTpl) []xsf.ID {
...
@@ -25,7 +22,6 @@ func (*EmailTpl) GetIDs(rs []*EmailTpl) []xsf.ID {
type
EmailTplOpts
struct
{
type
EmailTplOpts
struct
{
}
}
func
(
EmailTpl
)
NewFromModel
(
m
*
models
.
EmailTpl
)
*
EmailTpl
{
func
(
EmailTpl
)
NewFromModel
(
m
*
models
.
EmailTpl
)
*
EmailTpl
{
if
m
==
nil
{
if
m
==
nil
{
return
nil
return
nil
...
...
pkg/email/biz/email_tpl_receiver.go
浏览文件 @
a4765858
package
biz
package
biz
import
(
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
EmailTplReceiver
struct
{
type
EmailTplReceiver
struct
{
models
.
EmailTplReceiver
models
.
EmailTplReceiver
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTplReceiver
,
EmailTplReceiver
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTplReceiver
,
EmailTplReceiver
]
}
}
var
EmailTplReceiverTool
=
&
EmailTplReceiver
{}
var
EmailTplReceiverTool
=
&
EmailTplReceiver
{}
...
@@ -22,7 +19,7 @@ var EmailTplReceiverTool = &EmailTplReceiver{}
...
@@ -22,7 +19,7 @@ var EmailTplReceiverTool = &EmailTplReceiver{}
func
(
*
EmailTplReceiver
)
GetIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
func
(
*
EmailTplReceiver
)
GetIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
return
sliceUtils
.
GetIDs
[
xsf
.
ID
](
rs
)
}
}
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
...
@@ -33,7 +30,6 @@ func (x *EmailTplReceiver) GetTplIDs(rs []*EmailTplReceiver) []xsf.ID{
...
@@ -33,7 +30,6 @@ func (x *EmailTplReceiver) GetTplIDs(rs []*EmailTplReceiver) []xsf.ID{
type
EmailTplReceiverOpts
struct
{
type
EmailTplReceiverOpts
struct
{
}
}
func
(
EmailTplReceiver
)
NewFromModel
(
m
*
models
.
EmailTplReceiver
)
*
EmailTplReceiver
{
func
(
EmailTplReceiver
)
NewFromModel
(
m
*
models
.
EmailTplReceiver
)
*
EmailTplReceiver
{
if
m
==
nil
{
if
m
==
nil
{
return
nil
return
nil
...
...
pkg/email/cache/email.go
浏览文件 @
a4765858
package
cache
package
cache
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
)
const
(
var
(
emailCachePrefixKey
=
prefix
+
"email:"
emailCachePrefixKey
=
"email:"
)
)
type
EmailCache
ocache
.
OCache
[
models
.
Email
]
type
EmailCache
ocache
.
OCache
[
models
.
Email
]
func
NewEmailCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
Email
]
{
func
NewEmailCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
Email
]
{
return
ocache
.
NewCache
[
models
.
Email
](
cacheType
,
emailCachePrefixKey
,
ocache
.
DefaultExpireTime
)
return
ocache
.
NewCache
[
models
.
Email
](
cacheType
,
emailCachePrefixKey
,
ocache
.
DefaultExpireTime
)
}
}
\ No newline at end of file
pkg/email/cache/email_receiver.go
浏览文件 @
a4765858
package
cache
package
cache
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
)
const
(
var
(
emailReceiverCachePrefixKey
=
prefix
+
"emailReceiver:"
emailReceiverCachePrefixKey
=
"emailReceiver:"
)
)
type
EmailReceiverCache
ocache
.
OCache
[
models
.
EmailReceiver
]
type
EmailReceiverCache
ocache
.
OCache
[
models
.
EmailReceiver
]
func
NewEmailReceiverCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailReceiver
]
{
func
NewEmailReceiverCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailReceiver
]
{
return
ocache
.
NewCache
[
models
.
EmailReceiver
](
cacheType
,
emailReceiverCachePrefixKey
,
ocache
.
DefaultExpireTime
)
return
ocache
.
NewCache
[
models
.
EmailReceiver
](
cacheType
,
emailReceiverCachePrefixKey
,
ocache
.
DefaultExpireTime
)
}
}
\ No newline at end of file
pkg/email/cache/email_send.go
浏览文件 @
a4765858
package
cache
package
cache
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
)
const
(
var
(
emailSendCachePrefixKey
=
prefix
+
"emailSend:"
emailSendCachePrefixKey
=
"emailSend:"
)
)
type
EmailSendCache
ocache
.
OCache
[
models
.
EmailSend
]
type
EmailSendCache
ocache
.
OCache
[
models
.
EmailSend
]
func
NewEmailSendCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailSend
]
{
func
NewEmailSendCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailSend
]
{
return
ocache
.
NewCache
[
models
.
EmailSend
](
cacheType
,
emailSendCachePrefixKey
,
ocache
.
DefaultExpireTime
)
return
ocache
.
NewCache
[
models
.
EmailSend
](
cacheType
,
emailSendCachePrefixKey
,
ocache
.
DefaultExpireTime
)
}
}
\ No newline at end of file
pkg/email/cache/email_send_log.go
浏览文件 @
a4765858
package
cache
package
cache
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
)
const
(
var
(
emailSendLogCachePrefixKey
=
prefix
+
"emailSendLog:"
emailSendLogCachePrefixKey
=
"emailSendLog:"
)
)
type
EmailSendLogCache
ocache
.
OCache
[
models
.
EmailSendLog
]
type
EmailSendLogCache
ocache
.
OCache
[
models
.
EmailSendLog
]
func
NewEmailSendLogCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailSendLog
]
{
func
NewEmailSendLogCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailSendLog
]
{
return
ocache
.
NewCache
[
models
.
EmailSendLog
](
cacheType
,
emailSendLogCachePrefixKey
,
ocache
.
DefaultExpireTime
)
return
ocache
.
NewCache
[
models
.
EmailSendLog
](
cacheType
,
emailSendLogCachePrefixKey
,
ocache
.
DefaultExpireTime
)
}
}
\ No newline at end of file
pkg/email/cache/email_tpl.go
浏览文件 @
a4765858
package
cache
package
cache
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
)
const
(
var
(
emailTplCachePrefixKey
=
prefix
+
"emailTpl:"
emailTplCachePrefixKey
=
"emailTpl:"
)
)
type
EmailTplCache
ocache
.
OCache
[
models
.
EmailTpl
]
type
EmailTplCache
ocache
.
OCache
[
models
.
EmailTpl
]
func
NewEmailTplCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailTpl
]
{
func
NewEmailTplCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailTpl
]
{
return
ocache
.
NewCache
[
models
.
EmailTpl
](
cacheType
,
emailTplCachePrefixKey
,
ocache
.
DefaultExpireTime
)
return
ocache
.
NewCache
[
models
.
EmailTpl
](
cacheType
,
emailTplCachePrefixKey
,
ocache
.
DefaultExpireTime
)
}
}
\ No newline at end of file
pkg/email/cache/email_tpl_receiver.go
浏览文件 @
a4765858
package
cache
package
cache
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
)
const
(
var
(
emailTplReceiverCachePrefixKey
=
prefix
+
"emailTplReceiver:"
emailTplReceiverCachePrefixKey
=
"emailTplReceiver:"
)
)
type
EmailTplReceiverCache
ocache
.
OCache
[
models
.
EmailTplReceiver
]
type
EmailTplReceiverCache
ocache
.
OCache
[
models
.
EmailTplReceiver
]
func
NewEmailTplReceiverCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailTplReceiver
]
{
func
NewEmailTplReceiverCache
(
cacheType
string
)
*
ocache
.
OCache
[
models
.
EmailTplReceiver
]
{
return
ocache
.
NewCache
[
models
.
EmailTplReceiver
](
cacheType
,
emailTplReceiverCachePrefixKey
,
ocache
.
DefaultExpireTime
)
return
ocache
.
NewCache
[
models
.
EmailTplReceiver
](
cacheType
,
emailTplReceiverCachePrefixKey
,
ocache
.
DefaultExpireTime
)
}
}
\ No newline at end of file
pkg/email/config/var.go
浏览文件 @
a4765858
package
con
sts
package
con
fig
var
(
var
(
Schema
string
=
""
Cfg
=
&
Config
{}
Prefix
string
=
""
)
)
// Config 配置结构体 (建议从环境变量或配置文件中读取)
type
Config
struct
{
SMTPServer
string
`yaml:"smtpServer" json:"smtpServer" mapstructure:"smtpServer"`
SMTPPort
int
`yaml:"smtpPort" json:"smtpPort" mapstructure:"smtpPort"`
Email
string
`yaml:"emailAddr" json:"emailAddr" mapstructure:"emailAddr"`
Token
string
`yaml:"emailToken" json:"emailToken" mapstructure:"emailToken"`
Name
string
`yaml:"emailAlias" json:"emailAlias" mapstructure:"emailAlias"`
Schema
string
`yaml:"schema" json:"schema" mapstructure:"schema"`
}
type
Email
struct
{
From
string
To
[]
Receiver
Subject
string
Body
string
Attachments
[]
*
Attachment
InlineImages
map
[
string
]
string
// CID -> 图片文件路径
}
type
Receiver
struct
{
Email
string
DisplayName
string
}
type
Attachment
struct
{
Filename
string
// 显示的文件名
FilePath
string
// 文件路径(二选一)
Data
[]
byte
// 文件数据(二选一)
ContentType
string
// 可选:指定内容类型
}
pkg/email/controller/email.go
浏览文件 @
a4765858
package
controller
package
controller
import
(
import
(
"operator-qt/internal/modules/operator/service"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailController
struct
{
type
emailController
struct
{
...
@@ -37,7 +35,7 @@ func (x *emailController) Create(c *gin.Context) {
...
@@ -37,7 +35,7 @@ func (x *emailController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
response
.
Success
(
c
,
id
)
}
}
func
(
x
*
emailController
)
DeleteByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -48,18 +46,6 @@ func (x *emailController) DeleteByID(c *gin.Context) {
...
@@ -48,18 +46,6 @@ func (x *emailController) DeleteByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailController
)
DeleteByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDsReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailService
.
DeleteByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
.
IDs
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
func
(
x
*
emailController
)
UpdateByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailController
)
UpdateByID
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailUpdateByIDReq
{}
in
:=
&
types
.
EmailUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
@@ -72,19 +58,8 @@ func (x *emailController) UpdateByID(c *gin.Context) {
...
@@ -72,19 +58,8 @@ func (x *emailController) UpdateByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailUpdateByIDsReq
{}
// GetByID
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailService
.
UpdateByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
// GetByID
// @Summary 查询邮件详情
// @Summary 查询邮件详情
// @Description 通过id查询邮件详情,参数id必填
// @Description 通过id查询邮件详情,参数id必填
// @Tags 麒兔运营商中台/athena服务/邮件
// @Tags 麒兔运营商中台/athena服务/邮件
...
@@ -100,7 +75,7 @@ func (x *emailController) GetByID(c *gin.Context) {
...
@@ -100,7 +75,7 @@ func (x *emailController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
}
}
email
,
err
:=
service
.
EmailService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
email
,
err
:=
service
.
EmailService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -122,6 +97,7 @@ func (x *emailController) GetByIDs(c *gin.Context) {
...
@@ -122,6 +97,7 @@ func (x *emailController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailObjDetailTool
.
NewSliceFromBizSlice
(
emails
)
data
:=
types
.
EmailObjDetailTool
.
NewSliceFromBizSlice
(
emails
)
response
.
SuccessWithList
(
c
,
data
)
response
.
SuccessWithList
(
c
,
data
)
}
}
// Page
// Page
// @Summary 分页查询邮件
// @Summary 分页查询邮件
// @Description 分页查询邮件
// @Description 分页查询邮件
...
@@ -147,6 +123,7 @@ func (x *emailController) Page(c *gin.Context) {
...
@@ -147,6 +123,7 @@ func (x *emailController) Page(c *gin.Context) {
data
:=
types
.
EmailObjDetailTool
.
NewSliceFromBizSlice
(
emails
)
data
:=
types
.
EmailObjDetailTool
.
NewSliceFromBizSlice
(
emails
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
}
// ExportCSV
// ExportCSV
// @Summary 导出csv
// @Summary 导出csv
// @Description 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_receiver.go
浏览文件 @
a4765858
package
controller
package
controller
import
(
import
(
"operator-qt/internal/modules/operator/service"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailReceiverController
struct
{
type
emailReceiverController
struct
{
...
@@ -37,7 +35,7 @@ func (x *emailReceiverController) Create(c *gin.Context) {
...
@@ -37,7 +35,7 @@ func (x *emailReceiverController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
response
.
Success
(
c
,
id
)
}
}
func
(
x
*
emailReceiverController
)
DeleteByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailReceiverController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -48,18 +46,6 @@ func (x *emailReceiverController) DeleteByID(c *gin.Context) {
...
@@ -48,18 +46,6 @@ func (x *emailReceiverController) DeleteByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailReceiverController
)
DeleteByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDsReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailReceiverService
.
DeleteByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
.
IDs
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
func
(
x
*
emailReceiverController
)
UpdateByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailReceiverController
)
UpdateByID
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailReceiverUpdateByIDReq
{}
in
:=
&
types
.
EmailReceiverUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
@@ -72,19 +58,8 @@ func (x *emailReceiverController) UpdateByID(c *gin.Context) {
...
@@ -72,19 +58,8 @@ func (x *emailReceiverController) UpdateByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailReceiverController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailReceiverUpdateByIDsReq
{}
// GetByID
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailReceiverService
.
UpdateByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
// GetByID
// @Summary 查询邮件收件人详情
// @Summary 查询邮件收件人详情
// @Description 通过id查询邮件收件人详情,参数id必填
// @Description 通过id查询邮件收件人详情,参数id必填
// @Tags 麒兔运营商中台/athena服务/邮件收件人
// @Tags 麒兔运营商中台/athena服务/邮件收件人
...
@@ -100,7 +75,7 @@ func (x *emailReceiverController) GetByID(c *gin.Context) {
...
@@ -100,7 +75,7 @@ func (x *emailReceiverController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
}
}
emailReceiver
,
err
:=
service
.
EmailReceiverService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
emailReceiver
,
err
:=
service
.
EmailReceiverService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -122,6 +97,7 @@ func (x *emailReceiverController) GetByIDs(c *gin.Context) {
...
@@ -122,6 +97,7 @@ func (x *emailReceiverController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailReceivers
)
data
:=
types
.
EmailReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailReceivers
)
response
.
SuccessWithList
(
c
,
data
)
response
.
SuccessWithList
(
c
,
data
)
}
}
// Page
// Page
// @Summary 分页查询邮件收件人
// @Summary 分页查询邮件收件人
// @Description 分页查询邮件收件人
// @Description 分页查询邮件收件人
...
@@ -147,6 +123,7 @@ func (x *emailReceiverController) Page(c *gin.Context) {
...
@@ -147,6 +123,7 @@ func (x *emailReceiverController) Page(c *gin.Context) {
data
:=
types
.
EmailReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailReceivers
)
data
:=
types
.
EmailReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailReceivers
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
}
// ExportCSV
// ExportCSV
// @Summary 导出csv
// @Summary 导出csv
// @Description 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_send.go
浏览文件 @
a4765858
package
controller
package
controller
import
(
import
(
"operator-qt/internal/modules/operator/service"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailSendController
struct
{
type
emailSendController
struct
{
...
@@ -37,7 +35,7 @@ func (x *emailSendController) Create(c *gin.Context) {
...
@@ -37,7 +35,7 @@ func (x *emailSendController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
response
.
Success
(
c
,
id
)
}
}
func
(
x
*
emailSendController
)
DeleteByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailSendController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -48,18 +46,7 @@ func (x *emailSendController) DeleteByID(c *gin.Context) {
...
@@ -48,18 +46,7 @@ func (x *emailSendController) DeleteByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailSendController
)
DeleteByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDsReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailSendService
.
DeleteByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
.
IDs
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
func
(
x
*
emailSendController
)
UpdateByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailSendController
)
UpdateByID
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailSendUpdateByIDReq
{}
in
:=
&
types
.
EmailSendUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
@@ -72,19 +59,8 @@ func (x *emailSendController) UpdateByID(c *gin.Context) {
...
@@ -72,19 +59,8 @@ func (x *emailSendController) UpdateByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailSendController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailSendUpdateByIDsReq
{}
// GetByID
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailSendService
.
UpdateByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
// GetByID
// @Summary 查询邮件发送详情
// @Summary 查询邮件发送详情
// @Description 通过id查询邮件发送详情,参数id必填
// @Description 通过id查询邮件发送详情,参数id必填
// @Tags 麒兔运营商中台/athena服务/邮件发送
// @Tags 麒兔运营商中台/athena服务/邮件发送
...
@@ -100,7 +76,7 @@ func (x *emailSendController) GetByID(c *gin.Context) {
...
@@ -100,7 +76,7 @@ func (x *emailSendController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
}
}
emailSend
,
err
:=
service
.
EmailSendService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
emailSend
,
err
:=
service
.
EmailSendService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -122,6 +98,7 @@ func (x *emailSendController) GetByIDs(c *gin.Context) {
...
@@ -122,6 +98,7 @@ func (x *emailSendController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailSendObjDetailTool
.
NewSliceFromBizSlice
(
emailSends
)
data
:=
types
.
EmailSendObjDetailTool
.
NewSliceFromBizSlice
(
emailSends
)
response
.
SuccessWithList
(
c
,
data
)
response
.
SuccessWithList
(
c
,
data
)
}
}
// Page
// Page
// @Summary 分页查询邮件发送
// @Summary 分页查询邮件发送
// @Description 分页查询邮件发送
// @Description 分页查询邮件发送
...
@@ -147,6 +124,7 @@ func (x *emailSendController) Page(c *gin.Context) {
...
@@ -147,6 +124,7 @@ func (x *emailSendController) Page(c *gin.Context) {
data
:=
types
.
EmailSendObjDetailTool
.
NewSliceFromBizSlice
(
emailSends
)
data
:=
types
.
EmailSendObjDetailTool
.
NewSliceFromBizSlice
(
emailSends
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
}
// ExportCSV
// ExportCSV
// @Summary 导出csv
// @Summary 导出csv
// @Description 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_send_log.go
浏览文件 @
a4765858
package
controller
package
controller
import
(
import
(
"operator-qt/internal/modules/operator/service"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailSendLogController
struct
{
type
emailSendLogController
struct
{
...
@@ -37,7 +35,7 @@ func (x *emailSendLogController) Create(c *gin.Context) {
...
@@ -37,7 +35,7 @@ func (x *emailSendLogController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
response
.
Success
(
c
,
id
)
}
}
func
(
x
*
emailSendLogController
)
DeleteByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailSendLogController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -48,18 +46,6 @@ func (x *emailSendLogController) DeleteByID(c *gin.Context) {
...
@@ -48,18 +46,6 @@ func (x *emailSendLogController) DeleteByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailSendLogController
)
DeleteByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDsReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailSendLogService
.
DeleteByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
.
IDs
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
func
(
x
*
emailSendLogController
)
UpdateByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailSendLogController
)
UpdateByID
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailSendLogUpdateByIDReq
{}
in
:=
&
types
.
EmailSendLogUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
@@ -72,19 +58,8 @@ func (x *emailSendLogController) UpdateByID(c *gin.Context) {
...
@@ -72,19 +58,8 @@ func (x *emailSendLogController) UpdateByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailSendLogController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailSendLogUpdateByIDsReq
{}
// GetByID
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailSendLogService
.
UpdateByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
// GetByID
// @Summary 查询邮件发送记录详情
// @Summary 查询邮件发送记录详情
// @Description 通过id查询邮件发送记录详情,参数id必填
// @Description 通过id查询邮件发送记录详情,参数id必填
// @Tags 麒兔运营商中台/athena服务/邮件发送记录
// @Tags 麒兔运营商中台/athena服务/邮件发送记录
...
@@ -100,7 +75,7 @@ func (x *emailSendLogController) GetByID(c *gin.Context) {
...
@@ -100,7 +75,7 @@ func (x *emailSendLogController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
}
}
emailSendLog
,
err
:=
service
.
EmailSendLogService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
emailSendLog
,
err
:=
service
.
EmailSendLogService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -122,6 +97,7 @@ func (x *emailSendLogController) GetByIDs(c *gin.Context) {
...
@@ -122,6 +97,7 @@ func (x *emailSendLogController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailSendLogObjDetailTool
.
NewSliceFromBizSlice
(
emailSendLogs
)
data
:=
types
.
EmailSendLogObjDetailTool
.
NewSliceFromBizSlice
(
emailSendLogs
)
response
.
SuccessWithList
(
c
,
data
)
response
.
SuccessWithList
(
c
,
data
)
}
}
// Page
// Page
// @Summary 分页查询邮件发送记录
// @Summary 分页查询邮件发送记录
// @Description 分页查询邮件发送记录
// @Description 分页查询邮件发送记录
...
@@ -147,6 +123,7 @@ func (x *emailSendLogController) Page(c *gin.Context) {
...
@@ -147,6 +123,7 @@ func (x *emailSendLogController) Page(c *gin.Context) {
data
:=
types
.
EmailSendLogObjDetailTool
.
NewSliceFromBizSlice
(
emailSendLogs
)
data
:=
types
.
EmailSendLogObjDetailTool
.
NewSliceFromBizSlice
(
emailSendLogs
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
}
// ExportCSV
// ExportCSV
// @Summary 导出csv
// @Summary 导出csv
// @Description 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_tpl.go
浏览文件 @
a4765858
package
controller
package
controller
import
(
import
(
"operator-qt/internal/modules/operator/service"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailTplController
struct
{
type
emailTplController
struct
{
...
@@ -37,7 +35,7 @@ func (x *emailTplController) Create(c *gin.Context) {
...
@@ -37,7 +35,7 @@ func (x *emailTplController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
response
.
Success
(
c
,
id
)
}
}
func
(
x
*
emailTplController
)
DeleteByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailTplController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -48,18 +46,6 @@ func (x *emailTplController) DeleteByID(c *gin.Context) {
...
@@ -48,18 +46,6 @@ func (x *emailTplController) DeleteByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailTplController
)
DeleteByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDsReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailTplService
.
DeleteByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
.
IDs
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
func
(
x
*
emailTplController
)
UpdateByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailTplController
)
UpdateByID
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailTplUpdateByIDReq
{}
in
:=
&
types
.
EmailTplUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
@@ -72,19 +58,8 @@ func (x *emailTplController) UpdateByID(c *gin.Context) {
...
@@ -72,19 +58,8 @@ func (x *emailTplController) UpdateByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailTplController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailTplUpdateByIDsReq
{}
// GetByID
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailTplService
.
UpdateByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
// GetByID
// @Summary 查询邮件模板详情
// @Summary 查询邮件模板详情
// @Description 通过id查询邮件模板详情,参数id必填
// @Description 通过id查询邮件模板详情,参数id必填
// @Tags 麒兔运营商中台/athena服务/邮件模板
// @Tags 麒兔运营商中台/athena服务/邮件模板
...
@@ -100,7 +75,7 @@ func (x *emailTplController) GetByID(c *gin.Context) {
...
@@ -100,7 +75,7 @@ func (x *emailTplController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
}
}
emailTpl
,
err
:=
service
.
EmailTplService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
emailTpl
,
err
:=
service
.
EmailTplService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -122,6 +97,7 @@ func (x *emailTplController) GetByIDs(c *gin.Context) {
...
@@ -122,6 +97,7 @@ func (x *emailTplController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailTplObjDetailTool
.
NewSliceFromBizSlice
(
emailTpls
)
data
:=
types
.
EmailTplObjDetailTool
.
NewSliceFromBizSlice
(
emailTpls
)
response
.
SuccessWithList
(
c
,
data
)
response
.
SuccessWithList
(
c
,
data
)
}
}
// Page
// Page
// @Summary 分页查询邮件模板
// @Summary 分页查询邮件模板
// @Description 分页查询邮件模板
// @Description 分页查询邮件模板
...
@@ -147,6 +123,7 @@ func (x *emailTplController) Page(c *gin.Context) {
...
@@ -147,6 +123,7 @@ func (x *emailTplController) Page(c *gin.Context) {
data
:=
types
.
EmailTplObjDetailTool
.
NewSliceFromBizSlice
(
emailTpls
)
data
:=
types
.
EmailTplObjDetailTool
.
NewSliceFromBizSlice
(
emailTpls
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
}
// ExportCSV
// ExportCSV
// @Summary 导出csv
// @Summary 导出csv
// @Description 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_tpl_receiver.go
浏览文件 @
a4765858
package
controller
package
controller
import
(
import
(
"operator-qt/internal/modules/operator/service"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/request"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailTplReceiverController
struct
{
type
emailTplReceiverController
struct
{
...
@@ -37,7 +35,7 @@ func (x *emailTplReceiverController) Create(c *gin.Context) {
...
@@ -37,7 +35,7 @@ func (x *emailTplReceiverController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
response
.
Success
(
c
,
id
)
}
}
func
(
x
*
emailTplReceiverController
)
DeleteByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailTplReceiverController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -48,18 +46,6 @@ func (x *emailTplReceiverController) DeleteByID(c *gin.Context) {
...
@@ -48,18 +46,6 @@ func (x *emailTplReceiverController) DeleteByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailTplReceiverController
)
DeleteByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDsReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailTplReceiverService
.
DeleteByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
.
IDs
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
func
(
x
*
emailTplReceiverController
)
UpdateByID
(
c
*
gin
.
Context
)
{
func
(
x
*
emailTplReceiverController
)
UpdateByID
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailTplReceiverUpdateByIDReq
{}
in
:=
&
types
.
EmailTplReceiverUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
@@ -72,19 +58,8 @@ func (x *emailTplReceiverController) UpdateByID(c *gin.Context) {
...
@@ -72,19 +58,8 @@ func (x *emailTplReceiverController) UpdateByID(c *gin.Context) {
}
}
response
.
Success
(
c
)
response
.
Success
(
c
)
}
}
func
(
x
*
emailTplReceiverController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailTplReceiverUpdateByIDsReq
{}
// GetByID
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
if
err
:=
service
.
EmailTplReceiverService
.
UpdateByIDs
(
ctxUtils
.
WrapCtx
(
c
),
in
,
nil
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
}
response
.
Success
(
c
)
}
// GetByID
// @Summary 查询邮件模板收件人详情
// @Summary 查询邮件模板收件人详情
// @Description 通过id查询邮件模板收件人详情,参数id必填
// @Description 通过id查询邮件模板收件人详情,参数id必填
// @Tags 麒兔运营商中台/athena服务/邮件模板收件人
// @Tags 麒兔运营商中台/athena服务/邮件模板收件人
...
@@ -100,7 +75,7 @@ func (x *emailTplReceiverController) GetByID(c *gin.Context) {
...
@@ -100,7 +75,7 @@ func (x *emailTplReceiverController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
}
}
emailTplReceiver
,
err
:=
service
.
EmailTplReceiverService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
emailTplReceiver
,
err
:=
service
.
EmailTplReceiverService
.
GetByID
(
ctxUtils
.
WrapCtx
(
c
),
in
.
ID
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
response
.
Error
(
c
,
err
)
response
.
Error
(
c
,
err
)
return
return
...
@@ -122,6 +97,7 @@ func (x *emailTplReceiverController) GetByIDs(c *gin.Context) {
...
@@ -122,6 +97,7 @@ func (x *emailTplReceiverController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailTplReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailTplReceivers
)
data
:=
types
.
EmailTplReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailTplReceivers
)
response
.
SuccessWithList
(
c
,
data
)
response
.
SuccessWithList
(
c
,
data
)
}
}
// Page
// Page
// @Summary 分页查询邮件模板收件人
// @Summary 分页查询邮件模板收件人
// @Description 分页查询邮件模板收件人
// @Description 分页查询邮件模板收件人
...
@@ -147,6 +123,7 @@ func (x *emailTplReceiverController) Page(c *gin.Context) {
...
@@ -147,6 +123,7 @@ func (x *emailTplReceiverController) Page(c *gin.Context) {
data
:=
types
.
EmailTplReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailTplReceivers
)
data
:=
types
.
EmailTplReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailTplReceivers
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
}
// ExportCSV
// ExportCSV
// @Summary 导出csv
// @Summary 导出csv
// @Description 导出csv
// @Description 导出csv
...
...
pkg/email/dao/email.go
浏览文件 @
a4765858
package
dao
package
dao
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
)
type
emailDao
struct
{
type
emailDao
struct
{
*
odao
.
ODao
[
models
.
Email
]
*
odao
.
ODao
[
models
.
Email
]
}
}
var
EmailDao
=
&
emailDao
{
var
EmailDao
=
&
emailDao
{}
ODao
:
odao
.
NewDao
[
models
.
Email
](
consts
.
Schema_operator
),
}
func
init
()
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
EmailDao
.
ODao
.
Cache
=
cache
.
NewEmailCache
(
database
.
GetCacheType
())
})
}
func
(
x
*
emailDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
xsf
.
ID
)
([]
*
models
.
Email
,
error
)
{
func
(
x
*
emailDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
xsf
.
ID
)
([]
*
models
.
Email
,
error
)
{
if
tplID
<=
0
{
if
tplID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
...
@@ -35,24 +24,24 @@ func (x *emailDao) GetSliceByTplIDs(ctx context.Context, order string, tplIDs []
...
@@ -35,24 +24,24 @@ func (x *emailDao) GetSliceByTplIDs(ctx context.Context, order string, tplIDs []
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emails
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
emails
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
emails
,
nil
return
emails
,
nil
}
}
func
(
x
*
emailDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
Email
,
int
,
error
)
{
func
(
x
*
emailDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
Email
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emails
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
emails
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
Email
)
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
Email
)
for
_
,
record
:=
range
emails
{
for
_
,
record
:=
range
emails
{
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
}
}
return
itemMap
,
len
(
emails
),
nil
return
itemMap
,
len
(
emails
),
nil
}
}
pkg/email/dao/email_receiver.go
浏览文件 @
a4765858
package
dao
package
dao
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
)
type
emailReceiverDao
struct
{
type
emailReceiverDao
struct
{
*
odao
.
ODao
[
models
.
EmailReceiver
]
*
odao
.
ODao
[
models
.
EmailReceiver
]
}
}
var
EmailReceiverDao
=
&
emailReceiverDao
{
var
EmailReceiverDao
=
&
emailReceiverDao
{}
ODao
:
odao
.
NewDao
[
models
.
EmailReceiver
](
consts
.
Schema_operator
),
}
func
init
()
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
EmailReceiverDao
.
ODao
.
Cache
=
cache
.
NewEmailReceiverCache
(
database
.
GetCacheType
())
})
}
func
(
x
*
emailReceiverDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
xsf
.
ID
)
([]
*
models
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
xsf
.
ID
)
([]
*
models
.
EmailReceiver
,
error
)
{
if
emailID
<=
0
{
if
emailID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
...
@@ -35,24 +24,24 @@ func (x *emailReceiverDao) GetSliceByEmailIDs(ctx context.Context, order string,
...
@@ -35,24 +24,24 @@ func (x *emailReceiverDao) GetSliceByEmailIDs(ctx context.Context, order string,
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
emailReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
emailReceivers
,
nil
return
emailReceivers
,
nil
}
}
func
(
x
*
emailReceiverDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailReceiver
,
int
,
error
)
{
func
(
x
*
emailReceiverDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailReceiver
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
emailReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailReceiver
)
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailReceiver
)
for
_
,
record
:=
range
emailReceivers
{
for
_
,
record
:=
range
emailReceivers
{
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
}
}
return
itemMap
,
len
(
emailReceivers
),
nil
return
itemMap
,
len
(
emailReceivers
),
nil
}
}
pkg/email/dao/email_send.go
浏览文件 @
a4765858
package
dao
package
dao
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
)
type
emailSendDao
struct
{
type
emailSendDao
struct
{
*
odao
.
ODao
[
models
.
EmailSend
]
*
odao
.
ODao
[
models
.
EmailSend
]
}
}
var
EmailSendDao
=
&
emailSendDao
{
var
EmailSendDao
=
&
emailSendDao
{}
ODao
:
odao
.
NewDao
[
models
.
EmailSend
](
consts
.
Schema_operator
),
}
func
init
()
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
EmailSendDao
.
ODao
.
Cache
=
cache
.
NewEmailSendCache
(
database
.
GetCacheType
())
})
}
func
(
x
*
emailSendDao
)
GetSliceByState
(
ctx
context
.
Context
,
order
string
,
state
enums
.
EmailSend_State_Enum
)
([]
*
models
.
EmailSend
,
error
)
{
func
(
x
*
emailSendDao
)
GetSliceByState
(
ctx
context
.
Context
,
order
string
,
state
enums
.
EmailSend_State_Enum
)
([]
*
models
.
EmailSend
,
error
)
{
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state = ?"
,
state
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state = ?"
,
state
)
}
}
func
(
x
*
emailSendDao
)
GetSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSend_State_Enum
)
([]
*
models
.
EmailSend
,
error
)
{
func
(
x
*
emailSendDao
)
GetSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSend_State_Enum
)
([]
*
models
.
EmailSend
,
error
)
{
if
len
(
states
)
==
0
{
if
len
(
states
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
}
}
func
(
x
*
emailSendDao
)
GetMapSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSend_State_Enum
)
(
map
[
enums
.
EmailSend_State_Enum
][]
*
models
.
EmailSend
,
int
,
error
)
{
func
(
x
*
emailSendDao
)
GetMapSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSend_State_Enum
)
(
map
[
enums
.
EmailSend_State_Enum
][]
*
models
.
EmailSend
,
int
,
error
)
{
if
len
(
states
)
==
0
{
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSendMapSlice
:=
make
(
map
[
enums
.
EmailSend_State_Enum
][]
*
models
.
EmailSend
)
emailSendMapSlice
:=
make
(
map
[
enums
.
EmailSend_State_Enum
][]
*
models
.
EmailSend
)
for
i
:=
range
emailSends
{
for
i
:=
range
emailSends
{
emailSendMapSlice
[
emailSends
[
i
]
.
State
]
=
append
(
emailSendMapSlice
[
emailSends
[
i
]
.
State
],
emailSends
[
i
])
emailSendMapSlice
[
emailSends
[
i
]
.
State
]
=
append
(
emailSendMapSlice
[
emailSends
[
i
]
.
State
],
emailSends
[
i
])
}
}
return
emailSendMapSlice
,
len
(
emailSends
),
nil
return
emailSendMapSlice
,
len
(
emailSends
),
nil
}
}
func
(
x
*
emailSendDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
xsf
.
ID
)
([]
*
models
.
EmailSend
,
error
)
{
func
(
x
*
emailSendDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
xsf
.
ID
)
([]
*
models
.
EmailSend
,
error
)
{
if
emailID
<=
0
{
if
emailID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
...
@@ -64,24 +53,24 @@ func (x *emailSendDao) GetSliceByEmailIDs(ctx context.Context, order string, ema
...
@@ -64,24 +53,24 @@ func (x *emailSendDao) GetSliceByEmailIDs(ctx context.Context, order string, ema
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
emailSends
,
nil
return
emailSends
,
nil
}
}
func
(
x
*
emailSendDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailSend
,
int
,
error
)
{
func
(
x
*
emailSendDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailSend
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id IN (?)"
,
emailIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailSend
)
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailSend
)
for
_
,
record
:=
range
emailSends
{
for
_
,
record
:=
range
emailSends
{
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
}
}
return
itemMap
,
len
(
emailSends
),
nil
return
itemMap
,
len
(
emailSends
),
nil
}
}
pkg/email/dao/email_send_log.go
浏览文件 @
a4765858
package
dao
package
dao
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
)
type
emailSendLogDao
struct
{
type
emailSendLogDao
struct
{
*
odao
.
ODao
[
models
.
EmailSendLog
]
*
odao
.
ODao
[
models
.
EmailSendLog
]
}
}
var
EmailSendLogDao
=
&
emailSendLogDao
{
var
EmailSendLogDao
=
&
emailSendLogDao
{}
ODao
:
odao
.
NewDao
[
models
.
EmailSendLog
](
consts
.
Schema_operator
),
}
func
init
()
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
EmailSendLogDao
.
ODao
.
Cache
=
cache
.
NewEmailSendLogCache
(
database
.
GetCacheType
())
})
}
func
(
x
*
emailSendLogDao
)
GetSliceByState
(
ctx
context
.
Context
,
order
string
,
state
enums
.
EmailSendLog_State_Enum
)
([]
*
models
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetSliceByState
(
ctx
context
.
Context
,
order
string
,
state
enums
.
EmailSendLog_State_Enum
)
([]
*
models
.
EmailSendLog
,
error
)
{
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state = ?"
,
state
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state = ?"
,
state
)
}
}
func
(
x
*
emailSendLogDao
)
GetSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSendLog_State_Enum
)
([]
*
models
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSendLog_State_Enum
)
([]
*
models
.
EmailSendLog
,
error
)
{
if
len
(
states
)
==
0
{
if
len
(
states
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
}
}
func
(
x
*
emailSendLogDao
)
GetMapSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSendLog_State_Enum
)
(
map
[
enums
.
EmailSendLog_State_Enum
][]
*
models
.
EmailSendLog
,
int
,
error
)
{
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
}
emailSendLogs
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
0
,
nil
}
emailSendLogMapSlice
:=
make
(
map
[
enums
.
EmailSendLog_State_Enum
][]
*
models
.
EmailSendLog
)
for
i
:=
range
emailSendLogs
{
emailSendLogMapSlice
[
emailSendLogs
[
i
]
.
State
]
=
append
(
emailSendLogMapSlice
[
emailSendLogs
[
i
]
.
State
],
emailSendLogs
[
i
])
}
return
emailSendLogMapSlice
,
len
(
emailSendLogs
),
nil
}
func
(
x
*
emailSendLogDao
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
order
string
,
emailSendID
xsf
.
ID
)
([]
*
models
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
order
string
,
emailSendID
xsf
.
ID
)
([]
*
models
.
EmailSendLog
,
error
)
{
if
emailSendID
<=
0
{
if
emailSendID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id = ?"
,
emailSendID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id = ?"
,
emailSendID
)
...
@@ -64,24 +36,24 @@ func (x *emailSendLogDao) GetSliceByEmailSendIDs(ctx context.Context, order stri
...
@@ -64,24 +36,24 @@ func (x *emailSendLogDao) GetSliceByEmailSendIDs(ctx context.Context, order stri
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLogs
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id IN (?)"
,
emailSendIDs
)
emailSendLogs
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id IN (?)"
,
emailSendIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
emailSendLogs
,
nil
return
emailSendLogs
,
nil
}
}
func
(
x
*
emailSendLogDao
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
order
string
,
emailSendIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailSendLog
,
int
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
order
string
,
emailSendIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailSendLog
,
int
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSendLogs
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id IN (?)"
,
emailSendIDs
)
emailSendLogs
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id IN (?)"
,
emailSendIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailSendLog
)
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailSendLog
)
for
_
,
record
:=
range
emailSendLogs
{
for
_
,
record
:=
range
emailSendLogs
{
itemMap
[
record
.
EmailSendID
]
=
append
(
itemMap
[
record
.
EmailSendID
],
record
)
itemMap
[
record
.
EmailSendID
]
=
append
(
itemMap
[
record
.
EmailSendID
],
record
)
}
}
return
itemMap
,
len
(
emailSendLogs
),
nil
return
itemMap
,
len
(
emailSendLogs
),
nil
}
}
pkg/email/dao/email_tpl.go
浏览文件 @
a4765858
package
dao
package
dao
import
(
import
(
"context"
"context"
"
operator-qt/internal/modules/operator/cache
"
"
gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
)
type
emailTplDao
struct
{
type
emailTplDao
struct
{
*
odao
.
ODao
[
models
.
EmailTpl
]
*
odao
.
ODao
[
models
.
EmailTpl
]
}
}
var
EmailTplDao
=
&
emailTplDao
{
var
EmailTplDao
=
&
emailTplDao
{}
ODao
:
odao
.
NewDao
[
models
.
EmailTpl
](
consts
.
Schema_operator
),
}
func
init
()
{
func
(
x
*
emailTplDao
)
GetByCode
(
ctx
context
.
Context
,
code
string
)
(
*
models
.
EmailTpl
,
error
)
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
if
code
==
""
{
EmailTplDao
.
ODao
.
Cache
=
cache
.
NewEmailTplCache
(
database
.
GetCacheType
())
return
nil
,
nil
})
}
return
x
.
GetByWhere
(
ctx
,
"code = ?"
,
code
)
}
}
pkg/email/dao/email_tpl_receiver.go
浏览文件 @
a4765858
package
dao
package
dao
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
)
type
emailTplReceiverDao
struct
{
type
emailTplReceiverDao
struct
{
*
odao
.
ODao
[
models
.
EmailTplReceiver
]
*
odao
.
ODao
[
models
.
EmailTplReceiver
]
}
}
var
EmailTplReceiverDao
=
&
emailTplReceiverDao
{
var
EmailTplReceiverDao
=
&
emailTplReceiverDao
{}
ODao
:
odao
.
NewDao
[
models
.
EmailTplReceiver
](
consts
.
Schema_operator
),
}
func
init
()
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
EmailTplReceiverDao
.
ODao
.
Cache
=
cache
.
NewEmailTplReceiverCache
(
database
.
GetCacheType
())
})
}
func
(
x
*
emailTplReceiverDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
xsf
.
ID
)
([]
*
models
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
xsf
.
ID
)
([]
*
models
.
EmailTplReceiver
,
error
)
{
if
tplID
<=
0
{
if
tplID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
...
@@ -35,24 +24,24 @@ func (x *emailTplReceiverDao) GetSliceByTplIDs(ctx context.Context, order string
...
@@ -35,24 +24,24 @@ func (x *emailTplReceiverDao) GetSliceByTplIDs(ctx context.Context, order string
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
emailTplReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
emailTplReceivers
,
nil
return
emailTplReceivers
,
nil
}
}
func
(
x
*
emailTplReceiverDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailTplReceiver
,
int
,
error
)
{
func
(
x
*
emailTplReceiverDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
][]
*
models
.
EmailTplReceiver
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailTplReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
emailTplReceivers
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id IN (?)"
,
tplIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailTplReceiver
)
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailTplReceiver
)
for
_
,
record
:=
range
emailTplReceivers
{
for
_
,
record
:=
range
emailTplReceivers
{
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
}
}
return
itemMap
,
len
(
emailTplReceivers
),
nil
return
itemMap
,
len
(
emailTplReceivers
),
nil
}
}
pkg/email/ecode/ecode.go
浏览文件 @
a4765858
package
ecode
package
ecode
import
"errors"
var
(
ErrEmailReceiverNotFound
=
errors
.
New
(
"email receiver not found"
)
ErrEmailReceiverAlreadyExists
=
errors
.
New
(
"email receiver already exists"
)
ErrEmailSendLogNotFound
=
errors
.
New
(
"email send log not found"
)
ErrEmailSendLogAlreadyExists
=
errors
.
New
(
"email send log already exists"
)
ErrEmailSendNotFound
=
errors
.
New
(
"email send not found"
)
ErrEmailSendAlreadyExists
=
errors
.
New
(
"email send already exists"
)
ErrEmailTplNotFound
=
errors
.
New
(
"email tpl not found"
)
ErrEmailTplAlreadyExists
=
errors
.
New
(
"email tpl already exists"
)
ErrEmailTplReceiverNotFound
=
errors
.
New
(
"email tpl receiver not found"
)
ErrEmailTplReceiverAlreadyExists
=
errors
.
New
(
"email tpl receiver already exists"
)
ErrEmailNotFound
=
errors
.
New
(
"email not found"
)
ErrEmailAlreadyExists
=
errors
.
New
(
"email already exists"
)
)
pkg/email/ecode/email_http.go
deleted
100644 → 0
浏览文件 @
4c2a0b25
package
ecode
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
)
// email business-level http error codes.
// the emailNO value range is 1~100, if the same error code is used, it will cause panic.
var
(
EmailName
=
"邮件"
emailBaseCode
=
errcode
.
HCode
(
emailNO
)
ErrEmailAlreadyExists
=
errcode
.
NewError
(
emailBaseCode
+
1
,
EmailName
+
"已存在"
)
ErrEmailCreate
=
errcode
.
NewError
(
emailBaseCode
+
2
,
"创建"
+
EmailName
+
"失败"
)
ErrEmailDeleteByID
=
errcode
.
NewError
(
emailBaseCode
+
3
,
"通过id删除"
+
EmailName
+
"失败"
)
ErrEmailUpdateByID
=
errcode
.
NewError
(
emailBaseCode
+
4
,
"通过id更新"
+
EmailName
+
"失败"
)
ErrEmailGetByID
=
errcode
.
NewError
(
emailBaseCode
+
5
,
"通过id查询"
+
EmailName
+
"失败"
)
ErrEmailPage
=
errcode
.
NewError
(
emailBaseCode
+
6
,
"分页查询"
+
EmailName
+
"失败"
)
ErrEmailDeleteByIDs
=
errcode
.
NewError
(
emailBaseCode
+
7
,
"通过ids删除"
+
EmailName
+
"失败"
)
ErrEmailGetSliceByCondition
=
errcode
.
NewError
(
emailBaseCode
+
8
,
"条件查询"
+
EmailName
+
"失败"
)
ErrEmailGetByIDs
=
errcode
.
NewError
(
emailBaseCode
+
9
,
"通过ids批量查询"
+
EmailName
+
"失败"
)
ErrEmailListByLastID
=
errcode
.
NewError
(
emailBaseCode
+
10
,
"通过lastID倒序查询"
+
EmailName
+
"失败"
)
ErrEmailNotFound
=
errcode
.
NewError
(
emailBaseCode
+
11
,
"未查询到"
+
EmailName
)
ErrEmailExport
=
errcode
.
NewError
(
emailBaseCode
+
12
,
"导出"
+
EmailName
+
"失败"
)
// error codes are globally unique, adding 1 to the previous error code
)
pkg/email/ecode/email_receiver_http.go
deleted
100644 → 0
浏览文件 @
4c2a0b25
package
ecode
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
)
// emailReceiver business-level http error codes.
// the emailReceiverNO value range is 1~100, if the same error code is used, it will cause panic.
var
(
EmailReceiverName
=
"邮件收件人"
emailReceiverBaseCode
=
errcode
.
HCode
(
emailReceiverNO
)
ErrEmailReceiverAlreadyExists
=
errcode
.
NewError
(
emailReceiverBaseCode
+
1
,
EmailReceiverName
+
"已存在"
)
ErrEmailReceiverCreate
=
errcode
.
NewError
(
emailReceiverBaseCode
+
2
,
"创建"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverDeleteByID
=
errcode
.
NewError
(
emailReceiverBaseCode
+
3
,
"通过id删除"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverUpdateByID
=
errcode
.
NewError
(
emailReceiverBaseCode
+
4
,
"通过id更新"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverGetByID
=
errcode
.
NewError
(
emailReceiverBaseCode
+
5
,
"通过id查询"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverPage
=
errcode
.
NewError
(
emailReceiverBaseCode
+
6
,
"分页查询"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverDeleteByIDs
=
errcode
.
NewError
(
emailReceiverBaseCode
+
7
,
"通过ids删除"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverGetSliceByCondition
=
errcode
.
NewError
(
emailReceiverBaseCode
+
8
,
"条件查询"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverGetByIDs
=
errcode
.
NewError
(
emailReceiverBaseCode
+
9
,
"通过ids批量查询"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverListByLastID
=
errcode
.
NewError
(
emailReceiverBaseCode
+
10
,
"通过lastID倒序查询"
+
EmailReceiverName
+
"失败"
)
ErrEmailReceiverNotFound
=
errcode
.
NewError
(
emailReceiverBaseCode
+
11
,
"未查询到"
+
EmailReceiverName
)
ErrEmailReceiverExport
=
errcode
.
NewError
(
emailReceiverBaseCode
+
12
,
"导出"
+
EmailReceiverName
+
"失败"
)
// error codes are globally unique, adding 1 to the previous error code
)
pkg/email/ecode/email_send_http.go
deleted
100644 → 0
浏览文件 @
4c2a0b25
package
ecode
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
)
// emailSend business-level http error codes.
// the emailSendNO value range is 1~100, if the same error code is used, it will cause panic.
var
(
EmailSendName
=
"邮件发送"
emailSendBaseCode
=
errcode
.
HCode
(
emailSendNO
)
ErrEmailSendAlreadyExists
=
errcode
.
NewError
(
emailSendBaseCode
+
1
,
EmailSendName
+
"已存在"
)
ErrEmailSendCreate
=
errcode
.
NewError
(
emailSendBaseCode
+
2
,
"创建"
+
EmailSendName
+
"失败"
)
ErrEmailSendDeleteByID
=
errcode
.
NewError
(
emailSendBaseCode
+
3
,
"通过id删除"
+
EmailSendName
+
"失败"
)
ErrEmailSendUpdateByID
=
errcode
.
NewError
(
emailSendBaseCode
+
4
,
"通过id更新"
+
EmailSendName
+
"失败"
)
ErrEmailSendGetByID
=
errcode
.
NewError
(
emailSendBaseCode
+
5
,
"通过id查询"
+
EmailSendName
+
"失败"
)
ErrEmailSendPage
=
errcode
.
NewError
(
emailSendBaseCode
+
6
,
"分页查询"
+
EmailSendName
+
"失败"
)
ErrEmailSendDeleteByIDs
=
errcode
.
NewError
(
emailSendBaseCode
+
7
,
"通过ids删除"
+
EmailSendName
+
"失败"
)
ErrEmailSendGetSliceByCondition
=
errcode
.
NewError
(
emailSendBaseCode
+
8
,
"条件查询"
+
EmailSendName
+
"失败"
)
ErrEmailSendGetByIDs
=
errcode
.
NewError
(
emailSendBaseCode
+
9
,
"通过ids批量查询"
+
EmailSendName
+
"失败"
)
ErrEmailSendListByLastID
=
errcode
.
NewError
(
emailSendBaseCode
+
10
,
"通过lastID倒序查询"
+
EmailSendName
+
"失败"
)
ErrEmailSendNotFound
=
errcode
.
NewError
(
emailSendBaseCode
+
11
,
"未查询到"
+
EmailSendName
)
ErrEmailSendExport
=
errcode
.
NewError
(
emailSendBaseCode
+
12
,
"导出"
+
EmailSendName
+
"失败"
)
// error codes are globally unique, adding 1 to the previous error code
)
pkg/email/ecode/email_send_log_http.go
deleted
100644 → 0
浏览文件 @
4c2a0b25
package
ecode
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
)
// emailSendLog business-level http error codes.
// the emailSendLogNO value range is 1~100, if the same error code is used, it will cause panic.
var
(
EmailSendLogName
=
"邮件发送记录"
emailSendLogBaseCode
=
errcode
.
HCode
(
emailSendLogNO
)
ErrEmailSendLogAlreadyExists
=
errcode
.
NewError
(
emailSendLogBaseCode
+
1
,
EmailSendLogName
+
"已存在"
)
ErrEmailSendLogCreate
=
errcode
.
NewError
(
emailSendLogBaseCode
+
2
,
"创建"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogDeleteByID
=
errcode
.
NewError
(
emailSendLogBaseCode
+
3
,
"通过id删除"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogUpdateByID
=
errcode
.
NewError
(
emailSendLogBaseCode
+
4
,
"通过id更新"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogGetByID
=
errcode
.
NewError
(
emailSendLogBaseCode
+
5
,
"通过id查询"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogPage
=
errcode
.
NewError
(
emailSendLogBaseCode
+
6
,
"分页查询"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogDeleteByIDs
=
errcode
.
NewError
(
emailSendLogBaseCode
+
7
,
"通过ids删除"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogGetSliceByCondition
=
errcode
.
NewError
(
emailSendLogBaseCode
+
8
,
"条件查询"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogGetByIDs
=
errcode
.
NewError
(
emailSendLogBaseCode
+
9
,
"通过ids批量查询"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogListByLastID
=
errcode
.
NewError
(
emailSendLogBaseCode
+
10
,
"通过lastID倒序查询"
+
EmailSendLogName
+
"失败"
)
ErrEmailSendLogNotFound
=
errcode
.
NewError
(
emailSendLogBaseCode
+
11
,
"未查询到"
+
EmailSendLogName
)
ErrEmailSendLogExport
=
errcode
.
NewError
(
emailSendLogBaseCode
+
12
,
"导出"
+
EmailSendLogName
+
"失败"
)
// error codes are globally unique, adding 1 to the previous error code
)
pkg/email/ecode/email_tpl_http.go
deleted
100644 → 0
浏览文件 @
4c2a0b25
package
ecode
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
)
// emailTpl business-level http error codes.
// the emailTplNO value range is 1~100, if the same error code is used, it will cause panic.
var
(
EmailTplName
=
"邮件模板"
emailTplBaseCode
=
errcode
.
HCode
(
emailTplNO
)
ErrEmailTplAlreadyExists
=
errcode
.
NewError
(
emailTplBaseCode
+
1
,
EmailTplName
+
"已存在"
)
ErrEmailTplCreate
=
errcode
.
NewError
(
emailTplBaseCode
+
2
,
"创建"
+
EmailTplName
+
"失败"
)
ErrEmailTplDeleteByID
=
errcode
.
NewError
(
emailTplBaseCode
+
3
,
"通过id删除"
+
EmailTplName
+
"失败"
)
ErrEmailTplUpdateByID
=
errcode
.
NewError
(
emailTplBaseCode
+
4
,
"通过id更新"
+
EmailTplName
+
"失败"
)
ErrEmailTplGetByID
=
errcode
.
NewError
(
emailTplBaseCode
+
5
,
"通过id查询"
+
EmailTplName
+
"失败"
)
ErrEmailTplPage
=
errcode
.
NewError
(
emailTplBaseCode
+
6
,
"分页查询"
+
EmailTplName
+
"失败"
)
ErrEmailTplDeleteByIDs
=
errcode
.
NewError
(
emailTplBaseCode
+
7
,
"通过ids删除"
+
EmailTplName
+
"失败"
)
ErrEmailTplGetSliceByCondition
=
errcode
.
NewError
(
emailTplBaseCode
+
8
,
"条件查询"
+
EmailTplName
+
"失败"
)
ErrEmailTplGetByIDs
=
errcode
.
NewError
(
emailTplBaseCode
+
9
,
"通过ids批量查询"
+
EmailTplName
+
"失败"
)
ErrEmailTplListByLastID
=
errcode
.
NewError
(
emailTplBaseCode
+
10
,
"通过lastID倒序查询"
+
EmailTplName
+
"失败"
)
ErrEmailTplNotFound
=
errcode
.
NewError
(
emailTplBaseCode
+
11
,
"未查询到"
+
EmailTplName
)
ErrEmailTplExport
=
errcode
.
NewError
(
emailTplBaseCode
+
12
,
"导出"
+
EmailTplName
+
"失败"
)
// error codes are globally unique, adding 1 to the previous error code
)
pkg/email/ecode/email_tpl_receiver_http.go
deleted
100644 → 0
浏览文件 @
4c2a0b25
package
ecode
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
)
// emailTplReceiver business-level http error codes.
// the emailTplReceiverNO value range is 1~100, if the same error code is used, it will cause panic.
var
(
EmailTplReceiverName
=
"邮件模板收件人"
emailTplReceiverBaseCode
=
errcode
.
HCode
(
emailTplReceiverNO
)
ErrEmailTplReceiverAlreadyExists
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
1
,
EmailTplReceiverName
+
"已存在"
)
ErrEmailTplReceiverCreate
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
2
,
"创建"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverDeleteByID
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
3
,
"通过id删除"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverUpdateByID
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
4
,
"通过id更新"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverGetByID
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
5
,
"通过id查询"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverPage
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
6
,
"分页查询"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverDeleteByIDs
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
7
,
"通过ids删除"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverGetSliceByCondition
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
8
,
"条件查询"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverGetByIDs
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
9
,
"通过ids批量查询"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverListByLastID
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
10
,
"通过lastID倒序查询"
+
EmailTplReceiverName
+
"失败"
)
ErrEmailTplReceiverNotFound
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
11
,
"未查询到"
+
EmailTplReceiverName
)
ErrEmailTplReceiverExport
=
errcode
.
NewError
(
emailTplReceiverBaseCode
+
12
,
"导出"
+
EmailTplReceiverName
+
"失败"
)
// error codes are globally unique, adding 1 to the previous error code
)
pkg/email/email.go
浏览文件 @
a4765858
package
xemail
package
xemail
import
(
import
(
"crypto/rand"
"bytes"
"context"
"crypto/tls"
"crypto/tls"
"fmt"
"fmt"
"math/big"
"io"
"regexp"
"text/template"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
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/pkg/xerrors/xerror"
"gorm.io/gorm"
"gopkg.in/gomail.v2"
"gopkg.in/gomail.v2"
)
)
// 配置结构体 (建议从环境变量或配置文件中读取)
func
NewEmail
(
from
string
,
to
[]
*
models
.
EmailTplReceiver
,
subject
string
,
body
string
,
attachments
[]
*
config
.
Attachment
,
inlineImages
map
[
string
]
string
)
*
config
.
Email
{
type
Config
struct
{
e
:=
config
.
Email
{
SMTPServer
string
From
:
from
,
SMTPPort
int
Subject
:
subject
,
SMTPUsername
string
Body
:
body
,
SMTPPassword
string
Attachments
:
attachments
,
FromEmail
string
InlineImages
:
inlineImages
,
}
}
for
_
,
r
:=
range
to
{
func
GenerateVerificationCode
(
length
int
)
(
string
,
error
)
{
name
,
email
,
err
:=
extractEmailReceiver
(
r
.
Receiver
)
code
:=
""
for
i
:=
0
;
i
<
length
;
i
++
{
num
,
err
:=
rand
.
Int
(
rand
.
Reader
,
big
.
NewInt
(
10
))
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
logger
.
Error
(
"extract email receiver err"
,
logger
.
Err
(
err
))
continue
}
}
code
+=
num
.
String
()
e
.
To
=
append
(
e
.
To
,
config
.
Receiver
{
Email
:
email
,
DisplayName
:
name
,
})
}
return
&
e
}
func
extractEmailReceiver
(
input
string
)
(
name
,
email
string
,
err
error
)
{
re
:=
regexp
.
MustCompile
(
`^([^<]+)\s*<([^>]+)>$`
)
matches
:=
re
.
FindStringSubmatch
(
input
)
if
len
(
matches
)
!=
3
{
return
""
,
""
,
fmt
.
Errorf
(
"无效的邮件格式"
)
}
}
return
code
,
nil
name
=
matches
[
1
]
name
=
regexp
.
MustCompile
(
`^\s+|\s+$`
)
.
ReplaceAllString
(
name
,
""
)
email
=
matches
[
2
]
return
name
,
email
,
nil
}
}
func
Send
VerificationCode
(
cfg
Config
,
toEmail
string
,
code
string
)
error
{
func
Send
TLS
(
ctx
context
.
Context
,
e
*
config
.
Email
)
error
{
m
:=
gomail
.
NewMessage
()
m
:=
gomail
.
NewMessage
()
m
.
SetHeader
(
"From"
,
cfg
.
FromEmail
)
m
.
SetAddressHeader
(
"From"
,
config
.
Cfg
.
Email
,
e
.
From
)
m
.
SetHeader
(
"To"
,
toEmail
)
var
toList
[]
string
m
.
SetHeader
(
"Subject"
,
"[万桩严选商城]验证码"
)
for
_
,
r
:=
range
e
.
To
{
m
.
SetBody
(
"text/html"
,
fmt
.
Sprintf
(
`
toList
=
append
(
toList
,
m
.
FormatAddress
(
r
.
Email
,
r
.
DisplayName
))
<html>
}
<body>
m
.
SetHeader
(
"To"
,
toList
...
)
<h3>验证码通知</h3>
m
.
SetHeader
(
"Subject"
,
e
.
Subject
)
<p>您的验证码是:<strong>%s</strong></p>
if
len
(
e
.
InlineImages
)
>
0
{
<p>有效期15分钟,请勿泄露给他人</p>
m
.
SetBody
(
"text/html"
,
e
.
Body
)
</body>
for
cid
,
filePath
:=
range
e
.
InlineImages
{
</html>
m
.
Embed
(
filePath
,
gomail
.
Rename
(
cid
))
`
,
code
))
}
}
else
{
m
.
SetBody
(
"text/html"
,
e
.
Body
)
}
for
_
,
att
:=
range
e
.
Attachments
{
if
att
.
FilePath
!=
""
{
if
att
.
ContentType
!=
""
{
m
.
Attach
(
att
.
FilePath
,
gomail
.
Rename
(
att
.
Filename
),
gomail
.
SetHeader
(
map
[
string
][]
string
{
"Content-Type"
:
{
att
.
ContentType
},
}))
}
else
{
m
.
Attach
(
att
.
FilePath
,
gomail
.
Rename
(
att
.
Filename
))
}
}
else
if
len
(
att
.
Data
)
>
0
{
reader
:=
bytes
.
NewReader
(
att
.
Data
)
if
att
.
ContentType
!=
""
{
m
.
Attach
(
att
.
Filename
,
gomail
.
SetCopyFunc
(
func
(
w
io
.
Writer
)
error
{
_
,
err
:=
io
.
Copy
(
w
,
reader
)
return
err
}),
gomail
.
SetHeader
(
map
[
string
][]
string
{
"Content-Type"
:
{
att
.
ContentType
},
}))
}
else
{
m
.
Attach
(
att
.
Filename
,
gomail
.
SetCopyFunc
(
func
(
w
io
.
Writer
)
error
{
_
,
err
:=
io
.
Copy
(
w
,
reader
)
return
err
}))
}
}
}
d
:=
gomail
.
NewDialer
(
d
:=
gomail
.
NewDialer
(
cfg
.
SMTPServer
,
c
onfig
.
C
fg
.
SMTPServer
,
cfg
.
SMTPPort
,
c
onfig
.
C
fg
.
SMTPPort
,
c
fg
.
SMTPUsername
,
c
onfig
.
Cfg
.
Email
,
c
fg
.
SMTPPassword
,
c
onfig
.
Cfg
.
Token
,
)
)
d
.
TLSConfig
=
&
tls
.
Config
{
ServerName
:
cfg
.
SMTPServer
}
d
.
TLSConfig
=
&
tls
.
Config
{
d
.
SSL
=
false
ServerName
:
config
.
Cfg
.
SMTPServer
,
MinVersion
:
tls
.
VersionTLS12
,
InsecureSkipVerify
:
false
,
}
d
.
SSL
=
true
if
err
:=
d
.
DialAndSend
(
m
);
err
!=
nil
{
if
err
:=
d
.
DialAndSend
(
m
);
err
!=
nil
{
return
xerror
.
New
(
err
.
Error
())
return
xerror
.
New
(
err
.
Error
())
}
}
return
nil
return
nil
}
}
type
oEmail
struct
{
}
var
OEmail
=
&
oEmail
{}
//
//func (x *oEmail) SendAsync(ctx context.Context, tplCode string, params map[string]string, cfg *Config) (err error) {
// et, err := service.EmailTplService.GetByCode(ctx, tplCode, nil)
// if err != nil {
// return err
// }
// if et == nil {
// return xerror.NewC(ecode.ErrEmailTplNotFound.ToXerror())
// }
// rs, err := service.EmailTplReceiverService.GetSliceByTplID(ctx, et.GetID(), nil)
// if err != nil {
// return err
// }
// if len(rs) == 0 {
// return xerror.NewC(ecode.ErrEmailTplReceiverNotFound.ToXerror())
// }
//
// subjectTpl, err := template.New(fmt.Sprintf("%s_%s_subject", tplCode, et.GetID())).Parse(et.Subject)
// if err != nil {
// return xerror.Wrap(err, "parse subjectTpl")
// }
// var subjectBuf bytes.Buffer
// if err = subjectTpl.Execute(&subjectBuf, params); err != nil {
// return xerror.Wrap(err, "render subjectTpl")
// }
// contentTpl, err := template.New(fmt.Sprintf("%s_%s_content", tplCode, et.GetID())).Parse(et.Tpl)
// if err != nil {
// return xerror.Wrap(err, "parse contentTpl")
// }
// var contentBuf bytes.Buffer
// if err = contentTpl.Execute(&contentBuf, params); err != nil {
// return xerror.Wrap(err, "render contentTpl")
// }
//
// from := fmt.Sprintf("%s<%s>", cfg.Name, cfg.Email)
// email := models.Email{}
// email.ID = xsfUtils.EmailID(ctx)
// email.TplID = et.ID
// email.From = from
// email.Subject = subjectBuf.String()
// email.Content = contentBuf.String()
//
// receivers := make([]*models.EmailReceiver, 0, len(rs))
// for _, r := range rs {
// receivers = append(receivers, &models.EmailReceiver{
// EmailID: email.ID,
// Receiver: r.Receiver,
// })
// }
//
// emailSend := models.EmailSend{}
// emailSend.ID = xsfUtils.EmailSendID(ctx)
// emailSend.EmailID = email.ID
// emailSend.State = enums.EmailSend_State_Wait
//
// emailSendLog := models.EmailSendLog{}
// emailSendLog.ID = xsfUtils.EmailSendLogID(ctx)
// emailSendLog.EmailSendID = emailSend.ID
// emailSendLog.State = emailSend.State
//
// if err := dao.EmailDao.Transaction(func(tx *gorm.DB) error {
// if err = dao.EmailDao.CreateTx(ctx, tx, &email); err != nil {
// return err
// }
// if err = dao.EmailReceiverDao.CreateSliceTx(ctx, tx, receivers); err != nil {
// return err
// }
// if err = dao.EmailSendDao.CreateTx(ctx, tx, &emailSend); err != nil {
// return err
// }
// if err = dao.EmailSendLogDao.CreateTx(ctx, tx, &emailSendLog); err != nil {
// return err
// }
// return nil
// }); err != nil {
// return xerror.New(err.Error())
// }
//
// return nil
//}
func
(
x
*
oEmail
)
SendTLS
(
ctx
context
.
Context
,
tplCode
string
,
params
map
[
string
]
string
,
attachments
[]
*
config
.
Attachment
,
inlineImages
map
[
string
]
string
)
(
err
error
)
{
et
,
err
:=
service
.
EmailTplService
.
GetByCode
(
ctx
,
tplCode
,
nil
)
if
err
!=
nil
{
return
err
}
if
et
==
nil
{
return
ecode
.
ErrEmailTplNotFound
}
rs
,
err
:=
service
.
EmailTplReceiverService
.
GetSliceByTplID
(
ctx
,
et
.
GetID
(),
nil
)
if
err
!=
nil
{
return
err
}
if
len
(
rs
)
==
0
{
return
ecode
.
ErrEmailTplReceiverNotFound
}
subjectTpl
,
err
:=
template
.
New
(
fmt
.
Sprintf
(
"%s_%s_subject"
,
tplCode
,
et
.
GetID
()))
.
Parse
(
et
.
Subject
)
if
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"parse subjectTpl"
)
}
var
subjectBuf
bytes
.
Buffer
if
err
=
subjectTpl
.
Execute
(
&
subjectBuf
,
params
);
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"render subjectTpl"
)
}
contentTpl
,
err
:=
template
.
New
(
fmt
.
Sprintf
(
"%s_%s_content"
,
tplCode
,
et
.
GetID
()))
.
Parse
(
et
.
Tpl
)
if
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"parse contentTpl"
)
}
var
contentBuf
bytes
.
Buffer
if
err
=
contentTpl
.
Execute
(
&
contentBuf
,
params
);
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"render contentTpl"
)
}
from
:=
fmt
.
Sprintf
(
"%s<%s>"
,
config
.
Cfg
.
Name
,
config
.
Cfg
.
Email
)
email
:=
models
.
Email
{}
email
.
ID
=
xsfUtils
.
EmailID
(
ctx
)
email
.
TplID
=
et
.
ID
email
.
From
=
from
email
.
Subject
=
subjectBuf
.
String
()
email
.
Content
=
contentBuf
.
String
()
receivers
:=
make
([]
*
models
.
EmailReceiver
,
0
,
len
(
rs
))
tplReceivers
:=
make
([]
*
models
.
EmailTplReceiver
,
0
,
len
(
rs
))
for
_
,
r
:=
range
rs
{
receivers
=
append
(
receivers
,
&
models
.
EmailReceiver
{
EmailID
:
email
.
ID
,
Receiver
:
r
.
Receiver
,
})
tplReceivers
=
append
(
tplReceivers
,
&
models
.
EmailTplReceiver
{
TplID
:
r
.
ID
,
Receiver
:
r
.
Receiver
,
})
}
emailSend
:=
models
.
EmailSend
{}
emailSend
.
ID
=
xsfUtils
.
EmailSendID
(
ctx
)
emailSend
.
EmailID
=
email
.
ID
emailSend
.
State
=
enums
.
EmailSend_State_Wait
emailSendLog
:=
models
.
EmailSendLog
{}
emailSendLog
.
ID
=
xsfUtils
.
EmailSendLogID
(
ctx
)
emailSendLog
.
EmailSendID
=
emailSend
.
ID
emailSendLog
.
State
=
emailSend
.
State
e
:=
NewEmail
(
email
.
From
,
tplReceivers
,
email
.
Subject
,
email
.
Content
,
attachments
,
inlineImages
)
if
err
:=
SendTLS
(
ctx
,
e
);
err
!=
nil
{
return
err
}
emailSend
.
State
=
enums
.
EmailSend_State_Success
emailSendLog
.
State
=
emailSend
.
State
if
err
:=
dao
.
EmailDao
.
Transaction
(
func
(
tx
*
gorm
.
DB
)
error
{
if
err
=
dao
.
EmailDao
.
CreateTx
(
ctx
,
tx
,
&
email
);
err
!=
nil
{
return
err
}
if
err
=
dao
.
EmailReceiverDao
.
CreateSliceTx
(
ctx
,
tx
,
receivers
);
err
!=
nil
{
return
err
}
if
err
=
dao
.
EmailSendDao
.
CreateTx
(
ctx
,
tx
,
&
emailSend
);
err
!=
nil
{
return
err
}
if
err
=
dao
.
EmailSendLogDao
.
CreateTx
(
ctx
,
tx
,
&
emailSendLog
);
err
!=
nil
{
return
err
}
return
nil
});
err
!=
nil
{
return
xerror
.
New
(
err
.
Error
())
}
return
nil
}
pkg/email/email.sql
浏览文件 @
a4765858
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>]'
,
`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
=
'邮件模板'
;
drop
table
if
exists
`email_tpl_receiver`
;
CREATE
TABLE
`email_tpl_receiver`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'用户主键id eg[1]'
,
`tpl_id`
bigint
(
20
)
NOT
NULL
COMMENT
'模板id eg[1]'
,
`receiver`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'收件人 eg[月饼<mooncake2026@163.com>]'
,
`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_tpl_id`
(
`tpl_id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'邮件模板收件人'
;
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]'
,
`from`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'发件人 eg[月饼<mooncake2026@163.com>]'
,
`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
)
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]'
,
`email_id`
bigint
(
20
)
NOT
NULL
COMMENT
'邮件id eg[1]'
,
`receiver`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'收件人 eg[月饼<mooncake2026@163.com>]'
,
`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_email_id`
(
`email_id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'邮件收件人'
;
drop
table
if
exists
`email_send`
;
CREATE
TABLE
`email_send`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'用户主键id eg[1]'
,
`email_id`
bigint
(
20
)
NOT
NULL
COMMENT
'邮件id eg[1]'
,
`state`
tinyint
(
4
)
NOT
NULL
DEFAULT
'1'
COMMENT
'发送状态 enums[0.Unknown.未知 1.Wait.待处理 2.Doing.处理中 3.Success.成功 4.Fail.失败 ] eg[1]'
,
`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`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'邮件发送'
;
drop
table
if
exists
`email_send_log`
;
CREATE
TABLE
`email_send_log`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'用户主键id eg[1]'
,
`email_send_id`
bigint
(
20
)
NOT
NULL
COMMENT
'邮件发送id eg[1]'
,
`state`
tinyint
(
4
)
NOT
NULL
DEFAULT
'1'
COMMENT
'发送状态 enums[0.Unknown.未知 1.Wait.待处理 2.Doing.处理中 3.Success.成功 4.Fail.失败 ] eg[1]'
,
`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`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'邮件发送记录'
;
\ No newline at end of file
pkg/email/enums/email_send.go
浏览文件 @
a4765858
package
enums
package
enums
type
EmailSend_State_Enum
int8
func
init
()
{
var
(
pdict
.
Add
(
"operator_emailSend_state"
,
EmailSend_State_Enums_Dict
)
EmailSend_State_Unknown
EmailSend_State_Enum
=
0
// 未知
mdict
.
Add
(
"emailSend_state"
,
EmailSend_State_Enums_Dict
)
EmailSend_State_Wait
EmailSend_State_Enum
=
1
// 待处理
}
EmailSend_State_Doing
EmailSend_State_Enum
=
2
// 处理中
type
EmailSend_State_Enum
int8
EmailSend_State_Success
EmailSend_State_Enum
=
3
// 成功
var
(
EmailSend_State_Fail
EmailSend_State_Enum
=
4
// 失败
EmailSend_State_Unknown
EmailSend_State_Enum
=
0
// 未知
EmailSend_State_Enums_ALL
=
[]
EmailSend_State_Enum
{
EmailSend_State_Wait
EmailSend_State_Enum
=
1
// 待处理
EmailSend_State_Doing
EmailSend_State_Enum
=
2
// 处理中
EmailSend_State_Success
EmailSend_State_Enum
=
3
// 成功
EmailSend_State_Fail
EmailSend_State_Enum
=
4
// 失败
EmailSend_State_Enums_ALL
=
[]
EmailSend_State_Enum
{
EmailSend_State_Unknown
,
EmailSend_State_Unknown
,
EmailSend_State_Wait
,
EmailSend_State_Wait
,
EmailSend_State_Doing
,
EmailSend_State_Doing
,
...
@@ -20,26 +16,27 @@ func init() {
...
@@ -20,26 +16,27 @@ func init() {
EmailSend_State_Fail
,
EmailSend_State_Fail
,
}
}
EmailSend_State_Enums_Dict
=
map
[
EmailSend_State_Enum
]
string
{
EmailSend_State_Enums_Dict
=
map
[
EmailSend_State_Enum
]
string
{
EmailSend_State_Unknown
:
EmailSend_State_Unknown
.
Desc
(),
EmailSend_State_Unknown
:
EmailSend_State_Unknown
.
Desc
(),
EmailSend_State_Wait
:
EmailSend_State_Wait
.
Desc
(),
EmailSend_State_Wait
:
EmailSend_State_Wait
.
Desc
(),
EmailSend_State_Doing
:
EmailSend_State_Doing
.
Desc
(),
EmailSend_State_Doing
:
EmailSend_State_Doing
.
Desc
(),
EmailSend_State_Success
:
EmailSend_State_Success
.
Desc
(),
EmailSend_State_Success
:
EmailSend_State_Success
.
Desc
(),
EmailSend_State_Fail
:
EmailSend_State_Fail
.
Desc
(),
EmailSend_State_Fail
:
EmailSend_State_Fail
.
Desc
(),
}
}
)
)
func
(
x
EmailSend_State_Enum
)
Desc
()
string
{
desc
:=
"未知"
func
(
x
EmailSend_State_Enum
)
Desc
()
string
{
switch
x
{
desc
:=
"未知"
case
EmailSend_State_Unknown
:
switch
x
{
desc
=
"未知"
case
EmailSend_State_Unknown
:
case
EmailSend_State_Wait
:
desc
=
"未知"
desc
=
"待处理"
case
EmailSend_State_Wait
:
case
EmailSend_State_Doing
:
desc
=
"待处理"
desc
=
"处理中"
case
EmailSend_State_Doing
:
case
EmailSend_State_Success
:
desc
=
"处理中"
desc
=
"成功"
case
EmailSend_State_Success
:
case
EmailSend_State_Fail
:
desc
=
"成功"
desc
=
"失败"
case
EmailSend_State_Fail
:
}
desc
=
"失败"
return
desc
}
}
return
desc
}
pkg/email/enums/email_send_log.go
浏览文件 @
a4765858
package
enums
package
enums
type
EmailSendLog_State_Enum
int8
func
init
()
{
var
(
pdict
.
Add
(
"operator_emailSendLog_state"
,
EmailSendLog_State_Enums_Dict
)
EmailSendLog_State_Unknown
EmailSendLog_State_Enum
=
0
// 未知
mdict
.
Add
(
"emailSendLog_state"
,
EmailSendLog_State_Enums_Dict
)
EmailSendLog_State_Wait
EmailSendLog_State_Enum
=
1
// 待处理
}
EmailSendLog_State_Doing
EmailSendLog_State_Enum
=
2
// 处理中
type
EmailSendLog_State_Enum
int8
EmailSendLog_State_Success
EmailSendLog_State_Enum
=
3
// 成功
var
(
EmailSendLog_State_Fail
EmailSendLog_State_Enum
=
4
// 失败
EmailSendLog_State_Unknown
EmailSendLog_State_Enum
=
0
// 未知
EmailSendLog_State_Enums_ALL
=
[]
EmailSendLog_State_Enum
{
EmailSendLog_State_Wait
EmailSendLog_State_Enum
=
1
// 待处理
EmailSendLog_State_Doing
EmailSendLog_State_Enum
=
2
// 处理中
EmailSendLog_State_Success
EmailSendLog_State_Enum
=
3
// 成功
EmailSendLog_State_Fail
EmailSendLog_State_Enum
=
4
// 失败
EmailSendLog_State_Enums_ALL
=
[]
EmailSendLog_State_Enum
{
EmailSendLog_State_Unknown
,
EmailSendLog_State_Unknown
,
EmailSendLog_State_Wait
,
EmailSendLog_State_Wait
,
EmailSendLog_State_Doing
,
EmailSendLog_State_Doing
,
...
@@ -20,26 +16,27 @@ func init() {
...
@@ -20,26 +16,27 @@ func init() {
EmailSendLog_State_Fail
,
EmailSendLog_State_Fail
,
}
}
EmailSendLog_State_Enums_Dict
=
map
[
EmailSendLog_State_Enum
]
string
{
EmailSendLog_State_Enums_Dict
=
map
[
EmailSendLog_State_Enum
]
string
{
EmailSendLog_State_Unknown
:
EmailSendLog_State_Unknown
.
Desc
(),
EmailSendLog_State_Unknown
:
EmailSendLog_State_Unknown
.
Desc
(),
EmailSendLog_State_Wait
:
EmailSendLog_State_Wait
.
Desc
(),
EmailSendLog_State_Wait
:
EmailSendLog_State_Wait
.
Desc
(),
EmailSendLog_State_Doing
:
EmailSendLog_State_Doing
.
Desc
(),
EmailSendLog_State_Doing
:
EmailSendLog_State_Doing
.
Desc
(),
EmailSendLog_State_Success
:
EmailSendLog_State_Success
.
Desc
(),
EmailSendLog_State_Success
:
EmailSendLog_State_Success
.
Desc
(),
EmailSendLog_State_Fail
:
EmailSendLog_State_Fail
.
Desc
(),
EmailSendLog_State_Fail
:
EmailSendLog_State_Fail
.
Desc
(),
}
}
)
)
func
(
x
EmailSendLog_State_Enum
)
Desc
()
string
{
desc
:=
"未知"
func
(
x
EmailSendLog_State_Enum
)
Desc
()
string
{
switch
x
{
desc
:=
"未知"
case
EmailSendLog_State_Unknown
:
switch
x
{
desc
=
"未知"
case
EmailSendLog_State_Unknown
:
case
EmailSendLog_State_Wait
:
desc
=
"未知"
desc
=
"待处理"
case
EmailSendLog_State_Wait
:
case
EmailSendLog_State_Doing
:
desc
=
"待处理"
desc
=
"处理中"
case
EmailSendLog_State_Doing
:
case
EmailSendLog_State_Success
:
desc
=
"处理中"
desc
=
"成功"
case
EmailSendLog_State_Success
:
case
EmailSendLog_State_Fail
:
desc
=
"成功"
desc
=
"失败"
case
EmailSendLog_State_Fail
:
}
desc
=
"失败"
return
desc
}
}
return
desc
}
pkg/email/init.go
浏览文件 @
a4765858
package
xemail
package
xemail
import
(
"context"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
econfig
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
)
func
init
()
{
_
=
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicParseConfFinish
,
func
(
ctx
context
.
Context
)
{
config
.
Read
(
func
(
c
*
config
.
Config
)
{
_
=
copier
.
Copy
(
econfig
.
Cfg
,
&
c
.
Email
)
})
})
_
=
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicDBInitFinish
,
func
(
ctx
context
.
Context
)
{
dao
.
EmailDao
.
ODao
=
odao
.
NewDao
[
models
.
Email
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailReceiverDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailReceiver
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailSendDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailSend
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailSendLogDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailSendLog
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailTplDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailTpl
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailTplReceiverDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailTplReceiver
](
econfig
.
Cfg
.
Schema
)
})
_
=
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
dao
.
EmailDao
.
ODao
=
odao
.
NewDao
[
models
.
Email
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailReceiverDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailReceiver
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailSendDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailSend
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailSendLogDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailSendLog
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailTplDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailTpl
](
econfig
.
Cfg
.
Schema
)
dao
.
EmailTplReceiverDao
.
ODao
=
odao
.
NewDao
[
models
.
EmailTplReceiver
](
econfig
.
Cfg
.
Schema
)
})
_
=
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicConfChange
,
func
(
ctx
context
.
Context
)
{
config
.
Read
(
func
(
c
*
config
.
Config
)
{
_
=
copier
.
Copy
(
config
.
Cfg
,
&
c
.
Email
)
})
})
}
pkg/email/models/email.go
浏览文件 @
a4765858
package
models
package
models
import
(
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
)
//Email 邮件
//
Email 邮件
type
Email
struct
{
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"`
//主键
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
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:"subject"`
//主题
Content
string
`json:"content" form:"content" gorm:"column:content;type:text;comment:邮件内容" example:"<div>hello moon! </div>" csv:"邮件内容"`
//邮件内容
From
string
`json:"from" form:"from" gorm:"column:from;type:varchar(255);comment:发件人" example:"月饼<mooncake2026@163.com>" csv:"发件人"`
//发件人
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
Content
string
`json:"content" form:"content" gorm:"column:content;type:text;comment:邮件内容" example:"<div>hello moon! </div>" csv:"邮件内容"`
//邮件内容
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" 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:"更新时间"`
//更新时间
}
}
const
TBEmail
=
"email"
const
TBEmail
=
"email"
func
(
Email
)
TableName
()
string
{
func
(
Email
)
TableName
()
string
{
return
TBEmail
return
TBEmail
}
}
func
(
x
Email
)
GetID
()
xsf
.
ID
{
func
(
x
Email
)
GetID
()
xsf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
Email
)
GetTplID
()
xsf
.
ID
{
func
(
x
*
Email
)
GetTplID
()
xsf
.
ID
{
return
x
.
TplID
return
x
.
TplID
}
}
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
}
}
return
set
.
Slice
()
return
set
.
Slice
()
}
}
func
(
x
Email
)
GetOrder
()
string
{
func
(
x
Email
)
GetOrder
()
string
{
return
"id asc"
return
"id asc"
}
}
...
...
pkg/email/models/email_receiver.go
浏览文件 @
a4765858
package
models
package
models
import
(
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
)
//EmailReceiver 邮件收件人
//
EmailReceiver 邮件收件人
type
EmailReceiver
struct
{
type
EmailReceiver
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" 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:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
}
}
const
TBEmailReceiver
=
"email_receiver"
const
TBEmailReceiver
=
"email_receiver"
func
(
EmailReceiver
)
TableName
()
string
{
func
(
EmailReceiver
)
TableName
()
string
{
return
TBEmailReceiver
return
TBEmailReceiver
}
}
func
(
x
EmailReceiver
)
GetID
()
xsf
.
ID
{
func
(
x
EmailReceiver
)
GetID
()
xsf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailReceiver
)
GetEmailID
()
xsf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailID
()
xsf
.
ID
{
return
x
.
EmailID
return
x
.
EmailID
}
}
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
}
}
return
set
.
Slice
()
return
set
.
Slice
()
}
}
func
(
x
EmailReceiver
)
GetOrder
()
string
{
func
(
x
EmailReceiver
)
GetOrder
()
string
{
return
"id asc"
return
"id asc"
}
}
...
...
pkg/email/models/email_send.go
浏览文件 @
a4765858
package
models
package
models
import
(
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
)
//EmailSend 邮件发送
//
EmailSend 邮件发送
type
EmailSend
struct
{
type
EmailSend
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" 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:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
}
}
const
TBEmailSend
=
"email_send"
const
TBEmailSend
=
"email_send"
func
(
EmailSend
)
TableName
()
string
{
func
(
EmailSend
)
TableName
()
string
{
return
TBEmailSend
return
TBEmailSend
}
}
func
(
x
EmailSend
)
GetID
()
xsf
.
ID
{
func
(
x
EmailSend
)
GetID
()
xsf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailSend
)
GetEmailID
()
xsf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailID
()
xsf
.
ID
{
return
x
.
EmailID
return
x
.
EmailID
}
}
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
}
}
return
set
.
Slice
()
return
set
.
Slice
()
}
}
func
(
x
EmailSend
)
GetOrder
()
string
{
func
(
x
EmailSend
)
GetOrder
()
string
{
return
"id asc"
return
"id asc"
}
}
...
...
pkg/email/models/email_send_log.go
浏览文件 @
a4765858
package
models
package
models
import
(
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
)
//EmailSendLog 邮件发送记录
//
EmailSendLog 邮件发送记录
type
EmailSendLog
struct
{
type
EmailSendLog
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" gorm:"column:email_send_id;type:bigint(20);comment:邮件发送id" example:"1" csv:"邮件发送id"`
//邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" gorm:"column:email_send_id;type:bigint(20);comment:邮件发送id" example:"1" csv:"邮件发送id"`
//邮件发送id
State
enums
.
EmailSendLog
_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend
_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" 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:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
}
}
const
TBEmailSendLog
=
"email_send_log"
const
TBEmailSendLog
=
"email_send_log"
func
(
EmailSendLog
)
TableName
()
string
{
func
(
EmailSendLog
)
TableName
()
string
{
return
TBEmailSendLog
return
TBEmailSendLog
}
}
func
(
x
EmailSendLog
)
GetID
()
xsf
.
ID
{
func
(
x
EmailSendLog
)
GetID
()
xsf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailSendLog
)
GetEmailSendID
()
xsf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendID
()
xsf
.
ID
{
return
x
.
EmailSendID
return
x
.
EmailSendID
}
}
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailSendID
())
set
.
Add
(
r
.
GetEmailSendID
())
}
}
return
set
.
Slice
()
return
set
.
Slice
()
}
}
func
(
x
EmailSendLog
)
GetOrder
()
string
{
func
(
x
EmailSendLog
)
GetOrder
()
string
{
return
"id asc"
return
"id asc"
}
}
...
...
pkg/email/models/email_tpl.go
浏览文件 @
a4765858
package
models
package
models
import
(
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
)
//EmailTpl 邮件模板
//
EmailTpl 邮件模板
type
EmailTpl
struct
{
type
EmailTpl
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
Code
int
`json:"code" form:"code" gorm:"column:code;type:tinyint(8);comment:模板代码" example:"SMS_NOTICE" csv:"模板代码"`
//模板代码
Code
string
`json:"code" form:"code" gorm:"column:code;type:tinyint(8);comment:模板代码" example:"SMS_NOTICE" csv:"模板代码"`
//模板代码
Tpl
string
`json:"tpl" form:"tpl" gorm:"column:tpl;type:text;comment:模板" example:"<div>hello moon! </div>" csv:"模板"`
//模板
Subject
string
`json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"subject"`
//主题
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
Tpl
string
`json:"tpl" form:"tpl" gorm:"column:tpl;type:text;comment:模板" example:"<div>hello moon! </div>" csv:"模板"`
//模板
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" 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:"更新时间"`
//更新时间
}
}
const
TBEmailTpl
=
"email_tpl"
const
TBEmailTpl
=
"email_tpl"
func
(
EmailTpl
)
TableName
()
string
{
func
(
EmailTpl
)
TableName
()
string
{
return
TBEmailTpl
return
TBEmailTpl
}
}
func
(
x
EmailTpl
)
GetID
()
xsf
.
ID
{
func
(
x
EmailTpl
)
GetID
()
xsf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
EmailTpl
)
GetOrder
()
string
{
func
(
x
EmailTpl
)
GetOrder
()
string
{
return
"id asc"
return
"id asc"
}
}
...
...
pkg/email/models/email_tpl_receiver.go
浏览文件 @
a4765858
package
models
package
models
import
(
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
)
//EmailTplReceiver 邮件模板收件人
//
EmailTplReceiver 邮件模板收件人
type
EmailTplReceiver
struct
{
type
EmailTplReceiver
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" 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:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
}
}
const
TBEmailTplReceiver
=
"email_tpl_receiver"
const
TBEmailTplReceiver
=
"email_tpl_receiver"
func
(
EmailTplReceiver
)
TableName
()
string
{
func
(
EmailTplReceiver
)
TableName
()
string
{
return
TBEmailTplReceiver
return
TBEmailTplReceiver
}
}
func
(
x
EmailTplReceiver
)
GetID
()
xsf
.
ID
{
func
(
x
EmailTplReceiver
)
GetID
()
xsf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailTplReceiver
)
GetTplID
()
xsf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplID
()
xsf
.
ID
{
return
x
.
TplID
return
x
.
TplID
}
}
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
}
}
return
set
.
Slice
()
return
set
.
Slice
()
}
}
func
(
x
EmailTplReceiver
)
GetOrder
()
string
{
func
(
x
EmailTplReceiver
)
GetOrder
()
string
{
return
"id asc"
return
"id asc"
}
}
...
...
pkg/email/service/common.go
浏览文件 @
a4765858
package
service
package
service
import
(
"context"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"time"
)
type
commonService
struct
{}
func
newCommonService
()
*
commonService
{
return
&
commonService
{}
}
const
(
batchSize
=
2000
)
func
csvName
(
ctx
context
.
Context
,
tableName
string
)
string
{
if
ctxUtils
.
GetCtxUID
(
ctx
)
>
0
{
return
"csv/"
+
tableName
+
""
+
cast
.
ToString
(
ctxUtils
.
GetCtxUID
(
ctx
))
+
"_"
+
time
.
Now
()
.
Format
(
"20060102150405"
)
+
".csv"
}
return
"csv/"
+
tableName
+
"_"
+
time
.
Now
()
.
Format
(
"20060102150405"
)
+
".csv"
}
pkg/email/service/email.go
浏览文件 @
a4765858
package
service
package
service
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/ecode"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"operator-qt/internal/modules/operator/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailService
struct
{
type
emailService
struct
{
...
@@ -24,12 +24,12 @@ var EmailService = newEmailService()
...
@@ -24,12 +24,12 @@ var EmailService = newEmailService()
func
newEmailService
()
*
emailService
{
func
newEmailService
()
*
emailService
{
return
&
emailService
{
return
&
emailService
{
Service
:
xcommon
.
NewService
(),
Service
:
xcommon
.
NewService
(),
commonService
:
newCommonService
(),
commonService
:
newCommonService
(),
}
}
}
}
func
(
x
*
emailService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
func
(
x
*
emailService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
email
:=
&
models
.
Email
{}
email
:=
&
models
.
Email
{}
_
=
copier
.
Copy
(
email
,
in
)
_
=
copier
.
Copy
(
email
,
in
)
email
.
ID
=
xsfUtils
.
EmailID
(
ctx
)
email
.
ID
=
xsfUtils
.
EmailID
(
ctx
)
...
@@ -49,22 +49,8 @@ func (x *emailService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.Emai
...
@@ -49,22 +49,8 @@ func (x *emailService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.Emai
return
dao
.
EmailDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
EmailDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
emailService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
error
{
if
len
(
ids
)
==
0
{
return
nil
}
emails
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
ids
,
emails
,
ecode
.
ErrEmailNotFound
);
err
!=
nil
{
return
err
}
return
dao
.
EmailDao
.
DeleteByIDs
(
ctx
,
ids
)
}
func
(
x
*
emailService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailUpdateByIDReq
,
opts
*
biz
.
EmailOpts
)
error
{
func
(
x
*
emailService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailUpdateByIDReq
,
opts
*
biz
.
EmailOpts
)
error
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
nil
return
nil
}
}
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
...
@@ -72,26 +58,9 @@ func (x *emailService) UpdateByID(ctx context.Context, in *types.EmailUpdateByID
...
@@ -72,26 +58,9 @@ func (x *emailService) UpdateByID(ctx context.Context, in *types.EmailUpdateByID
}
}
emailUpd
:=
&
models
.
Email
{}
emailUpd
:=
&
models
.
Email
{}
_
=
copier
.
Copy
(
emailUpd
,
in
)
_
=
copier
.
Copy
(
emailUpd
,
in
)
return
dao
.
EmailDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailUpd
)
return
dao
.
EmailDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailUpd
)
}
func
(
x
*
emailService
)
UpdateByIDs
(
ctx
context
.
Context
,
in
*
types
.
EmailUpdateByIDsReq
,
opts
*
biz
.
EmailOpts
)
error
{
if
len
(
in
.
IDs
)
==
0
{
return
nil
}
emails
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
in
.
IDs
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
in
.
IDs
,
emails
,
ecode
.
ErrEmailNotFound
);
err
!=
nil
{
return
err
}
emailUpd
:=
&
models
.
Email
{}
_
=
copier
.
Copy
(
emailUpd
,
in
)
return
dao
.
EmailDao
.
UpdateByIDs
(
ctx
,
in
.
IDs
,
emailUpd
)
}
}
func
(
x
*
emailService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
func
(
x
*
emailService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
...
@@ -101,7 +70,7 @@ func (x *emailService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.EmailO
...
@@ -101,7 +70,7 @@ func (x *emailService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.EmailO
return
nil
,
err
return
nil
,
err
}
}
if
emailBiz
!=
nil
{
if
emailBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailAlreadyExists
}
}
return
emailBiz
,
nil
return
emailBiz
,
nil
}
}
...
@@ -115,50 +84,49 @@ func (x *emailService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz.Ema
...
@@ -115,50 +84,49 @@ func (x *emailService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz.Ema
return
nil
,
err
return
nil
,
err
}
}
if
emailBiz
==
nil
{
if
emailBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailNotFound
}
}
return
emailBiz
,
nil
return
emailBiz
,
nil
}
}
func
(
x
*
emailService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
func
(
x
*
emailService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
email
,
err
:=
dao
.
EmailDao
.
GetByID
(
ctx
,
id
)
email
,
err
:=
dao
.
EmailDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
email
==
nil
{
if
email
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToBiz
(
ctx
,
email
,
opts
)
return
x
.
ToBiz
(
ctx
,
email
,
opts
)
}
}
func
(
x
*
emailService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByIDs
(
ctx
,
ids
)
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
}
}
func
(
x
*
emailService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
Email
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
emailBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailBizSlice
)
==
0
{
if
len
(
emailBizSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailBizIDMap
:=
biz
.
EmailTool
.
SliceToIDMapBiz
(
emailBizSlice
)
emailBizIDMap
:=
biz
.
EmailTool
.
SliceToIDMapBiz
(
emailBizSlice
)
return
emailBizIDMap
,
nil
return
emailBizIDMap
,
nil
...
@@ -169,8 +137,8 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq, opts *b
...
@@ -169,8 +137,8 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq, opts *b
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
total
,
nil
return
nil
,
total
,
nil
}
}
emailBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
emailBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -178,50 +146,50 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq, opts *b
...
@@ -178,50 +146,50 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq, opts *b
}
}
return
emailBizSlice
,
total
,
nil
return
emailBizSlice
,
total
,
nil
}
}
func
(
x
*
emailService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
tplID
==
0
{
if
tplID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByTplID
(
ctx
,
models
.
EmailTool
.
GetOrder
(),
tplID
)
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByTplID
(
ctx
,
models
.
EmailTool
.
GetOrder
(),
tplID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
}
}
func
(
x
*
emailService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByTplIDs
(
ctx
,
models
.
EmailTool
.
GetOrder
(),
tplIDs
)
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByTplIDs
(
ctx
,
models
.
EmailTool
.
GetOrder
(),
tplIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
}
}
func
(
x
*
emailService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
Email
,
int
,
error
)
{
func
(
x
*
emailService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
Email
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
emailBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailBizSlice
)
==
0
{
if
len
(
emailBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
Email
)
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
Email
)
for
_
,
r
:=
range
emailBizSlice
{
for
_
,
r
:=
range
emailBizSlice
{
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
}
}
return
ret
,
len
(
emailBizSlice
),
nil
return
ret
,
len
(
emailBizSlice
),
nil
}
}
func
(
x
*
emailService
)
ToBiz
(
ctx
context
.
Context
,
email
*
models
.
Email
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
func
(
x
*
emailService
)
ToBiz
(
ctx
context
.
Context
,
email
*
models
.
Email
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
...
@@ -249,34 +217,35 @@ func (x *emailService) ToSliceBiz(ctx context.Context, emails []*models.Email, o
...
@@ -249,34 +217,35 @@ func (x *emailService) ToSliceBiz(ctx context.Context, emails []*models.Email, o
return
emailBizSlice
,
nil
return
emailBizSlice
,
nil
}
}
func
(
x
*
emailService
)
Fill
(
ctx
context
.
Context
,
emailBiz
*
biz
.
Email
,
opts
*
biz
.
EmailOpts
)
error
{
func
(
x
*
emailService
)
Fill
(
ctx
context
.
Context
,
emailBiz
*
biz
.
Email
,
opts
*
biz
.
EmailOpts
)
error
{
if
emailBiz
==
nil
{
if
emailBiz
==
nil
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailService
)
SliceFill
(
ctx
context
.
Context
,
emailBizSlice
[]
*
biz
.
Email
,
opts
*
biz
.
EmailOpts
)
error
{
func
(
x
*
emailService
)
SliceFill
(
ctx
context
.
Context
,
emailBizSlice
[]
*
biz
.
Email
,
opts
*
biz
.
EmailOpts
)
error
{
if
len
(
emailBizSlice
)
==
0
{
if
len
(
emailBizSlice
)
==
0
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailOpts
)
(
[]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailOpts
)
(
[]
*
biz
.
Email
,
error
)
{
emails
,
err
:=
dao
.
EmailDao
.
GetAll
(
ctx
)
emails
,
err
:=
dao
.
EmailDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
}
}
func
(
x
*
emailService
)
ExportCSV
(
ctx
context
.
Context
,
in
*
types
.
EmailExportReq
,
opts
*
biz
.
EmailOpts
)
(
string
,
error
)
{
func
(
x
*
emailService
)
ExportCSV
(
ctx
context
.
Context
,
in
*
types
.
EmailExportReq
,
opts
*
biz
.
EmailOpts
)
(
string
,
error
)
{
req
:=
&
types
.
EmailPageReq
{}
req
:=
&
types
.
EmailPageReq
{}
_
=
copier
.
Copy
(
req
,
in
)
_
=
copier
.
Copy
(
req
,
in
)
...
...
pkg/email/service/email_receiver.go
浏览文件 @
a4765858
package
service
package
service
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/ecode"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"operator-qt/internal/modules/operator/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailReceiverService
struct
{
type
emailReceiverService
struct
{
...
@@ -24,12 +24,12 @@ var EmailReceiverService = newEmailReceiverService()
...
@@ -24,12 +24,12 @@ var EmailReceiverService = newEmailReceiverService()
func
newEmailReceiverService
()
*
emailReceiverService
{
func
newEmailReceiverService
()
*
emailReceiverService
{
return
&
emailReceiverService
{
return
&
emailReceiverService
{
Service
:
xcommon
.
NewService
(),
Service
:
xcommon
.
NewService
(),
commonService
:
newCommonService
(),
commonService
:
newCommonService
(),
}
}
}
}
func
(
x
*
emailReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
func
(
x
*
emailReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
emailReceiver
:=
&
models
.
EmailReceiver
{}
emailReceiver
:=
&
models
.
EmailReceiver
{}
_
=
copier
.
Copy
(
emailReceiver
,
in
)
_
=
copier
.
Copy
(
emailReceiver
,
in
)
emailReceiver
.
ID
=
xsfUtils
.
EmailReceiverID
(
ctx
)
emailReceiver
.
ID
=
xsfUtils
.
EmailReceiverID
(
ctx
)
...
@@ -49,22 +49,8 @@ func (x *emailReceiverService) DeleteByID(ctx context.Context, id xsf.ID, opts *
...
@@ -49,22 +49,8 @@ func (x *emailReceiverService) DeleteByID(ctx context.Context, id xsf.ID, opts *
return
dao
.
EmailReceiverDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
EmailReceiverDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
emailReceiverService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
if
len
(
ids
)
==
0
{
return
nil
}
emailReceivers
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
ids
,
emailReceivers
,
ecode
.
ErrEmailReceiverNotFound
);
err
!=
nil
{
return
err
}
return
dao
.
EmailReceiverDao
.
DeleteByIDs
(
ctx
,
ids
)
}
func
(
x
*
emailReceiverService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverUpdateByIDReq
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
func
(
x
*
emailReceiverService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverUpdateByIDReq
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
nil
return
nil
}
}
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
...
@@ -72,26 +58,9 @@ func (x *emailReceiverService) UpdateByID(ctx context.Context, in *types.EmailRe
...
@@ -72,26 +58,9 @@ func (x *emailReceiverService) UpdateByID(ctx context.Context, in *types.EmailRe
}
}
emailReceiverUpd
:=
&
models
.
EmailReceiver
{}
emailReceiverUpd
:=
&
models
.
EmailReceiver
{}
_
=
copier
.
Copy
(
emailReceiverUpd
,
in
)
_
=
copier
.
Copy
(
emailReceiverUpd
,
in
)
return
dao
.
EmailReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailReceiverUpd
)
return
dao
.
EmailReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailReceiverUpd
)
}
}
func
(
x
*
emailReceiverService
)
UpdateByIDs
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverUpdateByIDsReq
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
if
len
(
in
.
IDs
)
==
0
{
return
nil
}
emailReceivers
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
in
.
IDs
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
in
.
IDs
,
emailReceivers
,
ecode
.
ErrEmailReceiverNotFound
);
err
!=
nil
{
return
err
}
emailReceiverUpd
:=
&
models
.
EmailReceiver
{}
_
=
copier
.
Copy
(
emailReceiverUpd
,
in
)
return
dao
.
EmailReceiverDao
.
UpdateByIDs
(
ctx
,
in
.
IDs
,
emailReceiverUpd
)
}
func
(
x
*
emailReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
func
(
x
*
emailReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
...
@@ -101,7 +70,7 @@ func (x *emailReceiverService) ErrFound(ctx context.Context, id xsf.ID, opts *bi
...
@@ -101,7 +70,7 @@ func (x *emailReceiverService) ErrFound(ctx context.Context, id xsf.ID, opts *bi
return
nil
,
err
return
nil
,
err
}
}
if
emailReceiverBiz
!=
nil
{
if
emailReceiverBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailReceiverAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailReceiverAlreadyExists
}
}
return
emailReceiverBiz
,
nil
return
emailReceiverBiz
,
nil
}
}
...
@@ -115,50 +84,49 @@ func (x *emailReceiverService) ErrNotFound(ctx context.Context, id xsf.ID, opts
...
@@ -115,50 +84,49 @@ func (x *emailReceiverService) ErrNotFound(ctx context.Context, id xsf.ID, opts
return
nil
,
err
return
nil
,
err
}
}
if
emailReceiverBiz
==
nil
{
if
emailReceiverBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailReceiverNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailReceiverNotFound
}
}
return
emailReceiverBiz
,
nil
return
emailReceiverBiz
,
nil
}
}
func
(
x
*
emailReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
func
(
x
*
emailReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceiver
,
err
:=
dao
.
EmailReceiverDao
.
GetByID
(
ctx
,
id
)
emailReceiver
,
err
:=
dao
.
EmailReceiverDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
emailReceiver
==
nil
{
if
emailReceiver
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToBiz
(
ctx
,
emailReceiver
,
opts
)
return
x
.
ToBiz
(
ctx
,
emailReceiver
,
opts
)
}
}
func
(
x
*
emailReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByIDs
(
ctx
,
ids
)
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
}
}
func
(
x
*
emailReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailReceiverBizSlice
)
==
0
{
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceiverBizIDMap
:=
biz
.
EmailReceiverTool
.
SliceToIDMapBiz
(
emailReceiverBizSlice
)
emailReceiverBizIDMap
:=
biz
.
EmailReceiverTool
.
SliceToIDMapBiz
(
emailReceiverBizSlice
)
return
emailReceiverBizIDMap
,
nil
return
emailReceiverBizIDMap
,
nil
...
@@ -169,8 +137,8 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
...
@@ -169,8 +137,8 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
total
,
nil
return
nil
,
total
,
nil
}
}
emailReceiverBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
emailReceiverBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -178,50 +146,50 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
...
@@ -178,50 +146,50 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
}
}
return
emailReceiverBizSlice
,
total
,
nil
return
emailReceiverBizSlice
,
total
,
nil
}
}
func
(
x
*
emailReceiverService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
emailID
==
0
{
if
emailID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByEmailID
(
ctx
,
models
.
EmailReceiverTool
.
GetOrder
(),
emailID
)
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByEmailID
(
ctx
,
models
.
EmailReceiverTool
.
GetOrder
(),
emailID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
}
}
func
(
x
*
emailReceiverService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByEmailIDs
(
ctx
,
models
.
EmailReceiverTool
.
GetOrder
(),
emailIDs
)
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByEmailIDs
(
ctx
,
models
.
EmailReceiverTool
.
GetOrder
(),
emailIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
}
}
func
(
x
*
emailReceiverService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailReceiver
,
int
,
error
)
{
func
(
x
*
emailReceiverService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailReceiver
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailReceiverBizSlice
)
==
0
{
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailReceiver
)
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailReceiver
)
for
_
,
r
:=
range
emailReceiverBizSlice
{
for
_
,
r
:=
range
emailReceiverBizSlice
{
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
}
}
return
ret
,
len
(
emailReceiverBizSlice
),
nil
return
ret
,
len
(
emailReceiverBizSlice
),
nil
}
}
func
(
x
*
emailReceiverService
)
ToBiz
(
ctx
context
.
Context
,
emailReceiver
*
models
.
EmailReceiver
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
func
(
x
*
emailReceiverService
)
ToBiz
(
ctx
context
.
Context
,
emailReceiver
*
models
.
EmailReceiver
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
...
@@ -249,30 +217,30 @@ func (x *emailReceiverService) ToSliceBiz(ctx context.Context, emailReceivers []
...
@@ -249,30 +217,30 @@ func (x *emailReceiverService) ToSliceBiz(ctx context.Context, emailReceivers []
return
emailReceiverBizSlice
,
nil
return
emailReceiverBizSlice
,
nil
}
}
func
(
x
*
emailReceiverService
)
Fill
(
ctx
context
.
Context
,
emailReceiverBiz
*
biz
.
EmailReceiver
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
func
(
x
*
emailReceiverService
)
Fill
(
ctx
context
.
Context
,
emailReceiverBiz
*
biz
.
EmailReceiver
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
if
emailReceiverBiz
==
nil
{
if
emailReceiverBiz
==
nil
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailReceiverService
)
SliceFill
(
ctx
context
.
Context
,
emailReceiverBizSlice
[]
*
biz
.
EmailReceiver
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
func
(
x
*
emailReceiverService
)
SliceFill
(
ctx
context
.
Context
,
emailReceiverBizSlice
[]
*
biz
.
EmailReceiver
,
opts
*
biz
.
EmailReceiverOpts
)
error
{
if
len
(
emailReceiverBizSlice
)
==
0
{
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailReceiverOpts
)
(
[]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailReceiverOpts
)
(
[]
*
biz
.
EmailReceiver
,
error
)
{
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetAll
(
ctx
)
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
...
...
pkg/email/service/email_send.go
浏览文件 @
a4765858
package
service
package
service
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/ecode"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"operator-qt/internal/modules/operator/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailSendService
struct
{
type
emailSendService
struct
{
...
@@ -25,12 +25,12 @@ var EmailSendService = newEmailSendService()
...
@@ -25,12 +25,12 @@ var EmailSendService = newEmailSendService()
func
newEmailSendService
()
*
emailSendService
{
func
newEmailSendService
()
*
emailSendService
{
return
&
emailSendService
{
return
&
emailSendService
{
Service
:
xcommon
.
NewService
(),
Service
:
xcommon
.
NewService
(),
commonService
:
newCommonService
(),
commonService
:
newCommonService
(),
}
}
}
}
func
(
x
*
emailSendService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
func
(
x
*
emailSendService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
emailSend
:=
&
models
.
EmailSend
{}
emailSend
:=
&
models
.
EmailSend
{}
_
=
copier
.
Copy
(
emailSend
,
in
)
_
=
copier
.
Copy
(
emailSend
,
in
)
emailSend
.
ID
=
xsfUtils
.
EmailSendID
(
ctx
)
emailSend
.
ID
=
xsfUtils
.
EmailSendID
(
ctx
)
...
@@ -50,22 +50,8 @@ func (x *emailSendService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.
...
@@ -50,22 +50,8 @@ func (x *emailSendService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.
return
dao
.
EmailSendDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
EmailSendDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
emailSendService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
error
{
if
len
(
ids
)
==
0
{
return
nil
}
emailSends
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
ids
,
emailSends
,
ecode
.
ErrEmailSendNotFound
);
err
!=
nil
{
return
err
}
return
dao
.
EmailSendDao
.
DeleteByIDs
(
ctx
,
ids
)
}
func
(
x
*
emailSendService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailSendUpdateByIDReq
,
opts
*
biz
.
EmailSendOpts
)
error
{
func
(
x
*
emailSendService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailSendUpdateByIDReq
,
opts
*
biz
.
EmailSendOpts
)
error
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
nil
return
nil
}
}
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
...
@@ -73,26 +59,9 @@ func (x *emailSendService) UpdateByID(ctx context.Context, in *types.EmailSendUp
...
@@ -73,26 +59,9 @@ func (x *emailSendService) UpdateByID(ctx context.Context, in *types.EmailSendUp
}
}
emailSendUpd
:=
&
models
.
EmailSend
{}
emailSendUpd
:=
&
models
.
EmailSend
{}
_
=
copier
.
Copy
(
emailSendUpd
,
in
)
_
=
copier
.
Copy
(
emailSendUpd
,
in
)
return
dao
.
EmailSendDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendUpd
)
return
dao
.
EmailSendDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendUpd
)
}
}
func
(
x
*
emailSendService
)
UpdateByIDs
(
ctx
context
.
Context
,
in
*
types
.
EmailSendUpdateByIDsReq
,
opts
*
biz
.
EmailSendOpts
)
error
{
if
len
(
in
.
IDs
)
==
0
{
return
nil
}
emailSends
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
in
.
IDs
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
in
.
IDs
,
emailSends
,
ecode
.
ErrEmailSendNotFound
);
err
!=
nil
{
return
err
}
emailSendUpd
:=
&
models
.
EmailSend
{}
_
=
copier
.
Copy
(
emailSendUpd
,
in
)
return
dao
.
EmailSendDao
.
UpdateByIDs
(
ctx
,
in
.
IDs
,
emailSendUpd
)
}
func
(
x
*
emailSendService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
func
(
x
*
emailSendService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
...
@@ -102,7 +71,7 @@ func (x *emailSendService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.Em
...
@@ -102,7 +71,7 @@ func (x *emailSendService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.Em
return
nil
,
err
return
nil
,
err
}
}
if
emailSendBiz
!=
nil
{
if
emailSendBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendAlreadyExists
}
}
return
emailSendBiz
,
nil
return
emailSendBiz
,
nil
}
}
...
@@ -116,50 +85,49 @@ func (x *emailSendService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz
...
@@ -116,50 +85,49 @@ func (x *emailSendService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz
return
nil
,
err
return
nil
,
err
}
}
if
emailSendBiz
==
nil
{
if
emailSendBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendNotFound
}
}
return
emailSendBiz
,
nil
return
emailSendBiz
,
nil
}
}
func
(
x
*
emailSendService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
func
(
x
*
emailSendService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSend
,
err
:=
dao
.
EmailSendDao
.
GetByID
(
ctx
,
id
)
emailSend
,
err
:=
dao
.
EmailSendDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
emailSend
==
nil
{
if
emailSend
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToBiz
(
ctx
,
emailSend
,
opts
)
return
x
.
ToBiz
(
ctx
,
emailSend
,
opts
)
}
}
func
(
x
*
emailSendService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByIDs
(
ctx
,
ids
)
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
}
func
(
x
*
emailSendService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailSend
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
emailSendBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendBizSlice
)
==
0
{
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendBizIDMap
:=
biz
.
EmailSendTool
.
SliceToIDMapBiz
(
emailSendBizSlice
)
emailSendBizIDMap
:=
biz
.
EmailSendTool
.
SliceToIDMapBiz
(
emailSendBizSlice
)
return
emailSendBizIDMap
,
nil
return
emailSendBizIDMap
,
nil
...
@@ -170,8 +138,8 @@ func (x *emailSendService) Page(ctx context.Context, in *types.EmailSendPageReq,
...
@@ -170,8 +138,8 @@ func (x *emailSendService) Page(ctx context.Context, in *types.EmailSendPageReq,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
total
,
nil
return
nil
,
total
,
nil
}
}
emailSendBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
emailSendBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -184,91 +152,91 @@ func (x *emailSendService) GetSliceByState(ctx context.Context, state enums.Emai
...
@@ -184,91 +152,91 @@ func (x *emailSendService) GetSliceByState(ctx context.Context, state enums.Emai
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
}
func
(
x
*
emailSendService
)
GetSliceByStates
(
ctx
context
.
Context
,
states
[]
enums
.
EmailSend_State_Enum
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByStates
(
ctx
context
.
Context
,
states
[]
enums
.
EmailSend_State_Enum
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
states
)
==
0
{
if
len
(
states
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendMapSlice
,
size
,
err
:=
dao
.
EmailSendDao
.
GetMapSliceByStates
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
states
)
emailSendMapSlice
,
size
,
err
:=
dao
.
EmailSendDao
.
GetMapSliceByStates
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
states
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendMapSlice
)
==
0
{
if
len
(
emailSendMapSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSends
:=
make
([]
*
models
.
EmailSend
,
0
,
size
)
emailSends
:=
make
([]
*
models
.
EmailSend
,
0
,
size
)
for
_
,
v
:=
range
emailSendMapSlice
{
for
_
,
v
:=
range
emailSendMapSlice
{
emailSends
=
append
(
emailSends
,
v
...
)
emailSends
=
append
(
emailSends
,
v
...
)
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
}
func
(
x
*
emailSendService
)
GetMapSliceByStates
(
ctx
context
.
Context
,
states
[]
enums
.
EmailSend_State_Enum
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
enums
.
EmailSend_State_Enum
][]
*
biz
.
EmailSend
,
int
,
error
)
{
func
(
x
*
emailSendService
)
GetMapSliceByStates
(
ctx
context
.
Context
,
states
[]
enums
.
EmailSend_State_Enum
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
enums
.
EmailSend_State_Enum
][]
*
biz
.
EmailSend
,
int
,
error
)
{
if
len
(
states
)
==
0
{
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSendBizSlice
,
err
:=
x
.
GetSliceByStates
(
ctx
,
states
,
opts
)
emailSendBizSlice
,
err
:=
x
.
GetSliceByStates
(
ctx
,
states
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailSendBizSlice
)
==
0
{
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
enums
.
EmailSend_State_Enum
][]
*
biz
.
EmailSend
)
ret
:=
make
(
map
[
enums
.
EmailSend_State_Enum
][]
*
biz
.
EmailSend
)
for
_
,
r
:=
range
emailSendBizSlice
{
for
_
,
r
:=
range
emailSendBizSlice
{
ret
[
r
.
State
]
=
append
(
ret
[
r
.
State
],
r
)
ret
[
r
.
State
]
=
append
(
ret
[
r
.
State
],
r
)
}
}
return
ret
,
len
(
emailSendBizSlice
),
nil
return
ret
,
len
(
emailSendBizSlice
),
nil
}
}
func
(
x
*
emailSendService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
emailID
==
0
{
if
emailID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByEmailID
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
emailID
)
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByEmailID
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
emailID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
}
func
(
x
*
emailSendService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByEmailIDs
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
emailIDs
)
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByEmailIDs
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
emailIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
}
func
(
x
*
emailSendService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSend
,
int
,
error
)
{
func
(
x
*
emailSendService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSend
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSendBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
emailSendBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailSendBizSlice
)
==
0
{
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSend
)
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSend
)
for
_
,
r
:=
range
emailSendBizSlice
{
for
_
,
r
:=
range
emailSendBizSlice
{
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
}
}
return
ret
,
len
(
emailSendBizSlice
),
nil
return
ret
,
len
(
emailSendBizSlice
),
nil
}
}
func
(
x
*
emailSendService
)
ToBiz
(
ctx
context
.
Context
,
emailSend
*
models
.
EmailSend
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
func
(
x
*
emailSendService
)
ToBiz
(
ctx
context
.
Context
,
emailSend
*
models
.
EmailSend
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
...
@@ -296,30 +264,30 @@ func (x *emailSendService) ToSliceBiz(ctx context.Context, emailSends []*models.
...
@@ -296,30 +264,30 @@ func (x *emailSendService) ToSliceBiz(ctx context.Context, emailSends []*models.
return
emailSendBizSlice
,
nil
return
emailSendBizSlice
,
nil
}
}
func
(
x
*
emailSendService
)
Fill
(
ctx
context
.
Context
,
emailSendBiz
*
biz
.
EmailSend
,
opts
*
biz
.
EmailSendOpts
)
error
{
func
(
x
*
emailSendService
)
Fill
(
ctx
context
.
Context
,
emailSendBiz
*
biz
.
EmailSend
,
opts
*
biz
.
EmailSendOpts
)
error
{
if
emailSendBiz
==
nil
{
if
emailSendBiz
==
nil
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailSendService
)
SliceFill
(
ctx
context
.
Context
,
emailSendBizSlice
[]
*
biz
.
EmailSend
,
opts
*
biz
.
EmailSendOpts
)
error
{
func
(
x
*
emailSendService
)
SliceFill
(
ctx
context
.
Context
,
emailSendBizSlice
[]
*
biz
.
EmailSend
,
opts
*
biz
.
EmailSendOpts
)
error
{
if
len
(
emailSendBizSlice
)
==
0
{
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailSendService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendOpts
)
(
[]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendOpts
)
(
[]
*
biz
.
EmailSend
,
error
)
{
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetAll
(
ctx
)
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
...
...
pkg/email/service/email_send_log.go
浏览文件 @
a4765858
package
service
package
service
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/ecode"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"operator-qt/internal/modules/operator/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailSendLogService
struct
{
type
emailSendLogService
struct
{
...
@@ -25,12 +24,12 @@ var EmailSendLogService = newEmailSendLogService()
...
@@ -25,12 +24,12 @@ var EmailSendLogService = newEmailSendLogService()
func
newEmailSendLogService
()
*
emailSendLogService
{
func
newEmailSendLogService
()
*
emailSendLogService
{
return
&
emailSendLogService
{
return
&
emailSendLogService
{
Service
:
xcommon
.
NewService
(),
Service
:
xcommon
.
NewService
(),
commonService
:
newCommonService
(),
commonService
:
newCommonService
(),
}
}
}
}
func
(
x
*
emailSendLogService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
func
(
x
*
emailSendLogService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
emailSendLog
:=
&
models
.
EmailSendLog
{}
emailSendLog
:=
&
models
.
EmailSendLog
{}
_
=
copier
.
Copy
(
emailSendLog
,
in
)
_
=
copier
.
Copy
(
emailSendLog
,
in
)
emailSendLog
.
ID
=
xsfUtils
.
EmailSendLogID
(
ctx
)
emailSendLog
.
ID
=
xsfUtils
.
EmailSendLogID
(
ctx
)
...
@@ -50,22 +49,8 @@ func (x *emailSendLogService) DeleteByID(ctx context.Context, id xsf.ID, opts *b
...
@@ -50,22 +49,8 @@ func (x *emailSendLogService) DeleteByID(ctx context.Context, id xsf.ID, opts *b
return
dao
.
EmailSendLogDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
EmailSendLogDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
emailSendLogService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
if
len
(
ids
)
==
0
{
return
nil
}
emailSendLogs
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
ids
,
emailSendLogs
,
ecode
.
ErrEmailSendLogNotFound
);
err
!=
nil
{
return
err
}
return
dao
.
EmailSendLogDao
.
DeleteByIDs
(
ctx
,
ids
)
}
func
(
x
*
emailSendLogService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogUpdateByIDReq
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
func
(
x
*
emailSendLogService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogUpdateByIDReq
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
nil
return
nil
}
}
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
...
@@ -73,26 +58,9 @@ func (x *emailSendLogService) UpdateByID(ctx context.Context, in *types.EmailSen
...
@@ -73,26 +58,9 @@ func (x *emailSendLogService) UpdateByID(ctx context.Context, in *types.EmailSen
}
}
emailSendLogUpd
:=
&
models
.
EmailSendLog
{}
emailSendLogUpd
:=
&
models
.
EmailSendLog
{}
_
=
copier
.
Copy
(
emailSendLogUpd
,
in
)
_
=
copier
.
Copy
(
emailSendLogUpd
,
in
)
return
dao
.
EmailSendLogDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendLogUpd
)
return
dao
.
EmailSendLogDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendLogUpd
)
}
func
(
x
*
emailSendLogService
)
UpdateByIDs
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogUpdateByIDsReq
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
if
len
(
in
.
IDs
)
==
0
{
return
nil
}
emailSendLogs
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
in
.
IDs
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
in
.
IDs
,
emailSendLogs
,
ecode
.
ErrEmailSendLogNotFound
);
err
!=
nil
{
return
err
}
emailSendLogUpd
:=
&
models
.
EmailSendLog
{}
_
=
copier
.
Copy
(
emailSendLogUpd
,
in
)
return
dao
.
EmailSendLogDao
.
UpdateByIDs
(
ctx
,
in
.
IDs
,
emailSendLogUpd
)
}
}
func
(
x
*
emailSendLogService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
func
(
x
*
emailSendLogService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
...
@@ -102,7 +70,7 @@ func (x *emailSendLogService) ErrFound(ctx context.Context, id xsf.ID, opts *biz
...
@@ -102,7 +70,7 @@ func (x *emailSendLogService) ErrFound(ctx context.Context, id xsf.ID, opts *biz
return
nil
,
err
return
nil
,
err
}
}
if
emailSendLogBiz
!=
nil
{
if
emailSendLogBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendLogAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendLogAlreadyExists
}
}
return
emailSendLogBiz
,
nil
return
emailSendLogBiz
,
nil
}
}
...
@@ -116,50 +84,49 @@ func (x *emailSendLogService) ErrNotFound(ctx context.Context, id xsf.ID, opts *
...
@@ -116,50 +84,49 @@ func (x *emailSendLogService) ErrNotFound(ctx context.Context, id xsf.ID, opts *
return
nil
,
err
return
nil
,
err
}
}
if
emailSendLogBiz
==
nil
{
if
emailSendLogBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendLogNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendLogNotFound
}
}
return
emailSendLogBiz
,
nil
return
emailSendLogBiz
,
nil
}
}
func
(
x
*
emailSendLogService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
func
(
x
*
emailSendLogService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLog
,
err
:=
dao
.
EmailSendLogDao
.
GetByID
(
ctx
,
id
)
emailSendLog
,
err
:=
dao
.
EmailSendLogDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
emailSendLog
==
nil
{
if
emailSendLog
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToBiz
(
ctx
,
emailSendLog
,
opts
)
return
x
.
ToBiz
(
ctx
,
emailSendLog
,
opts
)
}
}
func
(
x
*
emailSendLogService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByIDs
(
ctx
,
ids
)
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
}
}
func
(
x
*
emailSendLogService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendLogBizSlice
)
==
0
{
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLogBizIDMap
:=
biz
.
EmailSendLogTool
.
SliceToIDMapBiz
(
emailSendLogBizSlice
)
emailSendLogBizIDMap
:=
biz
.
EmailSendLogTool
.
SliceToIDMapBiz
(
emailSendLogBizSlice
)
return
emailSendLogBizIDMap
,
nil
return
emailSendLogBizIDMap
,
nil
...
@@ -170,8 +137,8 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
...
@@ -170,8 +137,8 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
total
,
nil
return
nil
,
total
,
nil
}
}
emailSendLogBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
emailSendLogBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -179,96 +146,50 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
...
@@ -179,96 +146,50 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
}
}
return
emailSendLogBizSlice
,
total
,
nil
return
emailSendLogBizSlice
,
total
,
nil
}
}
func
(
x
*
emailSendLogService
)
GetSliceByState
(
ctx
context
.
Context
,
state
enums
.
EmailSendLog_State_Enum
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
emailSendID
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByState
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
state
)
if
emailSendID
==
0
{
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
}
func
(
x
*
emailSendLogService
)
GetSliceByStates
(
ctx
context
.
Context
,
states
[]
enums
.
EmailSendLog_State_Enum
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
states
)
==
0
{
return
nil
,
nil
}
emailSendLogMapSlice
,
size
,
err
:=
dao
.
EmailSendLogDao
.
GetMapSliceByStates
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
states
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendLogMapSlice
)
==
0
{
return
nil
,
nil
}
emailSendLogs
:=
make
([]
*
models
.
EmailSendLog
,
0
,
size
)
for
_
,
v
:=
range
emailSendLogMapSlice
{
emailSendLogs
=
append
(
emailSendLogs
,
v
...
)
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
}
func
(
x
*
emailSendLogService
)
GetMapSliceByStates
(
ctx
context
.
Context
,
states
[]
enums
.
EmailSendLog_State_Enum
,
opts
*
biz
.
EmailSendLogOpts
)
(
map
[
enums
.
EmailSendLog_State_Enum
][]
*
biz
.
EmailSendLog
,
int
,
error
)
{
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
}
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByStates
(
ctx
,
states
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
enums
.
EmailSendLog_State_Enum
][]
*
biz
.
EmailSendLog
)
for
_
,
r
:=
range
emailSendLogBizSlice
{
ret
[
r
.
State
]
=
append
(
ret
[
r
.
State
],
r
)
}
return
ret
,
len
(
emailSendLogBizSlice
),
nil
}
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
emailSendID
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
emailSendID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByEmailSendID
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
emailSendID
)
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByEmailSendID
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
emailSendID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
}
}
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByEmailSendIDs
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
emailSendIDs
)
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByEmailSendIDs
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
emailSendIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
}
}
func
(
x
*
emailSendLogService
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSendLog
,
int
,
error
)
{
func
(
x
*
emailSendLogService
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSendLog
,
int
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByEmailSendIDs
(
ctx
,
emailSendIDs
,
opts
)
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByEmailSendIDs
(
ctx
,
emailSendIDs
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailSendLogBizSlice
)
==
0
{
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSendLog
)
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSendLog
)
for
_
,
r
:=
range
emailSendLogBizSlice
{
for
_
,
r
:=
range
emailSendLogBizSlice
{
ret
[
r
.
EmailSendID
]
=
append
(
ret
[
r
.
EmailSendID
],
r
)
ret
[
r
.
EmailSendID
]
=
append
(
ret
[
r
.
EmailSendID
],
r
)
}
}
return
ret
,
len
(
emailSendLogBizSlice
),
nil
return
ret
,
len
(
emailSendLogBizSlice
),
nil
}
}
func
(
x
*
emailSendLogService
)
ToBiz
(
ctx
context
.
Context
,
emailSendLog
*
models
.
EmailSendLog
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
func
(
x
*
emailSendLogService
)
ToBiz
(
ctx
context
.
Context
,
emailSendLog
*
models
.
EmailSendLog
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
...
@@ -296,30 +217,30 @@ func (x *emailSendLogService) ToSliceBiz(ctx context.Context, emailSendLogs []*m
...
@@ -296,30 +217,30 @@ func (x *emailSendLogService) ToSliceBiz(ctx context.Context, emailSendLogs []*m
return
emailSendLogBizSlice
,
nil
return
emailSendLogBizSlice
,
nil
}
}
func
(
x
*
emailSendLogService
)
Fill
(
ctx
context
.
Context
,
emailSendLogBiz
*
biz
.
EmailSendLog
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
func
(
x
*
emailSendLogService
)
Fill
(
ctx
context
.
Context
,
emailSendLogBiz
*
biz
.
EmailSendLog
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
if
emailSendLogBiz
==
nil
{
if
emailSendLogBiz
==
nil
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailSendLogService
)
SliceFill
(
ctx
context
.
Context
,
emailSendLogBizSlice
[]
*
biz
.
EmailSendLog
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
func
(
x
*
emailSendLogService
)
SliceFill
(
ctx
context
.
Context
,
emailSendLogBizSlice
[]
*
biz
.
EmailSendLog
,
opts
*
biz
.
EmailSendLogOpts
)
error
{
if
len
(
emailSendLogBizSlice
)
==
0
{
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailSendLogService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendLogOpts
)
(
[]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendLogOpts
)
(
[]
*
biz
.
EmailSendLog
,
error
)
{
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetAll
(
ctx
)
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
...
...
pkg/email/service/email_tpl.go
浏览文件 @
a4765858
package
service
package
service
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/ecode"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"operator-qt/internal/modules/operator/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailTplService
struct
{
type
emailTplService
struct
{
...
@@ -24,12 +24,12 @@ var EmailTplService = newEmailTplService()
...
@@ -24,12 +24,12 @@ var EmailTplService = newEmailTplService()
func
newEmailTplService
()
*
emailTplService
{
func
newEmailTplService
()
*
emailTplService
{
return
&
emailTplService
{
return
&
emailTplService
{
Service
:
xcommon
.
NewService
(),
Service
:
xcommon
.
NewService
(),
commonService
:
newCommonService
(),
commonService
:
newCommonService
(),
}
}
}
}
func
(
x
*
emailTplService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
func
(
x
*
emailTplService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
emailTpl
:=
&
models
.
EmailTpl
{}
emailTpl
:=
&
models
.
EmailTpl
{}
_
=
copier
.
Copy
(
emailTpl
,
in
)
_
=
copier
.
Copy
(
emailTpl
,
in
)
emailTpl
.
ID
=
xsfUtils
.
EmailTplID
(
ctx
)
emailTpl
.
ID
=
xsfUtils
.
EmailTplID
(
ctx
)
...
@@ -49,22 +49,8 @@ func (x *emailTplService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.E
...
@@ -49,22 +49,8 @@ func (x *emailTplService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.E
return
dao
.
EmailTplDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
EmailTplDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
emailTplService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
error
{
if
len
(
ids
)
==
0
{
return
nil
}
emailTpls
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
ids
,
emailTpls
,
ecode
.
ErrEmailTplNotFound
);
err
!=
nil
{
return
err
}
return
dao
.
EmailTplDao
.
DeleteByIDs
(
ctx
,
ids
)
}
func
(
x
*
emailTplService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailTplUpdateByIDReq
,
opts
*
biz
.
EmailTplOpts
)
error
{
func
(
x
*
emailTplService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailTplUpdateByIDReq
,
opts
*
biz
.
EmailTplOpts
)
error
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
nil
return
nil
}
}
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
...
@@ -72,26 +58,9 @@ func (x *emailTplService) UpdateByID(ctx context.Context, in *types.EmailTplUpda
...
@@ -72,26 +58,9 @@ func (x *emailTplService) UpdateByID(ctx context.Context, in *types.EmailTplUpda
}
}
emailTplUpd
:=
&
models
.
EmailTpl
{}
emailTplUpd
:=
&
models
.
EmailTpl
{}
_
=
copier
.
Copy
(
emailTplUpd
,
in
)
_
=
copier
.
Copy
(
emailTplUpd
,
in
)
return
dao
.
EmailTplDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplUpd
)
return
dao
.
EmailTplDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplUpd
)
}
func
(
x
*
emailTplService
)
UpdateByIDs
(
ctx
context
.
Context
,
in
*
types
.
EmailTplUpdateByIDsReq
,
opts
*
biz
.
EmailTplOpts
)
error
{
if
len
(
in
.
IDs
)
==
0
{
return
nil
}
emailTpls
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
in
.
IDs
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
in
.
IDs
,
emailTpls
,
ecode
.
ErrEmailTplNotFound
);
err
!=
nil
{
return
err
}
emailTplUpd
:=
&
models
.
EmailTpl
{}
_
=
copier
.
Copy
(
emailTplUpd
,
in
)
return
dao
.
EmailTplDao
.
UpdateByIDs
(
ctx
,
in
.
IDs
,
emailTplUpd
)
}
}
func
(
x
*
emailTplService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
func
(
x
*
emailTplService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
...
@@ -101,7 +70,7 @@ func (x *emailTplService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.Ema
...
@@ -101,7 +70,7 @@ func (x *emailTplService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.Ema
return
nil
,
err
return
nil
,
err
}
}
if
emailTplBiz
!=
nil
{
if
emailTplBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplAlreadyExists
}
}
return
emailTplBiz
,
nil
return
emailTplBiz
,
nil
}
}
...
@@ -115,50 +84,63 @@ func (x *emailTplService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz.
...
@@ -115,50 +84,63 @@ func (x *emailTplService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz.
return
nil
,
err
return
nil
,
err
}
}
if
emailTplBiz
==
nil
{
if
emailTplBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplNotFound
}
}
return
emailTplBiz
,
nil
return
emailTplBiz
,
nil
}
}
func
(
x
*
emailTplService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
func
(
x
*
emailTplService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTpl
,
err
:=
dao
.
EmailTplDao
.
GetByID
(
ctx
,
id
)
emailTpl
,
err
:=
dao
.
EmailTplDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
emailTpl
==
nil
{
if
emailTpl
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
return
x
.
ToBiz
(
ctx
,
emailTpl
,
opts
)
}
func
(
x
*
emailTplService
)
GetByCode
(
ctx
context
.
Context
,
code
string
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
code
==
""
{
return
nil
,
nil
}
emailTpl
,
err
:=
dao
.
EmailTplDao
.
GetByCode
(
ctx
,
code
)
if
err
!=
nil
{
return
nil
,
err
}
if
emailTpl
==
nil
{
return
nil
,
nil
}
}
return
x
.
ToBiz
(
ctx
,
emailTpl
,
opts
)
return
x
.
ToBiz
(
ctx
,
emailTpl
,
opts
)
}
}
func
(
x
*
emailTplService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
([]
*
biz
.
EmailTpl
,
error
)
{
func
(
x
*
emailTplService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
([]
*
biz
.
EmailTpl
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetSliceByIDs
(
ctx
,
ids
)
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTpls
)
==
0
{
if
len
(
emailTpls
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
}
}
func
(
x
*
emailTplService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailTpl
,
error
)
{
func
(
x
*
emailTplService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailTpl
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
emailTplBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTplBizSlice
)
==
0
{
if
len
(
emailTplBizSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplBizIDMap
:=
biz
.
EmailTplTool
.
SliceToIDMapBiz
(
emailTplBizSlice
)
emailTplBizIDMap
:=
biz
.
EmailTplTool
.
SliceToIDMapBiz
(
emailTplBizSlice
)
return
emailTplBizIDMap
,
nil
return
emailTplBizIDMap
,
nil
...
@@ -169,8 +151,8 @@ func (x *emailTplService) Page(ctx context.Context, in *types.EmailTplPageReq, o
...
@@ -169,8 +151,8 @@ func (x *emailTplService) Page(ctx context.Context, in *types.EmailTplPageReq, o
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailTpls
)
==
0
{
if
len
(
emailTpls
)
==
0
{
return
nil
,
total
,
nil
return
nil
,
total
,
nil
}
}
emailTplBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
emailTplBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -204,30 +186,30 @@ func (x *emailTplService) ToSliceBiz(ctx context.Context, emailTpls []*models.Em
...
@@ -204,30 +186,30 @@ func (x *emailTplService) ToSliceBiz(ctx context.Context, emailTpls []*models.Em
return
emailTplBizSlice
,
nil
return
emailTplBizSlice
,
nil
}
}
func
(
x
*
emailTplService
)
Fill
(
ctx
context
.
Context
,
emailTplBiz
*
biz
.
EmailTpl
,
opts
*
biz
.
EmailTplOpts
)
error
{
func
(
x
*
emailTplService
)
Fill
(
ctx
context
.
Context
,
emailTplBiz
*
biz
.
EmailTpl
,
opts
*
biz
.
EmailTplOpts
)
error
{
if
emailTplBiz
==
nil
{
if
emailTplBiz
==
nil
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailTplService
)
SliceFill
(
ctx
context
.
Context
,
emailTplBizSlice
[]
*
biz
.
EmailTpl
,
opts
*
biz
.
EmailTplOpts
)
error
{
func
(
x
*
emailTplService
)
SliceFill
(
ctx
context
.
Context
,
emailTplBizSlice
[]
*
biz
.
EmailTpl
,
opts
*
biz
.
EmailTplOpts
)
error
{
if
len
(
emailTplBizSlice
)
==
0
{
if
len
(
emailTplBizSlice
)
==
0
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailTplService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplOpts
)
(
[]
*
biz
.
EmailTpl
,
error
)
{
func
(
x
*
emailTplService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplOpts
)
(
[]
*
biz
.
EmailTpl
,
error
)
{
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetAll
(
ctx
)
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTpls
)
==
0
{
if
len
(
emailTpls
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
...
...
pkg/email/service/email_tpl_receiver.go
浏览文件 @
a4765858
package
service
package
service
import
(
import
(
"context"
"context"
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/ecode"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"operator-qt/internal/modules/operator/types"
"operator-qt/internal/modules/operator/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/utils/csv_exporter"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
)
type
emailTplReceiverService
struct
{
type
emailTplReceiverService
struct
{
...
@@ -24,12 +24,12 @@ var EmailTplReceiverService = newEmailTplReceiverService()
...
@@ -24,12 +24,12 @@ var EmailTplReceiverService = newEmailTplReceiverService()
func
newEmailTplReceiverService
()
*
emailTplReceiverService
{
func
newEmailTplReceiverService
()
*
emailTplReceiverService
{
return
&
emailTplReceiverService
{
return
&
emailTplReceiverService
{
Service
:
xcommon
.
NewService
(),
Service
:
xcommon
.
NewService
(),
commonService
:
newCommonService
(),
commonService
:
newCommonService
(),
}
}
}
}
func
(
x
*
emailTplReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverCreateReq
)
(
id
xsf
.
ID
,
err
error
)
{
emailTplReceiver
:=
&
models
.
EmailTplReceiver
{}
emailTplReceiver
:=
&
models
.
EmailTplReceiver
{}
_
=
copier
.
Copy
(
emailTplReceiver
,
in
)
_
=
copier
.
Copy
(
emailTplReceiver
,
in
)
emailTplReceiver
.
ID
=
xsfUtils
.
EmailTplReceiverID
(
ctx
)
emailTplReceiver
.
ID
=
xsfUtils
.
EmailTplReceiverID
(
ctx
)
...
@@ -49,22 +49,8 @@ func (x *emailTplReceiverService) DeleteByID(ctx context.Context, id xsf.ID, opt
...
@@ -49,22 +49,8 @@ func (x *emailTplReceiverService) DeleteByID(ctx context.Context, id xsf.ID, opt
return
dao
.
EmailTplReceiverDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
EmailTplReceiverDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
emailTplReceiverService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
if
len
(
ids
)
==
0
{
return
nil
}
emailTplReceivers
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
ids
,
emailTplReceivers
,
ecode
.
ErrEmailTplReceiverNotFound
);
err
!=
nil
{
return
err
}
return
dao
.
EmailTplReceiverDao
.
DeleteByIDs
(
ctx
,
ids
)
}
func
(
x
*
emailTplReceiverService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverUpdateByIDReq
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
func
(
x
*
emailTplReceiverService
)
UpdateByID
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverUpdateByIDReq
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
nil
return
nil
}
}
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
if
_
,
err
:=
x
.
ErrNotFound
(
ctx
,
in
.
ID
,
opts
);
err
!=
nil
{
...
@@ -72,26 +58,9 @@ func (x *emailTplReceiverService) UpdateByID(ctx context.Context, in *types.Emai
...
@@ -72,26 +58,9 @@ func (x *emailTplReceiverService) UpdateByID(ctx context.Context, in *types.Emai
}
}
emailTplReceiverUpd
:=
&
models
.
EmailTplReceiver
{}
emailTplReceiverUpd
:=
&
models
.
EmailTplReceiver
{}
_
=
copier
.
Copy
(
emailTplReceiverUpd
,
in
)
_
=
copier
.
Copy
(
emailTplReceiverUpd
,
in
)
return
dao
.
EmailTplReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplReceiverUpd
)
return
dao
.
EmailTplReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplReceiverUpd
)
}
}
func
(
x
*
emailTplReceiverService
)
UpdateByIDs
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverUpdateByIDsReq
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
if
len
(
in
.
IDs
)
==
0
{
return
nil
}
emailTplReceivers
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
in
.
IDs
,
opts
)
if
err
!=
nil
{
return
err
}
if
err
=
sliceUtils
.
CompareSlice
(
in
.
IDs
,
emailTplReceivers
,
ecode
.
ErrEmailTplReceiverNotFound
);
err
!=
nil
{
return
err
}
emailTplReceiverUpd
:=
&
models
.
EmailTplReceiver
{}
_
=
copier
.
Copy
(
emailTplReceiverUpd
,
in
)
return
dao
.
EmailTplReceiverDao
.
UpdateByIDs
(
ctx
,
in
.
IDs
,
emailTplReceiverUpd
)
}
func
(
x
*
emailTplReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
...
@@ -101,7 +70,7 @@ func (x *emailTplReceiverService) ErrFound(ctx context.Context, id xsf.ID, opts
...
@@ -101,7 +70,7 @@ func (x *emailTplReceiverService) ErrFound(ctx context.Context, id xsf.ID, opts
return
nil
,
err
return
nil
,
err
}
}
if
emailTplReceiverBiz
!=
nil
{
if
emailTplReceiverBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplReceiverAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplReceiverAlreadyExists
}
}
return
emailTplReceiverBiz
,
nil
return
emailTplReceiverBiz
,
nil
}
}
...
@@ -115,50 +84,49 @@ func (x *emailTplReceiverService) ErrNotFound(ctx context.Context, id xsf.ID, op
...
@@ -115,50 +84,49 @@ func (x *emailTplReceiverService) ErrNotFound(ctx context.Context, id xsf.ID, op
return
nil
,
err
return
nil
,
err
}
}
if
emailTplReceiverBiz
==
nil
{
if
emailTplReceiverBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplReceiverNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplReceiverNotFound
}
}
return
emailTplReceiverBiz
,
nil
return
emailTplReceiverBiz
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceiver
,
err
:=
dao
.
EmailTplReceiverDao
.
GetByID
(
ctx
,
id
)
emailTplReceiver
,
err
:=
dao
.
EmailTplReceiverDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
emailTplReceiver
==
nil
{
if
emailTplReceiver
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToBiz
(
ctx
,
emailTplReceiver
,
opts
)
return
x
.
ToBiz
(
ctx
,
emailTplReceiver
,
opts
)
}
}
func
(
x
*
emailTplReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByIDs
(
ctx
,
ids
)
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
}
}
func
(
x
*
emailTplReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
map
[
xsf
.
ID
]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTplReceiverBizSlice
)
==
0
{
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceiverBizIDMap
:=
biz
.
EmailTplReceiverTool
.
SliceToIDMapBiz
(
emailTplReceiverBizSlice
)
emailTplReceiverBizIDMap
:=
biz
.
EmailTplReceiverTool
.
SliceToIDMapBiz
(
emailTplReceiverBizSlice
)
return
emailTplReceiverBizIDMap
,
nil
return
emailTplReceiverBizIDMap
,
nil
...
@@ -169,8 +137,8 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
...
@@ -169,8 +137,8 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
total
,
nil
return
nil
,
total
,
nil
}
}
emailTplReceiverBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
emailTplReceiverBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -178,50 +146,50 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
...
@@ -178,50 +146,50 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
}
}
return
emailTplReceiverBizSlice
,
total
,
nil
return
emailTplReceiverBizSlice
,
total
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
tplID
==
0
{
if
tplID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByTplID
(
ctx
,
models
.
EmailTplReceiverTool
.
GetOrder
(),
tplID
)
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByTplID
(
ctx
,
models
.
EmailTplReceiverTool
.
GetOrder
(),
tplID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
}
}
func
(
x
*
emailTplReceiverService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByTplIDs
(
ctx
,
models
.
EmailTplReceiverTool
.
GetOrder
(),
tplIDs
)
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByTplIDs
(
ctx
,
models
.
EmailTplReceiverTool
.
GetOrder
(),
tplIDs
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
}
}
func
(
x
*
emailTplReceiverService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailTplReceiver
,
int
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailTplReceiver
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
if
len
(
emailTplReceiverBizSlice
)
==
0
{
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailTplReceiver
)
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailTplReceiver
)
for
_
,
r
:=
range
emailTplReceiverBizSlice
{
for
_
,
r
:=
range
emailTplReceiverBizSlice
{
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
}
}
return
ret
,
len
(
emailTplReceiverBizSlice
),
nil
return
ret
,
len
(
emailTplReceiverBizSlice
),
nil
}
}
func
(
x
*
emailTplReceiverService
)
ToBiz
(
ctx
context
.
Context
,
emailTplReceiver
*
models
.
EmailTplReceiver
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
ToBiz
(
ctx
context
.
Context
,
emailTplReceiver
*
models
.
EmailTplReceiver
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
...
@@ -249,30 +217,30 @@ func (x *emailTplReceiverService) ToSliceBiz(ctx context.Context, emailTplReceiv
...
@@ -249,30 +217,30 @@ func (x *emailTplReceiverService) ToSliceBiz(ctx context.Context, emailTplReceiv
return
emailTplReceiverBizSlice
,
nil
return
emailTplReceiverBizSlice
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
Fill
(
ctx
context
.
Context
,
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
func
(
x
*
emailTplReceiverService
)
Fill
(
ctx
context
.
Context
,
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
if
emailTplReceiverBiz
==
nil
{
if
emailTplReceiverBiz
==
nil
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailTplReceiverService
)
SliceFill
(
ctx
context
.
Context
,
emailTplReceiverBizSlice
[]
*
biz
.
EmailTplReceiver
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
func
(
x
*
emailTplReceiverService
)
SliceFill
(
ctx
context
.
Context
,
emailTplReceiverBizSlice
[]
*
biz
.
EmailTplReceiver
,
opts
*
biz
.
EmailTplReceiverOpts
)
error
{
if
len
(
emailTplReceiverBizSlice
)
==
0
{
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
return
nil
}
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
}
return
nil
return
nil
}
}
func
(
x
*
emailTplReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
[]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
[]
*
biz
.
EmailTplReceiver
,
error
)
{
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetAll
(
ctx
)
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
...
...
pkg/email/types/email.go
浏览文件 @
a4765858
package
types
package
types
import
(
import
(
"operator-qt/internal/modules/operator/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
// EmailCreateReq request params 邮件
// EmailCreateReq request params 邮件
type
EmailCreateReq
struct
{
type
EmailCreateReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
}
}
func
(
x
*
EmailCreateReq
)
Valid
()
error
{
func
(
x
*
EmailCreateReq
)
Valid
()
error
{
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailGetByTplIDReq request params
// EmailGetByTplIDReq request params
type
EmailGetByTplIDReq
struct
{
type
EmailGetByTplIDReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
}
}
func
(
x
*
EmailGetByTplIDReq
)
Valid
()
error
{
func
(
x
*
EmailGetByTplIDReq
)
Valid
()
error
{
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailUpdateByIDReq request params
// EmailUpdateByIDReq request params
type
EmailUpdateByIDReq
struct
{
type
EmailUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
}
}
func
(
x
*
EmailUpdateByIDReq
)
Valid
()
error
{
func
(
x
*
EmailUpdateByIDReq
)
Valid
()
error
{
if
x
.
ID
<=
0
{
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailUpdateByIDsReq request params
// EmailUpdateByIDsReq request params
type
EmailUpdateByIDsReq
struct
{
type
EmailUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
}
}
func
(
x
*
EmailUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailUpdateByIDsReq
)
Valid
()
error
{
if
len
(
x
.
IDs
)
==
0
{
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailPageReq request params
// EmailPageReq request params
type
EmailPageReq
struct
{
type
EmailPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailPageReq
)
Valid
()
error
{
func
(
x
*
EmailPageReq
)
Valid
()
error
{
...
@@ -89,19 +92,19 @@ func (x *EmailPageReq) Valid() error {
...
@@ -89,19 +92,19 @@ func (x *EmailPageReq) Valid() error {
}
}
func
(
EmailPageReq
)
TableName
()
string
{
func
(
EmailPageReq
)
TableName
()
string
{
return
models
.
TBEmail
return
models
.
TBEmail
}
}
// EmailExportReq request params
// EmailExportReq request params
type
EmailExportReq
struct
{
type
EmailExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailExportReq
)
Valid
()
error
{
func
(
x
*
EmailExportReq
)
Valid
()
error
{
...
@@ -109,12 +112,11 @@ func (x *EmailExportReq) Valid() error {
...
@@ -109,12 +112,11 @@ func (x *EmailExportReq) Valid() error {
}
}
func
(
EmailExportReq
)
TableName
()
string
{
func
(
EmailExportReq
)
TableName
()
string
{
return
models
.
TBEmail
return
models
.
TBEmail
}
}
type
EmailObjDetail
struct
{
type
EmailObjDetail
struct
{
biz
.
Email
biz
.
Email
}
}
var
EmailObjDetailTool
=
EmailObjDetail
{}
var
EmailObjDetailTool
=
EmailObjDetail
{}
...
@@ -124,7 +126,7 @@ func (x EmailObjDetail) NewFromBiz(emailBiz *biz.Email) *EmailObjDetail {
...
@@ -124,7 +126,7 @@ func (x EmailObjDetail) NewFromBiz(emailBiz *biz.Email) *EmailObjDetail {
return
nil
return
nil
}
}
return
&
EmailObjDetail
{
return
&
EmailObjDetail
{
Email
:
*
emailBiz
,
Email
:
*
emailBiz
,
}
}
}
}
...
...
pkg/email/types/email_receiver.go
浏览文件 @
a4765858
package
types
package
types
import
(
import
(
"operator-qt/internal/modules/operator/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
// EmailReceiverCreateReq request params 邮件收件人
// EmailReceiverCreateReq request params 邮件收件人
type
EmailReceiverCreateReq
struct
{
type
EmailReceiverCreateReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailReceiverCreateReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverCreateReq
)
Valid
()
error
{
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailReceiverGetByEmailIDReq request params
// EmailReceiverGetByEmailIDReq request params
type
EmailReceiverGetByEmailIDReq
struct
{
type
EmailReceiverGetByEmailIDReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
}
}
func
(
x
*
EmailReceiverGetByEmailIDReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverGetByEmailIDReq
)
Valid
()
error
{
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailReceiverUpdateByIDReq request params
// EmailReceiverUpdateByIDReq request params
type
EmailReceiverUpdateByIDReq
struct
{
type
EmailReceiverUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailReceiverUpdateByIDReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverUpdateByIDReq
)
Valid
()
error
{
if
x
.
ID
<=
0
{
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailReceiverUpdateByIDsReq request params
// EmailReceiverUpdateByIDsReq request params
type
EmailReceiverUpdateByIDsReq
struct
{
type
EmailReceiverUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailReceiverUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverUpdateByIDsReq
)
Valid
()
error
{
if
len
(
x
.
IDs
)
==
0
{
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailReceiverPageReq request params
// EmailReceiverPageReq request params
type
EmailReceiverPageReq
struct
{
type
EmailReceiverPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailReceiverPageReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverPageReq
)
Valid
()
error
{
...
@@ -85,18 +88,18 @@ func (x *EmailReceiverPageReq) Valid() error {
...
@@ -85,18 +88,18 @@ func (x *EmailReceiverPageReq) Valid() error {
}
}
func
(
EmailReceiverPageReq
)
TableName
()
string
{
func
(
EmailReceiverPageReq
)
TableName
()
string
{
return
models
.
TBEmailReceiver
return
models
.
TBEmailReceiver
}
}
// EmailReceiverExportReq request params
// EmailReceiverExportReq request params
type
EmailReceiverExportReq
struct
{
type
EmailReceiverExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailReceiverExportReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverExportReq
)
Valid
()
error
{
...
@@ -104,12 +107,11 @@ func (x *EmailReceiverExportReq) Valid() error {
...
@@ -104,12 +107,11 @@ func (x *EmailReceiverExportReq) Valid() error {
}
}
func
(
EmailReceiverExportReq
)
TableName
()
string
{
func
(
EmailReceiverExportReq
)
TableName
()
string
{
return
models
.
TBEmailReceiver
return
models
.
TBEmailReceiver
}
}
type
EmailReceiverObjDetail
struct
{
type
EmailReceiverObjDetail
struct
{
biz
.
EmailReceiver
biz
.
EmailReceiver
}
}
var
EmailReceiverObjDetailTool
=
EmailReceiverObjDetail
{}
var
EmailReceiverObjDetailTool
=
EmailReceiverObjDetail
{}
...
@@ -119,7 +121,7 @@ func (x EmailReceiverObjDetail) NewFromBiz(emailReceiverBiz *biz.EmailReceiver)
...
@@ -119,7 +121,7 @@ func (x EmailReceiverObjDetail) NewFromBiz(emailReceiverBiz *biz.EmailReceiver)
return
nil
return
nil
}
}
return
&
EmailReceiverObjDetail
{
return
&
EmailReceiverObjDetail
{
EmailReceiver
:
*
emailReceiverBiz
,
EmailReceiver
:
*
emailReceiverBiz
,
}
}
}
}
...
...
pkg/email/types/email_send.go
浏览文件 @
a4765858
package
types
package
types
import
(
import
(
"operator-qt/internal/modules/operator/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"
operator-qt/internal/modules/operator/enums
"
"
gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime
"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
// EmailSendCreateReq request params 邮件发送
// EmailSendCreateReq request params 邮件发送
type
EmailSendCreateReq
struct
{
type
EmailSendCreateReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendCreateReq
)
Valid
()
error
{
func
(
x
*
EmailSendCreateReq
)
Valid
()
error
{
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendGetByEmailIDReq request params
// EmailSendGetByEmailIDReq request params
type
EmailSendGetByEmailIDReq
struct
{
type
EmailSendGetByEmailIDReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
}
}
func
(
x
*
EmailSendGetByEmailIDReq
)
Valid
()
error
{
func
(
x
*
EmailSendGetByEmailIDReq
)
Valid
()
error
{
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendGetByStateReq request params
// EmailSendGetByStateReq request params
type
EmailSendGetByStateReq
struct
{
type
EmailSendGetByStateReq
struct
{
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendGetByStateReq
)
Valid
()
error
{
func
(
x
*
EmailSendGetByStateReq
)
Valid
()
error
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendUpdateByIDReq request params
// EmailSendUpdateByIDReq request params
type
EmailSendUpdateByIDReq
struct
{
type
EmailSendUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendUpdateByIDReq
)
Valid
()
error
{
func
(
x
*
EmailSendUpdateByIDReq
)
Valid
()
error
{
if
x
.
ID
<=
0
{
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendUpdateByIDsReq request params
// EmailSendUpdateByIDsReq request params
type
EmailSendUpdateByIDsReq
struct
{
type
EmailSendUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailSendUpdateByIDsReq
)
Valid
()
error
{
if
len
(
x
.
IDs
)
==
0
{
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendPageReq request params
// EmailSendPageReq request params
type
EmailSendPageReq
struct
{
type
EmailSendPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailSendPageReq
)
Valid
()
error
{
func
(
x
*
EmailSendPageReq
)
Valid
()
error
{
...
@@ -107,18 +111,18 @@ func (x *EmailSendPageReq) Valid() error {
...
@@ -107,18 +111,18 @@ func (x *EmailSendPageReq) Valid() error {
}
}
func
(
EmailSendPageReq
)
TableName
()
string
{
func
(
EmailSendPageReq
)
TableName
()
string
{
return
models
.
TBEmailSend
return
models
.
TBEmailSend
}
}
// EmailSendExportReq request params
// EmailSendExportReq request params
type
EmailSendExportReq
struct
{
type
EmailSendExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailSendExportReq
)
Valid
()
error
{
func
(
x
*
EmailSendExportReq
)
Valid
()
error
{
...
@@ -126,7 +130,7 @@ func (x *EmailSendExportReq) Valid() error {
...
@@ -126,7 +130,7 @@ func (x *EmailSendExportReq) Valid() error {
}
}
func
(
EmailSendExportReq
)
TableName
()
string
{
func
(
EmailSendExportReq
)
TableName
()
string
{
return
models
.
TBEmailSend
return
models
.
TBEmailSend
}
}
type
EmailSendObjDetail
struct
{
type
EmailSendObjDetail
struct
{
...
@@ -142,8 +146,8 @@ func (x EmailSendObjDetail) NewFromBiz(emailSendBiz *biz.EmailSend) *EmailSendOb
...
@@ -142,8 +146,8 @@ func (x EmailSendObjDetail) NewFromBiz(emailSendBiz *biz.EmailSend) *EmailSendOb
return
nil
return
nil
}
}
return
&
EmailSendObjDetail
{
return
&
EmailSendObjDetail
{
EmailSend
:
*
emailSendBiz
,
EmailSend
:
*
emailSendBiz
,
StateZh
:
emailSendBiz
.
State
.
Desc
(),
StateZh
:
emailSendBiz
.
State
.
Desc
(),
}
}
}
}
...
...
pkg/email/types/email_send_log.go
浏览文件 @
a4765858
package
types
package
types
import
(
import
(
"operator-qt/internal/modules/operator/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"
operator-qt/internal/modules/operator/enums
"
"
gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime
"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
// EmailSendLogCreateReq request params 邮件发送记录
// EmailSendLogCreateReq request params 邮件发送记录
type
EmailSendLogCreateReq
struct
{
type
EmailSendLogCreateReq
struct
{
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendLogCreateReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogCreateReq
)
Valid
()
error
{
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendLogGetByEmailSendIDReq request params
// EmailSendLogGetByEmailSendIDReq request params
type
EmailSendLogGetByEmailSendIDReq
struct
{
type
EmailSendLogGetByEmailSendIDReq
struct
{
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
//邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
//邮件发送id
}
}
func
(
x
*
EmailSendLogGetByEmailSendIDReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogGetByEmailSendIDReq
)
Valid
()
error
{
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendLogGetByStateReq request params
// EmailSendLogGetByStateReq request params
type
EmailSendLogGetByStateReq
struct
{
type
EmailSendLogGetByStateReq
struct
{
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendLogGetByStateReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogGetByStateReq
)
Valid
()
error
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendLogUpdateByIDReq request params
// EmailSendLogUpdateByIDReq request params
type
EmailSendLogUpdateByIDReq
struct
{
type
EmailSendLogUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendLogUpdateByIDReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogUpdateByIDReq
)
Valid
()
error
{
if
x
.
ID
<=
0
{
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
}
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendLogUpdateByIDsReq request params
// EmailSendLogUpdateByIDsReq request params
type
EmailSendLogUpdateByIDsReq
struct
{
type
EmailSendLogUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
func
(
x
*
EmailSendLogUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogUpdateByIDsReq
)
Valid
()
error
{
if
len
(
x
.
IDs
)
==
0
{
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
}
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[state]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailSendLogPageReq request params
// EmailSendLogPageReq request params
type
EmailSendLogPageReq
struct
{
type
EmailSendLogPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailSendLogPageReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogPageReq
)
Valid
()
error
{
...
@@ -107,18 +111,18 @@ func (x *EmailSendLogPageReq) Valid() error {
...
@@ -107,18 +111,18 @@ func (x *EmailSendLogPageReq) Valid() error {
}
}
func
(
EmailSendLogPageReq
)
TableName
()
string
{
func
(
EmailSendLogPageReq
)
TableName
()
string
{
return
models
.
TBEmailSendLog
return
models
.
TBEmailSendLog
}
}
// EmailSendLogExportReq request params
// EmailSendLogExportReq request params
type
EmailSendLogExportReq
struct
{
type
EmailSendLogExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailSendLogExportReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogExportReq
)
Valid
()
error
{
...
@@ -126,7 +130,7 @@ func (x *EmailSendLogExportReq) Valid() error {
...
@@ -126,7 +130,7 @@ func (x *EmailSendLogExportReq) Valid() error {
}
}
func
(
EmailSendLogExportReq
)
TableName
()
string
{
func
(
EmailSendLogExportReq
)
TableName
()
string
{
return
models
.
TBEmailSendLog
return
models
.
TBEmailSendLog
}
}
type
EmailSendLogObjDetail
struct
{
type
EmailSendLogObjDetail
struct
{
...
@@ -142,8 +146,8 @@ func (x EmailSendLogObjDetail) NewFromBiz(emailSendLogBiz *biz.EmailSendLog) *Em
...
@@ -142,8 +146,8 @@ func (x EmailSendLogObjDetail) NewFromBiz(emailSendLogBiz *biz.EmailSendLog) *Em
return
nil
return
nil
}
}
return
&
EmailSendLogObjDetail
{
return
&
EmailSendLogObjDetail
{
EmailSendLog
:
*
emailSendLogBiz
,
EmailSendLog
:
*
emailSendLogBiz
,
StateZh
:
emailSendLogBiz
.
State
.
Desc
(),
StateZh
:
emailSendLogBiz
.
State
.
Desc
(),
}
}
}
}
...
...
pkg/email/types/email_tpl.go
浏览文件 @
a4765858
package
types
package
types
import
(
import
(
"operator-qt/internal/modules/operator/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
// EmailTplCreateReq request params 邮件模板
// EmailTplCreateReq request params 邮件模板
type
EmailTplCreateReq
struct
{
type
EmailTplCreateReq
struct
{
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
}
}
func
(
x
*
EmailTplCreateReq
)
Valid
()
error
{
func
(
x
*
EmailTplCreateReq
)
Valid
()
error
{
...
@@ -22,42 +24,42 @@ func (x *EmailTplCreateReq) Valid() error {
...
@@ -22,42 +24,42 @@ func (x *EmailTplCreateReq) Valid() error {
// EmailTplUpdateByIDReq request params
// EmailTplUpdateByIDReq request params
type
EmailTplUpdateByIDReq
struct
{
type
EmailTplUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
}
}
func
(
x
*
EmailTplUpdateByIDReq
)
Valid
()
error
{
func
(
x
*
EmailTplUpdateByIDReq
)
Valid
()
error
{
if
x
.
ID
<=
0
{
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailTplUpdateByIDsReq request params
// EmailTplUpdateByIDsReq request params
type
EmailTplUpdateByIDsReq
struct
{
type
EmailTplUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
}
}
func
(
x
*
EmailTplUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailTplUpdateByIDsReq
)
Valid
()
error
{
if
len
(
x
.
IDs
)
==
0
{
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
}
return
nil
return
nil
}
}
// EmailTplPageReq request params
// EmailTplPageReq request params
type
EmailTplPageReq
struct
{
type
EmailTplPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailTplPageReq
)
Valid
()
error
{
func
(
x
*
EmailTplPageReq
)
Valid
()
error
{
...
@@ -65,18 +67,18 @@ func (x *EmailTplPageReq) Valid() error {
...
@@ -65,18 +67,18 @@ func (x *EmailTplPageReq) Valid() error {
}
}
func
(
EmailTplPageReq
)
TableName
()
string
{
func
(
EmailTplPageReq
)
TableName
()
string
{
return
models
.
TBEmailTpl
return
models
.
TBEmailTpl
}
}
// EmailTplExportReq request params
// EmailTplExportReq request params
type
EmailTplExportReq
struct
{
type
EmailTplExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailTplExportReq
)
Valid
()
error
{
func
(
x
*
EmailTplExportReq
)
Valid
()
error
{
...
@@ -84,12 +86,11 @@ func (x *EmailTplExportReq) Valid() error {
...
@@ -84,12 +86,11 @@ func (x *EmailTplExportReq) Valid() error {
}
}
func
(
EmailTplExportReq
)
TableName
()
string
{
func
(
EmailTplExportReq
)
TableName
()
string
{
return
models
.
TBEmailTpl
return
models
.
TBEmailTpl
}
}
type
EmailTplObjDetail
struct
{
type
EmailTplObjDetail
struct
{
biz
.
EmailTpl
biz
.
EmailTpl
}
}
var
EmailTplObjDetailTool
=
EmailTplObjDetail
{}
var
EmailTplObjDetailTool
=
EmailTplObjDetail
{}
...
@@ -99,7 +100,7 @@ func (x EmailTplObjDetail) NewFromBiz(emailTplBiz *biz.EmailTpl) *EmailTplObjDet
...
@@ -99,7 +100,7 @@ func (x EmailTplObjDetail) NewFromBiz(emailTplBiz *biz.EmailTpl) *EmailTplObjDet
return
nil
return
nil
}
}
return
&
EmailTplObjDetail
{
return
&
EmailTplObjDetail
{
EmailTpl
:
*
emailTplBiz
,
EmailTpl
:
*
emailTplBiz
,
}
}
}
}
...
...
pkg/email/types/email_tpl_receiver.go
浏览文件 @
a4765858
package
types
package
types
import
(
import
(
"operator-qt/internal/modules/operator/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
// EmailTplReceiverCreateReq request params 邮件模板收件人
// EmailTplReceiverCreateReq request params 邮件模板收件人
type
EmailTplReceiverCreateReq
struct
{
type
EmailTplReceiverCreateReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailTplReceiverCreateReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverCreateReq
)
Valid
()
error
{
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailTplReceiverGetByTplIDReq request params
// EmailTplReceiverGetByTplIDReq request params
type
EmailTplReceiverGetByTplIDReq
struct
{
type
EmailTplReceiverGetByTplIDReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
}
}
func
(
x
*
EmailTplReceiverGetByTplIDReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverGetByTplIDReq
)
Valid
()
error
{
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailTplReceiverUpdateByIDReq request params
// EmailTplReceiverUpdateByIDReq request params
type
EmailTplReceiverUpdateByIDReq
struct
{
type
EmailTplReceiverUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailTplReceiverUpdateByIDReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverUpdateByIDReq
)
Valid
()
error
{
if
x
.
ID
<=
0
{
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailTplReceiverUpdateByIDsReq request params
// EmailTplReceiverUpdateByIDsReq request params
type
EmailTplReceiverUpdateByIDsReq
struct
{
type
EmailTplReceiverUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailTplReceiverUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverUpdateByIDsReq
)
Valid
()
error
{
if
len
(
x
.
IDs
)
==
0
{
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
}
return
nil
return
nil
}
}
// EmailTplReceiverPageReq request params
// EmailTplReceiverPageReq request params
type
EmailTplReceiverPageReq
struct
{
type
EmailTplReceiverPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailTplReceiverPageReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverPageReq
)
Valid
()
error
{
...
@@ -85,18 +88,18 @@ func (x *EmailTplReceiverPageReq) Valid() error {
...
@@ -85,18 +88,18 @@ func (x *EmailTplReceiverPageReq) Valid() error {
}
}
func
(
EmailTplReceiverPageReq
)
TableName
()
string
{
func
(
EmailTplReceiverPageReq
)
TableName
()
string
{
return
models
.
TBEmailTplReceiver
return
models
.
TBEmailTplReceiver
}
}
// EmailTplReceiverExportReq request params
// EmailTplReceiverExportReq request params
type
EmailTplReceiverExportReq
struct
{
type
EmailTplReceiverExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtBegin
xtime
.
DateTime
`json:"updatedAtBegin" form:"updatedAtBegin" query:"type:gte;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间起始 (>=)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
UpdatedAtEnd
xtime
.
DateTime
`json:"updatedAtEnd" form:"updatedAtEnd" query:"type:lt;column:updated_at" example:"2024-03-27 17:11:00"`
//更新时间截止 (<)
}
}
func
(
x
*
EmailTplReceiverExportReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverExportReq
)
Valid
()
error
{
...
@@ -104,12 +107,11 @@ func (x *EmailTplReceiverExportReq) Valid() error {
...
@@ -104,12 +107,11 @@ func (x *EmailTplReceiverExportReq) Valid() error {
}
}
func
(
EmailTplReceiverExportReq
)
TableName
()
string
{
func
(
EmailTplReceiverExportReq
)
TableName
()
string
{
return
models
.
TBEmailTplReceiver
return
models
.
TBEmailTplReceiver
}
}
type
EmailTplReceiverObjDetail
struct
{
type
EmailTplReceiverObjDetail
struct
{
biz
.
EmailTplReceiver
biz
.
EmailTplReceiver
}
}
var
EmailTplReceiverObjDetailTool
=
EmailTplReceiverObjDetail
{}
var
EmailTplReceiverObjDetailTool
=
EmailTplReceiverObjDetail
{}
...
@@ -119,7 +121,7 @@ func (x EmailTplReceiverObjDetail) NewFromBiz(emailTplReceiverBiz *biz.EmailTplR
...
@@ -119,7 +121,7 @@ func (x EmailTplReceiverObjDetail) NewFromBiz(emailTplReceiverBiz *biz.EmailTplR
return
nil
return
nil
}
}
return
&
EmailTplReceiverObjDetail
{
return
&
EmailTplReceiverObjDetail
{
EmailTplReceiver
:
*
emailTplReceiverBiz
,
EmailTplReceiver
:
*
emailTplReceiverBiz
,
}
}
}
}
...
...
pkg/email/xsf_utils/xsf_utils.go
浏览文件 @
a4765858
...
@@ -3,129 +3,130 @@ package xsfUtils
...
@@ -3,129 +3,130 @@ package xsfUtils
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
)
)
const
(
const
(
bizTag_agent
=
"qt.operator.agent.id"
bizTag_agent
=
"qt.operator.agent.id"
bizTag_agent_operator
=
"qt.operator.agent.operator.id"
bizTag_agent_operator
=
"qt.operator.agent.operator.id"
bizTag_api_notify
=
"qt.operator.api.notify.id"
bizTag_api_notify
=
"qt.operator.api.notify.id"
bizTag_app_module
=
"qt.operator.app.module.id"
bizTag_app_module
=
"qt.operator.app.module.id"
bizTag_auth_role
=
"qt.operator.auth.role.id"
bizTag_auth_role
=
"qt.operator.auth.role.id"
bizTag_cron_job
=
"qt.operator.cron.job.id"
bizTag_cron_job
=
"qt.operator.cron.job.id"
bizTag_cron_job_log
=
"qt.operator.cron.job.log.id"
bizTag_cron_job_log
=
"qt.operator.cron.job.log.id"
bizTag_cron_job_record
=
"qt.operator.cron.job.record.id"
bizTag_cron_job_record
=
"qt.operator.cron.job.record.id"
bizTag_email
=
"qt.operator.email.id"
bizTag_email
=
"qt.operator.email.id"
bizTag_email_receiver
=
"qt.operator.email.receiver.id"
bizTag_email_receiver
=
"qt.operator.email.receiver.id"
bizTag_email_send
=
"qt.operator.email.send.id"
bizTag_email_send
=
"qt.operator.email.send.id"
bizTag_email_send_log
=
"qt.operator.email.send.log.id"
bizTag_email_send_log
=
"qt.operator.email.send.log.id"
bizTag_email_tpl
=
"qt.operator.email.tpl.id"
bizTag_email_tpl
=
"qt.operator.email.tpl.id"
bizTag_email_tpl_receiver
=
"qt.operator.email.tpl.receiver.id"
bizTag_email_tpl_receiver
=
"qt.operator.email.tpl.receiver.id"
bizTag_intake
=
"qt.operator.intake.id"
bizTag_intake
=
"qt.operator.intake.id"
bizTag_operator
=
"qt.operator.operator.id"
bizTag_operator
=
"qt.operator.operator.id"
bizTag_platform_config
=
"qt.operator.platform.config.id"
bizTag_platform_config
=
"qt.operator.platform.config.id"
bizTag_share
=
"qt.operator.share.id"
bizTag_share
=
"qt.operator.share.id"
bizTag_site
=
"qt.operator.site.id"
bizTag_site
=
"qt.operator.site.id"
bizTag_site_share
=
"qt.operator.site.share.id"
bizTag_site_share
=
"qt.operator.site.share.id"
bizTag_site_user
=
"qt.operator.site.user.id"
bizTag_site_user
=
"qt.operator.site.user.id"
bizTag_sms_code
=
"qt.operator.sms.code.id"
bizTag_sms_code
=
"qt.operator.sms.code.id"
bizTag_user
=
"qt.operator.user.id"
bizTag_user
=
"qt.operator.user.id"
bizTag_user_token
=
"qt.operator.user.token.id"
bizTag_user_token
=
"qt.operator.user.token.id"
bizTag_web_log
=
"qt.operator.web.log.id"
bizTag_web_log
=
"qt.operator.web.log.id"
bizTag_withdraw
=
"qt.operator.withdraw.id"
bizTag_withdraw
=
"qt.operator.withdraw.id"
)
)
func
agentID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
AgentID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_agent
)
return
generateID
(
ctx
,
bizTag_agent
)
}
}
func
agent_o
peratorID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
AgentO
peratorID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_agent_operator
)
return
generateID
(
ctx
,
bizTag_agent_operator
)
}
}
func
api_n
otifyID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
ApiN
otifyID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_api_notify
)
return
generateID
(
ctx
,
bizTag_api_notify
)
}
}
func
app_m
oduleID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
AppM
oduleID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_app_module
)
return
generateID
(
ctx
,
bizTag_app_module
)
}
}
func
auth_r
oleID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
AuthR
oleID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_auth_role
)
return
generateID
(
ctx
,
bizTag_auth_role
)
}
}
func
cron_j
obID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
CronJ
obID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_cron_job
)
return
generateID
(
ctx
,
bizTag_cron_job
)
}
}
func
cron_job_l
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
CronJobL
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_cron_job_log
)
return
generateID
(
ctx
,
bizTag_cron_job_log
)
}
}
func
cron_job_r
ecordID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
CronJobR
ecordID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_cron_job_record
)
return
generateID
(
ctx
,
bizTag_cron_job_record
)
}
}
func
e
mailID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
E
mailID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email
)
return
generateID
(
ctx
,
bizTag_email
)
}
}
func
email_r
eceiverID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailR
eceiverID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_receiver
)
return
generateID
(
ctx
,
bizTag_email_receiver
)
}
}
func
email_s
endID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailS
endID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_send
)
return
generateID
(
ctx
,
bizTag_email_send
)
}
}
func
email_send_l
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailSendL
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_send_log
)
return
generateID
(
ctx
,
bizTag_email_send_log
)
}
}
func
email_t
plID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailT
plID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_tpl
)
return
generateID
(
ctx
,
bizTag_email_tpl
)
}
}
func
email_tpl_r
eceiverID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailTplR
eceiverID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_tpl_receiver
)
return
generateID
(
ctx
,
bizTag_email_tpl_receiver
)
}
}
func
i
ntakeID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
I
ntakeID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_intake
)
return
generateID
(
ctx
,
bizTag_intake
)
}
}
func
o
peratorID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
O
peratorID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_operator
)
return
generateID
(
ctx
,
bizTag_operator
)
}
}
func
platform_c
onfigID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
PlatformC
onfigID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_platform_config
)
return
generateID
(
ctx
,
bizTag_platform_config
)
}
}
func
s
hareID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
S
hareID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_share
)
return
generateID
(
ctx
,
bizTag_share
)
}
}
func
s
iteID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
S
iteID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_site
)
return
generateID
(
ctx
,
bizTag_site
)
}
}
func
site_s
hareID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
SiteS
hareID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_site_share
)
return
generateID
(
ctx
,
bizTag_site_share
)
}
}
func
site_u
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
SiteU
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_site_user
)
return
generateID
(
ctx
,
bizTag_site_user
)
}
}
func
sms_c
odeID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
SmsC
odeID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_sms_code
)
return
generateID
(
ctx
,
bizTag_sms_code
)
}
}
func
u
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
U
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_user
)
return
generateID
(
ctx
,
bizTag_user
)
}
}
func
user_t
okenID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
UserT
okenID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_user_token
)
return
generateID
(
ctx
,
bizTag_user_token
)
}
}
func
web_l
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
WebL
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_web_log
)
return
generateID
(
ctx
,
bizTag_web_log
)
}
}
func
w
ithdrawID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
W
ithdrawID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_withdraw
)
return
generateID
(
ctx
,
bizTag_withdraw
)
}
}
func
generateID
(
ctx
context
.
Context
,
bizTag
string
)
xsf
.
ID
{
func
generateID
(
ctx
context
.
Context
,
bizTag
string
)
xsf
.
ID
{
xsf
,
err
:=
dxsf
.
Generate
Api
ID
(
ctx
,
bizTag
)
xsf
,
err
:=
dxsf
.
GenerateID
(
ctx
,
bizTag
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
fmt
.
Sprintf
(
"Generate
Api
ID[%s] failed"
,
bizTag
),
logger
.
Err
(
err
),
ctxUtils
.
CtxTraceIDField
(
ctx
))
logger
.
Error
(
fmt
.
Sprintf
(
"GenerateID[%s] failed"
,
bizTag
),
logger
.
Err
(
err
),
ctxUtils
.
CtxTraceIDField
(
ctx
))
return
xsf
return
xsf
}
}
return
xsf
return
xsf
}
}
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.agent.id',100000,2000,'qt.operator.agent.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.agent.id',100000,2000,'qt.operator.agent.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.agent.operator.id',100000,2000,'qt.operator.agent.operator.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.agent.operator.id',100000,2000,'qt.operator.agent.operator.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.api.notify.id',100000,2000,'qt.operator.api.notify.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.api.notify.id',100000,2000,'qt.operator.api.notify.id');
...
...
pkg/eventbus/init.go
浏览文件 @
a4765858
...
@@ -5,6 +5,7 @@ var Eb = New()
...
@@ -5,6 +5,7 @@ var Eb = New()
const
(
const
(
TopicParseConf
string
=
"event:application:conf:init"
//
TopicParseConf
string
=
"event:application:conf:init"
//
TopicParseConfFinish
string
=
"event:application:conf:init:finish"
//
TopicParseConfFinish
string
=
"event:application:conf:init:finish"
//
TopicConfChange
string
=
"event:application:conf:change"
//
TopicLoggerInit
string
=
"event:application:logger:init"
//
TopicLoggerInit
string
=
"event:application:logger:init"
//
TopicLoggerInitFinish
string
=
"event:application:logger:init:finish"
//
TopicLoggerInitFinish
string
=
"event:application:logger:init:finish"
//
TopicDBInit
string
=
"event:application:database:init"
//
TopicDBInit
string
=
"event:application:database:init"
//
...
...
utils/dxsf/dxsf.go
浏览文件 @
a4765858
...
@@ -49,7 +49,7 @@ func Init() error {
...
@@ -49,7 +49,7 @@ func Init() error {
}
}
}
}
}
}
logger
.
Infof
(
"[dxsf] type: %s"
,
config
.
Cfg
.
App
.
IDGeneration
.
Type
)
return
nil
return
nil
}
}
...
...
utils/xsf/xsf.go
浏览文件 @
a4765858
...
@@ -9,7 +9,9 @@ import (
...
@@ -9,7 +9,9 @@ import (
"time"
"time"
"github.com/bwmarrin/snowflake"
"github.com/bwmarrin/snowflake"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
)
...
@@ -98,6 +100,7 @@ func Init() error {
...
@@ -98,6 +100,7 @@ func Init() error {
return
e
return
e
}
}
node
=
nod
node
=
nod
logger
.
Info
(
"[xsf] node "
+
cast
.
ToString
(
n
))
return
nil
return
nil
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论