add revision userid

This commit is contained in:
aichy126 2022-12-06 14:32:44 +08:00
parent 04a49d2316
commit de429a4521
4 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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()
}

View File

@ -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)
}

View File

@ -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
}