refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -66,8 +66,7 @@ type PostService interface {
|
||||
IncrementViews(ctx context.Context, postID, userID string) error
|
||||
// RecordShare 记录分享(仅已发布帖子计数 +1),返回最新 shares_count
|
||||
RecordShare(ctx context.Context, postID, userID string) (sharesCount int, err error)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// postServiceImpl 帖子服务实现
|
||||
type postServiceImpl struct {
|
||||
@@ -103,9 +102,9 @@ func (s *postServiceImpl) Create(ctx context.Context, userID, title, content str
|
||||
post := &model.Post{
|
||||
UserID: userID,
|
||||
ChannelID: channelID,
|
||||
Title: title,
|
||||
Content: content,
|
||||
Status: model.PostStatusPending,
|
||||
Title: title,
|
||||
Content: content,
|
||||
Status: model.PostStatusPending,
|
||||
}
|
||||
|
||||
err := s.postRepo.Create(post, images)
|
||||
@@ -166,7 +165,7 @@ func (s *postServiceImpl) reviewPostAsync(postID, userID, title, content string,
|
||||
Content: content,
|
||||
Images: images,
|
||||
AuthorID: authorID,
|
||||
}, map[string]interface{}{
|
||||
}, map[string]any{
|
||||
"result": result,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user