feat: 创建代理账号时自动分配店铺默认角色
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m22s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m22s
💘 Generated with Crush Assisted-by: Claude Sonnet 4.6 via Crush <crush@charm.land>
This commit is contained in:
@@ -124,6 +124,23 @@ func (s *Service) Create(ctx context.Context, req *dto.CreateAccountRequest) (*m
|
|||||||
return nil, errors.Wrap(errors.CodeInternalError, err, "创建账号失败")
|
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)
|
currentAccount, _ := s.accountStore.GetByID(ctx, currentUserID)
|
||||||
operatorName := ""
|
operatorName := ""
|
||||||
if currentAccount != nil {
|
if currentAccount != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user