Просмотр исходного кода

Merge branch 'feature/v1.2.13' of http://192.168.3.207:8080/BaseService/userCenter into feature/v1.2.13

wangshan 2 лет назад
Родитель
Сommit
b37b294272

+ 4 - 0
entity/ent.go

@@ -301,6 +301,7 @@ func (this *EntInfo) Update() bool {
 
 type Examine struct {
 	EntId       int64
+	AccountId   int64
 	ExamineId   string
 	AuthType    string
 	Reason      string
@@ -331,6 +332,7 @@ func (this *Examine) EntExamine() bool {
 			Appid:       "10000",
 			GoodsCode:   GOODSCODE_XXFB,
 			EntId:       this.EntId,
+			AccountId:   this.AccountId,
 			Type:        1,
 			GoodsSpecId: 4,
 			BuyNum:      1,
@@ -607,6 +609,7 @@ func (this *CheckEnt) Info() *EntInfoData {
 
 type UpdateEnt struct {
 	EntId       int64
+	AccountId   int64
 	UpdateType  int64
 	Mysql       *mysql.Mysql
 	ResourceLib resource.Resource
@@ -619,6 +622,7 @@ func (this *UpdateEnt) UpdateEnt() (int64, string) {
 		Appid:       "10000",
 		GoodsCode:   GOODSCODE_XXFB,
 		EntId:       this.EntId,
+		AccountId:   this.AccountId,
 		Type:        1, //1:开通权益 -1:取消权益
 		GoodsSpecId: 4,
 	}

+ 29 - 0
rpc/internal/logic/identitybyentidlogic.go

@@ -0,0 +1,29 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
+	"bp.jydev.jianyu360.cn/BaseService/userCenter/service"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type IdentityByEntIdLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewIdentityByEntIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IdentityByEntIdLogic {
+	return &IdentityByEntIdLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 根据企业id获取身份信息
+func (l *IdentityByEntIdLogic) IdentityByEntId(in *pb.IdentityReq) (*pb.Identity, error) {
+	return service.IdentityByEntId(in.Id), nil
+}

+ 6 - 0
rpc/internal/server/usercenterserver.go

@@ -160,6 +160,12 @@ func (s *UserCenterServer) IdentityByEntUserId(ctx context.Context, in *pb.Ident
 	return l.IdentityByEntUserId(in)
 }
 
+// 根据企业id获取身份信息
+func (s *UserCenterServer) IdentityByEntId(ctx context.Context, in *pb.IdentityReq) (*pb.Identity, error) {
+	l := logic.NewIdentityByEntIdLogic(ctx, s.svcCtx)
+	return l.IdentityByEntId(in)
+}
+
 // 获取用户身份相关参数
 func (s *UserCenterServer) UserIdentity(ctx context.Context, in *pb.UserIdentityReq) (*pb.UserIdentityResp, error) {
 	l := logic.NewUserIdentityLogic(ctx, s.svcCtx)

+ 38 - 33
rpc/pb/userCenter.pb.go

@@ -5299,7 +5299,7 @@ var file_userCenter_proto_rawDesc = []byte{
 	0x28, 0x03, 0x52, 0x11, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74,
 	0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d,
 	0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d,
-	0x65, 0x32, 0xb5, 0x09, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72,
+	0x65, 0x32, 0xe1, 0x09, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72,
 	0x12, 0x24, 0x0a, 0x07, 0x45, 0x6e, 0x74, 0x41, 0x75, 0x74, 0x68, 0x12, 0x0b, 0x2e, 0x45, 0x6e,
 	0x74, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x45, 0x6e, 0x74, 0x41, 0x75,
 	0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x0a, 0x45, 0x6e, 0x74, 0x45, 0x78, 0x61,
@@ -5371,11 +5371,14 @@ var file_userCenter_proto_rawDesc = []byte{
 	0x74, 0x69, 0x74, 0x79, 0x12, 0x2e, 0x0a, 0x13, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
 	0x42, 0x79, 0x45, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x0c, 0x2e, 0x49, 0x64,
 	0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x09, 0x2e, 0x49, 0x64, 0x65, 0x6e,
-	0x74, 0x69, 0x74, 0x79, 0x12, 0x33, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e,
-	0x74, 0x69, 0x74, 0x79, 0x12, 0x10, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74,
-	0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x65,
-	0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
-	0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x74, 0x69, 0x74, 0x79, 0x12, 0x2a, 0x0a, 0x0f, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
+	0x42, 0x79, 0x45, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x0c, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69,
+	0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x09, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
+	0x12, 0x33, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
+	0x12, 0x10, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52,
+	0x65, 0x71, 0x1a, 0x11, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
+	0x79, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
+	0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -5502,33 +5505,35 @@ var file_userCenter_proto_depIdxs = []int32{
 	51, // 48: UserCenter.IdentityByUserId:input_type -> IdentityReq
 	51, // 49: UserCenter.IdentityByPositionId:input_type -> IdentityReq
 	51, // 50: UserCenter.IdentityByEntUserId:input_type -> IdentityReq
-	54, // 51: UserCenter.UserIdentity:input_type -> UserIdentityReq
-	1,  // 52: UserCenter.EntAuth:output_type -> EntAuthResp
-	4,  // 53: UserCenter.EntExamine:output_type -> ExamineResp
-	7,  // 54: UserCenter.EntList:output_type -> EntListResp
-	11, // 55: UserCenter.ExamineList:output_type -> ExamineListResp
-	15, // 56: UserCenter.CheckEnt:output_type -> CheckEntResp
-	17, // 57: UserCenter.EntInfo:output_type -> EntInfoResp
-	4,  // 58: UserCenter.EntUpdate:output_type -> ExamineResp
-	17, // 59: UserCenter.ExamineInfo:output_type -> EntInfoResp
-	22, // 60: UserCenter.GetStatusByCode:output_type -> GetStatusByCodeResp
-	38, // 61: UserCenter.UserAdd:output_type -> UserAddResp
-	4,  // 62: UserCenter.UserUpdate:output_type -> ExamineResp
-	4,  // 63: UserCenter.UserDel:output_type -> ExamineResp
-	42, // 64: UserCenter.WorkDesktopMenuInfo:output_type -> WorkDesktopMenuInfoResp
-	49, // 65: UserCenter.WorkDesktopComprehensive:output_type -> WorkDesktopComprehensiveResp
-	49, // 66: UserCenter.WorkDesktopClearUserInfo:output_type -> WorkDesktopComprehensiveResp
-	23, // 67: UserCenter.GetUserInfo:output_type -> UserInfo
-	30, // 68: UserCenter.GetEntUserInfo:output_type -> EntUserResp
-	33, // 69: UserCenter.GetEntUserList:output_type -> EntUserListResp
-	35, // 70: UserCenter.CheckIsEntAdmin:output_type -> CheckIsEntAdminResp
-	53, // 71: UserCenter.IdentityList:output_type -> IdentityResp
-	52, // 72: UserCenter.IdentityByUserId:output_type -> Identity
-	52, // 73: UserCenter.IdentityByPositionId:output_type -> Identity
-	52, // 74: UserCenter.IdentityByEntUserId:output_type -> Identity
-	55, // 75: UserCenter.UserIdentity:output_type -> UserIdentityResp
-	52, // [52:76] is the sub-list for method output_type
-	28, // [28:52] is the sub-list for method input_type
+	51, // 51: UserCenter.IdentityByEntId:input_type -> IdentityReq
+	54, // 52: UserCenter.UserIdentity:input_type -> UserIdentityReq
+	1,  // 53: UserCenter.EntAuth:output_type -> EntAuthResp
+	4,  // 54: UserCenter.EntExamine:output_type -> ExamineResp
+	7,  // 55: UserCenter.EntList:output_type -> EntListResp
+	11, // 56: UserCenter.ExamineList:output_type -> ExamineListResp
+	15, // 57: UserCenter.CheckEnt:output_type -> CheckEntResp
+	17, // 58: UserCenter.EntInfo:output_type -> EntInfoResp
+	4,  // 59: UserCenter.EntUpdate:output_type -> ExamineResp
+	17, // 60: UserCenter.ExamineInfo:output_type -> EntInfoResp
+	22, // 61: UserCenter.GetStatusByCode:output_type -> GetStatusByCodeResp
+	38, // 62: UserCenter.UserAdd:output_type -> UserAddResp
+	4,  // 63: UserCenter.UserUpdate:output_type -> ExamineResp
+	4,  // 64: UserCenter.UserDel:output_type -> ExamineResp
+	42, // 65: UserCenter.WorkDesktopMenuInfo:output_type -> WorkDesktopMenuInfoResp
+	49, // 66: UserCenter.WorkDesktopComprehensive:output_type -> WorkDesktopComprehensiveResp
+	49, // 67: UserCenter.WorkDesktopClearUserInfo:output_type -> WorkDesktopComprehensiveResp
+	23, // 68: UserCenter.GetUserInfo:output_type -> UserInfo
+	30, // 69: UserCenter.GetEntUserInfo:output_type -> EntUserResp
+	33, // 70: UserCenter.GetEntUserList:output_type -> EntUserListResp
+	35, // 71: UserCenter.CheckIsEntAdmin:output_type -> CheckIsEntAdminResp
+	53, // 72: UserCenter.IdentityList:output_type -> IdentityResp
+	52, // 73: UserCenter.IdentityByUserId:output_type -> Identity
+	52, // 74: UserCenter.IdentityByPositionId:output_type -> Identity
+	52, // 75: UserCenter.IdentityByEntUserId:output_type -> Identity
+	52, // 76: UserCenter.IdentityByEntId:output_type -> Identity
+	55, // 77: UserCenter.UserIdentity:output_type -> UserIdentityResp
+	53, // [53:78] is the sub-list for method output_type
+	28, // [28:53] is the sub-list for method input_type
 	28, // [28:28] is the sub-list for extension type_name
 	28, // [28:28] is the sub-list for extension extendee
 	0,  // [0:28] is the sub-list for field type_name

+ 38 - 0
rpc/pb/userCenter_grpc.pb.go

@@ -68,6 +68,8 @@ type UserCenterClient interface {
 	IdentityByPositionId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error)
 	//根据企业员工id获取身份信息
 	IdentityByEntUserId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error)
+	//根据企业id获取身份信息
+	IdentityByEntId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error)
 	//获取用户身份相关参数
 	UserIdentity(ctx context.Context, in *UserIdentityReq, opts ...grpc.CallOption) (*UserIdentityResp, error)
 }
@@ -287,6 +289,15 @@ func (c *userCenterClient) IdentityByEntUserId(ctx context.Context, in *Identity
 	return out, nil
 }
 
+func (c *userCenterClient) IdentityByEntId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error) {
+	out := new(Identity)
+	err := c.cc.Invoke(ctx, "/UserCenter/IdentityByEntId", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 func (c *userCenterClient) UserIdentity(ctx context.Context, in *UserIdentityReq, opts ...grpc.CallOption) (*UserIdentityResp, error) {
 	out := new(UserIdentityResp)
 	err := c.cc.Invoke(ctx, "/UserCenter/UserIdentity", in, out, opts...)
@@ -346,6 +357,8 @@ type UserCenterServer interface {
 	IdentityByPositionId(context.Context, *IdentityReq) (*Identity, error)
 	//根据企业员工id获取身份信息
 	IdentityByEntUserId(context.Context, *IdentityReq) (*Identity, error)
+	//根据企业id获取身份信息
+	IdentityByEntId(context.Context, *IdentityReq) (*Identity, error)
 	//获取用户身份相关参数
 	UserIdentity(context.Context, *UserIdentityReq) (*UserIdentityResp, error)
 	mustEmbedUnimplementedUserCenterServer()
@@ -424,6 +437,9 @@ func (UnimplementedUserCenterServer) IdentityByPositionId(context.Context, *Iden
 func (UnimplementedUserCenterServer) IdentityByEntUserId(context.Context, *IdentityReq) (*Identity, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method IdentityByEntUserId not implemented")
 }
+func (UnimplementedUserCenterServer) IdentityByEntId(context.Context, *IdentityReq) (*Identity, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method IdentityByEntId not implemented")
+}
 func (UnimplementedUserCenterServer) UserIdentity(context.Context, *UserIdentityReq) (*UserIdentityResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method UserIdentity not implemented")
 }
@@ -854,6 +870,24 @@ func _UserCenter_IdentityByEntUserId_Handler(srv interface{}, ctx context.Contex
 	return interceptor(ctx, in, info, handler)
 }
 
+func _UserCenter_IdentityByEntId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(IdentityReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(UserCenterServer).IdentityByEntId(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/UserCenter/IdentityByEntId",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(UserCenterServer).IdentityByEntId(ctx, req.(*IdentityReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 func _UserCenter_UserIdentity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(UserIdentityReq)
 	if err := dec(in); err != nil {
@@ -971,6 +1005,10 @@ var UserCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "IdentityByEntUserId",
 			Handler:    _UserCenter_IdentityByEntUserId_Handler,
 		},
+		{
+			MethodName: "IdentityByEntId",
+			Handler:    _UserCenter_IdentityByEntId_Handler,
+		},
 		{
 			MethodName: "UserIdentity",
 			Handler:    _UserCenter_UserIdentity_Handler,

+ 2 - 0
rpc/userCenter.proto

@@ -545,6 +545,8 @@ service UserCenter {
   rpc IdentityByPositionId(IdentityReq) returns (Identity);
   //根据企业员工id获取身份信息
   rpc IdentityByEntUserId(IdentityReq) returns (Identity);
+  //根据企业id获取身份信息
+  rpc IdentityByEntId(IdentityReq) returns (Identity);
   //获取用户身份相关参数
   rpc UserIdentity (UserIdentityReq) returns (UserIdentityResp);
 }

+ 8 - 0
rpc/usercenter/usercenter.go

@@ -117,6 +117,8 @@ type (
 		IdentityByPositionId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error)
 		// 根据企业员工id获取身份信息
 		IdentityByEntUserId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error)
+		// 根据企业id获取身份信息
+		IdentityByEntId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error)
 		// 获取用户身份相关参数
 		UserIdentity(ctx context.Context, in *UserIdentityReq, opts ...grpc.CallOption) (*UserIdentityResp, error)
 	}
@@ -270,6 +272,12 @@ func (m *defaultUserCenter) IdentityByEntUserId(ctx context.Context, in *Identit
 	return client.IdentityByEntUserId(ctx, in, opts...)
 }
 
+// 根据企业id获取身份信息
+func (m *defaultUserCenter) IdentityByEntId(ctx context.Context, in *IdentityReq, opts ...grpc.CallOption) (*Identity, error) {
+	client := pb.NewUserCenterClient(m.cli.Conn())
+	return client.IdentityByEntId(ctx, in, opts...)
+}
+
 // 获取用户身份相关参数
 func (m *defaultUserCenter) UserIdentity(ctx context.Context, in *UserIdentityReq, opts ...grpc.CallOption) (*UserIdentityResp, error) {
 	client := pb.NewUserCenterClient(m.cli.Conn())

+ 6 - 0
service/entService.go

@@ -154,6 +154,9 @@ func (this *EntService) Examinet(data *userCenter.ExamineReq) (int64, string, in
 		Mysql:       entity.Mysql,
 		ResourceLib: entity.ResourceLib,
 	}
+	if identity := IdentityByEntId(data.EntId); identity != nil {
+		info.AccountId = identity.EntAccountId
+	}
 	if info.EntExamine() {
 		return 1, "", 0
 	}
@@ -283,6 +286,9 @@ func (this *EntService) UpdateEnt(data *userCenter.EntUpdateReq) (int64, string,
 		Mysql:       entity.Mysql,
 		ResourceLib: entity.ResourceLib,
 	}
+	if identity := IdentityByEntId(data.EntId); identity != nil {
+		info.AccountId = identity.EntAccountId
+	}
 	status, msg := info.UpdateEnt()
 	return 0, msg, status
 }

+ 11 - 0
service/identity.go

@@ -143,3 +143,14 @@ func IdentityByEntUserId(entUserId int64) *Identity {
 	}
 	return nil
 }
+
+//根据企业id获取身份信息
+func IdentityByEntId(entId int64) *Identity {
+	list := entity.Mysql.SelectBySql(`select id from base_account where ent_id=? and type=1 and person_id=0 limit 1`, entId)
+	if list == nil || len(*list) == 0 {
+		return nil
+	}
+	return &Identity{
+		EntAccountId: Int64All((*list)[0]["id"]),
+	}
+}