From e3ee281c7f5eea387ddf835d5ecccba4a48834be Mon Sep 17 00:00:00 2001 From: chy <2463300564@qq.com> Date: Tue, 8 Jul 2025 19:25:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E8=B4=A6=E5=8F=B7=E8=8E=B7=E5=8F=96=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/store/store.go | 1 + api/store/v1/store.go | 9 +++++++++ .../store_v1_get_store_info_by_netbar.go | 20 +++++++++++++++++++ internal/logic/store/store.go | 12 +++++++++++ internal/model/store.go | 8 ++++++++ internal/model/userTask.go | 1 + internal/service/store.go | 2 ++ internal/service/task.go | 2 +- utility/myCasbin/casbin.go | 3 +++ 9 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 internal/controller/store/store_v1_get_store_info_by_netbar.go diff --git a/api/store/store.go b/api/store/store.go index b31fabe..84ae246 100644 --- a/api/store/store.go +++ b/api/store/store.go @@ -24,4 +24,5 @@ type IStoreV1 interface { GetStoreAreaList(ctx context.Context, req *v1.GetStoreAreaListReq) (res *v1.GetStoreAreaListRes, err error) GetNetfeeSetting(ctx context.Context, req *v1.GetNetfeeSettingReq) (res *v1.GetNetfeeSettingRes, err error) SaveNetfeeSetting(ctx context.Context, req *v1.SaveNetfeeSettingReq) (res *v1.SaveNetfeeSettingRes, err error) + GetStoreInfoByNetbar(ctx context.Context, req *v1.GetStoreInfoByNetbarReq) (res *v1.GetStoreInfoByNetbarRes, err error) } diff --git a/api/store/v1/store.go b/api/store/v1/store.go index 702898f..2e31b89 100644 --- a/api/store/v1/store.go +++ b/api/store/v1/store.go @@ -143,3 +143,12 @@ type SaveNetfeeSettingReq struct { type SaveNetfeeSettingRes struct { Success bool `json:"success" dc:"是否成功"` } + +type GetStoreInfoByNetbarReq struct { + g.Meta `path:"/store/getStoreInfoByNetbar" method:"get" tags:"PC/Store" summary:"(用户)根据网关账号获取门店信息"` + NetbarAccount string `json:"netbarAccount" v:"required" dc:"网关账号"` +} + +type GetStoreInfoByNetbarRes struct { + Store interface{} `json:"store"` +} diff --git a/internal/controller/store/store_v1_get_store_info_by_netbar.go b/internal/controller/store/store_v1_get_store_info_by_netbar.go new file mode 100644 index 0000000..81ab88e --- /dev/null +++ b/internal/controller/store/store_v1_get_store_info_by_netbar.go @@ -0,0 +1,20 @@ +package store + +import ( + "context" + "server/internal/model" + + "server/api/store/v1" + "server/internal/service" +) + +func (c *ControllerV1) GetStoreInfoByNetbar(ctx context.Context, req *v1.GetStoreInfoByNetbarReq) (res *v1.GetStoreInfoByNetbarRes, err error) { + + out, err := service.Store().GetStoreInfoByNetbarAccount(ctx, &model.StoreByNetbarAccountIn{NetbarAccount: req.NetbarAccount}) + if err != nil { + return nil, err + } + return &v1.GetStoreInfoByNetbarRes{ + Store: out.Store, + }, nil +} diff --git a/internal/logic/store/store.go b/internal/logic/store/store.go index d092274..51787fb 100644 --- a/internal/logic/store/store.go +++ b/internal/logic/store/store.go @@ -374,3 +374,15 @@ func (s *sStore) SaveNetfeeSetting(ctx context.Context, in *model.SaveNetfeeSett Success: true, }, nil } + +// GetStoreInfoByNetbarAccount 根据网关账号获取门店信息 +func (s *sStore) GetStoreInfoByNetbarAccount(ctx context.Context, in *model.StoreByNetbarAccountIn) (out *model.StoreByNetbarAccountOut, err error) { + + var data model.Store + if err = dao.Stores.Ctx(ctx).Where(do.Stores{NetbarAccount: in.NetbarAccount}).Fields(dao.Stores.Columns().Id, dao.Stores.Columns().Name).Scan(&data); err != nil { + return nil, ecode.Fail.Sub("查询门店信息失败") + } + return &model.StoreByNetbarAccountOut{ + Store: data, + }, nil +} diff --git a/internal/model/store.go b/internal/model/store.go index fcc9ab0..ed3739f 100644 --- a/internal/model/store.go +++ b/internal/model/store.go @@ -116,3 +116,11 @@ type StoreDetailIn struct { type StoreDetailOut struct { Id int64 `json:"id"` } + +type StoreByNetbarAccountIn struct { + NetbarAccount string `json:"netbarAccount"` +} + +type StoreByNetbarAccountOut struct { + Store interface{} `json:"store"` +} diff --git a/internal/model/userTask.go b/internal/model/userTask.go index 24fbc02..1d4d77d 100644 --- a/internal/model/userTask.go +++ b/internal/model/userTask.go @@ -22,6 +22,7 @@ type UserTask struct { User User `json:"user,omitempty" orm:"with:id=user_id"` Game Game `json:"game,omitempty" orm:"with:game_id=game_id"` // Store Store `json:"store" orm:"with:id=store_id"` + UserTimes int64 `json:"userTimes" orm:"user_times" description:"用户完成次数"` // 用户完成次数 } type TaskReward struct { diff --git a/internal/service/store.go b/internal/service/store.go index a294148..710c9ea 100644 --- a/internal/service/store.go +++ b/internal/service/store.go @@ -27,6 +27,8 @@ type ( GetStoreAreaList(ctx context.Context, in *model.StoreAreaListIn) (out *model.StoreAreaListOut, err error) GetNetfeeSetting(ctx context.Context, in *model.GetNetfeeSettingIn) (out *model.StoreNetfeeAreaLevel, err error) SaveNetfeeSetting(ctx context.Context, in *model.SaveNetfeeSettingIn) (out *model.SaveNetfeeSettingOut, err error) + // GetStoreInfoByNetbarAccount 根据网关账号获取门店信息 + GetStoreInfoByNetbarAccount(ctx context.Context, in *model.StoreByNetbarAccountIn) (out *model.StoreByNetbarAccountOut, err error) } ) diff --git a/internal/service/task.go b/internal/service/task.go index 1dcbf65..6072297 100644 --- a/internal/service/task.go +++ b/internal/service/task.go @@ -19,7 +19,7 @@ type ( // GetTaskCompletedList 获取用户任务完成列表 GetTaskCompletedList(ctx context.Context, in *model.TaskListIn) (out *model.TaskListOut, err error) GetSelectorList(ctx context.Context, in *model.SelectorIn) (out *[]model.SelectorOut, err error) - // GetTask 完成任务 + // 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(ctx context.Context, in *model.GetTaskListV2In) (out *model.GetTaskListV2Out, err error) diff --git a/utility/myCasbin/casbin.go b/utility/myCasbin/casbin.go index 6c4cd7c..2cfd27d 100644 --- a/utility/myCasbin/casbin.go +++ b/utility/myCasbin/casbin.go @@ -40,6 +40,9 @@ func init() { enforcer.AddGroupingPolicy(consts.AdminRoleCode, consts.MerchantRoleCode) // 管理员继承商户角色权限 // 游客 { + // 根据网关账号获取门店信息 + enforcer.AddPolicy("guest", "/x/store/getStoreInfoByNetbar", "GET", "根据网关账号获取门店信息") + // 任务 enforcer.AddPolicy("guest", "/x/task/ranking", "GET", "获取排行榜") enforcer.AddPolicy("guest", "/x/task/getNonLoginTaskList", "GET", "未登录获取任务列表")