feat: add batch content governance actions
This commit is contained in:
@@ -600,6 +600,51 @@ func (s *SuperTestSuite) Test_ContentReview() {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SuperTestSuite) Test_BatchUpdateContentStatus() {
|
||||
Convey("BatchUpdateContentStatus", s.T(), func() {
|
||||
ctx := s.T().Context()
|
||||
database.Truncate(ctx, s.DB, models.TableNameUser, models.TableNameTenant, models.TableNameContent)
|
||||
|
||||
admin := &models.User{Username: "batch_admin"}
|
||||
owner := &models.User{Username: "batch_owner"}
|
||||
models.UserQuery.WithContext(ctx).Create(admin, owner)
|
||||
|
||||
tenant := &models.Tenant{
|
||||
UserID: owner.ID,
|
||||
Name: "Batch Tenant",
|
||||
Code: "batch",
|
||||
Status: consts.TenantStatusVerified,
|
||||
}
|
||||
models.TenantQuery.WithContext(ctx).Create(tenant)
|
||||
|
||||
content1 := &models.Content{
|
||||
TenantID: tenant.ID,
|
||||
UserID: owner.ID,
|
||||
Title: "Batch Content 1",
|
||||
Status: consts.ContentStatusPublished,
|
||||
}
|
||||
content2 := &models.Content{
|
||||
TenantID: tenant.ID,
|
||||
UserID: owner.ID,
|
||||
Title: "Batch Content 2",
|
||||
Status: consts.ContentStatusUnpublished,
|
||||
}
|
||||
models.ContentQuery.WithContext(ctx).Create(content1, content2)
|
||||
|
||||
err := Super.BatchUpdateContentStatus(ctx, admin.ID, &super_dto.SuperContentBatchStatusForm{
|
||||
ContentIDs: []int64{content1.ID, content2.ID},
|
||||
Status: consts.ContentStatusBlocked,
|
||||
Reason: "违规处理",
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
reloaded1, _ := models.ContentQuery.WithContext(ctx).Where(models.ContentQuery.ID.Eq(content1.ID)).First()
|
||||
reloaded2, _ := models.ContentQuery.WithContext(ctx).Where(models.ContentQuery.ID.Eq(content2.ID)).First()
|
||||
So(reloaded1.Status, ShouldEqual, consts.ContentStatusBlocked)
|
||||
So(reloaded2.Status, ShouldEqual, consts.ContentStatusBlocked)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SuperTestSuite) Test_OrderGovernance() {
|
||||
Convey("OrderGovernance", s.T(), func() {
|
||||
ctx := s.T().Context()
|
||||
|
||||
Reference in New Issue
Block a user