切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
3139bd5fd1db26b11119cf50a4dbf9a1ee6473de
1 个父辈
c8ac2252
综合自评消息提示
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
159 行增加
和
8 行删除
pkg/application/factory/reposetory.go
pkg/application/notify/service/message_personal.go
pkg/domain/message_personal.go
pkg/domain/user_auth_test.go
pkg/infrastructure/pg/models/message_personal.go
pkg/infrastructure/repository/pg_message_personal_repository.go
pkg/application/factory/reposetory.go
查看文件 @
3139bd5
...
...
@@ -208,3 +208,11 @@ func CreateLogSmsRepository(options map[string]interface{}) domain.LogSmsReposit
}
return
repository
.
NewLogSmsRepository
(
transactionContext
)
}
func
CreateMessagePersonalRepository
(
options
map
[
string
]
interface
{})
domain
.
MessagePersonalRepository
{
var
transactionContext
*
pg
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
transactionContext
=
value
.
(
*
pg
.
TransactionContext
)
}
return
repository
.
NewMessagePersonalRepository
(
transactionContext
)
}
...
...
pkg/application/notify/service/message_personal.go
查看文件 @
3139bd5
package
notify
import
(
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
...
...
@@ -20,7 +23,7 @@ func NewMessagePersonalService() *MessagePersonalService {
}
// 获取今天的周期综合自评消息提示
func
(
srv
*
MessagePersonalService
)
TodayMessageSummaryEvaluationSelf
(
param
*
command
.
GetUserMessageCommand
)
(
interface
{},
error
)
{
func
(
srv
*
MessagePersonalService
)
TodayMessageSummaryEvaluationSelf
(
param
*
command
.
GetUserMessageCommand
)
(
map
[
string
]
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
...
...
@@ -41,11 +44,61 @@ func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *comm
"types"
:
domain
.
EvaluationSelf
,
"beginTime"
:
nowTime
,
"endTime"
:
nowTime
,
"limit"
:
20
,
})
_
=
evaluationList
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"周期综合自评"
+
err
.
Error
())
}
resp
:=
map
[
string
]
interface
{}{
"needNotify"
:
false
,
"content"
:
""
,
}
if
len
(
evaluationList
)
==
0
{
return
resp
,
nil
}
messageRepo
:=
factory
.
CreateMessagePersonalRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
newMessageList
:=
[]
domain
.
MessagePersonal
{}
for
_
,
val
:=
range
evaluationList
{
payload
:=
map
[
string
]
string
{
"id"
:
strconv
.
Itoa
(
val
.
Id
),
}
payloadStr
,
_
:=
json
.
Marshal
(
payload
)
cnt
,
_
,
err
:=
messageRepo
.
Find
(
map
[
string
]
interface
{}{
"types"
:
domain
.
MessageTypesOther
,
"targetUserId"
:
param
.
UserId
,
"playload"
:
string
(
payloadStr
),
"limit"
:
1
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"检查自评消息记录"
+
err
.
Error
())
}
if
cnt
==
0
{
newMessageList
=
append
(
newMessageList
,
domain
.
MessagePersonal
{
Id
:
0
,
Types
:
domain
.
MessageTypesOther
,
TargetUserId
:
val
.
TargetUser
.
UserId
,
ReadFlag
:
domain
.
MessageIsRead
,
Title
:
fmt
.
Sprintf
(
"%s综合自评已开启,请前往进行评估"
,
val
.
CycleName
),
Content
:
fmt
.
Sprintf
(
"%s综合自评已开启,请前往进行评估"
,
val
.
CycleName
),
CreatedAt
:
time
.
Time
{},
UpdatedAt
:
time
.
Time
{},
Payload
:
string
(
payloadStr
),
})
resp
[
"needNotify"
]
=
true
resp
[
"content"
]
=
fmt
.
Sprintf
(
"%s综合自评已开启,请前往进行评估"
,
val
.
CycleName
)
break
}
}
for
i
:=
range
newMessageList
{
err
=
messageRepo
.
Save
(
&
newMessageList
[
i
])
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"保存自评消息记录"
+
err
.
Error
())
}
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
nil
,
nil
return
resp
,
nil
}
...
...
pkg/domain/message_personal.go
查看文件 @
3139bd5
...
...
@@ -5,7 +5,7 @@ import "time"
// MessagePersonal 个人的消息提示
type
MessagePersonal
struct
{
Id
int
`json:"id"`
//
Types
string
`json:"types"`
//消息类型
Types
MessageTypes
`json:"types"`
//消息类型
TargetUserId
int
`json:"targetUserId"`
//消息指向的用户
ReadFlag
MessageReadFlag
`json:"readFlag"`
//1:已读、2:未读
Title
string
`json:"title"`
//消息的标题
...
...
@@ -27,3 +27,8 @@ const (
MessageIsRead
MessageReadFlag
=
"read"
MessageUnread
MessageReadFlag
=
"unread"
)
type
MessagePersonalRepository
interface
{
Save
(
param
*
MessagePersonal
)
error
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
MessagePersonal
,
error
)
}
...
...
pkg/domain/user_auth_test.go
查看文件 @
3139bd5
...
...
@@ -9,8 +9,8 @@ import (
func
TestGenerateToken
(
t
*
testing
.
T
)
{
ut
:=
UserAuth
{
CompanyId
:
8
,
UserId
:
3435675157551872
,
Phone
:
"18060823798"
,
UserId
:
3422181461696000
,
Phone
:
"13066667702"
,
PlatformId
:
29
,
AdminType
:
1
,
}
...
...
pkg/infrastructure/pg/models/message_personal.go
查看文件 @
3139bd5
...
...
@@ -13,5 +13,5 @@ type MessagePersonal struct {
Content
string
`pg:"content"`
//消息的内容
CreatedAt
time
.
Time
`pg:"created_at"`
UpdatedAt
time
.
Time
`pg:"updated_at"`
Payload
string
`pg:"payload"`
//消息的额外承载的数据
Payload
string
`pg:"payload
,type:jsonb
"`
//消息的额外承载的数据
}
...
...
pkg/infrastructure/repository/pg_message_personal_repository.go
0 → 100644
查看文件 @
3139bd5
package
repository
import
(
"time"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
)
type
MessagePersonalRepository
struct
{
transactionContext
*
pgTransaction
.
TransactionContext
}
var
_
domain
.
MessagePersonalRepository
=
(
*
MessagePersonalRepository
)(
nil
)
func
NewMessagePersonalRepository
(
tx
*
pgTransaction
.
TransactionContext
)
*
MessagePersonalRepository
{
return
&
MessagePersonalRepository
{
transactionContext
:
tx
,
}
}
func
(
repo
*
MessagePersonalRepository
)
TransformToDomain
(
param
*
models
.
MessagePersonal
)
*
domain
.
MessagePersonal
{
return
&
domain
.
MessagePersonal
{
Id
:
param
.
Id
,
Types
:
domain
.
MessageTypes
(
param
.
Types
),
TargetUserId
:
param
.
TargetUserId
,
ReadFlag
:
domain
.
MessageReadFlag
(
param
.
ReadFlag
),
Title
:
param
.
Title
,
Content
:
param
.
Content
,
Payload
:
param
.
Payload
,
UpdatedAt
:
param
.
UpdatedAt
,
CreatedAt
:
param
.
CreatedAt
,
}
}
func
(
repo
*
MessagePersonalRepository
)
Save
(
param
*
domain
.
MessagePersonal
)
error
{
message
:=
&
models
.
MessagePersonal
{
Id
:
param
.
Id
,
Types
:
string
(
param
.
Types
),
TargetUserId
:
param
.
TargetUserId
,
ReadFlag
:
string
(
param
.
ReadFlag
),
Title
:
param
.
Title
,
Content
:
param
.
Content
,
Payload
:
param
.
Payload
,
UpdatedAt
:
time
.
Now
(),
CreatedAt
:
param
.
CreatedAt
,
}
tx
:=
repo
.
transactionContext
.
PgTx
if
message
.
Id
==
0
{
message
.
CreatedAt
=
time
.
Now
()
_
,
err
:=
tx
.
Model
(
message
)
.
Insert
()
return
err
}
_
,
err
:=
tx
.
Model
(
message
)
.
WherePK
()
.
Update
()
return
err
}
func
(
repo
*
MessagePersonalRepository
)
Find
(
param
map
[
string
]
interface
{})
(
int
,
[]
*
domain
.
MessagePersonal
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
var
m
[]
*
models
.
MessagePersonal
query
:=
tx
.
Model
(
&
m
)
.
Limit
(
20
)
if
v
,
ok
:=
param
[
"targetUserId"
];
ok
{
query
.
Where
(
"target_user_id=?"
,
v
)
}
if
v
,
ok
:=
param
[
"types"
];
ok
{
query
.
Where
(
"types=?"
,
v
)
}
if
v
,
ok
:=
param
[
"playload"
];
ok
{
query
.
Where
(
"playload @>?"
,
v
)
}
query
.
Order
(
"id desc"
)
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
}
var
datas
[]
*
domain
.
MessagePersonal
for
_
,
v
:=
range
m
{
d
:=
repo
.
TransformToDomain
(
v
)
datas
=
append
(
datas
,
d
)
}
return
count
,
datas
,
nil
}
...
...
请
注册
或
登录
后发表评论