| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455 |
- package grpc
- import (
- "context"
- "encoding/json"
- pb "sportfitness/base/api/grpc/base"
- "sportfitness/base/assembly/base/service"
- "sportfitness/base/errors"
- "sportfitness/base/global"
- "strings"
- "time"
- "google.golang.org/grpc/metadata"
- )
- type Api struct {
- pb.UnimplementedApiServer
- }
- func (Api) getRemoteIp(ctx context.Context) string {
- if md, ok := metadata.FromIncomingContext(ctx); ok {
- ip := md.Get("x-forwarded-for")
- if len(ip) > 0 {
- return ip[0]
- }
- }
- return ""
- }
- func (Api) getUserAgent(ctx context.Context) string {
- if md, ok := metadata.FromIncomingContext(ctx); ok {
- agents := md.Get("user-agent")
- return strings.Join(agents, "\n")
- }
- return ""
- }
- func (Api) getToken(ctx context.Context) (token string) {
- if md, ok := metadata.FromIncomingContext(ctx); ok {
- sl := md.Get("Token")
- if len(sl) >= 1 {
- token = sl[0]
- }
- }
- return
- }
- func (Api) checkRs(rs string) bool {
- b := false
- rsMap := make(map[string]interface{})
- err := json.Unmarshal([]byte(rs), &rsMap)
- if err != nil {
- panic(errors.J2MError)
- }
- code := int(rsMap["code"].(float64))
- if code == 0 {
- b = true
- } else {
- b = false
- }
- return b
- }
- // 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
- }
- // courseToGoVerify 前端入Go验证签名函数,只允许StandardRequest进行验证
- func (a Api) courseToGoVerify(ctx context.Context, q *pb.CourseStandardRequest) (string, *pb.CourseStandardRequest, 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)
- return &pb.SignInReply{Token: token}, nil
- }
- func (a Api) GenVerifyImage(ctx context.Context, q *pb.GenVerifyImageRequest) (*pb.GenVerifyImageReply, error) {
- codeId, imageBase64 := service.User{}.GenVerifyImage(q.Height, q.Width)
- 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() {
- //
- //}
- // ----------------------- 商家信息管理 ---------------------------------------------
- // AcrossUserSimpleQuery 可跨店会员简单查询
- func (a Api) AcrossUserSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.User{}.AcrossUserSimpleQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // VipUserSimpleQuery 会员简单查询
- func (a Api) VipUserSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.User{}.VipUserSimpleQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // TempVipUserSimpleQuery 临时会员简单查询
- func (a Api) TempVipUserSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.User{}.TempVipUserSimpleQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassSimpleQuery 课目简单查询
- func (a Api) ClassSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.ClassSimpleQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SelectHrSensors 心率带简单查询
- func (a Api) SelectHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.SelectHrSensors(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // GroupSimpleQueryByShopID 商家分组简单查询-通过商家自己ID查询
- func (a Api) GroupSimpleQueryByShopID(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Shop{}.GroupSimpleQueryByShopID(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // EqSimpleQuery 商家分组简单查询-通过商家自己ID查询
- func (a Api) EqSimpleQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Shop{}.EqSimpleQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ManageableSimpleQuery 商家管理员简单查询-通过商家自己ID查询
- func (a Api) ManageableSimpleQuery(ctx context.Context, r *pb.ManageableSimpleQueryRequest) (*pb.ManageableSimpleQueryReply, error) {
- token := a.getToken(ctx)
- rs := service.Shop{}.ManageableSimpleQuery(token, r.GetShopId())
- return rs, nil
- }
- // ----------------------- 商家信息管理 ---------------------------------------------
- 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
- }
- 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,并验证签名函数
- 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
- }
- // GetShopNaviAll 查询商家全部栏目
- func (a Api) GetShopNaviAll(ctx context.Context, r *pb.GetShopNaviAllRequest) (*pb.GetShopNaviAllReply, error) {
- token := a.getToken(ctx)
- rs := service.Shop{}.GetShopNaviAll(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
- }
- // ShopVenueEquipAdd 商家设备添加
- func (a Api) ShopVenueEquipAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Shop{}.ShopVenueEquipAdd(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
- }
- // VipOtherPhoneStatusEdit 商家会员其他手机号状态修改
- func (a Api) VipOtherPhoneStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.User{}.VipOtherPhoneStatusEdit(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{}.VipHourEdit(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
- }
- // VipUserClassQuery 商家会员课程查询
- func (a Api) VipUserClassQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.User{}.VipUserClassQuery(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
- }
- // SttPlanBasicQuery 商家课程表模板总览查询
- func (a Api) SttPlanBasicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanBasicQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanBasicAdd 商家课程表模板总览添加
- func (a Api) SttPlanBasicAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanBasicAdd(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanBasicEdit 商家课程表模板总览编辑
- func (a Api) SttPlanBasicEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanBasicEdit(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanBasicShopEdit 商家课程表模板总览所属商家修改
- func (a Api) SttPlanBasicShopEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanBasicShopEdit(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanBasicStatusEdit 商家课程表模板状态
- func (a Api) SttPlanBasicStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanBasicStatusEdit(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanBasicPublish 商家课程表模板发布
- func (a Api) SttPlanBasicPublish(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanBasicPublish(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanPreview 商家课程表模板详情预览
- func (a Api) SttPlanPreview(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanPreview(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanCopy 商家课程表模板复制
- func (a Api) SttPlanCopy(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanCopy(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanDetailQuery 商家课程表模板详情查询
- func (a Api) SttPlanDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanDetailQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // SttPlanDetailBatchSave 商家课程表模板详情批量保存
- func (a Api) SttPlanDetailBatchSave(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.SttPlanDetailBatchSave(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicQuery 商家课程表总览查询
- func (a Api) STTBasicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicAdd 商家课程表总览添加
- func (a Api) STTBasicAdd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicAdd(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicEdit 商家课程表总览编辑
- func (a Api) STTBasicEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicEdit(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicStatusEdit 商家课程表总览状态修改
- func (a Api) STTBasicStatusEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicStatusEdit(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicPreview 商家课程表详情预览
- func (a Api) STTBasicPreview(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicPreview(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicCopy 商家课程表模板复制
- func (a Api) STTBasicCopy(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicCopy(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicOfflineEdit 商家课程表上下线状态修改
- func (a Api) STTBasicOfflineEdit(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicOfflineEdit(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTDetailListQuery 商家课程表详情列表查询
- func (a Api) STTDetailListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTDetailListQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTBasicDetailBatchSave 商家课程表详情批量保存
- func (a Api) STTBasicDetailBatchSave(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTBasicDetailBatchSave(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // STTDetailAllowDelCheck 商家课程表详情判断是否可删除
- func (a Api) STTDetailAllowDelCheck(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Class{}.STTDetailAllowDelCheck(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ----------------------- 商家上下课管理 ---------------------------------------------
- // CourseDetailQuery 课程管理查询
- func (a Api) CourseDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Course{}.CourseDetailQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassListByOrderDate 某日课程表查询
- func (a Api) ClassListByOrderDate(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Course{}.ClassListByOrderDate(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassStartPrepare 上课准备
- func (a Api) ClassStartPrepare(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.ClassStartPrepare(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassStartPrepare(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassStartPrepareEdit 上课准备修改
- func (a Api) ClassStartPrepareEdit(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.ClassStartPrepareEdit(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.ClassStartPrepareEdit(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // VipClassDetailQuery 会员上课详情查询
- func (a Api) VipClassDetailQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Course{}.VipClassDetailQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // VipClassDetailAdd 会员上课详情添加-上课未预约
- func (a Api) VipClassDetailAdd(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.VipClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // VipClassDetailDel 会员上课详情删除
- func (a Api) VipClassDetailDel(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- // 删除应该是先删除心率跟评分库,再去删除基础库数据
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassDetailDel(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rs := service.Course{}.VipClassDetailDel(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // TmpClassDetailAdd 临时会员上课详情添加
- func (a Api) TmpClassDetailAdd(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.TmpClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.TmpClassDetailAdd(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // TmpClassDetailDel 临时会员上课详情删除
- func (a Api) TmpClassDetailDel(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- // 删除应该是先删除心率跟评分库,再去删除基础库数据
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassDetailDel(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rs := service.Course{}.TmpClassDetailDel(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // VipClassDetailStatueEdit 会员上课详情状态修改
- func (a Api) VipClassDetailStatueEdit(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.VipClassDetailStatueEdit(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassDetailStatusEdit(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassStartConfirm 确认上课
- func (a Api) ClassStartConfirm(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.ClassStartConfirm(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassStartConfirm(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- // 心率库修改成功后,调用接口获取上课需要的心率带sn,显示单元eqSn信息,生成Redis
- redisRs := service.HrRedis{}.ClassStartR1AndOnClassByUUStdID(token, q.ShopID, q.UUStdID)
- if !a.checkRs(redisRs) {
- rst := a.toWebFunc(redisRs)
- return rst, nil
- }
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassOverConfirm 确认下课
- func (a Api) ClassOverConfirm(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Course{}.ClassOverConfirm(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassGiveUpConfirm 关闭课程
- func (a Api) ClassGiveUpConfirm(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- rs := service.Course{}.ClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- if q.IsHr == 1 {
- hrRs := service.Hr{}.HrClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(hrRs) {
- rst := a.toWebFunc(hrRs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // AfterClassAddClassDetail 关闭课程
- func (a Api) AfterClassAddClassDetail(ctx context.Context, r *pb.CourseStandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.courseToGoVerify(ctx, r)
- var rs string
- // 因为是上课后追加的人,已经在基础库中添加,所以只需要在心率与评分中加入
- //rs := service.Course{}.ClassGiveUpConfirm(token, q.ShopID, q.JsonStr, sign)
- if q.IsHr == 1 {
- rs = service.Hr{}.AfterClassAddClassDetail(token, q.ShopID, q.JsonStr, sign)
- if !a.checkRs(rs) {
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- }
- if q.IsScore == 1 {
- // todo 调用评分系统接口
- }
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ----------------------- 商家预约管理 ---------------------------------------------
- // OrderListQuery 预约记录查询
- func (a Api) OrderListQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.OrderListQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // OrderAddByManager 管理员预约添加
- func (a Api) OrderAddByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.OrderAddByManager(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // OrderCancelByManager 管理员预约取消
- func (a Api) OrderCancelByManager(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.OrderCancelByManager(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // OrderStatistics 商家预约统计
- func (a Api) OrderStatistics(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.OrderStatistics(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ClassOrderQuery 可预约课程预约列表查询
- func (a Api) ClassOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.ClassOrderQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // VipUserOrderQuery 会员预约列表查询
- func (a Api) VipUserOrderQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.VipUserOrderQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // UserOrderQueryByStd 查询课程预约用户列表
- func (a Api) UserOrderQueryByStd(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Order{}.UserOrderQueryByStd(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ----------------------- 商家心率管理 ---------------------------------------------
- // HrSensorsPublicQuery 公共心率带查询
- func (a Api) HrSensorsPublicQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.HrSensorsPublicQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // HrSensorsPvtQuery 私有心率带查询
- func (a Api) HrSensorsPvtQuery(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.HrSensorsPvtQuery(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // AddHrSensors 公共心率带添加
- func (a Api) AddHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.AddHrSensors(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // AddPvtHrSensors 私有心率带添加
- func (a Api) AddPvtHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.AddPvtHrSensors(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // EditHrSensors 心率带编辑
- func (a Api) EditHrSensors(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.EditHrSensors(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // HrSensorsDel 心率带删除
- func (a Api) HrSensorsDel(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.HrSensorsDel(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // PKGroupChg 修改PK分队
- func (a Api) PKGroupChg(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.PKGroupChg(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // BindHrSensor 绑定心率带
- func (a Api) BindHrSensor(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.BindHrSensor(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // UnBindHrSensor 解绑心率带
- func (a Api) UnBindHrSensor(ctx context.Context, r *pb.StandardRequest) (*pb.StandardReply, error) {
- // 获取token,并验证签名函数
- token, q, sign := a.webToGoVerify(ctx, r)
- rs := service.Hr{}.UnBindHrSensor(token, q.ShopID, q.JsonStr, sign)
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // ----------------------- 评分管理 ---------------------------------------------
- // ----------------------- 微信管理 ---------------------------------------------
- // GenVerifyImageByWinXin 微信登陆获取图片验证码
- func (Api) GenVerifyImageByWinXin(ctx context.Context, r *pb.GenVerifyImageRequest) (*pb.GenVerifyImageReply, error) {
- //height := int(r.Height)
- //width := int(r.Width)
- id, pic := service.VerifyCode{}.GenImage(int(r.Height), int(r.Width))
- return &pb.GenVerifyImageReply{
- CodeId: id,
- ImageBase64: pic,
- }, nil
- }
- // GenPhoneVerifyCodeByWeiXin 微信登陆获取短信验证码
- func (a Api) GenPhoneVerifyCodeByWeiXin(ctx context.Context, r *pb.GenPhoneVerifyCodeRequestWX) (*pb.StandardReply, error) {
- ip := a.getRemoteIp(ctx)
- rs := service.VerifyCode{}.GetPhoneVFCode(
- r.SId,
- r.Account, ip, global.TemplateCode, r.CodeId, r.ImgCode, r.VerifyType, time.Duration(global.SmsExpireNano))
- rst := a.toWebFunc(rs)
- return rst, nil
- }
- // UserListenMsg Grpc-Web总线机制
- func (Api) UserListenMsg(_ *pb.DefaultRequest, stream pb.Api_UserListenMsgServer) (err error) {
- // TODO 验证并获取 userId
- userId := 0
- channel := service.MsgBus{}.AddListener(userId)
- defer func() {
- service.MsgBus{}.RemoveListener(userId)
- }()
- for {
- select {
- case msg := <-channel:
- {
- pbMsg := &pb.Msg{
- UserIdSend: int64(msg.UserIdSend),
- Title: msg.Title,
- Content: msg.Content,
- }
- err = stream.Send(pbMsg)
- if err != nil {
- return
- }
- }
- case <-stream.Context().Done():
- {
- return
- }
- }
- }
- }
- //// WeiXinSignIn 微信登陆
- //func (a Api) WeiXinSignIn(ctx context.Context, r *pb.WeiXinSignInRequest) (*pb.SignInReply, error) {
- //
- //
- // rs := service.Wx{}.WeiXinSignIn(token, q.ShopID, q.JsonStr, sign)
- //
- // return &pb.SignInReply{Token: rs}, nil
- //}
|