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
d7e6e1ad
Commit
d7e6e1ad
authored
Jun 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refact: timestamp
parent
b9aeabdc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
43 deletions
+35
-43
anniversary.go
cron/cp_cron/anniversary.go
+2
-2
rank.go
cv/cp_cv/rank.go
+4
-4
anniversary.go
domain/model/cp_m/anniversary.go
+18
-22
anniversary.go
route/cp_r/anniversary.go
+11
-15
No files found.
cron/cp_cron/anniversary.go
View file @
d7e6e1ad
...
...
@@ -14,7 +14,7 @@ import (
type
CpAnniversaryNoticeMsg
struct
{
Identifier
string
`json:"identifier"`
Content
string
`json:"content"`
Date
string
`json:"date
"`
Timestamp
int64
`json:"timestamp
"`
}
func
CpAnniversaryNotice
()
{
...
...
@@ -39,7 +39,7 @@ func CpAnniversaryNotice() {
data
,
_
:=
json
.
Marshal
(
CpAnniversaryNoticeMsg
{
Identifier
:
"CpAnniversaryNotice"
,
Content
:
v
.
Content
,
Date
:
v
.
Date
,
Timestamp
:
v
.
Timestamp
,
})
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
users
[
0
]
.
ExternalId
,
[]
string
{
users
[
1
]
.
ExternalId
},
string
(
data
),
"cp纪念日"
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"BatchSendCustomMsg fail:%v"
,
err
)
...
...
cv/cp_cv/rank.go
View file @
d7e6e1ad
...
...
@@ -27,7 +27,7 @@ type CvCpAchievement struct {
type
CvCpAnniversary
struct
{
Id
uint64
`json:"id"`
// 记录id
Content
string
`json:"content"`
// 纪念日内容
Date
string
`json:"date"`
// 纪念日日期
Timestamp
int64
`json:"timestamp"`
// 纪念日时间戳
IsRemind
bool
`json:"isRemind"`
// 是否提醒
}
...
...
domain/model/cp_m/anniversary.go
View file @
d7e6e1ad
...
...
@@ -13,32 +13,29 @@ type CpAnniversary struct {
UserId1
mysql
.
ID
UserId2
mysql
.
ID
Content
string
Date
string
Timezone
string
Timestamp
int64
IsRemind
bool
Reminded
mysql
.
YesNo
}
// 添加cp纪念日
func
AddCpAnniversary
(
model
*
domain
.
Model
,
cp
CpRelationTmp
,
content
,
date
,
tz
string
,
isRemind
bool
)
error
{
func
AddCpAnniversary
(
model
*
domain
.
Model
,
cp
CpRelationTmp
,
content
string
,
ts
int64
,
isRemind
bool
)
error
{
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Create
(
&
CpAnniversary
{
CpId
:
cp
.
ID
,
UserId1
:
cp
.
UserId1
,
UserId2
:
cp
.
UserId2
,
Content
:
content
,
Date
:
date
,
Timezone
:
tz
,
Timestamp
:
ts
,
IsRemind
:
isRemind
,
Reminded
:
mysql
.
NO
,
})
.
Error
}
// 更新cp纪念日
func
UpdateCpAnniversary
(
model
*
domain
.
Model
,
id
mysql
.
ID
,
content
,
date
,
tz
string
,
isRemind
bool
)
error
{
func
UpdateCpAnniversary
(
model
*
domain
.
Model
,
id
mysql
.
ID
,
content
string
,
ts
int64
,
isRemind
bool
)
error
{
updates
:=
map
[
string
]
interface
{}{
"content"
:
content
,
"date"
:
date
,
"timezone"
:
tz
,
"timestamp"
:
ts
,
"is_remind"
:
isRemind
,
}
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"id = ?"
,
id
)
.
Updates
(
updates
)
.
Error
...
...
@@ -64,9 +61,8 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID) []CpAnniversary {
// 获取所有需要提醒的纪念日
func
GetNeedRemindCpAnniversary
(
model
*
domain
.
Model
)
[]
CpAnniversary
{
var
res
[]
CpAnniversary
date
:=
time
.
Now
()
.
Format
(
"2006-01-02"
)
if
err
:=
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"`
date` = ?"
,
date
)
.
Where
(
"`
timestamp` > ?"
,
time
.
Now
()
.
Unix
()
)
.
Where
(
"is_remind = 1"
)
.
Where
(
"reminded = ?"
,
mysql
.
NO
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
...
...
route/cp_r/anniversary.go
View file @
d7e6e1ad
...
...
@@ -14,7 +14,7 @@ import (
type
PostPutAnniversaryReq
struct
{
Content
string
`form:"content" binding:"required"`
Date
string
`form:"date
" binding:"required"`
Timestamp
int64
`form:"timestamp
" binding:"required"`
IsRemind
bool
`form:"isRemind"`
}
...
...
@@ -22,9 +22,8 @@ type PostPutAnniversaryReq struct {
// @Summary 发布纪念日
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param timezone header string true "时区"
// @Param content formData string true "纪念日名称"
// @Param
date formData string true "纪念日时间(年月日)
"
// @Param
timestamp formData int true "时间戳
"
// @Param isRemind formData bool false "是否提醒"
// @Success 200
// @Router /v2/cp/anniversary [post]
...
...
@@ -43,8 +42,7 @@ func PostAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
if
!
exits
{
return
myCtx
,
bizerr
.
CpNotRelation
}
else
{
tz
:=
c
.
GetHeader
(
mycontext
.
TIMEZONE
)
if
err
:=
cp_m
.
AddCpAnniversary
(
model
,
relation
,
param
.
Content
,
param
.
Date
,
tz
,
param
.
IsRemind
);
err
!=
nil
{
if
err
:=
cp_m
.
AddCpAnniversary
(
model
,
relation
,
param
.
Content
,
param
.
Timestamp
,
param
.
IsRemind
);
err
!=
nil
{
return
myCtx
,
err
}
}
...
...
@@ -56,9 +54,8 @@ func PostAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
// @Summary 修改纪念日
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param timezone header string true "时区"
// @Param content formData string true "纪念日名称"
// @Param
date formData string true "纪念日时间(年月日)
"
// @Param
timestamp formData int true "时间戳
"
// @Param isRemind formData bool false "是否提醒"
// @Param id path int true "更新的记录id"
// @Success 200
...
...
@@ -71,8 +68,7 @@ func PutAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
}
id
,
_
:=
strconv
.
ParseUint
(
c
.
Param
(
"id"
),
10
,
64
)
model
:=
domain
.
CreateModelContext
(
myCtx
)
tz
:=
c
.
GetHeader
(
mycontext
.
TIMEZONE
)
if
err
:=
cp_m
.
UpdateCpAnniversary
(
model
,
id
,
param
.
Content
,
param
.
Date
,
tz
,
param
.
IsRemind
);
err
!=
nil
{
if
err
:=
cp_m
.
UpdateCpAnniversary
(
model
,
id
,
param
.
Content
,
param
.
Timestamp
,
param
.
IsRemind
);
err
!=
nil
{
return
myCtx
,
err
}
resp
.
ResponseOk
(
c
,
""
)
...
...
@@ -98,7 +94,7 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
response
=
append
(
response
,
cp_cv
.
CvCpAnniversary
{
Id
:
v
.
ID
,
Content
:
v
.
Content
,
Date
:
v
.
Date
,
Timestamp
:
v
.
Timestamp
,
IsRemind
:
v
.
IsRemind
,
})
}
...
...
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