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