调用账号服务报错as/sk验证错误,换回原先的方法
This commit is contained in:
parent
06e63b96b3
commit
4e5d45685d
@ -151,23 +151,24 @@ type InviteService struct {
|
|||||||
|
|
||||||
func CheckInvitedCodes(invitedCode string) (uint, error) {
|
func CheckInvitedCodes(invitedCode string) (uint, error) {
|
||||||
// 变更为通过账号服务验证邀请码
|
// 变更为通过账号服务验证邀请码
|
||||||
// var user model.User
|
var user model.User
|
||||||
// //找到用户
|
//找到用户
|
||||||
// if err := db.DB.Where("invited_code =?", invitedCode).Find(&user).Error; err != nil {
|
if err := db.DB.Where("invited_code =?", invitedCode).Find(&user).Error; err != nil {
|
||||||
// return 0, err
|
return 0, err
|
||||||
// }
|
|
||||||
// if user.ID == 0 {
|
|
||||||
// return 0, errors.New("邀请码无效")
|
|
||||||
// }
|
|
||||||
// return uint(user.ID), nil
|
|
||||||
if res, err := service.AccountProvider.ListByIDs(context.Background(), &account.ListByIDsRequest{
|
|
||||||
Page: 1,
|
|
||||||
PageSize: 1,
|
|
||||||
InvitationCode: []string{invitedCode},
|
|
||||||
}); err != nil && res != nil && len(res.Data) > 0 {
|
|
||||||
return uint(res.Data[0].ID), nil
|
|
||||||
}
|
}
|
||||||
return 0, errors.New("邀请码无效")
|
if user.ID == 0 {
|
||||||
|
return 0, errors.New("邀请码无效")
|
||||||
|
}
|
||||||
|
return uint(user.ID), nil
|
||||||
|
// todo 无法通过账号服务获取邀请码信息
|
||||||
|
// if res, err := service.AccountProvider.ListByIDs(context.Background(), &account.ListByIDsRequest{
|
||||||
|
// Page: 1,
|
||||||
|
// PageSize: 1,
|
||||||
|
// InvitationCode: []string{invitedCode},
|
||||||
|
// }); err != nil && res != nil && len(res.Data) > 0 {
|
||||||
|
// return uint(res.Data[0].ID), nil
|
||||||
|
// }
|
||||||
|
// return 0, errors.New("邀请码无效")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUser(req *artistInfoUser.GetUserRequest) (rep *artistInfoUser.GetUserRespond, err error) {
|
func GetUser(req *artistInfoUser.GetUserRequest) (rep *artistInfoUser.GetUserRespond, err error) {
|
||||||
@ -438,7 +439,7 @@ func FindUser(req *artistInfoUser.FindUserRequest) (rep *artistInfoUser.UserInfo
|
|||||||
fmt.Println("FindUser 11111111111")
|
fmt.Println("FindUser 11111111111")
|
||||||
rep = &artistInfoUser.UserInfo{}
|
rep = &artistInfoUser.UserInfo{}
|
||||||
var data = model.User{}
|
var data = model.User{}
|
||||||
var tx = db.DB.Model(model.User{}).Preload("RealNameInfo") //.Preload("InvitedBy.UserInfo.RealNameInfo")
|
var tx = db.DB.Model(model.User{}).Preload("RealNameInfo").Preload("InvitedBy.UserInfo.RealNameInfo")
|
||||||
if req.MgmtAccId != 0 {
|
if req.MgmtAccId != 0 {
|
||||||
tx = tx.Where("mgmt_acc_id = ?", req.MgmtAccId)
|
tx = tx.Where("mgmt_acc_id = ?", req.MgmtAccId)
|
||||||
}
|
}
|
||||||
@ -459,32 +460,36 @@ func FindUser(req *artistInfoUser.FindUserRequest) (rep *artistInfoUser.UserInfo
|
|||||||
data.RealNameInfo = &model.RealName{}
|
data.RealNameInfo = &model.RealName{}
|
||||||
}
|
}
|
||||||
// 邀请人的查询变更为通过账号服务查询
|
// 邀请人的查询变更为通过账号服务查询
|
||||||
// if data.InvitedBy == nil {
|
if data.InvitedBy == nil {
|
||||||
// data.InvitedBy = &model.Invite{}
|
data.InvitedBy = &model.Invite{}
|
||||||
// }
|
|
||||||
// var invitedName string
|
|
||||||
// if data.InvitedBy != nil && data.InvitedBy.UserInfo != nil && data.InvitedBy.UserInfo.RealNameInfo != nil {
|
|
||||||
// invitedName = data.InvitedBy.UserInfo.RealNameInfo.Name
|
|
||||||
// }
|
|
||||||
//查询邀请人
|
|
||||||
var inviterCode = model.Invite{}
|
|
||||||
var inviterAccount = &account.ListResponse{Data: []*account.AccountInfo{}}
|
|
||||||
var inviterName string
|
|
||||||
db.DB.Model(model.Invite{}).Where("invited_code = ?", data.InviteCode).First(&inviterCode)
|
|
||||||
if inviterCode.InviteCode != "" {
|
|
||||||
inviterAccount, err = service.AccountProvider.ListByIDs(context.Background(), &account.ListByIDsRequest{
|
|
||||||
Page: 1,
|
|
||||||
PageSize: 1,
|
|
||||||
InvitationCode: []string{inviterCode.InviteCode},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("AccountProvider.ListByID error", err.Error())
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(inviterAccount.Data) > 0 {
|
|
||||||
inviterName = inviterAccount.Data[0].RealName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var inviterName string
|
||||||
|
var inviterCode string
|
||||||
|
if data.InvitedBy != nil {
|
||||||
|
inviterCode = data.InvitedBy.InviteCode
|
||||||
|
}
|
||||||
|
if data.InvitedBy != nil && data.InvitedBy.UserInfo != nil && data.InvitedBy.UserInfo.RealNameInfo != nil {
|
||||||
|
inviterName = data.InvitedBy.UserInfo.RealNameInfo.Name
|
||||||
|
}
|
||||||
|
//查询邀请人 无法通过账号服务进行查询,密码验证错误
|
||||||
|
// var inviterCode = model.Invite{}
|
||||||
|
// var inviterAccount = &account.ListResponse{Data: []*account.AccountInfo{}}
|
||||||
|
// var inviterName string
|
||||||
|
// db.DB.Model(model.Invite{}).Where("invited_code = ?", data.InviteCode).First(&inviterCode)
|
||||||
|
// if inviterCode.InviteCode != "" {
|
||||||
|
// inviterAccount, err = service.AccountProvider.ListByIDs(context.Background(), &account.ListByIDsRequest{
|
||||||
|
// Page: 1,
|
||||||
|
// PageSize: 1,
|
||||||
|
// InvitationCode: []string{inviterCode.InviteCode},
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("AccountProvider.ListByID error", err.Error())
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// if len(inviterAccount.Data) > 0 {
|
||||||
|
// inviterName = inviterAccount.Data[0].RealName
|
||||||
|
// }
|
||||||
|
// }
|
||||||
service.AccountProvider.Info(context.Background(), &account.InfoRequest{})
|
service.AccountProvider.Info(context.Background(), &account.InfoRequest{})
|
||||||
rep = &artistInfoUser.UserInfo{
|
rep = &artistInfoUser.UserInfo{
|
||||||
Id: data.ID,
|
Id: data.ID,
|
||||||
@ -495,8 +500,8 @@ func FindUser(req *artistInfoUser.FindUserRequest) (rep *artistInfoUser.UserInfo
|
|||||||
MgmtArtistId: data.MgmtArtistId,
|
MgmtArtistId: data.MgmtArtistId,
|
||||||
MgmtArtistUid: data.MgmtArtistUid,
|
MgmtArtistUid: data.MgmtArtistUid,
|
||||||
TelNum: data.TelNum,
|
TelNum: data.TelNum,
|
||||||
InviterCode: inviterCode.InviteCode, //邀请人的邀请码,不是用户个人邀请码
|
InviterCode: inviterCode, //邀请人的邀请码,不是用户个人邀请码
|
||||||
InviterName: inviterName, //邀请人的姓名
|
InviterName: inviterName, //邀请人的姓名
|
||||||
IsRealName: data.IsRealName,
|
IsRealName: data.IsRealName,
|
||||||
RealNameId: data.RealNameId,
|
RealNameId: data.RealNameId,
|
||||||
RealName: &artistInfoUser.RealNameInfo{
|
RealName: &artistInfoUser.RealNameInfo{
|
||||||
@ -586,10 +591,13 @@ func FindUserList(req *artistInfoUser.FindUsersRequest) (rep []*artistInfoUser.U
|
|||||||
// invitedName = "无"
|
// invitedName = "无"
|
||||||
// }
|
// }
|
||||||
var inviterName, inviterCode string
|
var inviterName, inviterCode string
|
||||||
// 查询邀请人信息
|
// 查询邀请人信息,调用账号服务接口报错 as/sk 错误,换原先的方法
|
||||||
inviterInfo := GetInviterInfo(v.InviteCode)
|
// inviterInfo := GetInviterInfo(v.InviteCode)
|
||||||
|
// inviterName = inviterInfo.RealName
|
||||||
|
if v.RealNameInfo != nil {
|
||||||
|
inviterName = v.RealNameInfo.Name
|
||||||
|
}
|
||||||
inviterCode = v.InviteCode
|
inviterCode = v.InviteCode
|
||||||
inviterName = inviterInfo.RealName
|
|
||||||
rep = append(rep, &artistInfoUser.UserInfo{
|
rep = append(rep, &artistInfoUser.UserInfo{
|
||||||
Id: v.ID,
|
Id: v.ID,
|
||||||
DeletedAt: int64(v.DeletedAt),
|
DeletedAt: int64(v.DeletedAt),
|
||||||
@ -894,47 +902,48 @@ func GetInviterInfo(inviterCode string) (result account.AccountInfo) {
|
|||||||
fmt.Println("\n GetInviterInfo: 查询邀请人信息出错", err.Error())
|
fmt.Println("\n GetInviterInfo: 查询邀请人信息出错", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// todo 接口调用报错 as/ak错误
|
||||||
//查询邀请人信息
|
//查询邀请人信息
|
||||||
res, err := service.AccountProvider.ListByIDs(context.Background(), &account.ListByIDsRequest{
|
// res, err := service.AccountProvider.ListByIDs(context.Background(), &account.ListByIDsRequest{
|
||||||
Page: 1,
|
// Page: 1,
|
||||||
PageSize: 1,
|
// PageSize: 1,
|
||||||
InvitationCode: []string{inviteRelation.InviteCode},
|
// InvitationCode: []string{inviteRelation.InviteCode},
|
||||||
})
|
// })
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
fmt.Println("\n GetInviterInfo 查询邀请人信息出错 service.AccountProvider.ListByIDs Error", err.Error())
|
// fmt.Println("\n GetInviterInfo 查询邀请人信息出错 service.AccountProvider.ListByIDs Error", err.Error())
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if res != nil && len(res.Data) > 0 {
|
// if res != nil && len(res.Data) > 0 {
|
||||||
result = account.AccountInfo{
|
// result = account.AccountInfo{
|
||||||
ID: res.Data[0].ID,
|
// ID: res.Data[0].ID,
|
||||||
Account: res.Data[0].Account,
|
// Account: res.Data[0].Account,
|
||||||
NickName: res.Data[0].NickName,
|
// NickName: res.Data[0].NickName,
|
||||||
Type: res.Data[0].Type,
|
// Type: res.Data[0].Type,
|
||||||
TelNum: res.Data[0].TelNum,
|
// TelNum: res.Data[0].TelNum,
|
||||||
Status: res.Data[0].Status,
|
// Status: res.Data[0].Status,
|
||||||
Avatar: res.Data[0].Avatar,
|
// Avatar: res.Data[0].Avatar,
|
||||||
CreateAt: res.Data[0].CreateAt,
|
// CreateAt: res.Data[0].CreateAt,
|
||||||
RealNameID: res.Data[0].RealNameID,
|
// RealNameID: res.Data[0].RealNameID,
|
||||||
RealName: res.Data[0].RealName,
|
// RealName: res.Data[0].RealName,
|
||||||
IDNum: res.Data[0].IDNum,
|
// IDNum: res.Data[0].IDNum,
|
||||||
MnemonicWords: res.Data[0].MnemonicWords,
|
// MnemonicWords: res.Data[0].MnemonicWords,
|
||||||
IsNeedChange: res.Data[0].IsNeedChange,
|
// IsNeedChange: res.Data[0].IsNeedChange,
|
||||||
EnterDate: res.Data[0].EnterDate,
|
// EnterDate: res.Data[0].EnterDate,
|
||||||
WorkYear: res.Data[0].WorkYear,
|
// WorkYear: res.Data[0].WorkYear,
|
||||||
Domain: res.Data[0].Domain,
|
// Domain: res.Data[0].Domain,
|
||||||
Extend: res.Data[0].Extend,
|
// Extend: res.Data[0].Extend,
|
||||||
JobNum: res.Data[0].JobNum,
|
// JobNum: res.Data[0].JobNum,
|
||||||
BirthDate: res.Data[0].BirthDate,
|
// BirthDate: res.Data[0].BirthDate,
|
||||||
Age: res.Data[0].Age,
|
// Age: res.Data[0].Age,
|
||||||
Sex: res.Data[0].Sex,
|
// Sex: res.Data[0].Sex,
|
||||||
Title: res.Data[0].Title,
|
// Title: res.Data[0].Title,
|
||||||
Departments: res.Data[0].Departments,
|
// Departments: res.Data[0].Departments,
|
||||||
Ip: res.Data[0].Ip,
|
// Ip: res.Data[0].Ip,
|
||||||
LoginDate: res.Data[0].LoginDate,
|
// LoginDate: res.Data[0].LoginDate,
|
||||||
InvitationCode: res.Data[0].InvitationCode,
|
// InvitationCode: res.Data[0].InvitationCode,
|
||||||
}
|
// }
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
||||||
"github.com/fonchain/fonchain-artistinfo/pb/artistinfoArtshow"
|
"github.com/fonchain/fonchain-artistinfo/pb/artistinfoArtshow"
|
||||||
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
||||||
|
@ -9,6 +9,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
||||||
"github.com/fonchain/fonchain-artistinfo/pb/artistinfoArtshow"
|
"github.com/fonchain/fonchain-artistinfo/pb/artistinfoArtshow"
|
||||||
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
||||||
|
@ -3,8 +3,8 @@ package model
|
|||||||
// User 用户模型
|
// User 用户模型
|
||||||
type Invite struct {
|
type Invite struct {
|
||||||
Model
|
Model
|
||||||
// UserId int32 `gorm:"column:user_id;comment:邀请人账号id"`
|
UserId int32 `gorm:"column:user_id;comment:邀请人账号id"`
|
||||||
// UserInfo *User `gorm:"foreignKey:id;reference:UserId"`
|
UserInfo *User `gorm:"foreignKey:id;reference:UserId"`
|
||||||
InvitedId int32 `gorm:"column:invited_id;default:0;comment:受邀请画家宝用户id"`
|
InvitedId int32 `gorm:"column:invited_id;default:0;comment:受邀请画家宝用户id"`
|
||||||
InviteCode string `gorm:"column:invite_code;type:varchar(191);comment:邀请人的邀请码"`
|
InviteCode string `gorm:"column:invite_code;type:varchar(191);comment:邀请人的邀请码"`
|
||||||
InvitedCode string `gorm:"column:invited_code;type:varchar(191);comment:受邀请人的邀请码"`
|
InvitedCode string `gorm:"column:invited_code;type:varchar(191);comment:受邀请人的邀请码"`
|
||||||
|
@ -3,17 +3,17 @@ package model
|
|||||||
// User 用户模型
|
// User 用户模型
|
||||||
type User struct {
|
type User struct {
|
||||||
Model
|
Model
|
||||||
MgmtAccId int64 `gorm:"column:mgmt_acc_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_idx;comment:账号id"`
|
MgmtAccId int64 `gorm:"column:mgmt_acc_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_idx;comment:账号id"`
|
||||||
MgmtArtistId int64 `gorm:"column:mgmt_artist_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_idx;comment:艺术家id"`
|
MgmtArtistId int64 `gorm:"column:mgmt_artist_id;not null;uniqueIndex:mgmt_acc_mgmt_artist_idx;comment:艺术家id"`
|
||||||
MgmtArtistUid string `gorm:"column:mgmt_artist_uid;type:varchar(256);comment:艺术家uid"`
|
MgmtArtistUid string `gorm:"column:mgmt_artist_uid;type:varchar(256);comment:艺术家uid"`
|
||||||
TelNum string `gorm:"column:tel_num;type:varchar(20);not null;电话号码"`
|
TelNum string `gorm:"column:tel_num;type:varchar(20);not null;电话号码"`
|
||||||
InviteCode string `gorm:"column:invited_code;type:varchar(16);default:'';comment:个人邀请码"`
|
InviteCode string `gorm:"column:invited_code;type:varchar(16);default:'';comment:个人邀请码"`
|
||||||
// InvitedBy *Invite `gorm:"foreignKey:InvitedId"` //邀请者的相关信息,弃用,因为此处不存储经纪人数据
|
InvitedBy *Invite `gorm:"foreignKey:InvitedId"` //邀请者的相关信息
|
||||||
Account string `gorm:"column:account;varchar(191);comment:账号"`
|
Account string `gorm:"column:account;varchar(191);comment:账号"`
|
||||||
CertificateNum string `gorm:"column:certificate_num;type:varchar(16);comment:中美协会证书编号"`
|
CertificateNum string `gorm:"column:certificate_num;type:varchar(16);comment:中美协会证书编号"`
|
||||||
CertificateImg string `gorm:"column:certificate_img;type:varchar(512);comment:中美协会证书url"`
|
CertificateImg string `gorm:"column:certificate_img;type:varchar(512);comment:中美协会证书url"`
|
||||||
JoinAssoTime string `json:"joinAssoTime" gorm:"column:join_asso_time;comment:入会时间"`
|
JoinAssoTime string `json:"joinAssoTime" gorm:"column:join_asso_time;comment:入会时间"`
|
||||||
Photo string `gorm:"column:photo;type:varchar(255);comment:个人近照"`
|
Photo string `gorm:"column:photo;type:varchar(255);comment:个人近照"`
|
||||||
|
|
||||||
// 实名认证
|
// 实名认证
|
||||||
IsRealName int64 `gorm:"column:is_real_name;default:0;是否实名认证:0未认证 1已认证"`
|
IsRealName int64 `gorm:"column:is_real_name;default:0;是否实名认证:0未认证 1已认证"`
|
||||||
|
@ -3,7 +3,7 @@ package model
|
|||||||
// User 用户模型
|
// User 用户模型
|
||||||
type UserInvited struct {
|
type UserInvited struct {
|
||||||
Model
|
Model
|
||||||
// UserId int32 `gorm:"column:user_id;type:int;not null;comment:邀请人id"`
|
UserId int32 `gorm:"column:user_id;type:int;not null;comment:邀请人id"`
|
||||||
InviteCode string `gorm:"column:invite_code;comment:邀请人的邀请码"`
|
InviteCode string `gorm:"column:invite_code;comment:邀请人的邀请码"`
|
||||||
InvitedCode string `gorm:"column:invited_code;comment:受邀请人的邀请码"`
|
InvitedCode string `gorm:"column:invited_code;comment:受邀请人的邀请码"`
|
||||||
InvitedUserId int32 `gorm:"column:invited_user_id;type:int;not null;comment:受邀请人画家宝用户id"`
|
InvitedUserId int32 `gorm:"column:invited_user_id;type:int;not null;comment:受邀请人画家宝用户id"`
|
||||||
|
Loading…
Reference in New Issue
Block a user