-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
73 lines (61 loc) · 1.95 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package component_shipinlv
import (
"errors"
"fmt"
//component_shipinlv_lib "component_shipinlv/lib"
component_shipinlv_lib "github.com/tangwenru/go-component-shipinlv/lib"
)
type User struct {
}
type UserDetailResult struct {
Success bool `json:"success"`
Message string `json:"message"`
Code string `json:"code"`
Data UserDetail `json:"data"`
}
type UserDetail struct {
Id int64 `json:"id"`
AccountName string `json:"accountName"`
Nickname string `json:"nickname"`
AvatarUrl string `json:"avatarUrl"`
Enabled bool `json:"enabled"`
Expired int64 `json:"expired"`
WebSid string `json:"webSid"`
Role string `json:"role"`
AppSid string `json:"appSid"`
ClientSid string `json:"clientSid"`
DealerId int64 `json:"dealerId"`
Created int64 `json:"created"`
}
func (this *User) Detail(userId int64) (error, *UserDetail) {
userDetailResult := UserDetailResult{}
query := map[string]string{}
_, err := component_shipinlv_lib.MainSystem(userId, "user/info", &query, &userDetailResult)
userDetail := UserDetail{}
if err != nil {
fmt.Println("shiPinLv user info err:", err)
return err, &userDetail
}
if !userDetailResult.Success {
return errors.New(userDetailResult.Message), &userDetail
}
return err, &userDetailResult.Data
}
// 一个用户只能登录一个客户端
func (this *User) DetailByOneClient(userId int64, productType, clientUniqueKey string) (error, *UserDetail) {
userDetailResult := UserDetailResult{}
query := map[string]string{
"productType": productType,
"clientUniqueKey": clientUniqueKey,
}
_, err := component_shipinlv_lib.MainSystem(userId, "user/detailByOneClient", &query, &userDetailResult)
userDetail := UserDetail{}
if err != nil {
fmt.Println("shi Pin Lv user info err:", err)
return err, &userDetail
}
if !userDetailResult.Success {
return errors.New(userDetailResult.Message), &userDetail
}
return err, &userDetailResult.Data
}