Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xpkg
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
屠思豪
xpkg
Commits
fc02815e
提交
fc02815e
authored
12月 12, 2025
作者:
mooncake
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
ff4eee31
隐藏空白字符变更
内嵌
并排
正在显示
62 个修改的文件
包含
482 行增加
和
721 行删除
+482
-721
init_app.go
application/init_app.go
+17
-15
config.go
config/config.go
+14
-14
xpkg.yaml
config/xpkg.yaml
+0
-8
auth.go
gin/middleware/auth.go
+2
-2
request.go
gin/request/request.go
+6
-6
email.go
pkg/email/biz/email.go
+6
-6
email_receiver.go
pkg/email/biz/email_receiver.go
+6
-6
email_send.go
pkg/email/biz/email_send.go
+6
-6
email_send_log.go
pkg/email/biz/email_send_log.go
+6
-6
email_tpl.go
pkg/email/biz/email_tpl.go
+4
-4
email_tpl_receiver.go
pkg/email/biz/email_tpl_receiver.go
+6
-6
email.go
pkg/email/dao/email.go
+6
-5
email_receiver.go
pkg/email/dao/email_receiver.go
+6
-5
email_send.go
pkg/email/dao/email_send.go
+6
-5
email_send_log.go
pkg/email/dao/email_send_log.go
+6
-5
email_tpl_receiver.go
pkg/email/dao/email_tpl_receiver.go
+6
-5
email.go
pkg/email/email.go
+5
-6
email.go
pkg/email/models/email.go
+8
-8
email_receiver.go
pkg/email/models/email_receiver.go
+7
-7
email_send.go
pkg/email/models/email_send.go
+7
-7
email_send_log.go
pkg/email/models/email_send_log.go
+7
-7
email_tpl.go
pkg/email/models/email_tpl.go
+3
-3
email_tpl_receiver.go
pkg/email/models/email_tpl_receiver.go
+7
-7
email.go
pkg/email/service/email.go
+13
-14
email_receiver.go
pkg/email/service/email_receiver.go
+13
-14
email_send.go
pkg/email/service/email_send.go
+13
-14
email_send_log.go
pkg/email/service/email_send_log.go
+13
-14
email_tpl.go
pkg/email/service/email_tpl.go
+9
-10
email_tpl_receiver.go
pkg/email/service/email_tpl_receiver.go
+13
-14
email.go
pkg/email/types/email.go
+13
-13
email_receiver.go
pkg/email/types/email_receiver.go
+12
-12
email_send.go
pkg/email/types/email_send.go
+11
-11
email_send_log.go
pkg/email/types/email_send_log.go
+11
-11
email_tpl.go
pkg/email/types/email_tpl.go
+7
-7
email_tpl_receiver.go
pkg/email/types/email_tpl_receiver.go
+12
-12
xsf_utils.go
pkg/email/xsf_utils/xsf_utils.go
+0
-54
sf.go
pkg/sf/sf.go
+2
-41
ws.go
pkg/ws/ws.go
+17
-17
biz.go
xcommon/biz.go
+7
-7
ocache.go
xcommon/ocache/ocache.go
+10
-10
odao.go
xcommon/odao/odao.go
+23
-23
models.go
xcommon/xmodels/models.go
+17
-17
cron_job.go
xcron/biz/cron_job.go
+3
-3
cron_job_log.go
xcron/biz/cron_job_log.go
+5
-5
cron_job_record.go
xcron/biz/cron_job_record.go
+5
-5
cron_job.go
xcron/dao/cron_job.go
+2
-2
cron_job_log.go
xcron/dao/cron_job_log.go
+5
-5
cron_job_record.go
xcron/dao/cron_job_record.go
+5
-5
cron_job.go
xcron/models/cron_job.go
+3
-3
cron_job_log.go
xcron/models/cron_job_log.go
+7
-7
cron_job_record.go
xcron/models/cron_job_record.go
+7
-7
cron_job.go
xcron/service/cron_job.go
+10
-10
cron_job_log.go
xcron/service/cron_job_log.go
+8
-8
cron_job_record.go
xcron/service/cron_job_record.go
+8
-8
cron_job.go
xcron/types/cron_job.go
+4
-4
cron_job_log.go
xcron/types/cron_job_log.go
+4
-4
cron_job_record.go
xcron/types/cron_job_record.go
+4
-4
ctx.go
xutils/ctxutils/ctx.go
+22
-22
gormutils_test.go
xutils/gormutils/gormutils_test.go
+10
-10
idutils.go
xutils/idutils/idutils.go
+0
-96
web_log.go
xutils/weblogutils/web_log.go
+7
-7
xsf_test.go
xutils/xsf/xsf_test.go
+0
-42
没有找到文件。
application/init_app.go
浏览文件 @
fc02815e
...
@@ -13,14 +13,13 @@ import (
...
@@ -13,14 +13,13 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/global"
"gitlab.wanzhuangkj.com/tush/xpkg/global"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
goutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/goutils"
goutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/goutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/idutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
...
@@ -29,8 +28,8 @@ import (
...
@@ -29,8 +28,8 @@ import (
)
)
func
init
()
{
func
init
()
{
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicParseConf
,
func
(
ctx
context
.
Context
)
{
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicParseConf
,
func
(
ctx
context
.
Context
,
node
int
)
{
parseInit
()
parseInit
(
node
)
})
})
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicLoggerInit
,
func
(
ctx
context
.
Context
)
{
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicLoggerInit
,
func
(
ctx
context
.
Context
)
{
if
err
:=
initLogger
(
config
.
Cfg
);
err
!=
nil
{
if
err
:=
initLogger
(
config
.
Cfg
);
err
!=
nil
{
...
@@ -57,7 +56,7 @@ func init() {
...
@@ -57,7 +56,7 @@ func init() {
})
})
}
}
func
parseInit
()
{
func
parseInit
(
node
int
)
{
if
confType
,
ok
:=
os
.
LookupEnv
(
"CONF_TYPE"
);
(
ok
&&
sliceutils
.
NotContains
([]
string
{
"local"
,
"nacos"
,
"consul"
},
confType
))
||
!
ok
{
if
confType
,
ok
:=
os
.
LookupEnv
(
"CONF_TYPE"
);
(
ok
&&
sliceutils
.
NotContains
([]
string
{
"local"
,
"nacos"
,
"consul"
},
confType
))
||
!
ok
{
return
return
}
}
...
@@ -67,18 +66,20 @@ func parseInit() {
...
@@ -67,18 +66,20 @@ func parseInit() {
}
}
logger
.
Info
(
"[conf] parse conf finish."
)
logger
.
Info
(
"[conf] parse conf finish."
)
if
err
:=
xsf
.
Init
(
);
err
!=
nil
{
if
err
:=
sf
.
Init
(
node
);
err
!=
nil
{
logger
.
Fatal
(
err
.
Error
())
logger
.
Fatal
(
err
.
Error
())
}
}
logger
.
Info
(
"[xsf] initialized."
)
// logger.Info("[xsf] initialized.")
if
err
:=
idutils
.
Init
();
err
!=
nil
{
// if err := idutils.Init(); err != nil {
logger
.
Fatal
(
err
.
Error
())
// logger.Fatal(err.Error())
}
// }
logger
.
Info
(
"[idutils] initialized."
)
logger
.
Info
(
"[idutils] initialized."
)
}
}
type
Application
struct
{
type
Application
struct
{
node
int
app
*
app
.
App
app
*
app
.
App
router
func
()
*
gin
.
Engine
router
func
()
*
gin
.
Engine
}
}
...
@@ -87,7 +88,7 @@ func (x *Application) Run() {
...
@@ -87,7 +88,7 @@ func (x *Application) Run() {
defer
goutils
.
Recover
()
defer
goutils
.
Recover
()
ctx
:=
context
.
TODO
()
ctx
:=
context
.
TODO
()
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConf
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConf
,
x
.
node
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConfFinish
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConfFinish
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInit
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInit
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInitFinish
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInitFinish
)
...
@@ -115,7 +116,7 @@ func (x *Application) Run() {
...
@@ -115,7 +116,7 @@ func (x *Application) Run() {
func
(
x
*
Application
)
Prepare
()
{
func
(
x
*
Application
)
Prepare
()
{
defer
goutils
.
Recover
()
defer
goutils
.
Recover
()
ctx
:=
context
.
TODO
()
ctx
:=
context
.
TODO
()
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConf
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConf
,
x
.
node
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConfFinish
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicParseConfFinish
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInit
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInit
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInitFinish
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicLoggerInitFinish
)
...
@@ -133,12 +134,13 @@ func (x *Application) Prepare() {
...
@@ -133,12 +134,13 @@ func (x *Application) Prepare() {
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicPrintSwagger
)
eventbus
.
Eb
.
Publish
(
ctx
,
eventbus
.
TopicPrintSwagger
)
}
}
func
New
()
*
Application
{
func
New
(
node
int
)
*
Application
{
return
&
Application
{}
return
&
Application
{
node
:
node
}
}
}
func
NewWithRouter
(
router
func
()
*
gin
.
Engine
)
*
Application
{
func
NewWithRouter
(
node
int
,
router
func
()
*
gin
.
Engine
)
*
Application
{
return
&
Application
{
return
&
Application
{
node
:
node
,
router
:
router
,
router
:
router
,
}
}
}
}
...
...
config/config.go
浏览文件 @
fc02815e
...
@@ -128,9 +128,9 @@ type Config struct {
...
@@ -128,9 +128,9 @@ type Config struct {
Content
[]
byte
`yaml:"-" json:"-"`
Content
[]
byte
`yaml:"-" json:"-"`
}
}
type
Snowflake
struct
{
//
type Snowflake struct {
Node
int
`yaml:"node" json:"node" mapstructure:"node"`
//
Node int `yaml:"node" json:"node" mapstructure:"node"`
}
//
}
// 选择哪个配置中心
// 选择哪个配置中心
type
ConfCenter
struct
{
type
ConfCenter
struct
{
...
@@ -238,12 +238,12 @@ type App struct {
...
@@ -238,12 +238,12 @@ type App struct {
Version
string
`yaml:"version" json:"version" mapstructure:"version"`
Version
string
`yaml:"version" json:"version" mapstructure:"version"`
IPRateLimiter
IPRateLimiter
`yaml:"ipRateLimiter" json:"ipRateLimiter" mapstructure:"ipRateLimiter"`
IPRateLimiter
IPRateLimiter
`yaml:"ipRateLimiter" json:"ipRateLimiter" mapstructure:"ipRateLimiter"`
HideSensitiveFields
string
`yaml:"hideSensitiveFields" json:"hideSensitiveFields" mapstructure:"hideSensitiveFields"`
HideSensitiveFields
string
`yaml:"hideSensitiveFields" json:"hideSensitiveFields" mapstructure:"hideSensitiveFields"`
ConfPath
string
`yaml:"-" json:"confPath" mapstructure:"confPath"`
ConfPath
string
`yaml:"-" json:"confPath" mapstructure:"confPath"`
PodName
string
`yaml:"-" json:"podName" mapstructure:"podName"`
PodName
string
`yaml:"-" json:"podName" mapstructure:"podName"`
WebLog
WebLog
`yaml:"webLog" json:"webLog" mapstructure:"webLog"`
WebLog
WebLog
`yaml:"webLog" json:"webLog" mapstructure:"webLog"`
Email
Email
`yaml:"email" json:"email" mapstructure:"email"`
Email
Email
`yaml:"email" json:"email" mapstructure:"email"`
IDGeneration
IDGeneration
`yaml:"idGeneration" json:"idGeneration" mapstructure:"idGeneration"`
//
IDGeneration IDGeneration `yaml:"idGeneration" json:"idGeneration" mapstructure:"idGeneration"`
}
}
type
Middleware
struct
{
type
Middleware
struct
{
...
@@ -266,11 +266,11 @@ type RequestID struct {
...
@@ -266,11 +266,11 @@ type RequestID struct {
Key
string
`yaml:"key" json:"key" mapstructure:"key"`
Key
string
`yaml:"key" json:"key" mapstructure:"key"`
}
}
type
IDGeneration
struct
{
//
type IDGeneration struct {
Type
string
`yaml:"type" json:"type" mapstructure:"type"`
// snowflake or leaf
//
Type string `yaml:"type" json:"type" mapstructure:"type"` // snowflake or leaf
Leaf
Leaf
`yaml:"leaf" json:"leaf" mapstructure:"leaf"`
//
Leaf Leaf `yaml:"leaf" json:"leaf" mapstructure:"leaf"`
Snowflake
Snowflake
`yaml:"snowflake" json:"snowflake" mapstructure:"snowflake"`
//
Snowflake Snowflake `yaml:"snowflake" json:"snowflake" mapstructure:"snowflake"`
}
//
}
type
WebLog
struct
{
type
WebLog
struct
{
Enable
bool
`yaml:"enable" json:"enable" mapstructure:"enable"`
Enable
bool
`yaml:"enable" json:"enable" mapstructure:"enable"`
...
...
config/xpkg.yaml
浏览文件 @
fc02815e
...
@@ -41,14 +41,6 @@ app:
...
@@ -41,14 +41,6 @@ app:
readTimeout
:
2
readTimeout
:
2
writeTimeout
:
2
writeTimeout
:
2
hideSensitiveFields
:
"
smtpPassword"
hideSensitiveFields
:
"
smtpPassword"
idGeneration
:
type
:
leaf
# snowflake leaf
leaf
:
addr
:
http://leaf.qitu
showLog
:
true
retryCount
:
2
snowflake
:
node
:
1
http
:
http
:
port
:
8080
port
:
8080
...
...
gin/middleware/auth.go
浏览文件 @
fc02815e
...
@@ -7,8 +7,8 @@ import (
...
@@ -7,8 +7,8 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
ctxutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
ctxutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
const
(
const
(
...
@@ -95,7 +95,7 @@ func Auth(opts ...JwtOption) gin.HandlerFunc {
...
@@ -95,7 +95,7 @@ func Auth(opts ...JwtOption) gin.HandlerFunc {
return
return
}
}
}
else
{
}
else
{
xsfID
,
_
:=
x
sf
.
ParseString
(
claims
.
UID
)
xsfID
,
_
:=
sf
.
ParseString
(
claims
.
UID
)
c
.
Set
(
ctxutils
.
KeyUID
,
xsfID
)
c
.
Set
(
ctxutils
.
KeyUID
,
xsfID
)
c
.
Set
(
ctxutils
.
KeyUName
,
claims
.
Name
)
c
.
Set
(
ctxutils
.
KeyUName
,
claims
.
Name
)
}
}
...
...
gin/request/request.go
浏览文件 @
fc02815e
...
@@ -4,8 +4,8 @@ import (
...
@@ -4,8 +4,8 @@ import (
"math"
"math"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
const
(
const
(
...
@@ -13,7 +13,7 @@ const (
...
@@ -13,7 +13,7 @@ const (
)
)
var
(
var
(
LastIDMax
=
x
sf
.
ParseInt64
(
math
.
MaxInt64
)
LastIDMax
=
sf
.
ParseInt64
(
math
.
MaxInt64
)
)
)
type
Params
struct
{
type
Params
struct
{
...
@@ -35,7 +35,7 @@ type Conditions struct {
...
@@ -35,7 +35,7 @@ type Conditions struct {
}
}
type
BaseIDReq
struct
{
type
BaseIDReq
struct
{
ID
x
sf
.
ID
`json:"id" comment:"id" encomment:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
// id
ID
sf
.
ID
`json:"id" comment:"id" encomment:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
// id
}
}
func
(
x
*
BaseIDReq
)
Valid
()
error
{
func
(
x
*
BaseIDReq
)
Valid
()
error
{
...
@@ -46,7 +46,7 @@ func (x *BaseIDReq) Valid() error {
...
@@ -46,7 +46,7 @@ func (x *BaseIDReq) Valid() error {
}
}
type
BaseIDsReq
struct
{
type
BaseIDsReq
struct
{
IDs
[]
x
sf
.
ID
`json:"ids" comment:"ids" encomment:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1" binding:"min=1"`
// id list
IDs
[]
sf
.
ID
`json:"ids" comment:"ids" encomment:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1" binding:"min=1"`
// id list
}
}
func
(
x
BaseIDsReq
)
Valid
()
error
{
func
(
x
BaseIDsReq
)
Valid
()
error
{
...
@@ -57,7 +57,7 @@ func (x BaseIDsReq) Valid() error {
...
@@ -57,7 +57,7 @@ func (x BaseIDsReq) Valid() error {
}
}
type
GetByLastIDReq
struct
{
type
GetByLastIDReq
struct
{
LastID
xsf
.
ID
`json:"lastID" form:"lastID" validate:"required" example:"10086"`
// 最后一个id
LastID
sf
.
ID
`json:"lastID" form:"lastID" validate:"required" example:"10086"`
// 最后一个id
Limit
int
`json:"limit" form:"limit" validate:"required" example:"1000"`
// 限制数量
Limit
int
`json:"limit" form:"limit" validate:"required" example:"1000"`
// 限制数量
Sort
string
`json:"sort" form:"sort" example:"id asc"`
// 排序
Sort
string
`json:"sort" form:"sort" example:"id asc"`
// 排序
}
}
...
@@ -66,7 +66,7 @@ func (x *GetByLastIDReq) Valid() error {
...
@@ -66,7 +66,7 @@ func (x *GetByLastIDReq) Valid() error {
return
nil
return
nil
}
}
func
(
r
*
GetByLastIDReq
)
GetLastID
()
x
sf
.
ID
{
func
(
r
*
GetByLastIDReq
)
GetLastID
()
sf
.
ID
{
if
r
.
LastID
<=
0
{
if
r
.
LastID
<=
0
{
r
.
LastID
=
LastIDMax
r
.
LastID
=
LastIDMax
}
}
...
...
pkg/email/biz/email.go
浏览文件 @
fc02815e
...
@@ -2,24 +2,24 @@ package biz
...
@@ -2,24 +2,24 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
Email
struct
{
type
Email
struct
{
models
.
Email
models
.
Email
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
Email
,
Email
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
Email
,
Email
]
}
}
var
EmailTool
=
&
Email
{}
var
EmailTool
=
&
Email
{}
func
(
*
Email
)
GetIDs
(
rs
[]
*
Email
)
[]
x
sf
.
ID
{
func
(
*
Email
)
GetIDs
(
rs
[]
*
Email
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
[
x
sf
.
ID
](
rs
)
return
sliceutils
.
GetIDs
[
sf
.
ID
](
rs
)
}
}
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
x
sf
.
ID
{
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
}
}
...
...
pkg/email/biz/email_receiver.go
浏览文件 @
fc02815e
...
@@ -2,24 +2,24 @@ package biz
...
@@ -2,24 +2,24 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
EmailReceiver
struct
{
type
EmailReceiver
struct
{
models
.
EmailReceiver
models
.
EmailReceiver
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
EmailReceiver
,
EmailReceiver
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
EmailReceiver
,
EmailReceiver
]
}
}
var
EmailReceiverTool
=
&
EmailReceiver
{}
var
EmailReceiverTool
=
&
EmailReceiver
{}
func
(
*
EmailReceiver
)
GetIDs
(
rs
[]
*
EmailReceiver
)
[]
x
sf
.
ID
{
func
(
*
EmailReceiver
)
GetIDs
(
rs
[]
*
EmailReceiver
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
[
x
sf
.
ID
](
rs
)
return
sliceutils
.
GetIDs
[
sf
.
ID
](
rs
)
}
}
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
x
sf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
}
}
...
...
pkg/email/biz/email_send.go
浏览文件 @
fc02815e
...
@@ -2,24 +2,24 @@ package biz
...
@@ -2,24 +2,24 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
EmailSend
struct
{
type
EmailSend
struct
{
models
.
EmailSend
models
.
EmailSend
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
EmailSend
,
EmailSend
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
EmailSend
,
EmailSend
]
}
}
var
EmailSendTool
=
&
EmailSend
{}
var
EmailSendTool
=
&
EmailSend
{}
func
(
*
EmailSend
)
GetIDs
(
rs
[]
*
EmailSend
)
[]
x
sf
.
ID
{
func
(
*
EmailSend
)
GetIDs
(
rs
[]
*
EmailSend
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
[
x
sf
.
ID
](
rs
)
return
sliceutils
.
GetIDs
[
sf
.
ID
](
rs
)
}
}
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
x
sf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
}
}
...
...
pkg/email/biz/email_send_log.go
浏览文件 @
fc02815e
...
@@ -2,24 +2,24 @@ package biz
...
@@ -2,24 +2,24 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
EmailSendLog
struct
{
type
EmailSendLog
struct
{
models
.
EmailSendLog
models
.
EmailSendLog
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
EmailSendLog
,
EmailSendLog
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
EmailSendLog
,
EmailSendLog
]
}
}
var
EmailSendLogTool
=
&
EmailSendLog
{}
var
EmailSendLogTool
=
&
EmailSendLog
{}
func
(
*
EmailSendLog
)
GetIDs
(
rs
[]
*
EmailSendLog
)
[]
x
sf
.
ID
{
func
(
*
EmailSendLog
)
GetIDs
(
rs
[]
*
EmailSendLog
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
[
x
sf
.
ID
](
rs
)
return
sliceutils
.
GetIDs
[
sf
.
ID
](
rs
)
}
}
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
x
sf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailSendID
())
set
.
Add
(
r
.
GetEmailSendID
())
}
}
...
...
pkg/email/biz/email_tpl.go
浏览文件 @
fc02815e
...
@@ -2,20 +2,20 @@ package biz
...
@@ -2,20 +2,20 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
EmailTpl
struct
{
type
EmailTpl
struct
{
models
.
EmailTpl
models
.
EmailTpl
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
EmailTpl
,
EmailTpl
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
EmailTpl
,
EmailTpl
]
}
}
var
EmailTplTool
=
&
EmailTpl
{}
var
EmailTplTool
=
&
EmailTpl
{}
func
(
*
EmailTpl
)
GetIDs
(
rs
[]
*
EmailTpl
)
[]
x
sf
.
ID
{
func
(
*
EmailTpl
)
GetIDs
(
rs
[]
*
EmailTpl
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
[
x
sf
.
ID
](
rs
)
return
sliceutils
.
GetIDs
[
sf
.
ID
](
rs
)
}
}
func
(
EmailTpl
)
NewFromModel
(
m
*
models
.
EmailTpl
)
*
EmailTpl
{
func
(
EmailTpl
)
NewFromModel
(
m
*
models
.
EmailTpl
)
*
EmailTpl
{
...
...
pkg/email/biz/email_tpl_receiver.go
浏览文件 @
fc02815e
...
@@ -2,24 +2,24 @@ package biz
...
@@ -2,24 +2,24 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
EmailTplReceiver
struct
{
type
EmailTplReceiver
struct
{
models
.
EmailTplReceiver
models
.
EmailTplReceiver
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
EmailTplReceiver
,
EmailTplReceiver
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
EmailTplReceiver
,
EmailTplReceiver
]
}
}
var
EmailTplReceiverTool
=
&
EmailTplReceiver
{}
var
EmailTplReceiverTool
=
&
EmailTplReceiver
{}
func
(
*
EmailTplReceiver
)
GetIDs
(
rs
[]
*
EmailTplReceiver
)
[]
x
sf
.
ID
{
func
(
*
EmailTplReceiver
)
GetIDs
(
rs
[]
*
EmailTplReceiver
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
[
x
sf
.
ID
](
rs
)
return
sliceutils
.
GetIDs
[
sf
.
ID
](
rs
)
}
}
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
x
sf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
}
}
...
...
pkg/email/dao/email.go
浏览文件 @
fc02815e
...
@@ -2,9 +2,10 @@ package dao
...
@@ -2,9 +2,10 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailDao
struct
{
type
emailDao
struct
{
...
@@ -13,14 +14,14 @@ type emailDao struct {
...
@@ -13,14 +14,14 @@ type emailDao struct {
var
EmailDao
=
&
emailDao
{}
var
EmailDao
=
&
emailDao
{}
func
(
x
*
emailDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
x
sf
.
ID
)
([]
*
models
.
Email
,
error
)
{
func
(
x
*
emailDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
sf
.
ID
)
([]
*
models
.
Email
,
error
)
{
if
tplID
<=
0
{
if
tplID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
}
}
func
(
x
*
emailDao
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
x
sf
.
ID
)
([]
*
models
.
Email
,
error
)
{
func
(
x
*
emailDao
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
sf
.
ID
)
([]
*
models
.
Email
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -31,7 +32,7 @@ func (x *emailDao) GetSliceByTplIDs(ctx context.Context, order string, tplIDs []
...
@@ -31,7 +32,7 @@ func (x *emailDao) GetSliceByTplIDs(ctx context.Context, order string, tplIDs []
return
emails
,
nil
return
emails
,
nil
}
}
func
(
x
*
emailDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
Email
,
int
,
error
)
{
func
(
x
*
emailDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
Email
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -39,7 +40,7 @@ func (x *emailDao) GetMapSliceByTplIDs(ctx context.Context, order string, tplIDs
...
@@ -39,7 +40,7 @@ func (x *emailDao) GetMapSliceByTplIDs(ctx context.Context, order string, tplIDs
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
Email
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
Email
)
for
_
,
record
:=
range
emails
{
for
_
,
record
:=
range
emails
{
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
}
}
...
...
pkg/email/dao/email_receiver.go
浏览文件 @
fc02815e
...
@@ -2,9 +2,10 @@ package dao
...
@@ -2,9 +2,10 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailReceiverDao
struct
{
type
emailReceiverDao
struct
{
...
@@ -13,14 +14,14 @@ type emailReceiverDao struct {
...
@@ -13,14 +14,14 @@ type emailReceiverDao struct {
var
EmailReceiverDao
=
&
emailReceiverDao
{}
var
EmailReceiverDao
=
&
emailReceiverDao
{}
func
(
x
*
emailReceiverDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
x
sf
.
ID
)
([]
*
models
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
sf
.
ID
)
([]
*
models
.
EmailReceiver
,
error
)
{
if
emailID
<=
0
{
if
emailID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
}
}
func
(
x
*
emailReceiverDao
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
x
sf
.
ID
)
([]
*
models
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverDao
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
sf
.
ID
)
([]
*
models
.
EmailReceiver
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -31,7 +32,7 @@ func (x *emailReceiverDao) GetSliceByEmailIDs(ctx context.Context, order string,
...
@@ -31,7 +32,7 @@ func (x *emailReceiverDao) GetSliceByEmailIDs(ctx context.Context, order string,
return
emailReceivers
,
nil
return
emailReceivers
,
nil
}
}
func
(
x
*
emailReceiverDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
EmailReceiver
,
int
,
error
)
{
func
(
x
*
emailReceiverDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
EmailReceiver
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -39,7 +40,7 @@ func (x *emailReceiverDao) GetMapSliceByEmailIDs(ctx context.Context, order stri
...
@@ -39,7 +40,7 @@ func (x *emailReceiverDao) GetMapSliceByEmailIDs(ctx context.Context, order stri
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
EmailReceiver
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
EmailReceiver
)
for
_
,
record
:=
range
emailReceivers
{
for
_
,
record
:=
range
emailReceivers
{
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
}
}
...
...
pkg/email/dao/email_send.go
浏览文件 @
fc02815e
...
@@ -2,10 +2,11 @@ package dao
...
@@ -2,10 +2,11 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailSendDao
struct
{
type
emailSendDao
struct
{
...
@@ -42,14 +43,14 @@ func (x *emailSendDao) GetMapSliceByStates(ctx context.Context, order string, st
...
@@ -42,14 +43,14 @@ func (x *emailSendDao) GetMapSliceByStates(ctx context.Context, order string, st
}
}
return
emailSendMapSlice
,
len
(
emailSends
),
nil
return
emailSendMapSlice
,
len
(
emailSends
),
nil
}
}
func
(
x
*
emailSendDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
x
sf
.
ID
)
([]
*
models
.
EmailSend
,
error
)
{
func
(
x
*
emailSendDao
)
GetSliceByEmailID
(
ctx
context
.
Context
,
order
string
,
emailID
sf
.
ID
)
([]
*
models
.
EmailSend
,
error
)
{
if
emailID
<=
0
{
if
emailID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_id = ?"
,
emailID
)
}
}
func
(
x
*
emailSendDao
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
x
sf
.
ID
)
([]
*
models
.
EmailSend
,
error
)
{
func
(
x
*
emailSendDao
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
sf
.
ID
)
([]
*
models
.
EmailSend
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -60,7 +61,7 @@ func (x *emailSendDao) GetSliceByEmailIDs(ctx context.Context, order string, ema
...
@@ -60,7 +61,7 @@ func (x *emailSendDao) GetSliceByEmailIDs(ctx context.Context, order string, ema
return
emailSends
,
nil
return
emailSends
,
nil
}
}
func
(
x
*
emailSendDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
EmailSend
,
int
,
error
)
{
func
(
x
*
emailSendDao
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
order
string
,
emailIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
EmailSend
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -68,7 +69,7 @@ func (x *emailSendDao) GetMapSliceByEmailIDs(ctx context.Context, order string,
...
@@ -68,7 +69,7 @@ func (x *emailSendDao) GetMapSliceByEmailIDs(ctx context.Context, order string,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
EmailSend
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
EmailSend
)
for
_
,
record
:=
range
emailSends
{
for
_
,
record
:=
range
emailSends
{
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
itemMap
[
record
.
EmailID
]
=
append
(
itemMap
[
record
.
EmailID
],
record
)
}
}
...
...
pkg/email/dao/email_send_log.go
浏览文件 @
fc02815e
...
@@ -2,10 +2,11 @@ package dao
...
@@ -2,10 +2,11 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailSendLogDao
struct
{
type
emailSendLogDao
struct
{
...
@@ -25,14 +26,14 @@ func (x *emailSendLogDao) GetSliceByStates(ctx context.Context, order string, st
...
@@ -25,14 +26,14 @@ func (x *emailSendLogDao) GetSliceByStates(ctx context.Context, order string, st
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"state IN (?)"
,
states
)
}
}
func
(
x
*
emailSendLogDao
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
order
string
,
emailSendID
x
sf
.
ID
)
([]
*
models
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
order
string
,
emailSendID
sf
.
ID
)
([]
*
models
.
EmailSendLog
,
error
)
{
if
emailSendID
<=
0
{
if
emailSendID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id = ?"
,
emailSendID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"email_send_id = ?"
,
emailSendID
)
}
}
func
(
x
*
emailSendLogDao
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
order
string
,
emailSendIDs
[]
x
sf
.
ID
)
([]
*
models
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
order
string
,
emailSendIDs
[]
sf
.
ID
)
([]
*
models
.
EmailSendLog
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -43,7 +44,7 @@ func (x *emailSendLogDao) GetSliceByEmailSendIDs(ctx context.Context, order stri
...
@@ -43,7 +44,7 @@ func (x *emailSendLogDao) GetSliceByEmailSendIDs(ctx context.Context, order stri
return
emailSendLogs
,
nil
return
emailSendLogs
,
nil
}
}
func
(
x
*
emailSendLogDao
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
order
string
,
emailSendIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
EmailSendLog
,
int
,
error
)
{
func
(
x
*
emailSendLogDao
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
order
string
,
emailSendIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
EmailSendLog
,
int
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -51,7 +52,7 @@ func (x *emailSendLogDao) GetMapSliceByEmailSendIDs(ctx context.Context, order s
...
@@ -51,7 +52,7 @@ func (x *emailSendLogDao) GetMapSliceByEmailSendIDs(ctx context.Context, order s
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
EmailSendLog
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
EmailSendLog
)
for
_
,
record
:=
range
emailSendLogs
{
for
_
,
record
:=
range
emailSendLogs
{
itemMap
[
record
.
EmailSendID
]
=
append
(
itemMap
[
record
.
EmailSendID
],
record
)
itemMap
[
record
.
EmailSendID
]
=
append
(
itemMap
[
record
.
EmailSendID
],
record
)
}
}
...
...
pkg/email/dao/email_tpl_receiver.go
浏览文件 @
fc02815e
...
@@ -2,9 +2,10 @@ package dao
...
@@ -2,9 +2,10 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailTplReceiverDao
struct
{
type
emailTplReceiverDao
struct
{
...
@@ -13,14 +14,14 @@ type emailTplReceiverDao struct {
...
@@ -13,14 +14,14 @@ type emailTplReceiverDao struct {
var
EmailTplReceiverDao
=
&
emailTplReceiverDao
{}
var
EmailTplReceiverDao
=
&
emailTplReceiverDao
{}
func
(
x
*
emailTplReceiverDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
x
sf
.
ID
)
([]
*
models
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverDao
)
GetSliceByTplID
(
ctx
context
.
Context
,
order
string
,
tplID
sf
.
ID
)
([]
*
models
.
EmailTplReceiver
,
error
)
{
if
tplID
<=
0
{
if
tplID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"tpl_id = ?"
,
tplID
)
}
}
func
(
x
*
emailTplReceiverDao
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
x
sf
.
ID
)
([]
*
models
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverDao
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
sf
.
ID
)
([]
*
models
.
EmailTplReceiver
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -31,7 +32,7 @@ func (x *emailTplReceiverDao) GetSliceByTplIDs(ctx context.Context, order string
...
@@ -31,7 +32,7 @@ func (x *emailTplReceiverDao) GetSliceByTplIDs(ctx context.Context, order string
return
emailTplReceivers
,
nil
return
emailTplReceivers
,
nil
}
}
func
(
x
*
emailTplReceiverDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
EmailTplReceiver
,
int
,
error
)
{
func
(
x
*
emailTplReceiverDao
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
order
string
,
tplIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
EmailTplReceiver
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -39,7 +40,7 @@ func (x *emailTplReceiverDao) GetMapSliceByTplIDs(ctx context.Context, order str
...
@@ -39,7 +40,7 @@ func (x *emailTplReceiverDao) GetMapSliceByTplIDs(ctx context.Context, order str
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
EmailTplReceiver
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
EmailTplReceiver
)
for
_
,
record
:=
range
emailTplReceivers
{
for
_
,
record
:=
range
emailTplReceivers
{
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
itemMap
[
record
.
TplID
]
=
append
(
itemMap
[
record
.
TplID
],
record
)
}
}
...
...
pkg/email/email.go
浏览文件 @
fc02815e
...
@@ -15,10 +15,9 @@ import (
...
@@ -15,10 +15,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/service"
"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/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gorm.io/gorm"
"gorm.io/gorm"
"gopkg.in/gomail.v2"
"gopkg.in/gomail.v2"
...
@@ -126,7 +125,7 @@ var OEmail = &oEmail{}
...
@@ -126,7 +125,7 @@ var OEmail = &oEmail{}
type
Params
struct
{
type
Params
struct
{
UType
int
UType
int
UID
x
sf
.
ID
UID
sf
.
ID
TplCode
string
TplCode
string
TplParams
map
[
string
]
string
TplParams
map
[
string
]
string
Attachments
[]
*
config
.
Attachment
Attachments
[]
*
config
.
Attachment
...
@@ -166,7 +165,7 @@ func (x *oEmail) SendTLS(ctx context.Context, in *Params) (err error) {
...
@@ -166,7 +165,7 @@ func (x *oEmail) SendTLS(ctx context.Context, in *Params) (err error) {
from
:=
fmt
.
Sprintf
(
"%s<%s>"
,
config
.
Cfg
.
Alias
,
config
.
Cfg
.
Addr
)
from
:=
fmt
.
Sprintf
(
"%s<%s>"
,
config
.
Cfg
.
Alias
,
config
.
Cfg
.
Addr
)
email
:=
models
.
Email
{}
email
:=
models
.
Email
{}
email
.
ID
=
xsfutils
.
EmailID
(
ctx
)
email
.
ID
=
sf
.
GenerateID
(
)
email
.
TplID
=
et
.
ID
email
.
TplID
=
et
.
ID
email
.
UType
=
in
.
UType
email
.
UType
=
in
.
UType
email
.
UID
=
in
.
UID
email
.
UID
=
in
.
UID
...
@@ -199,12 +198,12 @@ func (x *oEmail) SendTLS(ctx context.Context, in *Params) (err error) {
...
@@ -199,12 +198,12 @@ func (x *oEmail) SendTLS(ctx context.Context, in *Params) (err error) {
}
}
emailSend
:=
models
.
EmailSend
{}
emailSend
:=
models
.
EmailSend
{}
emailSend
.
ID
=
xsfutils
.
EmailSendID
(
ctx
)
emailSend
.
ID
=
sf
.
GenerateID
(
)
emailSend
.
EmailID
=
email
.
ID
emailSend
.
EmailID
=
email
.
ID
emailSend
.
State
=
enums
.
EmailSend_State_Wait
emailSend
.
State
=
enums
.
EmailSend_State_Wait
emailSendLog
:=
models
.
EmailSendLog
{}
emailSendLog
:=
models
.
EmailSendLog
{}
emailSendLog
.
ID
=
xsfutils
.
EmailSendLogID
(
ctx
)
emailSendLog
.
ID
=
sf
.
GenerateID
(
)
emailSendLog
.
EmailSendID
=
emailSend
.
ID
emailSendLog
.
EmailSendID
=
emailSend
.
ID
emailSendLog
.
State
=
emailSend
.
State
emailSendLog
.
State
=
emailSend
.
State
...
...
pkg/email/models/email.go
浏览文件 @
fc02815e
package
models
package
models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// Email 邮件
// Email 邮件
type
Email
struct
{
type
Email
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
UID
xsf
.
ID
`json:"uid" form:"uid" swaggertype:"string" gorm:"column:uid;type:bigint(20);comment:uid" example:"1" csv:"uid"`
//uid
UID
sf
.
ID
`json:"uid" form:"uid" swaggertype:"string" gorm:"column:uid;type:bigint(20);comment:uid" example:"1" csv:"uid"`
//uid
UType
int
`json:"utype" form:"utype" gorm:"column:utype;type:int(11);comment:utype" example:"1" csv:"utype"`
//utype
UType
int
`json:"utype" form:"utype" gorm:"column:utype;type:int(11);comment:utype" example:"1" csv:"utype"`
//utype
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
From
string
`json:"from" form:"from" gorm:"column:from;type:varchar(255);comment:发件人" example:"月饼<mooncake2026@163.com>" csv:"发件人"`
//发件人
From
string
`json:"from" form:"from" gorm:"column:from;type:varchar(255);comment:发件人" example:"月饼<mooncake2026@163.com>" csv:"发件人"`
//发件人
Subject
string
`json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"主题"`
//主题
Subject
string
`json:"subject" form:"subject" gorm:"column:subject;type:varchar(255);comment:主题" example:"验证码" csv:"主题"`
//主题
Content
string
`json:"content" form:"content" gorm:"column:content;type:text;comment:邮件内容" example:"<div>hello moon! </div>" csv:"邮件内容"`
//邮件内容
Content
string
`json:"content" form:"content" gorm:"column:content;type:text;comment:邮件内容" example:"<div>hello moon! </div>" csv:"邮件内容"`
//邮件内容
...
@@ -26,14 +26,14 @@ func (Email) TableName() string {
...
@@ -26,14 +26,14 @@ func (Email) TableName() string {
return
TBEmail
return
TBEmail
}
}
func
(
x
Email
)
GetID
()
x
sf
.
ID
{
func
(
x
Email
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
Email
)
GetTplID
()
x
sf
.
ID
{
func
(
x
*
Email
)
GetTplID
()
sf
.
ID
{
return
x
.
TplID
return
x
.
TplID
}
}
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
x
sf
.
ID
{
func
(
x
*
Email
)
GetTplIDs
(
rs
[]
*
Email
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
}
}
...
...
pkg/email/models/email_receiver.go
浏览文件 @
fc02815e
package
models
package
models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// EmailReceiver 邮件收件人
// EmailReceiver 邮件收件人
type
EmailReceiver
struct
{
type
EmailReceiver
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
...
@@ -22,14 +22,14 @@ func (EmailReceiver) TableName() string {
...
@@ -22,14 +22,14 @@ func (EmailReceiver) TableName() string {
return
TBEmailReceiver
return
TBEmailReceiver
}
}
func
(
x
EmailReceiver
)
GetID
()
x
sf
.
ID
{
func
(
x
EmailReceiver
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailReceiver
)
GetEmailID
()
x
sf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailID
()
sf
.
ID
{
return
x
.
EmailID
return
x
.
EmailID
}
}
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
x
sf
.
ID
{
func
(
x
*
EmailReceiver
)
GetEmailIDs
(
rs
[]
*
EmailReceiver
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
}
}
...
...
pkg/email/models/email_send.go
浏览文件 @
fc02815e
...
@@ -2,16 +2,16 @@ package models
...
@@ -2,16 +2,16 @@ package models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// EmailSend 邮件发送
// EmailSend 邮件发送
type
EmailSend
struct
{
type
EmailSend
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" gorm:"column:email_id;type:bigint(20);comment:邮件id" example:"1" csv:"邮件id"`
//邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
...
@@ -23,14 +23,14 @@ func (EmailSend) TableName() string {
...
@@ -23,14 +23,14 @@ func (EmailSend) TableName() string {
return
TBEmailSend
return
TBEmailSend
}
}
func
(
x
EmailSend
)
GetID
()
x
sf
.
ID
{
func
(
x
EmailSend
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailSend
)
GetEmailID
()
x
sf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailID
()
sf
.
ID
{
return
x
.
EmailID
return
x
.
EmailID
}
}
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
x
sf
.
ID
{
func
(
x
*
EmailSend
)
GetEmailIDs
(
rs
[]
*
EmailSend
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailID
())
set
.
Add
(
r
.
GetEmailID
())
}
}
...
...
pkg/email/models/email_send_log.go
浏览文件 @
fc02815e
...
@@ -2,16 +2,16 @@ package models
...
@@ -2,16 +2,16 @@ package models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// EmailSendLog 邮件发送记录
// EmailSendLog 邮件发送记录
type
EmailSendLog
struct
{
type
EmailSendLog
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" gorm:"column:email_send_id;type:bigint(20);comment:邮件发送id" example:"1" csv:"邮件发送id"`
//邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" gorm:"column:email_send_id;type:bigint(20);comment:邮件发送id" example:"1" csv:"邮件发送id"`
//邮件发送id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" gorm:"column:state;type:tinyint(4);default:1;comment:发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]" example:"1" csv:"发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]"`
//发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
...
@@ -23,14 +23,14 @@ func (EmailSendLog) TableName() string {
...
@@ -23,14 +23,14 @@ func (EmailSendLog) TableName() string {
return
TBEmailSendLog
return
TBEmailSendLog
}
}
func
(
x
EmailSendLog
)
GetID
()
x
sf
.
ID
{
func
(
x
EmailSendLog
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailSendLog
)
GetEmailSendID
()
x
sf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendID
()
sf
.
ID
{
return
x
.
EmailSendID
return
x
.
EmailSendID
}
}
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
x
sf
.
ID
{
func
(
x
*
EmailSendLog
)
GetEmailSendIDs
(
rs
[]
*
EmailSendLog
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetEmailSendID
())
set
.
Add
(
r
.
GetEmailSendID
())
}
}
...
...
pkg/email/models/email_tpl.go
浏览文件 @
fc02815e
package
models
package
models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/
xutils/x
sf"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/
sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// EmailTpl 邮件模板
// EmailTpl 邮件模板
type
EmailTpl
struct
{
type
EmailTpl
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
Code
string
`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"`
//主题
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:"模板"`
//模板
Tpl
string
`json:"tpl" form:"tpl" gorm:"column:tpl;type:text;comment:模板" example:"<div>hello moon! </div>" csv:"模板"`
//模板
...
@@ -22,7 +22,7 @@ func (EmailTpl) TableName() string {
...
@@ -22,7 +22,7 @@ func (EmailTpl) TableName() string {
return
TBEmailTpl
return
TBEmailTpl
}
}
func
(
x
EmailTpl
)
GetID
()
x
sf
.
ID
{
func
(
x
EmailTpl
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
EmailTpl
)
GetOrder
()
string
{
func
(
x
EmailTpl
)
GetOrder
()
string
{
...
...
pkg/email/models/email_tpl_receiver.go
浏览文件 @
fc02815e
package
models
package
models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// EmailTplReceiver 邮件模板收件人
// EmailTplReceiver 邮件模板收件人
type
EmailTplReceiver
struct
{
type
EmailTplReceiver
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1" csv:"用户主键id"`
//主键
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" gorm:"column:tpl_id;type:bigint(20);comment:模板id" example:"1" csv:"模板id"`
//模板id
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
Receiver
string
`json:"receiver" form:"receiver" gorm:"column:receiver;type:varchar(255);comment:收件人" example:"月饼<mooncake2026@163.com>" csv:"收件人"`
//收件人
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2024-03-27 17:11:00" csv:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2024-03-27 17:11:00" csv:"更新时间"`
//更新时间
...
@@ -22,14 +22,14 @@ func (EmailTplReceiver) TableName() string {
...
@@ -22,14 +22,14 @@ func (EmailTplReceiver) TableName() string {
return
TBEmailTplReceiver
return
TBEmailTplReceiver
}
}
func
(
x
EmailTplReceiver
)
GetID
()
x
sf
.
ID
{
func
(
x
EmailTplReceiver
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
EmailTplReceiver
)
GetTplID
()
x
sf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplID
()
sf
.
ID
{
return
x
.
TplID
return
x
.
TplID
}
}
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
x
sf
.
ID
{
func
(
x
*
EmailTplReceiver
)
GetTplIDs
(
rs
[]
*
EmailTplReceiver
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetTplID
())
set
.
Add
(
r
.
GetTplID
())
}
}
...
...
pkg/email/service/email.go
浏览文件 @
fc02815e
...
@@ -9,10 +9,9 @@ import (
...
@@ -9,10 +9,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfutils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailService
struct
{
type
emailService
struct
{
...
@@ -29,17 +28,17 @@ func newEmailService() *emailService {
...
@@ -29,17 +28,17 @@ func newEmailService() *emailService {
}
}
}
}
func
(
x
*
emailService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
emailService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
email
:=
&
models
.
Email
{}
email
:=
&
models
.
Email
{}
_
=
copier
.
Copy
(
email
,
in
)
_
=
copier
.
Copy
(
email
,
in
)
email
.
ID
=
xsfutils
.
EmailID
(
ctx
)
email
.
ID
=
sf
.
GenerateID
(
)
if
err
=
dao
.
EmailDao
.
Create
(
ctx
,
email
);
err
!=
nil
{
if
err
=
dao
.
EmailDao
.
Create
(
ctx
,
email
);
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
email
.
ID
,
nil
return
email
.
ID
,
nil
}
}
func
(
x
*
emailService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
emailService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -61,7 +60,7 @@ func (x *emailService) UpdateByID(ctx context.Context, in *types.EmailUpdateByID
...
@@ -61,7 +60,7 @@ func (x *emailService) UpdateByID(ctx context.Context, in *types.EmailUpdateByID
return
dao
.
EmailDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailUpd
)
return
dao
.
EmailDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailUpd
)
}
}
func
(
x
*
emailService
)
ErrFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
func
(
x
*
emailService
)
ErrFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -75,7 +74,7 @@ func (x *emailService) ErrFound(ctx context.Context, id xsf.ID) (emailBiz *biz.E
...
@@ -75,7 +74,7 @@ func (x *emailService) ErrFound(ctx context.Context, id xsf.ID) (emailBiz *biz.E
return
emailBiz
,
nil
return
emailBiz
,
nil
}
}
func
(
x
*
emailService
)
ErrNotFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
func
(
x
*
emailService
)
ErrNotFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -89,7 +88,7 @@ func (x *emailService) ErrNotFound(ctx context.Context, id xsf.ID) (emailBiz *bi
...
@@ -89,7 +88,7 @@ func (x *emailService) ErrNotFound(ctx context.Context, id xsf.ID) (emailBiz *bi
return
emailBiz
,
nil
return
emailBiz
,
nil
}
}
func
(
x
*
emailService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
func
(
x
*
emailService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailBiz
*
biz
.
Email
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -103,7 +102,7 @@ func (x *emailService) GetByID(ctx context.Context, id xsf.ID) (emailBiz *biz.Em
...
@@ -103,7 +102,7 @@ func (x *emailService) GetByID(ctx context.Context, id xsf.ID) (emailBiz *biz.Em
return
x
.
ToBiz
(
ctx
,
email
)
return
x
.
ToBiz
(
ctx
,
email
)
}
}
func
(
x
*
emailService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
Email
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -117,7 +116,7 @@ func (x *emailService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*biz.
...
@@ -117,7 +116,7 @@ func (x *emailService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*biz.
return
x
.
ToSliceBiz
(
ctx
,
emails
)
return
x
.
ToSliceBiz
(
ctx
,
emails
)
}
}
func
(
x
*
emailService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
Email
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -146,7 +145,7 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq) ([]*biz
...
@@ -146,7 +145,7 @@ func (x *emailService) Page(ctx context.Context, in *types.EmailPageReq) ([]*biz
}
}
return
emailBizSlice
,
total
,
nil
return
emailBizSlice
,
total
,
nil
}
}
func
(
x
*
emailService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
x
sf
.
ID
)
([]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
sf
.
ID
)
([]
*
biz
.
Email
,
error
)
{
if
tplID
==
0
{
if
tplID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -160,7 +159,7 @@ func (x *emailService) GetSliceByTplID(ctx context.Context, tplID xsf.ID) ([]*bi
...
@@ -160,7 +159,7 @@ func (x *emailService) GetSliceByTplID(ctx context.Context, tplID xsf.ID) ([]*bi
return
x
.
ToSliceBiz
(
ctx
,
emails
)
return
x
.
ToSliceBiz
(
ctx
,
emails
)
}
}
func
(
x
*
emailService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
x
sf
.
ID
)
([]
*
biz
.
Email
,
error
)
{
func
(
x
*
emailService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
sf
.
ID
)
([]
*
biz
.
Email
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -174,7 +173,7 @@ func (x *emailService) GetSliceByTplIDs(ctx context.Context, tplIDs []xsf.ID) ([
...
@@ -174,7 +173,7 @@ func (x *emailService) GetSliceByTplIDs(ctx context.Context, tplIDs []xsf.ID) ([
return
x
.
ToSliceBiz
(
ctx
,
emails
)
return
x
.
ToSliceBiz
(
ctx
,
emails
)
}
}
func
(
x
*
emailService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
Email
,
int
,
error
)
{
func
(
x
*
emailService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
Email
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -185,7 +184,7 @@ func (x *emailService) GetMapSliceByTplIDs(ctx context.Context, tplIDs []xsf.ID)
...
@@ -185,7 +184,7 @@ func (x *emailService) GetMapSliceByTplIDs(ctx context.Context, tplIDs []xsf.ID)
if
len
(
emailBizSlice
)
==
0
{
if
len
(
emailBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
Email
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
Email
)
for
_
,
r
:=
range
emailBizSlice
{
for
_
,
r
:=
range
emailBizSlice
{
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
}
}
...
...
pkg/email/service/email_receiver.go
浏览文件 @
fc02815e
...
@@ -9,10 +9,9 @@ import (
...
@@ -9,10 +9,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfutils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailReceiverService
struct
{
type
emailReceiverService
struct
{
...
@@ -29,17 +28,17 @@ func newEmailReceiverService() *emailReceiverService {
...
@@ -29,17 +28,17 @@ func newEmailReceiverService() *emailReceiverService {
}
}
}
}
func
(
x
*
emailReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
emailReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailReceiverCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
emailReceiver
:=
&
models
.
EmailReceiver
{}
emailReceiver
:=
&
models
.
EmailReceiver
{}
_
=
copier
.
Copy
(
emailReceiver
,
in
)
_
=
copier
.
Copy
(
emailReceiver
,
in
)
emailReceiver
.
ID
=
xsfutils
.
EmailReceiverID
(
ctx
)
emailReceiver
.
ID
=
sf
.
GenerateID
(
)
if
err
=
dao
.
EmailReceiverDao
.
Create
(
ctx
,
emailReceiver
);
err
!=
nil
{
if
err
=
dao
.
EmailReceiverDao
.
Create
(
ctx
,
emailReceiver
);
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
emailReceiver
.
ID
,
nil
return
emailReceiver
.
ID
,
nil
}
}
func
(
x
*
emailReceiverService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
emailReceiverService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -61,7 +60,7 @@ func (x *emailReceiverService) UpdateByID(ctx context.Context, in *types.EmailRe
...
@@ -61,7 +60,7 @@ func (x *emailReceiverService) UpdateByID(ctx context.Context, in *types.EmailRe
return
dao
.
EmailReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailReceiverUpd
)
return
dao
.
EmailReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailReceiverUpd
)
}
}
func
(
x
*
emailReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
func
(
x
*
emailReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -75,7 +74,7 @@ func (x *emailReceiverService) ErrFound(ctx context.Context, id xsf.ID) (emailRe
...
@@ -75,7 +74,7 @@ func (x *emailReceiverService) ErrFound(ctx context.Context, id xsf.ID) (emailRe
return
emailReceiverBiz
,
nil
return
emailReceiverBiz
,
nil
}
}
func
(
x
*
emailReceiverService
)
ErrNotFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
func
(
x
*
emailReceiverService
)
ErrNotFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -89,7 +88,7 @@ func (x *emailReceiverService) ErrNotFound(ctx context.Context, id xsf.ID) (emai
...
@@ -89,7 +88,7 @@ func (x *emailReceiverService) ErrNotFound(ctx context.Context, id xsf.ID) (emai
return
emailReceiverBiz
,
nil
return
emailReceiverBiz
,
nil
}
}
func
(
x
*
emailReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
func
(
x
*
emailReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailReceiverBiz
*
biz
.
EmailReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -103,7 +102,7 @@ func (x *emailReceiverService) GetByID(ctx context.Context, id xsf.ID) (emailRec
...
@@ -103,7 +102,7 @@ func (x *emailReceiverService) GetByID(ctx context.Context, id xsf.ID) (emailRec
return
x
.
ToBiz
(
ctx
,
emailReceiver
)
return
x
.
ToBiz
(
ctx
,
emailReceiver
)
}
}
func
(
x
*
emailReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -117,7 +116,7 @@ func (x *emailReceiverService) GetSliceByIDs(ctx context.Context, ids []xsf.ID)
...
@@ -117,7 +116,7 @@ func (x *emailReceiverService) GetSliceByIDs(ctx context.Context, ids []xsf.ID)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
)
}
}
func
(
x
*
emailReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -146,7 +145,7 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
...
@@ -146,7 +145,7 @@ func (x *emailReceiverService) Page(ctx context.Context, in *types.EmailReceiver
}
}
return
emailReceiverBizSlice
,
total
,
nil
return
emailReceiverBizSlice
,
total
,
nil
}
}
func
(
x
*
emailReceiverService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
x
sf
.
ID
)
([]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
sf
.
ID
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
emailID
==
0
{
if
emailID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -160,7 +159,7 @@ func (x *emailReceiverService) GetSliceByEmailID(ctx context.Context, emailID xs
...
@@ -160,7 +159,7 @@ func (x *emailReceiverService) GetSliceByEmailID(ctx context.Context, emailID xs
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
)
}
}
func
(
x
*
emailReceiverService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
x
sf
.
ID
)
([]
*
biz
.
EmailReceiver
,
error
)
{
func
(
x
*
emailReceiverService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
sf
.
ID
)
([]
*
biz
.
EmailReceiver
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -174,7 +173,7 @@ func (x *emailReceiverService) GetSliceByEmailIDs(ctx context.Context, emailIDs
...
@@ -174,7 +173,7 @@ func (x *emailReceiverService) GetSliceByEmailIDs(ctx context.Context, emailIDs
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
)
return
x
.
ToSliceBiz
(
ctx
,
emailReceivers
)
}
}
func
(
x
*
emailReceiverService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailReceiver
,
int
,
error
)
{
func
(
x
*
emailReceiverService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
EmailReceiver
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -185,7 +184,7 @@ func (x *emailReceiverService) GetMapSliceByEmailIDs(ctx context.Context, emailI
...
@@ -185,7 +184,7 @@ func (x *emailReceiverService) GetMapSliceByEmailIDs(ctx context.Context, emailI
if
len
(
emailReceiverBizSlice
)
==
0
{
if
len
(
emailReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailReceiver
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
EmailReceiver
)
for
_
,
r
:=
range
emailReceiverBizSlice
{
for
_
,
r
:=
range
emailReceiverBizSlice
{
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
}
}
...
...
pkg/email/service/email_send.go
浏览文件 @
fc02815e
...
@@ -10,10 +10,9 @@ import (
...
@@ -10,10 +10,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfutils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailSendService
struct
{
type
emailSendService
struct
{
...
@@ -30,17 +29,17 @@ func newEmailSendService() *emailSendService {
...
@@ -30,17 +29,17 @@ func newEmailSendService() *emailSendService {
}
}
}
}
func
(
x
*
emailSendService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
emailSendService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
emailSend
:=
&
models
.
EmailSend
{}
emailSend
:=
&
models
.
EmailSend
{}
_
=
copier
.
Copy
(
emailSend
,
in
)
_
=
copier
.
Copy
(
emailSend
,
in
)
emailSend
.
ID
=
xsfutils
.
EmailSendID
(
ctx
)
emailSend
.
ID
=
sf
.
GenerateID
(
)
if
err
=
dao
.
EmailSendDao
.
Create
(
ctx
,
emailSend
);
err
!=
nil
{
if
err
=
dao
.
EmailSendDao
.
Create
(
ctx
,
emailSend
);
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
emailSend
.
ID
,
nil
return
emailSend
.
ID
,
nil
}
}
func
(
x
*
emailSendService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
emailSendService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -62,7 +61,7 @@ func (x *emailSendService) UpdateByID(ctx context.Context, in *types.EmailSendUp
...
@@ -62,7 +61,7 @@ func (x *emailSendService) UpdateByID(ctx context.Context, in *types.EmailSendUp
return
dao
.
EmailSendDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendUpd
)
return
dao
.
EmailSendDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendUpd
)
}
}
func
(
x
*
emailSendService
)
ErrFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
func
(
x
*
emailSendService
)
ErrFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -76,7 +75,7 @@ func (x *emailSendService) ErrFound(ctx context.Context, id xsf.ID) (emailSendBi
...
@@ -76,7 +75,7 @@ func (x *emailSendService) ErrFound(ctx context.Context, id xsf.ID) (emailSendBi
return
emailSendBiz
,
nil
return
emailSendBiz
,
nil
}
}
func
(
x
*
emailSendService
)
ErrNotFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
func
(
x
*
emailSendService
)
ErrNotFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -90,7 +89,7 @@ func (x *emailSendService) ErrNotFound(ctx context.Context, id xsf.ID) (emailSen
...
@@ -90,7 +89,7 @@ func (x *emailSendService) ErrNotFound(ctx context.Context, id xsf.ID) (emailSen
return
emailSendBiz
,
nil
return
emailSendBiz
,
nil
}
}
func
(
x
*
emailSendService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
func
(
x
*
emailSendService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailSendBiz
*
biz
.
EmailSend
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -104,7 +103,7 @@ func (x *emailSendService) GetByID(ctx context.Context, id xsf.ID) (emailSendBiz
...
@@ -104,7 +103,7 @@ func (x *emailSendService) GetByID(ctx context.Context, id xsf.ID) (emailSendBiz
return
x
.
ToBiz
(
ctx
,
emailSend
)
return
x
.
ToBiz
(
ctx
,
emailSend
)
}
}
func
(
x
*
emailSendService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -118,7 +117,7 @@ func (x *emailSendService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*
...
@@ -118,7 +117,7 @@ func (x *emailSendService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*
return
x
.
ToSliceBiz
(
ctx
,
emailSends
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
)
}
}
func
(
x
*
emailSendService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
EmailSend
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -193,7 +192,7 @@ func (x *emailSendService) GetMapSliceByStates(ctx context.Context, states []enu
...
@@ -193,7 +192,7 @@ func (x *emailSendService) GetMapSliceByStates(ctx context.Context, states []enu
}
}
return
ret
,
len
(
emailSendBizSlice
),
nil
return
ret
,
len
(
emailSendBizSlice
),
nil
}
}
func
(
x
*
emailSendService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
x
sf
.
ID
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByEmailID
(
ctx
context
.
Context
,
emailID
sf
.
ID
)
([]
*
biz
.
EmailSend
,
error
)
{
if
emailID
==
0
{
if
emailID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -207,7 +206,7 @@ func (x *emailSendService) GetSliceByEmailID(ctx context.Context, emailID xsf.ID
...
@@ -207,7 +206,7 @@ func (x *emailSendService) GetSliceByEmailID(ctx context.Context, emailID xsf.ID
return
x
.
ToSliceBiz
(
ctx
,
emailSends
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
)
}
}
func
(
x
*
emailSendService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
x
sf
.
ID
)
([]
*
biz
.
EmailSend
,
error
)
{
func
(
x
*
emailSendService
)
GetSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
sf
.
ID
)
([]
*
biz
.
EmailSend
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -221,7 +220,7 @@ func (x *emailSendService) GetSliceByEmailIDs(ctx context.Context, emailIDs []xs
...
@@ -221,7 +220,7 @@ func (x *emailSendService) GetSliceByEmailIDs(ctx context.Context, emailIDs []xs
return
x
.
ToSliceBiz
(
ctx
,
emailSends
)
return
x
.
ToSliceBiz
(
ctx
,
emailSends
)
}
}
func
(
x
*
emailSendService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailSend
,
int
,
error
)
{
func
(
x
*
emailSendService
)
GetMapSliceByEmailIDs
(
ctx
context
.
Context
,
emailIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
EmailSend
,
int
,
error
)
{
if
len
(
emailIDs
)
==
0
{
if
len
(
emailIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -232,7 +231,7 @@ func (x *emailSendService) GetMapSliceByEmailIDs(ctx context.Context, emailIDs [
...
@@ -232,7 +231,7 @@ func (x *emailSendService) GetMapSliceByEmailIDs(ctx context.Context, emailIDs [
if
len
(
emailSendBizSlice
)
==
0
{
if
len
(
emailSendBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailSend
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
EmailSend
)
for
_
,
r
:=
range
emailSendBizSlice
{
for
_
,
r
:=
range
emailSendBizSlice
{
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
ret
[
r
.
EmailID
]
=
append
(
ret
[
r
.
EmailID
],
r
)
}
}
...
...
pkg/email/service/email_send_log.go
浏览文件 @
fc02815e
...
@@ -9,10 +9,9 @@ import (
...
@@ -9,10 +9,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfutils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailSendLogService
struct
{
type
emailSendLogService
struct
{
...
@@ -29,17 +28,17 @@ func newEmailSendLogService() *emailSendLogService {
...
@@ -29,17 +28,17 @@ func newEmailSendLogService() *emailSendLogService {
}
}
}
}
func
(
x
*
emailSendLogService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
emailSendLogService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailSendLogCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
emailSendLog
:=
&
models
.
EmailSendLog
{}
emailSendLog
:=
&
models
.
EmailSendLog
{}
_
=
copier
.
Copy
(
emailSendLog
,
in
)
_
=
copier
.
Copy
(
emailSendLog
,
in
)
emailSendLog
.
ID
=
xsfutils
.
EmailSendLogID
(
ctx
)
emailSendLog
.
ID
=
sf
.
GenerateID
(
)
if
err
=
dao
.
EmailSendLogDao
.
Create
(
ctx
,
emailSendLog
);
err
!=
nil
{
if
err
=
dao
.
EmailSendLogDao
.
Create
(
ctx
,
emailSendLog
);
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
emailSendLog
.
ID
,
nil
return
emailSendLog
.
ID
,
nil
}
}
func
(
x
*
emailSendLogService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
emailSendLogService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -61,7 +60,7 @@ func (x *emailSendLogService) UpdateByID(ctx context.Context, in *types.EmailSen
...
@@ -61,7 +60,7 @@ func (x *emailSendLogService) UpdateByID(ctx context.Context, in *types.EmailSen
return
dao
.
EmailSendLogDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendLogUpd
)
return
dao
.
EmailSendLogDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailSendLogUpd
)
}
}
func
(
x
*
emailSendLogService
)
ErrFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
func
(
x
*
emailSendLogService
)
ErrFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -75,7 +74,7 @@ func (x *emailSendLogService) ErrFound(ctx context.Context, id xsf.ID) (emailSen
...
@@ -75,7 +74,7 @@ func (x *emailSendLogService) ErrFound(ctx context.Context, id xsf.ID) (emailSen
return
emailSendLogBiz
,
nil
return
emailSendLogBiz
,
nil
}
}
func
(
x
*
emailSendLogService
)
ErrNotFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
func
(
x
*
emailSendLogService
)
ErrNotFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -89,7 +88,7 @@ func (x *emailSendLogService) ErrNotFound(ctx context.Context, id xsf.ID) (email
...
@@ -89,7 +88,7 @@ func (x *emailSendLogService) ErrNotFound(ctx context.Context, id xsf.ID) (email
return
emailSendLogBiz
,
nil
return
emailSendLogBiz
,
nil
}
}
func
(
x
*
emailSendLogService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
func
(
x
*
emailSendLogService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailSendLogBiz
*
biz
.
EmailSendLog
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -103,7 +102,7 @@ func (x *emailSendLogService) GetByID(ctx context.Context, id xsf.ID) (emailSend
...
@@ -103,7 +102,7 @@ func (x *emailSendLogService) GetByID(ctx context.Context, id xsf.ID) (emailSend
return
x
.
ToBiz
(
ctx
,
emailSendLog
)
return
x
.
ToBiz
(
ctx
,
emailSendLog
)
}
}
func
(
x
*
emailSendLogService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -117,7 +116,7 @@ func (x *emailSendLogService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) (
...
@@ -117,7 +116,7 @@ func (x *emailSendLogService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) (
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
)
}
}
func
(
x
*
emailSendLogService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -146,7 +145,7 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
...
@@ -146,7 +145,7 @@ func (x *emailSendLogService) Page(ctx context.Context, in *types.EmailSendLogPa
}
}
return
emailSendLogBizSlice
,
total
,
nil
return
emailSendLogBizSlice
,
total
,
nil
}
}
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
emailSendID
x
sf
.
ID
)
([]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendID
(
ctx
context
.
Context
,
emailSendID
sf
.
ID
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
emailSendID
==
0
{
if
emailSendID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -160,7 +159,7 @@ func (x *emailSendLogService) GetSliceByEmailSendID(ctx context.Context, emailSe
...
@@ -160,7 +159,7 @@ func (x *emailSendLogService) GetSliceByEmailSendID(ctx context.Context, emailSe
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
)
}
}
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
x
sf
.
ID
)
([]
*
biz
.
EmailSendLog
,
error
)
{
func
(
x
*
emailSendLogService
)
GetSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
sf
.
ID
)
([]
*
biz
.
EmailSendLog
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -174,7 +173,7 @@ func (x *emailSendLogService) GetSliceByEmailSendIDs(ctx context.Context, emailS
...
@@ -174,7 +173,7 @@ func (x *emailSendLogService) GetSliceByEmailSendIDs(ctx context.Context, emailS
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
)
return
x
.
ToSliceBiz
(
ctx
,
emailSendLogs
)
}
}
func
(
x
*
emailSendLogService
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailSendLog
,
int
,
error
)
{
func
(
x
*
emailSendLogService
)
GetMapSliceByEmailSendIDs
(
ctx
context
.
Context
,
emailSendIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
EmailSendLog
,
int
,
error
)
{
if
len
(
emailSendIDs
)
==
0
{
if
len
(
emailSendIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -185,7 +184,7 @@ func (x *emailSendLogService) GetMapSliceByEmailSendIDs(ctx context.Context, ema
...
@@ -185,7 +184,7 @@ func (x *emailSendLogService) GetMapSliceByEmailSendIDs(ctx context.Context, ema
if
len
(
emailSendLogBizSlice
)
==
0
{
if
len
(
emailSendLogBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailSendLog
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
EmailSendLog
)
for
_
,
r
:=
range
emailSendLogBizSlice
{
for
_
,
r
:=
range
emailSendLogBizSlice
{
ret
[
r
.
EmailSendID
]
=
append
(
ret
[
r
.
EmailSendID
],
r
)
ret
[
r
.
EmailSendID
]
=
append
(
ret
[
r
.
EmailSendID
],
r
)
}
}
...
...
pkg/email/service/email_tpl.go
浏览文件 @
fc02815e
...
@@ -9,10 +9,9 @@ import (
...
@@ -9,10 +9,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfutils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailTplService
struct
{
type
emailTplService
struct
{
...
@@ -29,17 +28,17 @@ func newEmailTplService() *emailTplService {
...
@@ -29,17 +28,17 @@ func newEmailTplService() *emailTplService {
}
}
}
}
func
(
x
*
emailTplService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
emailTplService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
emailTpl
:=
&
models
.
EmailTpl
{}
emailTpl
:=
&
models
.
EmailTpl
{}
_
=
copier
.
Copy
(
emailTpl
,
in
)
_
=
copier
.
Copy
(
emailTpl
,
in
)
emailTpl
.
ID
=
xsfutils
.
EmailTplID
(
ctx
)
emailTpl
.
ID
=
sf
.
GenerateID
(
)
if
err
=
dao
.
EmailTplDao
.
Create
(
ctx
,
emailTpl
);
err
!=
nil
{
if
err
=
dao
.
EmailTplDao
.
Create
(
ctx
,
emailTpl
);
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
emailTpl
.
ID
,
nil
return
emailTpl
.
ID
,
nil
}
}
func
(
x
*
emailTplService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
emailTplService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -61,7 +60,7 @@ func (x *emailTplService) UpdateByID(ctx context.Context, in *types.EmailTplUpda
...
@@ -61,7 +60,7 @@ func (x *emailTplService) UpdateByID(ctx context.Context, in *types.EmailTplUpda
return
dao
.
EmailTplDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplUpd
)
return
dao
.
EmailTplDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplUpd
)
}
}
func
(
x
*
emailTplService
)
ErrFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
func
(
x
*
emailTplService
)
ErrFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -75,7 +74,7 @@ func (x *emailTplService) ErrFound(ctx context.Context, id xsf.ID) (emailTplBiz
...
@@ -75,7 +74,7 @@ func (x *emailTplService) ErrFound(ctx context.Context, id xsf.ID) (emailTplBiz
return
emailTplBiz
,
nil
return
emailTplBiz
,
nil
}
}
func
(
x
*
emailTplService
)
ErrNotFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
func
(
x
*
emailTplService
)
ErrNotFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -89,7 +88,7 @@ func (x *emailTplService) ErrNotFound(ctx context.Context, id xsf.ID) (emailTplB
...
@@ -89,7 +88,7 @@ func (x *emailTplService) ErrNotFound(ctx context.Context, id xsf.ID) (emailTplB
return
emailTplBiz
,
nil
return
emailTplBiz
,
nil
}
}
func
(
x
*
emailTplService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
func
(
x
*
emailTplService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailTplBiz
*
biz
.
EmailTpl
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -117,7 +116,7 @@ func (x *emailTplService) GetByCode(ctx context.Context, code string) (emailTplB
...
@@ -117,7 +116,7 @@ func (x *emailTplService) GetByCode(ctx context.Context, code string) (emailTplB
return
x
.
ToBiz
(
ctx
,
emailTpl
)
return
x
.
ToBiz
(
ctx
,
emailTpl
)
}
}
func
(
x
*
emailTplService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
EmailTpl
,
error
)
{
func
(
x
*
emailTplService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
EmailTpl
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -131,7 +130,7 @@ func (x *emailTplService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*b
...
@@ -131,7 +130,7 @@ func (x *emailTplService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*b
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
)
return
x
.
ToSliceBiz
(
ctx
,
emailTpls
)
}
}
func
(
x
*
emailTplService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
EmailTpl
,
error
)
{
func
(
x
*
emailTplService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
EmailTpl
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
...
pkg/email/service/email_tpl_receiver.go
浏览文件 @
fc02815e
...
@@ -9,10 +9,9 @@ import (
...
@@ -9,10 +9,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/ecode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/types"
xsfutils
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/xsf_utils
"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf
"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
csvexporter
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/csvexporter"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
emailTplReceiverService
struct
{
type
emailTplReceiverService
struct
{
...
@@ -29,17 +28,17 @@ func newEmailTplReceiverService() *emailTplReceiverService {
...
@@ -29,17 +28,17 @@ func newEmailTplReceiverService() *emailTplReceiverService {
}
}
}
}
func
(
x
*
emailTplReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
Create
(
ctx
context
.
Context
,
in
*
types
.
EmailTplReceiverCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
emailTplReceiver
:=
&
models
.
EmailTplReceiver
{}
emailTplReceiver
:=
&
models
.
EmailTplReceiver
{}
_
=
copier
.
Copy
(
emailTplReceiver
,
in
)
_
=
copier
.
Copy
(
emailTplReceiver
,
in
)
emailTplReceiver
.
ID
=
xsfutils
.
EmailTplReceiverID
(
ctx
)
emailTplReceiver
.
ID
=
sf
.
GenerateID
(
)
if
err
=
dao
.
EmailTplReceiverDao
.
Create
(
ctx
,
emailTplReceiver
);
err
!=
nil
{
if
err
=
dao
.
EmailTplReceiverDao
.
Create
(
ctx
,
emailTplReceiver
);
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
return
emailTplReceiver
.
ID
,
nil
return
emailTplReceiver
.
ID
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
emailTplReceiverService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -61,7 +60,7 @@ func (x *emailTplReceiverService) UpdateByID(ctx context.Context, in *types.Emai
...
@@ -61,7 +60,7 @@ func (x *emailTplReceiverService) UpdateByID(ctx context.Context, in *types.Emai
return
dao
.
EmailTplReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplReceiverUpd
)
return
dao
.
EmailTplReceiverDao
.
UpdateByID
(
ctx
,
in
.
ID
,
emailTplReceiverUpd
)
}
}
func
(
x
*
emailTplReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
ErrFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -75,7 +74,7 @@ func (x *emailTplReceiverService) ErrFound(ctx context.Context, id xsf.ID) (emai
...
@@ -75,7 +74,7 @@ func (x *emailTplReceiverService) ErrFound(ctx context.Context, id xsf.ID) (emai
return
emailTplReceiverBiz
,
nil
return
emailTplReceiverBiz
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
ErrNotFound
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
ErrNotFound
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -89,7 +88,7 @@ func (x *emailTplReceiverService) ErrNotFound(ctx context.Context, id xsf.ID) (e
...
@@ -89,7 +88,7 @@ func (x *emailTplReceiverService) ErrNotFound(ctx context.Context, id xsf.ID) (e
return
emailTplReceiverBiz
,
nil
return
emailTplReceiverBiz
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
func
(
x
*
emailTplReceiverService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
emailTplReceiverBiz
*
biz
.
EmailTplReceiver
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -103,7 +102,7 @@ func (x *emailTplReceiverService) GetByID(ctx context.Context, id xsf.ID) (email
...
@@ -103,7 +102,7 @@ func (x *emailTplReceiverService) GetByID(ctx context.Context, id xsf.ID) (email
return
x
.
ToBiz
(
ctx
,
emailTplReceiver
)
return
x
.
ToBiz
(
ctx
,
emailTplReceiver
)
}
}
func
(
x
*
emailTplReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -117,7 +116,7 @@ func (x *emailTplReceiverService) GetSliceByIDs(ctx context.Context, ids []xsf.I
...
@@ -117,7 +116,7 @@ func (x *emailTplReceiverService) GetSliceByIDs(ctx context.Context, ids []xsf.I
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
)
}
}
func
(
x
*
emailTplReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -146,7 +145,7 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
...
@@ -146,7 +145,7 @@ func (x *emailTplReceiverService) Page(ctx context.Context, in *types.EmailTplRe
}
}
return
emailTplReceiverBizSlice
,
total
,
nil
return
emailTplReceiverBizSlice
,
total
,
nil
}
}
func
(
x
*
emailTplReceiverService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
x
sf
.
ID
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetSliceByTplID
(
ctx
context
.
Context
,
tplID
sf
.
ID
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
tplID
==
0
{
if
tplID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -160,7 +159,7 @@ func (x *emailTplReceiverService) GetSliceByTplID(ctx context.Context, tplID xsf
...
@@ -160,7 +159,7 @@ func (x *emailTplReceiverService) GetSliceByTplID(ctx context.Context, tplID xsf
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
)
}
}
func
(
x
*
emailTplReceiverService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
x
sf
.
ID
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
sf
.
ID
)
([]
*
biz
.
EmailTplReceiver
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -174,7 +173,7 @@ func (x *emailTplReceiverService) GetSliceByTplIDs(ctx context.Context, tplIDs [
...
@@ -174,7 +173,7 @@ func (x *emailTplReceiverService) GetSliceByTplIDs(ctx context.Context, tplIDs [
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
)
return
x
.
ToSliceBiz
(
ctx
,
emailTplReceivers
)
}
}
func
(
x
*
emailTplReceiverService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailTplReceiver
,
int
,
error
)
{
func
(
x
*
emailTplReceiverService
)
GetMapSliceByTplIDs
(
ctx
context
.
Context
,
tplIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
EmailTplReceiver
,
int
,
error
)
{
if
len
(
tplIDs
)
==
0
{
if
len
(
tplIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -185,7 +184,7 @@ func (x *emailTplReceiverService) GetMapSliceByTplIDs(ctx context.Context, tplID
...
@@ -185,7 +184,7 @@ func (x *emailTplReceiverService) GetMapSliceByTplIDs(ctx context.Context, tplID
if
len
(
emailTplReceiverBizSlice
)
==
0
{
if
len
(
emailTplReceiverBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
EmailTplReceiver
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
EmailTplReceiver
)
for
_
,
r
:=
range
emailTplReceiverBizSlice
{
for
_
,
r
:=
range
emailTplReceiverBizSlice
{
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
ret
[
r
.
TplID
]
=
append
(
ret
[
r
.
TplID
],
r
)
}
}
...
...
pkg/email/types/email.go
浏览文件 @
fc02815e
...
@@ -4,9 +4,9 @@ import (
...
@@ -4,9 +4,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -14,7 +14,7 @@ var _ xtime.DateTime
...
@@ -14,7 +14,7 @@ var _ xtime.DateTime
// EmailCreateReq request params 邮件
// EmailCreateReq request params 邮件
type
EmailCreateReq
struct
{
type
EmailCreateReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
}
}
...
@@ -28,7 +28,7 @@ func (x *EmailCreateReq) Valid() error {
...
@@ -28,7 +28,7 @@ func (x *EmailCreateReq) Valid() error {
// EmailGetByTplIDReq request params
// EmailGetByTplIDReq request params
type
EmailGetByTplIDReq
struct
{
type
EmailGetByTplIDReq
struct
{
TplID
x
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
}
}
func
(
x
*
EmailGetByTplIDReq
)
Valid
()
error
{
func
(
x
*
EmailGetByTplIDReq
)
Valid
()
error
{
...
@@ -40,8 +40,8 @@ func (x *EmailGetByTplIDReq) Valid() error {
...
@@ -40,8 +40,8 @@ func (x *EmailGetByTplIDReq) Valid() error {
// EmailUpdateByIDReq request params
// EmailUpdateByIDReq request params
type
EmailUpdateByIDReq
struct
{
type
EmailUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
}
}
...
@@ -58,10 +58,10 @@ func (x *EmailUpdateByIDReq) Valid() error {
...
@@ -58,10 +58,10 @@ func (x *EmailUpdateByIDReq) Valid() error {
// EmailUpdateByIDsReq request params
// EmailUpdateByIDsReq request params
type
EmailUpdateByIDsReq
struct
{
type
EmailUpdateByIDsReq
struct
{
IDs
[]
x
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
TplID
x
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" example:"<div>hello moon! </div>"`
// 邮件内容
}
}
func
(
x
*
EmailUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailUpdateByIDsReq
)
Valid
()
error
{
...
@@ -77,8 +77,8 @@ func (x *EmailUpdateByIDsReq) Valid() error {
...
@@ -77,8 +77,8 @@ func (x *EmailUpdateByIDsReq) Valid() error {
// EmailPageReq request params
// EmailPageReq request params
type
EmailPageReq
struct
{
type
EmailPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
...
@@ -97,8 +97,8 @@ func (EmailPageReq) TableName() string {
...
@@ -97,8 +97,8 @@ func (EmailPageReq) TableName() string {
// EmailExportReq request params
// EmailExportReq request params
type
EmailExportReq
struct
{
type
EmailExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
From
string
`json:"from" form:"from" query:"" example:"月饼<mooncake2026@163.com>"`
// 发件人
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
Content
string
`json:"content" form:"content" query:"" example:"<div>hello moon! </div>"`
// 邮件内容
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
...
...
pkg/email/types/email_receiver.go
浏览文件 @
fc02815e
...
@@ -4,9 +4,9 @@ import (
...
@@ -4,9 +4,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -14,7 +14,7 @@ var _ xtime.DateTime
...
@@ -14,7 +14,7 @@ var _ xtime.DateTime
// EmailReceiverCreateReq request params 邮件收件人
// EmailReceiverCreateReq request params 邮件收件人
type
EmailReceiverCreateReq
struct
{
type
EmailReceiverCreateReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
...
@@ -27,7 +27,7 @@ func (x *EmailReceiverCreateReq) Valid() error {
...
@@ -27,7 +27,7 @@ func (x *EmailReceiverCreateReq) Valid() error {
// EmailReceiverGetByEmailIDReq request params
// EmailReceiverGetByEmailIDReq request params
type
EmailReceiverGetByEmailIDReq
struct
{
type
EmailReceiverGetByEmailIDReq
struct
{
EmailID
x
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
}
}
func
(
x
*
EmailReceiverGetByEmailIDReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverGetByEmailIDReq
)
Valid
()
error
{
...
@@ -39,8 +39,8 @@ func (x *EmailReceiverGetByEmailIDReq) Valid() error {
...
@@ -39,8 +39,8 @@ func (x *EmailReceiverGetByEmailIDReq) Valid() error {
// EmailReceiverUpdateByIDReq request params
// EmailReceiverUpdateByIDReq request params
type
EmailReceiverUpdateByIDReq
struct
{
type
EmailReceiverUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
...
@@ -56,9 +56,9 @@ func (x *EmailReceiverUpdateByIDReq) Valid() error {
...
@@ -56,9 +56,9 @@ func (x *EmailReceiverUpdateByIDReq) Valid() error {
// EmailReceiverUpdateByIDsReq request params
// EmailReceiverUpdateByIDsReq request params
type
EmailReceiverUpdateByIDsReq
struct
{
type
EmailReceiverUpdateByIDsReq
struct
{
IDs
[]
x
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
EmailID
x
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailReceiverUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailReceiverUpdateByIDsReq
)
Valid
()
error
{
...
@@ -74,8 +74,8 @@ func (x *EmailReceiverUpdateByIDsReq) Valid() error {
...
@@ -74,8 +74,8 @@ func (x *EmailReceiverUpdateByIDsReq) Valid() error {
// EmailReceiverPageReq request params
// EmailReceiverPageReq request params
type
EmailReceiverPageReq
struct
{
type
EmailReceiverPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
@@ -93,8 +93,8 @@ func (EmailReceiverPageReq) TableName() string {
...
@@ -93,8 +93,8 @@ func (EmailReceiverPageReq) TableName() string {
// EmailReceiverExportReq request params
// EmailReceiverExportReq request params
type
EmailReceiverExportReq
struct
{
type
EmailReceiverExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
...
pkg/email/types/email_send.go
浏览文件 @
fc02815e
...
@@ -5,10 +5,10 @@ import (
...
@@ -5,10 +5,10 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -16,7 +16,7 @@ var _ xtime.DateTime
...
@@ -16,7 +16,7 @@ var _ xtime.DateTime
// EmailSendCreateReq request params 邮件发送
// EmailSendCreateReq request params 邮件发送
type
EmailSendCreateReq
struct
{
type
EmailSendCreateReq
struct
{
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
...
@@ -32,7 +32,7 @@ func (x *EmailSendCreateReq) Valid() error {
...
@@ -32,7 +32,7 @@ func (x *EmailSendCreateReq) Valid() error {
// EmailSendGetByEmailIDReq request params
// EmailSendGetByEmailIDReq request params
type
EmailSendGetByEmailIDReq
struct
{
type
EmailSendGetByEmailIDReq
struct
{
EmailID
x
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
//邮件id
}
}
func
(
x
*
EmailSendGetByEmailIDReq
)
Valid
()
error
{
func
(
x
*
EmailSendGetByEmailIDReq
)
Valid
()
error
{
...
@@ -56,8 +56,8 @@ func (x *EmailSendGetByStateReq) Valid() error {
...
@@ -56,8 +56,8 @@ func (x *EmailSendGetByStateReq) Valid() error {
// EmailSendUpdateByIDReq request params
// EmailSendUpdateByIDReq request params
type
EmailSendUpdateByIDReq
struct
{
type
EmailSendUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
...
@@ -76,8 +76,8 @@ func (x *EmailSendUpdateByIDReq) Valid() error {
...
@@ -76,8 +76,8 @@ func (x *EmailSendUpdateByIDReq) Valid() error {
// EmailSendUpdateByIDsReq request params
// EmailSendUpdateByIDsReq request params
type
EmailSendUpdateByIDsReq
struct
{
type
EmailSendUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" validate:"required" example:"1"`
// 邮件id
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSend_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
...
@@ -97,8 +97,8 @@ func (x *EmailSendUpdateByIDsReq) Valid() error {
...
@@ -97,8 +97,8 @@ func (x *EmailSendUpdateByIDsReq) Valid() error {
// EmailSendPageReq request params
// EmailSendPageReq request params
type
EmailSendPageReq
struct
{
type
EmailSendPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
@@ -116,8 +116,8 @@ func (EmailSendPageReq) TableName() string {
...
@@ -116,8 +116,8 @@ func (EmailSendPageReq) TableName() string {
// EmailSendExportReq request params
// EmailSendExportReq request params
type
EmailSendExportReq
struct
{
type
EmailSendExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailID
xsf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
EmailID
sf
.
ID
`json:"emailID" form:"emailID" swaggertype:"string" query:"" example:"1"`
// 邮件id
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSend_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
...
pkg/email/types/email_send_log.go
浏览文件 @
fc02815e
...
@@ -5,10 +5,10 @@ import (
...
@@ -5,10 +5,10 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -16,7 +16,7 @@ var _ xtime.DateTime
...
@@ -16,7 +16,7 @@ var _ xtime.DateTime
// EmailSendLogCreateReq request params 邮件发送记录
// EmailSendLogCreateReq request params 邮件发送记录
type
EmailSendLogCreateReq
struct
{
type
EmailSendLogCreateReq
struct
{
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
...
@@ -32,7 +32,7 @@ func (x *EmailSendLogCreateReq) Valid() error {
...
@@ -32,7 +32,7 @@ func (x *EmailSendLogCreateReq) Valid() error {
// EmailSendLogGetByEmailSendIDReq request params
// EmailSendLogGetByEmailSendIDReq request params
type
EmailSendLogGetByEmailSendIDReq
struct
{
type
EmailSendLogGetByEmailSendIDReq
struct
{
EmailSendID
x
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
//邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
//邮件发送id
}
}
func
(
x
*
EmailSendLogGetByEmailSendIDReq
)
Valid
()
error
{
func
(
x
*
EmailSendLogGetByEmailSendIDReq
)
Valid
()
error
{
...
@@ -56,8 +56,8 @@ func (x *EmailSendLogGetByStateReq) Valid() error {
...
@@ -56,8 +56,8 @@ func (x *EmailSendLogGetByStateReq) Valid() error {
// EmailSendLogUpdateByIDReq request params
// EmailSendLogUpdateByIDReq request params
type
EmailSendLogUpdateByIDReq
struct
{
type
EmailSendLogUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
...
@@ -76,8 +76,8 @@ func (x *EmailSendLogUpdateByIDReq) Valid() error {
...
@@ -76,8 +76,8 @@ func (x *EmailSendLogUpdateByIDReq) Valid() error {
// EmailSendLogUpdateByIDsReq request params
// EmailSendLogUpdateByIDsReq request params
type
EmailSendLogUpdateByIDsReq
struct
{
type
EmailSendLogUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" validate:"required" example:"1"`
// 邮件发送id
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
State
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" validate:"required" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
}
}
...
@@ -97,8 +97,8 @@ func (x *EmailSendLogUpdateByIDsReq) Valid() error {
...
@@ -97,8 +97,8 @@ func (x *EmailSendLogUpdateByIDsReq) Valid() error {
// EmailSendLogPageReq request params
// EmailSendLogPageReq request params
type
EmailSendLogPageReq
struct
{
type
EmailSendLogPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
@@ -116,8 +116,8 @@ func (EmailSendLogPageReq) TableName() string {
...
@@ -116,8 +116,8 @@ func (EmailSendLogPageReq) TableName() string {
// EmailSendLogExportReq request params
// EmailSendLogExportReq request params
type
EmailSendLogExportReq
struct
{
type
EmailSendLogExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
EmailSendID
xsf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
EmailSendID
sf
.
ID
`json:"emailSendID" form:"emailSendID" swaggertype:"string" query:"" example:"1"`
// 邮件发送id
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
States
[]
enums
.
EmailSendLog_State_Enum
`json:"state" form:"state" query:"type:in" example:"1"`
// 发送状态 枚举[0:未知 1:待处理 2:处理中 3:成功 4:失败]
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
...
pkg/email/types/email_tpl.go
浏览文件 @
fc02815e
...
@@ -4,9 +4,9 @@ import (
...
@@ -4,9 +4,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -24,7 +24,7 @@ func (x *EmailTplCreateReq) Valid() error {
...
@@ -24,7 +24,7 @@ func (x *EmailTplCreateReq) Valid() error {
// EmailTplUpdateByIDReq request params
// EmailTplUpdateByIDReq request params
type
EmailTplUpdateByIDReq
struct
{
type
EmailTplUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
}
}
...
@@ -38,9 +38,9 @@ func (x *EmailTplUpdateByIDReq) Valid() error {
...
@@ -38,9 +38,9 @@ func (x *EmailTplUpdateByIDReq) Valid() error {
// EmailTplUpdateByIDsReq request params
// EmailTplUpdateByIDsReq request params
type
EmailTplUpdateByIDsReq
struct
{
type
EmailTplUpdateByIDsReq
struct
{
IDs
[]
x
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" example:"<div>hello moon! </div>"`
// 模板
}
}
func
(
x
*
EmailTplUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailTplUpdateByIDsReq
)
Valid
()
error
{
...
@@ -53,7 +53,7 @@ func (x *EmailTplUpdateByIDsReq) Valid() error {
...
@@ -53,7 +53,7 @@ func (x *EmailTplUpdateByIDsReq) Valid() error {
// EmailTplPageReq request params
// EmailTplPageReq request params
type
EmailTplPageReq
struct
{
type
EmailTplPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
...
@@ -72,7 +72,7 @@ func (EmailTplPageReq) TableName() string {
...
@@ -72,7 +72,7 @@ func (EmailTplPageReq) TableName() string {
// EmailTplExportReq request params
// EmailTplExportReq request params
type
EmailTplExportReq
struct
{
type
EmailTplExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Code
int
`json:"code" form:"code" query:"" example:"SMS_NOTICE"`
// 模板代码
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
Tpl
string
`json:"tpl" form:"tpl" query:"" example:"<div>hello moon! </div>"`
// 模板
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
...
...
pkg/email/types/email_tpl_receiver.go
浏览文件 @
fc02815e
...
@@ -4,9 +4,9 @@ import (
...
@@ -4,9 +4,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/email/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -14,7 +14,7 @@ var _ xtime.DateTime
...
@@ -14,7 +14,7 @@ var _ xtime.DateTime
// EmailTplReceiverCreateReq request params 邮件模板收件人
// EmailTplReceiverCreateReq request params 邮件模板收件人
type
EmailTplReceiverCreateReq
struct
{
type
EmailTplReceiverCreateReq
struct
{
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
...
@@ -27,7 +27,7 @@ func (x *EmailTplReceiverCreateReq) Valid() error {
...
@@ -27,7 +27,7 @@ func (x *EmailTplReceiverCreateReq) Valid() error {
// EmailTplReceiverGetByTplIDReq request params
// EmailTplReceiverGetByTplIDReq request params
type
EmailTplReceiverGetByTplIDReq
struct
{
type
EmailTplReceiverGetByTplIDReq
struct
{
TplID
x
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
//模板id
}
}
func
(
x
*
EmailTplReceiverGetByTplIDReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverGetByTplIDReq
)
Valid
()
error
{
...
@@ -39,8 +39,8 @@ func (x *EmailTplReceiverGetByTplIDReq) Valid() error {
...
@@ -39,8 +39,8 @@ func (x *EmailTplReceiverGetByTplIDReq) Valid() error {
// EmailTplReceiverUpdateByIDReq request params
// EmailTplReceiverUpdateByIDReq request params
type
EmailTplReceiverUpdateByIDReq
struct
{
type
EmailTplReceiverUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
...
@@ -56,9 +56,9 @@ func (x *EmailTplReceiverUpdateByIDReq) Valid() error {
...
@@ -56,9 +56,9 @@ func (x *EmailTplReceiverUpdateByIDReq) Valid() error {
// EmailTplReceiverUpdateByIDsReq request params
// EmailTplReceiverUpdateByIDsReq request params
type
EmailTplReceiverUpdateByIDsReq
struct
{
type
EmailTplReceiverUpdateByIDsReq
struct
{
IDs
[]
x
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"1"`
//用户主键id
TplID
x
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" validate:"required" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" example:"月饼<mooncake2026@163.com>"`
// 收件人
}
}
func
(
x
*
EmailTplReceiverUpdateByIDsReq
)
Valid
()
error
{
func
(
x
*
EmailTplReceiverUpdateByIDsReq
)
Valid
()
error
{
...
@@ -74,8 +74,8 @@ func (x *EmailTplReceiverUpdateByIDsReq) Valid() error {
...
@@ -74,8 +74,8 @@ func (x *EmailTplReceiverUpdateByIDsReq) Valid() error {
// EmailTplReceiverPageReq request params
// EmailTplReceiverPageReq request params
type
EmailTplReceiverPageReq
struct
{
type
EmailTplReceiverPageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
@@ -93,8 +93,8 @@ func (EmailTplReceiverPageReq) TableName() string {
...
@@ -93,8 +93,8 @@ func (EmailTplReceiverPageReq) TableName() string {
// EmailTplReceiverExportReq request params
// EmailTplReceiverExportReq request params
type
EmailTplReceiverExportReq
struct
{
type
EmailTplReceiverExportReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
IDs
[]
sf
.
ID
`json:"ids" form:"ids" swaggertype:"array,string" query:"type:in" example:"1"`
//用户主键id
TplID
xsf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
TplID
sf
.
ID
`json:"tplID" form:"tplID" swaggertype:"string" query:"" example:"1"`
// 模板id
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
Receiver
string
`json:"receiver" form:"receiver" query:"" example:"月饼<mooncake2026@163.com>"`
// 收件人
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2024-03-27 17:11:00"`
//创建时间截止 (<)
...
...
pkg/email/xsf_utils/xsf_utils.go
deleted
100644 → 0
浏览文件 @
ff4eee31
package
xsfutils
import
(
"context"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/idutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
const
(
bizTag_email
=
"qt.operator.email.id"
bizTag_email_receiver
=
"qt.operator.email.receiver.id"
bizTag_email_send
=
"qt.operator.email.send.id"
bizTag_email_send_log
=
"qt.operator.email.send.log.id"
bizTag_email_tpl
=
"qt.operator.email.tpl.id"
bizTag_email_tpl_receiver
=
"qt.operator.email.tpl.receiver.id"
)
func
EmailID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email
)
}
func
EmailReceiverID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_receiver
)
}
func
EmailSendID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_send
)
}
func
EmailSendLogID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_send_log
)
}
func
EmailTplID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_tpl
)
}
func
EmailTplReceiverID
(
ctx
context
.
Context
)
xsf
.
ID
{
return
generateID
(
ctx
,
bizTag_email_tpl_receiver
)
}
func
generateID
(
ctx
context
.
Context
,
bizTag
string
)
xsf
.
ID
{
xsf
,
err
:=
idutils
.
GenerateID
(
ctx
,
bizTag
)
if
err
!=
nil
{
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.email.id',100000,2000,'qt.operator.email.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.receiver.id',100000,2000,'qt.operator.email.receiver.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.send.id',100000,2000,'qt.operator.email.send.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.send.log.id',100000,2000,'qt.operator.email.send.log.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.tpl.id',100000,2000,'qt.operator.email.tpl.id');
// insert into leaf_alloc(biz_tag,max_id,step,description) values ('qt.operator.email.tpl.receiver.id',100000,2000,'qt.operator.email.tpl.receiver.id');
xutils/xsf/x
sf.go
→
pkg/sf/
sf.go
浏览文件 @
fc02815e
package
x
sf
package
sf
import
(
import
(
"fmt"
"fmt"
"math/rand"
"os"
"strconv"
"strconv"
"strings"
"time"
"github.com/bwmarrin/snowflake"
"github.com/bwmarrin/snowflake"
"github.com/spf13/cast"
"github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
)
)
...
@@ -83,18 +78,7 @@ func (j JSONSyntaxError) Error() string {
...
@@ -83,18 +78,7 @@ func (j JSONSyntaxError) Error() string {
}
}
// n [1,1023]
// n [1,1023]
func
Init
()
error
{
func
Init
(
n
int
)
error
{
n
:=
getConfigN
()
delta
:=
getNodeFromPodName
()
if
delta
>
0
{
n
=
n
+
delta
}
if
n
<=
0
{
n
=
getRandomN
()
}
config
.
Write
(
func
(
c
*
config
.
Config
)
{
c
.
App
.
IDGeneration
.
Snowflake
.
Node
=
n
})
nod
,
e
:=
snowflake
.
NewNode
(
int64
(
n
))
nod
,
e
:=
snowflake
.
NewNode
(
int64
(
n
))
if
e
!=
nil
{
if
e
!=
nil
{
return
e
return
e
...
@@ -104,29 +88,6 @@ func Init() error {
...
@@ -104,29 +88,6 @@ func Init() error {
return
nil
return
nil
}
}
func
getConfigN
()
int
{
n
:=
0
config
.
Read
(
func
(
c
*
config
.
Config
)
{
n
=
c
.
App
.
IDGeneration
.
Snowflake
.
Node
})
return
n
}
func
getRandomN
()
int
{
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
n
:=
int
(
r
.
Intn
(
1023
)
+
1
)
return
n
}
func
getNodeFromPodName
()
int
{
if
podName
:=
os
.
Getenv
(
"POD_NAME"
);
podName
!=
""
{
parts
:=
strings
.
Split
(
podName
,
"-"
)
if
len
(
parts
)
==
2
{
lastPart
:=
parts
[
len
(
parts
)
-
1
]
n
,
_
:=
strconv
.
ParseInt
(
lastPart
,
10
,
64
)
return
int
(
n
)
}
}
return
0
}
func
(
x
ID
)
String
()
string
{
func
(
x
ID
)
String
()
string
{
return
snowflake
.
ID
(
x
)
.
String
()
return
snowflake
.
ID
(
x
)
.
String
()
}
}
...
...
pkg/ws/ws.go
浏览文件 @
fc02815e
...
@@ -9,8 +9,8 @@ import (
...
@@ -9,8 +9,8 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
...
@@ -27,7 +27,7 @@ const (
...
@@ -27,7 +27,7 @@ const (
type
wsConn
struct
{
type
wsConn
struct
{
manager
*
WsConnManager
manager
*
WsConnManager
receiverID
x
sf
.
ID
// user id
receiverID
sf
.
ID
// user id
conn
*
websocket
.
Conn
conn
*
websocket
.
Conn
sendBuff
chan
*
WsMessage
sendBuff
chan
*
WsMessage
log
*
zap
.
Logger
log
*
zap
.
Logger
...
@@ -36,7 +36,7 @@ type wsConn struct {
...
@@ -36,7 +36,7 @@ type wsConn struct {
}
}
type
WsConnManager
struct
{
type
WsConnManager
struct
{
pool
map
[
x
sf
.
ID
]
*
wsConn
pool
map
[
sf
.
ID
]
*
wsConn
upgrader
*
websocket
.
Upgrader
upgrader
*
websocket
.
Upgrader
l
*
sync
.
RWMutex
l
*
sync
.
RWMutex
log
*
zap
.
Logger
log
*
zap
.
Logger
...
@@ -44,19 +44,19 @@ type WsConnManager struct {
...
@@ -44,19 +44,19 @@ type WsConnManager struct {
}
}
type
Hook
interface
{
type
Hook
interface
{
OnHeartbeatOK
(
receiverID
x
sf
.
ID
)
error
OnHeartbeatOK
(
receiverID
sf
.
ID
)
error
OnHeartbeatFail
(
receiverID
x
sf
.
ID
)
error
OnHeartbeatFail
(
receiverID
sf
.
ID
)
error
AfterSend
(
receiverID
x
sf
.
ID
,
payload
*
WsMessage
)
error
AfterSend
(
receiverID
sf
.
ID
,
payload
*
WsMessage
)
error
OnConnNotFound
(
receiverID
x
sf
.
ID
,
payload
*
WsMessage
)
error
OnConnNotFound
(
receiverID
sf
.
ID
,
payload
*
WsMessage
)
error
OnSendFail
(
receiverID
x
sf
.
ID
,
payload
*
WsMessage
,
err
error
)
error
OnSendFail
(
receiverID
sf
.
ID
,
payload
*
WsMessage
,
err
error
)
error
OnConnAccept
(
userID
x
sf
.
ID
)
error
OnConnAccept
(
userID
sf
.
ID
)
error
AfterUnregister
(
userID
x
sf
.
ID
)
error
AfterUnregister
(
userID
sf
.
ID
)
error
OnReceive
(
senderID
x
sf
.
ID
,
messageType
int
,
msg
[]
byte
)
OnReceive
(
senderID
sf
.
ID
,
messageType
int
,
msg
[]
byte
)
}
}
func
NewWsConnManager
(
logger
*
zap
.
Logger
,
upgrader
*
websocket
.
Upgrader
,
hooks
...
Hook
)
*
WsConnManager
{
func
NewWsConnManager
(
logger
*
zap
.
Logger
,
upgrader
*
websocket
.
Upgrader
,
hooks
...
Hook
)
*
WsConnManager
{
return
&
WsConnManager
{
return
&
WsConnManager
{
pool
:
make
(
map
[
x
sf
.
ID
]
*
wsConn
),
pool
:
make
(
map
[
sf
.
ID
]
*
wsConn
),
log
:
logger
,
log
:
logger
,
upgrader
:
upgrader
,
upgrader
:
upgrader
,
hooks
:
hooks
,
hooks
:
hooks
,
...
@@ -105,7 +105,7 @@ func (m *WsConnManager) accept(c *gin.Context) error {
...
@@ -105,7 +105,7 @@ func (m *WsConnManager) accept(c *gin.Context) error {
return
xerror
.
Wrap
(
err
,
"parse jwt"
)
return
xerror
.
Wrap
(
err
,
"parse jwt"
)
}
}
userIDStr
:=
claims
.
UID
userIDStr
:=
claims
.
UID
userID
,
_
:=
x
sf
.
ParseString
(
userIDStr
)
userID
,
_
:=
sf
.
ParseString
(
userIDStr
)
conn
,
err
:=
m
.
upgrader
.
Upgrade
(
w
,
r
,
nil
)
conn
,
err
:=
m
.
upgrader
.
Upgrade
(
w
,
r
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
xerror
.
Wrap
(
err
,
"ws upgrade failed"
)
return
xerror
.
Wrap
(
err
,
"ws upgrade failed"
)
...
@@ -129,14 +129,14 @@ func (m *WsConnManager) accept(c *gin.Context) error {
...
@@ -129,14 +129,14 @@ func (m *WsConnManager) accept(c *gin.Context) error {
return
nil
return
nil
}
}
func
(
m
*
WsConnManager
)
getConn
(
userID
x
sf
.
ID
)
(
*
wsConn
,
bool
)
{
func
(
m
*
WsConnManager
)
getConn
(
userID
sf
.
ID
)
(
*
wsConn
,
bool
)
{
m
.
l
.
RLock
()
m
.
l
.
RLock
()
defer
m
.
l
.
RUnlock
()
defer
m
.
l
.
RUnlock
()
client
,
exists
:=
m
.
pool
[
userID
]
client
,
exists
:=
m
.
pool
[
userID
]
return
client
,
exists
return
client
,
exists
}
}
func
(
m
*
WsConnManager
)
Send
(
ctx
context
.
Context
,
receiverID
x
sf
.
ID
,
payload
*
WsMessage
)
error
{
func
(
m
*
WsConnManager
)
Send
(
ctx
context
.
Context
,
receiverID
sf
.
ID
,
payload
*
WsMessage
)
error
{
conn
,
exists
:=
m
.
getConn
(
receiverID
)
conn
,
exists
:=
m
.
getConn
(
receiverID
)
if
exists
{
if
exists
{
if
err
:=
conn
.
send
(
ctx
,
payload
);
err
!=
nil
{
if
err
:=
conn
.
send
(
ctx
,
payload
);
err
!=
nil
{
...
@@ -239,7 +239,7 @@ func (c *wsConn) writeLoop() {
...
@@ -239,7 +239,7 @@ func (c *wsConn) writeLoop() {
}
}
type
WsMsg
struct
{
type
WsMsg
struct
{
senderID
x
sf
.
ID
senderID
sf
.
ID
msgType
int
msgType
int
msg
[]
byte
msg
[]
byte
}
}
...
@@ -290,6 +290,6 @@ const (
...
@@ -290,6 +290,6 @@ const (
type
WsMessage
struct
{
type
WsMessage
struct
{
Seq
string
`json:"seq"`
Seq
string
`json:"seq"`
Cmd
Cmd
`json:"cmd"`
Cmd
Cmd
`json:"cmd"`
ReceiverID
xsf
.
ID
`json:"receiverID"`
ReceiverID
sf
.
ID
`json:"receiverID"`
Data
json
.
RawMessage
`json:"payload"`
// 原始JSON,目前是models.ChatMessage
Data
json
.
RawMessage
`json:"payload"`
// 原始JSON,目前是models.ChatMessage
}
}
xcommon/biz.go
浏览文件 @
fc02815e
package
xcommon
package
xcommon
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xtype"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xtype"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
IConverter
[
ID
xtype
.
Key
,
T
,
B
any
]
interface
{
type
IConverter
[
ID
xtype
.
Key
,
T
,
B
any
]
interface
{
...
@@ -25,11 +25,11 @@ func (x *CommonBiz[ID, T, B]) NewSliceFromModelsBiz(ms []*T) []*B {
...
@@ -25,11 +25,11 @@ func (x *CommonBiz[ID, T, B]) NewSliceFromModelsBiz(ms []*T) []*B {
return
ret
return
ret
}
}
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
NewMapFromModelMapBiz
(
idMap
map
[
xsf
.
ID
]
*
T
)
map
[
x
sf
.
ID
]
*
B
{
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
NewMapFromModelMapBiz
(
idMap
map
[
sf
.
ID
]
*
T
)
map
[
sf
.
ID
]
*
B
{
if
len
(
idMap
)
==
0
{
if
len
(
idMap
)
==
0
{
return
nil
return
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
]
*
B
,
len
(
idMap
))
ret
:=
make
(
map
[
sf
.
ID
]
*
B
,
len
(
idMap
))
var
bt
B
var
bt
B
for
k
,
v
:=
range
idMap
{
for
k
,
v
:=
range
idMap
{
ret
[
k
]
=
bt
.
NewFromModel
(
v
)
ret
[
k
]
=
bt
.
NewFromModel
(
v
)
...
@@ -37,11 +37,11 @@ func (x *CommonBiz[ID, T, B]) NewMapFromModelMapBiz(idMap map[xsf.ID]*T) map[xsf
...
@@ -37,11 +37,11 @@ func (x *CommonBiz[ID, T, B]) NewMapFromModelMapBiz(idMap map[xsf.ID]*T) map[xsf
return
ret
return
ret
}
}
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
NewMapSliceFromModelMapSliceBiz
(
idMapSlice
map
[
xsf
.
ID
][]
*
T
)
map
[
x
sf
.
ID
][]
*
B
{
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
NewMapSliceFromModelMapSliceBiz
(
idMapSlice
map
[
sf
.
ID
][]
*
T
)
map
[
sf
.
ID
][]
*
B
{
if
len
(
idMapSlice
)
==
0
{
if
len
(
idMapSlice
)
==
0
{
return
nil
return
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
B
,
len
(
idMapSlice
))
ret
:=
make
(
map
[
sf
.
ID
][]
*
B
,
len
(
idMapSlice
))
for
k
,
v
:=
range
idMapSlice
{
for
k
,
v
:=
range
idMapSlice
{
ret
[
k
]
=
x
.
NewSliceFromModelsBiz
(
v
)
ret
[
k
]
=
x
.
NewSliceFromModelsBiz
(
v
)
}
}
...
@@ -70,7 +70,7 @@ func (x *CommonBiz[ID, T, B]) SliceToIDMapBiz(rs []*B) map[ID]*B {
...
@@ -70,7 +70,7 @@ func (x *CommonBiz[ID, T, B]) SliceToIDMapBiz(rs []*B) map[ID]*B {
return
ret
return
ret
}
}
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
IDMapToSliceBiz
(
m
map
[
x
sf
.
ID
]
*
B
)
[]
*
B
{
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
IDMapToSliceBiz
(
m
map
[
sf
.
ID
]
*
B
)
[]
*
B
{
if
len
(
m
)
==
0
{
if
len
(
m
)
==
0
{
return
nil
return
nil
}
}
...
@@ -81,7 +81,7 @@ func (x *CommonBiz[ID, T, B]) IDMapToSliceBiz(m map[xsf.ID]*B) []*B {
...
@@ -81,7 +81,7 @@ func (x *CommonBiz[ID, T, B]) IDMapToSliceBiz(m map[xsf.ID]*B) []*B {
return
ret
return
ret
}
}
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
IDMapSliceToSliceBiz
(
m
map
[
x
sf
.
ID
][]
*
B
)
[]
*
B
{
func
(
x
*
CommonBiz
[
ID
,
T
,
B
])
IDMapSliceToSliceBiz
(
m
map
[
sf
.
ID
][]
*
B
)
[]
*
B
{
if
len
(
m
)
==
0
{
if
len
(
m
)
==
0
{
return
nil
return
nil
}
}
...
...
xcommon/ocache/ocache.go
浏览文件 @
fc02815e
...
@@ -10,9 +10,9 @@ import (
...
@@ -10,9 +10,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
utils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils"
utils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
const
(
const
(
...
@@ -27,7 +27,7 @@ func getCacheKey(prefix string, id int64) string {
...
@@ -27,7 +27,7 @@ func getCacheKey(prefix string, id int64) string {
}
}
type
IID
interface
{
type
IID
interface
{
GetID
()
x
sf
.
ID
GetID
()
sf
.
ID
TableName
()
string
TableName
()
string
}
}
...
@@ -60,7 +60,7 @@ func NewCache[T IID](cacheType string, prefix string, d time.Duration) *OCache[T
...
@@ -60,7 +60,7 @@ func NewCache[T IID](cacheType string, prefix string, d time.Duration) *OCache[T
return
nil
return
nil
}
}
func
(
x
*
OCache
[
T
])
Set
(
ctx
context
.
Context
,
id
x
sf
.
ID
,
data
*
T
,
duration
time
.
Duration
)
error
{
func
(
x
*
OCache
[
T
])
Set
(
ctx
context
.
Context
,
id
sf
.
ID
,
data
*
T
,
duration
time
.
Duration
)
error
{
if
x
.
Cache
==
nil
{
if
x
.
Cache
==
nil
{
return
nil
return
nil
}
}
...
@@ -74,7 +74,7 @@ func (x *OCache[T]) Set(ctx context.Context, id xsf.ID, data *T, duration time.D
...
@@ -74,7 +74,7 @@ func (x *OCache[T]) Set(ctx context.Context, id xsf.ID, data *T, duration time.D
return
nil
return
nil
}
}
func
(
x
*
OCache
[
T
])
Get
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
*
T
,
error
)
{
func
(
x
*
OCache
[
T
])
Get
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
*
T
,
error
)
{
if
x
.
Cache
==
nil
{
if
x
.
Cache
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -103,7 +103,7 @@ func (x *OCache[T]) MultiSet(ctx context.Context, data []*T, duration time.Durat
...
@@ -103,7 +103,7 @@ func (x *OCache[T]) MultiSet(ctx context.Context, data []*T, duration time.Durat
return
nil
return
nil
}
}
func
(
x
*
OCache
[
T
])
MultiGet
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
xsf
.
ID
]
int
,
map
[
x
sf
.
ID
]
*
T
,
error
)
{
func
(
x
*
OCache
[
T
])
MultiGet
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
int
,
map
[
sf
.
ID
]
*
T
,
error
)
{
if
x
.
Cache
==
nil
{
if
x
.
Cache
==
nil
{
return
nil
,
nil
,
nil
return
nil
,
nil
,
nil
}
}
...
@@ -119,8 +119,8 @@ func (x *OCache[T]) MultiGet(ctx context.Context, ids []xsf.ID) (map[xsf.ID]int,
...
@@ -119,8 +119,8 @@ func (x *OCache[T]) MultiGet(ctx context.Context, ids []xsf.ID) (map[xsf.ID]int,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
xerror
.
NewCacheError
(
err
.
Error
())
return
nil
,
nil
,
xerror
.
NewCacheError
(
err
.
Error
())
}
}
retMap
:=
make
(
map
[
x
sf
.
ID
]
*
T
)
retMap
:=
make
(
map
[
sf
.
ID
]
*
T
)
hasMap
:=
make
(
map
[
x
sf
.
ID
]
int
)
hasMap
:=
make
(
map
[
sf
.
ID
]
int
)
for
i
,
id
:=
range
ids
{
for
i
,
id
:=
range
ids
{
item
:=
items
[
i
]
item
:=
items
[
i
]
hasMap
[
id
]
=
0
hasMap
[
id
]
=
0
...
@@ -138,7 +138,7 @@ func (x *OCache[T]) MultiGet(ctx context.Context, ids []xsf.ID) (map[xsf.ID]int,
...
@@ -138,7 +138,7 @@ func (x *OCache[T]) MultiGet(ctx context.Context, ids []xsf.ID) (map[xsf.ID]int,
return
hasMap
,
retMap
,
nil
return
hasMap
,
retMap
,
nil
}
}
func
(
x
*
OCache
[
T
])
Del
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
OCache
[
T
])
Del
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
cacheKey
:=
x
.
KeyPrefix
+
utils
.
Int64ToStr
(
id
.
Int64
())
cacheKey
:=
x
.
KeyPrefix
+
utils
.
Int64ToStr
(
id
.
Int64
())
if
err
:=
x
.
Cache
.
Del
(
ctx
,
cacheKey
);
err
!=
nil
{
if
err
:=
x
.
Cache
.
Del
(
ctx
,
cacheKey
);
err
!=
nil
{
return
xerror
.
NewCacheError
(
err
.
Error
())
return
xerror
.
NewCacheError
(
err
.
Error
())
...
@@ -146,7 +146,7 @@ func (x *OCache[T]) Del(ctx context.Context, id xsf.ID) error {
...
@@ -146,7 +146,7 @@ func (x *OCache[T]) Del(ctx context.Context, id xsf.ID) error {
return
nil
return
nil
}
}
func
(
x
*
OCache
[
T
])
Dels
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
error
{
func
(
x
*
OCache
[
T
])
Dels
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
...
@@ -161,7 +161,7 @@ func (x *OCache[T]) Dels(ctx context.Context, ids []xsf.ID) error {
...
@@ -161,7 +161,7 @@ func (x *OCache[T]) Dels(ctx context.Context, ids []xsf.ID) error {
return
nil
return
nil
}
}
func
(
x
*
OCache
[
T
])
SetPlaceholder
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
OCache
[
T
])
SetPlaceholder
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
cacheKey
:=
x
.
KeyPrefix
+
utils
.
Int64ToStr
(
id
.
Int64
())
cacheKey
:=
x
.
KeyPrefix
+
utils
.
Int64ToStr
(
id
.
Int64
())
if
err
:=
x
.
Cache
.
SetCacheWithNotFound
(
ctx
,
cacheKey
);
err
!=
nil
{
if
err
:=
x
.
Cache
.
SetCacheWithNotFound
(
ctx
,
cacheKey
);
err
!=
nil
{
return
xerror
.
NewCacheError
(
err
.
Error
())
return
xerror
.
NewCacheError
(
err
.
Error
())
...
...
xcommon/odao/odao.go
浏览文件 @
fc02815e
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
...
@@ -15,7 +16,6 @@ import (
...
@@ -15,7 +16,6 @@ import (
utils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils"
utils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils"
ctxutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
ctxutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
setutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
setutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"golang.org/x/sync/singleflight"
"golang.org/x/sync/singleflight"
"gorm.io/gorm"
"gorm.io/gorm"
olog
"gorm.io/gorm/logger"
olog
"gorm.io/gorm/logger"
...
@@ -43,7 +43,7 @@ func NewDao[T ocache.IID](schema string) *ODao[T] {
...
@@ -43,7 +43,7 @@ func NewDao[T ocache.IID](schema string) *ODao[T] {
}
}
}
}
func
(
x
*
ODao
[
T
])
deleteCache
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
ODao
[
T
])
deleteCache
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -53,7 +53,7 @@ func (x *ODao[T]) deleteCache(ctx context.Context, id xsf.ID) error {
...
@@ -53,7 +53,7 @@ func (x *ODao[T]) deleteCache(ctx context.Context, id xsf.ID) error {
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
deleteCaches
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
error
{
func
(
x
*
ODao
[
T
])
deleteCaches
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
...
@@ -123,8 +123,8 @@ func (x *ODao[T]) CreateSliceTx(ctx context.Context, tx *gorm.DB, tbs []*T) erro
...
@@ -123,8 +123,8 @@ func (x *ODao[T]) CreateSliceTx(ctx context.Context, tx *gorm.DB, tbs []*T) erro
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
getIDs
(
tbs
[]
*
T
)
[]
x
sf
.
ID
{
func
(
x
*
ODao
[
T
])
getIDs
(
tbs
[]
*
T
)
[]
sf
.
ID
{
idsSet
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
idsSet
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
tbs
{
for
_
,
r
:=
range
tbs
{
if
id
:=
(
*
r
)
.
GetID
();
id
>
0
{
if
id
:=
(
*
r
)
.
GetID
();
id
>
0
{
idsSet
.
Add
(
id
)
idsSet
.
Add
(
id
)
...
@@ -133,21 +133,21 @@ func (x *ODao[T]) getIDs(tbs []*T) []xsf.ID {
...
@@ -133,21 +133,21 @@ func (x *ODao[T]) getIDs(tbs []*T) []xsf.ID {
return
idsSet
.
Slice
()
return
idsSet
.
Slice
()
}
}
func
(
x
*
ODao
[
T
])
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
ODao
[
T
])
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
return
x
.
DeleteByIDTx
(
ctx
,
x
.
DB
(),
id
)
return
x
.
DeleteByIDTx
(
ctx
,
x
.
DB
(),
id
)
}
}
func
(
x
*
ODao
[
T
])
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
error
{
func
(
x
*
ODao
[
T
])
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
return
x
.
DeleteByIDsTx
(
ctx
,
x
.
DB
(),
ids
)
return
x
.
DeleteByIDsTx
(
ctx
,
x
.
DB
(),
ids
)
}
}
func
(
x
*
ODao
[
T
])
DeleteByIDTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
id
x
sf
.
ID
)
error
{
func
(
x
*
ODao
[
T
])
DeleteByIDTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -159,7 +159,7 @@ func (x *ODao[T]) DeleteByIDTx(ctx context.Context, tx *gorm.DB, id xsf.ID) erro
...
@@ -159,7 +159,7 @@ func (x *ODao[T]) DeleteByIDTx(ctx context.Context, tx *gorm.DB, id xsf.ID) erro
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
DeleteByIDsTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
ids
[]
x
sf
.
ID
)
error
{
func
(
x
*
ODao
[
T
])
DeleteByIDsTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
ids
[]
sf
.
ID
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
...
@@ -171,7 +171,7 @@ func (x *ODao[T]) DeleteByIDsTx(ctx context.Context, tx *gorm.DB, ids []xsf.ID)
...
@@ -171,7 +171,7 @@ func (x *ODao[T]) DeleteByIDsTx(ctx context.Context, tx *gorm.DB, ids []xsf.ID)
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
UpdateByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
,
tb
any
)
error
{
func
(
x
*
ODao
[
T
])
UpdateByID
(
ctx
context
.
Context
,
id
sf
.
ID
,
tb
any
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -181,7 +181,7 @@ func (x *ODao[T]) UpdateByID(ctx context.Context, id xsf.ID, tb any) error {
...
@@ -181,7 +181,7 @@ func (x *ODao[T]) UpdateByID(ctx context.Context, id xsf.ID, tb any) error {
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
UpdateByIDSilent
(
ctx
context
.
Context
,
id
x
sf
.
ID
,
tb
any
)
error
{
func
(
x
*
ODao
[
T
])
UpdateByIDSilent
(
ctx
context
.
Context
,
id
sf
.
ID
,
tb
any
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -191,7 +191,7 @@ func (x *ODao[T]) UpdateByIDSilent(ctx context.Context, id xsf.ID, tb any) error
...
@@ -191,7 +191,7 @@ func (x *ODao[T]) UpdateByIDSilent(ctx context.Context, id xsf.ID, tb any) error
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
UpdateByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
,
tb
any
)
error
{
func
(
x
*
ODao
[
T
])
UpdateByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
,
tb
any
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
...
@@ -201,7 +201,7 @@ func (x *ODao[T]) UpdateByIDs(ctx context.Context, ids []xsf.ID, tb any) error {
...
@@ -201,7 +201,7 @@ func (x *ODao[T]) UpdateByIDs(ctx context.Context, ids []xsf.ID, tb any) error {
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
UpdateByIDTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
id
x
sf
.
ID
,
tb
any
)
error
{
func
(
x
*
ODao
[
T
])
UpdateByIDTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
id
sf
.
ID
,
tb
any
)
error
{
return
x
.
updByIDTx
(
ctx
,
tx
,
id
,
tb
)
return
x
.
updByIDTx
(
ctx
,
tx
,
id
,
tb
)
}
}
...
@@ -209,7 +209,7 @@ func (x *ODao[T]) UpdateByIDTx(ctx context.Context, tx *gorm.DB, id xsf.ID, tb a
...
@@ -209,7 +209,7 @@ func (x *ODao[T]) UpdateByIDTx(ctx context.Context, tx *gorm.DB, id xsf.ID, tb a
// id 必传
// id 必传
// upd 可以是struct、map
// upd 可以是struct、map
// Updates 方法支持 struct 和 map[string]any 参数。当使用 struct 更新时,默认情况下GORM 只会更新非零值的字段
// Updates 方法支持 struct 和 map[string]any 参数。当使用 struct 更新时,默认情况下GORM 只会更新非零值的字段
func
(
x
*
ODao
[
T
])
updByIDTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
id
x
sf
.
ID
,
upd
any
)
error
{
func
(
x
*
ODao
[
T
])
updByIDTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
id
sf
.
ID
,
upd
any
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -221,7 +221,7 @@ func (x *ODao[T]) updByIDTx(ctx context.Context, tx *gorm.DB, id xsf.ID, upd any
...
@@ -221,7 +221,7 @@ func (x *ODao[T]) updByIDTx(ctx context.Context, tx *gorm.DB, id xsf.ID, upd any
return
nil
return
nil
}
}
func
(
x
*
ODao
[
T
])
UpdateByIDsTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
ids
[]
x
sf
.
ID
,
tb
any
)
error
{
func
(
x
*
ODao
[
T
])
UpdateByIDsTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
ids
[]
sf
.
ID
,
tb
any
)
error
{
return
x
.
updByIDsTx
(
ctx
,
tx
,
ids
,
tb
)
return
x
.
updByIDsTx
(
ctx
,
tx
,
ids
,
tb
)
}
}
...
@@ -257,7 +257,7 @@ func (x *ODao[T]) UpdateByIDsTx(ctx context.Context, tx *gorm.DB, ids []xsf.ID,
...
@@ -257,7 +257,7 @@ func (x *ODao[T]) UpdateByIDsTx(ctx context.Context, tx *gorm.DB, ids []xsf.ID,
// Save - 生成更新所有字段的SQL
// Save - 生成更新所有字段的SQL
// SQL: UPDATE users SET name = '张三', age = 30, email = ”, address = ”, ...所有字段 WHERE id = 1;
// SQL: UPDATE users SET name = '张三', age = 30, email = ”, address = ”, ...所有字段 WHERE id = 1;
// db.Save(&user)
// db.Save(&user)
func
(
x
*
ODao
[
T
])
updByIDsTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
ids
[]
x
sf
.
ID
,
upd
any
)
error
{
func
(
x
*
ODao
[
T
])
updByIDsTx
(
ctx
context
.
Context
,
tx
*
gorm
.
DB
,
ids
[]
sf
.
ID
,
upd
any
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
...
@@ -276,7 +276,7 @@ func (x *ODao[T]) GetAll(ctx context.Context) (records []*T, err error) {
...
@@ -276,7 +276,7 @@ func (x *ODao[T]) GetAll(ctx context.Context) (records []*T, err error) {
return
records
,
nil
return
records
,
nil
}
}
func
(
x
*
ODao
[
T
])
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
(
rs
[]
*
T
,
err
error
)
{
func
(
x
*
ODao
[
T
])
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
rs
[]
*
T
,
err
error
)
{
m
,
err
:=
x
.
GetMapByIDs
(
ctx
,
ids
)
m
,
err
:=
x
.
GetMapByIDs
(
ctx
,
ids
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -348,7 +348,7 @@ func (x *ODao[T]) GetSliceByCondition(ctx context.Context, c *query.Conditions)
...
@@ -348,7 +348,7 @@ func (x *ODao[T]) GetSliceByCondition(ctx context.Context, c *query.Conditions)
return
rs
,
nil
return
rs
,
nil
}
}
func
(
x
*
ODao
[
T
])
GetSliceByLastID
(
ctx
context
.
Context
,
lastID
x
sf
.
ID
,
limit
int
,
sort
string
)
(
rs
[]
*
T
,
err
error
)
{
func
(
x
*
ODao
[
T
])
GetSliceByLastID
(
ctx
context
.
Context
,
lastID
sf
.
ID
,
limit
int
,
sort
string
)
(
rs
[]
*
T
,
err
error
)
{
if
lastID
==
0
||
limit
==
0
{
if
lastID
==
0
||
limit
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -409,7 +409,7 @@ func (x *ODao[T]) CountByWhere(ctx context.Context, where any) (count int64, err
...
@@ -409,7 +409,7 @@ func (x *ODao[T]) CountByWhere(ctx context.Context, where any) (count int64, err
return
count
,
nil
return
count
,
nil
}
}
func
(
x
*
ODao
[
T
])
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
record
*
T
,
err
error
)
{
func
(
x
*
ODao
[
T
])
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
record
*
T
,
err
error
)
{
if
id
==
0
{
if
id
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -458,7 +458,7 @@ func (x *ODao[T]) GetByID(ctx context.Context, id xsf.ID) (record *T, err error)
...
@@ -458,7 +458,7 @@ func (x *ODao[T]) GetByID(ctx context.Context, id xsf.ID) (record *T, err error)
return
nil
,
err
return
nil
,
err
}
}
func
(
x
*
ODao
[
T
])
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
itemMap
map
[
x
sf
.
ID
]
*
T
,
err
error
)
{
func
(
x
*
ODao
[
T
])
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
itemMap
map
[
sf
.
ID
]
*
T
,
err
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -467,7 +467,7 @@ func (x *ODao[T]) GetMapByIDs(ctx context.Context, ids []xsf.ID) (itemMap map[xs
...
@@ -467,7 +467,7 @@ func (x *ODao[T]) GetMapByIDs(ctx context.Context, ids []xsf.ID) (itemMap map[xs
if
err
:=
x
.
DB
()
.
WithContext
(
ctx
)
.
Where
(
"id IN (?)"
,
ids
)
.
Find
(
&
records
)
.
Error
;
err
!=
nil
{
if
err
:=
x
.
DB
()
.
WithContext
(
ctx
)
.
Where
(
"id IN (?)"
,
ids
)
.
Find
(
&
records
)
.
Error
;
err
!=
nil
{
return
nil
,
xerror
.
NewDBError
(
err
.
Error
())
return
nil
,
xerror
.
NewDBError
(
err
.
Error
())
}
}
itemMap
=
make
(
map
[
x
sf
.
ID
]
*
T
)
itemMap
=
make
(
map
[
sf
.
ID
]
*
T
)
for
_
,
record
:=
range
records
{
for
_
,
record
:=
range
records
{
itemMap
[(
*
record
)
.
GetID
()]
=
record
itemMap
[(
*
record
)
.
GetID
()]
=
record
}
}
...
@@ -477,7 +477,7 @@ func (x *ODao[T]) GetMapByIDs(ctx context.Context, ids []xsf.ID) (itemMap map[xs
...
@@ -477,7 +477,7 @@ func (x *ODao[T]) GetMapByIDs(ctx context.Context, ids []xsf.ID) (itemMap map[xs
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
missedIDs
[]
x
sf
.
ID
var
missedIDs
[]
sf
.
ID
for
k
,
v
:=
range
hasMap
{
for
k
,
v
:=
range
hasMap
{
if
v
==
0
{
if
v
==
0
{
missedIDs
=
append
(
missedIDs
,
k
)
missedIDs
=
append
(
missedIDs
,
k
)
...
@@ -488,7 +488,7 @@ func (x *ODao[T]) GetMapByIDs(ctx context.Context, ids []xsf.ID) (itemMap map[xs
...
@@ -488,7 +488,7 @@ func (x *ODao[T]) GetMapByIDs(ctx context.Context, ids []xsf.ID) (itemMap map[xs
if
err
=
x
.
DB
()
.
WithContext
(
ctx
)
.
Where
(
"id IN (?)"
,
missedIDs
)
.
Find
(
&
records
)
.
Error
;
err
!=
nil
{
if
err
=
x
.
DB
()
.
WithContext
(
ctx
)
.
Where
(
"id IN (?)"
,
missedIDs
)
.
Find
(
&
records
)
.
Error
;
err
!=
nil
{
return
nil
,
xerror
.
NewDBError
(
err
.
Error
())
return
nil
,
xerror
.
NewDBError
(
err
.
Error
())
}
}
var
recordIDMap
=
make
(
map
[
x
sf
.
ID
]
struct
{})
var
recordIDMap
=
make
(
map
[
sf
.
ID
]
struct
{})
if
len
(
records
)
>
0
{
if
len
(
records
)
>
0
{
for
_
,
record
:=
range
records
{
for
_
,
record
:=
range
records
{
itemMap
[(
*
record
)
.
GetID
()]
=
record
itemMap
[(
*
record
)
.
GetID
()]
=
record
...
...
xcommon/xmodels/models.go
浏览文件 @
fc02815e
package
xmodels
package
xmodels
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
ctxutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
ctxutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
setutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
setutils
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
type
CommonModel
struct
{
type
CommonModel
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1234567890123456789" csv:"主键ID"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20);primaryKey;autoIncrement;comment:主键" example:"1234567890123456789" csv:"主键ID"`
//主键
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2025-09-18 10:05:00" csv:"创建时间"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2025-09-18 10:05:00" csv:"创建时间"`
//创建时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2025-09-18 10:05:00" csv:"更新时间"`
//更新时间
UpdatedAt
xtime
.
DateTime
`json:"updatedAt" form:"updatedAt" gorm:"column:updated_at;type:datetime;comment:更新时间" example:"2025-09-18 10:05:00" csv:"更新时间"`
//更新时间
}
}
func
(
x
CommonModel
)
GetID
()
x
sf
.
ID
{
func
(
x
CommonModel
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
CommonModel
)
GetOrder
()
string
{
func
(
x
CommonModel
)
GetOrder
()
string
{
...
@@ -35,17 +35,17 @@ func (x *CommonModel) BeforeUpdate(tx *gorm.DB) (err error) {
...
@@ -35,17 +35,17 @@ func (x *CommonModel) BeforeUpdate(tx *gorm.DB) (err error) {
return
nil
return
nil
}
}
func
GetUid
(
tx
*
gorm
.
DB
)
x
sf
.
ID
{
func
GetUid
(
tx
*
gorm
.
DB
)
sf
.
ID
{
ctx
:=
tx
.
Statement
.
Context
ctx
:=
tx
.
Statement
.
Context
return
ctxutils
.
GetCtxUID
(
ctx
)
return
ctxutils
.
GetCtxUID
(
ctx
)
}
}
type
IModel
interface
{
type
IModel
interface
{
GetID
()
x
sf
.
ID
GetID
()
sf
.
ID
}
}
func
GetIDs
[
T
IModel
](
rs
[]
*
T
)
[]
x
sf
.
ID
{
func
GetIDs
[
T
IModel
](
rs
[]
*
T
)
[]
sf
.
ID
{
st
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
st
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
v
:=
range
rs
{
for
_
,
v
:=
range
rs
{
st
.
Add
((
*
v
)
.
GetID
())
st
.
Add
((
*
v
)
.
GetID
())
}
}
...
@@ -60,15 +60,15 @@ func StrMapToSlice[T any](m map[string]*T) []*T {
...
@@ -60,15 +60,15 @@ func StrMapToSlice[T any](m map[string]*T) []*T {
return
rs
return
rs
}
}
func
GetStrMapIDs
[
T
IModel
](
m
map
[
string
]
*
T
)
[]
x
sf
.
ID
{
func
GetStrMapIDs
[
T
IModel
](
m
map
[
string
]
*
T
)
[]
sf
.
ID
{
st
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
st
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
v
:=
range
m
{
for
_
,
v
:=
range
m
{
st
.
Add
((
*
v
)
.
GetID
())
st
.
Add
((
*
v
)
.
GetID
())
}
}
return
st
.
Slice
()
return
st
.
Slice
()
}
}
func
IDMapToSlice
[
T
any
](
m
map
[
x
sf
.
ID
]
*
T
)
[]
*
T
{
func
IDMapToSlice
[
T
any
](
m
map
[
sf
.
ID
]
*
T
)
[]
*
T
{
var
rs
[]
*
T
var
rs
[]
*
T
for
_
,
r
:=
range
m
{
for
_
,
r
:=
range
m
{
rs
=
append
(
rs
,
r
)
rs
=
append
(
rs
,
r
)
...
@@ -76,23 +76,23 @@ func IDMapToSlice[T any](m map[xsf.ID]*T) []*T {
...
@@ -76,23 +76,23 @@ func IDMapToSlice[T any](m map[xsf.ID]*T) []*T {
return
rs
return
rs
}
}
func
GetIDMapIDs
[
T
IModel
](
m
map
[
xsf
.
ID
]
*
T
)
[]
x
sf
.
ID
{
func
GetIDMapIDs
[
T
IModel
](
m
map
[
sf
.
ID
]
*
T
)
[]
sf
.
ID
{
st
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
st
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
v
:=
range
m
{
for
_
,
v
:=
range
m
{
st
.
Add
((
*
v
)
.
GetID
())
st
.
Add
((
*
v
)
.
GetID
())
}
}
return
st
.
Slice
()
return
st
.
Slice
()
}
}
func
SliceToIDMap
[
T
IModel
](
rs
[]
*
T
)
map
[
x
sf
.
ID
]
*
T
{
func
SliceToIDMap
[
T
IModel
](
rs
[]
*
T
)
map
[
sf
.
ID
]
*
T
{
m
:=
make
(
map
[
x
sf
.
ID
]
*
T
)
m
:=
make
(
map
[
sf
.
ID
]
*
T
)
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
m
[(
*
r
)
.
GetID
()]
=
r
m
[(
*
r
)
.
GetID
()]
=
r
}
}
return
m
return
m
}
}
func
IDMapSliceToSlice
[
T
any
](
m
map
[
x
sf
.
ID
][]
*
T
)
[]
*
T
{
func
IDMapSliceToSlice
[
T
any
](
m
map
[
sf
.
ID
][]
*
T
)
[]
*
T
{
var
rs
[]
*
T
var
rs
[]
*
T
for
_
,
r
:=
range
m
{
for
_
,
r
:=
range
m
{
rs
=
append
(
rs
,
r
...
)
rs
=
append
(
rs
,
r
...
)
...
@@ -100,8 +100,8 @@ func IDMapSliceToSlice[T any](m map[xsf.ID][]*T) []*T {
...
@@ -100,8 +100,8 @@ func IDMapSliceToSlice[T any](m map[xsf.ID][]*T) []*T {
return
rs
return
rs
}
}
func
GetIDMapSliceIDs
[
T
IModel
](
m
map
[
xsf
.
ID
][]
*
T
)
[]
x
sf
.
ID
{
func
GetIDMapSliceIDs
[
T
IModel
](
m
map
[
sf
.
ID
][]
*
T
)
[]
sf
.
ID
{
st
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
st
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
rs
:=
range
m
{
for
_
,
rs
:=
range
m
{
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
st
.
Add
((
*
r
)
.
GetID
())
st
.
Add
((
*
r
)
.
GetID
())
...
...
xcron/biz/cron_job.go
浏览文件 @
fc02815e
...
@@ -5,15 +5,15 @@ import (
...
@@ -5,15 +5,15 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
type
CronJob
struct
{
type
CronJob
struct
{
models
.
CronJob
models
.
CronJob
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
CronJob
,
CronJob
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
CronJob
,
CronJob
]
CronJobInfo
*
models
.
CronJobInfo
CronJobInfo
*
models
.
CronJobInfo
}
}
...
@@ -35,7 +35,7 @@ func (x *CronJob) ParseJobInfo() {
...
@@ -35,7 +35,7 @@ func (x *CronJob) ParseJobInfo() {
var
CronJobTool
=
&
CronJob
{}
var
CronJobTool
=
&
CronJob
{}
func
(
*
CronJob
)
GetIDs
(
rs
[]
*
CronJob
)
[]
x
sf
.
ID
{
func
(
*
CronJob
)
GetIDs
(
rs
[]
*
CronJob
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
(
rs
)
return
sliceutils
.
GetIDs
(
rs
)
}
}
...
...
xcron/biz/cron_job_log.go
浏览文件 @
fc02815e
package
biz
package
biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
CronJobLog
struct
{
type
CronJobLog
struct
{
models
.
CronJobLog
models
.
CronJobLog
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
CronJobLog
,
CronJobLog
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
CronJobLog
,
CronJobLog
]
}
}
var
CronJobLogTool
=
&
CronJobLog
{}
var
CronJobLogTool
=
&
CronJobLog
{}
func
(
*
CronJobLog
)
GetIDs
(
rs
[]
*
CronJobLog
)
[]
x
sf
.
ID
{
func
(
*
CronJobLog
)
GetIDs
(
rs
[]
*
CronJobLog
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
(
rs
)
return
sliceutils
.
GetIDs
(
rs
)
}
}
func
(
x
*
CronJobLog
)
GetJobIDs
(
rs
[]
*
CronJobLog
)
[]
x
sf
.
ID
{
func
(
x
*
CronJobLog
)
GetJobIDs
(
rs
[]
*
CronJobLog
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetJobID
())
set
.
Add
(
r
.
GetJobID
())
}
}
...
...
xcron/biz/cron_job_record.go
浏览文件 @
fc02815e
...
@@ -3,24 +3,24 @@ package biz
...
@@ -3,24 +3,24 @@ package biz
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
CronJobRecord
struct
{
type
CronJobRecord
struct
{
models
.
CronJobRecord
models
.
CronJobRecord
xcommon
.
CommonBiz
[
x
sf
.
ID
,
models
.
CronJobRecord
,
CronJobRecord
]
xcommon
.
CommonBiz
[
sf
.
ID
,
models
.
CronJobRecord
,
CronJobRecord
]
}
}
var
CronJobRecordTool
=
&
CronJobRecord
{}
var
CronJobRecordTool
=
&
CronJobRecord
{}
func
(
*
CronJobRecord
)
GetIDs
(
rs
[]
*
CronJobRecord
)
[]
x
sf
.
ID
{
func
(
*
CronJobRecord
)
GetIDs
(
rs
[]
*
CronJobRecord
)
[]
sf
.
ID
{
return
sliceutils
.
GetIDs
(
rs
)
return
sliceutils
.
GetIDs
(
rs
)
}
}
func
(
x
*
CronJobRecord
)
GetJobIDs
(
rs
[]
*
CronJobRecord
)
[]
x
sf
.
ID
{
func
(
x
*
CronJobRecord
)
GetJobIDs
(
rs
[]
*
CronJobRecord
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetJobID
())
set
.
Add
(
r
.
GetJobID
())
}
}
...
...
xcron/dao/cron_job.go
浏览文件 @
fc02815e
...
@@ -7,8 +7,8 @@ import (
...
@@ -7,8 +7,8 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"golang.org/x/sync/singleflight"
"golang.org/x/sync/singleflight"
"gorm.io/gorm"
"gorm.io/gorm"
glogger
"gorm.io/gorm/logger"
glogger
"gorm.io/gorm/logger"
...
@@ -88,7 +88,7 @@ func (x *cronJobDao) GetMapSliceByEnables(ctx context.Context, order string, ena
...
@@ -88,7 +88,7 @@ func (x *cronJobDao) GetMapSliceByEnables(ctx context.Context, order string, ena
return
cronJobMapSlice
,
len
(
cronJobs
),
nil
return
cronJobMapSlice
,
len
(
cronJobs
),
nil
}
}
func
(
x
*
cronJobDao
)
GetNotRunning
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
*
models
.
CronJob
,
error
)
{
func
(
x
*
cronJobDao
)
GetNotRunning
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
*
models
.
CronJob
,
error
)
{
result
:=
x
.
DB
()
.
Session
(
&
gorm
.
Session
{
Logger
:
glogger
.
Discard
})
.
WithContext
(
ctx
)
.
Model
(
&
models
.
CronJob
{})
.
result
:=
x
.
DB
()
.
Session
(
&
gorm
.
Session
{
Logger
:
glogger
.
Discard
})
.
WithContext
(
ctx
)
.
Model
(
&
models
.
CronJob
{})
.
Where
(
"state = ?"
,
enums
.
CronJob_State_NOT_RUNNING
)
.
Where
(
"id = ?"
,
id
)
.
Where
(
"state = ?"
,
enums
.
CronJob_State_NOT_RUNNING
)
.
Where
(
"id = ?"
,
id
)
.
Update
(
"state"
,
enums
.
CronJob_State_RUNNING
)
Update
(
"state"
,
enums
.
CronJob_State_RUNNING
)
...
...
xcron/dao/cron_job_log.go
浏览文件 @
fc02815e
...
@@ -3,9 +3,9 @@ package dao
...
@@ -3,9 +3,9 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"golang.org/x/sync/singleflight"
"golang.org/x/sync/singleflight"
)
)
...
@@ -20,14 +20,14 @@ var CronJobLogDao = &cronJobLogDao{
...
@@ -20,14 +20,14 @@ var CronJobLogDao = &cronJobLogDao{
},
},
}
}
func
(
x
*
cronJobLogDao
)
GetSliceByJobID
(
ctx
context
.
Context
,
order
string
,
jobID
x
sf
.
ID
)
([]
*
models
.
CronJobLog
,
error
)
{
func
(
x
*
cronJobLogDao
)
GetSliceByJobID
(
ctx
context
.
Context
,
order
string
,
jobID
sf
.
ID
)
([]
*
models
.
CronJobLog
,
error
)
{
if
jobID
<=
0
{
if
jobID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"job_id = ?"
,
jobID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"job_id = ?"
,
jobID
)
}
}
func
(
x
*
cronJobLogDao
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
x
sf
.
ID
)
([]
*
models
.
CronJobLog
,
error
)
{
func
(
x
*
cronJobLogDao
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
sf
.
ID
)
([]
*
models
.
CronJobLog
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -38,7 +38,7 @@ func (x *cronJobLogDao) GetSliceByJobIDs(ctx context.Context, order string, jobI
...
@@ -38,7 +38,7 @@ func (x *cronJobLogDao) GetSliceByJobIDs(ctx context.Context, order string, jobI
return
cronJobLogs
,
nil
return
cronJobLogs
,
nil
}
}
func
(
x
*
cronJobLogDao
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
CronJobLog
,
int
,
error
)
{
func
(
x
*
cronJobLogDao
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
CronJobLog
,
int
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -46,7 +46,7 @@ func (x *cronJobLogDao) GetMapSliceByJobIDs(ctx context.Context, order string, j
...
@@ -46,7 +46,7 @@ func (x *cronJobLogDao) GetMapSliceByJobIDs(ctx context.Context, order string, j
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
CronJobLog
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
CronJobLog
)
for
_
,
record
:=
range
cronJobLogs
{
for
_
,
record
:=
range
cronJobLogs
{
itemMap
[
record
.
JobID
]
=
append
(
itemMap
[
record
.
JobID
],
record
)
itemMap
[
record
.
JobID
]
=
append
(
itemMap
[
record
.
JobID
],
record
)
}
}
...
...
xcron/dao/cron_job_record.go
浏览文件 @
fc02815e
...
@@ -3,9 +3,9 @@ package dao
...
@@ -3,9 +3,9 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"golang.org/x/sync/singleflight"
"golang.org/x/sync/singleflight"
)
)
...
@@ -20,14 +20,14 @@ var CronJobRecordDao = &cronJobRecordDao{
...
@@ -20,14 +20,14 @@ var CronJobRecordDao = &cronJobRecordDao{
},
},
}
}
func
(
x
*
cronJobRecordDao
)
GetSliceByJobID
(
ctx
context
.
Context
,
order
string
,
jobID
x
sf
.
ID
)
([]
*
models
.
CronJobRecord
,
error
)
{
func
(
x
*
cronJobRecordDao
)
GetSliceByJobID
(
ctx
context
.
Context
,
order
string
,
jobID
sf
.
ID
)
([]
*
models
.
CronJobRecord
,
error
)
{
if
jobID
<=
0
{
if
jobID
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"job_id = ?"
,
jobID
)
return
x
.
GetOrderSliceByWhere
(
ctx
,
order
,
"job_id = ?"
,
jobID
)
}
}
func
(
x
*
cronJobRecordDao
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
x
sf
.
ID
)
([]
*
models
.
CronJobRecord
,
error
)
{
func
(
x
*
cronJobRecordDao
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
sf
.
ID
)
([]
*
models
.
CronJobRecord
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -38,7 +38,7 @@ func (x *cronJobRecordDao) GetSliceByJobIDs(ctx context.Context, order string, j
...
@@ -38,7 +38,7 @@ func (x *cronJobRecordDao) GetSliceByJobIDs(ctx context.Context, order string, j
return
cronJobRecords
,
nil
return
cronJobRecords
,
nil
}
}
func
(
x
*
cronJobRecordDao
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
models
.
CronJobRecord
,
int
,
error
)
{
func
(
x
*
cronJobRecordDao
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
order
string
,
jobIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
models
.
CronJobRecord
,
int
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -46,7 +46,7 @@ func (x *cronJobRecordDao) GetMapSliceByJobIDs(ctx context.Context, order string
...
@@ -46,7 +46,7 @@ func (x *cronJobRecordDao) GetMapSliceByJobIDs(ctx context.Context, order string
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
0
,
err
return
nil
,
0
,
err
}
}
itemMap
:=
make
(
map
[
x
sf
.
ID
][]
*
models
.
CronJobRecord
)
itemMap
:=
make
(
map
[
sf
.
ID
][]
*
models
.
CronJobRecord
)
for
_
,
record
:=
range
cronJobRecords
{
for
_
,
record
:=
range
cronJobRecords
{
itemMap
[
record
.
JobID
]
=
append
(
itemMap
[
record
.
JobID
],
record
)
itemMap
[
record
.
JobID
]
=
append
(
itemMap
[
record
.
JobID
],
record
)
}
}
...
...
xcron/models/cron_job.go
浏览文件 @
fc02815e
...
@@ -5,14 +5,14 @@ import (
...
@@ -5,14 +5,14 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/
xutils/x
sf"
"gitlab.wanzhuangkj.com/tush/xpkg/
pkg/
sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// CronJob 定时任务
// CronJob 定时任务
type
CronJob
struct
{
type
CronJob
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"101"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"101"`
//主键
JobName
string
`json:"jobName" form:"jobName" gorm:"column:job_name;type:varchar(128);comment:定时任务名称" example:"任务-自动确认订单"`
//定时任务名称
JobName
string
`json:"jobName" form:"jobName" gorm:"column:job_name;type:varchar(128);comment:定时任务名称" example:"任务-自动确认订单"`
//定时任务名称
JobCode
string
`json:"jobCode" form:"jobCode" gorm:"column:job_code;type:varchar(128);comment:定时任务code" example:"autoConfirmOrdersTask"`
//定时任务code
JobCode
string
`json:"jobCode" form:"jobCode" gorm:"column:job_code;type:varchar(128);comment:定时任务code" example:"autoConfirmOrdersTask"`
//定时任务code
TimeSpec
string
`json:"timeSpec" form:"timeSpec" gorm:"column:time_spec;type:varchar(128);comment:定时任务时间表达式" example:"0 0 0 * * ?"`
//定时任务时间表达式
TimeSpec
string
`json:"timeSpec" form:"timeSpec" gorm:"column:time_spec;type:varchar(128);comment:定时任务时间表达式" example:"0 0 0 * * ?"`
//定时任务时间表达式
...
@@ -35,7 +35,7 @@ func (CronJob) TableName() string {
...
@@ -35,7 +35,7 @@ func (CronJob) TableName() string {
return
TBCronJob
return
TBCronJob
}
}
func
(
x
CronJob
)
GetID
()
x
sf
.
ID
{
func
(
x
CronJob
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
...
...
xcron/models/cron_job_log.go
浏览文件 @
fc02815e
package
models
package
models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// CronJobLog 定时任务日志
// CronJobLog 定时任务日志
type
CronJobLog
struct
{
type
CronJobLog
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"101"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"101"`
//主键
JobID
xsf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" gorm:"column:job_id;type:bigint(20) unsigned;comment:job ID" example:"101"`
//job ID
JobID
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" gorm:"column:job_id;type:bigint(20) unsigned;comment:job ID" example:"101"`
//job ID
Info
string
`json:"info" form:"info" gorm:"column:info;type:text;comment:日志" example:"job occur error..."`
//日志
Info
string
`json:"info" form:"info" gorm:"column:info;type:text;comment:日志" example:"job occur error..."`
//日志
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2025-01-07 12:20:43"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2025-01-07 12:20:43"`
//创建时间
}
}
...
@@ -23,18 +23,18 @@ func (CronJobLog) TableName() string {
...
@@ -23,18 +23,18 @@ func (CronJobLog) TableName() string {
return
TBCronJobLog
return
TBCronJobLog
}
}
func
(
x
CronJobLog
)
GetID
()
x
sf
.
ID
{
func
(
x
CronJobLog
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
CronJobLog
)
Init
()
*
CronJobLog
{
func
(
x
*
CronJobLog
)
Init
()
*
CronJobLog
{
return
x
return
x
}
}
func
(
x
*
CronJobLog
)
GetJobID
()
x
sf
.
ID
{
func
(
x
*
CronJobLog
)
GetJobID
()
sf
.
ID
{
return
x
.
JobID
return
x
.
JobID
}
}
func
(
x
*
CronJobLog
)
GetJobIDs
(
rs
[]
*
CronJobLog
)
[]
x
sf
.
ID
{
func
(
x
*
CronJobLog
)
GetJobIDs
(
rs
[]
*
CronJobLog
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetJobID
())
set
.
Add
(
r
.
GetJobID
())
}
}
...
...
xcron/models/cron_job_record.go
浏览文件 @
fc02815e
package
models
package
models
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/setutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
)
)
// CronJobRecord 定时任务运行记录
// CronJobRecord 定时任务运行记录
type
CronJobRecord
struct
{
type
CronJobRecord
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"101"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"101"`
//主键
JobID
xsf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" gorm:"column:job_id;type:bigint(20) unsigned;comment:job ID" example:"101"`
//job ID
JobID
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" gorm:"column:job_id;type:bigint(20) unsigned;comment:job ID" example:"101"`
//job ID
BeginTime
xtime
.
DateTime
`json:"beginTime" form:"beginTime" gorm:"column:begin_time;type:datetime;default:CURRENT_TIMESTAMP;comment:开始时间" example:"2025-01-07 12:20:43"`
//开始时间
BeginTime
xtime
.
DateTime
`json:"beginTime" form:"beginTime" gorm:"column:begin_time;type:datetime;default:CURRENT_TIMESTAMP;comment:开始时间" example:"2025-01-07 12:20:43"`
//开始时间
EndTime
xtime
.
DateTime
`json:"endTime" form:"endTime" gorm:"column:end_time;type:datetime;default:CURRENT_TIMESTAMP;comment:结束时间" example:"2025-01-07 12:20:43"`
//结束时间
EndTime
xtime
.
DateTime
`json:"endTime" form:"endTime" gorm:"column:end_time;type:datetime;default:CURRENT_TIMESTAMP;comment:结束时间" example:"2025-01-07 12:20:43"`
//结束时间
Info
string
`json:"info" form:"info" gorm:"column:info;type:text;comment:额外信息" example:""`
//额外信息
Info
string
`json:"info" form:"info" gorm:"column:info;type:text;comment:额外信息" example:""`
//额外信息
...
@@ -26,18 +26,18 @@ func (CronJobRecord) TableName() string {
...
@@ -26,18 +26,18 @@ func (CronJobRecord) TableName() string {
return
TBCronJobRecord
return
TBCronJobRecord
}
}
func
(
x
CronJobRecord
)
GetID
()
x
sf
.
ID
{
func
(
x
CronJobRecord
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
func
(
x
*
CronJobRecord
)
Init
()
*
CronJobRecord
{
func
(
x
*
CronJobRecord
)
Init
()
*
CronJobRecord
{
return
x
return
x
}
}
func
(
x
*
CronJobRecord
)
GetJobID
()
x
sf
.
ID
{
func
(
x
*
CronJobRecord
)
GetJobID
()
sf
.
ID
{
return
x
.
JobID
return
x
.
JobID
}
}
func
(
x
*
CronJobRecord
)
GetJobIDs
(
rs
[]
*
CronJobRecord
)
[]
x
sf
.
ID
{
func
(
x
*
CronJobRecord
)
GetJobIDs
(
rs
[]
*
CronJobRecord
)
[]
sf
.
ID
{
set
:=
setutils
.
NewSet
[
x
sf
.
ID
]()
set
:=
setutils
.
NewSet
[
sf
.
ID
]()
for
_
,
r
:=
range
rs
{
for
_
,
r
:=
range
rs
{
set
.
Add
(
r
.
GetJobID
())
set
.
Add
(
r
.
GetJobID
())
}
}
...
...
xcron/service/cron_job.go
浏览文件 @
fc02815e
...
@@ -4,13 +4,13 @@ import (
...
@@ -4,13 +4,13 @@ import (
"context"
"context"
"fmt"
"fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"github.com/jinzhu/copier"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/sliceutils"
...
@@ -38,11 +38,11 @@ func (x *cronJobService) GetByJobCode(ctx context.Context, jobCode string) (*biz
...
@@ -38,11 +38,11 @@ func (x *cronJobService) GetByJobCode(ctx context.Context, jobCode string) (*biz
return
x
.
ToBiz
(
ctx
,
cronJob
)
return
x
.
ToBiz
(
ctx
,
cronJob
)
}
}
func
(
x
*
cronJobService
)
GetNotRunning
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
*
models
.
CronJob
,
error
)
{
func
(
x
*
cronJobService
)
GetNotRunning
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
*
models
.
CronJob
,
error
)
{
return
dao
.
CronJobDao
.
GetNotRunning
(
ctx
,
id
)
return
dao
.
CronJobDao
.
GetNotRunning
(
ctx
,
id
)
}
}
func
(
x
*
cronJobService
)
Create
(
ctx
context
.
Context
,
req
*
types
.
CronJobCreateReq
)
(
id
x
sf
.
ID
,
err
error
)
{
func
(
x
*
cronJobService
)
Create
(
ctx
context
.
Context
,
req
*
types
.
CronJobCreateReq
)
(
id
sf
.
ID
,
err
error
)
{
cronJob
:=
&
models
.
CronJob
{}
cronJob
:=
&
models
.
CronJob
{}
_
=
copier
.
Copy
(
cronJob
,
req
)
_
=
copier
.
Copy
(
cronJob
,
req
)
if
err
=
dao
.
CronJobDao
.
Create
(
ctx
,
cronJob
);
err
!=
nil
{
if
err
=
dao
.
CronJobDao
.
Create
(
ctx
,
cronJob
);
err
!=
nil
{
...
@@ -51,7 +51,7 @@ func (x *cronJobService) Create(ctx context.Context, req *types.CronJobCreateReq
...
@@ -51,7 +51,7 @@ func (x *cronJobService) Create(ctx context.Context, req *types.CronJobCreateReq
return
cronJob
.
ID
,
nil
return
cronJob
.
ID
,
nil
}
}
func
(
x
*
cronJobService
)
DeleteByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
cronJobService
)
DeleteByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
return
nil
}
}
...
@@ -65,7 +65,7 @@ func (x *cronJobService) DeleteByID(ctx context.Context, id xsf.ID) error {
...
@@ -65,7 +65,7 @@ func (x *cronJobService) DeleteByID(ctx context.Context, id xsf.ID) error {
return
dao
.
CronJobDao
.
DeleteByID
(
ctx
,
id
)
return
dao
.
CronJobDao
.
DeleteByID
(
ctx
,
id
)
}
}
func
(
x
*
cronJobService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
error
{
func
(
x
*
cronJobService
)
DeleteByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
error
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
return
nil
}
}
...
@@ -80,7 +80,7 @@ func (x *cronJobService) DeleteByIDs(ctx context.Context, ids []xsf.ID) error {
...
@@ -80,7 +80,7 @@ func (x *cronJobService) DeleteByIDs(ctx context.Context, ids []xsf.ID) error {
return
dao
.
CronJobDao
.
DeleteByIDs
(
ctx
,
ids
)
return
dao
.
CronJobDao
.
DeleteByIDs
(
ctx
,
ids
)
}
}
func
(
x
*
cronJobService
)
StartByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
cronJobService
)
StartByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
req
:=
&
types
.
CronJobUpdateByIDReq
{
req
:=
&
types
.
CronJobUpdateByIDReq
{
ID
:
id
,
ID
:
id
,
Enable
:
enums
.
CronJob_Enable_OPEN
,
Enable
:
enums
.
CronJob_Enable_OPEN
,
...
@@ -88,7 +88,7 @@ func (x *cronJobService) StartByID(ctx context.Context, id xsf.ID) error {
...
@@ -88,7 +88,7 @@ func (x *cronJobService) StartByID(ctx context.Context, id xsf.ID) error {
return
x
.
UpdateByID
(
ctx
,
req
)
return
x
.
UpdateByID
(
ctx
,
req
)
}
}
func
(
x
*
cronJobService
)
StopByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
error
{
func
(
x
*
cronJobService
)
StopByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
error
{
req
:=
&
types
.
CronJobUpdateByIDReq
{
req
:=
&
types
.
CronJobUpdateByIDReq
{
ID
:
id
,
ID
:
id
,
Enable
:
enums
.
CronJob_Enable_CLOSE
,
Enable
:
enums
.
CronJob_Enable_CLOSE
,
...
@@ -129,7 +129,7 @@ func (x *cronJobService) UpdateByIDs(ctx context.Context, req *types.CronJobUpda
...
@@ -129,7 +129,7 @@ func (x *cronJobService) UpdateByIDs(ctx context.Context, req *types.CronJobUpda
return
dao
.
CronJobDao
.
UpdateByIDs
(
ctx
,
req
.
IDs
,
cronJobUpd
)
return
dao
.
CronJobDao
.
UpdateByIDs
(
ctx
,
req
.
IDs
,
cronJobUpd
)
}
}
func
(
x
*
cronJobService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
cronJobBiz
*
biz
.
CronJob
,
err
error
)
{
func
(
x
*
cronJobService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
cronJobBiz
*
biz
.
CronJob
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -143,7 +143,7 @@ func (x *cronJobService) GetByID(ctx context.Context, id xsf.ID) (cronJobBiz *bi
...
@@ -143,7 +143,7 @@ func (x *cronJobService) GetByID(ctx context.Context, id xsf.ID) (cronJobBiz *bi
return
x
.
ToBiz
(
ctx
,
cronJob
)
return
x
.
ToBiz
(
ctx
,
cronJob
)
}
}
func
(
x
*
cronJobService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
CronJob
,
error
)
{
func
(
x
*
cronJobService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
CronJob
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -157,7 +157,7 @@ func (x *cronJobService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*bi
...
@@ -157,7 +157,7 @@ func (x *cronJobService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]*bi
return
x
.
ToSliceBiz
(
ctx
,
cronJobs
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobs
)
}
}
func
(
x
*
cronJobService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
CronJob
,
error
)
{
func
(
x
*
cronJobService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
CronJob
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
...
xcron/service/cron_job_log.go
浏览文件 @
fc02815e
...
@@ -3,12 +3,12 @@ package service
...
@@ -3,12 +3,12 @@ package service
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
cronJobLogService
struct
{
type
cronJobLogService
struct
{
...
@@ -23,7 +23,7 @@ func newCronJobLogService() *cronJobLogService {
...
@@ -23,7 +23,7 @@ func newCronJobLogService() *cronJobLogService {
}
}
}
}
func
(
x
*
cronJobLogService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
cronJobLogBiz
*
biz
.
CronJobLog
,
err
error
)
{
func
(
x
*
cronJobLogService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
cronJobLogBiz
*
biz
.
CronJobLog
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -37,7 +37,7 @@ func (x *cronJobLogService) GetByID(ctx context.Context, id xsf.ID) (cronJobLogB
...
@@ -37,7 +37,7 @@ func (x *cronJobLogService) GetByID(ctx context.Context, id xsf.ID) (cronJobLogB
return
x
.
ToBiz
(
ctx
,
cronJobLog
)
return
x
.
ToBiz
(
ctx
,
cronJobLog
)
}
}
func
(
x
*
cronJobLogService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
CronJobLog
,
error
)
{
func
(
x
*
cronJobLogService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
CronJobLog
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -51,7 +51,7 @@ func (x *cronJobLogService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]
...
@@ -51,7 +51,7 @@ func (x *cronJobLogService) GetSliceByIDs(ctx context.Context, ids []xsf.ID) ([]
return
x
.
ToSliceBiz
(
ctx
,
cronJobLogs
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobLogs
)
}
}
func
(
x
*
cronJobLogService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
CronJobLog
,
error
)
{
func
(
x
*
cronJobLogService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
CronJobLog
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -80,7 +80,7 @@ func (x *cronJobLogService) Page(ctx context.Context, req *types.CronJobLogPageR
...
@@ -80,7 +80,7 @@ func (x *cronJobLogService) Page(ctx context.Context, req *types.CronJobLogPageR
}
}
return
cronJobLogBizSlice
,
total
,
nil
return
cronJobLogBizSlice
,
total
,
nil
}
}
func
(
x
*
cronJobLogService
)
GetSliceByJobID
(
ctx
context
.
Context
,
jobID
x
sf
.
ID
)
([]
*
biz
.
CronJobLog
,
error
)
{
func
(
x
*
cronJobLogService
)
GetSliceByJobID
(
ctx
context
.
Context
,
jobID
sf
.
ID
)
([]
*
biz
.
CronJobLog
,
error
)
{
if
jobID
==
0
{
if
jobID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -94,7 +94,7 @@ func (x *cronJobLogService) GetSliceByJobID(ctx context.Context, jobID xsf.ID) (
...
@@ -94,7 +94,7 @@ func (x *cronJobLogService) GetSliceByJobID(ctx context.Context, jobID xsf.ID) (
return
x
.
ToSliceBiz
(
ctx
,
cronJobLogs
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobLogs
)
}
}
func
(
x
*
cronJobLogService
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
x
sf
.
ID
)
([]
*
biz
.
CronJobLog
,
error
)
{
func
(
x
*
cronJobLogService
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
sf
.
ID
)
([]
*
biz
.
CronJobLog
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -108,7 +108,7 @@ func (x *cronJobLogService) GetSliceByJobIDs(ctx context.Context, jobIDs []xsf.I
...
@@ -108,7 +108,7 @@ func (x *cronJobLogService) GetSliceByJobIDs(ctx context.Context, jobIDs []xsf.I
return
x
.
ToSliceBiz
(
ctx
,
cronJobLogs
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobLogs
)
}
}
func
(
x
*
cronJobLogService
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
CronJobLog
,
int
,
error
)
{
func
(
x
*
cronJobLogService
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
CronJobLog
,
int
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -119,7 +119,7 @@ func (x *cronJobLogService) GetMapSliceByJobIDs(ctx context.Context, jobIDs []xs
...
@@ -119,7 +119,7 @@ func (x *cronJobLogService) GetMapSliceByJobIDs(ctx context.Context, jobIDs []xs
if
len
(
cronJobLogBizSlice
)
==
0
{
if
len
(
cronJobLogBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
CronJobLog
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
CronJobLog
)
for
_
,
r
:=
range
cronJobLogBizSlice
{
for
_
,
r
:=
range
cronJobLogBizSlice
{
ret
[
r
.
JobID
]
=
append
(
ret
[
r
.
JobID
],
r
)
ret
[
r
.
JobID
]
=
append
(
ret
[
r
.
JobID
],
r
)
}
}
...
...
xcron/service/cron_job_record.go
浏览文件 @
fc02815e
...
@@ -3,12 +3,12 @@ package service
...
@@ -3,12 +3,12 @@ package service
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/types"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
)
type
cronJobRecordService
struct
{
type
cronJobRecordService
struct
{
...
@@ -23,7 +23,7 @@ func newCronJobRecordService() *cronJobRecordService {
...
@@ -23,7 +23,7 @@ func newCronJobRecordService() *cronJobRecordService {
}
}
}
}
func
(
x
*
cronJobRecordService
)
GetByID
(
ctx
context
.
Context
,
id
x
sf
.
ID
)
(
cronJobRecordBiz
*
biz
.
CronJobRecord
,
err
error
)
{
func
(
x
*
cronJobRecordService
)
GetByID
(
ctx
context
.
Context
,
id
sf
.
ID
)
(
cronJobRecordBiz
*
biz
.
CronJobRecord
,
err
error
)
{
if
id
<=
0
{
if
id
<=
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -34,7 +34,7 @@ func (x *cronJobRecordService) GetByID(ctx context.Context, id xsf.ID) (cronJobR
...
@@ -34,7 +34,7 @@ func (x *cronJobRecordService) GetByID(ctx context.Context, id xsf.ID) (cronJobR
return
x
.
ToBiz
(
ctx
,
cronJobRecord
)
return
x
.
ToBiz
(
ctx
,
cronJobRecord
)
}
}
func
(
x
*
cronJobRecordService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
x
sf
.
ID
)
([]
*
biz
.
CronJobRecord
,
error
)
{
func
(
x
*
cronJobRecordService
)
GetSliceByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
([]
*
biz
.
CronJobRecord
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -48,7 +48,7 @@ func (x *cronJobRecordService) GetSliceByIDs(ctx context.Context, ids []xsf.ID)
...
@@ -48,7 +48,7 @@ func (x *cronJobRecordService) GetSliceByIDs(ctx context.Context, ids []xsf.ID)
return
x
.
ToSliceBiz
(
ctx
,
cronJobRecords
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobRecords
)
}
}
func
(
x
*
cronJobRecordService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
]
*
biz
.
CronJobRecord
,
error
)
{
func
(
x
*
cronJobRecordService
)
GetMapByIDs
(
ctx
context
.
Context
,
ids
[]
sf
.
ID
)
(
map
[
sf
.
ID
]
*
biz
.
CronJobRecord
,
error
)
{
if
len
(
ids
)
==
0
{
if
len
(
ids
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -77,7 +77,7 @@ func (x *cronJobRecordService) Page(ctx context.Context, req *types.CronJobRecor
...
@@ -77,7 +77,7 @@ func (x *cronJobRecordService) Page(ctx context.Context, req *types.CronJobRecor
}
}
return
cronJobRecordBizSlice
,
total
,
nil
return
cronJobRecordBizSlice
,
total
,
nil
}
}
func
(
x
*
cronJobRecordService
)
GetSliceByJobID
(
ctx
context
.
Context
,
jobID
x
sf
.
ID
)
([]
*
biz
.
CronJobRecord
,
error
)
{
func
(
x
*
cronJobRecordService
)
GetSliceByJobID
(
ctx
context
.
Context
,
jobID
sf
.
ID
)
([]
*
biz
.
CronJobRecord
,
error
)
{
if
jobID
==
0
{
if
jobID
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -91,7 +91,7 @@ func (x *cronJobRecordService) GetSliceByJobID(ctx context.Context, jobID xsf.ID
...
@@ -91,7 +91,7 @@ func (x *cronJobRecordService) GetSliceByJobID(ctx context.Context, jobID xsf.ID
return
x
.
ToSliceBiz
(
ctx
,
cronJobRecords
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobRecords
)
}
}
func
(
x
*
cronJobRecordService
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
x
sf
.
ID
)
([]
*
biz
.
CronJobRecord
,
error
)
{
func
(
x
*
cronJobRecordService
)
GetSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
sf
.
ID
)
([]
*
biz
.
CronJobRecord
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -105,7 +105,7 @@ func (x *cronJobRecordService) GetSliceByJobIDs(ctx context.Context, jobIDs []xs
...
@@ -105,7 +105,7 @@ func (x *cronJobRecordService) GetSliceByJobIDs(ctx context.Context, jobIDs []xs
return
x
.
ToSliceBiz
(
ctx
,
cronJobRecords
)
return
x
.
ToSliceBiz
(
ctx
,
cronJobRecords
)
}
}
func
(
x
*
cronJobRecordService
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
xsf
.
ID
)
(
map
[
x
sf
.
ID
][]
*
biz
.
CronJobRecord
,
int
,
error
)
{
func
(
x
*
cronJobRecordService
)
GetMapSliceByJobIDs
(
ctx
context
.
Context
,
jobIDs
[]
sf
.
ID
)
(
map
[
sf
.
ID
][]
*
biz
.
CronJobRecord
,
int
,
error
)
{
if
len
(
jobIDs
)
==
0
{
if
len
(
jobIDs
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
...
@@ -116,7 +116,7 @@ func (x *cronJobRecordService) GetMapSliceByJobIDs(ctx context.Context, jobIDs [
...
@@ -116,7 +116,7 @@ func (x *cronJobRecordService) GetMapSliceByJobIDs(ctx context.Context, jobIDs [
if
len
(
cronJobRecordBizSlice
)
==
0
{
if
len
(
cronJobRecordBizSlice
)
==
0
{
return
nil
,
0
,
nil
return
nil
,
0
,
nil
}
}
ret
:=
make
(
map
[
x
sf
.
ID
][]
*
biz
.
CronJobRecord
)
ret
:=
make
(
map
[
sf
.
ID
][]
*
biz
.
CronJobRecord
)
for
_
,
r
:=
range
cronJobRecordBizSlice
{
for
_
,
r
:=
range
cronJobRecordBizSlice
{
ret
[
r
.
JobID
]
=
append
(
ret
[
r
.
JobID
],
r
)
ret
[
r
.
JobID
]
=
append
(
ret
[
r
.
JobID
],
r
)
}
}
...
...
xcron/types/cron_job.go
浏览文件 @
fc02815e
package
types
package
types
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
...
@@ -41,7 +41,7 @@ func (x *CronJobGetByEnableReq) Valid() error {
...
@@ -41,7 +41,7 @@ func (x *CronJobGetByEnableReq) Valid() error {
}
}
type
CronJobUpdateByIDReq
struct
{
type
CronJobUpdateByIDReq
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"101"`
//ID
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" validate:"required" example:"101"`
//ID
JobName
string
`json:"jobName" form:"jobName" validate:"required" example:"任务-自动确认订单"`
// 定时任务名称
JobName
string
`json:"jobName" form:"jobName" validate:"required" example:"任务-自动确认订单"`
// 定时任务名称
JobCode
string
`json:"jobCode" form:"jobCode" validate:"required" example:"autoConfirmOrdersTask"`
// 定时任务code
JobCode
string
`json:"jobCode" form:"jobCode" validate:"required" example:"autoConfirmOrdersTask"`
// 定时任务code
TimeSpec
string
`json:"timeSpec" form:"timeSpec" validate:"required" example:"0 0 0 * * ?"`
// 定时任务时间表达式
TimeSpec
string
`json:"timeSpec" form:"timeSpec" validate:"required" example:"0 0 0 * * ?"`
// 定时任务时间表达式
...
@@ -55,7 +55,7 @@ func (x *CronJobUpdateByIDReq) Valid() error {
...
@@ -55,7 +55,7 @@ func (x *CronJobUpdateByIDReq) Valid() error {
}
}
type
CronJobUpdateByIDsReq
struct
{
type
CronJobUpdateByIDsReq
struct
{
IDs
[]
xsf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"101"`
//ID
IDs
[]
sf
.
ID
`json:"ids" swaggertype:"array,string" form:"ids" validate:"required" example:"101"`
//ID
JobName
string
`json:"jobName" form:"jobName" validate:"required" example:"任务-自动确认订单"`
// 定时任务名称
JobName
string
`json:"jobName" form:"jobName" validate:"required" example:"任务-自动确认订单"`
// 定时任务名称
JobCode
string
`json:"jobCode" form:"jobCode" validate:"required" example:"autoConfirmOrdersTask"`
// 定时任务code
JobCode
string
`json:"jobCode" form:"jobCode" validate:"required" example:"autoConfirmOrdersTask"`
// 定时任务code
TimeSpec
string
`json:"timeSpec" form:"timeSpec" validate:"required" example:"0 0 0 * * ?"`
// 定时任务时间表达式
TimeSpec
string
`json:"timeSpec" form:"timeSpec" validate:"required" example:"0 0 0 * * ?"`
// 定时任务时间表达式
...
@@ -70,7 +70,7 @@ func (x *CronJobUpdateByIDsReq) Valid() error {
...
@@ -70,7 +70,7 @@ func (x *CronJobUpdateByIDsReq) Valid() error {
type
CronJobPageReq
struct
{
type
CronJobPageReq
struct
{
query
.
Pagination
query
.
Pagination
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" query:"" example:"101"`
//ID
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" query:"" example:"101"`
//ID
JobName
string
`json:"jobName" form:"jobName" query:"" example:"任务-自动确认订单"`
// 定时任务名称
JobName
string
`json:"jobName" form:"jobName" query:"" example:"任务-自动确认订单"`
// 定时任务名称
JobCode
string
`json:"jobCode" form:"jobCode" query:"" example:"autoConfirmOrdersTask"`
// 定时任务code
JobCode
string
`json:"jobCode" form:"jobCode" query:"" example:"autoConfirmOrdersTask"`
// 定时任务code
TimeSpec
string
`json:"timeSpec" form:"timeSpec" query:"" example:"0 0 0 * * ?"`
// 定时任务时间表达式
TimeSpec
string
`json:"timeSpec" form:"timeSpec" query:"" example:"0 0 0 * * ?"`
// 定时任务时间表达式
...
...
xcron/types/cron_job_log.go
浏览文件 @
fc02815e
package
types
package
types
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
type
CronJobLogGetByJobIDReq
struct
{
type
CronJobLogGetByJobIDReq
struct
{
JobID
x
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" validate:"required" example:"101"`
//job ID
JobID
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" validate:"required" example:"101"`
//job ID
}
}
type
CronJobLogPageReq
struct
{
type
CronJobLogPageReq
struct
{
query
.
Pagination
query
.
Pagination
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" query:"" example:"101"`
//ID
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" query:"" example:"101"`
//ID
JobID
xsf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" query:"" example:"101"`
// job ID
JobID
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" query:"" example:"101"`
// job ID
Info
string
`json:"info" form:"info" query:"" example:"job occur error..."`
// 日志
Info
string
`json:"info" form:"info" query:"" example:"job occur error..."`
// 日志
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2025-01-07 12:20:43"`
//创建时间起始 (>=)
CreatedAtBegin
xtime
.
DateTime
`json:"createdAtBegin" form:"createdAtBegin" query:"type:gte;column:created_at" example:"2025-01-07 12:20:43"`
//创建时间起始 (>=)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2025-01-07 12:20:43"`
//创建时间截止 (<)
CreatedAtEnd
xtime
.
DateTime
`json:"createdAtEnd" form:"createdAtEnd" query:"type:lt;column:created_at" example:"2025-01-07 12:20:43"`
//创建时间截止 (<)
...
...
xcron/types/cron_job_record.go
浏览文件 @
fc02815e
package
types
package
types
import
(
import
(
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/biz"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
)
)
var
_
xtime
.
DateTime
var
_
xtime
.
DateTime
type
CronJobRecordGetByJobIDReq
struct
{
type
CronJobRecordGetByJobIDReq
struct
{
JobID
x
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" validate:"required" example:"101"`
//job ID
JobID
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" validate:"required" example:"101"`
//job ID
}
}
type
CronJobRecordPageReq
struct
{
type
CronJobRecordPageReq
struct
{
query
.
Pagination
query
.
Pagination
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" query:"" example:"101"`
//ID
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" query:"" example:"101"`
//ID
JobID
xsf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" query:"" example:"101"`
// job ID
JobID
sf
.
ID
`json:"jobID" form:"jobID" swaggertype:"string" query:"" example:"101"`
// job ID
BeginTimeBegin
xtime
.
DateTime
`json:"beginTimeBegin" form:"beginTimeBegin" query:"type:gte;column:begin_time" example:"2025-01-07 12:20:43"`
//开始时间起始 (>=)
BeginTimeBegin
xtime
.
DateTime
`json:"beginTimeBegin" form:"beginTimeBegin" query:"type:gte;column:begin_time" example:"2025-01-07 12:20:43"`
//开始时间起始 (>=)
BeginTimeEnd
xtime
.
DateTime
`json:"beginTimeEnd" form:"beginTimeEnd" query:"type:lt;column:begin_time" example:"2025-01-07 12:20:43"`
//开始时间截止 (<)
BeginTimeEnd
xtime
.
DateTime
`json:"beginTimeEnd" form:"beginTimeEnd" query:"type:lt;column:begin_time" example:"2025-01-07 12:20:43"`
//开始时间截止 (<)
EndTimeBegin
xtime
.
DateTime
`json:"endTimeBegin" form:"endTimeBegin" query:"type:gte;column:end_time" example:"2025-01-07 12:20:43"`
//结束时间起始 (>=)
EndTimeBegin
xtime
.
DateTime
`json:"endTimeBegin" form:"endTimeBegin" query:"type:gte;column:end_time" example:"2025-01-07 12:20:43"`
//结束时间起始 (>=)
...
...
xutils/ctxutils/ctx.go
浏览文件 @
fc02815e
...
@@ -7,8 +7,8 @@ import (
...
@@ -7,8 +7,8 @@ import (
"strings"
"strings"
"time"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"github.com/spf13/cast"
...
@@ -151,7 +151,7 @@ func GetGinCtxTid(c *gin.Context) string {
...
@@ -151,7 +151,7 @@ func GetGinCtxTid(c *gin.Context) string {
}
}
func
GenerateTid
()
string
{
func
GenerateTid
()
string
{
return
x
sf
.
GenerateID
()
.
String
()
return
sf
.
GenerateID
()
.
String
()
}
}
func
GetCtxTid
(
ctx
context
.
Context
)
string
{
func
GetCtxTid
(
ctx
context
.
Context
)
string
{
...
@@ -203,15 +203,15 @@ func GetGinCtx(ctx context.Context) (*gin.Context, error) {
...
@@ -203,15 +203,15 @@ func GetGinCtx(ctx context.Context) (*gin.Context, error) {
return
nil
,
ErrorGinContextNotFound
return
nil
,
ErrorGinContextNotFound
}
}
func
GetGinUID
(
c
*
gin
.
Context
)
x
sf
.
ID
{
func
GetGinUID
(
c
*
gin
.
Context
)
sf
.
ID
{
if
val
:=
c
.
Value
(
KeyUID
);
val
!=
nil
{
if
val
:=
c
.
Value
(
KeyUID
);
val
!=
nil
{
if
v
,
ok
:=
val
.
(
x
sf
.
ID
);
ok
{
if
v
,
ok
:=
val
.
(
sf
.
ID
);
ok
{
return
v
return
v
}
}
v
:=
cast
.
ToInt64
(
val
)
v
:=
cast
.
ToInt64
(
val
)
return
x
sf
.
ParseInt64
(
v
)
return
sf
.
ParseInt64
(
v
)
}
}
return
x
sf
.
ID
(
0
)
return
sf
.
ID
(
0
)
}
}
func
GetGinUName
(
c
*
gin
.
Context
)
string
{
func
GetGinUName
(
c
*
gin
.
Context
)
string
{
...
@@ -234,15 +234,15 @@ func GetGinCompanyName(c *gin.Context) string {
...
@@ -234,15 +234,15 @@ func GetGinCompanyName(c *gin.Context) string {
return
""
return
""
}
}
func
GetCtxUID
(
c
context
.
Context
)
x
sf
.
ID
{
func
GetCtxUID
(
c
context
.
Context
)
sf
.
ID
{
if
val
:=
c
.
Value
(
KeyUID
);
val
!=
nil
{
if
val
:=
c
.
Value
(
KeyUID
);
val
!=
nil
{
if
v
,
ok
:=
val
.
(
x
sf
.
ID
);
ok
{
if
v
,
ok
:=
val
.
(
sf
.
ID
);
ok
{
return
v
return
v
}
}
v
:=
cast
.
ToInt64
(
val
)
v
:=
cast
.
ToInt64
(
val
)
return
x
sf
.
ParseInt64
(
v
)
return
sf
.
ParseInt64
(
v
)
}
}
return
x
sf
.
ID
(
0
)
return
sf
.
ID
(
0
)
}
}
func
GetCtxCompanyName
(
c
context
.
Context
)
string
{
func
GetCtxCompanyName
(
c
context
.
Context
)
string
{
...
@@ -289,34 +289,34 @@ func GetGinUserName(c *gin.Context) string {
...
@@ -289,34 +289,34 @@ func GetGinUserName(c *gin.Context) string {
return
getGinVal
[
string
](
c
,
KeyUName
)
return
getGinVal
[
string
](
c
,
KeyUName
)
}
}
func
GetGinShopID
(
c
*
gin
.
Context
)
x
sf
.
ID
{
func
GetGinShopID
(
c
*
gin
.
Context
)
sf
.
ID
{
return
getGinVal
[
x
sf
.
ID
](
c
,
KeyShopID
)
return
getGinVal
[
sf
.
ID
](
c
,
KeyShopID
)
}
}
func
GetCtxShopID
(
c
context
.
Context
)
x
sf
.
ID
{
func
GetCtxShopID
(
c
context
.
Context
)
sf
.
ID
{
return
getCtxVal
[
x
sf
.
ID
](
c
,
KeyShopID
)
return
getCtxVal
[
sf
.
ID
](
c
,
KeyShopID
)
}
}
func
GetGinCompanyID
(
c
*
gin
.
Context
)
x
sf
.
ID
{
func
GetGinCompanyID
(
c
*
gin
.
Context
)
sf
.
ID
{
if
val
:=
c
.
Value
(
KeyCompanyID
);
val
!=
nil
{
if
val
:=
c
.
Value
(
KeyCompanyID
);
val
!=
nil
{
if
v
,
ok
:=
val
.
(
x
sf
.
ID
);
ok
{
if
v
,
ok
:=
val
.
(
sf
.
ID
);
ok
{
return
v
return
v
}
}
v
:=
cast
.
ToInt64
(
val
)
v
:=
cast
.
ToInt64
(
val
)
return
x
sf
.
ParseInt64
(
v
)
return
sf
.
ParseInt64
(
v
)
}
}
return
x
sf
.
ID
(
0
)
return
sf
.
ID
(
0
)
}
}
func
GetCtxCompanyID
(
c
context
.
Context
)
x
sf
.
ID
{
func
GetCtxCompanyID
(
c
context
.
Context
)
sf
.
ID
{
if
val
:=
c
.
Value
(
KeyCompanyID
);
val
!=
nil
{
if
val
:=
c
.
Value
(
KeyCompanyID
);
val
!=
nil
{
if
v
,
ok
:=
val
.
(
x
sf
.
ID
);
ok
{
if
v
,
ok
:=
val
.
(
sf
.
ID
);
ok
{
return
v
return
v
}
}
v
:=
cast
.
ToInt64
(
val
)
v
:=
cast
.
ToInt64
(
val
)
return
x
sf
.
ParseInt64
(
v
)
return
sf
.
ParseInt64
(
v
)
}
}
return
x
sf
.
ID
(
0
)
return
sf
.
ID
(
0
)
}
}
func
getGinVal
[
T
any
](
c
*
gin
.
Context
,
key
string
)
T
{
func
getGinVal
[
T
any
](
c
*
gin
.
Context
,
key
string
)
T
{
...
...
xutils/gormutils/gormutils_test.go
浏览文件 @
fc02815e
...
@@ -8,9 +8,9 @@ import (
...
@@ -8,9 +8,9 @@ import (
"testing"
"testing"
"time"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/gormutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/gormutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gorm.io/driver/mysql"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/logger"
...
@@ -21,7 +21,7 @@ func TestMakeWhere(t *testing.T) {
...
@@ -21,7 +21,7 @@ func TestMakeWhere(t *testing.T) {
in
:=
PageReq2
{}
in
:=
PageReq2
{}
in
.
PageIndex
=
1
in
.
PageIndex
=
1
in
.
PageSize
=
50
in
.
PageSize
=
50
in
.
IDs
=
[]
x
sf
.
ID
{
10
,
2
,
3
}
in
.
IDs
=
[]
sf
.
ID
{
10
,
2
,
3
}
in
.
UserID
=
10
in
.
UserID
=
10
in
.
SiteName
=
"优盟"
in
.
SiteName
=
"优盟"
in
.
Sort
=
"-id,siteID,-siteName"
in
.
Sort
=
"-id,siteID,-siteName"
...
@@ -60,21 +60,21 @@ func getConn() *gorm.DB {
...
@@ -60,21 +60,21 @@ func getConn() *gorm.DB {
type
PageReq
struct
{
type
PageReq
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
x
sf
.
ID
`json:"ids" gq:"type:in;table:op;column:id" example:"10"`
IDs
[]
sf
.
ID
`json:"ids" gq:"type:in;table:op;column:id" example:"10"`
UserID
x
sf
.
ID
`json:"userID" gq:"table:su;column:user_id" example:"10"`
UserID
sf
.
ID
`json:"userID" gq:"table:su;column:user_id" example:"10"`
SiteName
string
`json:"siteName" gq:"type:left;table:s;column:name" example:"优盟"`
SiteName
string
`json:"siteName" gq:"type:left;table:s;column:name" example:"优盟"`
}
}
type
PageReq2
struct
{
type
PageReq2
struct
{
query
.
Pagination
query
.
Pagination
IDs
[]
x
sf
.
ID
`json:"ids" query:"type:in;table:op;column:id" example:"10"`
IDs
[]
sf
.
ID
`json:"ids" query:"type:in;table:op;column:id" example:"10"`
UserID
x
sf
.
ID
`json:"userID" query:"table:su;column:user_id" example:"10"`
UserID
sf
.
ID
`json:"userID" query:"table:su;column:user_id" example:"10"`
SiteName
string
`json:"siteName" query:"type:left;table:s;column:name" example:"优盟"`
SiteName
string
`json:"siteName" query:"type:left;table:s;column:name" example:"优盟"`
}
}
type
User
struct
{
type
User
struct
{
ID
xsf
.
ID
`json:"id" gorm:"id" gq:"sort:op.id"`
ID
sf
.
ID
`json:"id" gorm:"id" gq:"sort:op.id"`
SiteID
xsf
.
ID
`json:"siteID" gorm:"site_id" gq:"sort:s.id;table:s;column:id"`
SiteID
sf
.
ID
`json:"siteID" gorm:"site_id" gq:"sort:s.id;table:s;column:id"`
SiteName
string
`json:"siteName" gorm:"site_name" gq:"sort:s.name;table:s;column:name"`
SiteName
string
`json:"siteName" gorm:"site_name" gq:"sort:s.name;table:s;column:name"`
}
}
...
...
xutils/idutils/idutils.go
deleted
100644 → 0
浏览文件 @
ff4eee31
package
idutils
import
(
"context"
"errors"
"fmt"
"net/http"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
)
var
(
idGenerateType
=
"snowflake"
// 默认snowflake方式生成
leafRetryCount
=
3
leafShowLog
=
false
leafAddr
string
=
"http://leaf.qitu"
leafApi
=
&
client
{
cli
:
httpcli
.
NewClient
(
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
MaxIdleConnsPerHost
:
4
,
MaxIdleConns
:
4
,
IdleConnTimeout
:
90
*
time
.
Second
,
},
}),
}
)
type
client
struct
{
cli
*
httpcli
.
Client
}
func
Init
()
error
{
if
config
.
Cfg
.
App
.
IDGeneration
.
Type
!=
""
{
idGenerateType
=
config
.
Cfg
.
App
.
IDGeneration
.
Type
if
idGenerateType
==
"leaf"
{
if
config
.
Cfg
.
App
.
IDGeneration
.
Leaf
.
Addr
!=
""
{
leafAddr
=
config
.
Cfg
.
App
.
IDGeneration
.
Leaf
.
Addr
}
if
config
.
Cfg
.
App
.
IDGeneration
.
Leaf
.
ShowLog
{
leafShowLog
=
true
}
if
config
.
Cfg
.
App
.
IDGeneration
.
Leaf
.
RetryCount
>
0
{
leafRetryCount
=
config
.
Cfg
.
App
.
IDGeneration
.
Leaf
.
RetryCount
}
}
}
logger
.
Infof
(
"[idutils] type: %s"
,
config
.
Cfg
.
App
.
IDGeneration
.
Type
)
return
nil
}
func
GenerateID
(
ctx
context
.
Context
,
bizTag
string
)
(
xsf
.
ID
,
error
)
{
if
idGenerateType
==
"snowflake"
{
return
generateSFID
(
ctx
,
bizTag
)
}
else
{
return
generateApiID
(
ctx
,
bizTag
)
}
}
func
generateSFID
(
_
context
.
Context
,
_
string
)
(
xsf
.
ID
,
error
)
{
return
xsf
.
GenerateID
(),
nil
}
func
GenerateSFID
()
xsf
.
ID
{
return
xsf
.
GenerateID
()
}
func
generateApiID
(
ctx
context
.
Context
,
bizTag
string
)
(
xsf
.
ID
,
error
)
{
url
:=
fmt
.
Sprintf
(
`%s/api/leaf?biz_tag=%s`
,
leafAddr
,
bizTag
)
var
id
xsf
.
ID
reply
:=
&
IDReply
{
Data
:
&
id
,
}
req
:=
leafApi
.
cli
.
NewRequest
()
if
!
leafShowLog
{
req
=
req
.
OmitLog
()
}
if
err
:=
req
.
SetRetry
(
leafRetryCount
)
.
SetContentType
(
"application/json"
)
.
SetURL
(
url
)
.
GET
(
ctx
)
.
BindJSON
(
reply
)
.
Err
();
err
!=
nil
{
logger
.
Error
(
"调用leaf失败"
,
logger
.
String
(
"bizTag"
,
bizTag
),
logger
.
Err
(
err
))
return
xsf
.
ID
(
0
),
fmt
.
Errorf
(
"调用leaf失败, %w"
,
err
)
}
if
reply
.
Code
==
1
{
return
id
,
nil
}
return
xsf
.
ID
(
0
),
errors
.
New
(
reply
.
Msg
)
}
type
IDReply
struct
{
Code
int
`json:"code"`
Data
any
`json:"data"`
Msg
string
`json:"msg"`
}
xutils/weblogutils/web_log.go
浏览文件 @
fc02815e
...
@@ -16,10 +16,10 @@ import (
...
@@ -16,10 +16,10 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
merge
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/merger"
merge
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/merger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/sf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/ctxutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/jsonutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/jsonutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/retryutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/retryutils"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/xtime"
"gorm.io/gorm"
"gorm.io/gorm"
glogger
"gorm.io/gorm/logger"
glogger
"gorm.io/gorm/logger"
...
@@ -102,7 +102,7 @@ func Init() {
...
@@ -102,7 +102,7 @@ func Init() {
if
l
.
Len
()
==
0
{
if
l
.
Len
()
==
0
{
return
nil
return
nil
}
}
ctx
:=
context
.
WithValue
(
context
.
Background
(),
ctxutils
.
ContextTraceIDKey
,
x
sf
.
GenerateID
()
.
String
())
ctx
:=
context
.
WithValue
(
context
.
Background
(),
ctxutils
.
ContextTraceIDKey
,
sf
.
GenerateID
()
.
String
())
ors
:=
make
([]
*
WebLog
,
0
,
l
.
Len
())
ors
:=
make
([]
*
WebLog
,
0
,
l
.
Len
())
for
e
:=
l
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
for
e
:=
l
.
Front
();
e
!=
nil
;
e
=
e
.
Next
()
{
le
,
ok
:=
e
.
Value
.
(
*
WebLog
)
le
,
ok
:=
e
.
Value
.
(
*
WebLog
)
...
@@ -156,7 +156,7 @@ func Init() {
...
@@ -156,7 +156,7 @@ func Init() {
func
AddAsync
(
ctx
context
.
Context
,
operate
string
,
req
*
entity
.
CopyHttpReq
,
rsp
*
entity
.
CopyHttpRsp
)
{
func
AddAsync
(
ctx
context
.
Context
,
operate
string
,
req
*
entity
.
CopyHttpReq
,
rsp
*
entity
.
CopyHttpRsp
)
{
wl
:=
&
WebLog
{}
wl
:=
&
WebLog
{}
wl
.
ID
=
x
sf
.
GenerateID
()
wl
.
ID
=
sf
.
GenerateID
()
wl
.
CompanyName
=
ctxutils
.
GetCtxCompanyName
(
ctx
)
wl
.
CompanyName
=
ctxutils
.
GetCtxCompanyName
(
ctx
)
wl
.
CompanyID
=
ctxutils
.
GetCtxCompanyID
(
ctx
)
wl
.
CompanyID
=
ctxutils
.
GetCtxCompanyID
(
ctx
)
wl
.
UID
=
ctxutils
.
GetCtxUID
(
ctx
)
wl
.
UID
=
ctxutils
.
GetCtxUID
(
ctx
)
...
@@ -194,9 +194,9 @@ func (x *webLogDao) Create(ctx context.Context, r *WebLog) error {
...
@@ -194,9 +194,9 @@ func (x *webLogDao) Create(ctx context.Context, r *WebLog) error {
}
}
type
WebLog
struct
{
type
WebLog
struct
{
ID
xsf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"1000"`
//主键
ID
sf
.
ID
`json:"id" form:"id" swaggertype:"string" gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement;comment:主键" example:"1000"`
//主键
CompanyID
xsf
.
ID
`json:"companyID" form:"companyID" swaggertype:"string" gorm:"column:company_id;type:bigint(20) unsigned;comment:公司ID" example:"1008"`
//公司ID
CompanyID
sf
.
ID
`json:"companyID" form:"companyID" swaggertype:"string" gorm:"column:company_id;type:bigint(20) unsigned;comment:公司ID" example:"1008"`
//公司ID
UID
xsf
.
ID
`json:"uID" form:"uID" swaggertype:"string" gorm:"column:u_id;type:bigint(20) unsigned;comment:用户ID" example:"2008"`
//用户ID
UID
sf
.
ID
`json:"uID" form:"uID" swaggertype:"string" gorm:"column:u_id;type:bigint(20) unsigned;comment:用户ID" example:"2008"`
//用户ID
CompanyName
string
`json:"companyName" form:"companyName" gorm:"column:company_name;type:varchar(128);comment:公司名称" example:"tomcat"`
//公司名称
CompanyName
string
`json:"companyName" form:"companyName" gorm:"column:company_name;type:varchar(128);comment:公司名称" example:"tomcat"`
//公司名称
UName
string
`json:"uName" form:"uName" gorm:"column:u_name;type:varchar(128);comment:名称" example:"tomcat"`
//名称
UName
string
`json:"uName" form:"uName" gorm:"column:u_name;type:varchar(128);comment:名称" example:"tomcat"`
//名称
Operate
string
`json:"operate" form:"operate" gorm:"column:operate;type:varchar(128);comment:操作" example:"用户登出"`
//操作
Operate
string
`json:"operate" form:"operate" gorm:"column:operate;type:varchar(128);comment:操作" example:"用户登出"`
//操作
...
@@ -206,7 +206,7 @@ type WebLog struct {
...
@@ -206,7 +206,7 @@ type WebLog struct {
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2025-01-07 12:20:43"`
//创建时间
CreatedAt
xtime
.
DateTime
`json:"createdAt" form:"createdAt" gorm:"column:created_at;type:datetime;comment:创建时间" example:"2025-01-07 12:20:43"`
//创建时间
}
}
func
(
x
WebLog
)
GetID
()
x
sf
.
ID
{
func
(
x
WebLog
)
GetID
()
sf
.
ID
{
return
x
.
ID
return
x
.
ID
}
}
...
...
xutils/xsf/xsf_test.go
deleted
100644 → 0
浏览文件 @
ff4eee31
package
xsf
import
(
"fmt"
"reflect"
"testing"
)
func
TestID_MarshalJSON
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
f
ID
want
[]
byte
wantErr
bool
}{
// TODO: Add test cases.
{
name
:
"test1"
,
f
:
ID
(
1002
),
want
:
[]
byte
(
`"1002"`
),
wantErr
:
false
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
,
err
:=
tt
.
f
.
MarshalJSON
()
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"ID.MarshalJSON() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
}
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"ID.MarshalJSON() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
func
TestID_String
(
t
*
testing
.
T
)
{
for
i
:=
0
;
i
<
10
;
i
++
{
fmt
.
Println
(
GenerateID
()
.
String
())
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论