MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / ApproveCheck

Method ApproveCheck

internal/service/check.go:45–119  ·  view source on GitHub ↗

ApproveCheck 审核通过

(ctx context.Context, checkID int64, remark string, uid int64)

Source from the content-addressed store, hash-verified

43
44// ApproveCheck 审核通过
45func (s *checkService) ApproveCheck(ctx context.Context, checkID int64, remark string, uid int64) error {
46 // 获取审核详情
47 check, err := s.repo.FindByID(ctx, checkID)
48 if err != nil {
49 s.l.Error("获取审核详情失败", zap.Error(err))
50 return fmt.Errorf("获取审核详情失败: %w", err)
51 }
52
53 // 检查是否已审核
54 if check.Status != domain.UnderReview {
55 s.l.Error("当前审核状态不允许操作", zap.Uint8("status", check.Status))
56 return fmt.Errorf("当前审核状态不允许操作,状态:%v", check.Status)
57 }
58
59 // 更新审核状态为通过
60 if err := s.repo.UpdateStatus(ctx, domain.Check{
61 ID: checkID,
62 Remark: remark,
63 Status: domain.Approved,
64 }); err != nil {
65 s.l.Error("更新审核状态失败",
66 zap.Int64("check_id", checkID),
67 zap.String("remark", remark),
68 zap.Error(err))
69 return fmt.Errorf("更新审核状态失败: %w", err)
70 }
71
72 go func() {
73 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
74 defer cancel()
75
76 expectedTasks := 1
77 if check.BizId == 1 || check.BizId == 2 {
78 expectedTasks++
79 }
80 done := make(chan error, expectedTasks)
81 go func() {
82 if check.BizId == 1 {
83 done <- s.postProducer.ProducePublishEvent(publish.PublishEvent{
84 PostId: check.PostID,
85 Uid: check.Uid,
86 Status: domain.Published,
87 BizId: check.BizId,
88 })
89 } else if check.BizId == 2 {
90 done <- s.commentProducer.ProduceCommentEvent(comment.CommentEvent{
91 PostId: check.PostID,
92 Uid: check.Uid,
93 Status: domain.Published,
94 BizId: check.BizId,
95 })
96 } else {
97 done <- nil
98 }
99 }()
100
101 go func() {
102 done <- s.recordActivity(uid, "审核通过")

Callers

nothing calls this directly

Calls 5

recordActivityMethod · 0.95
FindByIDMethod · 0.65
UpdateStatusMethod · 0.65
ProducePublishEventMethod · 0.65
ProduceCommentEventMethod · 0.65

Tested by

no test coverage detected