diff --git a/internal/logic/merchant/merchant.go b/internal/logic/merchant/merchant.go index 6e334a1..cc067d1 100644 --- a/internal/logic/merchant/merchant.go +++ b/internal/logic/merchant/merchant.go @@ -78,6 +78,5 @@ func (s *sMerchant) Audit(ctx context.Context, in *model.MerchantAuditIn) (out * } func (s *sMerchant) Create(ctx context.Context, in *model.MerchantCreateIn) (out *model.CreateOut, err error) { - return } diff --git a/internal/logic/store/store.go b/internal/logic/store/store.go index 72440ea..84471c3 100644 --- a/internal/logic/store/store.go +++ b/internal/logic/store/store.go @@ -1 +1,77 @@ package store + +import ( + "context" + "server/internal/dao" + "server/internal/model" + "server/internal/model/do" + "server/internal/service" + "server/utility/ecode" + + "github.com/gogf/gf/v2/database/gdb" +) + +type sStore struct { +} + +func New() service.IStore { + return &sStore{} +} +func init() { + service.RegisterStore(New()) +} +func (s *sStore) List(ctx context.Context, in *model.StoreListIn) (out *model.StoreListOut, err error) { + // 1. 初始化返回数据 + return +} + +func (s *sStore) Create(ctx context.Context, in *model.StoreCreateIn) (out *model.CreateOut, err error) { + // 1. 检查门店名称是否重复 + exist, err := dao.Stores.Ctx(ctx).Where(do.Stores{Name: in.Name}).Exist() + if err != nil { + return nil, ecode.Fail.Sub("新增门店查重出现异常") + } + if exist { + return nil, ecode.Params.Sub("门店名称已存在") + } + + // 2. 使用事务处理数据插入 + if err = dao.Stores.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + // 2.1 生成唯一的门店编号 + // 2.2 插入门店基本信息 + // 2.3 创建门店管理员账号 + // 2.4 初始化门店配置 + return nil + }); err != nil { + return nil, err + } + + return +} +func (s *sStore) Update(ctx context.Context, in *model.StoreUpdateIn) (out *model.UpdateOut, err error) { + // 1. 验证门店是否存在 + // 2. 验证操作权限(商户管理员或门店管理员) + // 3. 检查更新后的门店名称是否重复 + // 4. 使用事务更新门店信息 + // 5. 记录操作日志 + return +} +func (s *sStore) Delete(ctx context.Context, in *model.StoreDeleteIn) (out *model.DeleteOut, err error) { + // 1. 验证门店是否存在 + // 2. 验证操作权限(仅允许商户管理员) + // 3. 检查门店状态(是否有关联数据) + // 4. 使用事务处理删除操作 + // 5. 清理相关数据 + // 6. 记录操作日志 + return +} +func (s *sStore) Info(ctx context.Context, in *model.StoreInfoIn) (out *model.StoreInfoOut, err error) { + // 1. 验证门店是否存在 + // 2. 验证访问权限 + // 3. 获取门店基本信息 + // 4. 获取门店配置信息 + // 5. 获取门店管理员信息 + // 6. 获取门店统计信息 + // 7. 处理敏感信息 + return +} diff --git a/internal/model/store.go b/internal/model/store.go index 7207b73..e28d6dc 100644 --- a/internal/model/store.go +++ b/internal/model/store.go @@ -16,11 +16,32 @@ type Store struct { Status int `json:"status" orm:"status,default:1" dc:"状态:1=正常营业,2=暂停营业,3=已关闭"` } -type CreateIn struct { - Name string `json:"name" v:"required" dc:"门店名称"` +type StoreCreateIn struct { + Name string } -type UpdateIn struct { +type StoreUpdateIn struct { Id int Name string } + +type StoreListIn struct { + MerchantId int + Page int + Size int + Status int +} + +type StoreListOut struct { + List []Store + Total int +} +type StoreInfoIn struct { + Id int +} +type StoreInfoOut struct { +} + +type StoreDeleteIn struct { + Id int +} diff --git a/internal/service/store.go b/internal/service/store.go index 3d70438..72f4f2d 100644 --- a/internal/service/store.go +++ b/internal/service/store.go @@ -5,4 +5,32 @@ package service -type () +import ( + "context" + "server/internal/model" +) + +type ( + IStore interface { + List(ctx context.Context, in *model.StoreListIn) (out *model.StoreListOut, err error) + Create(ctx context.Context, in *model.StoreCreateIn) (out *model.CreateOut, err error) + Update(ctx context.Context, in *model.StoreUpdateIn) (out *model.UpdateOut, err error) + Delete(ctx context.Context, in *model.StoreDeleteIn) (out *model.DeleteOut, err error) + Info(ctx context.Context, in *model.StoreInfoIn) (out *model.StoreInfoOut, err error) + } +) + +var ( + localStore IStore +) + +func Store() IStore { + if localStore == nil { + panic("implement not found for interface IStore, forgot register?") + } + return localStore +} + +func RegisterStore(i IStore) { + localStore = i +} diff --git a/internal/service/user.go b/internal/service/user.go index 2433601..90baae2 100644 --- a/internal/service/user.go +++ b/internal/service/user.go @@ -16,6 +16,7 @@ type ( Info(ctx context.Context, in *model.UserInfoIn) (out *model.UserInfoOut, err error) Update(ctx context.Context, in *model.UserUpdateIn) (out *model.UpdateOut, err error) BindPhone(ctx context.Context, in *model.UserBindPhoneIn) (out *model.UpdateOut, err error) + List(ctx context.Context, in *model.UserListIn) (out *model.UserListOut, err error) } )