From efdbb212613a1a2278c75bbd52dc89c7da19e1cd Mon Sep 17 00:00:00 2001 From: denghui <1016848185@qq.com> Date: Wed, 11 Jun 2025 10:24:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E6=88=B7=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/merchant/v1/merchant.go | 4 +- api/merchantAdmin/v1/merchantAdmin.go | 4 +- hack/config.yaml | 2 +- internal/cmd/cmd.go | 2 + internal/consts/merchant.go | 2 +- internal/consts/store.go | 6 ++ .../merchantAdmin_v1_merchant_admin_info.go | 2 +- internal/controller/user/user_v1_list.go | 18 +++- internal/dao/internal/admins.go | 22 ++--- internal/dao/internal/feedbacks.go | 22 ++--- internal/dao/internal/games.go | 22 ++--- internal/dao/internal/merchant_admins.go | 22 ++--- internal/dao/internal/merchants.go | 22 ++--- internal/dao/internal/reward_types.go | 22 ++--- internal/dao/internal/rewards.go | 22 ++--- internal/dao/internal/roles.go | 22 ++--- internal/dao/internal/store_admins.go | 22 ++--- internal/dao/internal/store_rewards.go | 22 ++--- internal/dao/internal/stores.go | 22 ++--- internal/dao/internal/tasks.go | 22 ++--- internal/dao/internal/user_tasks.go | 22 ++--- internal/dao/internal/users.go | 88 +++++++++---------- internal/logic/merchant/merchant.go | 2 +- internal/logic/merchantAdmin/merchantAdmin.go | 57 +++++++++++- internal/logic/user/user.go | 18 +++- internal/model/do/users.go | 35 ++++---- internal/model/entity/users.go | 33 +++---- internal/model/merchantAdmin.go | 4 +- internal/model/user.go | 38 ++++---- manifest/config/config.yaml | 8 +- utility/myCasbin/casbin.go | 3 +- 31 files changed, 310 insertions(+), 302 deletions(-) create mode 100644 internal/consts/store.go diff --git a/api/merchant/v1/merchant.go b/api/merchant/v1/merchant.go index 3eba5b6..8d3ce75 100644 --- a/api/merchant/v1/merchant.go +++ b/api/merchant/v1/merchant.go @@ -7,7 +7,7 @@ type ListReq struct { Page int `json:"page" dc:"页数"` Size int `json:"size" dc:"每页数量"` Status int `json:"status" dc:"状态:1=启用,2=禁用"` - AuditStatus int `json:"auditStatus" dc:"审核状态:0=待审核,1=审核通过,2=审核拒绝"` + AuditStatus int `json:"auditStatus" dc:"审核状态:1=待审核,2=审核通过,3=审核拒绝"` } type ListRes struct { List interface{} `json:"list" dc:"商户列表"` @@ -31,7 +31,7 @@ type UpdateRes struct { type AuditReq struct { g.Meta `path:"/merchant/audit" method:"post" tags:"Merchant" summary:"(系统管理员)商户审核"` Id int64 `json:"id" v:"required" dc:"商户ID"` - AuditStatus int `json:"auditStatus" v:"required" dc:"审核状态:1=审核通过,2=审核拒绝" ` + AuditStatus int `json:"auditStatus" v:"required" dc:"审核状态:2=审核通过,3=审核拒绝" ` AuditRemark string `json:"auditRemark" dc:"审核备注"` RejectReason string `json:"rejectReason" dc:"拒绝原因"` } diff --git a/api/merchantAdmin/v1/merchantAdmin.go b/api/merchantAdmin/v1/merchantAdmin.go index f150513..b9ca024 100644 --- a/api/merchantAdmin/v1/merchantAdmin.go +++ b/api/merchantAdmin/v1/merchantAdmin.go @@ -8,5 +8,7 @@ type MerchantAdminInfoReq struct { g.Meta `path:"/merchant/info" method:"get" tags:"MerchantAdmin" summary:"(商户管理员)获取商户管理员信息"` } type MerchantAdminInfoRes struct { - Name string + MerchantId int64 `json:"merchantId"` + Username string `json:"username"` + StoreId int64 `json:"storeId"` // 下属门店 id } diff --git a/hack/config.yaml b/hack/config.yaml index 125fe0d..cc97da3 100644 --- a/hack/config.yaml +++ b/hack/config.yaml @@ -4,6 +4,6 @@ gfcli: gen: dao: - - link: "mysql:root:MSms0427@tcp(192.168.3.132:3306)/arenax" + - link: "mysql:root:MSms0427@tcp(localhost:3306)/arenax" descriptionTag: true tablesEx: "casbin_rule" \ No newline at end of file diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 66a91a9..bfda6f3 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -10,6 +10,7 @@ import ( "server/internal/controller/feedback" "server/internal/controller/game" "server/internal/controller/merchant" + "server/internal/controller/merchantAdmin" "server/internal/controller/reward" "server/internal/controller/rewardType" "server/internal/controller/role" @@ -38,6 +39,7 @@ var ( group.Middleware(middleware.Auth) group.Middleware(middleware.Casbin) group.Bind( + merchantAdmin.NewV1(), upload.NewV1(), admin.NewV1(), role.NewV1(), diff --git a/internal/consts/merchant.go b/internal/consts/merchant.go index c7dac4e..4b3b586 100644 --- a/internal/consts/merchant.go +++ b/internal/consts/merchant.go @@ -8,7 +8,7 @@ const ( // 商户审核状态 const ( - MerchantPendingReview = iota + MerchantPendingReview = iota + 1 MerchantReviewPassed MerchantReviewRejected ) diff --git a/internal/consts/store.go b/internal/consts/store.go new file mode 100644 index 0000000..73f56ff --- /dev/null +++ b/internal/consts/store.go @@ -0,0 +1,6 @@ +package consts + +const ( + StoreEnable = iota + 1 + StoreDisable +) diff --git a/internal/controller/merchantAdmin/merchantAdmin_v1_merchant_admin_info.go b/internal/controller/merchantAdmin/merchantAdmin_v1_merchant_admin_info.go index 2f74869..bdd99a1 100644 --- a/internal/controller/merchantAdmin/merchantAdmin_v1_merchant_admin_info.go +++ b/internal/controller/merchantAdmin/merchantAdmin_v1_merchant_admin_info.go @@ -15,5 +15,5 @@ func (c *ControllerV1) MerchantAdminInfo(ctx context.Context, req *v1.MerchantAd if err != nil { return nil, err } - return &v1.MerchantAdminInfoRes{Name: info.Name}, nil + return &v1.MerchantAdminInfoRes{Username: info.Username, MerchantId: info.MerchantId, StoreId: info.StoreId}, nil } diff --git a/internal/controller/user/user_v1_list.go b/internal/controller/user/user_v1_list.go index fc9b376..8d45a9e 100644 --- a/internal/controller/user/user_v1_list.go +++ b/internal/controller/user/user_v1_list.go @@ -2,13 +2,23 @@ package user import ( "context" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "server/internal/model" + "server/internal/service" "server/api/user/v1" ) func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) { - return nil, gerror.NewCode(gcode.CodeNotImplemented) + fromCtx := g.RequestFromCtx(ctx) + operatorId := fromCtx.Get("operatorId").Int64() + operatorRole := fromCtx.Get("role").String() + out, err := service.User().List(ctx, &model.UserListIn{Page: req.Page, Size: req.Size, OperatorId: operatorId, OperatorRole: operatorRole}) + if err != nil { + return nil, err + } + return &v1.ListRes{ + List: out.List, + Total: out.Total, + }, nil } diff --git a/internal/dao/internal/admins.go b/internal/dao/internal/admins.go index dc72d15..7c3f2be 100644 --- a/internal/dao/internal/admins.go +++ b/internal/dao/internal/admins.go @@ -13,10 +13,9 @@ import ( // AdminsDao is the data access object for the table admins. 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. + 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. } // 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, + group: "default", + table: "admins", + columns: adminsColumns, } } @@ -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. diff --git a/internal/dao/internal/feedbacks.go b/internal/dao/internal/feedbacks.go index 7a8d085..d67a1e5 100644 --- a/internal/dao/internal/feedbacks.go +++ b/internal/dao/internal/feedbacks.go @@ -13,10 +13,9 @@ import ( // FeedbacksDao is the data access object for the table feedbacks. 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. + 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. } // 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, + group: "default", + table: "feedbacks", + columns: feedbacksColumns, } } @@ -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. diff --git a/internal/dao/internal/games.go b/internal/dao/internal/games.go index 34d43cd..993ab21 100644 --- a/internal/dao/internal/games.go +++ b/internal/dao/internal/games.go @@ -13,10 +13,9 @@ import ( // GamesDao is the data access object for the table games. 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. + 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. } // GamesColumns defines and stores column names for the table games. @@ -44,12 +43,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, + group: "default", + table: "games", + columns: gamesColumns, } } @@ -75,11 +73,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. diff --git a/internal/dao/internal/merchant_admins.go b/internal/dao/internal/merchant_admins.go index 1dacbd5..706ef30 100644 --- a/internal/dao/internal/merchant_admins.go +++ b/internal/dao/internal/merchant_admins.go @@ -13,10 +13,9 @@ import ( // MerchantAdminsDao is the data access object for the table merchant_admins. 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. + 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. } // MerchantAdminsColumns defines and stores column names for the table merchant_admins. @@ -60,12 +59,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, + group: "default", + table: "merchant_admins", + columns: merchantAdminsColumns, } } @@ -91,11 +89,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. diff --git a/internal/dao/internal/merchants.go b/internal/dao/internal/merchants.go index 717f855..6dd5d05 100644 --- a/internal/dao/internal/merchants.go +++ b/internal/dao/internal/merchants.go @@ -13,10 +13,9 @@ import ( // MerchantsDao is the data access object for the table merchants. 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. + 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. } // 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, + group: "default", + table: "merchants", + columns: merchantsColumns, } } @@ -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. diff --git a/internal/dao/internal/reward_types.go b/internal/dao/internal/reward_types.go index 9703427..ee07106 100644 --- a/internal/dao/internal/reward_types.go +++ b/internal/dao/internal/reward_types.go @@ -13,10 +13,9 @@ import ( // RewardTypesDao is the data access object for the table reward_types. 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. + 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. } // RewardTypesColumns defines and stores column names for the table reward_types. @@ -44,12 +43,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, + group: "default", + table: "reward_types", + columns: rewardTypesColumns, } } @@ -75,11 +73,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. diff --git a/internal/dao/internal/rewards.go b/internal/dao/internal/rewards.go index d60fc10..693f7db 100644 --- a/internal/dao/internal/rewards.go +++ b/internal/dao/internal/rewards.go @@ -13,10 +13,9 @@ import ( // RewardsDao is the data access object for the table rewards. 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. + 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. } // RewardsColumns defines and stores column names for the table rewards. @@ -54,12 +53,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, + group: "default", + table: "rewards", + columns: rewardsColumns, } } @@ -85,11 +83,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. diff --git a/internal/dao/internal/roles.go b/internal/dao/internal/roles.go index 563bfdb..c8c80b4 100644 --- a/internal/dao/internal/roles.go +++ b/internal/dao/internal/roles.go @@ -13,10 +13,9 @@ import ( // RolesDao is the data access object for the table roles. 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. + 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. } // RolesColumns defines and stores column names for the table roles. @@ -46,12 +45,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, + group: "default", + table: "roles", + columns: rolesColumns, } } @@ -77,11 +75,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. diff --git a/internal/dao/internal/store_admins.go b/internal/dao/internal/store_admins.go index 151f658..7ab00ec 100644 --- a/internal/dao/internal/store_admins.go +++ b/internal/dao/internal/store_admins.go @@ -13,10 +13,9 @@ import ( // StoreAdminsDao is the data access object for the table store_admins. 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. + 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. } // StoreAdminsColumns defines and stores column names for the table store_admins. @@ -56,12 +55,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, + group: "default", + table: "store_admins", + columns: storeAdminsColumns, } } @@ -87,11 +85,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. diff --git a/internal/dao/internal/store_rewards.go b/internal/dao/internal/store_rewards.go index 87e840c..73bb09e 100644 --- a/internal/dao/internal/store_rewards.go +++ b/internal/dao/internal/store_rewards.go @@ -13,10 +13,9 @@ import ( // StoreRewardsDao is the data access object for the table store_rewards. type StoreRewardsDao 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 StoreRewardsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + 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 StoreRewardsColumns // columns contains all the column names of Table for convenient usage. } // StoreRewardsColumns defines and stores column names for the table store_rewards. @@ -34,12 +33,11 @@ var storeRewardsColumns = StoreRewardsColumns{ } // NewStoreRewardsDao creates and returns a new DAO object for table data access. -func NewStoreRewardsDao(handlers ...gdb.ModelHandler) *StoreRewardsDao { +func NewStoreRewardsDao() *StoreRewardsDao { return &StoreRewardsDao{ - group: "default", - table: "store_rewards", - columns: storeRewardsColumns, - handlers: handlers, + group: "default", + table: "store_rewards", + columns: storeRewardsColumns, } } @@ -65,11 +63,7 @@ func (dao *StoreRewardsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreRewardsDao) 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. diff --git a/internal/dao/internal/stores.go b/internal/dao/internal/stores.go index 9725b7c..b97c4c8 100644 --- a/internal/dao/internal/stores.go +++ b/internal/dao/internal/stores.go @@ -13,10 +13,9 @@ import ( // StoresDao is the data access object for the table stores. 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. + 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. } // StoresColumns defines and stores column names for the table stores. @@ -50,12 +49,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, + group: "default", + table: "stores", + columns: storesColumns, } } @@ -81,11 +79,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. diff --git a/internal/dao/internal/tasks.go b/internal/dao/internal/tasks.go index 6541eb6..414dc25 100644 --- a/internal/dao/internal/tasks.go +++ b/internal/dao/internal/tasks.go @@ -13,10 +13,9 @@ import ( // TasksDao is the data access object for the table tasks. 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. + 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. } // TasksColumns defines and stores column names for the table tasks. @@ -38,12 +37,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, + group: "default", + table: "tasks", + columns: tasksColumns, } } @@ -69,11 +67,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. diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index b4e59d1..a3ec699 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -13,10 +13,9 @@ import ( // UserTasksDao is the data access object for the table user_tasks. 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. + 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. } // UserTasksColumns defines and stores column names for the table user_tasks. @@ -48,12 +47,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, + group: "default", + table: "user_tasks", + columns: userTasksColumns, } } @@ -79,11 +77,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. diff --git a/internal/dao/internal/users.go b/internal/dao/internal/users.go index 45b4639..39cc508 100644 --- a/internal/dao/internal/users.go +++ b/internal/dao/internal/users.go @@ -13,59 +13,59 @@ import ( // UsersDao is the data access object for the table users. 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. + 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. } // UsersColumns defines and stores column names for the table users. type UsersColumns struct { - Id string // 用户唯一标识符 - WxOpenId string // 微信 OpenID - Username string // 用户名 - Nickname string // 昵称 - Avatar string // 用户头像URL - PasswordHash string // 密码哈希 - Email string // 邮箱地址 - PhoneNumber string // 手机号 - WxPopenId string // 微信 PopenID - QqPopenId string // QQ PopenID - FirstVisitAt string // 首次访问时间 - LastLoginAt string // 最后登录时间 - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 软删除时间 - RoleId string // 角色ID + Id string // 用户唯一标识符 + WxOpenId string // 微信 OpenID + Username string // 用户名 + Nickname string // 昵称 + Avatar string // 用户头像URL + PasswordHash string // 密码哈希 + Email string // 邮箱地址 + PhoneNumber string // 手机号 + WxPopenId string // 微信 PopenID + QqPopenId string // QQ PopenID + FirstVisitAt string // 首次访问时间 + LastLoginAt string // 最后登录时间 + CreatedAt string // 创建时间 + UpdatedAt string // 更新时间 + DeletedAt string // 软删除时间 + RoleId string // 角色ID + LastLoginStoreId string // 上次登录门店ID } // usersColumns holds the columns for the table users. var usersColumns = UsersColumns{ - Id: "id", - WxOpenId: "wx_open_id", - Username: "username", - Nickname: "nickname", - Avatar: "avatar", - PasswordHash: "password_hash", - Email: "email", - PhoneNumber: "phone_number", - WxPopenId: "wx_popen_id", - QqPopenId: "qq_popen_id", - FirstVisitAt: "first_visit_at", - LastLoginAt: "last_login_at", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", - RoleId: "role_id", + Id: "id", + WxOpenId: "wx_open_id", + Username: "username", + Nickname: "nickname", + Avatar: "avatar", + PasswordHash: "password_hash", + Email: "email", + PhoneNumber: "phone_number", + WxPopenId: "wx_popen_id", + QqPopenId: "qq_popen_id", + FirstVisitAt: "first_visit_at", + LastLoginAt: "last_login_at", + CreatedAt: "created_at", + UpdatedAt: "updated_at", + DeletedAt: "deleted_at", + RoleId: "role_id", + LastLoginStoreId: "last_login_store_id", } // 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, + group: "default", + table: "users", + columns: usersColumns, } } @@ -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. diff --git a/internal/logic/merchant/merchant.go b/internal/logic/merchant/merchant.go index 8b11bbd..ad13d9e 100644 --- a/internal/logic/merchant/merchant.go +++ b/internal/logic/merchant/merchant.go @@ -49,7 +49,7 @@ func (s *sMerchant) Audit(ctx context.Context, in *model.MerchantAuditIn) (out * if merchant.IsEmpty() { return nil, ecode.Params.Sub("商户不存在") } - if merchant[dao.Merchants.Columns().AuditStatus].Int() != 0 { + if merchant[dao.Merchants.Columns().AuditStatus].Int() != 1 { return nil, ecode.Params.Sub("商户已审核") } if err = dao.Merchants.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { diff --git a/internal/logic/merchantAdmin/merchantAdmin.go b/internal/logic/merchantAdmin/merchantAdmin.go index a0b0013..b60e290 100644 --- a/internal/logic/merchantAdmin/merchantAdmin.go +++ b/internal/logic/merchantAdmin/merchantAdmin.go @@ -90,7 +90,11 @@ func (s *sMerchantAdmin) Login(ctx context.Context, in *model.MerchantLoginIn) ( return } func (s *sMerchantAdmin) Info(ctx context.Context, in *model.MerchantAdminInfoIn) (out *model.MerchantAdminInfoOut, err error) { - one, err := dao.MerchantAdmins.Ctx(ctx).WherePri(in.MerchantAdminId).One() + one, err := dao.MerchantAdmins.Ctx(ctx).WherePri(in.MerchantAdminId). + LeftJoin( + dao.Stores.Table(), + fmt.Sprintf("%s.%s = %s.%s", dao.Stores.Table(), dao.Stores.Columns().MerchantId, dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId)). + Fields(fmt.Sprintf("%s.*, %s.%s %s", dao.MerchantAdmins.Table(), dao.Stores.Table(), dao.Stores.Columns().Id, "storeId")).One() if err != nil { return nil, ecode.Fail.Sub("查询商户管理员失败") } @@ -102,7 +106,9 @@ func (s *sMerchantAdmin) Info(ctx context.Context, in *model.MerchantAdminInfoIn return nil, ecode.Fail.Sub("查询商户管理员失败") } return &model.MerchantAdminInfoOut{ - Name: admin.Username, + Username: admin.Username, + MerchantId: admin.MerchantId, + StoreId: one["storeId"].Int64(), }, nil } func (s *sMerchantAdmin) Code(ctx context.Context, in *model.MerchantAdminCodeIn) (out *model.MerchantAdminCodeOut, err error) { @@ -167,7 +173,21 @@ func (s *sMerchantAdmin) Register(ctx context.Context, in *model.MerchantAdminRe if err != nil { return ecode.Fail.Sub("插入商户数据失败") } - + // 查询出商户角色 id 和门店角色 id + array, err := tx.Model(dao.Roles.Table()).WhereIn(dao.Roles.Columns().Code, []string{consts.MerchantRoleCode, consts.StoreRoleCode}).Fields(dao.Roles.Columns().Code, dao.Roles.Columns().Id).All() + if err != nil { + return ecode.Fail.Sub("查询角色数据失败") + } + var merchantRoleId, storeRoleId int64 + for _, value := range array { + code := value[dao.Roles.Columns().Code].String() + id := value[dao.Roles.Columns().Id].Int64() + if code == consts.MerchantRoleCode { + merchantRoleId = id + } else if code == consts.StoreRoleCode { + storeRoleId = id + } + } // 插入商户管理员数据 if _, err = tx.Model(dao.MerchantAdmins.Table()).Data(do.MerchantAdmins{ MerchantId: id, @@ -175,10 +195,41 @@ func (s *sMerchantAdmin) Register(ctx context.Context, in *model.MerchantAdminRe Phone: in.Phone, IsPrimary: true, Username: in.Username, + RoleId: merchantRoleId, Status: consts.MerchantAdministratorEnable, }).Insert(); err != nil { return ecode.Fail.Sub("插入商户管理员数据失败") } + + // 初始化一个网吧 + storeCode, err := snowid.GetSnowClient().GenerateStoreCode() + if err != nil { + return ecode.Fail.Sub("生成网吧编号失败") + } + + storeId, err := tx.Model(dao.Stores.Table()).Data(do.Stores{ + MerchantId: id, + Name: fmt.Sprintf("%s的网吧", in.Username), + StoreCode: storeCode, + ContactPhone: in.Phone, + Status: consts.StoreEnable, + }).InsertAndGetId() + if err != nil { + return ecode.Fail.Sub("插入网吧数据失败") + } + // 初始化一个网吧管理员 + if _, err = tx.Model(dao.StoreAdmins.Table()).Data(do.StoreAdmins{ + StoreId: storeId, + Username: in.Username, + Phone: in.Phone, + Status: consts.StoreAdminEnable, + PasswordHash: hashPass, + IsPrimary: true, + RoleId: storeRoleId, + }).Insert(); err != nil { + return ecode.Fail.Sub("插入网吧管理员数据失败") + } + return }); err != nil { return nil, err diff --git a/internal/logic/user/user.go b/internal/logic/user/user.go index a115a7f..8d3c052 100644 --- a/internal/logic/user/user.go +++ b/internal/logic/user/user.go @@ -199,8 +199,22 @@ func (s *sUser) BindPhone(ctx context.Context, in *model.UserBindPhoneIn) (out * } func (s *sUser) List(ctx context.Context, in *model.UserListIn) (out *model.UserListOut, err error) { - // 用于系统管理员、商户、门店查看用户列表, 展示用户最近的相关信息 - return + list := make([]model.User, 0) + var total int + orm := dao.Users.Ctx(ctx) + if in.Nickname != "" { + orm = orm.WhereLike(dao.Users.Columns().Nickname, "%"+in.Nickname+"%") + } + if err = orm.Page(in.Page, in.Size).LeftJoin( + dao.Stores.Table(), + fmt.Sprintf("%s.%s = %s.%s", dao.Users.Table(), dao.Users.Columns().LastLoginStoreId, dao.Stores.Table(), dao.Stores.Columns().Id), + ).Fields(fmt.Sprintf("%s.*, %s.%s %s", dao.Users.Table(), dao.Stores.Table(), dao.Stores.Columns().Name, "last_login_store_name")).ScanAndCount(&list, &total, false); err != nil { + return nil, ecode.Fail.Sub("获取用户列表失败") + } + return &model.UserListOut{ + List: list, + Total: total, + }, nil } func (s *sUser) BoundUrl(ctx context.Context, in *model.UserBoundUrlIn) (out *model.UserBoundUrlOut, err error) { diff --git a/internal/model/do/users.go b/internal/model/do/users.go index f6661e8..1d5493f 100644 --- a/internal/model/do/users.go +++ b/internal/model/do/users.go @@ -11,21 +11,22 @@ import ( // Users is the golang structure of table users for DAO operations like Where/Data. type Users struct { - g.Meta `orm:"table:users, do:true"` - Id interface{} // 用户唯一标识符 - WxOpenId interface{} // 微信 OpenID - Username interface{} // 用户名 - Nickname interface{} // 昵称 - Avatar interface{} // 用户头像URL - PasswordHash interface{} // 密码哈希 - Email interface{} // 邮箱地址 - PhoneNumber interface{} // 手机号 - WxPopenId interface{} // 微信 PopenID - QqPopenId interface{} // QQ PopenID - FirstVisitAt *gtime.Time // 首次访问时间 - LastLoginAt *gtime.Time // 最后登录时间 - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 软删除时间 - RoleId interface{} // 角色ID + g.Meta `orm:"table:users, do:true"` + Id interface{} // 用户唯一标识符 + WxOpenId interface{} // 微信 OpenID + Username interface{} // 用户名 + Nickname interface{} // 昵称 + Avatar interface{} // 用户头像URL + PasswordHash interface{} // 密码哈希 + Email interface{} // 邮箱地址 + PhoneNumber interface{} // 手机号 + WxPopenId interface{} // 微信 PopenID + QqPopenId interface{} // QQ PopenID + FirstVisitAt *gtime.Time // 首次访问时间 + LastLoginAt *gtime.Time // 最后登录时间 + CreatedAt *gtime.Time // 创建时间 + UpdatedAt *gtime.Time // 更新时间 + DeletedAt *gtime.Time // 软删除时间 + RoleId interface{} // 角色ID + LastLoginStoreId interface{} // 上次登录门店ID } diff --git a/internal/model/entity/users.go b/internal/model/entity/users.go index 3aaf380..9fa9514 100644 --- a/internal/model/entity/users.go +++ b/internal/model/entity/users.go @@ -10,20 +10,21 @@ import ( // Users is the golang structure for table users. type Users struct { - Id int64 `json:"id" orm:"id" description:"用户唯一标识符"` // 用户唯一标识符 - WxOpenId string `json:"wxOpenId" orm:"wx_open_id" description:"微信 OpenID"` // 微信 OpenID - Username string `json:"username" orm:"username" description:"用户名"` // 用户名 - Nickname string `json:"nickname" orm:"nickname" description:"昵称"` // 昵称 - Avatar string `json:"avatar" orm:"avatar" description:"用户头像URL"` // 用户头像URL - PasswordHash string `json:"passwordHash" orm:"password_hash" description:"密码哈希"` // 密码哈希 - Email string `json:"email" orm:"email" description:"邮箱地址"` // 邮箱地址 - PhoneNumber string `json:"phoneNumber" orm:"phone_number" description:"手机号"` // 手机号 - WxPopenId string `json:"wxPopenId" orm:"wx_popen_id" description:"微信 PopenID"` // 微信 PopenID - QqPopenId string `json:"qqPopenId" orm:"qq_popen_id" description:"QQ PopenID"` // QQ PopenID - FirstVisitAt *gtime.Time `json:"firstVisitAt" orm:"first_visit_at" description:"首次访问时间"` // 首次访问时间 - LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at" description:"最后登录时间"` // 最后登录时间 - CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 - UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间 - RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID + Id int64 `json:"id" orm:"id" description:"用户唯一标识符"` // 用户唯一标识符 + WxOpenId string `json:"wxOpenId" orm:"wx_open_id" description:"微信 OpenID"` // 微信 OpenID + Username string `json:"username" orm:"username" description:"用户名"` // 用户名 + Nickname string `json:"nickname" orm:"nickname" description:"昵称"` // 昵称 + Avatar string `json:"avatar" orm:"avatar" description:"用户头像URL"` // 用户头像URL + PasswordHash string `json:"passwordHash" orm:"password_hash" description:"密码哈希"` // 密码哈希 + Email string `json:"email" orm:"email" description:"邮箱地址"` // 邮箱地址 + PhoneNumber string `json:"phoneNumber" orm:"phone_number" description:"手机号"` // 手机号 + WxPopenId string `json:"wxPopenId" orm:"wx_popen_id" description:"微信 PopenID"` // 微信 PopenID + QqPopenId string `json:"qqPopenId" orm:"qq_popen_id" description:"QQ PopenID"` // QQ PopenID + FirstVisitAt *gtime.Time `json:"firstVisitAt" orm:"first_visit_at" description:"首次访问时间"` // 首次访问时间 + LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at" description:"最后登录时间"` // 最后登录时间 + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 + 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 } diff --git a/internal/model/merchantAdmin.go b/internal/model/merchantAdmin.go index c1ee535..64f2686 100644 --- a/internal/model/merchantAdmin.go +++ b/internal/model/merchantAdmin.go @@ -19,7 +19,9 @@ type MerchantAdminInfoIn struct { MerchantAdminId int64 } type MerchantAdminInfoOut struct { - Name string + Username string + MerchantId int64 + StoreId int64 } type MerchantAdminCodeIn struct { Phone string diff --git a/internal/model/user.go b/internal/model/user.go index d612774..65023d8 100644 --- a/internal/model/user.go +++ b/internal/model/user.go @@ -8,21 +8,19 @@ import ( // User 用户信息 type User struct { - Id int64 `json:"id" orm:"id,primary"` // 用户ID - Username string `json:"username" orm:"username,not null"` // 用户名 - PasswordHash string `json:"passwordHash" orm:"password_hash,not null"` // 密码哈希 - Nickname string `json:"nickname" orm:"nickname"` // 昵称 - Avatar string `json:"avatar" orm:"avatar"` // 头像 - Phone string `json:"phone" orm:"phone"` // 手机号 - Email string `json:"email" orm:"email"` // 邮箱 - Gender int `json:"gender" orm:"gender,default:0"` // 性别:0=未知,1=男,2=女 - Birthday *gtime.Time `json:"birthday" orm:"birthday"` // 生日 - Status int `json:"status" orm:"status,default:1"` // 状态:1=正常,2=禁用 - LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at"` // 最后登录时间 - LastLoginIp string `json:"lastLoginIp" orm:"last_login_ip"` // 最后登录IP - CreatedAt *gtime.Time `json:"createdAt" orm:"created_at"` // 创建时间 - UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at"` // 更新时间 - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at"` // 软删除时间戳 + Id int64 `json:"id" orm:"id,primary"` // 用户ID + Username string `json:"username" orm:"username,not null"` // 用户名 + Nickname string `json:"nickname" orm:"nickname"` // 昵称 + Avatar string `json:"avatar" orm:"avatar"` // 头像 + Phone string `json:"phone" orm:"phone"` // 手机号 + Email string `json:"email" orm:"email"` // 邮箱 + Gender int `json:"gender" orm:"gender,default:0"` // 性别:0=未知,1=男,2=女 + Birthday *gtime.Time `json:"birthday" orm:"birthday"` // 生日 + Status int `json:"status" orm:"status,default:1"` // 状态:1=正常,2=禁用 + LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at"` // 最后登录时间 + LastLoginIp string `json:"lastLoginIp" orm:"last_login_ip"` // 最后登录IP + LastLoginStoreId int `json:"lastLoginStoreId" orm:"last_login_store_id"` // 最后登录门店ID + LastLoginStoreName string `json:"lastLoginStoreName" orm:"last_login_store_name"` // 最后登录门店名称 } // UserCreateIn 创建用户请求 @@ -96,11 +94,11 @@ type UserBindPhoneOut struct { } type UserListIn struct { - OperatorId int64 - Role string - Nickname string - Page int - Size int + OperatorId int64 + OperatorRole string + Nickname string + Page int + Size int } type UserListOut struct { List []User diff --git a/manifest/config/config.yaml b/manifest/config/config.yaml index d3c6544..bab9a75 100644 --- a/manifest/config/config.yaml +++ b/manifest/config/config.yaml @@ -15,7 +15,7 @@ database: level: "all" stdout: true default: - link: "mysql:root:MSms0427@tcp(192.168.3.132:3306)/arenax?loc=Local&charset=utf8mb4" + link: "mysql:root:MSms0427@tcp(localhost:3306)/arenax?loc=Local&charset=utf8mb4" debug: true # Redis configuration. @@ -32,4 +32,8 @@ wechat: appId: "wx056fad20f1bd9110" appSecret: "4269b5a2bb0274e805b43efb3fbd232a" ticketExpire: 60 - token: "arenax" \ No newline at end of file + token: "arenax" + +rsa: + publickey: "./manifest/config/public.pem" + privatekey: "./manifest/config/private.pem" \ No newline at end of file diff --git a/utility/myCasbin/casbin.go b/utility/myCasbin/casbin.go index 0b01fb2..1b3dd0b 100644 --- a/utility/myCasbin/casbin.go +++ b/utility/myCasbin/casbin.go @@ -82,8 +82,7 @@ func init() { } // 商户 { - // 商户:查 - // 门店:增删查 + enforcer.AddPolicy("merchant", "/x/merchant/info", "GET", "获取商户信息") } // 管理员