完成艺术家查询接口
This commit is contained in:
parent
35b6166f04
commit
9cc419c041
@ -18,6 +18,14 @@ type ArtistInfoUserProvider struct {
|
||||
artistInfoLogic *logic.ArtistInfoUser
|
||||
}
|
||||
|
||||
func (a *ArtistInfoUserProvider) FindUsersUserView(ctx context.Context, request *artistInfoUser.FindUsersRequest) (*artistInfoUser.FindUsersUserViewResponse, error) {
|
||||
return a.artistInfoLogic.FindUsersUserView(request)
|
||||
}
|
||||
|
||||
func (a *ArtistInfoUserProvider) FindUsers(ctx context.Context, request *artistInfoUser.FindUsersRequest) (*artistInfoUser.FindUsersResponse, error) {
|
||||
return a.artistInfoLogic.FindUserList(request)
|
||||
}
|
||||
|
||||
func (a *ArtistInfoUserProvider) RegisterUser(ctx context.Context, req *artistInfoUser.RegisterUserRequest) (rep *artistInfoUser.RegisterUserRespond, err error) {
|
||||
fmt.Println("第一处")
|
||||
// backup := &artistinfoUser.GetUserInfoRespond{}
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"github.com/fonchain/fonchain-artistinfo/pkg/service"
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
func RegisterUser(req *artistInfoUser.RegisterUserRequest) (rep *artistInfoUser.RegisterUserRespond, err error) {
|
||||
@ -177,6 +178,7 @@ func CheckInvitedCodes(invitedCode string) (uint, error) {
|
||||
}
|
||||
return uint(user.ID), nil
|
||||
}
|
||||
|
||||
func GetUser(req *artistInfoUser.GetUserRequest) (rep *artistInfoUser.GetUserRespond, err error) {
|
||||
rep = &artistInfoUser.GetUserRespond{}
|
||||
// service := &artist.UserUpdateInfoService{}
|
||||
@ -510,6 +512,108 @@ func FindUser(req *artistInfoUser.FindUserRequest) (rep *artistInfoUser.UserInfo
|
||||
return rep, nil
|
||||
}
|
||||
|
||||
func FindUserList(req *artistInfoUser.FindUsersRequest) (rep []*artistInfoUser.UserInfo, total int64, err error) {
|
||||
//todo 待修改,邀请人的关联信息不显示
|
||||
var (
|
||||
datas = []model.User{}
|
||||
tx = db.DB.Model(model.User{}).
|
||||
Preload("RealNameInfo").Preload("InvitedBy.UserInfo.RealNameInfo").Where("sys_user.mgmt_artist_uid!=''")
|
||||
)
|
||||
if req.InvitedCode != "" {
|
||||
tx = tx.Where("invited_code = ?", req.InvitedCode)
|
||||
}
|
||||
if req.MgmtArtistUid != "" {
|
||||
tx = tx.Where("mgmt_artist_uid = ?", req.MgmtArtistUid)
|
||||
}
|
||||
if req.InviterName != "" {
|
||||
tx = tx.Joins("LEFT JOIN real_name rn ON rn.id = sys_user.real_name_id").Clauses(clause.Like{
|
||||
Column: "rn.name",
|
||||
Value: "%" + req.InviterName + "%",
|
||||
})
|
||||
}
|
||||
if req.IsArtist {
|
||||
tx = tx.Where("mgmt_artist_uid !='' ")
|
||||
}
|
||||
|
||||
err = tx.Count(&total).Scopes(db.Pagination(req.Page, req.PageSize)).Find(&datas).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range datas {
|
||||
if v.RealNameInfo == nil {
|
||||
v.RealNameInfo = &model.RealName{}
|
||||
}
|
||||
if v.InvitedBy == nil {
|
||||
v.InvitedBy = &model.Invite{}
|
||||
}
|
||||
var invitedName string
|
||||
if v.InvitedBy != nil && v.InvitedBy.UserInfo != nil && v.InvitedBy.UserInfo.RealNameInfo != nil {
|
||||
invitedName = v.InvitedBy.UserInfo.RealNameInfo.Name
|
||||
} else {
|
||||
invitedName = "无"
|
||||
}
|
||||
rep = append(rep, &artistInfoUser.UserInfo{
|
||||
Id: v.ID,
|
||||
DeletedAt: int64(v.DeletedAt),
|
||||
UpdatedAt: v.UpdatedAt.Unix(),
|
||||
CreatedAt: v.CreatedAt.Unix(),
|
||||
MgmtAccId: v.MgmtAccId,
|
||||
MgmtArtistId: v.MgmtArtistId,
|
||||
MgmtArtistUid: v.MgmtArtistUid,
|
||||
TelNum: v.TelNum,
|
||||
InvitedCode: v.InvitedBy.InviteCode, //邀请人的邀请码,不是用户个人邀请码
|
||||
InvitedName: invitedName, //邀请人没有实名则为空字符串
|
||||
IsRealName: v.IsRealName,
|
||||
RealNameId: v.RealNameId,
|
||||
RealName: &artistInfoUser.RealNameInfo{
|
||||
Name: v.RealNameInfo.Name,
|
||||
IdNum: v.RealNameInfo.IdNum,
|
||||
IdCardFront: v.RealNameInfo.IdCardFront,
|
||||
IdCardBack: v.RealNameInfo.IdCardBack,
|
||||
Age: int32(v.RealNameInfo.Age),
|
||||
Sex: string(v.RealNameInfo.Sex),
|
||||
Birthday: v.RealNameInfo.Birthday,
|
||||
Address: v.RealNameInfo.Address,
|
||||
Id: v.RealNameInfo.ID,
|
||||
},
|
||||
FddState: v.FddState,
|
||||
CustomerId: v.CustomerId,
|
||||
OpenId: v.OpenId,
|
||||
IsRead: v.IsRead,
|
||||
IsLock: v.IsLock,
|
||||
Account: v.Account,
|
||||
CertificateNum: v.CertificateNum,
|
||||
CertificateImg: v.CertificateImg,
|
||||
Photo: v.Photo,
|
||||
HtmlType: v.Htmltype,
|
||||
EnvType: v.Envtype,
|
||||
InviteCode: v.InviteCode,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetViewUserList(req *artistInfoUser.FindUsersRequest) (resp []model.UserView, total int64, err error) {
|
||||
resp = []model.UserView{}
|
||||
var (
|
||||
tx = db.DB.Model(model.UserView{})
|
||||
)
|
||||
if req.InvitedCode != "" {
|
||||
tx = tx.Where("invited_code = ?", req.InvitedCode)
|
||||
}
|
||||
if req.MgmtArtistUid != "" {
|
||||
tx = tx.Where("mgmt_artist_uid = ?", req.MgmtArtistUid)
|
||||
}
|
||||
if req.InviterName != "" {
|
||||
tx = tx.Where("inviter_real_name = ?", req.InviterName)
|
||||
}
|
||||
if req.IsArtist {
|
||||
tx = tx.Where("mgmt_artist_uid !='' ")
|
||||
}
|
||||
err = tx.Count(&total).Scopes(db.Pagination(req.Page, req.PageSize)).Find(&resp).Error
|
||||
return
|
||||
}
|
||||
|
||||
func UpdateUserData(req *artistInfoUser.UserInfo) (rep *artistInfoUser.CommonNoParams, err error) {
|
||||
var (
|
||||
preUpdateData model.User
|
||||
|
@ -1,9 +1,12 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/fonchain/fonchain-artistinfo/cmd/internal/dao"
|
||||
"github.com/fonchain/fonchain-artistinfo/pb/artist"
|
||||
"github.com/fonchain/fonchain-artistinfo/pb/artistInfoUser"
|
||||
"github.com/fonchain/fonchain-artistinfo/pkg/service"
|
||||
)
|
||||
|
||||
type IArtistInfo interface {
|
||||
@ -85,7 +88,81 @@ func (a *ArtistInfoUser) GetUserMsg(req *artistInfoUser.GetUserMsgRequest) (rep
|
||||
func (a *ArtistInfoUser) FindUser(req *artistInfoUser.FindUserRequest) (rep *artistInfoUser.UserInfo, err error) {
|
||||
return dao.FindUser(req)
|
||||
}
|
||||
func (a *ArtistInfoUser) FindUserList(req *artistInfoUser.FindUsersRequest) (rep *artistInfoUser.FindUsersResponse, err error) {
|
||||
res, total, err := dao.FindUserList(req)
|
||||
rep = &artistInfoUser.FindUsersResponse{Data: res, Page: &artistInfoUser.UserCommonPageInfo{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
Total: total,
|
||||
}}
|
||||
return
|
||||
}
|
||||
func (a *ArtistInfoUser) FindUsersUserView(req *artistInfoUser.FindUsersRequest) (rep *artistInfoUser.FindUsersUserViewResponse, err error) {
|
||||
res, total, err := dao.GetViewUserList(req)
|
||||
var returnData []*artistInfoUser.UserView
|
||||
var artistUidList = []string{}
|
||||
|
||||
for _, v := range res {
|
||||
if v.ArtistUid != "" {
|
||||
artistUidList = append(artistUidList, v.ArtistUid)
|
||||
}
|
||||
returnData = append(returnData, &artistInfoUser.UserView{
|
||||
UserId: v.UserId,
|
||||
AccId: v.AccId,
|
||||
ArtistUid: v.ArtistUid,
|
||||
TelNum: v.TelNum,
|
||||
InviteCode: v.InviteCode,
|
||||
Account: v.Account,
|
||||
Photo: v.Photo,
|
||||
IsRealName: v.IsRealName,
|
||||
FddState: v.FddState,
|
||||
IsRead: v.IsRead,
|
||||
IsLock: v.IsLock,
|
||||
RealName: v.RealName,
|
||||
IdNum: v.IdNum,
|
||||
Sex: string(v.Sex),
|
||||
Age: v.Age,
|
||||
Address: v.RealAddress,
|
||||
IdcardBack: v.IdcardBack,
|
||||
IdcardFront: v.IdcardFront,
|
||||
InviterInviteCode: v.InviterInviteCode,
|
||||
InviterRealName: v.InviterRealName,
|
||||
DeletedAt: v.DeletedAt,
|
||||
UpdatedAt: v.UpdatedAt.Unix(),
|
||||
CreatedAt: v.CreatedAt.Unix(),
|
||||
})
|
||||
}
|
||||
if artistUidList != nil {
|
||||
var artistDatas *artist.ArtistListResponse
|
||||
artistDatas, err = service.GrpcArtistImpl.ArtistList(context.Background(), &artist.ArtistListRequest{
|
||||
Page: 1,
|
||||
PageSize: int32(len(artistUidList)),
|
||||
Uids: artistUidList,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("错误:GrpcArtistImpl.GetInfoByUuids ", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
for _, artistValue := range artistDatas.Data {
|
||||
for i, user := range returnData {
|
||||
if artistValue.Uid == user.ArtistUid {
|
||||
returnData[i].CertificateNum = artistValue.CaaCertNum
|
||||
returnData[i].OpenBank = artistValue.BankNum
|
||||
returnData[i].PenName = artistValue.PenName
|
||||
returnData[i].StageName = artistValue.StageName
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
rep = &artistInfoUser.FindUsersUserViewResponse{Data: returnData, Page: &artistInfoUser.UserCommonPageInfo{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
Total: total,
|
||||
}}
|
||||
return
|
||||
}
|
||||
func (a *ArtistInfoUser) UpdateUserData(req *artistInfoUser.UserInfo) (rep *artistInfoUser.CommonNoParams, err error) {
|
||||
rep, err = dao.UpdateUserData(req)
|
||||
return
|
||||
|
81
cmd/model/user_view.go
Normal file
81
cmd/model/user_view.go
Normal file
@ -0,0 +1,81 @@
|
||||
// Package model -----------------------------
|
||||
// @file : user_view.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2023/2/27 13:51
|
||||
// -------------------------------------------
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserView struct {
|
||||
UserId int64 `json:"userId" gorm:"column:user_id;comment:用户表id"`
|
||||
AccId int64 `json:"accId" gorm:"column:mgmt_acc_id;comment:账号id"`
|
||||
ArtistUid string `json:"artistUid" gorm:"column:mgmt_artist_uid;comment:账号id"`
|
||||
TelNum string `json:"telNum" gorm:"column:tel_num;comment:电话号码"`
|
||||
InviteCode string `json:"inviteCode" gorm:"column:invited_code;comment:邀请码"`
|
||||
Account string `json:"account" gorm:"column:account;comment:账号"`
|
||||
Photo string `json:"photo" gorm:"column:photo;comment:个人近照"`
|
||||
IsRealName int64 `json:"isRealName" gorm:"column:is_real_name;comment:是否实名认证"`
|
||||
FddState int64 `json:"fddState" gorm:"column:fdd_state;comment:法大大状态"`
|
||||
IsRead int64 `json:"is_read" gorm:"column:is_read;comment:是否已读 0未读 1已读"`
|
||||
IsLock bool `json:"isLock" gorm:"column:is_lock;comment:是否锁定"`
|
||||
RealName string `json:"realName" gorm:"column:real_name;comment:真实姓名"`
|
||||
IdNum string `json:"idNum" gorm:"column:id_num;comment:证件号码"`
|
||||
Sex SexType `json:"sex" gorm:"column:sex;comment:性别"`
|
||||
Age int64 `json:"age" gorm:"column:age;comment:年龄"`
|
||||
RealAddress string `json:"address" gorm:"column:real_address;comment:真实地址"`
|
||||
IdcardBack string `json:"idcardBack" gorm:"column:idcard_back;comment:身份证背面"`
|
||||
IdcardFront string `json:"idcard_front" gorm:"column:idcard_front;comment:身份证反面"`
|
||||
InviterInviteCode string `json:"inviterInviteCode" gorm:"column:inviter_invite_code;comment:邀请人的邀请码"`
|
||||
InviterRealName string `json:"inviterRealName" gorm:"column:inviter_name;comment:邀请人的真实姓名"`
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"column:created_at;comment:"`
|
||||
UpdatedAt time.Time `json:"updatedAt" gorm:"column:updated_at;comment:"`
|
||||
DeletedAt int64 `json:"deletedAt" gorm:"column:deleted_at;comment:"`
|
||||
}
|
||||
|
||||
func (u UserView) TableName() string {
|
||||
return "user_view"
|
||||
}
|
||||
func CreateUserView(db *gorm.DB) error {
|
||||
var sql = `
|
||||
CREATE OR REPLACE VIEW user_view AS
|
||||
SELECT
|
||||
su.id user_id,
|
||||
su.mgmt_acc_id,
|
||||
su.mgmt_artist_uid,
|
||||
su.tel_num,
|
||||
su.invited_code,
|
||||
su.account,
|
||||
su.photo,
|
||||
su.is_real_name,
|
||||
su.fdd_state,
|
||||
su.is_read,
|
||||
su.is_lock,
|
||||
rn.name real_name,
|
||||
rn.idcard_front,
|
||||
rn.idcard_back,
|
||||
rn.address real_address,
|
||||
rn.id_num,
|
||||
rn.sex,
|
||||
rn.age,
|
||||
su.created_at,
|
||||
su.updated_at,
|
||||
su.deleted_at,
|
||||
inviter.invited_code inviter_invite_code,
|
||||
inviter_rn.name inviter_name
|
||||
FROM sys_user su
|
||||
LEFT JOIN real_name rn ON rn.id = su.real_name_id
|
||||
-- 邀请者信息
|
||||
LEFT JOIN invite ON invite.invited_id = su.id
|
||||
LEFT JOIN sys_user inviter ON inviter.id = invite.user_id
|
||||
LEFT JOIN real_name inviter_rn ON inviter_rn.id = inviter.real_name_id
|
||||
WHERE
|
||||
su.deleted_at = 0
|
||||
`
|
||||
db.Exec(sql)
|
||||
return nil
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -47,6 +47,7 @@ message ArtistListRequest {
|
||||
string Keyword = 1 [json_name = "keyword"];
|
||||
int32 Page = 2 [json_name = "page"];
|
||||
int32 PageSize = 3 [json_name = "page_size"];
|
||||
repeated string uids =4 [json_name = "uids"];
|
||||
}
|
||||
// ProfileListRequest
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,8 +46,9 @@ type ArtistInfoUserClient interface {
|
||||
UpdateMsg(ctx context.Context, in *UpdateMsgRequest, opts ...grpc_go.CallOption) (*UpdateMsgRespond, common.ErrorWithAttachment)
|
||||
BindInviteInvitedAccount(ctx context.Context, in *BindInviteInvitedAccountRequest, opts ...grpc_go.CallOption) (*BindInviteInvitedAccountRespond, common.ErrorWithAttachment)
|
||||
BindArtistId(ctx context.Context, in *BindArtistIdRequest, opts ...grpc_go.CallOption) (*BindArtistIdResp, common.ErrorWithAttachment)
|
||||
FindUsers(ctx context.Context, in *FindUserRequest, opts ...grpc_go.CallOption) (*FindUserResponse, common.ErrorWithAttachment)
|
||||
FindUser(ctx context.Context, in *FindUserRequest, opts ...grpc_go.CallOption) (*UserInfo, common.ErrorWithAttachment)
|
||||
FindUsers(ctx context.Context, in *FindUsersRequest, opts ...grpc_go.CallOption) (*FindUsersResponse, common.ErrorWithAttachment)
|
||||
FindUsersUserView(ctx context.Context, in *FindUsersRequest, opts ...grpc_go.CallOption) (*FindUsersUserViewResponse, common.ErrorWithAttachment)
|
||||
UpdateUserData(ctx context.Context, in *UserInfo, opts ...grpc_go.CallOption) (*CommonNoParams, common.ErrorWithAttachment)
|
||||
PreSaveArtistInfo(ctx context.Context, in *PreSaveArtistInfoData, opts ...grpc_go.CallOption) (*CommonNoParams, common.ErrorWithAttachment)
|
||||
GetPreSaveArtistInfo(ctx context.Context, in *GetPreSaveArtistInfoRequest, opts ...grpc_go.CallOption) (*PreSaveArtistInfoData, common.ErrorWithAttachment)
|
||||
@ -74,8 +75,9 @@ type ArtistInfoUserClientImpl struct {
|
||||
UpdateMsg func(ctx context.Context, in *UpdateMsgRequest) (*UpdateMsgRespond, error)
|
||||
BindInviteInvitedAccount func(ctx context.Context, in *BindInviteInvitedAccountRequest) (*BindInviteInvitedAccountRespond, error)
|
||||
BindArtistId func(ctx context.Context, in *BindArtistIdRequest) (*BindArtistIdResp, error)
|
||||
FindUsers func(ctx context.Context, in *FindUserRequest) (*FindUserResponse, error)
|
||||
FindUser func(ctx context.Context, in *FindUserRequest) (*UserInfo, error)
|
||||
FindUsers func(ctx context.Context, in *FindUsersRequest) (*FindUsersResponse, error)
|
||||
FindUsersUserView func(ctx context.Context, in *FindUsersRequest) (*FindUsersUserViewResponse, error)
|
||||
UpdateUserData func(ctx context.Context, in *UserInfo) (*CommonNoParams, error)
|
||||
PreSaveArtistInfo func(ctx context.Context, in *PreSaveArtistInfoData) (*CommonNoParams, error)
|
||||
GetPreSaveArtistInfo func(ctx context.Context, in *GetPreSaveArtistInfoRequest) (*PreSaveArtistInfoData, error)
|
||||
@ -189,18 +191,24 @@ func (c *artistInfoUserClient) BindArtistId(ctx context.Context, in *BindArtistI
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BindArtistId", in, out)
|
||||
}
|
||||
|
||||
func (c *artistInfoUserClient) FindUsers(ctx context.Context, in *FindUserRequest, opts ...grpc_go.CallOption) (*FindUserResponse, common.ErrorWithAttachment) {
|
||||
out := new(FindUserResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/FindUsers", in, out)
|
||||
}
|
||||
|
||||
func (c *artistInfoUserClient) FindUser(ctx context.Context, in *FindUserRequest, opts ...grpc_go.CallOption) (*UserInfo, common.ErrorWithAttachment) {
|
||||
out := new(UserInfo)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/FindUser", in, out)
|
||||
}
|
||||
|
||||
func (c *artistInfoUserClient) FindUsers(ctx context.Context, in *FindUsersRequest, opts ...grpc_go.CallOption) (*FindUsersResponse, common.ErrorWithAttachment) {
|
||||
out := new(FindUsersResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/FindUsers", in, out)
|
||||
}
|
||||
|
||||
func (c *artistInfoUserClient) FindUsersUserView(ctx context.Context, in *FindUsersRequest, opts ...grpc_go.CallOption) (*FindUsersUserViewResponse, common.ErrorWithAttachment) {
|
||||
out := new(FindUsersUserViewResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/FindUsersUserView", in, out)
|
||||
}
|
||||
|
||||
func (c *artistInfoUserClient) UpdateUserData(ctx context.Context, in *UserInfo, opts ...grpc_go.CallOption) (*CommonNoParams, common.ErrorWithAttachment) {
|
||||
out := new(CommonNoParams)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -241,8 +249,9 @@ type ArtistInfoUserServer interface {
|
||||
UpdateMsg(context.Context, *UpdateMsgRequest) (*UpdateMsgRespond, error)
|
||||
BindInviteInvitedAccount(context.Context, *BindInviteInvitedAccountRequest) (*BindInviteInvitedAccountRespond, error)
|
||||
BindArtistId(context.Context, *BindArtistIdRequest) (*BindArtistIdResp, error)
|
||||
FindUsers(context.Context, *FindUserRequest) (*FindUserResponse, error)
|
||||
FindUser(context.Context, *FindUserRequest) (*UserInfo, error)
|
||||
FindUsers(context.Context, *FindUsersRequest) (*FindUsersResponse, error)
|
||||
FindUsersUserView(context.Context, *FindUsersRequest) (*FindUsersUserViewResponse, error)
|
||||
UpdateUserData(context.Context, *UserInfo) (*CommonNoParams, error)
|
||||
PreSaveArtistInfo(context.Context, *PreSaveArtistInfoData) (*CommonNoParams, error)
|
||||
GetPreSaveArtistInfo(context.Context, *GetPreSaveArtistInfoRequest) (*PreSaveArtistInfoData, error)
|
||||
@ -302,12 +311,15 @@ func (UnimplementedArtistInfoUserServer) BindInviteInvitedAccount(context.Contex
|
||||
func (UnimplementedArtistInfoUserServer) BindArtistId(context.Context, *BindArtistIdRequest) (*BindArtistIdResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method BindArtistId not implemented")
|
||||
}
|
||||
func (UnimplementedArtistInfoUserServer) FindUsers(context.Context, *FindUserRequest) (*FindUserResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindUsers not implemented")
|
||||
}
|
||||
func (UnimplementedArtistInfoUserServer) FindUser(context.Context, *FindUserRequest) (*UserInfo, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindUser not implemented")
|
||||
}
|
||||
func (UnimplementedArtistInfoUserServer) FindUsers(context.Context, *FindUsersRequest) (*FindUsersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindUsers not implemented")
|
||||
}
|
||||
func (UnimplementedArtistInfoUserServer) FindUsersUserView(context.Context, *FindUsersRequest) (*FindUsersUserViewResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindUsersUserView not implemented")
|
||||
}
|
||||
func (UnimplementedArtistInfoUserServer) UpdateUserData(context.Context, *UserInfo) (*CommonNoParams, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateUserData not implemented")
|
||||
}
|
||||
@ -809,7 +821,7 @@ func _ArtistInfoUser_BindArtistId_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ArtistInfoUser_FindUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _ArtistInfoUser_FindUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
@ -822,6 +834,35 @@ func _ArtistInfoUser_FindUsers_Handler(srv interface{}, ctx context.Context, dec
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("FindUser", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ArtistInfoUser_FindUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindUsersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("FindUsers", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
@ -838,8 +879,8 @@ func _ArtistInfoUser_FindUsers_Handler(srv interface{}, ctx context.Context, dec
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ArtistInfoUser_FindUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindUserRequest)
|
||||
func _ArtistInfoUser_FindUsersUserView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindUsersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -851,7 +892,7 @@ func _ArtistInfoUser_FindUser_Handler(srv interface{}, ctx context.Context, dec
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("FindUser", args, invAttachment)
|
||||
invo := invocation.NewRPCInvocation("FindUsersUserView", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
@ -1025,13 +1066,17 @@ var ArtistInfoUser_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "BindArtistId",
|
||||
Handler: _ArtistInfoUser_BindArtistId_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "FindUser",
|
||||
Handler: _ArtistInfoUser_FindUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "FindUsers",
|
||||
Handler: _ArtistInfoUser_FindUsers_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "FindUser",
|
||||
Handler: _ArtistInfoUser_FindUser_Handler,
|
||||
MethodName: "FindUsersUserView",
|
||||
Handler: _ArtistInfoUser_FindUsersUserView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateUserData",
|
||||
|
@ -22,14 +22,20 @@ service ArtistInfoUser {
|
||||
rpc UpdateMsg(UpdateMsgRequest) returns (UpdateMsgRespond){} //更新用户信息
|
||||
rpc BindInviteInvitedAccount(BindInviteInvitedAccountRequest)returns(BindInviteInvitedAccountRespond){} //绑定邀请人与被邀请人账号
|
||||
rpc BindArtistId(BindArtistIdRequest)returns(BindArtistIdResp){} // 账号绑定艺术家id
|
||||
rpc FindUsers(FindUserRequest)returns(FindUserResponse){} //批量查询用户信息
|
||||
rpc FindUser(FindUserRequest)returns(UserInfo){}//查找单个用户信息
|
||||
rpc FindUsers(FindUsersRequest)returns(FindUsersResponse){} //批量查询用户信息
|
||||
rpc FindUsersUserView(FindUsersRequest)returns(FindUsersUserViewResponse){} //使用视图批量查询用户信息
|
||||
rpc UpdateUserData(UserInfo)returns(CommonNoParams){} //更新用户信息
|
||||
rpc PreSaveArtistInfo(PreSaveArtistInfoData)returns(CommonNoParams){}//暂存艺术家信息
|
||||
rpc GetPreSaveArtistInfo(GetPreSaveArtistInfoRequest)returns(PreSaveArtistInfoData){}//获取暂存的艺术家信息
|
||||
}
|
||||
message CommonNoParams{
|
||||
}
|
||||
message UserCommonPageInfo{
|
||||
int32 page =1;
|
||||
int32 pageSize =2;
|
||||
int64 total=4;
|
||||
}
|
||||
message UpdateMsgRequest {
|
||||
int64 Id = 1;
|
||||
}
|
||||
@ -365,18 +371,34 @@ message CreateDataRequest{
|
||||
}
|
||||
|
||||
message FindUserRequest{
|
||||
int64 mgmtAccId = 1; //账号id
|
||||
int64 mgmtArtistId = 2;//艺术家id
|
||||
int64 mgmtAccId = 1; //账号id
|
||||
int64 mgmtArtistId = 2; //艺术家id
|
||||
string mgmtArtistUid = 3;
|
||||
// string Account = 3;
|
||||
// string TelNum = 4;
|
||||
// bool IsLock = 5;
|
||||
// bool Enable = 6;
|
||||
// int64 FddState = 7;
|
||||
string invitedCode = 8;//邀请码
|
||||
string invitedCode = 8; //邀请码
|
||||
bool isArtist=9; //查询有艺术家uid的数据
|
||||
}
|
||||
message FindUserResponse{
|
||||
message FindUsersRequest{
|
||||
string mgmtArtistUid = 1;
|
||||
string inviterName =2; //邀请人名称
|
||||
string ArtistRealName = 3; //画家真是姓名
|
||||
string invitedCode = 4;//邀请码
|
||||
int32 page=5;
|
||||
int32 pageSize=6;
|
||||
bool isArtist=9; //查询有艺术家uid的数据
|
||||
// string Account = 3;
|
||||
// string TelNum = 4;
|
||||
// bool IsLock = 5;
|
||||
// bool Enable = 6;
|
||||
// int64 FddState = 7;
|
||||
}
|
||||
message FindUsersResponse{
|
||||
repeated UserInfo data = 1;
|
||||
UserCommonPageInfo page =2;
|
||||
}
|
||||
|
||||
|
||||
@ -446,3 +468,37 @@ message PreSaveArtistInfoData{
|
||||
message GetPreSaveArtistInfoRequest{
|
||||
int64 mgmtAccId = 1;
|
||||
}
|
||||
|
||||
message UserView{
|
||||
int64 userId=1;
|
||||
int64 accId=2;
|
||||
string artistUid=3;
|
||||
string telNum=4;
|
||||
string inviteCode=5;
|
||||
string account=6;
|
||||
string photo=7;
|
||||
int64 isRealName=8;
|
||||
int64 fddState=9;
|
||||
int64 is_read=10;
|
||||
bool isLock=11;
|
||||
string realName=12;
|
||||
string idNum=13;
|
||||
string sex=14;
|
||||
int64 age=15;
|
||||
string address=16;
|
||||
string idcardBack=17;
|
||||
string idcard_front=18;
|
||||
string inviterInviteCode=19;
|
||||
string inviterRealName=20;
|
||||
int64 deletedAt = 21;
|
||||
int64 updatedAt = 22;
|
||||
int64 createdAt = 23;
|
||||
string penName =24;
|
||||
string stageName=25;
|
||||
string certificateNum=26;
|
||||
string openBank=27;
|
||||
}
|
||||
message FindUsersUserViewResponse{
|
||||
repeated UserView data=1;
|
||||
UserCommonPageInfo page =2;
|
||||
}
|
15
pkg/db/dto.go
Normal file
15
pkg/db/dto.go
Normal file
@ -0,0 +1,15 @@
|
||||
// Package model -----------------------------
|
||||
// @file : dto.go
|
||||
// @author : JJXu
|
||||
// @contact : wavingbear@163.com
|
||||
// @time : 2023/2/27 11:54
|
||||
// -------------------------------------------
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
func Pagination[T int | int32 | int64](page T, pageSize T) func(db *gorm.DB) *gorm.DB {
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
return db.Limit(int(pageSize)).Offset(int((page - 1) * pageSize))
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -39,7 +40,15 @@ func Init(confPath string) {
|
||||
path := strings.Join([]string{DbUser, ":", DbPassWord, "@tcp(", DbHost, ":", DbPort, ")/", DbLogName, "?charset=utf8&parseTime=true"}, "")
|
||||
//连接数据库
|
||||
Database(path)
|
||||
migration() //迁移表 如果需要就打开使用
|
||||
//迁移表 如果需要就打开使用
|
||||
migration()
|
||||
// 生成视图 ,如果更新报错需要手动删除视图后再执行程序
|
||||
if err = generateModelView(
|
||||
model.CreateUserView, //用户表视图
|
||||
); err != nil {
|
||||
fmt.Println("创建或更新视图失败,错误内容:", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func LoadMysqlData(file *ini.File) {
|
||||
@ -90,10 +99,10 @@ func migration() {
|
||||
&model.User{},
|
||||
&model.Invite{},
|
||||
&model.Artwork{},
|
||||
&model.Contract{},
|
||||
&model.SupplyInfo{},
|
||||
&model.ExhVideo{},
|
||||
&model.ExhExam{},
|
||||
//&model.Contract{},
|
||||
//&model.SupplyInfo{},
|
||||
//&model.ExhVideo{},
|
||||
//&model.ExhExam{},
|
||||
&model.ArtistInfo{},
|
||||
&model.UserInvited{},
|
||||
&model.ArtworkState{},
|
||||
@ -107,3 +116,18 @@ func migration() {
|
||||
}
|
||||
fmt.Println("register table success")
|
||||
}
|
||||
|
||||
// 创建视图
|
||||
func generateModelView(functions ...func(db *gorm.DB) error) (err error) {
|
||||
if functions == nil {
|
||||
return
|
||||
}
|
||||
for _, viewFunc := range functions {
|
||||
err = viewFunc(DB)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user