| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456 |
- 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 {
- // 接收不到不会err信息,可做异常处理
- 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
- //}
|