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
440edccb
Commit
440edccb
authored
Jun 07, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:调整cp纪念日
parent
d7e6e1ad
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
21 deletions
+73
-21
anniversary.go
_const/enum/cp_e/anniversary.go
+8
-0
anniversary.go
cv/cp_cv/anniversary.go
+22
-0
rank.go
cv/cp_cv/rank.go
+3
-10
anniversary.go
domain/model/cp_m/anniversary.go
+1
-1
anniversary.go
route/cp_r/anniversary.go
+30
-1
rank.go
route/cp_r/rank.go
+9
-9
No files found.
_const/enum/cp_e/anniversary.go
0 → 100644
View file @
440edccb
package
cp_e
type
AnniversaryItemType
int
const
(
AnniversaryItemTypeNormal
AnniversaryItemType
=
0
// 普通类型
AnniversaryItemTypeAvatar
AnniversaryItemType
=
1
// 头像类型
)
cv/cp_cv/anniversary.go
0 → 100644
View file @
440edccb
package
cp_cv
import
(
"hilo-user/_const/enum/cp_e"
"hilo-user/cv/user_cv"
)
// cp信息
type
CvCpBase
struct
{
UserInfo
user_cv
.
UserTiny
`json:"userInfo"`
// 用户信息
CpUserInfo
user_cv
.
UserTiny
`json:"cpUserInfo,omitempty"`
// cp用户信息
}
type
CvCpAnniversary
struct
{
Type
cp_e
.
AnniversaryItemType
`json:"type"`
// 列表类型 0:普通 1:头像
CpInfo
*
CvCpBase
`json:"cpInfo"`
// cp信息,type=1(头像)时候用到
Id
uint64
`json:"id"`
// 记录id
Content
string
`json:"content"`
// 纪念日内容
Timestamp
int64
`json:"timestamp"`
// 纪念日时间戳
IsRemind
bool
`json:"isRemind"`
// 是否提醒
CanDel
bool
`json:"canDel"`
// 能否删除
}
cv/cp_cv/rank.go
View file @
440edccb
...
...
@@ -5,7 +5,7 @@ import (
"hilo-user/cv/user_cv"
)
type
CvCp
struct
{
type
CvCp
Rank
struct
{
CpId
uint64
`json:"cpId"`
// cpId
User1
*
user_cv
.
CvUserBase
`json:"user1"`
// user1
User2
*
user_cv
.
CvUserBase
`json:"user2,omitempty"`
// user2
...
...
@@ -24,14 +24,7 @@ type CvCpAchievement struct {
TimeUnix
int64
`json:"timeUnix"`
// 达成成就时间戳
}
type
CvCpAnniversary
struct
{
Id
uint64
`json:"id"`
// 记录id
Content
string
`json:"content"`
// 纪念日内容
Timestamp
int64
`json:"timestamp"`
// 纪念日时间戳
IsRemind
bool
`json:"isRemind"`
// 是否提醒
}
type
CpTops
struct
{
Day
[]
CvCp
`json:"day"`
Week
[]
CvCp
`json:"week"`
Day
[]
CvCp
Rank
`json:"day"`
Week
[]
CvCp
Rank
`json:"week"`
}
domain/model/cp_m/anniversary.go
View file @
440edccb
...
...
@@ -52,7 +52,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
(
"
id
"
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
if
err
:=
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"cp_id = ?"
,
relation
.
ID
)
.
Order
(
"
`timestamp` DESC,id DESC
"
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetAllCpAnniversary fail:%v"
,
err
)
}
return
res
...
...
route/cp_r/anniversary.go
View file @
440edccb
...
...
@@ -4,8 +4,11 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
"hilo-user/_const/enum/cp_e"
"hilo-user/cv/cp_cv"
"hilo-user/cv/user_cv"
"hilo-user/domain/model/cp_m"
"hilo-user/domain/model/user_m"
"hilo-user/myerr/bizerr"
"hilo-user/req"
"hilo-user/resp"
...
...
@@ -79,6 +82,8 @@ func PutAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
// @Summary 获取纪念日
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param pageIndex query int true "偏移值 默认:1" default(1)
// @Param pageSize query int true "请求数量 默认:10" default(10)
// @Success 200 {object} []cp_cv.CvCpAnniversary
// @Router /v2/cp/anniversary [get]
func
PageAnniversary
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
...
...
@@ -87,15 +92,39 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
return
myCtx
,
err
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
var
response
=
make
([]
cp_cv
.
CvCpAnniversary
,
0
)
model
:=
domain
.
CreateModelContext
(
myCtx
)
cpRelation
,
exits
:=
cp_m
.
GetCpRelation
(
model
,
userId
)
if
exits
{
userIds
:=
[]
uint64
{
cpRelation
.
UserId1
,
cpRelation
.
UserId2
}
users
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
userIds
)
if
err
!=
nil
{
return
myCtx
,
err
}
cpUserId
:=
cpRelation
.
UserId2
if
cpUserId
==
userId
{
cpUserId
=
cpRelation
.
UserId1
}
userInfo
:=
user_cv
.
UserToTiny
(
users
[
userId
])
cpUserInfo
:=
user_cv
.
UserToTiny
(
users
[
cpUserId
])
response
=
append
(
response
,
cp_cv
.
CvCpAnniversary
{
Type
:
cp_e
.
AnniversaryItemTypeAvatar
,
CpInfo
:
&
cp_cv
.
CvCpBase
{
UserInfo
:
*
userInfo
,
CpUserInfo
:
*
cpUserInfo
,
},
CanDel
:
false
,
})
}
anniversary
:=
cp_m
.
GetAllCpAnniversary
(
model
,
userId
)
for
_
,
v
:=
range
anniversary
{
response
=
append
(
response
,
cp_cv
.
CvCpAnniversary
{
Type
:
cp_e
.
AnniversaryItemTypeNormal
,
Id
:
v
.
ID
,
Content
:
v
.
Content
,
Timestamp
:
v
.
Timestamp
,
IsRemind
:
v
.
IsRemind
,
CanDel
:
true
,
})
}
resp
.
ResponsePageBaseOk
(
c
,
response
,
0
,
false
)
...
...
route/cp_r/rank.go
View file @
440edccb
...
...
@@ -25,7 +25,7 @@ import (
// @Param pageIndex query int true "偏移值 默认:1" default(1)
// @Param pageSize query int true "请求数量 默认:10" default(10)
// @Param queryType path string true "类型:day/week/month"
// @Success 200 {object} []cp_cv.CvCp
// @Success 200 {object} []cp_cv.CvCp
Rank
// @Router /v2/cp/rank/{queryType} [get]
func
CpRank
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
...
...
@@ -58,7 +58,7 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
offset
,
limit
:=
(
pageReq
.
PageIndex
-
1
)
*
pageReq
.
PageSize
,
pageReq
.
PageSize
model
:=
domain
.
CreateModelContext
(
myCtx
)
ranks
:=
cp_m
.
PageCpDayRank
(
model
,
beginDate
,
endDate
,
offset
,
limit
)
var
response
[]
cp_cv
.
CvCp
var
response
[]
cp_cv
.
CvCp
Rank
var
userIds
[]
mysql
.
ID
var
cpIds
[]
mysql
.
ID
for
_
,
rank
:=
range
ranks
{
...
...
@@ -72,7 +72,7 @@ func CpRank(c *gin.Context) (*mycontext.MyContext, error) {
}
cpLevels
:=
cp_m
.
MGetCpLevel
(
model
,
cpIds
)
for
i
,
rank
:=
range
ranks
{
response
=
append
(
response
,
cp_cv
.
CvCp
{
response
=
append
(
response
,
cp_cv
.
CvCp
Rank
{
CpId
:
rank
.
CpId
,
User1
:
userBase
[
rank
.
UserId1
],
User2
:
userBase
[
rank
.
UserId2
],
...
...
@@ -104,8 +104,8 @@ func CpTop3(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
err
}
var
response
=
cp_cv
.
CpTops
{
Day
:
make
([]
cp_cv
.
CvCp
,
0
),
Week
:
make
([]
cp_cv
.
CvCp
,
0
),
Day
:
make
([]
cp_cv
.
CvCp
Rank
,
0
),
Week
:
make
([]
cp_cv
.
CvCp
Rank
,
0
),
}
queryTypes
:=
[]
string
{
"day"
,
"week"
}
for
_
,
queryType
:=
range
queryTypes
{
...
...
@@ -134,7 +134,7 @@ func CpTop3(c *gin.Context) (*mycontext.MyContext, error) {
cpLevels
:=
cp_m
.
MGetCpLevel
(
model
,
cpIds
)
for
i
,
rank
:=
range
ranks
{
if
queryType
==
"day"
{
response
.
Day
=
append
(
response
.
Day
,
cp_cv
.
CvCp
{
response
.
Day
=
append
(
response
.
Day
,
cp_cv
.
CvCp
Rank
{
CpId
:
rank
.
CpId
,
User1
:
userBase
[
rank
.
UserId1
],
User2
:
userBase
[
rank
.
UserId2
],
...
...
@@ -145,7 +145,7 @@ func CpTop3(c *gin.Context) (*mycontext.MyContext, error) {
},
})
}
else
{
response
.
Week
=
append
(
response
.
Week
,
cp_cv
.
CvCp
{
response
.
Week
=
append
(
response
.
Week
,
cp_cv
.
CvCp
Rank
{
CpId
:
rank
.
CpId
,
User1
:
userBase
[
rank
.
UserId1
],
User2
:
userBase
[
rank
.
UserId2
],
...
...
@@ -167,7 +167,7 @@ func CpTop3(c *gin.Context) (*mycontext.MyContext, error) {
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param queryType path string true "类型:day/week/month"
// @Success 200 {object} cp_cv.CvCp
// @Success 200 {object} cp_cv.CvCp
Rank
// @Router /v2/cp/my/{queryType} [get]
func
CpMy
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
...
...
@@ -212,7 +212,7 @@ func CpMy(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
return
myCtx
,
err
}
response
:=
cp_cv
.
CvCp
{
response
:=
cp_cv
.
CvCp
Rank
{
CpId
:
relation
.
ID
,
Score
:
scores
,
}
...
...
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