From de429a452181c449e795c5a99bb5e44a53708209 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:32:44 +0800 Subject: [PATCH] add revision userid --- internal/entity/revision_entity.go | 2 +- internal/repo/revision/revision_repo.go | 5 +++-- internal/service/revision/revision.go | 2 +- internal/service/revision_service.go | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/entity/revision_entity.go b/internal/entity/revision_entity.go index 46bfd228..b59e7ee5 100644 --- a/internal/entity/revision_entity.go +++ b/internal/entity/revision_entity.go @@ -25,7 +25,7 @@ type Revision struct { Content string `xorm:"not null TEXT content"` Log string `xorm:"VARCHAR(255) log"` Status int `xorm:"not null default 1 INT(11) status"` - ReviewUserID int64 `xorm:"not null default 0 BIGINT(20) review_user_id"` + ReviewUserID string `xorm:"not null default 0 BIGINT(20) review_user_id"` } // TableName revision table name diff --git a/internal/repo/revision/revision_repo.go b/internal/repo/revision/revision_repo.go index 1d5a276f..1c6bca45 100644 --- a/internal/repo/revision/revision_repo.go +++ b/internal/repo/revision/revision_repo.go @@ -81,14 +81,15 @@ func (rr *revisionRepo) UpdateObjectRevisionId(ctx context.Context, revision *en } // UpdateStatus update revision status -func (rr *revisionRepo) UpdateStatus(ctx context.Context, id string, status int) (err error) { +func (rr *revisionRepo) UpdateStatus(ctx context.Context, id string, status int, reviewUserID string) (err error) { if id == "" { return nil } var data entity.Revision data.ID = id data.Status = status - _, err = rr.data.DB.Where("id =?", id).Cols("status").Update(&data) + data.ReviewUserID = reviewUserID + _, err = rr.data.DB.Where("id =?", id).Cols("status", "review_user_id").Update(&data) if err != nil { return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() } diff --git a/internal/service/revision/revision.go b/internal/service/revision/revision.go index f368a27b..7ee32698 100644 --- a/internal/service/revision/revision.go +++ b/internal/service/revision/revision.go @@ -16,5 +16,5 @@ type RevisionRepo interface { UpdateObjectRevisionId(ctx context.Context, revision *entity.Revision, session *xorm.Session) (err error) ExistUnreviewedByObjectID(ctx context.Context, objectID string) (revision *entity.Revision, exist bool, err error) GetUnreviewedRevisionPage(ctx context.Context, page, pageSize int, objectTypes []int) ([]*entity.Revision, int64, error) - UpdateStatus(ctx context.Context, id string, status int) (err error) + UpdateStatus(ctx context.Context, id string, status int, reviewUserID string) (err error) } diff --git a/internal/service/revision_service.go b/internal/service/revision_service.go index 4dfbcbcb..84624cea 100644 --- a/internal/service/revision_service.go +++ b/internal/service/revision_service.go @@ -75,7 +75,7 @@ func (rs *RevisionService) RevisionAudit(ctx context.Context, req *schema.Revisi return } if req.Operation == schema.RevisionAuditReject { - err = rs.revisionRepo.UpdateStatus(ctx, req.ID, entity.RevisionReviewRejectStatus) + err = rs.revisionRepo.UpdateStatus(ctx, req.ID, entity.RevisionReviewRejectStatus, req.UserID) return } if req.Operation == schema.RevisionAuditApprove { @@ -110,7 +110,7 @@ func (rs *RevisionService) RevisionAudit(ctx context.Context, req *schema.Revisi if saveErr != nil { return saveErr } - err = rs.revisionRepo.UpdateStatus(ctx, req.ID, entity.RevisionReviewPassStatus) + err = rs.revisionRepo.UpdateStatus(ctx, req.ID, entity.RevisionReviewPassStatus, req.UserID) return }