切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
6b0c8f13802892e85c3f559c47b4df51f65aa42f
2 个父辈
87f25834
044b982e
Merge branch 'dev-tangxvhui' into test
隐藏空白字符变更
内嵌
并排对比
正在显示
10 个修改的文件
包含
246 行增加
和
48 行删除
pkg/application/factory/reposetory.go
pkg/application/notify/message_personal.go
pkg/application/notify/service/message_personal.go
pkg/domain/message_personal.go
pkg/domain/user_auth_test.go
pkg/infrastructure/pg/init.go
pkg/infrastructure/pg/models/message_personal.go
pkg/infrastructure/repository/pg_message_personal_repository.go
pkg/port/beego/controllers/message_personal_controller.go
sql/2023-03-24.sql
pkg/application/factory/reposetory.go
查看文件 @
6b0c8f1
...
...
@@ -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/message_personal.go
已删除
100644 → 0
查看文件 @
87f2583
package
notify
import
(
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
)
// 个人信息提示
type
MessagePersonalService
struct
{
}
func
NewMessagePersonalService
()
*
MessagePersonalService
{
newService
:=
&
MessagePersonalService
{}
return
newService
}
// 获取今天的周期综合自评消息提示
func
(
srv
*
MessagePersonalService
)
TodayMessageSummaryEvaluationSelf
(
param
*
command
.
GetUserMessageCommand
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
// nowTime := time.Now()
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
nil
,
nil
}
pkg/application/notify/service/message_personal.go
0 → 100644
查看文件 @
6b0c8f1
package
notify
import
(
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 个人信息提示
type
MessagePersonalService
struct
{
}
func
NewMessagePersonalService
()
*
MessagePersonalService
{
newService
:=
&
MessagePersonalService
{}
return
newService
}
// 获取今天的周期综合自评消息提示
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
())
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
nowTime
:=
time
.
Now
()
evaluationRepo
:=
factory
.
CreateSummaryEvaluationRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
_
,
evaluationList
,
err
:=
evaluationRepo
.
Find
(
map
[
string
]
interface
{}{
"targetUserId"
:
param
.
UserId
,
"types"
:
domain
.
EvaluationSelf
,
"beginTime"
:
nowTime
,
"endTime"
:
nowTime
,
})
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
resp
,
nil
}
...
...
pkg/domain/message_personal.go
查看文件 @
6b0c8f1
...
...
@@ -4,15 +4,15 @@ import "time"
// MessagePersonal 个人的消息提示
type
MessagePersonal
struct
{
Id
int
//
Types
string
//消息类型
TargetUserId
int
//消息指向的用户
ReadFlag
MessageReadFlag
//1:已读、2:未读
Title
string
//消息的标题
Content
string
//消息的内容
CreatedAt
time
.
Time
UpdatedAt
time
.
Time
Payload
string
//消息的额外承载的数据
Id
int
`json:"id"`
//
Types
MessageTypes
`json:"types"`
//消息类型
TargetUserId
int
`json:"targetUserId"`
//消息指向的用户
ReadFlag
MessageReadFlag
`json:"readFlag"`
//1:已读、2:未读
Title
string
`json:"title"`
//消息的标题
Content
string
`json:"content"`
//消息的内容
CreatedAt
time
.
Time
`json:"createdAt"`
UpdatedAt
time
.
Time
`json:"updatedAt"`
Payload
string
`json:"payload"`
//消息的额外承载的数据
}
type
MessageTypes
string
...
...
@@ -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
查看文件 @
6b0c8f1
...
...
@@ -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/init.go
查看文件 @
6b0c8f1
...
...
@@ -51,6 +51,7 @@ func init() {
&
models
.
SummaryEvaluationValue
{},
&
models
.
Permission
{},
&
models
.
LogSms
{},
&
models
.
MessagePersonal
{},
}
for
_
,
model
:=
range
tables
{
err
:=
DB
.
Model
(
model
)
.
CreateTable
(
&
orm
.
CreateTableOptions
{
...
...
pkg/infrastructure/pg/models/message_personal.go
0 → 100644
查看文件 @
6b0c8f1
package
models
import
"time"
// MessagePersonal 记录个人的提示消息
type
MessagePersonal
struct
{
tableName
struct
{}
`comment:"记录个人的提示消息" pg:"message_personal"`
Id
int
`pg:"id,pk"`
//
Types
string
`pg:"types"`
//消息类型
TargetUserId
int
`pg:"target_user_id"`
//消息指向的用户
ReadFlag
string
`pg:"read_flag"`
//1:已读、2:未读
Title
string
`pg:"title"`
//消息的标题
Content
string
`pg:"content"`
//消息的内容
CreatedAt
time
.
Time
`pg:"created_at"`
UpdatedAt
time
.
Time
`pg:"updated_at"`
Payload
string
`pg:"payload,type:jsonb"`
//消息的额外承载的数据
}
...
...
pkg/infrastructure/repository/pg_message_personal_repository.go
0 → 100644
查看文件 @
6b0c8f1
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
}
...
...
pkg/port/beego/controllers/message_personal_controller.go
0 → 100644
查看文件 @
6b0c8f1
package
controllers
...
...
sql/2023-03-24.sql
0 → 100644
查看文件 @
6b0c8f1
-- summary_evaluation_value表添加字段
ALTER
TABLE
public
.
summary_evaluation_value
ADD
executor
jsonb
NULL
;
-- 初始化旧数据的summary_evaluation_value.executor
UPDATE
public
.
summary_evaluation_value
SET
executor
=
public
.
summary_evaluation
.
executor
FROM
public
.
summary_evaluation
WHERE
public
.
summary_evaluation_value
.
summary_evaluation_id
=
public
.
summary_evaluation
.
id
;
...
...
请
注册
或
登录
后发表评论