Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
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
hujiebin
hilo-common
Commits
cdb952ca
Commit
cdb952ca
authored
Feb 23, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送用户道具
parent
1b487799
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 deletions
+116
-0
user.go
rpc/user.go
+116
-0
No files found.
rpc/user.go
View file @
cdb952ca
...
@@ -2,6 +2,7 @@ package rpc
...
@@ -2,6 +2,7 @@ package rpc
import
(
import
(
"encoding/json"
"encoding/json"
"errors"
"fmt"
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/mylogrus"
...
@@ -134,6 +135,121 @@ func GetUserBagId(model *domain.Model, bagId mysql.ID) (CvUserBag, error) {
...
@@ -134,6 +135,121 @@ func GetUserBagId(model *domain.Model, bagId mysql.ID) (CvUserBag, error) {
return
response
.
Data
,
nil
return
response
.
Data
,
nil
}
}
// 发送用户背包
func
SendUserBag
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
resType
,
resId
mysql
.
ID
,
count
,
day
mysql
.
Num
,
reason
string
)
error
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/prop/bag/send"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpPostForm
(
model
,
_url
,
nil
,
map
[
string
]
string
{
"userId"
:
fmt
.
Sprintf
(
"%d"
,
userId
),
"resType"
:
fmt
.
Sprintf
(
"%d"
,
resType
),
"resId"
:
fmt
.
Sprintf
(
"%d"
,
resId
),
"count"
:
fmt
.
Sprintf
(
"%d"
,
count
),
"day"
:
fmt
.
Sprintf
(
"%d"
,
day
),
"reason"
:
reason
,
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserBag fail:%v"
,
err
)
return
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserBag json fail:%v"
,
err
)
return
err
}
if
response
.
Code
!=
200
{
model
.
Log
.
Errorf
(
"SendUserBag fail:%v"
,
*
response
)
return
errors
.
New
(
response
.
Message
)
}
return
nil
}
// 发送用户贵族
func
SendUserNoble
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
level
int
,
day
mysql
.
Num
)
error
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/prop/noble/send"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpPostForm
(
model
,
_url
,
nil
,
map
[
string
]
string
{
"userId"
:
fmt
.
Sprintf
(
"%d"
,
userId
),
"level"
:
fmt
.
Sprintf
(
"%d"
,
level
),
"day"
:
fmt
.
Sprintf
(
"%d"
,
day
),
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserNoble fail:%v"
,
err
)
return
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserNoble json fail:%v"
,
err
)
return
err
}
if
response
.
Code
!=
200
{
model
.
Log
.
Errorf
(
"SendUserNoble fail:%v"
,
*
response
)
return
errors
.
New
(
response
.
Message
)
}
return
nil
}
// 发送用户头饰
func
SendUserHeadwear
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
headwearId
mysql
.
ID
,
day
mysql
.
Num
)
error
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/prop/headwear/send"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpPostForm
(
model
,
_url
,
nil
,
map
[
string
]
string
{
"userId"
:
fmt
.
Sprintf
(
"%d"
,
userId
),
"headwearId"
:
fmt
.
Sprintf
(
"%d"
,
headwearId
),
"day"
:
fmt
.
Sprintf
(
"%d"
,
day
),
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserHeadwear fail:%v"
,
err
)
return
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserHeadwear json fail:%v"
,
err
)
return
err
}
if
response
.
Code
!=
200
{
model
.
Log
.
Errorf
(
"SendUserHeadwear fail:%v"
,
*
response
)
return
errors
.
New
(
response
.
Message
)
}
return
nil
}
// 发送用户座驾
func
SendUserRide
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
rideId
mysql
.
ID
,
day
mysql
.
Num
)
error
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/prop/ride/send"
,
defaultUserServerScheme
,
getUserHost
())
resp
,
err
:=
HttpPostForm
(
model
,
_url
,
nil
,
map
[
string
]
string
{
"userId"
:
fmt
.
Sprintf
(
"%d"
,
userId
),
"rideId"
:
fmt
.
Sprintf
(
"%d"
,
rideId
),
"day"
:
fmt
.
Sprintf
(
"%d"
,
day
),
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserRide fail:%v"
,
err
)
return
err
}
response
:=
new
(
Response
)
if
err
=
json
.
Unmarshal
(
resp
,
response
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"SendUserRide json fail:%v"
,
err
)
return
err
}
if
response
.
Code
!=
200
{
model
.
Log
.
Errorf
(
"SendUserRide fail:%v"
,
*
response
)
return
errors
.
New
(
response
.
Message
)
}
return
nil
}
func
getUserHost
()
string
{
func
getUserHost
()
string
{
l
:=
len
(
UserServerHost
)
l
:=
len
(
UserServerHost
)
r
:=
rand
.
Intn
(
l
)
// 随机一个
r
:=
rand
.
Intn
(
l
)
// 随机一个
...
...
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