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
303c41b0
Commit
303c41b0
authored
Jun 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化纪念日
parent
a4a24136
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
8 deletions
+43
-8
anniversary.go
_const/enum/cp_e/anniversary.go
+3
-3
anniversary.go
cv/cp_cv/anniversary.go
+1
-0
anniversary.go
domain/model/cp_m/anniversary.go
+36
-3
anniversary.go
route/cp_r/anniversary.go
+3
-2
No files found.
_const/enum/cp_e/anniversary.go
View file @
303c41b0
...
...
@@ -3,7 +3,7 @@ package cp_e
type
AnniversaryItemType
int
const
(
AnniversaryItemTypeNormal
AnniversaryItemType
=
0
// 普通类型
AnniversaryItemTypeAvatar
AnniversaryItemType
=
1
// 头像类型
AnniversaryItemType
Birthday
AnniversaryItemType
=
2
// 生日类型
AnniversaryItemTypeNormal
AnniversaryItemType
=
0
// 普通类型
AnniversaryItemTypeAvatar
AnniversaryItemType
=
1
// 头像类型
AnniversaryItemType
Anniversary
AnniversaryItemType
=
2
// 纪念日类型(一年一度,如生日/结婚纪念日)
)
cv/cp_cv/anniversary.go
View file @
303c41b0
...
...
@@ -19,4 +19,5 @@ type CvCpAnniversary struct {
Timestamp
int64
`json:"timestamp"`
// 纪念日时间戳
IsRemind
bool
`json:"isRemind"`
// 是否提醒
CanDel
bool
`json:"canDel"`
// 能否删除
IsTop
bool
`json:"isTop"`
// 是否置顶
}
domain/model/cp_m/anniversary.go
View file @
303c41b0
package
cp_m
import
(
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-user/_const/enum/cp_e"
"hilo-user/domain/model/user_m"
"time"
)
// CpAnniversary cp纪念日
type
CpAnniversary
struct
{
mysql
.
Entity
CpId
mysql
.
ID
Type
cp_e
.
AnniversaryItemType
CpId
mysql
.
ID
UserId1
mysql
.
ID
UserId2
mysql
.
ID
Content
string
...
...
@@ -21,16 +23,47 @@ type CpAnniversary struct {
Sort
int
}
// 初始化6个cp纪念日
// 1)我们在一起;2)XXX的生日;3)XXX的生日;4)第一次说我爱你;5)第一次亲吻;6)结婚纪念日
// todo 翻译
func
InitCpAnniversary
(
model
*
domain
.
Model
,
cp
CpRelationTmp
)
error
{
users
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
[]
uint64
{
cp
.
UserId1
,
cp
.
UserId2
})
if
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
"我们在一起"
,
time
.
Now
()
.
Unix
(),
true
,
100
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
fmt
.
Sprintf
(
"%s的生日"
,
users
[
cp
.
UserId1
]
.
Nick
),
int64
(
users
[
cp
.
UserId1
]
.
Birthday
),
true
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
fmt
.
Sprintf
(
"%s的生日"
,
users
[
cp
.
UserId2
]
.
Nick
),
int64
(
users
[
cp
.
UserId2
]
.
Birthday
),
true
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
"第一次说我爱你"
,
0
,
false
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
cp
,
"第一次亲吻"
,
0
,
false
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeAnniversary
,
cp
,
"结婚纪念日"
,
0
,
false
,
0
);
err
!=
nil
{
return
err
}
return
nil
}
// 添加cp纪念日
func
AddCpAnniversary
(
model
*
domain
.
Model
,
cp
CpRelationTmp
,
content
string
,
ts
int64
,
isRemind
bool
)
error
{
func
AddCpAnniversary
(
model
*
domain
.
Model
,
Type
cp_e
.
AnniversaryItemType
,
cp
CpRelationTmp
,
content
string
,
ts
int64
,
isRemind
bool
,
sort
int
)
error
{
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Create
(
&
CpAnniversary
{
CpId
:
cp
.
ID
,
Type
:
Type
,
UserId1
:
cp
.
UserId1
,
UserId2
:
cp
.
UserId2
,
Content
:
content
,
Timestamp
:
ts
,
IsRemind
:
isRemind
,
Reminded
:
mysql
.
NO
,
Sort
:
sort
,
})
.
Error
}
...
...
@@ -55,7 +88,7 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID) []CpAnniversary {
if
!
exists
{
return
res
}
if
err
:=
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"cp_id = ?"
,
relation
.
ID
)
.
Order
(
"`sort` DESC,updated_time DESC"
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
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
)
}
return
res
...
...
route/cp_r/anniversary.go
View file @
303c41b0
...
...
@@ -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
,
relation
,
param
.
Content
,
param
.
Timestamp
,
param
.
IsRemind
);
err
!=
nil
{
if
err
:=
cp_m
.
AddCpAnniversary
(
model
,
cp_e
.
AnniversaryItemTypeNormal
,
relation
,
param
.
Content
,
param
.
Timestamp
,
param
.
IsRemind
,
0
);
err
!=
nil
{
return
myCtx
,
err
}
}
...
...
@@ -120,12 +120,13 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
anniversary
:=
cp_m
.
GetAllCpAnniversary
(
model
,
userId
)
for
_
,
v
:=
range
anniversary
{
response
=
append
(
response
,
cp_cv
.
CvCpAnniversary
{
Type
:
cp_e
.
AnniversaryItemTypeNormal
,
Type
:
v
.
Type
,
Id
:
v
.
ID
,
Content
:
v
.
Content
,
Timestamp
:
v
.
Timestamp
,
IsRemind
:
v
.
IsRemind
,
CanDel
:
true
,
IsTop
:
v
.
Sort
>
0
,
})
}
resp
.
ResponsePageBaseOk
(
c
,
response
,
0
,
false
)
...
...
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