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

Method RejectCheck

internal/service/check.go:122–179  ·  view source on GitHub ↗

RejectCheck 审核拒绝

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

Source from the content-addressed store, hash-verified

120
121// RejectCheck 审核拒绝
122func (s *checkService) RejectCheck(ctx context.Context, checkID int64, remark string, uid int64) error {
123 // 获取审核详情
124 check, err := s.repo.FindByID(ctx, checkID)
125 if err != nil {
126 s.l.Error("获取审核详情失败", zap.Error(err))
127 return fmt.Errorf("获取审核详情失败: %w", err)
128 }
129
130 // 检查状态
131 if check.Status != domain.UnderReview {
132 s.l.Error("当前审核状态不允许操作", zap.Uint8("status", check.Status))
133 return fmt.Errorf("当前审核状态不允许操作,状态:%v", check.Status)
134 }
135
136 if err := s.repo.UpdateStatus(ctx, domain.Check{
137 ID: checkID,
138 Remark: remark,
139 Status: domain.UnApproved,
140 }); err != nil {
141 s.l.Error("更新审核状态失败",
142 zap.Int64("check_id", checkID),
143 zap.String("remark", remark),
144 zap.Error(err))
145 return fmt.Errorf("更新审核状态失败: %w", err)
146 }
147
148 go func() {
149 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
150 defer cancel()
151
152 done := make(chan error, 2)
153 go func() {
154 done <- s.postProducer.ProducePublishEvent(publish.PublishEvent{
155 PostId: check.PostID,
156 Uid: check.Uid,
157 Status: domain.Draft,
158 })
159 }()
160
161 go func() {
162 done <- s.recordActivity(uid, "审核拒绝")
163 }()
164
165 for i := 0; i < 2; i++ {
166 select {
167 case err := <-done:
168 if err != nil {
169 s.l.Error("异步任务执行失败", zap.Error(err))
170 }
171 case <-ctx.Done():
172 s.l.Error("异步任务执行超时")
173 return
174 }
175 }
176 }()
177
178 return nil
179}

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected