Jelajahi Sumber

更新总后台grpc

jyq 4 tahun lalu
induk
melakukan
948dcf28ad

+ 488 - 3
api/grpc/base.go

@@ -2,10 +2,11 @@ package grpc
 
 import (
 	"context"
-	"google.golang.org/grpc/metadata"
 	pb "sportfitness/base/api/grpc/base"
 	"sportfitness/base/assembly/base/service"
 	"strings"
+
+	"google.golang.org/grpc/metadata"
 )
 
 type Api struct {
@@ -31,7 +32,7 @@ func (Api) getUserAgent(ctx context.Context) string {
 
 func (Api) getToken(ctx context.Context) (token string) {
 	if md, ok := metadata.FromIncomingContext(ctx); ok {
-		sl := md.Get("token")
+		sl := md.Get("Token")
 		if len(sl) >= 1 {
 			token = sl[0]
 		}
@@ -39,9 +40,32 @@ func (Api) getToken(ctx context.Context) (token string) {
 	return
 }
 
+// webToGoVerify 前端入Go验证签名函数,只允许StandardRequest进行验证
+func (a Api) webToGoVerify(ctx context.Context, q *pb.StandardRequest) (string, *pb.StandardRequest, string) {
+	token := a.getToken(ctx)
+
+	//wtgStr = q.JsonStr
+	wtgSign := q.Sign // 生成新签名
+	return token, q, wtgSign
+}
+
+func (Api) goToWebSigner(content string) (gtwStr, gtwSign string) {
+	gtwStr = content
+	gtwSign = ""
+	return
+}
+
+func (a Api) toWebFunc(content string) *pb.StandardReply {
+	gtwStr, gtwSign := a.goToWebSigner(content) // 空函数,go透传给前台数据时生成签名
+	return &pb.StandardReply{
+		JsonRst: gtwStr,
+		Sign:    gtwSign,
+	}
+}
+
 func (a Api) SignIn(ctx context.Context, q *pb.SignInRequest) (*pb.SignInReply, error) {
 	token := service.User{}.SignInUserCodePassword(
-		q.Name, q.Password, a.getRemoteIp(ctx), a.getUserAgent(ctx), q.CodeID, q.VerifyCode)
+		q.Name, q.Password, a.getRemoteIp(ctx), a.getUserAgent(ctx), q.CodeId, q.VerifyCode)
 
 	return &pb.SignInReply{Token: token}, nil
 }
@@ -51,6 +75,467 @@ func (a Api) GenVerifyImage(ctx context.Context, q *pb.GenVerifyImageRequest) (*
 	return &pb.GenVerifyImageReply{ImageBase64: imageBase64, CodeId: codeId}, nil
 }
 
+func (a Api) SignOut(ctx context.Context, q *pb.DefaultRequest) (*pb.DefaultReply, error) {
+	token := a.getToken(ctx)
+	service.User{}.SignOut(token)
+	return &pb.DefaultReply{}, nil
+}
+
 //func (a Api) SignUpInWithPhone()  {
 //
 //}
+
+// ----------------------- 商家信息管理 ---------------------------------------------
+
+func (a Api) ManageableShopList(ctx context.Context, r *pb.ShopListRequest) (*pb.ShopListReply, error) {
+	token := a.getToken(ctx)
+
+	rs := service.Shop{}.ManageableShopList(token, r)
+
+	return rs, nil
+}
+
+// ShopGroupQuery 商家跨店分组查询
+func (a Api) ShopGroupQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopGroupQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// GetShopNavi 查询商家栏目:分级查询,查询一级菜单parentId传入0
+func (a Api) GetShopNavi(ctx context.Context, r *pb.GetShopNaviRequest) (*pb.GetShopNaviReply, error) {
+	token := a.getToken(ctx)
+
+	rs := service.Shop{}.GetShopNavi(token, r)
+	return rs, nil
+}
+
+// ShopGroupAdd 商家跨店分组添加
+func (a Api) ShopGroupAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopGroupAdd(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopGroupEdit 商家跨店分组编辑
+func (a Api) ShopGroupEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopGroupEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopGroupStatusEdit 商家跨店分组状态修改
+func (a Api) ShopGroupStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopGroupStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopGroupDetailsQuery 跨店分组详情查询
+func (a Api) ShopGroupDetailsQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopGroupDetailsQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueQuery 商家区域查询
+func (a Api) ShopVenueQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueAdd 商家区域添加
+func (a Api) ShopVenueAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueAdd(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueEdit 商家区域编辑
+func (a Api) ShopVenueEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueStatusEdit 商家区域状态修改
+func (a Api) ShopVenueStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueEquipQuery 商家设备查询
+func (a Api) ShopVenueEquipQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueEquipQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueEquipEdit 商家设备编辑
+func (a Api) ShopVenueEquipEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueEquipEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueEquipStatusEdit 商家设备状态修改
+func (a Api) ShopVenueEquipStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueEquipStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVenueEquipStatusDel 商家设备删除
+func (a Api) ShopVenueEquipStatusDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopVenueEquipStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopConfigQuery 商家配置查询
+func (a Api) ShopConfigQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopConfigQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopConfigEdit 商家配置编辑
+func (a Api) ShopConfigEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Shop{}.ShopConfigEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// --------------------------商家会员管理----------------------------------------------------
+
+// ShopVipUserQuery 商家会员查询
+func (a Api) ShopVipUserQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.ShopVipUserQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVipUserAdd 商家会员添加
+func (a Api) ShopVipUserAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.ShopVipUserAdd(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVipUserEdit 商家会员编辑
+func (a Api) ShopVipUserEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.ShopVipUserEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ShopVipUserStatusEdit 商家会员状态编辑
+func (a Api) ShopVipUserStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.ShopVipUserStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// AcrossVipUserQuery 跨店会员查询
+func (a Api) AcrossVipUserQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.AcrossVipUserQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// AcrossVipUserAdd 跨店会员添加
+func (a Api) AcrossVipUserAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.AcrossVipUserQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// AcrossVipUserDel 跨店会员删除
+func (a Api) AcrossVipUserDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.AcrossVipUserDel(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipPhoneQuery 商家会员手机号查询
+func (a Api) VipPhoneQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipPhoneQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipMainPhoneCheck 商家会员主手机号校验
+func (a Api) VipMainPhoneCheck(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipMainPhoneCheck(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipOtherPhoneAdd 商家会员其他手机号添加
+func (a Api) VipOtherPhoneAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipOtherPhoneAdd(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipOtherPhoneEdit 商家会员其他手机号编辑
+func (a Api) VipOtherPhoneEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipOtherPhoneEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// TempVipUserQuery 商家临时会员查询
+func (a Api) TempVipUserQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.TempVipUserQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// TempVipUserAdd 商家临时会员添加
+func (a Api) TempVipUserAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.TempVipUserAdd(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// TempVipUserEdit 商家临时会员编辑
+func (a Api) TempVipUserEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.TempVipUserEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// TempVipUserStatusEdit 商家临时会员状态修改
+func (a Api) TempVipUserStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.TempVipUserStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipHourEdit 商家会员课时编辑
+func (a Api) VipHourEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.TempVipUserStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipConsumeListQuery 商家会员消费课时查询
+func (a Api) VipConsumeListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipConsumeListQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipConsumeDetailQuery 商家会员消费课时详情查询
+func (a Api) VipConsumeDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipConsumeDetailQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipClassRelationEdit 商家会员对应课程增删
+func (a Api) VipClassRelationEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipClassRelationEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// VipHourChgQuery 商家会员消费课时详情查询
+func (a Api) VipHourChgQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.User{}.VipHourChgQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// GetSimpleQiNiuToken 获取七牛简单Token
+func (a Api) GetSimpleQiNiuToken(ctx context.Context, r *pb.DefaultRequest) (*pb.QiNiuTokenReply, error) {
+	token := a.getToken(ctx)
+	rs := service.User{}.GetSimpleQiNiuToken(token)
+	return rs, nil
+}
+
+// GetOverlayImgQiNiuToken 获取七牛可覆盖文件Token
+func (a Api) GetOverlayImgQiNiuToken(ctx context.Context, r *pb.GetOverlayImgRequest) (*pb.QiNiuTokenReply, error) {
+	token := a.getToken(ctx)
+
+	rs := service.User{}.GetOverlayImgQiNiuToken(token, r.FileName)
+	return rs, nil
+}
+
+// ClassQuery 商家基础课程查询
+func (a Api) ClassQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassQuery(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassAdd 商家基础课程添加
+func (a Api) ClassAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassAdd(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassEdit 商家基础课程编辑
+func (a Api) ClassEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassStatusEdit 商家基础课程状态编辑
+func (a Api) ClassStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassStatusEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassColorEdit 商家基础课程颜色修改
+func (a Api) ClassColorEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassColorEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassWxVisibleEdit 商家基础课程微信显示状态修改
+func (a Api) ClassWxVisibleEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassWxVisibleEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}
+
+// ClassVipEdit 商家课程会员增删
+func (a Api) ClassVipEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
+	// 获取token,并验证签名函数
+	token, q, sign := a.webToGoVerify(ctx, r)
+
+	rs := service.Class{}.ClassVipEdit(token, q.ShopID, q.JsonStr, sign)
+	rst := a.toWebFunc(rs)
+	return rst, nil
+}

File diff ditekan karena terlalu besar
+ 1317 - 172
api/grpc/base/base.pb.go


File diff ditekan karena terlalu besar
+ 1774 - 38
api/grpc/base/base_grpc.pb.go


+ 60 - 0
assembly/base/repository/postgre/class.go

@@ -0,0 +1,60 @@
+// Package postgre
+/**
+ * @ File:
+ * @ Date: 2021/4/26 11:26
+ * @ Author: JYQ
+ * @ Description:
+ */
+package postgre
+
+type PGClass struct {
+}
+
+func (PGClass) ClassQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_List_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGClass) ClassAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_Add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGClass) ClassEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGClass) ClassStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGClass) ClassColorEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_color_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGClass) ClassVisibleStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_visible_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGClass) ClassVipUserEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_vip_user_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}

+ 14 - 2
assembly/base/repository/postgre/functest.go

@@ -10,12 +10,24 @@ func (f FuncTest) TestAdd(optUserId int, jsonStr string, verfStr string) (err er
 	err = getClient().Raw("select demo_tmp_user_add(? ,? ,? )", optUserId, jsonStr, verfStr).Scan(&result).Error
 	return
 }
-func (f FuncTest) TestQuery1(optUserId int, jsonStr string, verfStr string) (err error) {
 
-	result := map[string]interface{}{}
+func (f FuncTest) TestQuery32(optUserId int, jsonStr string, verfStr string) (rst string, err error) {
+
+	var result string
 	//row1,err_ := getClient().Raw("select demo_tmp_user_query(? ,? ,? )",optUserId,jsonStr,verfStr).Rows()
 	err = getClient().Raw("select demo_tmp_user_query(? ,? ,? )", optUserId, jsonStr, verfStr).Scan(&result).Error
 	//row1.Scan(&result)
 	//println(result)
+	//if err != nil {
+	//	st := err.Error()
+	//	t1 := strings.Split(st, ";")[0]
+	//	comma1 := strings.Index(t1, "errcode:")
+	//	comma2 := strings.Index(t1, "errmemo:")
+	//	println(comma1, comma2)
+	//	pos := strings.Index(t1[comma1:], ",err")
+	//	println(pos)
+	//	println(t1[comma1:13])
+	//	println(t1[comma2:])
+	//}
 	return
 }

+ 19 - 4
assembly/base/repository/postgre/functest_test.go

@@ -1,9 +1,11 @@
 package postgre
 
 import (
-	"git.beswell.com/gframe/application"
 	"sportfitness/base/assembly/base/repository"
+	"sportfitness/base/errors"
 	"testing"
+
+	"git.beswell.com/gframe/application"
 )
 
 func init() {
@@ -18,8 +20,21 @@ func TestAdd(t *testing.T) {
 
 	println(err)
 }
-func TestQuery1(t *testing.T) {
-	err := FuncTest{}.TestQuery1(1, "{\"user_name\": \"王\"}", "XX")
 
-	println(err)
+func TestQuery32(t *testing.T) {
+	str, err := FuncTest{}.TestQuery32(1, "{\"user_name\": \"王\"}", "XX")
+	//if err != nil{
+	//	e := errors.PGError
+	//	errJson, e_ := json.Marshal(e)
+	//
+	//	if e_ != nil {
+	//		println(e_)
+	//	}
+	//	ej := string(errJson)
+	//	println(ej)
+	//}
+	if err != nil {
+		panic(errors.PGError)
+	}
+	println(str)
 }

+ 270 - 0
assembly/base/repository/postgre/shop.go

@@ -0,0 +1,270 @@
+// Package postgre
+/**
+ * @ File:
+ * @ Date: 2021/4/13 10:46
+ * @ Author: JYQ
+ * @ Description:
+ */
+package postgre
+
+type PGShop struct {
+}
+
+func (PGShop) ShopGroupQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_group_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopGroupAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_group_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopGroupEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_group_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopGroupStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_group_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopGroupDetailsQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_ingroup_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_venue_list_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_venue_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_venue_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_venue_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueEquipQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_eq_list_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueEquipAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_eq_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueEquipEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_eq_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueEquipStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_eq_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopVenueEquipStatusDel(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_eq_del(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopConfigQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_config_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ShopConfigEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_shop_config_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserListQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_list_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) AcrossVipUserListQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_across_vip_user_list_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) AcrossVipUserAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_across_vip_user_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) AcrossVipUserDel(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_across_vip_user_del(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserPhoneQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_across_vip_user_del(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserQueryByPhone(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_query_by_phone(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserOtherPhoneAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_other_phone_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserOtherPhoneEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_other_phone_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserOtherPhoneStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_other_phone_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) TmpVipUserQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_tmp_user_list_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) TmpUserAdd(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_tmp_user_add(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) TmpVipUserEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_tmp_user_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) TmpVipUserStatusEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_tmp_user_status_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserHourEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_hour_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserConsumeListQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_consume_list_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserConsumeDetailQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_consume_detail_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) VipUserClassEdit(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_vip_user_class_edit(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}
+
+func (PGShop) ClassHourChgQuery(optUserId int64, objectShopId int64, jsonStr string, verfStr string) (result string, err error) {
+	err = getClient().Raw("select fn_class_hour_chg_query(? ,? ,? )", optUserId, objectShopId, jsonStr, verfStr).
+		Scan(&result).Error
+
+	return
+}

+ 100 - 1
assembly/base/service/base.go

@@ -1,9 +1,16 @@
 package service
 
 import (
+	"encoding/json"
+	"runtime"
+	pb "sportfitness/base/api/grpc/base"
+	"sportfitness/base/errors"
+	"sportfitness/base/repository/grpc/bsw/im"
+	im2 "sportfitness/base/repository/grpc/bsw/im/im"
+	"strings"
+
 	"git.beswell.com/gframe/application"
 	"github.com/sirupsen/logrus"
-	"sportfitness/base/repository/grpc/bsw/im"
 )
 
 type base struct {
@@ -22,3 +29,95 @@ func RegisterServices() {
 		logrus.Fatalf("服务保存失败: \n%s", err)
 	}
 }
+
+func GetFuncName() string {
+	pc := make([]uintptr, 1)
+	runtime.Callers(2, pc)
+	f := runtime.FuncForPC(pc[0]).Name()
+	println(f)
+	l := strings.Split(f, ".")
+	serviceName := l[1] + "/" + l[2]
+	return serviceName
+}
+
+func (base) checkPermission(token string, shopId int64) (optId int64) {
+	// 用token获取用户ID
+	optId = User{}.SubSessionCheck(token)
+	pc := make([]uintptr, 1)
+	runtime.Callers(2, pc)
+	f := runtime.FuncForPC(pc[0]).Name()
+	println(f)
+	l := strings.Split(f, ".")
+	serviceName := l[1] + "/" + l[2]
+
+	// 目标商家是否有操作权限
+	rs := im.SubPermissionListCheck(token, shopId, []string{serviceName}).ResultList[0]
+	if !rs {
+		// todo 暂时忽略权限校验
+		//panic(errors.PmsnError)
+	}
+	return
+}
+
+func (base) JSONToMap(str string) (map[string]interface{}, error) {
+
+	var tempMap map[string]interface{}
+
+	err := json.Unmarshal([]byte(str), &tempMap)
+
+	if err != nil {
+		err = errors.J2MError
+		return tempMap, err
+	}
+
+	return tempMap, nil
+}
+
+func (base) WebStatusCheck(s pb.WebStatus) pb.WebStatus {
+	var ws pb.WebStatus
+	switch s {
+	case 0:
+		ws = pb.WebStatus_Ban
+	case 1:
+		ws = pb.WebStatus_On
+	case 9:
+		ws = pb.WebStatus_Delete
+	case 99:
+		ws = pb.WebStatus_All
+	default:
+		panic(errors.WebStatusError)
+	}
+	return ws
+}
+
+func (b base) WebStatusToManageStatus(s pb.WebStatus) im2.Status {
+	var status im2.Status
+	ws := b.WebStatusCheck(s)
+	switch ws {
+	case 99:
+		status = im2.Status_Null
+	case 0:
+		status = im2.Status_Ban
+	case 1:
+		status = im2.Status_On
+	case 9:
+		status = im2.Status_Delete
+	default:
+		panic(errors.WebToImStatusError)
+	}
+	return status
+}
+
+func (base) ManageStatusToWebStatus(s im2.Status) (status pb.WebStatus) {
+	switch s {
+	case 1:
+		status = pb.WebStatus_Ban
+	case 2:
+		status = pb.WebStatus_On
+	case 9:
+		status = pb.WebStatus_Delete
+	default:
+		panic(errors.ImToWebtatusError)
+	}
+	return status
+}

+ 87 - 0
assembly/base/service/classMGT.go

@@ -0,0 +1,87 @@
+// Package service
+/**
+ * @ File:
+ * @ Date: 2021/4/26 11:15
+ * @ Author: JYQ
+ * @ Description: 课程管理,包含课程表模板,课程表实例
+ */
+package service
+
+import (
+	"sportfitness/base/assembly/base/repository/postgre"
+	"sportfitness/base/errors"
+)
+
+type Class struct {
+	base
+}
+
+func (c Class) ClassQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (c Class) ClassAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (c Class) ClassEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (c Class) ClassStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (c Class) ClassColorEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassColorEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (c Class) ClassWxVisibleEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassVisibleStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (c Class) ClassVipEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := c.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGClass{}.ClassVipUserEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}

+ 8 - 0
assembly/base/service/courseMGT.go

@@ -0,0 +1,8 @@
+// Package service
+/**
+ * @ File:
+ * @ Date: 2021/4/26 11:18
+ * @ Author: JYQ
+ * @ Description: 上下课管理
+ */
+package service

+ 8 - 0
assembly/base/service/order.go

@@ -0,0 +1,8 @@
+// Package service
+/**
+ * @ File:
+ * @ Date: 2021/4/26 11:19
+ * @ Author: JYQ
+ * @ Description: 预约管理
+ */
+package service

+ 239 - 0
assembly/base/service/shop.go

@@ -0,0 +1,239 @@
+// Package service
+/**
+ * @ File: shop
+ * @ Date: 2021/4/13 10:41
+ * @ Author: JYQ
+ * @ Description:
+ */
+package service
+
+import (
+	pb "sportfitness/base/api/grpc/base"
+	"sportfitness/base/assembly/base/repository/postgre"
+	"sportfitness/base/errors"
+	"sportfitness/base/repository/grpc/bsw/im"
+)
+
+type Shop struct {
+	base
+}
+
+func (s Shop) ShopGroupQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopGroupQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (s Shop) ManageableShopList(token string, r *pb.ShopListRequest) *pb.ShopListReply {
+	// 获取商家可用商家列表shopId传入0,因为是通用接口
+	_ = s.checkPermission(token, 0)
+	status := s.WebStatusToManageStatus(r.Status)
+	rst := im.ShopListRequest(r.Name, status, r.SId)
+	println(rst)
+	var info []*pb.ShopInfo
+	if len(rst.List) > 0 {
+		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 &pb.ShopListReply{List: info}
+
+}
+
+// GetShopNavi 获取商家导航
+func (s Shop) GetShopNavi(token string, r *pb.GetShopNaviRequest) *pb.GetShopNaviReply {
+	optId := s.checkPermission(token, r.GetShopId())
+
+	rst := im.GetShopNavi(int64(optId), r.GetShopId(), r.GetParentId())
+	var info []*pb.Column
+	if len(rst.List) > 0 {
+		l := &pb.Column{}
+		for _, v := range rst.List {
+			l.Name = v.Name
+			l.Url = v.Url
+			l.Code = v.Code
+			l.Sn = v.Sn
+			l.NavShow = v.NavShow
+			l.Id = v.Id
+			l.Status = s.ManageStatusToWebStatus(v.Status)
+			info = append(info, l)
+		}
+	}
+
+	return &pb.GetShopNaviReply{List: info}
+}
+
+func (s Shop) ShopGroupAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopGroupAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (s Shop) ShopGroupEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopGroupEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (s Shop) ShopGroupStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopGroupStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (s Shop) ShopGroupDetailsQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopGroupDetailsQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+func (s Shop) ShopVenueQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueAdd 商家区域添加 @token:token
+func (s Shop) ShopVenueAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueEdit 商家区域编辑
+func (s Shop) ShopVenueEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueStatusEdit 商家区域状态修改
+func (s Shop) ShopVenueStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueEquipQuery 商家设备查询
+func (s Shop) ShopVenueEquipQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueEquipAdd 商家设备添加
+func (s Shop) ShopVenueEquipAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueEquipQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueEquipEdit 商家设备编辑
+func (s Shop) ShopVenueEquipEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueEquipEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueEquipStatusEdit 商家设备状态修改
+func (s Shop) ShopVenueEquipStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueEquipStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVenueEquipStatusDel 商家设备删除
+func (s Shop) ShopVenueEquipStatusDel(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopVenueEquipStatusDel(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopConfigQuery 商家配置查询
+func (s Shop) ShopConfigQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopConfigQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopConfigEdit 商家设备删除
+func (s Shop) ShopConfigEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := s.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.ShopConfigEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}

+ 290 - 1
assembly/base/service/user.go

@@ -1,11 +1,27 @@
 package service
 
-import "sportfitness/base/repository/grpc/bsw/im"
+import (
+	"fmt"
+	pb "sportfitness/base/api/grpc/base"
+	"sportfitness/base/assembly/base/repository/postgre"
+	"sportfitness/base/errors"
+	"sportfitness/base/repository/grpc/bsw/im"
+	im2 "sportfitness/base/repository/grpc/bsw/im/im"
+
+	"github.com/qiniu/api.v7/v7/auth/qbox"
+	"github.com/qiniu/api.v7/v7/storage"
+)
 
 type User struct {
 	base
 }
 
+var (
+	accessKey = "JvRT6F0pbWwfTwRZOeYCLcTFBwtE_E0CFp6DZklk"
+	secretKey = "vgYd-QjeAk9v5QrIU1z4427xJi_nao4LCuXgWfgJ"
+	bucket    = "beswell"
+)
+
 func (User) SignInUserCodePassword(userCode, password, ip, ClientInfo,
 	codeId, verifyCode string) (token string) {
 
@@ -17,8 +33,281 @@ func (User) SignInUserCodePassword(userCode, password, ip, ClientInfo,
 	return token
 }
 
+func (User) SignOut(token string) {
+	im.SignOut(token)
+}
+
 func (User) GenVerifyImage(height, width int32) (string, string) {
 	codeId, imageBase64 := im.GenVerifyImage(height, width)
 
 	return codeId, imageBase64
 }
+
+func (User) SubSessionCheck(token string) int64 {
+	userId := im.SubSessionCheck(token)
+
+	return userId
+}
+
+// SubPermissionListCheck 页面批量鉴权
+func (User) SubPermissionListCheck(token string, shopID int64, serviceList []string) (rs *im2.PermissionCheckReply) {
+	rs = im.SubPermissionListCheck(token, shopID, serviceList)
+	return
+}
+
+// ShopVipUserQuery 商家会员查询
+func (u User) ShopVipUserQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserListQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVipUserAdd 商家会员添加
+func (u User) ShopVipUserAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVipUserEdit 商家会员编辑
+func (u User) ShopVipUserEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// ShopVipUserStatusEdit 商家会状态员编辑
+func (u User) ShopVipUserStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// AcrossVipUserQuery 商家跨店会员查询
+func (u User) AcrossVipUserQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.AcrossVipUserListQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// AcrossVipUserAdd 商家跨店会员添加
+func (u User) AcrossVipUserAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.AcrossVipUserAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// AcrossVipUserDel 商家跨店会员删除
+func (u User) AcrossVipUserDel(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.AcrossVipUserDel(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipPhoneQuery 商家跨店会员删除
+func (u User) VipPhoneQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserPhoneQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipMainPhoneCheck 商家会员主手机号校验
+func (u User) VipMainPhoneCheck(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserQueryByPhone(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipOtherPhoneAdd 商家会员其他手机号添加
+func (u User) VipOtherPhoneAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserOtherPhoneAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipOtherPhoneEdit 商家会员其他手机号编辑
+func (u User) VipOtherPhoneEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserOtherPhoneEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipOtherPhoneStatusEdit 商家会员其他手机号状态修改
+func (u User) VipOtherPhoneStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserOtherPhoneStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// TempVipUserQuery 商家临时会员查询
+func (u User) TempVipUserQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.TmpVipUserQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// TempVipUserAdd 商家临时会员添加
+func (u User) TempVipUserAdd(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.TmpUserAdd(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// TempVipUserEdit 商家临时会员编辑
+func (u User) TempVipUserEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.TmpVipUserEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// TempVipUserStatusEdit 商家临时会员状态修改
+func (u User) TempVipUserStatusEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.TmpVipUserStatusEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipHourEdit 商家会员课时编辑
+func (u User) VipHourEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserHourEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipConsumeListQuery 商家会员消费课时查询
+func (u User) VipConsumeListQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserConsumeListQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipConsumeDetailQuery 商家会员消费课时详情查询
+func (u User) VipConsumeDetailQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserConsumeDetailQuery(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipClassRelationEdit 商家会员消费课时详情查询
+func (u User) VipClassRelationEdit(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserClassEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// VipHourChgQuery 商家会员消费课时详情查询
+func (u User) VipHourChgQuery(token string, objectShopId int64, jsonStr string, sign string) string {
+	optId := u.checkPermission(token, objectShopId)
+
+	rst, err := postgre.PGShop{}.VipUserClassEdit(optId, objectShopId, jsonStr, sign)
+	if err != nil {
+		panic(errors.PGError)
+	}
+	return rst
+}
+
+// GetSimpleQiNiuToken 获取七牛简单Token
+func (u User) GetSimpleQiNiuToken(token string) *pb.QiNiuTokenReply {
+	_ = u.checkPermission(token, 0)
+	putPolicy := storage.PutPolicy{
+		Scope: bucket,
+	}
+
+	mac := qbox.NewMac(accessKey, secretKey)
+	t := putPolicy.UploadToken(mac)
+
+	return &pb.QiNiuTokenReply{Token: t}
+}
+
+// GetOverlayImgQiNiuToken 获取七牛可覆盖文件Token
+func (u User) GetOverlayImgQiNiuToken(token, fileName string) *pb.QiNiuTokenReply {
+	_ = u.checkPermission(token, 0)
+	putPolicy := storage.PutPolicy{
+		Scope: fmt.Sprintf("%s:%s", bucket, fileName),
+	}
+
+	mac := qbox.NewMac(accessKey, secretKey)
+	t := putPolicy.UploadToken(mac)
+
+	return &pb.QiNiuTokenReply{Token: t}
+}

+ 55 - 0
errors/error.go

@@ -0,0 +1,55 @@
+// Package errors
+/**
+ * @ File:
+ * @ Date: 2021/4/13 11:13
+ * @ Author: JYQ
+ * @ Description:
+ */
+package errors
+
+import (
+	pb "sportfitness/base/api/grpc/base"
+
+	"git.beswell.com/gframe/application"
+)
+
+type ErrorCode int
+
+//const (
+//	PGErr ErrorCode = 100
+//)
+
+var (
+	//PGError = NewInternalErr(PGErr, "数据库内部错误")
+	PGError            = application.Errorf(application.ErrorCode(pb.ErrorCode_PGErr), "数据库内部错误")
+	PmsnError          = application.Errorf(application.ErrorCode(pb.ErrorCode_PmsnError), "用户无此权限,请联系管理员")
+	J2MError           = application.Errorf(application.ErrorCode(pb.ErrorCode_J2MError), "Json数据解析失败,请检查后提交")
+	WebStatusError     = application.Errorf(application.ErrorCode(pb.ErrorCode_WebStatusError), "状态值错误,请检查后重新提交")
+	WebToImStatusError = application.Errorf(application.ErrorCode(pb.ErrorCode_WebToImStatusError),
+		"状态值转换错误,请检查后提交")
+	ImToWebtatusError = application.Errorf(application.ErrorCode(pb.ErrorCode_ImToWebtatusError),
+		"状态值转换错误,请检查后提交")
+)
+
+//StandardError 标准错误,包含错误码和错误信息
+type StandardError struct {
+	Code ErrorCode `json:"code"`
+	//debugMsg string `json:"memo"`
+	ShowMsg string `json:"memo"`
+}
+
+func NewInternalErr(code ErrorCode, msg string) *StandardError {
+	return &StandardError{
+		Code: code,
+		//debugMsg: msg,
+		ShowMsg: msg,
+	}
+}
+
+func NewServiceErr(code ErrorCode, msg string) *StandardError {
+	return &StandardError{
+		Code: code,
+		//debugMsg: msg,
+		ShowMsg: msg,
+	}
+}

+ 1 - 1
go.mod

@@ -8,6 +8,7 @@ require (
 	github.com/go-redis/redis/v8 v8.8.0
 	github.com/go-sql-driver/mysql v1.6.0 // indirect
 	github.com/golang/protobuf v1.5.2
+	github.com/qiniu/api.v7/v7 v7.6.0
 	github.com/hashicorp/go-hclog v0.16.0 // indirect
 	github.com/klauspost/compress v1.11.13 // indirect
 	github.com/sirupsen/logrus v1.8.1
@@ -17,5 +18,4 @@ require (
 	google.golang.org/genproto v0.0.0-20210406143921-e86de6bf7a46 // indirect
 	google.golang.org/grpc v1.36.1
 	google.golang.org/protobuf v1.26.0
-	gorm.io/gorm v1.21.6
 )

+ 112 - 12
proto/server/base.proto

@@ -5,19 +5,36 @@ option go_package =".;base";
 package base;
 
 enum ErrorCode{
-  OK = 0;
+  OK                 = 0;
+  PGErr              = 100;
+  PmsnError          = 110;
+  J2MError           = 120;
+  WebStatusError     = 121;
+  WebToImStatusError = 122;
+  ImToWebtatusError  = 123;
 }
 
 // metadata 中需要字段 tokefrgen n 用作登录验证
 service Api {
   rpc SignUp (SignUpRequest) returns (DefaultReply) {}
   rpc SignIn (SignInRequest) returns (SignInReply)  {}
+  // rpc SignInWithPhone (SignInRequest) returns (SignInReply)  {} // 缺少短信验证码接口
   rpc SignOut (DefaultRequest) returns (DefaultReply)  {}
   rpc GenVerifyImage (GenVerifyImageRequest) returns (GenVerifyImageReply)  {}
 
+  // 下拉框接口
+  rpc SelectHrSensors (StandardRequest) returns (StandardReply)  {}
+  rpc AcrossUserSimpleQuery (StandardRequest) returns (StandardReply)  {}
+  rpc VipUserSimpleQuery (StandardRequest) returns (StandardReply)  {}
+  rpc TempVipUserSimpleQuery (StandardRequest) returns (StandardReply)  {}
+  rpc ShopSimpleQuery (StandardRequest) returns (StandardReply)  {}
+  rpc ManageableSimpleQuery (StandardRequest) returns (StandardReply)  {}
+  rpc ClassSimpleQuery (StandardRequest) returns (StandardReply)  {}
+  rpc ScreenSimpleQuery (StandardRequest) returns (StandardReply)  {}
+
   // 商家信息管理
-  rpc ManageableShopList (StandardRequest) returns (StandardReply) {}
-  rpc GetShopNavi (StandardRequest) returns (StandardReply) {}
+  rpc ManageableShopList (ShopListRequest) returns (ShopListReply) {}
+  rpc GetShopNavi (GetShopNaviRequest) returns (GetShopNaviReply) {}
   rpc ShopGroupQuery (StandardRequest) returns (StandardReply) {}
   rpc ShopGroupAdd (StandardRequest) returns (StandardReply) {}
   rpc ShopGroupEdit (StandardRequest) returns (StandardReply) {}
@@ -47,21 +64,41 @@ service Api {
   rpc AcrossVipUserQuery (StandardRequest) returns (StandardReply) {}
   rpc AcrossVipUserAdd (StandardRequest) returns (StandardReply) {}
   rpc AcrossVipUserDel (StandardRequest) returns (StandardReply) {}
+  rpc VipPhoneQuery (StandardRequest) returns (StandardReply) {}
+  rpc VipMainPhoneCheck (StandardRequest) returns (StandardReply) {}
+  rpc VipOtherPhoneAdd (StandardRequest) returns (StandardReply) {}
+  rpc VipOtherPhoneEdit (StandardRequest) returns (StandardReply) {}
+  rpc VipOtherPhoneStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc TempVipUserQuery (StandardRequest) returns (StandardReply) {}
+  rpc TempVipUserAdd (StandardRequest) returns (StandardReply) {}
+  rpc TempVipUserEdit (StandardRequest) returns (StandardReply) {}
+  rpc TempVipUserStatusEdit (StandardRequest) returns (StandardReply) {}
+  rpc VipHourEdit (StandardRequest) returns (StandardReply) {}
+  rpc VipConsumeListQuery (StandardRequest) returns (StandardReply) {}
+  rpc VipConsumeDetailQuery (StandardRequest) returns (StandardReply) {}
+  rpc VipClassRelationEdit (StandardRequest) returns (StandardReply) {}
+  rpc VipHourChgQuery (StandardRequest) returns (StandardReply) {}
+  rpc GetOverlayImgQiNiuToken (GetOverlayImgRequest) returns (QiNiuTokenReply) {}
+  rpc GetSimpleQiNiuToken (DefaultRequest) returns (QiNiuTokenReply) {}
+
+
+
   // 心率
-  rpc SelectHrSensors (StandardRequest) returns (StandardReply)  {}
+
 }
 message DefaultRequest{
 }
 message DefaultReply{}
 
 message StandardRequest{
-  string Token = 1;
-  string JsonStr = 2;
-  string Sign = 3;
+  int64 shopID = 1;
+  string jsonStr = 2;
+  string sign = 3;
 }
 
 message StandardReply{
-  string JsonRst = 1;
+  string jsonRst = 1;
+  string sign = 2;
 }
 
 message SignUpRequest {
@@ -74,10 +111,10 @@ message SignInReply {
 }
 
 message SignInRequest {
-  string Name = 1;
-  string Password = 2;
-  string CodeID = 3;
-  string VerifyCode = 4;
+  string name = 1;
+  string password = 2;
+  string codeId = 3;
+  string verifyCode = 4;
 }
 
 message GenVerifyImageRequest{
@@ -88,4 +125,67 @@ message GenVerifyImageRequest{
 message GenVerifyImageReply{
   string codeId = 1;
   string imageBase64 = 2;
+}
+
+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;
+}
+
+message ShopListRequest{
+  // 模糊查询
+  string name = 1;
+  // Status_Null查询全部
+  WebStatus status = 2;
+  //上级商家Id, -1 时查询全部
+  int64 sId = 3;
+}
+
+message ShopListReply{
+  repeated ShopInfo list = 1;
+}
+
+enum WebStatus{
+  Ban = 0;
+  On = 1;
+  Delete = 9;
+  All = 99;
+}
+
+message GetShopNaviRequest{
+  int64 shopId = 1;
+  // 最顶层为0
+  int32 parentId = 2;
+}
+
+message Column{
+  string name = 1;
+  string url = 2;
+  string code = 3;
+  // 顺序
+  int32 sn = 4;
+  WebStatus status = 5;
+  bool navShow = 6;
+  int64 id = 7;
+}
+
+message GetShopNaviReply{
+  repeated Column list = 1;
+}
+
+message GetOverlayImgRequest{
+  string fileName = 1;
+}
+
+message QiNiuTokenReply{
+  string token = 1;
 }

+ 64 - 9
repository/grpc/bsw/im/api.go

@@ -2,18 +2,19 @@ package im
 
 import (
 	"context"
+	"sportfitness/base/global"
+	im "sportfitness/base/repository/grpc/bsw/im/im"
+
 	"git.beswell.com/gframe/application"
 	"google.golang.org/grpc/metadata"
-	"sportfitness/base/global"
-	pb "sportfitness/base/repository/grpc/bsw/im/im"
 )
 
-func getClient() pb.ApiClient {
+func getClient() im.ApiClient {
 	conn, err := application.GetServiceGrpcConn("bsw/im")
 	if err != nil {
 		panic(err)
 	}
-	client := pb.NewApiClient(conn)
+	client := im.NewApiClient(conn)
 
 	return client
 }
@@ -23,7 +24,7 @@ func ctx() context.Context {
 	return metadata.NewOutgoingContext(context.Background(), md)
 }
 
-func SignUpUserCode(params *pb.SignUpRequest) (userId int64) {
+func SignUpUserCode(params *im.SignUpRequest) (userId int64) {
 	r, err := getClient().SignUpUserCode(ctx(), params)
 
 	if err != nil {
@@ -34,7 +35,7 @@ func SignUpUserCode(params *pb.SignUpRequest) (userId int64) {
 }
 
 func GenVerifyImage(height, width int32) (id, imageBase64 string) {
-	r, err := getClient().GenVerifyImage(ctx(), &pb.GenVerifyImageRequest{
+	r, err := getClient().GenVerifyImage(ctx(), &im.GenVerifyImageRequest{
 		Height: int32(height),
 		Width:  int32(width),
 	})
@@ -48,7 +49,7 @@ func GenVerifyImage(height, width int32) (id, imageBase64 string) {
 }
 
 func SignInUserCodePassword(userCode, password, ip, ClientInfo, codeId, verifyCode string) (token string, userId int) {
-	r, err := getClient().SignInUserCode(ctx(), &pb.SignInPasswordRequest{
+	r, err := getClient().SignInUserCode(ctx(), &im.SignInPasswordRequest{
 		Credential:    userCode,
 		Password:      password,
 		ExpirationSec: global.TokenExpireSec,
@@ -67,10 +68,10 @@ func SignInUserCodePassword(userCode, password, ip, ClientInfo, codeId, verifyCo
 }
 
 func RegisterServiceList(servicePathList []string) {
-	request := &pb.SaveServiceListRequest{}
+	request := &im.SaveServiceListRequest{}
 
 	for _, p := range servicePathList {
-		request.List = append(request.List, &pb.Service{
+		request.List = append(request.List, &im.Service{
 			Path: p,
 			Memo: "自动添加",
 		})
@@ -81,3 +82,57 @@ func RegisterServiceList(servicePathList []string) {
 		panic(err)
 	}
 }
+
+func SignOut(token string) {
+	request := &im.TokenParam{Token: token}
+
+	_, err := getClient().SubSignOut(ctx(), request)
+	if err != nil {
+		panic(err)
+	}
+}
+
+func SubSessionCheck(token string) int64 {
+	request := &im.TokenParam{Token: token}
+
+	rs, err := getClient().SubSessionCheck(ctx(), request)
+	if err != nil {
+		panic(err)
+	}
+	return rs.UserId
+}
+
+func SubPermissionListCheck(token string, shopId int64, servicePathList []string) *im.PermissionCheckReply {
+
+	rs, err := getClient().SubPermissionListCheck(ctx(), &im.PermissionCheck{
+		Token:           token,
+		ShopId:          shopId,
+		ServicePathList: servicePathList,
+	})
+	if err != nil {
+		panic(err)
+	}
+	return rs
+}
+
+func ShopListRequest(name string, status im.Status, sId int64) *im.ShopListReply {
+
+	request := &im.ShopListRequest{SysId: 1, Name: name, Status: status, SId: sId}
+
+	rs, err := getClient().ShopList(ctx(), request)
+	if err != nil {
+		panic(err)
+	}
+	return rs
+}
+
+func GetShopNavi(userId, shopId int64, parentId int32) *im.UserGetColumnListReply {
+
+	request := &im.UserGetColumnListRequest{UserId: userId, ShopId: shopId, ParentId: parentId}
+
+	rs, err := getClient().UserGetColumnList(ctx(), request)
+	if err != nil {
+		panic(err)
+	}
+	return rs
+}

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