Skip to content

Commit

Permalink
fix: update by cr
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Dec 28, 2023
1 parent 25f539b commit 6e4da90
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
24 changes: 12 additions & 12 deletions pkg/database/dao/mock/subject_group.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/database/dao/mock/subject_template_group.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/database/dao/subject_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ type SubjectGroupManager interface {
FilterGroupPKsHasMemberBeforeExpiredAt(groupPKs []int64, expiredAt int64) ([]int64, error)

BulkCreateWithTx(tx *sqlx.Tx, relations []SubjectRelation) error
BulkDeleteBySubjectPKs(tx *sqlx.Tx, subjectPKs []int64) error
BulkDeleteByGroupPKs(tx *sqlx.Tx, groupPKs []int64) error
BulkDeleteBySubjectPKsWithTx(tx *sqlx.Tx, subjectPKs []int64) error
BulkDeleteByGroupPKsWithTx(tx *sqlx.Tx, groupPKs []int64) error
BulkUpdateExpiredAtWithTx(tx *sqlx.Tx, relations []SubjectRelation) error

ListGroupMember(groupPK int64) ([]SubjectRelation, error)
Expand Down Expand Up @@ -352,16 +352,16 @@ func (m *subjectGroupManager) BulkCreateWithTx(tx *sqlx.Tx, relations []SubjectR
return m.bulkInsertWithTx(tx, relations)
}

// BulkDeleteBySubjectPKs ...
func (m *subjectGroupManager) BulkDeleteBySubjectPKs(tx *sqlx.Tx, subjectPKs []int64) error {
// BulkDeleteBySubjectPKsWithTx ...
func (m *subjectGroupManager) BulkDeleteBySubjectPKsWithTx(tx *sqlx.Tx, subjectPKs []int64) error {
if len(subjectPKs) == 0 {
return nil
}
return m.bulkDeleteBySubjectPKs(tx, subjectPKs)
}

// BulkDeleteByGroupPKs ...
func (m *subjectGroupManager) BulkDeleteByGroupPKs(tx *sqlx.Tx, groupPKs []int64) error {
// BulkDeleteByGroupPKsWithTx ...
func (m *subjectGroupManager) BulkDeleteByGroupPKsWithTx(tx *sqlx.Tx, groupPKs []int64) error {
if len(groupPKs) == 0 {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/database/dao/subject_template_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type SubjectTemplateGroupManager interface {
BulkUpdateExpiredAtWithTx(tx *sqlx.Tx, relations []SubjectTemplateGroup) error
BulkUpdateExpiredAtByRelationWithTx(tx *sqlx.Tx, relations []SubjectRelation) error
BulkDeleteWithTx(tx *sqlx.Tx, relations []SubjectTemplateGroup) error
BulkDeleteBySubjectPKs(tx *sqlx.Tx, subjectPKs []int64) error
BulkDeleteBySubjectPKsWithTx(tx *sqlx.Tx, subjectPKs []int64) error
}

type subjectTemplateGroupManager struct {
Expand Down Expand Up @@ -237,7 +237,7 @@ func (m *subjectTemplateGroupManager) ListThinRelationWithMaxExpiredAtByGroupPK(
return relations, err
}

func (m *subjectTemplateGroupManager) BulkDeleteBySubjectPKs(tx *sqlx.Tx, subjectPKs []int64) error {
func (m *subjectTemplateGroupManager) BulkDeleteBySubjectPKsWithTx(tx *sqlx.Tx, subjectPKs []int64) error {
sql := `DELETE FROM subject_template_group
WHERE subject_pk in (?)`
return database.SqlxDeleteWithTx(tx, sql, subjectPKs)
Expand Down
6 changes: 3 additions & 3 deletions pkg/service/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ func (l *groupService) BulkDeleteByGroupPKsWithTx(tx *sqlx.Tx, groupPKs []int64)
errorWrapf := errorx.NewLayerFunctionErrorWrapf(GroupSVC, "BulkDeleteByGroupPKsWithTx")

// 批量用户组删除成员关系 subjectRelation
err := l.manager.BulkDeleteByGroupPKs(tx, groupPKs)
err := l.manager.BulkDeleteByGroupPKsWithTx(tx, groupPKs)
if err != nil {
return errorWrapf(
err, "manager.BulkDeleteByGroupPKs group_pks=`%+v` fail", groupPKs)
Expand All @@ -893,14 +893,14 @@ func (l *groupService) BulkDeleteBySubjectPKsWithTx(tx *sqlx.Tx, subjectPKs []in
errorWrapf := errorx.NewLayerFunctionErrorWrapf(GroupSVC, "BulkDeleteBySubjectPKsWithTx")

// 批量其加入的用户组关系 subjectRelation
err := l.manager.BulkDeleteBySubjectPKs(tx, subjectPKs)
err := l.manager.BulkDeleteBySubjectPKsWithTx(tx, subjectPKs)
if err != nil {
return errorWrapf(
err, "manager.BulkDeleteBySubjectPKs subject_pks=`%+v` fail", subjectPKs)
}

// 批量删除subject template group
err = l.subjectTemplateGroupManager.BulkDeleteBySubjectPKs(tx, subjectPKs)
err = l.subjectTemplateGroupManager.BulkDeleteBySubjectPKsWithTx(tx, subjectPKs)
if err != nil {
return errorWrapf(
err,
Expand Down
14 changes: 7 additions & 7 deletions pkg/service/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var _ = Describe("GroupService", func() {
It("manager.BulkDeleteBySubjectPKs fail", func() {
mockSubjectService := mock.NewMockSubjectGroupManager(ctl)

mockSubjectService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
errors.New("error"),
).AnyTimes()

Expand All @@ -97,12 +97,12 @@ var _ = Describe("GroupService", func() {
It("manager.BulkDeleteBySubjectPKs fail", func() {
mockSubjectService := mock.NewMockSubjectGroupManager(ctl)

mockSubjectService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
nil,
).AnyTimes()

mockSubjectTemplateGroupService := mock.NewMockSubjectTemplateGroupManager(ctl)
mockSubjectTemplateGroupService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectTemplateGroupService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
errors.New("error"),
).AnyTimes()

Expand All @@ -119,12 +119,12 @@ var _ = Describe("GroupService", func() {
It("subjectSystemGroupManager.DeleteBySubjectPKsWithTx fail", func() {
mockSubjectService := mock.NewMockSubjectGroupManager(ctl)

mockSubjectService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
nil,
).AnyTimes()

mockSubjectTemplateGroupService := mock.NewMockSubjectTemplateGroupManager(ctl)
mockSubjectTemplateGroupService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectTemplateGroupService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
nil,
).AnyTimes()

Expand All @@ -147,12 +147,12 @@ var _ = Describe("GroupService", func() {
It("ok", func() {
mockSubjectService := mock.NewMockSubjectGroupManager(ctl)

mockSubjectService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
nil,
).AnyTimes()

mockSubjectTemplateGroupService := mock.NewMockSubjectTemplateGroupManager(ctl)
mockSubjectTemplateGroupService.EXPECT().BulkDeleteBySubjectPKs(gomock.Any(), []int64{1, 2}).Return(
mockSubjectTemplateGroupService.EXPECT().BulkDeleteBySubjectPKsWithTx(gomock.Any(), []int64{1, 2}).Return(
nil,
).AnyTimes()

Expand Down

0 comments on commit 6e4da90

Please sign in to comment.