From a7dfe858c7115a11fe1a4fe8ad89e64822b43119 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 9 Apr 2026 11:06:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E6=97=B6=E8=87=AA=E5=8A=A8=E5=88=86=E9=85=8D?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E9=BB=98=E8=AE=A4=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💘 Generated with Crush Assisted-by: Claude Sonnet 4.6 via Crush --- internal/service/account/service.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/service/account/service.go b/internal/service/account/service.go index 9de7c96..81c0924 100644 --- a/internal/service/account/service.go +++ b/internal/service/account/service.go @@ -124,6 +124,23 @@ func (s *Service) Create(ctx context.Context, req *dto.CreateAccountRequest) (*m return nil, errors.Wrap(errors.CodeInternalError, err, "创建账号失败") } + // 代理账号自动分配该店铺的默认角色 + if req.UserType == constants.UserTypeAgent && req.ShopID != nil { + roleIDs, err := s.shopRoleStore.GetRoleIDsByShopID(ctx, *req.ShopID) + if err == nil { + for _, roleID := range roleIDs { + ar := &model.AccountRole{ + AccountID: account.ID, + RoleID: roleID, + Status: constants.StatusEnabled, + Creator: currentUserID, + Updater: currentUserID, + } + _ = s.accountRoleStore.Create(ctx, ar) + } + } + } + currentAccount, _ := s.accountStore.GetByID(ctx, currentUserID) operatorName := "" if currentAccount != nil {