Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenweijian
hilo-user
Commits
78403c9e
Commit
78403c9e
authored
Jun 16, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:增加msgId
parent
6295f1dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
anniversary.go
domain/model/cp_m/anniversary.go
+15
-8
anniversary.go
route/cp_r/anniversary.go
+3
-3
No files found.
domain/model/cp_m/anniversary.go
View file @
78403c9e
...
...
@@ -23,6 +23,7 @@ type CpAnniversary struct {
IsRemind
bool
LastRemindTime
int64
Sort
int
MsgId
uint
}
// 初始化6个cp纪念日
...
...
@@ -32,22 +33,22 @@ func InitCpAnniversary(model *domain.Model, cp CpRelation, lang string) error {
if
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
GetTranslate
(
259
,
lang
),
time
.
Now
()
.
Unix
(),
true
,
100
);
err
!=
nil
{
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
GetTranslate
(
259
,
lang
),
time
.
Now
()
.
Unix
(),
true
,
100
,
259
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
fmt
.
Sprintf
(
GetTranslate
(
260
,
lang
),
users
[
cp
.
UserId1
]
.
Nick
),
0
,
true
,
0
);
err
!=
nil
{
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
fmt
.
Sprintf
(
GetTranslate
(
260
,
lang
),
users
[
cp
.
UserId1
]
.
Nick
),
0
,
true
,
0
,
260
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
fmt
.
Sprintf
(
GetTranslate
(
260
,
lang
),
users
[
cp
.
UserId2
]
.
Nick
),
0
,
true
,
0
);
err
!=
nil
{
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
fmt
.
Sprintf
(
GetTranslate
(
260
,
lang
),
users
[
cp
.
UserId2
]
.
Nick
),
0
,
true
,
0
,
260
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
GetTranslate
(
261
,
lang
),
0
,
true
,
0
);
err
!=
nil
{
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
GetTranslate
(
261
,
lang
),
0
,
true
,
0
,
261
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
GetTranslate
(
262
,
lang
),
0
,
true
,
0
);
err
!=
nil
{
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
GetTranslate
(
262
,
lang
),
0
,
true
,
0
,
262
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
GetTranslate
(
263
,
lang
),
0
,
true
,
0
);
err
!=
nil
{
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
GetTranslate
(
263
,
lang
),
0
,
true
,
0
,
263
);
err
!=
nil
{
return
err
}
return
nil
...
...
@@ -68,7 +69,7 @@ func GetTranslate(msgId uint, lang string) string {
}
// 添加cp纪念日
func
AddCpAnniversary
(
model
*
domain
.
Model
,
Type
cp_e
.
AnniversaryItemType
,
cp
CpRelation
,
content
string
,
ts
int64
,
isRemind
bool
,
sort
int
)
error
{
func
AddCpAnniversary
(
model
*
domain
.
Model
,
Type
cp_e
.
AnniversaryItemType
,
cp
CpRelation
,
content
string
,
ts
int64
,
isRemind
bool
,
sort
int
,
msgId
uint
)
error
{
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Create
(
&
CpAnniversary
{
CpId
:
cp
.
Id
,
Type
:
Type
,
...
...
@@ -79,6 +80,7 @@ func AddCpAnniversary(model *domain.Model, Type cp_e.AnniversaryItemType, cp CpR
IsRemind
:
isRemind
,
LastRemindTime
:
0
,
Sort
:
sort
,
MsgId
:
msgId
,
})
.
Error
}
...
...
@@ -97,7 +99,7 @@ func DelCpAnniversary(model *domain.Model, id mysql.ID) error {
}
// 根据用户id获取所有纪念日
func
GetAllCpAnniversary
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
[]
CpAnniversary
{
func
GetAllCpAnniversary
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
lang
string
)
[]
CpAnniversary
{
var
res
[]
CpAnniversary
relation
,
exists
:=
GetCpRelation
(
model
,
userId
)
if
!
exists
{
...
...
@@ -106,6 +108,11 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID) []CpAnniversary {
if
err
:=
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"cp_id = ?"
,
relation
.
Id
)
.
Order
(
"`sort` DESC,updated_time DESC,id ASC"
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetAllCpAnniversary fail:%v"
,
err
)
}
for
i
,
v
:=
range
res
{
if
v
.
CreatedTime
.
Equal
(
v
.
UpdatedTime
)
&&
v
.
MsgId
>
0
{
res
[
i
]
.
Content
=
GetTranslate
(
v
.
MsgId
,
lang
)
}
}
return
res
}
...
...
route/cp_r/anniversary.go
View file @
78403c9e
...
...
@@ -45,7 +45,7 @@ func PostAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
if
!
exits
{
return
myCtx
,
bizerr
.
CpNotRelation
}
else
{
if
err
:=
cp_m
.
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
relation
,
param
.
Content
,
param
.
Timestamp
,
param
.
IsRemind
,
0
);
err
!=
nil
{
if
err
:=
cp_m
.
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
relation
,
param
.
Content
,
param
.
Timestamp
,
param
.
IsRemind
,
0
,
0
);
err
!=
nil
{
return
myCtx
,
err
}
}
...
...
@@ -88,7 +88,7 @@ func PutAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
// @Router /v2/cp/anniversary [get]
func
PageAnniversary
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
userId
,
lang
,
err
:=
req
.
GetUserIdLang
(
c
,
myCtx
)
if
err
!=
nil
{
return
myCtx
,
err
}
...
...
@@ -118,7 +118,7 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
CanDel
:
false
,
})
}
anniversary
:=
cp_m
.
GetAllCpAnniversary
(
model
,
userId
)
anniversary
:=
cp_m
.
GetAllCpAnniversary
(
model
,
userId
,
lang
)
for
_
,
v
:=
range
anniversary
{
timestamp
:=
v
.
Timestamp
if
v
.
Type
==
cp_e
.
AnniversaryItemTypeAnniversary
&&
timestamp
>
0
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment