Jelajahi Sumber

修改pg方法

jyq 4 tahun lalu
induk
melakukan
71f3062193

+ 24 - 0
api/grpc/base.go

@@ -95,6 +95,30 @@ func (a Api) ManageableShopList(ctx context.Context, r *pb.ShopListRequest) (*pb
 	return rs, nil
 }
 
+func (a Api) ManageableGetShopInfo(ctx context.Context, r *pb.ShopDetailRequest) (*pb.ShopInfo, error) {
+	token := a.getToken(ctx)
+
+	rs := service.Shop{}.ManageableGetShopInfo(token, r)
+
+	return rs, nil
+}
+
+func (a Api) ShopLicenseList(ctx context.Context, r *pb.ShopDetailRequest) (*pb.LicenseList, error) {
+	token := a.getToken(ctx)
+
+	rs := service.Shop{}.ShopLicenseList(token, r)
+
+	return rs, nil
+}
+
+//func (a Api) ShopLicenseTypeMap(ctx context.Context, r *pb.IdList) (*pb.LicenseTypeMapReply, error) {
+//	token := a.getToken(ctx)
+//
+//	_ = service.Shop{}.LicenseTypeMap(token, r)
+//
+//	return nil, nil
+//}
+
 // ShopGroupQuery 商家跨店分组查询
 func (a Api) ShopGroupQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
 	// 获取token,并验证签名函数

File diff ditekan karena terlalu besar
+ 1030 - 489
api/grpc/base/base.pb.go


+ 108 - 0
api/grpc/base/base_grpc.pb.go

