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
dec05051
Commit
dec05051
authored
Jun 20, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:oldCp
parent
b4ec010a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
old_cp.go
domain/model/cp_m/old_cp.go
+5
-3
inner.go
route/user_r/inner.go
+1
-1
cp_test.go
test/cp_test.go
+1
-1
No files found.
domain/model/cp_m/old_cp.go
View file @
dec05051
...
@@ -35,17 +35,19 @@ func (OldCp) TableName() string {
...
@@ -35,17 +35,19 @@ func (OldCp) TableName() string {
return
"cp"
return
"cp"
}
}
func
GetOldCpOrNil
(
model
*
domain
.
Model
,
tmpUserId1
mysql
.
ID
,
tmpUserId2
mysql
.
ID
)
(
*
Cp
,
error
)
{
// 获取旧的绑定中的cp
func
GetOldConnectCp
(
model
*
domain
.
Model
,
tmpUserId1
mysql
.
ID
,
tmpUserId2
mysql
.
ID
)
(
*
OldCp
,
error
)
{
userId1
:=
tmpUserId1
userId1
:=
tmpUserId1
userId2
:=
tmpUserId2
userId2
:=
tmpUserId2
if
tmpUserId1
<
tmpUserId2
{
if
tmpUserId1
<
tmpUserId2
{
userId1
=
tmpUserId2
userId1
=
tmpUserId2
userId2
=
tmpUserId1
userId2
=
tmpUserId1
}
}
cp
:=
Cp
{}
cp
:=
Old
Cp
{}
if
err
:=
model
.
Db
.
Where
(
&
Cp
{
if
err
:=
model
.
Db
.
Where
(
&
Old
Cp
{
UserId1
:
userId1
,
UserId1
:
userId1
,
UserId2
:
userId2
,
UserId2
:
userId2
,
Status
:
Connect
,
})
.
First
(
&
cp
)
.
Error
;
err
!=
nil
{
})
.
First
(
&
cp
)
.
Error
;
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
nil
,
nil
return
nil
,
nil
...
...
route/user_r/inner.go
View file @
dec05051
...
@@ -158,7 +158,7 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -158,7 +158,7 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
title
=
cp_cv
.
GetTranslate
(
msgId
,
req
.
Language
)
title
=
cp_cv
.
GetTranslate
(
msgId
,
req
.
Language
)
}
}
var
oldScore
uint32
var
oldScore
uint32
if
oldCp
,
_
:=
cp_m
.
GetOldC
pOrNil
(
model
,
cpRelation
.
UserId1
,
cpRelation
.
UserId2
);
oldCp
!=
nil
{
if
oldCp
,
_
:=
cp_m
.
GetOldC
onnectCp
(
model
,
cpRelation
.
UserId1
,
cpRelation
.
UserId2
);
oldCp
!=
nil
{
oldScore
=
uint32
(
oldCp
.
Score
)
oldScore
=
uint32
(
oldCp
.
Score
)
}
}
response
=
cp_cv
.
CvCp
{
response
=
cp_cv
.
CvCp
{
...
...
test/cp_test.go
View file @
dec05051
...
@@ -33,7 +33,7 @@ func TestCalLoc(t *testing.T) {
...
@@ -33,7 +33,7 @@ func TestCalLoc(t *testing.T) {
func
TestSumCpScore
(
t
*
testing
.
T
)
{
func
TestSumCpScore
(
t
*
testing
.
T
)
{
model
:=
domain
.
CreateModelNil
()
model
:=
domain
.
CreateModelNil
()
old
,
err
:=
cp_m
.
GetOldC
pOrNil
(
model
,
76421
,
4549
)
old
,
err
:=
cp_m
.
GetOldC
onnectCp
(
model
,
7642
,
4549
)
t
.
Logf
(
"%v-%v"
,
old
,
err
)
t
.
Logf
(
"%v-%v"
,
old
,
err
)
n
:=
cp_m
.
SumCpPoints
(
model
,
1
)
n
:=
cp_m
.
SumCpPoints
(
model
,
1
)
t
.
Logf
(
"%v"
,
n
)
t
.
Logf
(
"%v"
,
n
)
...
...
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