8 Commits

6 changed files with 55 additions and 21 deletions
Split View
  1. +1
    -1
      go.mod
  2. +4
    -2
      go.sum
  3. +18
    -17
      user.client.go
  4. +13
    -0
      user.client_test.go
  5. +16
    -0
      user.pb.go
  6. +3
    -1
      user.proto

+ 1
- 1
go.mod View File

@ -3,7 +3,7 @@ module git.tetele.net/tgo/userrpc
go 1.14
require (
git.tetele.net/tgo/conf v0.33.1
git.tetele.net/tgo/conf v0.46.0
git.tetele.net/tgo/crypter v0.2.2
github.com/chai2010/protorpc v1.1.3
github.com/golang/protobuf v1.0.0


+ 4
- 2
go.sum View File

@ -1,7 +1,9 @@
git.tetele.net/tgo/conf v0.33.1 h1:ZEIv3Vq35RCv5f3T3Uz97s2mkZLl7W5OlmXvzI3/sS8=
git.tetele.net/tgo/conf v0.33.1/go.mod h1:AWVIBEDE5dtotthUgR0SWaR2Qa6/f+O5WQ3s7Tj8q7A=
git.tetele.net/tgo/conf v0.46.0/go.mod h1:AWVIBEDE5dtotthUgR0SWaR2Qa6/f+O5WQ3s7Tj8q7A=
git.tetele.net/tgo/crypter v0.2.2 h1:YMQJh2Gj5Po4ZfelJUmXBKi01UbmtiSy3bmqRfnYQMo=
git.tetele.net/tgo/crypter v0.2.2/go.mod h1:vfvRLZA8+lHNgNXneOcgvVhDyuv25ZRb+C6xHOmXNx0=
git.tetele.net/yueheng/conf v0.33.1 h1:ZEIv3Vq35RCv5f3T3Uz97s2mkZLl7W5OlmXvzI3/sS8=
git.tetele.net/yueheng/conf v0.33.1/go.mod h1:AWVIBEDE5dtotthUgR0SWaR2Qa6/f+O5WQ3s7Tj8q7A=
git.tetele.net/yueheng/conf v1.2.6/go.mod h1:qRujMTqjMByvdC05qdfscZMFRKM5XA1qbtz4rnFyStY=
github.com/chai2010/protorpc v1.1.3 h1:VJK5hIoZn0XCGol0GmbxZkUG6FbTI5LP2Lam6RVd15w=
github.com/chai2010/protorpc v1.1.3/go.mod h1:/wO0kiyVdu7ug8dCMrA2yDr2vLfyhsLEuzLa9J2HJ+I=
github.com/golang/protobuf v1.0.0 h1:lsek0oXi8iFE9L+EXARyHIjU5rlWIhhTkjDz3vHhWWQ=


+ 18
- 17
user.client.go View File

@ -31,22 +31,24 @@ func GetUserByToken(dbname, token string, url ...string) (map[string]string, err
if res.GetUserId() != "" {
return map[string]string{
"UserId": res.GetUserId(),
"Username": res.GetUsername(),
"Nickname": res.GetNickname(),
"Mobile": res.GetMobile(),
"Email": res.GetEmail(),
"Status": res.GetStatus(),
"BusinessId": res.GetBusinessId(),
"StoreId": res.GetStoreId(),
"FansTo": res.GetFansTo(),
"IsVip": res.GetIsVip(),
"Usercode": res.GetUsercode(),
"GroupId": res.GetGroupId(),
"Type": res.GetType(),
"ThirdId": res.GetThirdId(),
"Platform": res.GetPlatform(),
"LockFans": res.GetLockFans(),
"UserId": res.GetUserId(),
"Username": res.GetUsername(),
"Nickname": res.GetNickname(),
"Mobile": res.GetMobile(),
"Email": res.GetEmail(),
"Status": res.GetStatus(),
"BusinessId": res.GetBusinessId(),
"StoreId": res.GetStoreId(),
"FansTo": res.GetFansTo(),
"IsVip": res.GetIsVip(),
"Usercode": res.GetUsercode(),
"GroupId": res.GetGroupId(),
"Type": res.GetType(),
"ThirdId": res.GetThirdId(),
"Platform": res.GetPlatform(),
"LockFans": res.GetLockFans(),
"CompanyId": res.GetCompanyId(),
"DepartmentId": res.GetDepartmentId(),
}, nil
}
@ -194,7 +196,6 @@ func GetById(site_id, dbname, user_id string, url ...string) (map[string]string,
return HandleUserRes(res)
}
/**
* 更新用户缓存
* 2021/11/23


+ 13
- 0
user.client_test.go View File

@ -48,3 +48,16 @@ func Test_UpdateUserCache(t *testing.T){
t.Log(res)
}
func Test_GetById(t *testing.T){
dbname := "shop"
siteId := "1198881"
res,err := GetById(siteId,dbname,"6")
if err != nil {
t.Error(err.Error())
}
t.Log(res)
}

+ 16
- 0
user.pb.go View File

@ -153,6 +153,8 @@ type UserResponse struct {
ThirdId *string `protobuf:"bytes,14,opt,name=third_id" json:"third_id,omitempty"`
Platform *string `protobuf:"bytes,15,opt,name=platform" json:"platform,omitempty"`
LockFans *string `protobuf:"bytes,16,opt,name=lock_fans" json:"lock_fans,omitempty"`
CompanyId *string `protobuf:"bytes,17,opt,name=company_id" json:"company_id,omitempty"`
DepartmentId *string `protobuf:"bytes,18,opt,name=department_id" json:"department_id,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@ -272,6 +274,20 @@ func (m *UserResponse) GetLockFans() string {
return ""
}
func (m *UserResponse) GetCompanyId() string {
if m != nil && m.CompanyId != nil {
return *m.CompanyId
}
return ""
}
func (m *UserResponse) GetDepartmentId() string {
if m != nil && m.DepartmentId != nil {
return *m.DepartmentId
}
return ""
}
// 用户登录请求结构
type LoginRequest struct {
Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`


+ 3
- 1
user.proto View File

@ -40,6 +40,8 @@ message UserResponse {
string third_id = 14; //token对应的third_id
string platform = 15; //
string lock_fans = 16; //
string company_id = 17;
string department_id =18;
}
//
@ -96,7 +98,7 @@ service UserService {
rpc getUserThird(Request) returns (Response); // v2
rpc getBusiness(Request) returns (Response); //
rpc getById(Request) returns (Response); //
rpc updateUserCache(Request) returns (Response); //
rpc updateUserCache(Request) returns (Response); //
rpc getBusinessInfo(Request) returns (Response); //
rpc getAddressInfo(Request) returns (Response); //
rpc getUserScore(Request) returns (Response); //


Loading…
Cancel
Save