@@ -34,6 +34,9 @@ type ApiClient interface {
 	ScreenSimpleQuery(ctx context.Context, in *StandardRequest, opts ...grpc.CallOption) (*StandardReply, error)
 	// 商家信息管理
 	ManageableShopList(ctx context.Context, in *ShopListRequest, opts ...grpc.CallOption) (*ShopListReply, error)
+	ManageableGetShopInfo(ctx context.Context, in *ShopDetailRequest, opts ...grpc.CallOption) (*ShopInfo, error)
+	ShopLicenseList(ctx context.Context, in *ShopDetailRequest, opts ...grpc.CallOption) (*LicenseList, error)
+	ShopLicenseTypeMap(ctx context.Context, in *IdList, opts ...grpc.CallOption) (*LicenseTypeMapReply, error)
 	GetShopNavi(ctx context.Context, in *GetShopNaviRequest, opts ...grpc.CallOption) (*GetShopNaviReply, error)
 	ShopGroupQuery(ctx context.Context, in *StandardRequest, opts ...grpc.CallOption) (*StandardReply, error)
 	ShopGroupAdd(ctx context.Context, in *StandardRequest, opts ...grpc.CallOption) (*StandardReply, error)
@@ -256,6 +259,33 @@ func (c *apiClient) ManageableShopList(ctx context.Context, in *ShopListRequest,
 	return out, nil
 }
 
+func (c *apiClient) ManageableGetShopInfo(ctx context.Context, in *ShopDetailRequest, opts ...grpc.CallOption) (*ShopInfo, error) {
+	out := new(ShopInfo)
+	err := c.cc.Invoke(ctx, "/base.Api/ManageableGetShopInfo", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *apiClient) ShopLicenseList(ctx context.Context, in *ShopDetailRequest, opts ...grpc.CallOption) (*LicenseList, error) {
+	out := new(LicenseList)
+	err := c.cc.Invoke(ctx, "/base.Api/ShopLicenseList", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *apiClient) ShopLicenseTypeMap(ctx context.Context, in *IdList, opts ...grpc.CallOption) (*LicenseTypeMapReply, error) {
+	out := new(LicenseTypeMapReply)
+	err := c.cc.Invoke(ctx, "/base.Api/ShopLicenseTypeMap", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 func (c *apiClient) GetShopNavi(ctx context.Context, in *GetShopNaviRequest, opts ...grpc.CallOption) (*GetShopNaviReply, error) {
 	out := new(GetShopNaviReply)
 	err := c.cc.Invoke(ctx, "/base.Api/GetShopNavi", in, out, opts...)
@@ -1077,6 +1107,9 @@ type ApiServer interface {
 	ScreenSimpleQuery(context.Context, *StandardRequest) (*StandardReply, error)
 	// 商家信息管理
 	ManageableShopList(context.Context, *ShopListRequest) (*ShopListReply, error)
+	ManageableGetShopInfo(context.Context, *ShopDetailRequest) (*ShopInfo, error)
+	ShopLicenseList(context.Context, *ShopDetailRequest) (*LicenseList, error)
+	ShopLicenseTypeMap(context.Context, *IdList) (*LicenseTypeMapReply, error)
 	GetShopNavi(context.Context, *GetShopNaviRequest) (*GetShopNaviReply, error)
 	ShopGroupQuery(context.Context, *StandardRequest) (*StandardReply, error)
 	ShopGroupAdd(context.Context, *StandardRequest) (*StandardReply, error)
@@ -1218,6 +1251,15 @@ func (UnimplementedApiServer) ScreenSimpleQuery(context.Context, *StandardReques
 func (UnimplementedApiServer) ManageableShopList(context.Context, *ShopListRequest) (*ShopListReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ManageableShopList not implemented")
 }
+func (UnimplementedApiServer) ManageableGetShopInfo(context.Context, *ShopDetailRequest) (*ShopInfo, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ManageableGetShopInfo not implemented")
+}
+func (UnimplementedApiServer) ShopLicenseList(context.Context, *ShopDetailRequest) (*LicenseList, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ShopLicenseList not implemented")
+}
+func (UnimplementedApiServer) ShopLicenseTypeMap(context.Context, *IdList) (*LicenseTypeMapReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ShopLicenseTypeMap not implemented")
+}
 func (UnimplementedApiServer) GetShopNavi(context.Context, *GetShopNaviRequest) (*GetShopNaviReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetShopNavi not implemented")
 }
@@ -1732,6 +1774,60 @@ func _Api_ManageableShopList_Handler(srv interface{}, ctx context.Context, dec f
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Api_ManageableGetShopInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ShopDetailRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ApiServer).ManageableGetShopInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/base.Api/ManageableGetShopInfo",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ApiServer).ManageableGetShopInfo(ctx, req.(*ShopDetailRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Api_ShopLicenseList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ShopDetailRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ApiServer).ShopLicenseList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/base.Api/ShopLicenseList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ApiServer).ShopLicenseList(ctx, req.(*ShopDetailRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Api_ShopLicenseTypeMap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(IdList)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ApiServer).ShopLicenseTypeMap(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/base.Api/ShopLicenseTypeMap",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ApiServer).ShopLicenseTypeMap(ctx, req.(*IdList))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 func _Api_GetShopNavi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(GetShopNaviRequest)
 	if err := dec(in); err != nil {
@@ -3393,6 +3489,18 @@ var Api_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "ManageableShopList",
 			Handler:    _Api_ManageableShopList_Handler,
 		},
+		{
+			MethodName: "ManageableGetShopInfo",
+			Handler:    _Api_ManageableGetShopInfo_Handler,
+		},
+		{
+			MethodName: "ShopLicenseList",
+			Handler:    _Api_ShopLicenseList_Handler,
+		},
+		{
+			MethodName: "ShopLicenseTypeMap",
+			Handler:    _Api_ShopLicenseTypeMap_Handler,
+		},
 		{
 			MethodName: "GetShopNavi",
 			Handler:    _Api_GetShopNavi_Handler,

+ 90 - 1
assembly/base/service/shop.go

@@ -33,7 +33,7 @@ func (s Shop) ManageableShopList(token string, r *pb.ShopListRequest) *pb.ShopLi
 	_ = s.checkPermission(token, 0)
 	status := s.WebStatusToManageStatus(r.Status)
 	rst := im.ShopListRequest(r.Name, status, r.SId)
-	println(rst)
+	//println(rst)
 	var info []*pb.ShopInfo
 	if len(rst.List) > 0 {
 		l := &pb.ShopInfo{}
@@ -52,7 +52,68 @@ func (s Shop) ManageableShopList(token string, r *pb.ShopListRequest) *pb.ShopLi
 	}
 
 	return &pb.ShopListReply{List: info}
+}
+
+func (s Shop) ManageableGetShopInfo(token string, r *pb.ShopDetailRequest) *pb.ShopInfo {
+
+	optId := s.checkPermission(token, r.GetShopId())
+
+	rst := im.ShopDetail(r.ShopId)
+
+	navi := im.GetShopNavi(int64(optId), r.GetShopId(), 0)
+	var isHr, isScore int64 = 0, 0
+	if len(navi.List) > 0 {
+		for _, v := range navi.List {
+			if v.Name == "心率管理" {
+				isHr = 1
+			}
+			if v.Name == "运动评估" {
+				isScore = 1
+			}
+		}
+	}
+	info := &pb.ShopInfo{
+		ShopId:      rst.ShopId,
+		Name:        rst.Name,
+		SId:         rst.SId,
+		Addr:        rst.Addr,
+		Phone:       rst.Phone,
+		Contacts:    rst.Contacts,
+		Status:      s.ManageStatusToWebStatus(rst.Status),
+		CreatedAt:   rst.CreatedAt,
+		CreatedUser: rst.CreatedUser,
+		UpdatedAt:   rst.UpdatedAt,
+		UpdatedUser: rst.UpdatedUser,
+		IsHr:        isHr,
+		IsScore:     isScore,
+	}
+	return info
+}
+
+func (s Shop) LicenseTypeMap(token string, r *pb.IdList) *pb.LicenseTypeMapReply {
 
+	_ = s.checkPermission(token, 0)
+
+	rst := im.LicenseTypeMap(r.IdList)
+	println(rst)
+	//var info map[int64]pb.LicenseType
+	//if rst != nil {
+	//	l := &pb.ShopInfo{}
+	//	for _, v := range rst.List {
+	//		l.ShopId = v.ShopId
+	//		l.Name = v.Name
+	//		l.SId = v.SId
+	//		l.Addr = v.Addr
+	//		l.Phone = v.Phone
+	//		l.Contacts = v.Contacts
+	//		l.CreatedAt = v.CreatedAt
+	//		l.UpdatedAt = v.UpdatedAt
+	//		l.Status = s.ManageStatusToWebStatus(v.Status)
+	//		info = append(info, l)
+	//	}
+	//}
+
+	return nil
 }
 
 // GetShopNavi 获取商家导航
@@ -78,6 +139,34 @@ func (s Shop) GetShopNavi(token string, r *pb.GetShopNaviRequest) *pb.GetShopNav
 	return &pb.GetShopNaviReply{List: info}
 }
 
+// ShopLicenseList 获取商家许可证
+func (s Shop) ShopLicenseList(token string, r *pb.ShopDetailRequest) *pb.LicenseList {
+	_ = s.checkPermission(token, r.GetShopId())
+
+	rst := im.ShopLicenseList(r.ShopId)
+	var info []*pb.License
+	if len(rst.List) > 0 {
+		l := &pb.License{}
+		for _, v := range rst.List {
+			l.Id = v.Id
+			l.LcsTypeId = v.LcsTypeId
+			l.Name = v.Name
+			l.ValidPeriod = v.ValidPeriod
+			l.LcsPrice = v.LcsPrice
+			l.LcsBeginTime = v.LcsBeginTime
+			l.LcsEndTime = v.LcsEndTime
+			l.FeeId = v.FeeId
+			l.Status = s.ManageStatusToWebStatus(v.Status)
+			l.Memo = v.Memo
+			l.CreatedAt = v.CreatedUser
+			l.UpdatedAt = v.UpdatedAt
+			info = append(info, l)
+		}
+	}
+
+	return &pb.LicenseList{List: info}
+}
+
 func (s Shop) ShopGroupAdd(token string, objectShopId int64, jsonStr string, sign string) string {
 	optId := s.checkPermission(token, objectShopId)
 

+ 76 - 18
proto/server/base.proto

@@ -1,17 +1,17 @@
 syntax = "proto3";
 
-option go_package =".;base";
+option go_package = ".;base";
 
 package base;
 
 enum ErrorCode{
-  OK                 = 0;
-  PGErr              = 100;
-  PmsnError          = 110;
-  J2MError           = 120;
-  WebStatusError     = 121;
+  OK = 0;
+  PGErr = 100;
+  PmsnError = 110;
+  J2MError = 120;
+  WebStatusError = 121;
   WebToImStatusError = 122;
-  ImToWebtatusError  = 123;
+  ImToWebtatusError = 123;
 }
 
 // metadata 中需要字段 tokefrgen n 用作登录验证
@@ -34,6 +34,9 @@ service Api {
 
   // 商家信息管理
   rpc ManageableShopList (ShopListRequest) returns (ShopListReply) {}
+  rpc ManageableGetShopInfo (ShopDetailRequest) returns (ShopInfo) {}
+  rpc ShopLicenseList (ShopDetailRequest) returns (LicenseList) {}
+  rpc ShopLicenseTypeMap (IdList) returns (LicenseTypeMapReply)  {}
   rpc GetShopNavi (GetShopNaviRequest) returns (GetShopNaviReply) {}
   rpc ShopGroupQuery (StandardRequest) returns (StandardReply) {}
   rpc ShopGroupAdd (StandardRequest) returns (StandardReply) {}
@@ -178,17 +181,23 @@ message GenVerifyImageReply{
 }
 
 message ShopInfo{
-  int64 shopId          =1;
-  string name           =2;
-  int64 sId             =3;
-  string addr           =4;
-  string phone          =5;
-  string contacts       =6;
-  WebStatus status         =7;
-  int64 created_at      =8;
-  int64 created_user    =9;
-  int64 updated_at      =10;
-  int64 updated_user    =11;
+  int64 shopId = 1;
+  string name = 2;
+  int64 sId = 3;
+  string addr = 4;
+  string phone = 5;
+  string contacts = 6;
+  WebStatus status = 7;
+  int64 created_at = 8;
+  int64 created_user = 9;
+  int64 updated_at = 10;
+  int64 updated_user = 11;
+  int64 is_hr = 12;
+  int64 is_score = 13;
+}
+
+message ShopDetailRequest{
+  int64 shopId = 1;
 }
 
 message ShopListRequest{
@@ -238,4 +247,53 @@ message GetOverlayImgRequest{
 
 message QiNiuTokenReply{
   string token = 1;
+}
+
+message License{
+  int64 id = 1;
+  int64 shopId = 2;
+  int64 lcsTypeId = 3;
+  string name = 4;
+  // nanoSec
+  int64 validPeriod = 5;
+  // 分
+  int64 lcsPrice = 6;
+  // nanoSec
+  int64 lcsBeginTime = 7;
+  // nanoSec
+  int64 lcsEndTime = 8;
+
+  int64 feeId = 9;
+  WebStatus status = 10;
+  string memo = 11;
+  // nanoSec
+  int64  createdAt = 12;
+  int64 createdUser = 13;
+  // nanoSec
+  int64 updatedAt = 14;
+  int64 updatedUser = 15;
+}
+
+message LicenseList{
+  repeated License list = 1;
+}
+
+message IdList{
+  repeated int64 idList = 1;
+}
+
+message LicenseType{
+  int64 typeId = 1;
+  string name = 2;
+  // 有效期时长,单位毫秒
+  int64 validPeriodMs = 3;
+  // 单位:分
+  int32 price = 4;
+  string memo = 5;
+  int64 execUser = 6;
+  WebStatus status = 7;
+}
+
+message LicenseTypeMapReply{
+  map<int64, LicenseType> licenseMap = 1;
 }

+ 30 - 1
repository/grpc/bsw/im/api.go

@@ -116,13 +116,42 @@ func SubPermissionListCheck(token string, shopId int64, servicePathList []string
 
 func ShopListRequest(name string, status im.Status, sId int64) *im.ShopListReply {
 
-	request := &im.ShopListRequest{SysId: 1, Name: name, Status: status, SId: sId}
+	request := &im.ShopListRequest{SysId: 0, Name: name, Status: status, SId: sId}
 
 	rs, err := getClient().ShopList(ctx(), request)
 	handleErr(err)
 	return rs
 }
 
+// ShopDetail 查询商家信息
+func ShopDetail(shopId int64) *im.ShopInfo {
+	request := &im.ShopDetailRequest{ShopId: shopId}
+
+	rs, err := getClient().ShopDetail(ctx(), request)
+	handleErr(err)
+	return rs
+}
+
+// ShopLicenseList 商户许可列表
+func ShopLicenseList(shopId int64) *im.LicenseList {
+	request := &im.ShopDetailRequest{ShopId: shopId}
+
+	rs, err := getClient().ShopLicenseList(ctx(), request)
+
+	handleErr(err)
+	return rs
+}
+
+// LicenseTypeMap 许可类型字典
+func LicenseTypeMap(idList []int64) *im.LicenseTypeMapReply {
+	request := &im.IdList{IdList: idList}
+
+	rs, err := getClient().LicenseTypeMap(ctx(), request)
+
+	handleErr(err)
+	return rs
+}
+
 func GetShopNavi(userId, shopId int64, parentId int32) *im.UserGetColumnListReply {
 
 	request := &im.UserGetColumnListRequest{UserId: userId, ShopId: shopId, ParentId: parentId}

+ 15 - 7
repository/grpc/bsw/im/api_test.go

@@ -1,12 +1,13 @@
 package im
 
 import (
-	"git.beswell.com/gframe/application"
-	"github.com/sirupsen/logrus"
-	"google.golang.org/grpc"
 	"sportfitness/base/global"
 	pb "sportfitness/base/repository/grpc/bsw/im/im"
 	"testing"
+
+	"git.beswell.com/gframe/application"
+	"github.com/sirupsen/logrus"
+	"google.golang.org/grpc"
 )
 
 func init() {
@@ -73,9 +74,16 @@ func TestMD(t *testing.T) {
 
 }
 
-func TestSignInUserCodePassword(t *testing.T) {
-	token, userId := SignInUserCodePassword(
-		"test123", "123456", "192.168.0.100", "web")
+//func TestSignInUserCodePassword(t *testing.T) {
+//	token, userId := SignInUserCodePassword(
+//		"test123", "123456", "192.168.0.100", "web")
+//
+//	println(token, userId)
+//}
+func TestLicenseTypeMap(t *testing.T) {
+	idList := []int64{165770159456260096}
+	rs := LicenseTypeMap(
+		idList)
 
-	println(token, userId)
+	println(rs)
 }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini