| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- 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{}.VipUserShopStatusEdit(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
- }
- // VipUserClassQuery 商家会员课程查询
- func (u User) VipUserClassQuery(token string, objectShopId int64, jsonStr string, sign string) string {
- optId := u.checkPermission(token, objectShopId)
- rst, err := postgre.PGShop{}.VipUserClassQuery(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}
- }
- // AcrossUserSimpleQuery 可跨店会员简单查询
- func (u User) AcrossUserSimpleQuery(token string, objectShopId int64, jsonStr string, sign string) string {
- optId := u.checkPermission(token, objectShopId)
- rst, err := postgre.PGShop{}.AcrossUserSimpleQuery(optId, objectShopId, jsonStr, sign)
- if err != nil {
- panic(errors.PGError)
- }
- return rst
- }
- // VipUserSimpleQuery 会员简单查询
- func (u User) VipUserSimpleQuery(token string, objectShopId int64, jsonStr string, sign string) string {
- optId := u.checkPermission(token, objectShopId)
- rst, err := postgre.PGShop{}.VipUserSimpleQuery(optId, objectShopId, jsonStr, sign)
- if err != nil {
- panic(errors.PGError)
- }
- return rst
- }
- // TempVipUserSimpleQuery 临时会员简单查询
- func (u User) TempVipUserSimpleQuery(token string, objectShopId int64, jsonStr string, sign string) string {
- optId := u.checkPermission(token, objectShopId)
- rst, err := postgre.PGShop{}.TmpVipUserSimpleQuery(optId, objectShopId, jsonStr, sign)
- if err != nil {
- panic(errors.PGError)
- }
- return rst
- }
|