diff --git a/internal/admin/repository/eventsourcing/handler/iam_member.go b/internal/admin/repository/eventsourcing/handler/iam_member.go index 2d1cfed17d..b54f23f287 100644 --- a/internal/admin/repository/eventsourcing/handler/iam_member.go +++ b/internal/admin/repository/eventsourcing/handler/iam_member.go @@ -96,11 +96,8 @@ func (m *IamMember) processUser(event *models.Event) (err error) { } for _, member := range members { m.fillUserData(member, user) - err = m.view.PutIAMMember(member, event.Sequence) - if err != nil { - return err - } } + return m.view.PutIAMMembers(members, event.Sequence) default: return m.view.ProcessedIAMMemberSequence(event.Sequence) } diff --git a/internal/admin/repository/eventsourcing/view/iam_member.go b/internal/admin/repository/eventsourcing/view/iam_member.go index b52532e9f6..99aa58ce35 100644 --- a/internal/admin/repository/eventsourcing/view/iam_member.go +++ b/internal/admin/repository/eventsourcing/view/iam_member.go @@ -32,6 +32,14 @@ func (v *View) PutIAMMember(org *model.IAMMemberView, sequence uint64) error { return v.ProcessedIAMMemberSequence(sequence) } +func (v *View) PutIAMMembers(members []*model.IAMMemberView, sequence uint64) error { + err := view.PutIAMMembers(v.Db, iamMemberTable, members...) + if err != nil { + return err + } + return v.ProcessedIAMMemberSequence(sequence) +} + func (v *View) DeleteIAMMember(iamID, userID string, eventSequence uint64) error { err := view.DeleteIAMMember(v.Db, iamMemberTable, iamID, userID) if err != nil && !errors.IsNotFound(err) { diff --git a/internal/auth/repository/eventsourcing/handler/user.go b/internal/auth/repository/eventsourcing/handler/user.go index f49f92d886..c78ffe0dbe 100644 --- a/internal/auth/repository/eventsourcing/handler/user.go +++ b/internal/auth/repository/eventsourcing/handler/user.go @@ -148,12 +148,8 @@ func (u *User) fillLoginNamesOnOrgUsers(event *models.Event) error { } for _, user := range users { user.SetLoginNames(policy, org.Domains) - err := u.view.PutUser(user, event.Sequence) - if err != nil { - return err - } } - return nil + return u.view.PutUsers(users, event.Sequence) } func (u *User) fillPreferredLoginNamesOnOrgUsers(event *models.Event) error { @@ -174,12 +170,8 @@ func (u *User) fillPreferredLoginNamesOnOrgUsers(event *models.Event) error { } for _, user := range users { user.PreferredLoginName = user.GenerateLoginName(org.GetPrimaryDomain().Domain, policy.UserLoginMustBeDomain) - err := u.view.PutUser(user, 0) - if err != nil { - return err - } } - return nil + return u.view.PutUsers(users, 0) } func (u *User) OnError(event *models.Event, err error) error { diff --git a/internal/auth/repository/eventsourcing/handler/user_grant.go b/internal/auth/repository/eventsourcing/handler/user_grant.go index d58c452868..fd6727170c 100644 --- a/internal/auth/repository/eventsourcing/handler/user_grant.go +++ b/internal/auth/repository/eventsourcing/handler/user_grant.go @@ -124,11 +124,8 @@ func (u *UserGrant) processUser(event *models.Event) (err error) { } for _, grant := range grants { u.fillUserData(grant, user) - err = u.view.PutUserGrant(grant, event.Sequence) - if err != nil { - return err - } } + return u.view.PutUserGrants(grants, event.Sequence) default: return u.view.ProcessedUserGrantSequence(event.Sequence) } @@ -148,8 +145,8 @@ func (u *UserGrant) processProject(event *models.Event) (err error) { } for _, grant := range grants { u.fillProjectData(grant, project) - return u.view.PutUserGrant(grant, event.Sequence) } + return u.view.PutUserGrants(grants, event.Sequence) case proj_es_model.ProjectMemberAdded, proj_es_model.ProjectMemberChanged, proj_es_model.ProjectMemberRemoved: member := new(proj_es_model.ProjectMember) member.SetData(event) diff --git a/internal/auth/repository/eventsourcing/handler/user_session.go b/internal/auth/repository/eventsourcing/handler/user_session.go index 5b7f92f021..ba0a88cda6 100644 --- a/internal/auth/repository/eventsourcing/handler/user_session.go +++ b/internal/auth/repository/eventsourcing/handler/user_session.go @@ -74,11 +74,12 @@ func (u *UserSession) Reduce(event *models.Event) (err error) { return u.view.ProcessedUserSessionSequence(event.Sequence) } for _, session := range sessions { - if err := u.updateSession(session, event); err != nil { + session.AppendEvent(event) + if err := u.fillUserInfo(session, event.AggregateID); err != nil { return err } } - return nil + return u.view.PutUserSessions(sessions, event.Sequence) case es_model.UserRemoved: return u.view.DeleteUserSessions(event.AggregateID, event.Sequence) default: diff --git a/internal/auth/repository/eventsourcing/view/user.go b/internal/auth/repository/eventsourcing/view/user.go index f3ea161cf2..0ffa193346 100644 --- a/internal/auth/repository/eventsourcing/view/user.go +++ b/internal/auth/repository/eventsourcing/view/user.go @@ -55,6 +55,14 @@ func (v *View) PutUser(user *model.UserView, sequence uint64) error { return v.ProcessedUserSequence(sequence) } +func (v *View) PutUsers(users []*model.UserView, sequence uint64) error { + err := view.PutUsers(v.Db, userTable, users...) + if err != nil { + return err + } + return v.ProcessedUserSequence(sequence) +} + func (v *View) DeleteUser(userID string, eventSequence uint64) error { err := view.DeleteUser(v.Db, userTable, userID) if err != nil { diff --git a/internal/auth/repository/eventsourcing/view/user_grant.go b/internal/auth/repository/eventsourcing/view/user_grant.go index 0cc5851d18..cc53b97504 100644 --- a/internal/auth/repository/eventsourcing/view/user_grant.go +++ b/internal/auth/repository/eventsourcing/view/user_grant.go @@ -43,6 +43,14 @@ func (v *View) PutUserGrant(grant *model.UserGrantView, sequence uint64) error { return v.ProcessedUserGrantSequence(sequence) } +func (v *View) PutUserGrants(grants []*model.UserGrantView, sequence uint64) error { + err := view.PutUserGrants(v.Db, userGrantTable, grants...) + if err != nil { + return err + } + return v.ProcessedUserGrantSequence(sequence) +} + func (v *View) DeleteUserGrant(grantID string, eventSequence uint64) error { err := view.DeleteUserGrant(v.Db, userGrantTable, grantID) if err != nil { diff --git a/internal/auth/repository/eventsourcing/view/user_session.go b/internal/auth/repository/eventsourcing/view/user_session.go index b486fb24c8..fe9d6b0ec2 100644 --- a/internal/auth/repository/eventsourcing/view/user_session.go +++ b/internal/auth/repository/eventsourcing/view/user_session.go @@ -30,6 +30,14 @@ func (v *View) PutUserSession(userSession *model.UserSessionView) error { return v.ProcessedUserSessionSequence(userSession.Sequence) } +func (v *View) PutUserSessions(userSession []*model.UserSessionView, sequence uint64) error { + err := view.PutUserSessions(v.Db, userSessionTable, userSession...) + if err != nil { + return err + } + return v.ProcessedUserSessionSequence(sequence) +} + func (v *View) DeleteUserSessions(userID string, eventSequence uint64) error { err := view.DeleteUserSessions(v.Db, userSessionTable, userID) if err != nil { diff --git a/internal/iam/repository/view/iam_member_view.go b/internal/iam/repository/view/iam_member_view.go index 87438610f6..3b2aaad402 100644 --- a/internal/iam/repository/view/iam_member_view.go +++ b/internal/iam/repository/view/iam_member_view.go @@ -53,6 +53,15 @@ func PutIAMMember(db *gorm.DB, table string, role *model.IAMMemberView) error { return save(db, role) } +func PutIAMMembers(db *gorm.DB, table string, members ...*model.IAMMemberView) error { + save := repository.PrepareBulkSave(table) + m := make([]interface{}, len(members)) + for i, member := range members { + m[i] = member + } + return save(db, m...) +} + func DeleteIAMMember(db *gorm.DB, table, orgID, userID string) error { member, err := IAMMemberByIDs(db, table, orgID, userID) if err != nil { diff --git a/internal/management/repository/eventsourcing/handler/org_domain.go b/internal/management/repository/eventsourcing/handler/org_domain.go index 4088251191..7b44c71cfd 100644 --- a/internal/management/repository/eventsourcing/handler/org_domain.go +++ b/internal/management/repository/eventsourcing/handler/org_domain.go @@ -71,10 +71,10 @@ func (d *OrgDomain) processOrgDomain(event *models.Event) (err error) { } for _, existing := range existingDomains { existing.Primary = false - err := d.view.PutOrgDomain(existing, 0) - if err != nil { - return err - } + } + err = d.view.PutOrgDomains(existingDomains, 0) + if err != nil { + return err } err = domain.AppendEvent(event) case model.OrgDomainRemoved: diff --git a/internal/management/repository/eventsourcing/handler/org_member.go b/internal/management/repository/eventsourcing/handler/org_member.go index 65146929e1..97df1fff1a 100644 --- a/internal/management/repository/eventsourcing/handler/org_member.go +++ b/internal/management/repository/eventsourcing/handler/org_member.go @@ -99,11 +99,8 @@ func (m *OrgMember) processUser(event *models.Event) (err error) { } for _, member := range members { m.fillUserData(member, user) - err = m.view.PutOrgMember(member, event.Sequence) - if err != nil { - return err - } } + return m.view.PutOrgMembers(members, event.Sequence) default: return m.view.ProcessedOrgMemberSequence(event.Sequence) } diff --git a/internal/management/repository/eventsourcing/handler/project_grant.go b/internal/management/repository/eventsourcing/handler/project_grant.go index 96151efa2b..2e634b6235 100644 --- a/internal/management/repository/eventsourcing/handler/project_grant.go +++ b/internal/management/repository/eventsourcing/handler/project_grant.go @@ -47,7 +47,7 @@ func (p *ProjectGrant) Reduce(event *models.Event) (err error) { if err != nil { return err } - return p.updateExistingProjects(project) + return p.updateExistingProjects(project, event.Sequence) case es_model.ProjectGrantAdded: err = grantedProject.AppendEvent(event) if err != nil { @@ -106,21 +106,15 @@ func (p *ProjectGrant) getProject(projectID string) (*proj_model.Project, error) return p.projectEvents.ProjectByID(context.Background(), projectID) } -func (p *ProjectGrant) updateExistingProjects(project *view_model.ProjectView) error { +func (p *ProjectGrant) updateExistingProjects(project *view_model.ProjectView, sequence uint64) error { projectGrants, err := p.view.ProjectGrantsByProjectID(project.ProjectID) if err != nil { logging.LogWithFields("SPOOL-los03", "id", project.ProjectID).WithError(err).Warn("could not update existing projects") } for _, existing := range projectGrants { existing.Name = project.Name - err := p.view.PutProjectGrant(existing) - if err != nil { - logging.LogWithFields("SPOOL-sjwi3", "id", existing.ProjectID).WithError(err).Warn("could not update existing project") - return err - } } - - return p.view.ProcessedProjectGrantSequence(project.Sequence) + return p.view.PutProjectGrants(projectGrants, sequence) } func (p *ProjectGrant) OnError(event *models.Event, err error) error { diff --git a/internal/management/repository/eventsourcing/handler/project_grant_member.go b/internal/management/repository/eventsourcing/handler/project_grant_member.go index e379d90476..84839ae7b8 100644 --- a/internal/management/repository/eventsourcing/handler/project_grant_member.go +++ b/internal/management/repository/eventsourcing/handler/project_grant_member.go @@ -101,11 +101,8 @@ func (p *ProjectGrantMember) processUser(event *models.Event) (err error) { } for _, member := range members { p.fillUserData(member, user) - err = p.view.PutProjectGrantMember(member, event.Sequence) - if err != nil { - return err - } } + return p.view.PutProjectGrantMembers(members, event.Sequence) default: return p.view.ProcessedProjectGrantMemberSequence(event.Sequence) } diff --git a/internal/management/repository/eventsourcing/handler/project_member.go b/internal/management/repository/eventsourcing/handler/project_member.go index 6c22530520..118a188302 100644 --- a/internal/management/repository/eventsourcing/handler/project_member.go +++ b/internal/management/repository/eventsourcing/handler/project_member.go @@ -101,11 +101,8 @@ func (p *ProjectMember) processUser(event *models.Event) (err error) { } for _, member := range members { p.fillUserData(member, user) - err = p.view.PutProjectMember(member, event.Sequence) - if err != nil { - return err - } } + return p.view.PutProjectMembers(members, event.Sequence) default: return p.view.ProcessedProjectMemberSequence(event.Sequence) } diff --git a/internal/management/repository/eventsourcing/handler/user_grant.go b/internal/management/repository/eventsourcing/handler/user_grant.go index b4d31654aa..a941467f7e 100644 --- a/internal/management/repository/eventsourcing/handler/user_grant.go +++ b/internal/management/repository/eventsourcing/handler/user_grant.go @@ -106,11 +106,8 @@ func (u *UserGrant) processUser(event *models.Event) (err error) { } for _, grant := range grants { u.fillUserData(grant, user) - err = u.view.PutUserGrant(grant, event.Sequence) - if err != nil { - return err - } } + return u.view.PutUserGrants(grants, event.Sequence) default: return u.view.ProcessedUserGrantSequence(event.Sequence) } @@ -133,8 +130,8 @@ func (u *UserGrant) processProject(event *models.Event) (err error) { } for _, grant := range grants { u.fillProjectData(grant, project) - return u.view.PutUserGrant(grant, event.Sequence) } + return u.view.PutUserGrants(grants, event.Sequence) default: return u.view.ProcessedUserGrantSequence(event.Sequence) } diff --git a/internal/management/repository/eventsourcing/view/org_domain.go b/internal/management/repository/eventsourcing/view/org_domain.go index a06e1c9150..474a481d43 100644 --- a/internal/management/repository/eventsourcing/view/org_domain.go +++ b/internal/management/repository/eventsourcing/view/org_domain.go @@ -38,6 +38,14 @@ func (v *View) PutOrgDomain(org *model.OrgDomainView, sequence uint64) error { return nil } +func (v *View) PutOrgDomains(domains []*model.OrgDomainView, sequence uint64) error { + err := view.PutOrgDomains(v.Db, orgDomainTable, domains...) + if err != nil { + return err + } + return v.ProcessedUserSequence(sequence) +} + func (v *View) DeleteOrgDomain(orgID, domain string, eventSequence uint64) error { err := view.DeleteOrgDomain(v.Db, orgDomainTable, orgID, domain) if err != nil { diff --git a/internal/management/repository/eventsourcing/view/org_member.go b/internal/management/repository/eventsourcing/view/org_member.go index d74c62df3c..ca99202b09 100644 --- a/internal/management/repository/eventsourcing/view/org_member.go +++ b/internal/management/repository/eventsourcing/view/org_member.go @@ -23,8 +23,16 @@ func (v *View) OrgMembersByUserID(userID string) ([]*model.OrgMemberView, error) return view.OrgMembersByUserID(v.Db, orgMemberTable, userID) } -func (v *View) PutOrgMember(org *model.OrgMemberView, sequence uint64) error { - err := view.PutOrgMember(v.Db, orgMemberTable, org) +func (v *View) PutOrgMember(member *model.OrgMemberView, sequence uint64) error { + err := view.PutOrgMember(v.Db, orgMemberTable, member) + if err != nil { + return err + } + return v.ProcessedOrgMemberSequence(sequence) +} + +func (v *View) PutOrgMembers(members []*model.OrgMemberView, sequence uint64) error { + err := view.PutOrgMembers(v.Db, orgMemberTable, members...) if err != nil { return err } diff --git a/internal/management/repository/eventsourcing/view/project_grant.go b/internal/management/repository/eventsourcing/view/project_grant.go index d5e0da0c89..f0cdd3330a 100644 --- a/internal/management/repository/eventsourcing/view/project_grant.go +++ b/internal/management/repository/eventsourcing/view/project_grant.go @@ -31,12 +31,20 @@ func (v *View) SearchProjectGrants(request *proj_model.ProjectGrantViewSearchReq return view.SearchProjectGrants(v.Db, grantedProjectTable, request) } -func (v *View) PutProjectGrant(project *model.ProjectGrantView) error { - err := view.PutProjectGrant(v.Db, grantedProjectTable, project) +func (v *View) PutProjectGrant(grant *model.ProjectGrantView) error { + err := view.PutProjectGrant(v.Db, grantedProjectTable, grant) if err != nil { return err } - return v.ProcessedProjectGrantSequence(project.Sequence) + return v.ProcessedProjectGrantSequence(grant.Sequence) +} + +func (v *View) PutProjectGrants(grants []*model.ProjectGrantView, sequence uint64) error { + err := view.PutProjectGrants(v.Db, grantedProjectTable, grants...) + if err != nil { + return err + } + return v.ProcessedProjectGrantSequence(sequence) } func (v *View) DeleteProjectGrant(grantID string, eventSequence uint64) error { diff --git a/internal/management/repository/eventsourcing/view/project_grant_member.go b/internal/management/repository/eventsourcing/view/project_grant_member.go index 95c34d6160..39e9521a77 100644 --- a/internal/management/repository/eventsourcing/view/project_grant_member.go +++ b/internal/management/repository/eventsourcing/view/project_grant_member.go @@ -27,8 +27,16 @@ func (v *View) ProjectGrantMembersByUserID(userID string) ([]*model.ProjectGrant return view.ProjectGrantMembersByUserID(v.Db, projectGrantMemberTable, userID) } -func (v *View) PutProjectGrantMember(project *model.ProjectGrantMemberView, sequence uint64) error { - err := view.PutProjectGrantMember(v.Db, projectGrantMemberTable, project) +func (v *View) PutProjectGrantMember(member *model.ProjectGrantMemberView, sequence uint64) error { + err := view.PutProjectGrantMember(v.Db, projectGrantMemberTable, member) + if err != nil { + return err + } + return v.ProcessedProjectGrantMemberSequence(sequence) +} + +func (v *View) PutProjectGrantMembers(members []*model.ProjectGrantMemberView, sequence uint64) error { + err := view.PutProjectGrantMembers(v.Db, projectGrantMemberTable, members...) if err != nil { return err } diff --git a/internal/management/repository/eventsourcing/view/project_member.go b/internal/management/repository/eventsourcing/view/project_member.go index 206772dab0..717d827d7b 100644 --- a/internal/management/repository/eventsourcing/view/project_member.go +++ b/internal/management/repository/eventsourcing/view/project_member.go @@ -35,6 +35,14 @@ func (v *View) PutProjectMember(project *model.ProjectMemberView, sequence uint6 return v.ProcessedProjectMemberSequence(sequence) } +func (v *View) PutProjectMembers(project []*model.ProjectMemberView, sequence uint64) error { + err := view.PutProjectMembers(v.Db, projectMemberTable, project...) + if err != nil { + return err + } + return v.ProcessedProjectMemberSequence(sequence) +} + func (v *View) DeleteProjectMember(projectID, userID string, eventSequence uint64) error { err := view.DeleteProjectMember(v.Db, projectMemberTable, projectID, userID) if err != nil { diff --git a/internal/management/repository/eventsourcing/view/user_grant.go b/internal/management/repository/eventsourcing/view/user_grant.go index 3b5378acf5..29e3a2d33a 100644 --- a/internal/management/repository/eventsourcing/view/user_grant.go +++ b/internal/management/repository/eventsourcing/view/user_grant.go @@ -47,6 +47,14 @@ func (v *View) PutUserGrant(grant *model.UserGrantView, sequence uint64) error { return v.ProcessedUserGrantSequence(sequence) } +func (v *View) PutUserGrants(grants []*model.UserGrantView, sequence uint64) error { + err := view.PutUserGrants(v.Db, userGrantTable, grants...) + if err != nil { + return err + } + return v.ProcessedUserGrantSequence(sequence) +} + func (v *View) DeleteUserGrant(grantID string, eventSequence uint64) error { err := view.DeleteUserGrant(v.Db, userGrantTable, grantID) if err != nil { diff --git a/internal/org/repository/view/org_domain_view.go b/internal/org/repository/view/org_domain_view.go index 7c0bf14546..55f7724c85 100644 --- a/internal/org/repository/view/org_domain_view.go +++ b/internal/org/repository/view/org_domain_view.go @@ -60,9 +60,18 @@ func OrgDomainsByOrgID(db *gorm.DB, table string, orgID string) ([]*model.OrgDom return domains, nil } -func PutOrgDomain(db *gorm.DB, table string, role *model.OrgDomainView) error { +func PutOrgDomain(db *gorm.DB, table string, domain *model.OrgDomainView) error { save := repository.PrepareSave(table) - return save(db, role) + return save(db, domain) +} + +func PutOrgDomains(db *gorm.DB, table string, domains ...*model.OrgDomainView) error { + save := repository.PrepareBulkSave(table) + d := make([]interface{}, len(domains)) + for i, domain := range domains { + d[i] = domain + } + return save(db, d...) } func DeleteOrgDomain(db *gorm.DB, table, orgID, domain string) error { diff --git a/internal/org/repository/view/org_member_view.go b/internal/org/repository/view/org_member_view.go index 9166c2af66..2d44013662 100644 --- a/internal/org/repository/view/org_member_view.go +++ b/internal/org/repository/view/org_member_view.go @@ -53,6 +53,15 @@ func PutOrgMember(db *gorm.DB, table string, role *model.OrgMemberView) error { return save(db, role) } +func PutOrgMembers(db *gorm.DB, table string, members ...*model.OrgMemberView) error { + save := repository.PrepareBulkSave(table) + m := make([]interface{}, len(members)) + for i, member := range members { + m[i] = member + } + return save(db, m...) +} + func DeleteOrgMember(db *gorm.DB, table, orgID, userID string) error { member, err := OrgMemberByIDs(db, table, orgID, userID) if err != nil { diff --git a/internal/project/repository/view/project_grant_member_view.go b/internal/project/repository/view/project_grant_member_view.go index b78dc0c35d..46b32eb518 100644 --- a/internal/project/repository/view/project_grant_member_view.go +++ b/internal/project/repository/view/project_grant_member_view.go @@ -63,6 +63,15 @@ func PutProjectGrantMember(db *gorm.DB, table string, role *model.ProjectGrantMe return save(db, role) } +func PutProjectGrantMembers(db *gorm.DB, table string, members ...*model.ProjectGrantMemberView) error { + save := repository.PrepareBulkSave(table) + m := make([]interface{}, len(members)) + for i, member := range members { + m[i] = member + } + return save(db, m...) +} + func DeleteProjectGrantMember(db *gorm.DB, table, grantID, userID string) error { grant, err := ProjectGrantMemberByIDs(db, table, grantID, userID) if err != nil { diff --git a/internal/project/repository/view/project_grant_view.go b/internal/project/repository/view/project_grant_view.go index 865033cd3b..3cc1d68520 100644 --- a/internal/project/repository/view/project_grant_view.go +++ b/internal/project/repository/view/project_grant_view.go @@ -63,9 +63,18 @@ func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrant return projectGrants, count, err } -func PutProjectGrant(db *gorm.DB, table string, project *model.ProjectGrantView) error { +func PutProjectGrant(db *gorm.DB, table string, grant *model.ProjectGrantView) error { save := repository.PrepareSave(table) - return save(db, project) + return save(db, grant) +} + +func PutProjectGrants(db *gorm.DB, table string, grants ...*model.ProjectGrantView) error { + save := repository.PrepareBulkSave(table) + g := make([]interface{}, len(grants)) + for i, grant := range grants { + g[i] = grant + } + return save(db, g...) } func DeleteProjectGrant(db *gorm.DB, table, grantID string) error { diff --git a/internal/project/repository/view/project_member_view.go b/internal/project/repository/view/project_member_view.go index f391ed827e..cf26bce3d8 100644 --- a/internal/project/repository/view/project_member_view.go +++ b/internal/project/repository/view/project_member_view.go @@ -62,6 +62,15 @@ func PutProjectMember(db *gorm.DB, table string, role *model.ProjectMemberView) return save(db, role) } +func PutProjectMembers(db *gorm.DB, table string, members ...*model.ProjectMemberView) error { + save := repository.PrepareBulkSave(table) + m := make([]interface{}, len(members)) + for i, member := range members { + m[i] = member + } + return save(db, m...) +} + func DeleteProjectMember(db *gorm.DB, table, projectID, userID string) error { role, err := ProjectMemberByIDs(db, table, projectID, userID) if err != nil { diff --git a/internal/qrcode/readme.md b/internal/qrcode/readme.md index 375eba31a8..ca703abd53 100644 --- a/internal/qrcode/readme.md +++ b/internal/qrcode/readme.md @@ -11,4 +11,4 @@ and not s.Rect(currX, currY, qs.blockSize, qs.blockSize, "fill:black;stroke:none") ``` -This allows the svg to be styled by css more easily and does not compromise Content Security Policy (CSP). \ No newline at end of file +This allows the svg to be styled by css more easily and does not compromise Content Security Policy (CSP). diff --git a/internal/user/repository/view/user_session_view.go b/internal/user/repository/view/user_session_view.go index 7bed501ddd..156a4d705f 100644 --- a/internal/user/repository/view/user_session_view.go +++ b/internal/user/repository/view/user_session_view.go @@ -63,6 +63,15 @@ func PutUserSession(db *gorm.DB, table string, session *model.UserSessionView) e return save(db, session) } +func PutUserSessions(db *gorm.DB, table string, sessions ...*model.UserSessionView) error { + save := repository.PrepareBulkSave(table) + s := make([]interface{}, len(sessions)) + for i, session := range sessions { + s[i] = session + } + return save(db, s...) +} + func DeleteUserSessions(db *gorm.DB, table, userID string) error { delete := repository.PrepareDeleteByKey(table, model.UserSessionSearchKey(usr_model.UserSessionSearchKeyUserID), userID) return delete(db) diff --git a/internal/usergrant/repository/view/user_grant_view.go b/internal/usergrant/repository/view/user_grant_view.go index a0abe433f9..6aa4a7ee69 100644 --- a/internal/usergrant/repository/view/user_grant_view.go +++ b/internal/usergrant/repository/view/user_grant_view.go @@ -129,6 +129,15 @@ func PutUserGrant(db *gorm.DB, table string, grant *model.UserGrantView) error { return save(db, grant) } +func PutUserGrants(db *gorm.DB, table string, grants ...*model.UserGrantView) error { + save := repository.PrepareBulkSave(table) + g := make([]interface{}, len(grants)) + for i, grant := range grants { + g[i] = grant + } + return save(db, g...) +} + func DeleteUserGrant(db *gorm.DB, table, grantID string) error { delete := repository.PrepareDeleteByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID) return delete(db)