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 个修改的文件
包含
1191 行增加
和
1340 行删除
+1191
-1340
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
+4
-3
email_receiver.go
pkg/email/cache/email_receiver.go
+4
-3
email_send.go
pkg/email/cache/email_send.go
+4
-3
email_send_log.go
pkg/email/cache/email_send_log.go
+4
-3
email_tpl.go
pkg/email/cache/email_tpl.go
+4
-3
email_tpl_receiver.go
pkg/email/cache/email_tpl_receiver.go
+4
-3
var.go
pkg/email/config/var.go
+33
-3
email.go
pkg/email/controller/email.go
+10
-33
email_receiver.go
pkg/email/controller/email_receiver.go
+10
-33
email_send.go
pkg/email/controller/email_send.go
+11
-33
email_send_log.go
pkg/email/controller/email_send_log.go
+10
-33
email_tpl.go
pkg/email/controller/email_tpl.go
+10
-33
email_tpl_receiver.go
pkg/email/controller/email_tpl_receiver.go
+10
-33
email.go
pkg/email/dao/email.go
+10
-21
email_receiver.go
pkg/email/dao/email_receiver.go
+10
-21
email_send.go
pkg/email/dao/email_send.go
+24
-35
email_send_log.go
pkg/email/dao/email_send_log.go
+13
-41
email_tpl.go
pkg/email/dao/email_tpl.go
+8
-14
email_tpl_receiver.go
pkg/email/dao/email_tpl_receiver.go
+10
-21
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
+6
-9
email_send_log.go
pkg/email/enums/email_send_log.go
+6
-9
init.go
pkg/email/init.go
+41
-0
email.go
pkg/email/models/email.go
+9
-7
email_receiver.go
pkg/email/models/email_receiver.go
+8
-7
email_send.go
pkg/email/models/email_send.go
+9
-8
email_send_log.go
pkg/email/models/email_send_log.go
+10
-9
email_tpl.go
pkg/email/models/email_tpl.go
+8
-6
email_tpl_receiver.go
pkg/email/models/email_tpl_receiver.go
+8
-7
common.go
pkg/email/service/common.go
+24
-0
email.go
pkg/email/service/email.go
+53
-84
email_receiver.go
pkg/email/service/email_receiver.go
+52
-84
email_send.go
pkg/email/service/email_send.go
+70
-102
email_send_log.go
pkg/email/service/email_send_log.go
+52
-131
email_tpl.go
pkg/email/service/email_tpl.go
+49
-67
email_tpl_receiver.go
pkg/email/service/email_tpl_receiver.go
+52
-84
email.go
pkg/email/types/email.go
+12
-10
email_receiver.go
pkg/email/types/email_receiver.go
+12
-10
email_send.go
pkg/email/types/email_send.go
+14
-10
email_send_log.go
pkg/email/types/email_send_log.go
+14
-10
email_tpl.go
pkg/email/types/email_tpl.go
+8
-7
email_tpl_receiver.go
pkg/email/types/email_tpl_receiver.go
+12
-10
xsf_utils.go
pkg/email/xsf_utils/xsf_utils.go
+32
-31
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() {
if
err
:=
dxsf
.
Init
();
err
!=
nil
{
logger
.
Fatal
(
err
.
Error
())
}
logger
.
Info
(
"[dxsf] initialized."
)
}
type
Application
struct
{
...
...
cmd/email/cmd.go
浏览文件 @
a4765858
package
email
package
main
func
main
()
{
}
config/config.go
浏览文件 @
a4765858
package
config
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/config"
"strings"
"sync"
"time"
...
...
@@ -120,6 +121,7 @@ type Config struct {
Redis
Redis
`yaml:"redis" json:"redis" mapstructure:"redis"`
Cron
Cron
`yaml:"cron" json:"cron" mapstructure:"cron"`
Oss
oss
.
AliOssConfig
`yaml:"oss" json:"oss" mapstructure:"oss"`
Email
config
.
Config
`yaml:"email" json:"email" mapstructure:"email"`
Content
[]
byte
`yaml:"-" json:"-"`
}
...
...
config/consul.go
浏览文件 @
a4765858
...
...
@@ -3,6 +3,7 @@ package config
import
(
"bytes"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"time"
"github.com/hashicorp/consul/api"
...
...
@@ -13,6 +14,7 @@ import (
)
type
ConsulConfFetcher
struct
{
count
int
isNew
bool
confKey
string
err
error
...
...
@@ -51,6 +53,7 @@ func (x *ConsulConfFetcher) sync() *ConsulConfFetcher {
return
x
}
if
hashUtils
.
Md5
(
kv
.
Value
)
!=
hashUtils
.
Md5
(
x
.
cfg
.
GetContent
())
{
x
.
count
++
x
.
isNew
=
true
x
.
cfg
.
SetContent
(
kv
.
Value
)
}
...
...
@@ -78,6 +81,9 @@ func (x *ConsulConfFetcher) parse() *ConsulConfFetcher {
for
_
,
load
:=
range
x
.
loads
{
load
(
x
.
cfg
.
GetContent
())
}
if
x
.
count
>
1
{
eventbus
.
Eb
.
Publish
(
context
.
Background
(),
eventbus
.
TopicConfChange
)
}
logger
.
Debug
(
"[consul] conf updated"
)
return
x
}
...
...
config/init.go
浏览文件 @
a4765858
...
...
@@ -29,7 +29,8 @@ func ParseConf() (err error) {
if
confType
==
"local"
{
localConf
()
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
()
});
err
!=
nil
{
return
err
...
...
@@ -48,6 +49,9 @@ func ParseConf() (err error) {
if
confType
==
"nacos"
{
nacosConf
()
nc
:=
NewNacos
(
&
Cfg
.
ConfCenter
.
Nacos
,
func
(
content
[]
byte
)
(
err
error
)
{
if
bytes
.
Compare
(
content
,
Cfg
.
GetContent
())
==
0
{
return
nil
}
Cfg
.
SetContent
(
content
)
v
:=
viper
.
New
()
v
.
SetConfigType
(
"yaml"
)
...
...
@@ -57,7 +61,10 @@ func ParseConf() (err error) {
if
err
:=
v
.
Unmarshal
(
&
Cfg
);
err
!=
nil
{
return
err
}
return
ParseExtend
()
if
err
:=
ParseExtend
();
err
!=
nil
{
return
err
}
return
nil
},
logger
.
Get
())
if
err
:=
nc
.
Connect
()
.
Watch
()
.
Fetch
()
.
Parse
()
.
Err
();
err
!=
nil
{
return
err
...
...
config/local.go
浏览文件 @
a4765858
...
...
@@ -4,8 +4,10 @@ package config
import
(
"bufio"
"bytes"
"context"
"encoding/json"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"os"
"path"
"path/filepath"
...
...
@@ -17,8 +19,11 @@ import (
"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
func
parseLocal
(
configFile
string
,
obj
ICfg
,
reloads
...
func
())
error
{
type
localParser
struct
{
count
int
}
func
(
x
*
localParser
)
parseLocal
(
configFile
string
,
obj
ICfg
,
reloads
...
func
())
error
{
confFileAbs
,
err
:=
filepath
.
Abs
(
configFile
)
if
err
!=
nil
{
return
err
...
...
@@ -50,13 +55,13 @@ func parseLocal(configFile string, obj ICfg, reloads ...func()) error {
for
_
,
reload
:=
range
reloads
{
reload
()
}
watchConfig
(
configFile
,
obj
,
reloads
...
)
x
.
watchConfig
(
configFile
,
obj
,
reloads
...
)
}
return
nil
}
func
watchConfig
(
confFile
string
,
obj
ICfg
,
reloads
...
func
())
{
func
(
x
*
localParser
)
watchConfig
(
confFile
string
,
obj
ICfg
,
reloads
...
func
())
{
viper
.
WatchConfig
()
// Note: OnConfigChange is called twice on Windows
...
...
@@ -78,6 +83,10 @@ func watchConfig(confFile string, obj ICfg, reloads ...func()) {
reload
()
}
}
x
.
count
++
if
x
.
count
>
1
{
eventbus
.
Eb
.
Publish
(
context
.
Background
(),
eventbus
.
TopicConfChange
)
}
})
}
...
...
config/nacos.go
浏览文件 @
a4765858
package
config
import
(
"context"
"errors"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/clients/config_client"
...
...
@@ -21,6 +23,7 @@ type NacosClient struct {
parseFn
func
(
content
[]
byte
)
(
err
error
)
e
error
l
*
zap
.
Logger
count
int
}
type
Parser
func
(
content
[]
byte
)
(
err
error
)
...
...
@@ -98,7 +101,11 @@ func (x *NacosClient) Parse() *NacosClient {
if
x
.
e
!=
nil
{
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
}
...
...
go.mod
浏览文件 @
a4765858
...
...
@@ -90,6 +90,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.12 // 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
golang.org/x/image v0.23.0 // 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
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/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/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=
...
...
pkg/email/biz/email.go
浏览文件 @
a4765858
package
biz
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"
"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/xcommon"
)
type
Email
struct
{
models
.
Email
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
Email
,
Email
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
Email
,
Email
]
}
var
EmailTool
=
&
Email
{}
...
...
@@ -22,7 +19,7 @@ var EmailTool = &Email{}
func
(
*
Email
)
GetIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
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
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
...
...
@@ -33,7 +30,6 @@ func (x *Email) GetTplIDs(rs []*Email) []xsf.ID{
type
EmailOpts
struct
{
}
func
(
Email
)
NewFromModel
(
m
*
models
.
Email
)
*
Email
{
if
m
==
nil
{
return
nil
...
...
pkg/email/biz/email_receiver.go
浏览文件 @
a4765858
package
biz
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"
"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/xcommon"
)
type
EmailReceiver
struct
{
models
.
EmailReceiver
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailReceiver
,
EmailReceiver
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailReceiver
,
EmailReceiver
]
}
var
EmailReceiverTool
=
&
EmailReceiver
{}
...
...
@@ -22,7 +19,7 @@ var EmailReceiverTool = &EmailReceiver{}
func
(
*
EmailReceiver
)
GetIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
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
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
...
...
@@ -33,7 +30,6 @@ func (x *EmailReceiver) GetEmailIDs(rs []*EmailReceiver) []xsf.ID{
type
EmailReceiverOpts
struct
{
}
func
(
EmailReceiver
)
NewFromModel
(
m
*
models
.
EmailReceiver
)
*
EmailReceiver
{
if
m
==
nil
{
return
nil
...
...
pkg/email/biz/email_send.go
浏览文件 @
a4765858
package
biz
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"
"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/xcommon"
)
type
EmailSend
struct
{
models
.
EmailSend
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSend
,
EmailSend
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSend
,
EmailSend
]
}
var
EmailSendTool
=
&
EmailSend
{}
...
...
@@ -22,7 +19,7 @@ var EmailSendTool = &EmailSend{}
func
(
*
EmailSend
)
GetIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
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
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
...
...
@@ -33,7 +30,6 @@ func (x *EmailSend) GetEmailIDs(rs []*EmailSend) []xsf.ID{
type
EmailSendOpts
struct
{
}
func
(
EmailSend
)
NewFromModel
(
m
*
models
.
EmailSend
)
*
EmailSend
{
if
m
==
nil
{
return
nil
...
...
pkg/email/biz/email_send_log.go
浏览文件 @
a4765858
package
biz
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"
"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/xcommon"
)
type
EmailSendLog
struct
{
models
.
EmailSendLog
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSendLog
,
EmailSendLog
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailSendLog
,
EmailSendLog
]
}
var
EmailSendLogTool
=
&
EmailSendLog
{}
...
...
@@ -22,7 +19,7 @@ var EmailSendLogTool = &EmailSendLog{}
func
(
*
EmailSendLog
)
GetIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
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
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailSendID
())
...
...
@@ -33,7 +30,6 @@ func (x *EmailSendLog) GetEmailSendIDs(rs []*EmailSendLog) []xsf.ID{
type
EmailSendLogOpts
struct
{
}
func
(
EmailSendLog
)
NewFromModel
(
m
*
models
.
EmailSendLog
)
*
EmailSendLog
{
if
m
==
nil
{
return
nil
...
...
pkg/email/biz/email_tpl.go
浏览文件 @
a4765858
package
biz
import
(
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"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/xcommon"
)
type
EmailTpl
struct
{
models
.
EmailTpl
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTpl
,
EmailTpl
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTpl
,
EmailTpl
]
}
var
EmailTplTool
=
&
EmailTpl
{}
...
...
@@ -25,7 +22,6 @@ func (*EmailTpl) GetIDs(rs []*EmailTpl) []xsf.ID {
type
EmailTplOpts
struct
{
}
func
(
EmailTpl
)
NewFromModel
(
m
*
models
.
EmailTpl
)
*
EmailTpl
{
if
m
==
nil
{
return
nil
...
...
pkg/email/biz/email_tpl_receiver.go
浏览文件 @
a4765858
package
biz
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"
"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/xcommon"
)
type
EmailTplReceiver
struct
{
models
.
EmailTplReceiver
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTplReceiver
,
EmailTplReceiver
]
xcommon
.
CommonBiz
[
xsf
.
ID
,
models
.
EmailTplReceiver
,
EmailTplReceiver
]
}
var
EmailTplReceiverTool
=
&
EmailTplReceiver
{}
...
...
@@ -22,7 +19,7 @@ var EmailTplReceiverTool = &EmailTplReceiver{}
func
(
*
EmailTplReceiver
)
GetIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
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
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
...
...
@@ -33,7 +30,6 @@ func (x *EmailTplReceiver) GetTplIDs(rs []*EmailTplReceiver) []xsf.ID{
type
EmailTplReceiverOpts
struct
{
}
func
(
EmailTplReceiver
)
NewFromModel
(
m
*
models
.
EmailTplReceiver
)
*
EmailTplReceiver
{
if
m
==
nil
{
return
nil
...
...
pkg/email/cache/email.go
浏览文件 @
a4765858
package
cache
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
const
(
emailCachePrefixKey
=
prefix
+
"email:"
var
(
emailCachePrefixKey
=
"email:"
)
type
EmailCache
ocache
.
OCache
[
models
.
Email
]
...
...
pkg/email/cache/email_receiver.go
浏览文件 @
a4765858
package
cache
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
const
(
emailReceiverCachePrefixKey
=
prefix
+
"emailReceiver:"
var
(
emailReceiverCachePrefixKey
=
"emailReceiver:"
)
type
EmailReceiverCache
ocache
.
OCache
[
models
.
EmailReceiver
]
...
...
pkg/email/cache/email_send.go
浏览文件 @
a4765858
package
cache
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
const
(
emailSendCachePrefixKey
=
prefix
+
"emailSend:"
var
(
emailSendCachePrefixKey
=
"emailSend:"
)
type
EmailSendCache
ocache
.
OCache
[
models
.
EmailSend
]
...
...
pkg/email/cache/email_send_log.go
浏览文件 @
a4765858
package
cache
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
const
(
emailSendLogCachePrefixKey
=
prefix
+
"emailSendLog:"
var
(
emailSendLogCachePrefixKey
=
"emailSendLog:"
)
type
EmailSendLogCache
ocache
.
OCache
[
models
.
EmailSendLog
]
...
...
pkg/email/cache/email_tpl.go
浏览文件 @
a4765858
package
cache
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
const
(
emailTplCachePrefixKey
=
prefix
+
"emailTpl:"
var
(
emailTplCachePrefixKey
=
"emailTpl:"
)
type
EmailTplCache
ocache
.
OCache
[
models
.
EmailTpl
]
...
...
pkg/email/cache/email_tpl_receiver.go
浏览文件 @
a4765858
package
cache
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/ocache"
"operator-qt/internal/modules/operator/models"
)
const
(
emailTplReceiverCachePrefixKey
=
prefix
+
"emailTplReceiver:"
var
(
emailTplReceiverCachePrefixKey
=
"emailTplReceiver:"
)
type
EmailTplReceiverCache
ocache
.
OCache
[
models
.
EmailTplReceiver
]
...
...
pkg/email/config/var.go
浏览文件 @
a4765858
package
con
sts
package
con
fig
var
(
Schema
string
=
""
Prefix
string
=
""
Cfg
=
&
Config
{}
)
// 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
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"
"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/xcommon"
)
type
emailController
struct
{
...
...
@@ -37,7 +35,7 @@ func (x *emailController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
}
func
(
x
*
emailController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -48,18 +46,6 @@ func (x *emailController) DeleteByID(c *gin.Context) {
}
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
)
{
in
:=
&
types
.
EmailUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
...
@@ -72,18 +58,7 @@ func (x *emailController) UpdateByID(c *gin.Context) {
}
response
.
Success
(
c
)
}
func
(
x
*
emailController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailUpdateByIDsReq
{}
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 查询邮件详情
// @Description 通过id查询邮件详情,参数id必填
...
...
@@ -100,7 +75,7 @@ func (x *emailController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
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
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -122,6 +97,7 @@ func (x *emailController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailObjDetailTool
.
NewSliceFromBizSlice
(
emails
)
response
.
SuccessWithList
(
c
,
data
)
}
// Page
// @Summary 分页查询邮件
// @Description 分页查询邮件
...
...
@@ -147,6 +123,7 @@ func (x *emailController) Page(c *gin.Context) {
data
:=
types
.
EmailObjDetailTool
.
NewSliceFromBizSlice
(
emails
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
// ExportCSV
// @Summary 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_receiver.go
浏览文件 @
a4765858
package
controller
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"
"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/xcommon"
)
type
emailReceiverController
struct
{
...
...
@@ -37,7 +35,7 @@ func (x *emailReceiverController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
}
func
(
x
*
emailReceiverController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -48,18 +46,6 @@ func (x *emailReceiverController) DeleteByID(c *gin.Context) {
}
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
)
{
in
:=
&
types
.
EmailReceiverUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
...
@@ -72,18 +58,7 @@ func (x *emailReceiverController) UpdateByID(c *gin.Context) {
}
response
.
Success
(
c
)
}
func
(
x
*
emailReceiverController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailReceiverUpdateByIDsReq
{}
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 查询邮件收件人详情
// @Description 通过id查询邮件收件人详情,参数id必填
...
...
@@ -100,7 +75,7 @@ func (x *emailReceiverController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
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
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -122,6 +97,7 @@ func (x *emailReceiverController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailReceivers
)
response
.
SuccessWithList
(
c
,
data
)
}
// Page
// @Summary 分页查询邮件收件人
// @Description 分页查询邮件收件人
...
...
@@ -147,6 +123,7 @@ func (x *emailReceiverController) Page(c *gin.Context) {
data
:=
types
.
EmailReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailReceivers
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
// ExportCSV
// @Summary 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_send.go
浏览文件 @
a4765858
package
controller
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"
"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/xcommon"
)
type
emailSendController
struct
{
...
...
@@ -37,7 +35,7 @@ func (x *emailSendController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
}
func
(
x
*
emailSendController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -48,18 +46,7 @@ func (x *emailSendController) DeleteByID(c *gin.Context) {
}
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
)
{
in
:=
&
types
.
EmailSendUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
...
@@ -72,18 +59,7 @@ func (x *emailSendController) UpdateByID(c *gin.Context) {
}
response
.
Success
(
c
)
}
func
(
x
*
emailSendController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailSendUpdateByIDsReq
{}
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 查询邮件发送详情
// @Description 通过id查询邮件发送详情,参数id必填
...
...
@@ -100,7 +76,7 @@ func (x *emailSendController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
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
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -122,6 +98,7 @@ func (x *emailSendController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailSendObjDetailTool
.
NewSliceFromBizSlice
(
emailSends
)
response
.
SuccessWithList
(
c
,
data
)
}
// Page
// @Summary 分页查询邮件发送
// @Description 分页查询邮件发送
...
...
@@ -147,6 +124,7 @@ func (x *emailSendController) Page(c *gin.Context) {
data
:=
types
.
EmailSendObjDetailTool
.
NewSliceFromBizSlice
(
emailSends
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
// ExportCSV
// @Summary 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_send_log.go
浏览文件 @
a4765858
package
controller
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"
"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/xcommon"
)
type
emailSendLogController
struct
{
...
...
@@ -37,7 +35,7 @@ func (x *emailSendLogController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
}
func
(
x
*
emailSendLogController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -48,18 +46,6 @@ func (x *emailSendLogController) DeleteByID(c *gin.Context) {
}
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
)
{
in
:=
&
types
.
EmailSendLogUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
...
@@ -72,18 +58,7 @@ func (x *emailSendLogController) UpdateByID(c *gin.Context) {
}
response
.
Success
(
c
)
}
func
(
x
*
emailSendLogController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailSendLogUpdateByIDsReq
{}
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 查询邮件发送记录详情
// @Description 通过id查询邮件发送记录详情,参数id必填
...
...
@@ -100,7 +75,7 @@ func (x *emailSendLogController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
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
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -122,6 +97,7 @@ func (x *emailSendLogController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailSendLogObjDetailTool
.
NewSliceFromBizSlice
(
emailSendLogs
)
response
.
SuccessWithList
(
c
,
data
)
}
// Page
// @Summary 分页查询邮件发送记录
// @Description 分页查询邮件发送记录
...
...
@@ -147,6 +123,7 @@ func (x *emailSendLogController) Page(c *gin.Context) {
data
:=
types
.
EmailSendLogObjDetailTool
.
NewSliceFromBizSlice
(
emailSendLogs
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
// ExportCSV
// @Summary 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_tpl.go
浏览文件 @
a4765858
package
controller
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"
"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/xcommon"
)
type
emailTplController
struct
{
...
...
@@ -37,7 +35,7 @@ func (x *emailTplController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
}
func
(
x
*
emailTplController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -48,18 +46,6 @@ func (x *emailTplController) DeleteByID(c *gin.Context) {
}
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
)
{
in
:=
&
types
.
EmailTplUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
...
@@ -72,18 +58,7 @@ func (x *emailTplController) UpdateByID(c *gin.Context) {
}
response
.
Success
(
c
)
}
func
(
x
*
emailTplController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailTplUpdateByIDsReq
{}
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 查询邮件模板详情
// @Description 通过id查询邮件模板详情,参数id必填
...
...
@@ -100,7 +75,7 @@ func (x *emailTplController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
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
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -122,6 +97,7 @@ func (x *emailTplController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailTplObjDetailTool
.
NewSliceFromBizSlice
(
emailTpls
)
response
.
SuccessWithList
(
c
,
data
)
}
// Page
// @Summary 分页查询邮件模板
// @Description 分页查询邮件模板
...
...
@@ -147,6 +123,7 @@ func (x *emailTplController) Page(c *gin.Context) {
data
:=
types
.
EmailTplObjDetailTool
.
NewSliceFromBizSlice
(
emailTpls
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
// ExportCSV
// @Summary 导出csv
// @Description 导出csv
...
...
pkg/email/controller/email_tpl_receiver.go
浏览文件 @
a4765858
package
controller
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"
"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/xcommon"
)
type
emailTplReceiverController
struct
{
...
...
@@ -37,7 +35,7 @@ func (x *emailTplReceiverController) Create(c *gin.Context) {
response
.
Success
(
c
,
id
)
}
func
(
x
*
emailTplReceiverController
)
DeleteByID
(
c
*
gin
.
Context
)
{
in
:=
&
request
.
BaseIDReq
{}
in
:=
&
request
.
BaseIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -48,18 +46,6 @@ func (x *emailTplReceiverController) DeleteByID(c *gin.Context) {
}
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
)
{
in
:=
&
types
.
EmailTplReceiverUpdateByIDReq
{}
if
err
:=
x
.
Bind
(
c
,
in
);
err
!=
nil
{
...
...
@@ -72,18 +58,7 @@ func (x *emailTplReceiverController) UpdateByID(c *gin.Context) {
}
response
.
Success
(
c
)
}
func
(
x
*
emailTplReceiverController
)
UpdateByIDs
(
c
*
gin
.
Context
)
{
in
:=
&
types
.
EmailTplReceiverUpdateByIDsReq
{}
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 查询邮件模板收件人详情
// @Description 通过id查询邮件模板收件人详情,参数id必填
...
...
@@ -100,7 +75,7 @@ func (x *emailTplReceiverController) GetByID(c *gin.Context) {
response
.
Error
(
c
,
err
)
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
{
response
.
Error
(
c
,
err
)
return
...
...
@@ -122,6 +97,7 @@ func (x *emailTplReceiverController) GetByIDs(c *gin.Context) {
data
:=
types
.
EmailTplReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailTplReceivers
)
response
.
SuccessWithList
(
c
,
data
)
}
// Page
// @Summary 分页查询邮件模板收件人
// @Description 分页查询邮件模板收件人
...
...
@@ -147,6 +123,7 @@ func (x *emailTplReceiverController) Page(c *gin.Context) {
data
:=
types
.
EmailTplReceiverObjDetailTool
.
NewSliceFromBizSlice
(
emailTplReceivers
)
response
.
SuccessWithPage
(
c
,
data
,
total
)
}
// ExportCSV
// @Summary 导出csv
// @Description 导出csv
...
...
pkg/email/dao/email.go
浏览文件 @
a4765858
package
dao
import
(
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
)
type
emailDao
struct
{
*
odao
.
ODao
[
models
.
Email
]
}
var
EmailDao
=
&
emailDao
{
ODao
:
odao
.
NewDao
[
models
.
Email
](
consts
.
Schema_operator
),
}
var
EmailDao
=
&
emailDao
{}
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
)
{
if
tplID
<=
0
{
return
nil
,
nil
...
...
@@ -35,24 +24,24 @@ func (x *emailDao) GetSliceByTplIDs(ctx context.Context, order string, tplIDs []
if
len
(
tplIDs
)
==
0
{
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
{
return
nil
,
err
}
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
{
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
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
Email
)
for
_
,
record
:=
range
emails
{
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
import
(
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
)
type
emailReceiverDao
struct
{
*
odao
.
ODao
[
models
.
EmailReceiver
]
}
var
EmailReceiverDao
=
&
emailReceiverDao
{
ODao
:
odao
.
NewDao
[
models
.
EmailReceiver
](
consts
.
Schema_operator
),
}
var
EmailReceiverDao
=
&
emailReceiverDao
{}
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
)
{
if
emailID
<=
0
{
return
nil
,
nil
...
...
@@ -35,24 +24,24 @@ func (x *emailReceiverDao) GetSliceByEmailIDs(ctx context.Context, order string,
if
len
(
emailIDs
)
==
0
{
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
{
return
nil
,
err
}
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
{
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
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailReceiver
)
for
_
,
record
:=
range
emailReceivers
{
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
import
(
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
)
type
emailSendDao
struct
{
*
odao
.
ODao
[
models
.
EmailSend
]
}
var
EmailSendDao
=
&
emailSendDao
{
ODao
:
odao
.
NewDao
[
models
.
EmailSend
](
consts
.
Schema_operator
),
}
var
EmailSendDao
=
&
emailSendDao
{}
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
)
{
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state = ?"
,
state
)
}
func
(
x
*
emailSendDao
)
GetSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSend_State_Enum
)
([]
*
models
.
EmailSend
,
error
)
{
if
len
(
states
)
==
0
{
return
nil
,
nil
if
len
(
states
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
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
{
return
nil
,
0
,
nil
}
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
if
err
!=
nil
{
return
nil
,
0
,
err
emailSends
,
err
:=
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailSends
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailSends
)
==
0
{
return
nil
,
0
,
nil
}
emailSendMapSlice
:=
make
(
map
[
enums
.
EmailSend_State_Enum
][]
*
models
.
EmailSend
)
for
i
:=
range
emailSends
{
emailSendMapSlice
[
emailSends
[
i
]
.
State
]
=
append
(
emailSendMapSlice
[
emailSends
[
i
]
.
State
],
emailSends
[
i
])
for
i
:=
range
emailSends
{
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
)
{
if
emailID
<=
0
{
...
...
@@ -64,24 +53,24 @@ func (x *emailSendDao) GetSliceByEmailIDs(ctx context.Context, order string, ema
if
len
(
emailIDs
)
==
0
{
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
{
return
nil
,
err
}
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
{
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
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailSend
)
for
_
,
record
:=
range
emailSends
{
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
import
(
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"operator-qt/internal/modules/operator/models"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
)
type
emailSendLogDao
struct
{
*
odao
.
ODao
[
models
.
EmailSendLog
]
}
var
EmailSendLogDao
=
&
emailSendLogDao
{
ODao
:
odao
.
NewDao
[
models
.
EmailSendLog
](
consts
.
Schema_operator
),
}
var
EmailSendLogDao
=
&
emailSendLogDao
{}
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
)
{
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state = ?"
,
state
)
}
func
(
x
*
emailSendLogDao
)
GetSliceByStates
(
ctx
context
.
Context
,
order
string
,
states
[]
enums
.
EmailSendLog_State_Enum
)
([]
*
models
.
EmailSendLog
,
error
)
{
if
len
(
states
)
==
0
{
return
nil
,
nil
if
len
(
states
)
==
0
{
return
nil
,
nil
}
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
)
{
if
emailSendID
<=
0
{
return
nil
,
nil
...
...
@@ -64,24 +36,24 @@ func (x *emailSendLogDao) GetSliceByEmailSendIDs(ctx context.Context, order stri
if
len
(
emailSendIDs
)
==
0
{
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
{
return
nil
,
err
}
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
{
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
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailSendLog
)
for
_
,
record
:=
range
emailSendLogs
{
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
import
(
"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"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"operator-qt/internal/consts"
"operator-qt/internal/global"
)
type
emailTplDao
struct
{
*
odao
.
ODao
[
models
.
EmailTpl
]
}
var
EmailTplDao
=
&
emailTplDao
{
ODao
:
odao
.
NewDao
[
models
.
EmailTpl
](
consts
.
Schema_operator
),
}
var
EmailTplDao
=
&
emailTplDao
{}
func
init
()
{
_
=
global
.
Eb
.
Subscribe
(
eventbus
.
TopicCacheInitFinish
,
func
(
ctx
context
.
Context
)
{
EmailTplDao
.
ODao
.
Cache
=
cache
.
NewEmailTplCache
(
database
.
GetCacheType
())
})
func
(
x
*
emailTplDao
)
GetByCode
(
ctx
context
.
Context
,
code
string
)
(
*
models
.
EmailTpl
,
error
)
{
if
code
==
""
{
return
nil
,
nil
}
return
x
.
GetByWhere
(
ctx
,
"code = ?"
,
code
)
}
pkg/email/dao/email_tpl_receiver.go
浏览文件 @
a4765858
package
dao
import
(
"context"
"operator-qt/internal/modules/operator/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
)
type
emailTplReceiverDao
struct
{
*
odao
.
ODao
[
models
.
EmailTplReceiver
]
}
var
EmailTplReceiverDao
=
&
emailTplReceiverDao
{
ODao
:
odao
.
NewDao
[
models
.
EmailTplReceiver
](
consts
.
Schema_operator
),
}
var
EmailTplReceiverDao
=
&
emailTplReceiverDao
{}
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
)
{
if
tplID
<=
0
{
return
nil
,
nil
...
...
@@ -35,24 +24,24 @@ func (x *emailTplReceiverDao) GetSliceByTplIDs(ctx context.Context, order string
if
len
(
tplIDs
)
==
0
{
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
{
return
nil
,
err
}
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
{
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
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
itemMap
:=
make
(
map
[
xsf
.
ID
][]
*
models
.
EmailTplReceiver
)
for
_
,
record
:=
range
emailTplReceivers
{
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
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
import
(
"crypto/rand"
"bytes"
"context"
"crypto/tls"
"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"
"gorm.io/gorm"
"gopkg.in/gomail.v2"
)
// 配置结构体 (建议从环境变量或配置文件中读取)
type
Config
struct
{
SMTPServer
string
SMTPPort
int
SMTPUsername
string
SMTPPassword
string
FromEmail
string
}
func
GenerateVerificationCode
(
length
int
)
(
string
,
error
)
{
code
:=
""
for
i
:=
0
;
i
<
length
;
i
++
{
num
,
err
:=
rand
.
Int
(
rand
.
Reader
,
big
.
NewInt
(
10
))
func
NewEmail
(
from
string
,
to
[]
*
models
.
EmailTplReceiver
,
subject
string
,
body
string
,
attachments
[]
*
config
.
Attachment
,
inlineImages
map
[
string
]
string
)
*
config
.
Email
{
e
:=
config
.
Email
{
From
:
from
,
Subject
:
subject
,
Body
:
body
,
Attachments
:
attachments
,
InlineImages
:
inlineImages
,
}
for
_
,
r
:=
range
to
{
name
,
email
,
err
:=
extractEmailReceiver
(
r
.
Receiver
)
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
code
,
nil
return
&
e
}
func
SendVerificationCode
(
cfg
Config
,
toEmail
string
,
code
string
)
error
{
func
extractEmailReceiver
(
input
string
)
(
name
,
email
string
,
err
error
)
{
re
:=
regexp
.
MustCompile
(
`^([^<]+)\s*<([^>]+)>$`
)
matches
:=
re
.
FindStringSubmatch
(
input
)
if
len
(
matches
)
!=
3
{
return
""
,
""
,
fmt
.
Errorf
(
"无效的邮件格式"
)
}
name
=
matches
[
1
]
name
=
regexp
.
MustCompile
(
`^\s+|\s+$`
)
.
ReplaceAllString
(
name
,
""
)
email
=
matches
[
2
]
return
name
,
email
,
nil
}
func
SendTLS
(
ctx
context
.
Context
,
e
*
config
.
Email
)
error
{
m
:=
gomail
.
NewMessage
()
m
.
SetHeader
(
"From"
,
cfg
.
FromEmail
)
m
.
SetHeader
(
"To"
,
toEmail
)
m
.
SetHeader
(
"Subject"
,
"[万桩严选商城]验证码"
)
m
.
SetBody
(
"text/html"
,
fmt
.
Sprintf
(
`
<html>
<body>
<h3>验证码通知</h3>
<p>您的验证码是:<strong>%s</strong></p>
<p>有效期15分钟,请勿泄露给他人</p>
</body>
</html>
`
,
code
))
m
.
SetAddressHeader
(
"From"
,
config
.
Cfg
.
Email
,
e
.
From
)
var
toList
[]
string
for
_
,
r
:=
range
e
.
To
{
toList
=
append
(
toList
,
m
.
FormatAddress
(
r
.
Email
,
r
.
DisplayName
))
}
m
.
SetHeader
(
"To"
,
toList
...
)
m
.
SetHeader
(
"Subject"
,
e
.
Subject
)
if
len
(
e
.
InlineImages
)
>
0
{
m
.
SetBody
(
"text/html"
,
e
.
Body
)
for
cid
,
filePath
:=
range
e
.
InlineImages
{
m
.
Embed
(
filePath
,
gomail
.
Rename
(
cid
))
}
}
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
(
cfg
.
SMTPServer
,
cfg
.
SMTPPort
,
c
fg
.
SMTPUsername
,
c
fg
.
SMTPPassword
,
c
onfig
.
C
fg
.
SMTPServer
,
c
onfig
.
C
fg
.
SMTPPort
,
c
onfig
.
Cfg
.
Email
,
c
onfig
.
Cfg
.
Token
,
)
d
.
TLSConfig
=
&
tls
.
Config
{
ServerName
:
cfg
.
SMTPServer
}
d
.
SSL
=
false
d
.
TLSConfig
=
&
tls
.
Config
{
ServerName
:
config
.
Cfg
.
SMTPServer
,
MinVersion
:
tls
.
VersionTLS12
,
InsecureSkipVerify
:
false
,
}
d
.
SSL
=
true
if
err
:=
d
.
DialAndSend
(
m
);
err
!=
nil
{
return
xerror
.
New
(
err
.
Error
())
}
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
type
EmailSend_State_Enum
int8
func
init
()
{
pdict
.
Add
(
"operator_emailSend_state"
,
EmailSend_State_Enums_Dict
)
mdict
.
Add
(
"emailSend_state"
,
EmailSend_State_Enums_Dict
)
}
type
EmailSend_State_Enum
int8
var
(
var
(
EmailSend_State_Unknown
EmailSend_State_Enum
=
0
// 未知
EmailSend_State_Wait
EmailSend_State_Enum
=
1
// 待处理
EmailSend_State_Doing
EmailSend_State_Enum
=
2
// 处理中
...
...
@@ -26,8 +22,9 @@ func init() {
EmailSend_State_Success
:
EmailSend_State_Success
.
Desc
(),
EmailSend_State_Fail
:
EmailSend_State_Fail
.
Desc
(),
}
)
func
(
x
EmailSend_State_Enum
)
Desc
()
string
{
)
func
(
x
EmailSend_State_Enum
)
Desc
()
string
{
desc
:=
"未知"
switch
x
{
case
EmailSend_State_Unknown
:
...
...
@@ -42,4 +39,4 @@ func init() {
desc
=
"失败"
}
return
desc
}
}
pkg/email/enums/email_send_log.go
浏览文件 @
a4765858
package
enums
type
EmailSendLog_State_Enum
int8
func
init
()
{
pdict
.
Add
(
"operator_emailSendLog_state"
,
EmailSendLog_State_Enums_Dict
)
mdict
.
Add
(
"emailSendLog_state"
,
EmailSendLog_State_Enums_Dict
)
}
type
EmailSendLog_State_Enum
int8
var
(
var
(
EmailSendLog_State_Unknown
EmailSendLog_State_Enum
=
0
// 未知
EmailSendLog_State_Wait
EmailSendLog_State_Enum
=
1
// 待处理
EmailSendLog_State_Doing
EmailSendLog_State_Enum
=
2
// 处理中
...
...
@@ -26,8 +22,9 @@ func init() {
EmailSendLog_State_Success
:
EmailSendLog_State_Success
.
Desc
(),
EmailSendLog_State_Fail
:
EmailSendLog_State_Fail
.
Desc
(),
}
)
func
(
x
EmailSendLog_State_Enum
)
Desc
()
string
{
)
func
(
x
EmailSendLog_State_Enum
)
Desc
()
string
{
desc
:=
"未知"
switch
x
{
case
EmailSendLog_State_Unknown
:
...
...
@@ -42,4 +39,4 @@ func init() {
desc
=
"失败"
}
return
desc
}
}
pkg/email/init.go
浏览文件 @
a4765858
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
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
//Email 邮件
//
Email 邮件
type
Email
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
Subject
string
`json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"subject"`
//主题
From
string
`json:"from" form:"from" gorm:"column:from;type:varchar(255);comment:发件人" example:"月饼<mooncake2026@163.com>" csv:"发件人"`
//发件人
Content
string
`json:"content" form:"content" gorm:"column:content;type:text;comment:邮件内容" example:"<div>hello moon! </div>" csv:"邮件内容"`
//邮件内容
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
...
...
@@ -22,20 +24,20 @@ func (Email) TableName() string {
return
TBEmail
}
func
(
x
Email
)
GetID
()
xsf
.
ID
{
func
(
x
Email
)
GetID
()
xsf
.
ID
{
return
x
.
ID
}
func
(
x
*
Email
)
GetTplID
()
xsf
.
ID
{
func
(
x
*
Email
)
GetTplID
()
xsf
.
ID
{
return
x
.
TplID
}
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
}
return
set
.
Slice
()
}
func
(
x
Email
)
GetOrder
()
string
{
func
(
x
Email
)
GetOrder
()
string
{
return
"id asc"
}
...
...
pkg/email/models/email_receiver.go
浏览文件 @
a4765858
package
models
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
//EmailReceiver 邮件收件人
//
EmailReceiver 邮件收件人
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"`
//主键
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
...
...
@@ -21,20 +22,20 @@ func (EmailReceiver) TableName() string {
return
TBEmailReceiver
}
func
(
x
EmailReceiver
)
GetID
()
xsf
.
ID
{
func
(
x
EmailReceiver
)
GetID
()
xsf
.
ID
{
return
x
.
ID
}
func
(
x
*
EmailReceiver
)
GetEmailID
()
xsf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailID
()
xsf
.
ID
{
return
x
.
EmailID
}
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
}
return
set
.
Slice
()
}
func
(
x
EmailReceiver
)
GetOrder
()
string
{
func
(
x
EmailReceiver
)
GetOrder
()
string
{
return
"id asc"
}
...
...
pkg/email/models/email_send.go
浏览文件 @
a4765858
package
models
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"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/xtime"
"gorm.io/gorm"
)
//EmailSend 邮件发送
//
EmailSend 邮件发送
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"`
//主键
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
...
...
@@ -22,20 +23,20 @@ func (EmailSend) TableName() string {
return
TBEmailSend
}
func
(
x
EmailSend
)
GetID
()
xsf
.
ID
{
func
(
x
EmailSend
)
GetID
()
xsf
.
ID
{
return
x
.
ID
}
func
(
x
*
EmailSend
)
GetEmailID
()
xsf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailID
()
xsf
.
ID
{
return
x
.
EmailID
}
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
}
return
set
.
Slice
()
}
func
(
x
EmailSend
)
GetOrder
()
string
{
func
(
x
EmailSend
)
GetOrder
()
string
{
return
"id asc"
}
...
...
pkg/email/models/email_send_log.go
浏览文件 @
a4765858
package
models
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"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/xtime"
"gorm.io/gorm"
)
//EmailSendLog 邮件发送记录
//
EmailSendLog 邮件发送记录
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"`
//主键
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:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
}
...
...
@@ -22,20 +23,20 @@ func (EmailSendLog) TableName() string {
return
TBEmailSendLog
}
func
(
x
EmailSendLog
)
GetID
()
xsf
.
ID
{
func
(
x
EmailSendLog
)
GetID
()
xsf
.
ID
{
return
x
.
ID
}
func
(
x
*
EmailSendLog
)
GetEmailSendID
()
xsf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendID
()
xsf
.
ID
{
return
x
.
EmailSendID
}
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailSendID
())
}
return
set
.
Slice
()
}
func
(
x
EmailSendLog
)
GetOrder
()
string
{
func
(
x
EmailSendLog
)
GetOrder
()
string
{
return
"id asc"
}
...
...
pkg/email/models/email_tpl.go
浏览文件 @
a4765858
package
models
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
//EmailTpl 邮件模板
//
EmailTpl 邮件模板
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"`
//主键
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:"模板代码"`
//模板代码
Subject
string
`json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"subject"`
//主题
Tpl
string
`json:"tpl" form:"tpl" gorm:"column:tpl;type:text;comment:模板" example:"<div>hello moon! </div>" csv:"模板"`
//模板
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
...
...
@@ -20,10 +22,10 @@ func (EmailTpl) TableName() string {
return
TBEmailTpl
}
func
(
x
EmailTpl
)
GetID
()
xsf
.
ID
{
func
(
x
EmailTpl
)
GetID
()
xsf
.
ID
{
return
x
.
ID
}
func
(
x
EmailTpl
)
GetOrder
()
string
{
func
(
x
EmailTpl
)
GetOrder
()
string
{
return
"id asc"
}
...
...
pkg/email/models/email_tpl_receiver.go
浏览文件 @
a4765858
package
models
import
(
"gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/setUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
"gorm.io/gorm"
)
//EmailTplReceiver 邮件模板收件人
//
EmailTplReceiver 邮件模板收件人
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"`
//主键
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
...
...
@@ -21,20 +22,20 @@ func (EmailTplReceiver) TableName() string {
return
TBEmailTplReceiver
}
func
(
x
EmailTplReceiver
)
GetID
()
xsf
.
ID
{
func
(
x
EmailTplReceiver
)
GetID
()
xsf
.
ID
{
return
x
.
ID
}
func
(
x
*
EmailTplReceiver
)
GetTplID
()
xsf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplID
()
xsf
.
ID
{
return
x
.
TplID
}
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
xsf
.
ID
{
set
:=
setUtils
.
NewSet
[
xsf
.
ID
]()
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
}
return
set
.
Slice
()
}
func
(
x
EmailTplReceiver
)
GetOrder
()
string
{
func
(
x
EmailTplReceiver
)
GetOrder
()
string
{
return
"id asc"
}
...
...
pkg/email/service/common.go
浏览文件 @
a4765858
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
import
(
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
type
emailService
struct
{
...
...
@@ -29,7 +29,7 @@ func newEmailService() *emailService {
}
}
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
{}
_
=
copier
.
Copy
(
email
,
in
)
email
.
ID
=
xsfUtils
.
EmailID
(
ctx
)
...
...
@@ -49,22 +49,8 @@ func (x *emailService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.Emai
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
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
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
}
emailUpd
:=
&
models
.
Email
{}
_
=
copier
.
Copy
(
emailUpd
,
in
)
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
)
return
dao
.
EmailDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailUpd
)
}
func
(
x
*
emailService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
...
...
@@ -101,7 +70,7 @@ func (x *emailService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.EmailO
return
nil
,
err
}
if
emailBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailAlreadyExists
}
return
emailBiz
,
nil
}
...
...
@@ -115,15 +84,14 @@ func (x *emailService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz.Ema
return
nil
,
err
}
if
emailBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailNotFound
}
return
emailBiz
,
nil
}
func
(
x
*
emailService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
func
(
x
*
emailService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
}
email
,
err
:=
dao
.
EmailDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
...
...
@@ -136,28 +104,28 @@ func (x *emailService) GetByID(ctx context.Context, id xsf.ID, opts *biz.EmailOp
}
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
}
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emails
)
==
0
{
return
nil
,
nil
if
len
(
emails
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
}
emailBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
emailBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailBizSlice
)
==
0
{
if
len
(
emailBizSlice
)
==
0
{
return
nil
,
nil
}
emailBizIDMap
:=
biz
.
EmailTool
.
SliceToIDMapBiz
(
emailBizSlice
)
...
...
@@ -169,8 +137,8 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq, opts *b
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emails
)
==
0
{
return
nil
,
total
,
nil
if
len
(
emails
)
==
0
{
return
nil
,
total
,
nil
}
emailBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
if
err
!=
nil
{
...
...
@@ -178,50 +146,50 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq, opts *b
}
return
emailBizSlice
,
total
,
nil
}
func
(
x
*
emailService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
tplID
==
0
{
func
(
x
*
emailService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
tplID
==
0
{
return
nil
,
nil
}
emails
,
err
:=
dao
.
EmailDao
.
GetSliceByTplID
(
ctx
,
models
.
EmailTool
.
GetOrder
(),
tplID
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
}
func
(
x
*
emailService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
len
(
tplIDs
)
==
0
{
func
(
x
*
emailService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
([]
*
biz
.
Email
,
error
)
{
if
len
(
tplIDs
)
==
0
{
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
{
return
nil
,
err
}
if
len
(
emails
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
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
)
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
func
(
x
*
emailService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
Email
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
}
emailBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
emailBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
if
len
(
emailBizSlice
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
Email
)
for
_
,
r
:=
range
emailBizSlice
{
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
for
_
,
r
:=
range
emailBizSlice
{
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
)
{
...
...
@@ -249,34 +217,35 @@ func (x *emailService) ToSliceBiz(ctx context.Context, emails []*models.Email, o
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
return
nil
}
func
(
x
*
emailService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailOpts
)
(
[]
*
biz
.
Email
,
error
)
{
emails
,
err
:=
dao
.
EmailDao
.
GetAll
(
ctx
)
func
(
x
*
emailService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailOpts
)
(
[]
*
biz
.
Email
,
error
)
{
emails
,
err
:=
dao
.
EmailDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emails
)
==
0
{
if
len
(
emails
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emails
,
opts
)
}
func
(
x
*
emailService
)
ExportCSV
(
ctx
context
.
Context
,
in
*
types
.
EmailExportReq
,
opts
*
biz
.
EmailOpts
)
(
string
,
error
)
{
req
:=
&
types
.
EmailPageReq
{}
_
=
copier
.
Copy
(
req
,
in
)
...
...
pkg/email/service/email_receiver.go
浏览文件 @
a4765858
package
service
import
(
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
type
emailReceiverService
struct
{
...
...
@@ -29,7 +29,7 @@ func newEmailReceiverService() *emailReceiverService {
}
}
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
{}
_
=
copier
.
Copy
(
emailReceiver
,
in
)
emailReceiver
.
ID
=
xsfUtils
.
EmailReceiverID
(
ctx
)
...
...
@@ -49,22 +49,8 @@ func (x *emailReceiverService) DeleteByID(ctx context.Context, id xsf.ID, opts *
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
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
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
}
emailReceiverUpd
:=
&
models
.
EmailReceiver
{}
_
=
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
)
{
if
id
<=
0
{
return
nil
,
nil
...
...
@@ -101,7 +70,7 @@ func (x *emailReceiverService) ErrFound(ctx context.Context, id xsf.ID, opts *bi
return
nil
,
err
}
if
emailReceiverBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailReceiverAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailReceiverAlreadyExists
}
return
emailReceiverBiz
,
nil
}
...
...
@@ -115,15 +84,14 @@ func (x *emailReceiverService) ErrNotFound(ctx context.Context, id xsf.ID, opts
return
nil
,
err
}
if
emailReceiverBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailReceiverNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailReceiverNotFound
}
return
emailReceiverBiz
,
nil
}
func
(
x
*
emailReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
func
(
x
*
emailReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
}
emailReceiver
,
err
:=
dao
.
EmailReceiverDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
...
...
@@ -136,28 +104,28 @@ func (x *emailReceiverService) GetByID(ctx context.Context, id xsf.ID, opts *biz
}
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
}
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
}
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailReceiverBizSlice
)
==
0
{
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
,
nil
}
emailReceiverBizIDMap
:=
biz
.
EmailReceiverTool
.
SliceToIDMapBiz
(
emailReceiverBizSlice
)
...
...
@@ -169,8 +137,8 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailReceivers
)
==
0
{
return
nil
,
total
,
nil
if
len
(
emailReceivers
)
==
0
{
return
nil
,
total
,
nil
}
emailReceiverBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
if
err
!=
nil
{
...
...
@@ -178,50 +146,50 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
}
return
emailReceiverBizSlice
,
total
,
nil
}
func
(
x
*
emailReceiverService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
emailID
==
0
{
func
(
x
*
emailReceiverService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
emailID
==
0
{
return
nil
,
nil
}
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetSliceByEmailID
(
ctx
,
models
.
EmailReceiverTool
.
GetOrder
(),
emailID
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
}
func
(
x
*
emailReceiverService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
emailIDs
)
==
0
{
func
(
x
*
emailReceiverService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
emailIDs
)
==
0
{
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
{
return
nil
,
err
}
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
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
)
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
func
(
x
*
emailReceiverService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailReceiverOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailReceiver
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
}
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
emailReceiverBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailReceiver
)
for
_
,
r
:=
range
emailReceiverBizSlice
{
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
for
_
,
r
:=
range
emailReceiverBizSlice
{
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
)
{
...
...
@@ -249,30 +217,30 @@ func (x *emailReceiverService) ToSliceBiz(ctx context.Context, emailReceivers []
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
return
nil
}
func
(
x
*
emailReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailReceiverOpts
)
(
[]
*
biz
.
EmailReceiver
,
error
)
{
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetAll
(
ctx
)
func
(
x
*
emailReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailReceiverOpts
)
(
[]
*
biz
.
EmailReceiver
,
error
)
{
emailReceivers
,
err
:=
dao
.
EmailReceiverDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailReceivers
)
==
0
{
if
len
(
emailReceivers
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
,
opts
)
...
...
pkg/email/service/email_send.go
浏览文件 @
a4765858
package
service
import
(
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"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/types"
xsfUtils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils"
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
{
...
...
@@ -30,7 +30,7 @@ func newEmailSendService() *emailSendService {
}
}
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
{}
_
=
copier
.
Copy
(
emailSend
,
in
)
emailSend
.
ID
=
xsfUtils
.
EmailSendID
(
ctx
)
...
...
@@ -50,22 +50,8 @@ func (x *emailSendService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.
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
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
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
}
emailSendUpd
:=
&
models
.
EmailSend
{}
_
=
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
)
{
if
id
<=
0
{
return
nil
,
nil
...
...
@@ -102,7 +71,7 @@ func (x *emailSendService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.Em
return
nil
,
err
}
if
emailSendBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendAlreadyExists
}
return
emailSendBiz
,
nil
}
...
...
@@ -116,15 +85,14 @@ func (x *emailSendService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz
return
nil
,
err
}
if
emailSendBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendNotFound
}
return
emailSendBiz
,
nil
}
func
(
x
*
emailSendService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
func
(
x
*
emailSendService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
}
emailSend
,
err
:=
dao
.
EmailSendDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
...
...
@@ -137,28 +105,28 @@ func (x *emailSendService) GetByID(ctx context.Context, id xsf.ID, opts *biz.Ema
}
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
}
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
}
emailSendBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
emailSendBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendBizSlice
)
==
0
{
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
nil
}
emailSendBizIDMap
:=
biz
.
EmailSendTool
.
SliceToIDMapBiz
(
emailSendBizSlice
)
...
...
@@ -170,8 +138,8 @@ func (x *emailSendService) Page(ctx context.Context, in *types.EmailSendPageReq,
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailSends
)
==
0
{
return
nil
,
total
,
nil
if
len
(
emailSends
)
==
0
{
return
nil
,
total
,
nil
}
emailSendBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
if
err
!=
nil
{
...
...
@@ -184,91 +152,91 @@ func (x *emailSendService) GetSliceByState(ctx context.Context, state enums.Emai
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
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
}
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
{
return
nil
,
err
}
if
len
(
emailSendMapSlice
)
==
0
{
if
len
(
emailSendMapSlice
)
==
0
{
return
nil
,
nil
}
emailSends
:=
make
([]
*
models
.
EmailSend
,
0
,
size
)
for
_
,
v
:=
range
emailSendMapSlice
{
emailSends
=
append
(
emailSends
,
v
...
)
emailSends
:=
make
([]
*
models
.
EmailSend
,
0
,
size
)
for
_
,
v
:=
range
emailSendMapSlice
{
emailSends
=
append
(
emailSends
,
v
...
)
}
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
)
{
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
if
len
(
states
)
==
0
{
return
nil
,
0
,
nil
}
emailSendBizSlice
,
err
:=
x
.
GetSliceByStates
(
ctx
,
states
,
opts
)
emailSendBizSlice
,
err
:=
x
.
GetSliceByStates
(
ctx
,
states
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
enums
.
EmailSend_State_Enum
][]
*
biz
.
EmailSend
)
for
_
,
r
:=
range
emailSendBizSlice
{
ret
[
r
.
State
]
=
append
(
ret
[
r
.
State
],
r
)
for
_
,
r
:=
range
emailSendBizSlice
{
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
)
{
if
emailID
==
0
{
func
(
x
*
emailSendService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
emailID
==
0
{
return
nil
,
nil
}
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetSliceByEmailID
(
ctx
,
models
.
EmailSendTool
.
GetOrder
(),
emailID
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
}
func
(
x
*
emailSendService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
emailIDs
)
==
0
{
func
(
x
*
emailSendService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
emailIDs
)
==
0
{
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
{
return
nil
,
err
}
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
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
)
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
func
(
x
*
emailSendService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSend
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
}
emailSendBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
emailSendBizSlice
,
err
:=
x
.
GetSliceByEmailIDs
(
ctx
,
emailIDs
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSend
)
for
_
,
r
:=
range
emailSendBizSlice
{
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
for
_
,
r
:=
range
emailSendBizSlice
{
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
)
{
...
...
@@ -296,30 +264,30 @@ func (x *emailSendService) ToSliceBiz(ctx context.Context, emailSends []*models.
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
return
nil
}
func
(
x
*
emailSendService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendOpts
)
(
[]
*
biz
.
EmailSend
,
error
)
{
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetAll
(
ctx
)
func
(
x
*
emailSendService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendOpts
)
(
[]
*
biz
.
EmailSend
,
error
)
{
emailSends
,
err
:=
dao
.
EmailSendDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSends
)
==
0
{
if
len
(
emailSends
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailSends
,
opts
)
...
...
pkg/email/service/email_send_log.go
浏览文件 @
a4765858
package
service
import
(
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"operator-qt/internal/modules/operator/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
type
emailSendLogService
struct
{
...
...
@@ -30,7 +29,7 @@ func newEmailSendLogService() *emailSendLogService {
}
}
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
{}
_
=
copier
.
Copy
(
emailSendLog
,
in
)
emailSendLog
.
ID
=
xsfUtils
.
EmailSendLogID
(
ctx
)
...
...
@@ -50,22 +49,8 @@ func (x *emailSendLogService) DeleteByID(ctx context.Context, id xsf.ID, opts *b
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
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
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
}
emailSendLogUpd
:=
&
models
.
EmailSendLog
{}
_
=
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
)
{
if
id
<=
0
{
return
nil
,
nil
...
...
@@ -102,7 +70,7 @@ func (x *emailSendLogService) ErrFound(ctx context.Context, id xsf.ID, opts *biz
return
nil
,
err
}
if
emailSendLogBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendLogAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendLogAlreadyExists
}
return
emailSendLogBiz
,
nil
}
...
...
@@ -116,15 +84,14 @@ func (x *emailSendLogService) ErrNotFound(ctx context.Context, id xsf.ID, opts *
return
nil
,
err
}
if
emailSendLogBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailSendLogNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailSendLogNotFound
}
return
emailSendLogBiz
,
nil
}
func
(
x
*
emailSendLogService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
func
(
x
*
emailSendLogService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
}
emailSendLog
,
err
:=
dao
.
EmailSendLogDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
...
...
@@ -137,28 +104,28 @@ func (x *emailSendLogService) GetByID(ctx context.Context, id xsf.ID, opts *biz.
}
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
}
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
}
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendLogBizSlice
)
==
0
{
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
nil
}
emailSendLogBizIDMap
:=
biz
.
EmailSendLogTool
.
SliceToIDMapBiz
(
emailSendLogBizSlice
)
...
...
@@ -170,8 +137,8 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
total
,
nil
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
total
,
nil
}
emailSendLogBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
if
err
!=
nil
{
...
...
@@ -179,96 +146,50 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
}
return
emailSendLogBizSlice
,
total
,
nil
}
func
(
x
*
emailSendLogService
)
GetSliceByState
(
ctx
context
.
Context
,
state
enums
.
EmailSendLog_State_Enum
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByState
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
state
)
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
{
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
emailSendID
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
emailSendID
==
0
{
return
nil
,
nil
}
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetSliceByEmailSendID
(
ctx
,
models
.
EmailSendLogTool
.
GetOrder
(),
emailSendID
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
}
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
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
{
return
nil
,
err
}
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
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
)
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
0
,
nil
func
(
x
*
emailSendLogService
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailSendLogOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSendLog
,
int
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
0
,
nil
}
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByEmailSendIDs
(
ctx
,
emailSendIDs
,
opts
)
emailSendLogBizSlice
,
err
:=
x
.
GetSliceByEmailSendIDs
(
ctx
,
emailSendIDs
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailSendLog
)
for
_
,
r
:=
range
emailSendLogBizSlice
{
ret
[
r
.
EmailSendID
]
=
append
(
ret
[
r
.
EmailSendID
],
r
)
for
_
,
r
:=
range
emailSendLogBizSlice
{
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
)
{
...
...
@@ -296,30 +217,30 @@ func (x *emailSendLogService) ToSliceBiz(ctx context.Context, emailSendLogs []*m
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
return
nil
}
func
(
x
*
emailSendLogService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendLogOpts
)
(
[]
*
biz
.
EmailSendLog
,
error
)
{
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetAll
(
ctx
)
func
(
x
*
emailSendLogService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailSendLogOpts
)
(
[]
*
biz
.
EmailSendLog
,
error
)
{
emailSendLogs
,
err
:=
dao
.
EmailSendLogDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailSendLogs
)
==
0
{
if
len
(
emailSendLogs
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
,
opts
)
...
...
pkg/email/service/email_tpl.go
浏览文件 @
a4765858
package
service
import
(
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
type
emailTplService
struct
{
...
...
@@ -29,7 +29,7 @@ func newEmailTplService() *emailTplService {
}
}
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
{}
_
=
copier
.
Copy
(
emailTpl
,
in
)
emailTpl
.
ID
=
xsfUtils
.
EmailTplID
(
ctx
)
...
...
@@ -49,22 +49,8 @@ func (x *emailTplService) DeleteByID(ctx context.Context, id xsf.ID, opts *biz.E
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
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
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
}
emailTplUpd
:=
&
models
.
EmailTpl
{}
_
=
copier
.
Copy
(
emailTplUpd
,
in
)
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
)
return
dao
.
EmailTplDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplUpd
)
}
func
(
x
*
emailTplService
)
ErrFound
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
...
...
@@ -101,7 +70,7 @@ func (x *emailTplService) ErrFound(ctx context.Context, id xsf.ID, opts *biz.Ema
return
nil
,
err
}
if
emailTplBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplAlreadyExists
}
return
emailTplBiz
,
nil
}
...
...
@@ -115,15 +84,14 @@ func (x *emailTplService) ErrNotFound(ctx context.Context, id xsf.ID, opts *biz.
return
nil
,
err
}
if
emailTplBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplNotFound
}
return
emailTplBiz
,
nil
}
func
(
x
*
emailTplService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
func
(
x
*
emailTplService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplOpts
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
}
emailTpl
,
err
:=
dao
.
EmailTplDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
...
...
@@ -135,29 +103,43 @@ func (x *emailTplService) GetByID(ctx context.Context, id xsf.ID, opts *biz.Emai
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
)
}
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
}
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTpls
)
==
0
{
return
nil
,
nil
if
len
(
emailTpls
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
}
emailTplBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
emailTplBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTplBizSlice
)
==
0
{
if
len
(
emailTplBizSlice
)
==
0
{
return
nil
,
nil
}
emailTplBizIDMap
:=
biz
.
EmailTplTool
.
SliceToIDMapBiz
(
emailTplBizSlice
)
...
...
@@ -169,8 +151,8 @@ func (x *emailTplService) Page(ctx context.Context, in *types.EmailTplPageReq, o
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailTpls
)
==
0
{
return
nil
,
total
,
nil
if
len
(
emailTpls
)
==
0
{
return
nil
,
total
,
nil
}
emailTplBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
if
err
!=
nil
{
...
...
@@ -204,30 +186,30 @@ func (x *emailTplService) ToSliceBiz(ctx context.Context, emailTpls []*models.Em
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
return
nil
}
func
(
x
*
emailTplService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplOpts
)
(
[]
*
biz
.
EmailTpl
,
error
)
{
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetAll
(
ctx
)
func
(
x
*
emailTplService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplOpts
)
(
[]
*
biz
.
EmailTpl
,
error
)
{
emailTpls
,
err
:=
dao
.
EmailTplDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTpls
)
==
0
{
if
len
(
emailTpls
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
,
opts
)
...
...
pkg/email/service/email_tpl_receiver.go
浏览文件 @
a4765858
package
service
import
(
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
xsfUtils
"operator-qt/internal/modules/operator/utils/xsf_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/dao"
"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"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
)
type
emailTplReceiverService
struct
{
...
...
@@ -29,7 +29,7 @@ func newEmailTplReceiverService() *emailTplReceiverService {
}
}
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
{}
_
=
copier
.
Copy
(
emailTplReceiver
,
in
)
emailTplReceiver
.
ID
=
xsfUtils
.
EmailTplReceiverID
(
ctx
)
...
...
@@ -49,22 +49,8 @@ func (x *emailTplReceiverService) DeleteByID(ctx context.Context, id xsf.ID, opt
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
{
if
in
.
ID
<=
0
{
if
in
.
ID
<=
0
{
return
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
}
emailTplReceiverUpd
:=
&
models
.
EmailTplReceiver
{}
_
=
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
)
{
if
id
<=
0
{
return
nil
,
nil
...
...
@@ -101,7 +70,7 @@ func (x *emailTplReceiverService) ErrFound(ctx context.Context, id xsf.ID, opts
return
nil
,
err
}
if
emailTplReceiverBiz
!=
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplReceiverAlreadyExists
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplReceiverAlreadyExists
}
return
emailTplReceiverBiz
,
nil
}
...
...
@@ -115,15 +84,14 @@ func (x *emailTplReceiverService) ErrNotFound(ctx context.Context, id xsf.ID, op
return
nil
,
err
}
if
emailTplReceiverBiz
==
nil
{
return
nil
,
xerror
.
NewC
(
ecode
.
ErrEmailTplReceiverNotFound
.
ToXerror
())
return
nil
,
ecode
.
ErrEmailTplReceiverNotFound
}
return
emailTplReceiverBiz
,
nil
}
func
(
x
*
emailTplReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
func
(
x
*
emailTplReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
return
nil
,
nil
}
emailTplReceiver
,
err
:=
dao
.
EmailTplReceiverDao
.
GetByID
(
ctx
,
id
)
if
err
!=
nil
{
...
...
@@ -136,28 +104,28 @@ func (x *emailTplReceiverService) GetByID(ctx context.Context, id xsf.ID, opts *
}
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
}
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
}
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
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
}
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByIDs
(
ctx
,
ids
,
opts
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTplReceiverBizSlice
)
==
0
{
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
,
nil
}
emailTplReceiverBizIDMap
:=
biz
.
EmailTplReceiverTool
.
SliceToIDMapBiz
(
emailTplReceiverBizSlice
)
...
...
@@ -169,8 +137,8 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
total
,
nil
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
total
,
nil
}
emailTplReceiverBizSlice
,
err
:=
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
if
err
!=
nil
{
...
...
@@ -178,50 +146,50 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
}
return
emailTplReceiverBizSlice
,
total
,
nil
}
func
(
x
*
emailTplReceiverService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
tplID
==
0
{
func
(
x
*
emailTplReceiverService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
tplID
==
0
{
return
nil
,
nil
}
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetSliceByTplID
(
ctx
,
models
.
EmailTplReceiverTool
.
GetOrder
(),
tplID
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
}
func
(
x
*
emailTplReceiverService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
tplIDs
)
==
0
{
func
(
x
*
emailTplReceiverService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
tplIDs
)
==
0
{
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
{
return
nil
,
err
}
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
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
)
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
func
(
x
*
emailTplReceiverService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
map
[
xsf
.
ID
][]
*
biz
.
EmailTplReceiver
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
}
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
emailTplReceiverBizSlice
,
err
:=
x
.
GetSliceByTplIDs
(
ctx
,
tplIDs
,
opts
)
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
}
ret
:=
make
(
map
[
xsf
.
ID
][]
*
biz
.
EmailTplReceiver
)
for
_
,
r
:=
range
emailTplReceiverBizSlice
{
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
for
_
,
r
:=
range
emailTplReceiverBizSlice
{
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
)
{
...
...
@@ -249,30 +217,30 @@ func (x *emailTplReceiverService) ToSliceBiz(ctx context.Context, emailTplReceiv
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
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
{
return
nil
}
if
opts
!=
nil
{
if
opts
!=
nil
{
}
return
nil
}
func
(
x
*
emailTplReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
[]
*
biz
.
EmailTplReceiver
,
error
)
{
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetAll
(
ctx
)
func
(
x
*
emailTplReceiverService
)
GetAll
(
ctx
context
.
Context
,
opts
*
biz
.
EmailTplReceiverOpts
)
(
[]
*
biz
.
EmailTplReceiver
,
error
)
{
emailTplReceivers
,
err
:=
dao
.
EmailTplReceiverDao
.
GetAll
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
emailTplReceivers
)
==
0
{
if
len
(
emailTplReceivers
)
==
0
{
return
nil
,
nil
}
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
,
opts
)
...
...
pkg/email/types/email.go
浏览文件 @
a4765858
package
types
import
(
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"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/
utils/xtime
"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/xerrors/xerror
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
)
var
_
xtime
.
DateTime
// EmailCreateReq request params 邮件
...
...
@@ -18,11 +20,12 @@ type EmailCreateReq struct {
}
func
(
x
*
EmailCreateReq
)
Valid
()
error
{
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
return
nil
}
// EmailGetByTplIDReq request params
type
EmailGetByTplIDReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
...
...
@@ -47,7 +50,7 @@ func (x *EmailUpdateByIDReq) Valid() error {
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
return
nil
...
...
@@ -65,7 +68,7 @@ func (x *EmailUpdateByIDsReq) Valid() error {
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
return
nil
...
...
@@ -114,7 +117,6 @@ func (EmailExportReq) TableName() string {
type
EmailObjDetail
struct
{
biz
.
Email
}
var
EmailObjDetailTool
=
EmailObjDetail
{}
...
...
@@ -124,7 +126,7 @@ func (x EmailObjDetail) NewFromBiz(emailBiz *biz.Email) *EmailObjDetail {
return
nil
}
return
&
EmailObjDetail
{
Email
:
*
emailBiz
,
Email
:
*
emailBiz
,
}
}
...
...
pkg/email/types/email_receiver.go
浏览文件 @
a4765858
package
types
import
(
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"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/
utils/xtime
"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/xerrors/xerror
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
)
var
_
xtime
.
DateTime
// EmailReceiverCreateReq request params 邮件收件人
...
...
@@ -17,11 +19,12 @@ type EmailReceiverCreateReq struct {
}
func
(
x
*
EmailReceiverCreateReq
)
Valid
()
error
{
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
return
nil
}
// EmailReceiverGetByEmailIDReq request params
type
EmailReceiverGetByEmailIDReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
...
...
@@ -45,7 +48,7 @@ func (x *EmailReceiverUpdateByIDReq) Valid() error {
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
return
nil
...
...
@@ -62,7 +65,7 @@ func (x *EmailReceiverUpdateByIDsReq) Valid() error {
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
return
nil
...
...
@@ -109,7 +112,6 @@ func (EmailReceiverExportReq) TableName() string {
type
EmailReceiverObjDetail
struct
{
biz
.
EmailReceiver
}
var
EmailReceiverObjDetailTool
=
EmailReceiverObjDetail
{}
...
...
@@ -119,7 +121,7 @@ func (x EmailReceiverObjDetail) NewFromBiz(emailReceiverBiz *biz.EmailReceiver)
return
nil
}
return
&
EmailReceiverObjDetail
{
EmailReceiver
:
*
emailReceiverBiz
,
EmailReceiver
:
*
emailReceiverBiz
,
}
}
...
...
pkg/email/types/email_send.go
浏览文件 @
a4765858
package
types
import
(
"
operator-qt/internal/modules/operator
/biz"
"
operator-qt/internal/modules/operator/model
s"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/
xerrors/xerror
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/
pkg/
errcode"
"
gitlab.wanzhuangkj.com/tush/xpkg/pkg/email
/biz"
"
gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enum
s"
"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/
utils/xtime
"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/xerrors/xerror
"
"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/xtime"
)
var
_
xtime
.
DateTime
// EmailSendCreateReq request params 邮件发送
...
...
@@ -19,7 +21,7 @@ type EmailSendCreateReq struct {
}
func
(
x
*
EmailSendCreateReq
)
Valid
()
error
{
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
...
...
@@ -27,6 +29,7 @@ func (x *EmailSendCreateReq) Valid() error {
}
return
nil
}
// EmailSendGetByEmailIDReq request params
type
EmailSendGetByEmailIDReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
...
...
@@ -38,6 +41,7 @@ func (x *EmailSendGetByEmailIDReq) Valid() error {
}
return
nil
}
// EmailSendGetByStateReq request params
type
EmailSendGetByStateReq
struct
{
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
...
...
@@ -61,7 +65,7 @@ func (x *EmailSendUpdateByIDReq) Valid() error {
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
...
...
@@ -81,7 +85,7 @@ func (x *EmailSendUpdateByIDsReq) Valid() error {
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
if
x
.
EmailID
<=
0
{
if
x
.
EmailID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailID]不合法"
)
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSend_State_Enums_ALL
,
x
.
State
)
{
...
...
@@ -142,7 +146,7 @@ func (x EmailSendObjDetail) NewFromBiz(emailSendBiz *biz.EmailSend) *EmailSendOb
return
nil
}
return
&
EmailSendObjDetail
{
EmailSend
:
*
emailSendBiz
,
EmailSend
:
*
emailSendBiz
,
StateZh
:
emailSendBiz
.
State
.
Desc
(),
}
}
...
...
pkg/email/types/email_send_log.go
浏览文件 @
a4765858
package
types
import
(
"
operator-qt/internal/modules/operator
/biz"
"
operator-qt/internal/modules/operator/model
s"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/
xerrors/xerror
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/
pkg/
errcode"
"
gitlab.wanzhuangkj.com/tush/xpkg/pkg/email
/biz"
"
gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enum
s"
"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/
utils/xtime
"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/xerrors/xerror
"
"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/xtime"
)
var
_
xtime
.
DateTime
// EmailSendLogCreateReq request params 邮件发送记录
...
...
@@ -19,7 +21,7 @@ type EmailSendLogCreateReq struct {
}
func
(
x
*
EmailSendLogCreateReq
)
Valid
()
error
{
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
...
...
@@ -27,6 +29,7 @@ func (x *EmailSendLogCreateReq) Valid() error {
}
return
nil
}
// EmailSendLogGetByEmailSendIDReq request params
type
EmailSendLogGetByEmailSendIDReq
struct
{
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
//邮件发送id
...
...
@@ -38,6 +41,7 @@ func (x *EmailSendLogGetByEmailSendIDReq) Valid() error {
}
return
nil
}
// EmailSendLogGetByStateReq request params
type
EmailSendLogGetByStateReq
struct
{
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
...
...
@@ -61,7 +65,7 @@ func (x *EmailSendLogUpdateByIDReq) Valid() error {
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
...
...
@@ -81,7 +85,7 @@ func (x *EmailSendLogUpdateByIDsReq) Valid() error {
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
if
x
.
EmailSendID
<=
0
{
if
x
.
EmailSendID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[emailSendID]不合法"
)
}
if
sliceUtils
.
NotContains
(
enums
.
EmailSendLog_State_Enums_ALL
,
x
.
State
)
{
...
...
@@ -142,7 +146,7 @@ func (x EmailSendLogObjDetail) NewFromBiz(emailSendLogBiz *biz.EmailSendLog) *Em
return
nil
}
return
&
EmailSendLogObjDetail
{
EmailSendLog
:
*
emailSendLogBiz
,
EmailSendLog
:
*
emailSendLogBiz
,
StateZh
:
emailSendLogBiz
.
State
.
Desc
(),
}
}
...
...
pkg/email/types/email_tpl.go
浏览文件 @
a4765858
package
types
import
(
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"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/
utils/xtime
"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/xerrors/xerror
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
)
var
_
xtime
.
DateTime
// EmailTplCreateReq request params 邮件模板
...
...
@@ -89,7 +91,6 @@ func (EmailTplExportReq) TableName() string {
type
EmailTplObjDetail
struct
{
biz
.
EmailTpl
}
var
EmailTplObjDetailTool
=
EmailTplObjDetail
{}
...
...
@@ -99,7 +100,7 @@ func (x EmailTplObjDetail) NewFromBiz(emailTplBiz *biz.EmailTpl) *EmailTplObjDet
return
nil
}
return
&
EmailTplObjDetail
{
EmailTpl
:
*
emailTplBiz
,
EmailTpl
:
*
emailTplBiz
,
}
}
...
...
pkg/email/types/email_tpl_receiver.go
浏览文件 @
a4765858
package
types
import
(
"operator-qt/internal/modules/operator/biz"
"operator-qt/internal/modules/operator/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"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/
utils/xtime
"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/xerrors/xerror
"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xtime"
)
var
_
xtime
.
DateTime
// EmailTplReceiverCreateReq request params 邮件模板收件人
...
...
@@ -17,11 +19,12 @@ type EmailTplReceiverCreateReq struct {
}
func
(
x
*
EmailTplReceiverCreateReq
)
Valid
()
error
{
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
return
nil
}
// EmailTplReceiverGetByTplIDReq request params
type
EmailTplReceiverGetByTplIDReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
...
...
@@ -45,7 +48,7 @@ func (x *EmailTplReceiverUpdateByIDReq) Valid() error {
if
x
.
ID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[id]不合法"
)
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
return
nil
...
...
@@ -62,7 +65,7 @@ func (x *EmailTplReceiverUpdateByIDsReq) Valid() error {
if
len
(
x
.
IDs
)
==
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[ids]不能为空"
)
}
if
x
.
TplID
<=
0
{
if
x
.
TplID
<=
0
{
return
xerror
.
NewC
(
errcode
.
InvalidParams
.
Code
(),
"参数[tplID]不合法"
)
}
return
nil
...
...
@@ -109,7 +112,6 @@ func (EmailTplReceiverExportReq) TableName() string {
type
EmailTplReceiverObjDetail
struct
{
biz
.
EmailTplReceiver
}
var
EmailTplReceiverObjDetailTool
=
EmailTplReceiverObjDetail
{}
...
...
@@ -119,7 +121,7 @@ func (x EmailTplReceiverObjDetail) NewFromBiz(emailTplReceiverBiz *biz.EmailTplR
return
nil
}
return
&
EmailTplReceiverObjDetail
{
EmailTplReceiver
:
*
emailTplReceiverBiz
,
EmailTplReceiver
:
*
emailTplReceiverBiz
,
}
}
...
...
pkg/email/xsf_utils/xsf_utils.go
浏览文件 @
a4765858
...
...
@@ -3,14 +3,13 @@ package xsfUtils
import
(
"context"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"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/xsf"
)
const
(
bizTag_agent
=
"qt.operator.agent.id"
bizTag_agent_operator
=
"qt.operator.agent.operator.id"
...
...
@@ -39,93 +38,95 @@ const (
bizTag_web_log
=
"qt.operator.web.log.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
)
}
func
agent_o
peratorID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
AgentO
peratorID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
app_m
oduleID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
AppM
oduleID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
cron_j
obID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
CronJ
obID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
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
)
}
func
e
mailID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
E
mailID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
email_s
endID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailS
endID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
email_t
plID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
EmailT
plID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
i
ntakeID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
I
ntakeID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
platform_c
onfigID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
PlatformC
onfigID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
s
iteID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
S
iteID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
site_u
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
SiteU
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
u
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
U
serID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
func
web_l
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
func
WebL
ogID
(
ctx
context
.
Context
)
xsf
.
ID
{
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
)
}
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
{
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
}
// 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.api.notify.id',100000,2000,'qt.operator.api.notify.id');
...
...
pkg/eventbus/init.go
浏览文件 @
a4765858
...
...
@@ -5,6 +5,7 @@ var Eb = New()
const
(
TopicParseConf
string
=
"event:application:conf:init"
//
TopicParseConfFinish
string
=
"event:application:conf:init:finish"
//
TopicConfChange
string
=
"event:application:conf:change"
//
TopicLoggerInit
string
=
"event:application:logger:init"
//
TopicLoggerInitFinish
string
=
"event:application:logger:init:finish"
//
TopicDBInit
string
=
"event:application:database:init"
//
...
...
utils/dxsf/dxsf.go
浏览文件 @
a4765858
...
...
@@ -49,7 +49,7 @@ func Init() error {
}
}
}
logger
.
Infof
(
"[dxsf] type: %s"
,
config
.
Cfg
.
App
.
IDGeneration
.
Type
)
return
nil
}
...
...
utils/xsf/xsf.go
浏览文件 @
a4765858
...
...
@@ -9,7 +9,9 @@ import (
"time"
"github.com/bwmarrin/snowflake"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
...
...
@@ -98,6 +100,7 @@ func Init() error {
return
e
}
node
=
nod
logger
.
Info
(
"[xsf] node "
+
cast
.
ToString
(
n
))
return
nil
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论