增加 8圈自动登录
This commit is contained in:
@ -16,4 +16,5 @@ type IAuthV1 interface {
|
||||
MerchantCode(ctx context.Context, req *v1.MerchantCodeReq) (res *v1.MerchantCodeRes, err error)
|
||||
MerchantRegister(ctx context.Context, req *v1.MerchantRegisterReq) (res *v1.MerchantRegisterRes, err error)
|
||||
StoreLogin(ctx context.Context, req *v1.StoreLoginReq) (res *v1.StoreLoginRes, err error)
|
||||
Quan8Autologin(ctx context.Context, req *v1.Quan8AutologinReq) (res *v1.Quan8AutologinRes, err error)
|
||||
}
|
||||
|
||||
@ -58,3 +58,12 @@ type StoreLoginRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type Quan8AutologinReq struct {
|
||||
g.Meta `path:"/quan8/autologin" method:"post" tags:"PC/Auth" summary:"8圈用户自动登录该系统"`
|
||||
UUID string `json:"uuid" v:"required#UUID不能为空" dc:"UUID"`
|
||||
StoreId int64
|
||||
}
|
||||
type Quan8AutologinRes struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
@ -45,7 +45,8 @@ type WeChatPollingRes struct {
|
||||
|
||||
type GetWechatSceneIdReq struct {
|
||||
g.Meta `path:"/wechat/sceneId" method:"get" tags:"PC/WeChat" summary:"(PC)获取微信场景ID"`
|
||||
NetbarAccount string `json:"netbarAccount" v:"required" dc:"网关账号"`
|
||||
StoreId int `json:"storeId" v:"required#门店 id 账号不能为空" dc:"门店ID"`
|
||||
UUID string `json:"uuid" dc:"8圈唯一 id"`
|
||||
}
|
||||
|
||||
type GetWechatSceneIdRes struct {
|
||||
|
||||
21
internal/controller/auth/auth_v1_quan_8_autologin.go
Normal file
21
internal/controller/auth/auth_v1_quan_8_autologin.go
Normal file
@ -0,0 +1,21 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
|
||||
"server/api/auth/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) Quan8Autologin(ctx context.Context, req *v1.Quan8AutologinReq) (res *v1.Quan8AutologinRes, err error) {
|
||||
out, err := service.User().Quan8Autologin(ctx, &model.Quan8AutologinIn{
|
||||
UUID: req.UUID,
|
||||
StoreId: req.StoreId,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return &v1.Quan8AutologinRes{Token: out.Token}, nil
|
||||
|
||||
}
|
||||
@ -2,11 +2,18 @@ package wx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"server/api/wx/v1"
|
||||
"time"
|
||||
"server/internal/model"
|
||||
"server/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) GetWechatSceneId(ctx context.Context, req *v1.GetWechatSceneIdReq) (res *v1.GetWechatSceneIdRes, err error) {
|
||||
return &v1.GetWechatSceneIdRes{SceneId: fmt.Sprintf("%s_%d", req.NetbarAccount, time.Now().Unix())}, nil
|
||||
out, err := service.User().GenerateSceneId(ctx, &model.GenerateSceneIdIn{
|
||||
StoreId: req.StoreId,
|
||||
UUId: req.UUID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.GetWechatSceneIdRes{SceneId: out.SceneId}, nil
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@ type AdminsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// AdminsColumns defines and stores column names for the table admins.
|
||||
@ -50,12 +49,11 @@ var adminsColumns = AdminsColumns{
|
||||
}
|
||||
|
||||
// NewAdminsDao creates and returns a new DAO object for table data access.
|
||||
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
|
||||
func NewAdminsDao() *AdminsDao {
|
||||
return &AdminsDao{
|
||||
group: "default",
|
||||
table: "admins",
|
||||
columns: adminsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +79,7 @@ func (dao *AdminsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type FeedbacksDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// FeedbacksColumns defines and stores column names for the table feedbacks.
|
||||
@ -52,12 +51,11 @@ var feedbacksColumns = FeedbacksColumns{
|
||||
}
|
||||
|
||||
// NewFeedbacksDao creates and returns a new DAO object for table data access.
|
||||
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
|
||||
func NewFeedbacksDao() *FeedbacksDao {
|
||||
return &FeedbacksDao{
|
||||
group: "default",
|
||||
table: "feedbacks",
|
||||
columns: feedbacksColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,11 +81,7 @@ func (dao *FeedbacksDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type GamesDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns GamesColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// GamesColumns defines and stores column names for the table games.
|
||||
@ -46,12 +45,11 @@ var gamesColumns = GamesColumns{
|
||||
}
|
||||
|
||||
// NewGamesDao creates and returns a new DAO object for table data access.
|
||||
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
|
||||
func NewGamesDao() *GamesDao {
|
||||
return &GamesDao{
|
||||
group: "default",
|
||||
table: "games",
|
||||
columns: gamesColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,11 +75,7 @@ func (dao *GamesDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type MerchantAdminsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
|
||||
@ -58,12 +57,11 @@ var merchantAdminsColumns = MerchantAdminsColumns{
|
||||
}
|
||||
|
||||
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
|
||||
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
|
||||
func NewMerchantAdminsDao() *MerchantAdminsDao {
|
||||
return &MerchantAdminsDao{
|
||||
group: "default",
|
||||
table: "merchant_admins",
|
||||
columns: merchantAdminsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,11 +87,7 @@ func (dao *MerchantAdminsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type MerchantsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// MerchantsColumns defines and stores column names for the table merchants.
|
||||
@ -72,12 +71,11 @@ var merchantsColumns = MerchantsColumns{
|
||||
}
|
||||
|
||||
// NewMerchantsDao creates and returns a new DAO object for table data access.
|
||||
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
|
||||
func NewMerchantsDao() *MerchantsDao {
|
||||
return &MerchantsDao{
|
||||
group: "default",
|
||||
table: "merchants",
|
||||
columns: merchantsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,11 +101,7 @@ func (dao *MerchantsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type NoticesDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns NoticesColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// NoticesColumns defines and stores column names for the table notices.
|
||||
@ -50,12 +49,11 @@ var noticesColumns = NoticesColumns{
|
||||
}
|
||||
|
||||
// NewNoticesDao creates and returns a new DAO object for table data access.
|
||||
func NewNoticesDao(handlers ...gdb.ModelHandler) *NoticesDao {
|
||||
func NewNoticesDao() *NoticesDao {
|
||||
return &NoticesDao{
|
||||
group: "default",
|
||||
table: "notices",
|
||||
columns: noticesColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +79,7 @@ func (dao *NoticesDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *NoticesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type RewardCallbackDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns RewardCallbackColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// RewardCallbackColumns defines and stores column names for the table reward_callback.
|
||||
@ -50,12 +49,11 @@ var rewardCallbackColumns = RewardCallbackColumns{
|
||||
}
|
||||
|
||||
// NewRewardCallbackDao creates and returns a new DAO object for table data access.
|
||||
func NewRewardCallbackDao(handlers ...gdb.ModelHandler) *RewardCallbackDao {
|
||||
func NewRewardCallbackDao() *RewardCallbackDao {
|
||||
return &RewardCallbackDao{
|
||||
group: "default",
|
||||
table: "reward_callback",
|
||||
columns: rewardCallbackColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +79,7 @@ func (dao *RewardCallbackDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *RewardCallbackDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type RewardTypesDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// RewardTypesColumns defines and stores column names for the table reward_types.
|
||||
@ -46,12 +45,11 @@ var rewardTypesColumns = RewardTypesColumns{
|
||||
}
|
||||
|
||||
// NewRewardTypesDao creates and returns a new DAO object for table data access.
|
||||
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
|
||||
func NewRewardTypesDao() *RewardTypesDao {
|
||||
return &RewardTypesDao{
|
||||
group: "default",
|
||||
table: "reward_types",
|
||||
columns: rewardTypesColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,11 +75,7 @@ func (dao *RewardTypesDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type RewardWatersDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns RewardWatersColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// RewardWatersColumns defines and stores column names for the table reward_waters.
|
||||
@ -48,12 +47,11 @@ var rewardWatersColumns = RewardWatersColumns{
|
||||
}
|
||||
|
||||
// NewRewardWatersDao creates and returns a new DAO object for table data access.
|
||||
func NewRewardWatersDao(handlers ...gdb.ModelHandler) *RewardWatersDao {
|
||||
func NewRewardWatersDao() *RewardWatersDao {
|
||||
return &RewardWatersDao{
|
||||
group: "default",
|
||||
table: "reward_waters",
|
||||
columns: rewardWatersColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,11 +77,7 @@ func (dao *RewardWatersDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *RewardWatersDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type RewardsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// RewardsColumns defines and stores column names for the table rewards.
|
||||
@ -76,12 +75,11 @@ var rewardsColumns = RewardsColumns{
|
||||
}
|
||||
|
||||
// NewRewardsDao creates and returns a new DAO object for table data access.
|
||||
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
|
||||
func NewRewardsDao() *RewardsDao {
|
||||
return &RewardsDao{
|
||||
group: "default",
|
||||
table: "rewards",
|
||||
columns: rewardsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,11 +105,7 @@ func (dao *RewardsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type RolesDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns RolesColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// RolesColumns defines and stores column names for the table roles.
|
||||
@ -48,12 +47,11 @@ var rolesColumns = RolesColumns{
|
||||
}
|
||||
|
||||
// NewRolesDao creates and returns a new DAO object for table data access.
|
||||
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
|
||||
func NewRolesDao() *RolesDao {
|
||||
return &RolesDao{
|
||||
group: "default",
|
||||
table: "roles",
|
||||
columns: rolesColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,11 +77,7 @@ func (dao *RolesDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type StoreAdminsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// StoreAdminsColumns defines and stores column names for the table store_admins.
|
||||
@ -58,12 +57,11 @@ var storeAdminsColumns = StoreAdminsColumns{
|
||||
}
|
||||
|
||||
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
|
||||
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
|
||||
func NewStoreAdminsDao() *StoreAdminsDao {
|
||||
return &StoreAdminsDao{
|
||||
group: "default",
|
||||
table: "store_admins",
|
||||
columns: storeAdminsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,11 +87,7 @@ func (dao *StoreAdminsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type StoreDesktopSettingsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
|
||||
@ -34,12 +33,11 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{
|
||||
}
|
||||
|
||||
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
|
||||
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
|
||||
func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao {
|
||||
return &StoreDesktopSettingsDao{
|
||||
group: "default",
|
||||
table: "store_desktop_settings",
|
||||
columns: storeDesktopSettingsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,11 +63,7 @@ func (dao *StoreDesktopSettingsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type StoreIpsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoreIpsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// StoreIpsColumns defines and stores column names for the table store_ips.
|
||||
@ -42,12 +41,11 @@ var storeIpsColumns = StoreIpsColumns{
|
||||
}
|
||||
|
||||
// NewStoreIpsDao creates and returns a new DAO object for table data access.
|
||||
func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao {
|
||||
func NewStoreIpsDao() *StoreIpsDao {
|
||||
return &StoreIpsDao{
|
||||
group: "default",
|
||||
table: "store_ips",
|
||||
columns: storeIpsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,11 +71,7 @@ func (dao *StoreIpsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type StoreNetfeeAreaLevelDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level.
|
||||
@ -50,12 +49,11 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{
|
||||
}
|
||||
|
||||
// NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access.
|
||||
func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao {
|
||||
func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao {
|
||||
return &StoreNetfeeAreaLevelDao{
|
||||
group: "default",
|
||||
table: "store_netfee_area_level",
|
||||
columns: storeNetfeeAreaLevelColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +79,7 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type StoreRolesDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// StoreRolesColumns defines and stores column names for the table store_roles.
|
||||
@ -40,12 +39,11 @@ var storeRolesColumns = StoreRolesColumns{
|
||||
}
|
||||
|
||||
// NewStoreRolesDao creates and returns a new DAO object for table data access.
|
||||
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
|
||||
func NewStoreRolesDao() *StoreRolesDao {
|
||||
return &StoreRolesDao{
|
||||
group: "default",
|
||||
table: "store_roles",
|
||||
columns: storeRolesColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,11 +69,7 @@ func (dao *StoreRolesDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type StoresDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns StoresColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// StoresColumns defines and stores column names for the table stores.
|
||||
@ -52,12 +51,11 @@ var storesColumns = StoresColumns{
|
||||
}
|
||||
|
||||
// NewStoresDao creates and returns a new DAO object for table data access.
|
||||
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
|
||||
func NewStoresDao() *StoresDao {
|
||||
return &StoresDao{
|
||||
group: "default",
|
||||
table: "stores",
|
||||
columns: storesColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,11 +81,7 @@ func (dao *StoresDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type TaskRewardsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// TaskRewardsColumns defines and stores column names for the table task_rewards.
|
||||
@ -36,12 +35,11 @@ var taskRewardsColumns = TaskRewardsColumns{
|
||||
}
|
||||
|
||||
// NewTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||
func NewTaskRewardsDao(handlers ...gdb.ModelHandler) *TaskRewardsDao {
|
||||
func NewTaskRewardsDao() *TaskRewardsDao {
|
||||
return &TaskRewardsDao{
|
||||
group: "default",
|
||||
table: "task_rewards",
|
||||
columns: taskRewardsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,11 +65,7 @@ func (dao *TaskRewardsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *TaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type TasksDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns TasksColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// TasksColumns defines and stores column names for the table tasks.
|
||||
@ -46,12 +45,11 @@ var tasksColumns = TasksColumns{
|
||||
}
|
||||
|
||||
// NewTasksDao creates and returns a new DAO object for table data access.
|
||||
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
|
||||
func NewTasksDao() *TasksDao {
|
||||
return &TasksDao{
|
||||
group: "default",
|
||||
table: "tasks",
|
||||
columns: tasksColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,11 +75,7 @@ func (dao *TasksDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type UserTaskRewardsDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns UserTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// UserTaskRewardsColumns defines and stores column names for the table user_task_rewards.
|
||||
@ -58,12 +57,11 @@ var userTaskRewardsColumns = UserTaskRewardsColumns{
|
||||
}
|
||||
|
||||
// NewUserTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||
func NewUserTaskRewardsDao(handlers ...gdb.ModelHandler) *UserTaskRewardsDao {
|
||||
func NewUserTaskRewardsDao() *UserTaskRewardsDao {
|
||||
return &UserTaskRewardsDao{
|
||||
group: "default",
|
||||
table: "user_task_rewards",
|
||||
columns: userTaskRewardsColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,11 +87,7 @@ func (dao *UserTaskRewardsDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *UserTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type UserTasksDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// UserTasksColumns defines and stores column names for the table user_tasks.
|
||||
@ -54,12 +53,11 @@ var userTasksColumns = UserTasksColumns{
|
||||
}
|
||||
|
||||
// NewUserTasksDao creates and returns a new DAO object for table data access.
|
||||
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
|
||||
func NewUserTasksDao() *UserTasksDao {
|
||||
return &UserTasksDao{
|
||||
group: "default",
|
||||
table: "user_tasks",
|
||||
columns: userTasksColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,11 +83,7 @@ func (dao *UserTasksDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -16,7 +16,6 @@ type UsersDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns UsersColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// UsersColumns defines and stores column names for the table users.
|
||||
@ -37,6 +36,7 @@ type UsersColumns struct {
|
||||
DeletedAt string // 软删除时间
|
||||
RoleId string // 角色ID
|
||||
LastLoginStoreId string // 上次登录门店ID
|
||||
Quan8Uuid string // 8圈使用的 uuid
|
||||
}
|
||||
|
||||
// usersColumns holds the columns for the table users.
|
||||
@ -57,15 +57,15 @@ var usersColumns = UsersColumns{
|
||||
DeletedAt: "deleted_at",
|
||||
RoleId: "role_id",
|
||||
LastLoginStoreId: "last_login_store_id",
|
||||
Quan8Uuid: "quan8_uuid",
|
||||
}
|
||||
|
||||
// NewUsersDao creates and returns a new DAO object for table data access.
|
||||
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
|
||||
func NewUsersDao() *UsersDao {
|
||||
return &UsersDao{
|
||||
group: "default",
|
||||
table: "users",
|
||||
columns: usersColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,11 +91,7 @@ func (dao *UsersDao) Group() string {
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
model := dao.DB().Model(dao.table)
|
||||
for _, handler := range dao.handlers {
|
||||
model = handler(model)
|
||||
}
|
||||
return model.Safe().Ctx(ctx)
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
|
||||
@ -353,3 +353,111 @@ func (s *sUser) GamelifePackUrl(ctx context.Context, in *model.GamelifePackUrlIn
|
||||
Url: url,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) Quan8Autologin(ctx context.Context, in *model.Quan8AutologinIn) (out *model.Quan8AutologinOut, err error) {
|
||||
b, err := dao.Stores.Ctx(ctx).WherePri(in.StoreId).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查找门店失败")
|
||||
}
|
||||
if !b {
|
||||
return nil, ecode.Params.Sub("门店 id 错误")
|
||||
}
|
||||
// Fetch default role
|
||||
value, err := dao.Roles.Ctx(ctx).Where(do.Roles{Code: consts.UserRoleCode}).Fields(dao.Roles.Columns().Code, dao.Roles.Columns().Id).One()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查找角色失败")
|
||||
}
|
||||
|
||||
// Check if user exists by Quan8 UUID
|
||||
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Quan8Uuid: in.UUID}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查找用户失败")
|
||||
}
|
||||
|
||||
var userId int64
|
||||
if !exist {
|
||||
// User doesn't exist, create new user
|
||||
var username string
|
||||
for {
|
||||
randomStr := grand.Str("abcdefghijklmnopqrstuvwxyz0123456789", 8)
|
||||
username = "qy_" + randomStr
|
||||
count, err := dao.Users.Ctx(ctx).Where(do.Users{Username: username}).Count()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("检查用户名失败")
|
||||
}
|
||||
if count == 0 {
|
||||
break // username is unique
|
||||
}
|
||||
}
|
||||
|
||||
password, err := encrypt.EncryptPassword(consts.DefaultPassword)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("加密密码失败")
|
||||
}
|
||||
|
||||
user := &entity.Users{
|
||||
Quan8Uuid: in.UUID,
|
||||
Username: username,
|
||||
Nickname: username,
|
||||
PasswordHash: password,
|
||||
Avatar: consts.DefaultUserAvatar,
|
||||
FirstVisitAt: gtime.Now(),
|
||||
LastLoginAt: gtime.Now(),
|
||||
WxPopenId: utility.GenerateUserID("WX"),
|
||||
QqPopenId: utility.GenerateUserID("QQ"),
|
||||
RoleId: value[dao.Roles.Columns().Id].Int64(),
|
||||
LastLoginStoreId: in.StoreId,
|
||||
}
|
||||
|
||||
userId, err = dao.Users.Ctx(ctx).InsertAndGetId(user)
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("创建用户失败")
|
||||
}
|
||||
} else {
|
||||
value, err := dao.Users.Ctx(ctx).Where(do.Users{Quan8Uuid: in.UUID}).Fields(dao.Users.Columns().Id).Value()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查找用户失败")
|
||||
}
|
||||
userId = value.Int64()
|
||||
|
||||
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{LastLoginAt: gtime.Now(), LastLoginStoreId: in.StoreId}); err != nil {
|
||||
return nil, ecode.Fail.Sub("更新登录时间失败")
|
||||
}
|
||||
}
|
||||
// Generate token
|
||||
token, err := jwt.GenerateToken(&jwt.TokenIn{
|
||||
UserId: userId,
|
||||
Role: value[dao.Roles.Columns().Code].String(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("生成token失败")
|
||||
}
|
||||
return &model.Quan8AutologinOut{
|
||||
Token: token,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *sUser) GenerateSceneId(ctx context.Context, in *model.GenerateSceneIdIn) (out *model.GenerateSceneIdOut, err error) {
|
||||
var sceneId string
|
||||
|
||||
// Check if user exists by UUID if provided
|
||||
if in.UUId != "" {
|
||||
exist, err := dao.Users.Ctx(ctx).Where(do.Users{Quan8Uuid: in.UUId}).Exist()
|
||||
if err != nil {
|
||||
return nil, ecode.Fail.Sub("查找用户失败")
|
||||
}
|
||||
if !exist {
|
||||
return nil, ecode.Params.Sub("用户不存在")
|
||||
}
|
||||
// UUID is provided and user exists, use "is" flag
|
||||
sceneId = fmt.Sprintf("%d_1_%s", in.StoreId, in.UUId)
|
||||
} else {
|
||||
// UUID is empty, use "not" flag with random string
|
||||
randomStr := grand.Str("abcdefghijklmnopqrstuvwxyz0123456789", 8)
|
||||
sceneId = fmt.Sprintf("%d_0_%s", in.StoreId, randomStr)
|
||||
}
|
||||
|
||||
return &model.GenerateSceneIdOut{
|
||||
SceneId: sceneId,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -28,4 +28,5 @@ type Users struct {
|
||||
DeletedAt *gtime.Time // 软删除时间
|
||||
RoleId interface{} // 角色ID
|
||||
LastLoginStoreId interface{} // 上次登录门店ID
|
||||
Quan8Uuid interface{} // 8圈使用的 uuid
|
||||
}
|
||||
|
||||
@ -26,4 +26,5 @@ type Users struct {
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
|
||||
LastLoginStoreId int64 `json:"lastLoginStoreId" orm:"last_login_store_id" description:"上次登录门店ID"` // 上次登录门店ID
|
||||
Quan8Uuid string `json:"quan8Uuid" orm:"quan8_uuid" description:"8圈使用的 uuid"` // 8圈使用的 uuid
|
||||
}
|
||||
|
||||
@ -204,3 +204,21 @@ type GamelifePackUrlIn struct {
|
||||
type GamelifePackUrlOut struct {
|
||||
Url string
|
||||
}
|
||||
type Quan8AutologinIn struct {
|
||||
UUID string
|
||||
NetbarAccount string
|
||||
StoreId int64
|
||||
}
|
||||
|
||||
type Quan8AutologinOut struct {
|
||||
Token string
|
||||
}
|
||||
|
||||
type GenerateSceneIdIn struct {
|
||||
StoreId int
|
||||
UUId string
|
||||
}
|
||||
|
||||
type GenerateSceneIdOut struct {
|
||||
SceneId string
|
||||
}
|
||||
|
||||
@ -21,6 +21,151 @@ type (
|
||||
// List 奖励列表
|
||||
List(ctx context.Context, in *model.RewardListIn) (out *model.RewardListOut, err error)
|
||||
// GetLift 领取奖励
|
||||
// func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) {
|
||||
//
|
||||
// giftParam := model.GiftParam{}
|
||||
// var needUrl bool
|
||||
// // 判断奖励类型
|
||||
// if in.Source == 1 {
|
||||
// // 系统奖励处理
|
||||
// if in.RewradTypeId == 16 {
|
||||
// // 需要大区角色
|
||||
// giftParam.AreaId = in.AreaId
|
||||
// giftParam.Gid = in.GameId
|
||||
// giftParam.RoleIdx = in.RoleIdx
|
||||
// giftParam.TaskId = in.TaskId
|
||||
// } else {
|
||||
// // 不需要
|
||||
// giftParam.TaskId = in.TaskId
|
||||
// giftParam.Gid = in.GameId
|
||||
//
|
||||
// }
|
||||
// if in.RewardId != 16 && in.RewardId != 37 {
|
||||
// needUrl = true
|
||||
// }
|
||||
// } else {
|
||||
// // 门店奖励处理
|
||||
//
|
||||
// }
|
||||
//
|
||||
// glog.Info(ctx, "调用 tencent开始")
|
||||
// activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam})
|
||||
//
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// glog.Info(ctx, "调用 tencent结束")
|
||||
// fmt.Print(activity)
|
||||
//
|
||||
// result, ok := activity.(*model.GiftResponse)
|
||||
// if !ok {
|
||||
// return nil, ecode.Fail.Sub("数据类型转换失败")
|
||||
// }
|
||||
//
|
||||
// if len(result.GiftItem) == 0 {
|
||||
// return nil, ecode.Fail.Sub("奖励领取异常")
|
||||
// }
|
||||
//
|
||||
// // 存储数据库记录
|
||||
// var data model.GetRewardOut
|
||||
// if err = dao.RewardWaters.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
||||
// for _, item := range result.GiftItem {
|
||||
// marshal, err := json.Marshal(item.Water)
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("序列化 json 数据出现异常")
|
||||
// }
|
||||
// _, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{
|
||||
// OrderId: item.Water.OrderId,
|
||||
// Status: int64(item.Result),
|
||||
// Uid: item.Water.Uid,
|
||||
// Water: string(marshal),
|
||||
// TaskId: in.TaskId,
|
||||
// GameId: int64(in.GameId),
|
||||
// })
|
||||
//
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("添加奖励领取记录异常")
|
||||
// }
|
||||
//
|
||||
// // 根据 result判断
|
||||
// data.Result = int64(item.Result)
|
||||
// if item.Result == 1 {
|
||||
// //// 奖励发放成功,修改状态,扣除数量
|
||||
// glog.Infof(ctx, "奖励发放成功1,修改状态,扣除数量")
|
||||
// // 查询当前奖励是否为最后一个, 如果是则更新任务状态为2 完成
|
||||
// count, err := dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId}).WhereIn(dao.UserTaskRewards.Columns().Status, []int{2, 3, 5}).Count()
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("查询用户任务奖励失败")
|
||||
// }
|
||||
//
|
||||
// if count == 1 {
|
||||
// // 修改任务记录状态2
|
||||
// _, err = dao.UserTasks.Ctx(ctx).Where(do.UserTasks{Id: in.UserTaskId}).Data(do.UserTasks{
|
||||
// Status: 2,
|
||||
// }).Update()
|
||||
//
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("修改用户任务状态失败")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 增加奖励已领取数量
|
||||
// _, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Increment(dao.Rewards.Columns().ReceivedNum, 1)
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("获取奖励领取记录异常")
|
||||
// }
|
||||
//
|
||||
// // 修改用户任务奖励记录状态
|
||||
// _, err = dao.UserTaskRewards.Ctx(ctx).Where(do.UserTaskRewards{UserTaskId: in.UserTaskId, RewardId: in.RewardId}).Data(do.UserTaskRewards{
|
||||
// Status: consts.RewardSuccessStatus,
|
||||
// }).Update()
|
||||
//
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
||||
// }
|
||||
// } else if item.Result == 2 || item.Result == 3 {
|
||||
// // 发放背包成功,修改状态
|
||||
// glog.Infof(ctx, "奖励发放成功2,修改状态")
|
||||
// _, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{
|
||||
// Status: consts.RewardExchangeStatus,
|
||||
// }).Where(do.UserTaskRewards{
|
||||
// Id: in.UserTaskId,
|
||||
// RewardId: in.RewardId,
|
||||
// }).Update()
|
||||
//
|
||||
// if err != nil {
|
||||
// return ecode.Fail.Sub("修改用户任务奖励记录状态异常")
|
||||
// }
|
||||
// } else if item.Result == 4 {
|
||||
// // 奖励领取失败,不做操作,直接返回
|
||||
// glog.Infof(ctx, "领取奖励失败")
|
||||
// return ecode.Fail.Sub("领取奖励失败")
|
||||
// }
|
||||
//
|
||||
// //data.List = append(data.List, model.GetRewardNewOut{
|
||||
// // Result: int64(item.Result),
|
||||
// // Water: item.Water,
|
||||
// //})
|
||||
// }
|
||||
//
|
||||
// return
|
||||
//
|
||||
// }); err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if needUrl {
|
||||
// data.Url, err = gamelife.GetGamelifeClient(ctx).GetGamelifePackageUrl(ctx, in.PopenId, in.GameCode, in.GameId, in.BindType)
|
||||
// if err != nil {
|
||||
// return nil, ecode.Fail.Sub("获取绑定链接失败")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //return &model.GetRewardOut{
|
||||
// // List: data.List,
|
||||
// //}, err
|
||||
// return &data, err
|
||||
// }
|
||||
GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error)
|
||||
// GetGoodsList 调用外部获取物品列表
|
||||
GetGoodsList(ctx context.Context, in *model.GetGoodsListIn) (out *model.GetGoodsListOut, err error)
|
||||
|
||||
@ -22,7 +22,6 @@ type (
|
||||
// GetTask 完成任务
|
||||
GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.GetTaskOut, err error)
|
||||
GetUserTaskRecordsList(ctx context.Context, in *model.UserTaskRecordsListIn) (out *model.UserTaskRecordsListOut, err error)
|
||||
// GetTaskList PC-WEB获取任务列表
|
||||
GetTaskList(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error)
|
||||
SyncTaskFromGamelife(ctx context.Context) (out *model.SyncTaskOut, err error)
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ type (
|
||||
DelUser(ctx context.Context, in *model.DelUserIn) (out *model.DeleteOut, err error)
|
||||
GetUserGameRole(ctx context.Context, in *model.GetUserGameRoleIn) (out *model.GetUserGameRoleOut, err error)
|
||||
GamelifePackUrl(ctx context.Context, in *model.GamelifePackUrlIn) (out *model.GamelifePackUrlOut, err error)
|
||||
Quan8Autologin(ctx context.Context, in *model.Quan8AutologinIn) (out *model.Quan8AutologinOut, err error)
|
||||
GenerateSceneId(ctx context.Context, in *model.GenerateSceneIdIn) (out *model.GenerateSceneIdOut, err error)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user