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
f3e6d072
Commit
f3e6d072
authored
May 31, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:纪念日接口done
parent
4d02c6d0
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
199 additions
and
1 deletion
+199
-1
rank.go
cv/cp_cv/rank.go
+7
-0
anniversary.go
domain/model/cp_m/anniversary.go
+59
-0
bizCode.go
myerr/bizerr/bizCode.go
+2
-0
anniversary.go
route/cp_r/anniversary.go
+125
-0
rank.go
route/cp_r/rank.go
+1
-1
router.go
route/router.go
+5
-0
No files found.
cv/cp_cv/rank.go
View file @
f3e6d072
...
...
@@ -23,3 +23,10 @@ type CvCpAchievement struct {
Score
uint32
`json:"score"`
// 分值
TimeUnix
int64
`json:"timeUnix"`
// 达成成就时间戳
}
type
CvCpAnniversary
struct
{
Id
uint64
`json:"id"`
// 记录id
Content
string
`json:"content"`
// 纪念日内容
Date
string
`json:"date"`
// 纪念日日期
IsRemind
bool
`json:"isRemind"`
// 是否提醒
}
domain/model/cp_m/anniversary.go
0 → 100644
View file @
f3e6d072
package
cp_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
// CpAnniversary cp纪念日
type
CpAnniversary
struct
{
mysql
.
Entity
CpId
mysql
.
ID
UserId1
mysql
.
ID
UserId2
mysql
.
ID
Content
string
Date
string
Timezone
string
IsRemind
bool
}
// 添加cp纪念日
func
AddCpAnniversary
(
model
*
domain
.
Model
,
cp
CpRelationTmp
,
content
,
date
,
tz
string
,
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
,
IsRemind
:
isRemind
,
})
.
Error
}
// 更新cp纪念日
func
UpdateCpAnniversary
(
model
*
domain
.
Model
,
id
mysql
.
ID
,
content
,
date
,
tz
string
,
isRemind
bool
)
error
{
updates
:=
map
[
string
]
interface
{}{
"content"
:
content
,
"date"
:
date
,
"timezone"
:
tz
,
"is_remind"
:
isRemind
,
}
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"id = ?"
,
id
)
.
Updates
(
updates
)
.
Error
}
func
DelCpAnniversary
(
model
*
domain
.
Model
,
id
mysql
.
ID
)
error
{
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"id = ? "
,
id
)
.
Delete
(
&
CpAnniversary
{})
.
Error
}
// 根据用户id获取所有纪念日
func
GetAllCpAnniversary
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
[]
CpAnniversary
{
var
res
[]
CpAnniversary
relation
,
exists
:=
GetCpRelation
(
model
,
userId
)
if
!
exists
{
return
res
}
if
err
:=
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"cp_id = ?"
,
relation
.
ID
)
.
Order
(
"id"
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetAllCpAnniversary fail:%v"
,
err
)
}
return
res
}
myerr/bizerr/bizCode.go
View file @
f3e6d072
...
...
@@ -21,4 +21,6 @@ var (
DiamondAccountFrozen
=
myerr
.
NewBusinessCode
(
4004
,
"Diamond Account Frozen"
,
myerr
.
BusinessData
{})
ResPropertyDiamondNoUse
=
myerr
.
NewBusinessCode
(
5004
,
"Property can not buy"
,
myerr
.
BusinessData
{})
//头饰不能买
CpNotRelation
=
myerr
.
NewBusinessCode
(
6000
,
"cp not relation"
,
myerr
.
BusinessData
{})
)
route/cp_r/anniversary.go
0 → 100644
View file @
f3e6d072
package
cp_r
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
"hilo-user/cv/cp_cv"
"hilo-user/domain/model/cp_m"
"hilo-user/myerr/bizerr"
"hilo-user/req"
"hilo-user/resp"
"strconv"
)
type
PostPutAnniversaryReq
struct
{
Content
string
`form:"content" binding:"required"`
Date
string
`form:"date" binding:"required"`
IsRemind
bool
`form:"isRemind"`
}
// @Tags CP v2
// @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 isRemind formData bool false "是否提醒"
// @Success 200
// @Router /v2/cp/anniversary [post]
func
PostAnniversary
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myCtx
,
err
}
var
param
PostPutAnniversaryReq
if
err
:=
c
.
ShouldBind
(
&
param
);
err
!=
nil
{
return
myCtx
,
err
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
relation
,
exits
:=
cp_m
.
GetCpRelation
(
model
,
userId
)
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
{
return
myCtx
,
err
}
}
resp
.
ResponseOk
(
c
,
""
)
return
myCtx
,
nil
}
// @Tags CP v2
// @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 isRemind formData bool false "是否提醒"
// @Param id path int true "更新的记录id"
// @Success 200
// @Router /v2/cp/anniversary/{id} [put]
func
PutAnniversary
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
var
param
PostPutAnniversaryReq
if
err
:=
c
.
ShouldBind
(
&
param
);
err
!=
nil
{
return
myCtx
,
err
}
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
{
return
myCtx
,
err
}
resp
.
ResponseOk
(
c
,
""
)
return
myCtx
,
nil
}
// @Tags CP v2
// @Summary 获取纪念日
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Success 200 {object} []cp_cv.CvCpAnniversary
// @Router /v2/cp/anniversary [get]
func
PageAnniversary
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myCtx
,
err
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
var
response
=
make
([]
cp_cv
.
CvCpAnniversary
,
0
)
anniversary
:=
cp_m
.
GetAllCpAnniversary
(
model
,
userId
)
for
_
,
v
:=
range
anniversary
{
response
=
append
(
response
,
cp_cv
.
CvCpAnniversary
{
Id
:
v
.
ID
,
Content
:
v
.
Content
,
Date
:
v
.
Date
,
IsRemind
:
v
.
IsRemind
,
})
}
resp
.
ResponsePageBaseOk
(
c
,
response
,
0
,
false
)
return
myCtx
,
nil
}
// @Tags CP v2
// @Summary 获取纪念日
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param id path int true "记录id"
// @Success 200
// @Router /v2/cp/anniversary/:id [delete]
func
DelAnniversary
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
id
,
_
:=
strconv
.
ParseUint
(
c
.
Param
(
"id"
),
10
,
64
)
model
:=
domain
.
CreateModelContext
(
myCtx
)
if
err
:=
cp_m
.
DelCpAnniversary
(
model
,
id
);
err
!=
nil
{
return
myCtx
,
err
}
resp
.
ResponseOk
(
c
,
""
)
return
myCtx
,
nil
}
route/cp_r/rank.go
View file @
f3e6d072
...
...
@@ -198,5 +198,5 @@ func CpAchievement(c *gin.Context) (*mycontext.MyContext, error) {
}
else
{
}
resp
.
ResponsePageBaseOk
(
c
,
response
,
0
,
false
)
return
nil
,
nil
return
myCtx
,
nil
}
route/router.go
View file @
f3e6d072
...
...
@@ -36,6 +36,11 @@ func InitRouter() *gin.Engine {
cp
.
GET
(
"/rank/:queryType"
,
wrapper
(
cp_r
.
CpRank
))
cp
.
GET
(
"/my/:queryType"
,
wrapper
(
cp_r
.
CpMy
))
cp
.
GET
(
"/achievement"
,
wrapper
(
cp_r
.
CpAchievement
))
cp
.
POST
(
"/anniversary"
,
wrapper
(
cp_r
.
PostAnniversary
))
cp
.
PUT
(
"/anniversary/:id"
,
wrapper
(
cp_r
.
PutAnniversary
))
cp
.
GET
(
"/anniversary"
,
wrapper
(
cp_r
.
PageAnniversary
))
cp
.
DELETE
(
"/anniversary/:id"
,
wrapper
(
cp_r
.
DelAnniversary
))
}
inner
:=
r
.
Group
(
"/inner"
)
inner
.
Use
(
ExceptionHandle
,
LoggerHandle
)
...
...
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