huangguangrong 9 месяцев назад
Родитель
Сommit
5580261726
66 измененных файлов с 1147 добавлено и 768 удалено
  1. 277 295
      api/slow_wild.api
  2. 5 0
      apps/internal/constants/common.go
  3. 4 2
      apps/internal/handler/commentdeletehandler.go
  4. 5 4
      apps/internal/handler/createposthandler.go
  5. 5 4
      apps/internal/handler/finduserhandler.go
  6. 5 4
      apps/internal/handler/followuserhandler.go
  7. 5 4
      apps/internal/handler/getfanshandler.go
  8. 5 4
      apps/internal/handler/getfollowshandler.go
  9. 5 4
      apps/internal/handler/getpostcommentlisthandler.go
  10. 5 4
      apps/internal/handler/getposthandler.go
  11. 5 4
      apps/internal/handler/getpostlisthandler.go
  12. 5 4
      apps/internal/handler/getreplylisthandler.go
  13. 5 4
      apps/internal/handler/gettaghandler.go
  14. 5 4
      apps/internal/handler/gettaglisthandler.go
  15. 5 4
      apps/internal/handler/getuserinfohandler.go
  16. 5 4
      apps/internal/handler/getuserpostcollectionlisthandler.go
  17. 5 4
      apps/internal/handler/getuserpostlikelisthandler.go
  18. 5 4
      apps/internal/handler/getuserpostlisthandler.go
  19. 5 4
      apps/internal/handler/getuserprofilehandler.go
  20. 5 4
      apps/internal/handler/loginhandler.go
  21. 5 4
      apps/internal/handler/postcollectionhandler.go
  22. 5 4
      apps/internal/handler/postcommenthandler.go
  23. 5 4
      apps/internal/handler/postcommentupvotehandler.go
  24. 5 4
      apps/internal/handler/postdeletehandler.go
  25. 5 4
      apps/internal/handler/postreplyhandler.go
  26. 5 4
      apps/internal/handler/postsharehandler.go
  27. 5 4
      apps/internal/handler/postupvotehandler.go
  28. 5 4
      apps/internal/handler/registerhandler.go
  29. 28 0
      apps/internal/handler/routes.go
  30. 5 4
      apps/internal/handler/searchusernamehandler.go
  31. 5 4
      apps/internal/handler/unfollowuserhandler.go
  32. 9 12
      apps/internal/logic/commentdeletelogic.go
  33. 30 3
      apps/internal/logic/createpostlogic.go
  34. 13 3
      apps/internal/logic/finduserlogic.go
  35. 14 3
      apps/internal/logic/followuserlogic.go
  36. 16 3
      apps/internal/logic/getfanslogic.go
  37. 16 3
      apps/internal/logic/getfollowslogic.go
  38. 13 3
      apps/internal/logic/getpostcommentlistlogic.go
  39. 15 3
      apps/internal/logic/getpostlistlogic.go
  40. 11 5
      apps/internal/logic/getpostlogic.go
  41. 13 3
      apps/internal/logic/getreplylistlogic.go
  42. 12 3
      apps/internal/logic/gettaglistlogic.go
  43. 11 3
      apps/internal/logic/gettaglogic.go
  44. 15 3
      apps/internal/logic/getuserinfologic.go
  45. 13 3
      apps/internal/logic/getuserpostcollectionlistlogic.go
  46. 13 3
      apps/internal/logic/getuserpostlikelistlogic.go
  47. 13 3
      apps/internal/logic/getuserpostlistlogic.go
  48. 11 5
      apps/internal/logic/getuserprofilelogic.go
  49. 15 3
      apps/internal/logic/loginlogic.go
  50. 11 3
      apps/internal/logic/postcollectionlogic.go
  51. 16 3
      apps/internal/logic/postcommentlogic.go
  52. 12 3
      apps/internal/logic/postcommentupvotelogic.go
  53. 11 3
      apps/internal/logic/postdeletelogic.go
  54. 16 3
      apps/internal/logic/postreplylogic.go
  55. 11 3
      apps/internal/logic/postsharelogic.go
  56. 11 3
      apps/internal/logic/postupvotelogic.go
  57. 17 3
      apps/internal/logic/registerlogic.go
  58. 16 3
      apps/internal/logic/searchusernamelogic.go
  59. 15 3
      apps/internal/logic/unfollowuserlogic.go
  60. 2 0
      apps/internal/middleware/optionaljwtmiddleware.go
  61. 31 6
      apps/internal/svc/servicecontext.go
  62. 205 223
      apps/internal/types/types.go
  63. 36 0
      apps/internal/utils/ip.go
  64. 0 1
      apps/slowwild.go
  65. 13 14
      go.mod
  66. 22 22
      go.sum

+ 277 - 295
api/slow_wild.api

@@ -6,401 +6,383 @@ info (
 	version: "1.0.0"
 )
 
+type BaseReturnData {
+	Data interface{} `json:"data"`
+}
+
 type (
 	UserEntity {
-		id                   int64  `json:"id"`
-		avatar               string `json:"avatar"`
-		nickname             string `json:"nickname"`
-		username             string `json:"username"`
-		phone                string `json:"phone"`
-		status               int32  `json:"status"`
-		sex                  int32  `json:"sex"`
-		follows              int64  `json:"follows"`
-		followings           int64  `json:"followings"`
-		get_likes_count      int32  `json:"get_likes_count"`
-		get_collection_count int32  `json:"get_collection_count"`
+		Id                 int64  `json:"id"`
+		Avatar             string `json:"avatar"`
+		Nickname           string `json:"nickname"`
+		Username           string `json:"username"`
+		Phone              string `json:"phone"`
+		Status             int32  `json:"status"`
+		Sex                int32  `json:"sex"`
+		Follows            int64  `json:"follows"`
+		Followings         int64  `json:"followings"`
+		GetLikesCount      int32  `json:"get_likes_count"`
+		GetCollectionCount int32  `json:"get_collection_count"`
 	}
 	UserInfo {
-		id       int64  `json:"id"`
-		avatar   string `json:"avatar"`
-		nickname string `json:"nickname"`
-		sex      int32  `json:"sex"`
+		Id       int64  `json:"id"`
+		Avatar   string `json:"avatar"`
+		Nickname string `json:"nickname"`
+		Sex      int32  `json:"sex"`
 	}
 	FollowUserInfo {
-		user             UserInfo `json:"user"`
-		is_mutual_follow bool     `json:"is_mutual_follow"`
+		User           UserInfo `json:"user"`
+		IsMutualFollow bool     `json:"is_mutual_follow"`
 	}
 	LoginAndRegisterRsp {
-		token  string `json:"token"`
-		expire int64  `json:"expire"`
+		Token  string `json:"token"`
+		Expire int64  `json:"expire"`
 	}
 	LoginReq {
-		phone      string `json:"phone"`
-		password   string `json:"password"`
-		code       string `json:"code"`
-		login_type int32  `json:"login_type"`
-		login_ip   string `json:"login_ip"`
+		Phone     string `json:"phone"`
+		Password  string `json:"password"`
+		Code      string `json:"code"`
+		LoginType int32  `json:"login_type"`
+		LoginIp   string `json:"login_ip"`
 	}
 	RegisterReq {
-		phone    string `json:"phone"`
-		nickname string `json:"nickname"`
-		password string `json:"password"`
-		avatar   string `json:"avatar"`
-		sex      int32  `json:"sex"`
-		username string `json:"username"`
-		code     string `json:"code"`
+		Phone    string `json:"phone"`
+		Nickname string `json:"nickname"`
+		Password string `json:"password"`
+		Avatar   string `json:"avatar"`
+		Sex      int32  `json:"sex"`
+		Username string `json:"username"`
+		Code     string `json:"code"`
 	}
 	GetUserInfoReq {
-		user_id       int64 `json:"user_id"`
-		query_user_id int64 `json:"query_user_id"`
+		QueryUserId int64 `json:"query_user_id"`
 	}
 	GetUserInfoResp {
-		id        int64  `json:"id"`
-		avatar    string `json:"avatar"`
-		nickname  string `json:"nickname"`
-		sex       int32  `json:"sex"`
-		is_follow bool   `json:"is_follow"`
+		Id       int64  `json:"id"`
+		Avatar   string `json:"avatar"`
+		Nickname string `json:"nickname"`
+		Sex      int32  `json:"sex"`
+		IsFollow bool   `json:"is_follow"`
 	}
 	FindUserReq {
-		username string  `json:"username"`
-		phone    string  `json:"phone"`
-		ids      []int64 `json:"ids"`
+		Username string  `json:"username"`
+		Phone    string  `json:"phone"`
+		Ids      []int64 `json:"ids"`
 	}
 	FindUserResp {
-		user_list []UserInfo `json:"user_list"`
+		UserList []UserInfo `json:"user_list"`
 	}
 	FollowUserReq {
-		user_id        int64 `json:"user_id"`
-		follow_user_id int64 `json:"follow_user_id"`
+		FollowUserId int64 `json:"follow_user_id"`
 	}
 	FollowUserRes {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	UnFollowUserReq {
-		user_id           int64 `json:"user_id"`
-		un_follow_user_id int64 `json:"un_follow_user_id"`
+		UnFollowUserId int64 `json:"un_follow_user_id"`
 	}
 	UnFollowUserRes {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	GetFollowingReq {
-		user_id       int64 `json:"user_id"`
-		page_size     int32 `json:"page_size"`
-		page          int32 `json:"page"`
-		query_user_id int64 `json:"query_user_id"`
+		PageSize    int32 `json:"page_size"`
+		Page        int32 `json:"page"`
+		QueryUserId int64 `json:"query_user_id"`
 	}
 	GetFollowingRes {
-		list  []FollowUserInfo `json:"list"`
-		total int64            `json:"total"`
+		List  []FollowUserInfo `json:"list"`
+		Total int64            `json:"total"`
 	}
 	GetFollowReq {
-		user_id       int64 `json:"user_id"`
-		page_size     int32 `json:"page_size"`
-		page          int32 `json:"page"`
-		query_user_id int64 `json:"query_user_id"`
+		PageSize    int32 `json:"page_size"`
+		Page        int32 `json:"page"`
+		QueryUserId int64 `json:"query_user_id"`
 	}
 	GetFollowRes {
-		list  []FollowUserInfo `json:"list"`
-		total int64            `json:"total"`
+		List  []FollowUserInfo `json:"list"`
+		Total int64            `json:"total"`
 	}
 	GetUserProfileReq {
-		user_id int64 `json:"user_id"`
+		UserId int64 `json:"user_id"`
 	}
 	GetUserProfileRes {
-		id                   int64  `json:"id"`
-		nickname             string `json:"nickname"`
-		username             string `json:"username"`
-		status               int32  `json:"status"`
-		avatar               string `json:"avatar"`
-		phone                string `json:"phone"`
-		tweet_count          int32  `json:"tweet_count"`
-		is_following         bool   `json:"is_following"`
-		created_on           int64  `json:"created_on"`
-		follows              int64  `json:"follows"`
-		fans                 int64  `json:"fans"`
-		get_likes_count      int32  `json:"get_likes_count"`
-		get_collection_count int32  `json:"get_collection_count"`
-		sex                  int32  `json:"sex"`
+		Id                 int64  `json:"id"`
+		Nickname           string `json:"nickname"`
+		Username           string `json:"username"`
+		Status             int32  `json:"status"`
+		Avatar             string `json:"avatar"`
+		Phone              string `json:"phone"`
+		TweetCount         int32  `json:"tweet_count"`
+		IsFollowing        bool   `json:"is_following"`
+		CreatedOn          int64  `json:"created_on"`
+		Follows            int64  `json:"follows"`
+		Fans               int64  `json:"fans"`
+		GetLikesCount      int32  `json:"get_likes_count"`
+		GetCollectionCount int32  `json:"get_collection_count"`
+		Sex                int32  `json:"sex"`
 	}
 	SearchUsernameReq {
-		keyword   string `json:"keyword"`
-		page      int32  `json:"page"`
-		page_size int32  `json:"page_size"`
-		user_id   int64  `json:"user_id"`
+		Keyword  string `json:"keyword"`
+		Page     int32  `json:"page"`
+		PageSize int32  `json:"page_size"`
+		UserId   int64  `json:"user_id"`
 	}
 	SearchUsernameItem {
-		nickname  string `json:"nickname"`
-		avatar    string `json:"avatar"`
-		id        int64  `json:"id"`
-		sex       int32  `json:"sex"`
-		is_follow bool   `json:"is_follow"`
+		Nickname string `json:"nickname"`
+		Avatar   string `json:"avatar"`
+		Id       int64  `json:"id"`
+		Sex      int32  `json:"sex"`
+		IsFollow bool   `json:"is_follow"`
 	}
 	SearchUsernameRes {
-		list  []SearchUsernameItem `json:"list"`
-		total int64                `json:"total"`
+		List  []SearchUsernameItem `json:"list"`
+		Total int64                `json:"total"`
 	}
 	CreateTag {
-		name string `json:"name"`
-		id   int64  `json:"id"`
+		Name string `json:"name"`
+		Id   int64  `json:"id"`
 	}
 	CreatePostReq {
-		user_id     int64       `json:"user_id"`
-		title       string      `json:"title"`
-		content     string      `json:"content"`
-		tags        []CreateTag `json:"tags"`
-		at_user_ids []int64     `json:"at_user_ids"`
-		post_type   int32       `json:"post_type"`
-		visibility  int32       `json:"visibility"`
-		images      []string    `json:"images"`
-		video_cover string      `json:"video_cover"`
-		video_url   string      `json:"video_url"`
-		ip          string      `json:"ip"`
-		ip_loc      string      `json:"ip_loc"`
+		Title      string      `json:"title"`
+		Content    string      `json:"content"`
+		Tags       []CreateTag `json:"tags"`
+		AtUserIds  []int64     `json:"at_user_ids"`
+		PostType   int32       `json:"post_type"`
+		Visibility int32       `json:"visibility"`
+		Images     []string    `json:"images"`
+		VideoCover string      `json:"video_cover"`
+		VideoUrl   string      `json:"video_url"`
+		Ip         string      `json:"ip"`
+		IpLoc      string      `json:"ip_loc"`
 	}
 	CreatePostRsp {
-		post_id int64 `json:"post_id"`
+		PostId int64 `json:"post_id"`
 	}
 	GetTagListReq {
-		page      int32  `json:"page"`
-		page_size int32  `json:"page_size"`
-		tag_name  string `json:"tag_name"`
-		sort_by   int32  `json:"sort_by"`
+		Page     int32  `json:"page"`
+		PageSize int32  `json:"page_size"`
+		TagName  string `json:"tag_name"`
+		SortBy   int32  `json:"sort_by"`
 	}
 	TagItem {
-		name       string   `json:"name"`
-		hot_num    int64    `json:"hot_num"`
-		user       UserInfo `json:"user"`
-		id         int64    `json:"id"`
-		created_on int64    `json:"created_on"`
+		Name      string   `json:"name"`
+		HotNum    int64    `json:"hot_num"`
+		User      UserInfo `json:"user"`
+		Id        int64    `json:"id"`
+		CreatedOn int64    `json:"created_on"`
 	}
 	GetTagListRsp {
-		tag_list []TagItem `json:"tag_list"`
-		total    int32     `json:"total"`
+		TagList []TagItem `json:"tag_list"`
+		Total   int32     `json:"total"`
 	}
 	GetTagReq {
-		tag_id  int64 `json:"tag_id"`
-		user_id int64 `json:"user_id"`
+		TagId int64 `json:"tag_id"`
 	}
 	GetTagRsp {
-		name         string   `json:"name"`
-		hot_num      int64    `json:"hot_num"`
-		user         UserInfo `json:"user"`
-		id           int64    `json:"id"`
-		created_on   int64    `json:"created_on"`
-		post_count   int64    `json:"post_count"`
-		follow_count int64    `json:"follow_count"`
-		is_followed  bool     `json:"is_followed"`
+		Name        string   `json:"name"`
+		HotNum      int64    `json:"hot_num"`
+		User        UserInfo `json:"user"`
+		Id          int64    `json:"id"`
+		CreatedOn   int64    `json:"created_on"`
+		PostCount   int64    `json:"post_count"`
+		FollowCount int64    `json:"follow_count"`
+		IsFollowed  bool     `json:"is_followed"`
 	}
 	GetPostListReq {
-		page        int32  `json:"page"`
-		page_size   int32  `json:"page_size"`
-		search_type int32  `json:"search_type"`
-		sort_type   int32  `json:"sort_type"`
-		keyword     string `json:"keyword"`
-		user_id     int64  `json:"user_id"`
+		Page       int32  `json:"page"`
+		PageSize   int32  `json:"page_size"`
+		SearchType int32  `json:"search_type"`
+		SortType   int32  `json:"sort_type"`
+		Keyword    string `json:"keyword"`
 	}
 	GetPostListItem {
-		id               int64     `json:"id"`
-		user             UserInfo  `json:"user"`
-		title            string    `json:"title"`
-		content_summary  string    `json:"content_summary"`
-		post_type        int32     `json:"post_type"`
-		comment_count    int64     `json:"comment_count"`
-		upvote_count     int64     `json:"upvote_count"`
-		collection_count int64     `json:"collection_count"`
-		share_count      int64     `json:"share_count"`
-		visibility       int32     `json:"visibility"`
-		ip_loc           string    `json:"ip_loc"`
-		hot_num          int64     `json:"hot_num"`
-		images           []string  `json:"images"`
-		video_url        string    `json:"video_url"`
-		video_cover      string    `json:"video_cover"`
-		created_on       int64     `json:"created_on"`
-		tags             []TagItem `json:"tags"`
-		is_liked         bool      `json:"is_liked"`
-		is_collected     bool      `json:"is_collected"`
-		is_mine          bool      `json:"is_mine"`
+		Id              int64     `json:"id"`
+		User            UserInfo  `json:"user"`
+		Title           string    `json:"title"`
+		ContentSummary  string    `json:"content_summary"`
+		PostYype        int32     `json:"post_type"`
+		CommentCount    int64     `json:"comment_count"`
+		UpvoteCount     int64     `json:"upvote_count"`
+		CollectionCount int64     `json:"collection_count"`
+		ShareCount      int64     `json:"share_count"`
+		Visibility      int32     `json:"visibility"`
+		IpLoc           string    `json:"ip_loc"`
+		HotNum          int64     `json:"hot_num"`
+		Images          []string  `json:"images"`
+		VideoUrl        string    `json:"video_url"`
+		VideoCover      string    `json:"video_cover"`
+		CreatedOn       int64     `json:"created_on"`
+		Tags            []TagItem `json:"tags"`
+		IsLiked         bool      `json:"is_liked"`
+		IsCollected     bool      `json:"is_collected"`
+		IsMine          bool      `json:"is_mine"`
 	}
 	GetPostListRsp {
-		list  []GetPostListItem `json:"list"`
-		total int64             `json:"total"`
+		List  []GetPostListItem `json:"list"`
+		Total int64             `json:"total"`
 	}
 	GetPostReq {
-		user_id int64 `json:"user_id"`
-		post_id int64 `json:"post_id"`
+		PostId int64 `json:"post_id"`
 	}
 	GetPostRsp {
-		id                int64      `json:"id"`
-		user              UserInfo   `json:"user"`
-		title             string     `json:"title"`
-		content_summary   string     `json:"content_summary"`
-		post_type         int32      `json:"post_type"`
-		comment_count     int64      `json:"comment_count"`
-		upvote_count      int64      `json:"upvote_count"`
-		collection_count  int64      `json:"collection_count"`
-		share_count       int64      `json:"share_count"`
-		visibility        int32      `json:"visibility"`
-		ip_loc            string     `json:"ip_loc"`
-		hot_num           int64      `json:"hot_num"`
-		images            []string   `json:"images"`
-		video_url         string     `json:"video_url"`
-		video_cover       string     `json:"video_cover"`
-		content           string     `json:"content"`
-		created_on        int64      `json:"created_on"`
-		tags              []TagItem  `json:"tags"`
-		with_user         []UserInfo `json:"with_user"`
-		latest_replied_on int64      `json:"latest_replied_on"`
-		is_liked          bool       `json:"is_liked"`
-		is_collected      bool       `json:"is_collected"`
-		is_mine           bool       `json:"is_mine"`
+		Id              int64      `json:"id"`
+		User            UserInfo   `json:"user"`
+		Title           string     `json:"title"`
+		ContentSummary  string     `json:"content_summary"`
+		PostYype        int32      `json:"post_type"`
+		CommentCount    int64      `json:"comment_count"`
+		UpvoteCount     int64      `json:"upvote_count"`
+		CollectionCount int64      `json:"collection_count"`
+		ShareCount      int64      `json:"share_count"`
+		Visibility      int32      `json:"visibility"`
+		IpLoc           string     `json:"ip_loc"`
+		HotNum          int64      `json:"hot_num"`
+		Images          []string   `json:"images"`
+		VideoUrl        string     `json:"video_url"`
+		VideoCover      string     `json:"video_cover"`
+		Content         string     `json:"content"`
+		CreatedOn       int64      `json:"created_on"`
+		Tags            []TagItem  `json:"tags"`
+		WithUser        []UserInfo `json:"with_user"`
+		LatestRepliedOn int64      `json:"latest_replied_on"`
+		IsLiked         bool       `json:"is_liked"`
+		IsCollected     bool       `json:"is_collected"`
+		IsMine          bool       `json:"is_mine"`
 	}
 	PostUpvoteReq {
-		post_id int64 `json:"post_id"`
-		user_id int64 `json:"user_id"`
+		PostId int64 `json:"post_id"`
 	}
 	PostUpvoteRsp {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	PostCollectionReq {
-		post_id int64 `json:"post_id"`
-		user_id int64 `json:"user_id"`
+		PostId int64 `json:"post_id"`
 	}
 	PostCollectionRsp {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	PostShareReq {
-		post_id int64 `json:"post_id"`
-		user_id int64 `json:"user_id"`
+		PostId int64 `json:"post_id"`
 	}
 	PostShareRsp {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	PostCommentReq {
-		post_id    int64  `json:"post_id"`
-		user_id    int64  `json:"user_id"`
-		content    string `json:"content"`
-		image      string `json:"image"`
-		at_user_id int64  `json:"at_user_id"`
-		ip         string `json:"ip"`
-		ip_loc     string `json:"ip_loc"`
+		PostId   int64  `json:"post_id"`
+		Content  string `json:"content"`
+		Image    string `json:"image"`
+		AtUserId int64  `json:"at_user_id"`
+		Ip       string `json:"ip"`
+		IpLoc    string `json:"ip_loc"`
 	}
 	PostCommentRsp {
-		comment_id int64 `json:"comment_id"`
+		CommentId int64 `json:"comment_id"`
 	}
 	PostReplyReq {
-		post_id     int64  `json:"post_id"`
-		user_id     int64  `json:"user_id"`
-		content     string `json:"content"`
-		image       string `json:"image"`
-		at_user_id  int64  `json:"at_user_id"`
-		ip          string `json:"ip"`
-		ip_loc      string `json:"ip_loc"`
-		comment_id  int64  `json:"comment_id"`
-		to_reply_id int64  `json:"to_reply_id"`
+		PostId    int64  `json:"post_id"`
+		Content   string `json:"content"`
+		Image     string `json:"image"`
+		AtUserId  int64  `json:"at_user_id"`
+		Ip        string `json:"ip"`
+		IpLoc     string `json:"ip_loc"`
+		CommentId int64  `json:"comment_id"`
+		ToReplyId int64  `json:"to_reply_id"`
 	}
 	PostReplyRsp {
-		reply_id int64 `json:"reply_id"`
+		ReplyId int64 `json:"reply_id"`
 	}
 	GetPostCommentListReq {
-		page      int32 `json:"page"`
-		page_size int32 `json:"page_size"`
-		post_id   int64 `json:"post_id"`
-		user_id   int64 `json:"user_id"`
+		Page     int32 `json:"page"`
+		PageSize int32 `json:"page_size"`
+		PostId   int64 `json:"post_id"`
 	}
 	RepliesItem {
-		id           int64      `json:"id"`
-		post_id      int64      `json:"post_id"`
-		user         UserInfo   `json:"user"`
-		ip_loc       string     `json:"ip_loc"`
-		content      string     `json:"content"`
-		image        string     `json:"image"`
-		with_user    []UserInfo `json:"with_user"`
-		upvote_count int64      `json:"upvote_count"`
-		is_liked     bool       `json:"is_liked"`
-		is_mine      bool       `json:"is_mine"`
-		created_on   int64      `json:"created_on"`
+		Id          int64      `json:"id"`
+		PostId      int64      `json:"post_id"`
+		User        UserInfo   `json:"user"`
+		IpLoc       string     `json:"ip_loc"`
+		Content     string     `json:"content"`
+		Image       string     `json:"image"`
+		WithUser    []UserInfo `json:"with_user"`
+		UpvoteCount int64      `json:"upvote_count"`
+		IsLiked     bool       `json:"is_liked"`
+		IsMine      bool       `json:"is_mine"`
+		CreatedOn   int64      `json:"created_on"`
 	}
 	CommentItem {
-		id           int64         `json:"id"`
-		post_id      int64         `json:"post_id"`
-		user         UserInfo      `json:"user"`
-		ip_loc       string        `json:"ip_loc"`
-		content      string        `json:"content"`
-		image        string        `json:"image"`
-		with_user    []UserInfo    `json:"with_user"`
-		reply_count  int64         `json:"reply_count"`
-		upvote_count int64         `json:"upvote_count"`
-		reply_item   []RepliesItem `json:"reply_item"`
-		is_liked     bool          `json:"is_liked"`
-		is_mine      bool          `json:"is_mine"`
-		created_on   int64         `json:"created_on"`
+		Id          int64         `json:"id"`
+		PostId      int64         `json:"post_id"`
+		User        UserInfo      `json:"user"`
+		IpLoc       string        `json:"ip_loc"`
+		Content     string        `json:"content"`
+		Image       string        `json:"image"`
+		WithUser    []UserInfo    `json:"with_user"`
+		ReplyCount  int64         `json:"reply_count"`
+		UpvoteCount int64         `json:"upvote_count"`
+		ReplyItem   []RepliesItem `json:"reply_item"`
+		IsLiked     bool          `json:"is_liked"`
+		IsMine      bool          `json:"is_mine"`
+		CreatedOn   int64         `json:"created_on"`
 	}
 	GetPostCommentListRsp {
-		list  []CommentItem `json:"list"`
-		total int64         `json:"total"`
+		List  []CommentItem `json:"list"`
+		Total int64         `json:"total"`
 	}
 	GetReplyListReq {
-		page       int32 `json:"page"`
-		page_size  int32 `json:"page_size"`
-		comment_id int64 `json:"comment_id"`
-		user_id    int64 `json:"user_id"`
+		Page      int32 `json:"page"`
+		PageSize  int32 `json:"page_size"`
+		CommentId int64 `json:"comment_id"`
 	}
 	GetReplyListRsp {
-		list  []RepliesItem `json:"list"`
-		total int64         `json:"total"`
+		List  []RepliesItem `json:"list"`
+		Total int64         `json:"total"`
 	}
 	PostCommentUpvoteReq {
-		user_id      int64 `json:"user_id"`
-		comment_id   int64 `json:"comment_id"`
-		comment_type int32 `json:"comment_type"`
+		CommentId   int64 `json:"comment_id"`
+		CommentType int32 `json:"comment_type"`
 	}
 	PostCommentUpvoteRsp {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	PostDeleteReq {
-		user_id int64 `json:"user_id"`
-		post_id int64 `json:"post_id"`
+		PostId int64 `json:"post_id"`
 	}
 	PostDeleteRsp {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	CommentDeleteReq {
-		user_id      int64 `json:"user_id"`
-		comment_id   int64 `json:"comment_id"`
-		comment_type int32 `json:"comment_type"`
+		CommentId   int64 `json:"comment_id"`
+		CommentType int32 `json:"comment_type"`
 	}
 	CommentDeleteRsp {
-		success bool `json:"success"`
+		Success bool `json:"success"`
 	}
 	GetUserPostListReq {
-		user_id       int64 `json:"user_id"`
-		page          int64 `json:"page"`
-		page_size     int64 `json:"page_size"`
-		query_user_id int64 `json:"query_user_id"`
+		Page        int64 `json:"page"`
+		PageSize    int64 `json:"page_size"`
+		QueryUserId int64 `json:"query_user_id"`
 	}
 	GetUserPostListRsp {
-		list  []GetPostListItem `json:"list"`
-		total int64             `json:"total"`
+		List  []GetPostListItem `json:"list"`
+		Total int64             `json:"total"`
 	}
 	GetUserPostCollectionListReq {
-		user_id       int64 `json:"user_id"`
-		page          int64 `json:"page"`
-		page_size     int64 `json:"page_size"`
-		query_user_id int64 `json:"query_user_id"`
+		Page        int64 `json:"page"`
+		PageSize    int64 `json:"page_size"`
+		QueryUserId int64 `json:"query_user_id"`
 	}
 	GetUserPostCollectionListRsp {
-		list  []GetPostListItem `json:"list"`
-		total int64             `json:"total"`
+		List  []GetPostListItem `json:"list"`
+		Total int64             `json:"total"`
 	}
 	GetUserPostLikeListReq {
-		user_id       int64 `json:"user_id"`
-		page          int64 `json:"page"`
-		page_size     int64 `json:"page_size"`
-		query_user_id int64 `json:"query_user_id"`
+		Page        int64 `json:"page"`
+		PageSize    int64 `json:"page_size"`
+		QueryUserId int64 `json:"query_user_id"`
 	}
 	GetUserPostLikeListRsp {
-		list  []GetPostListItem `json:"list"`
-		total int64             `json:"total"`
+		List  []GetPostListItem `json:"list"`
+		Total int64             `json:"total"`
 	}
 )
 
@@ -410,11 +392,11 @@ type (
 service slowwild {
 	@doc "登录方法"
 	@handler login
-	post /api/user/login (LoginReq) returns (LoginAndRegisterRsp)
+	post /api/user/login (LoginReq) returns (BaseReturnData)
 
 	@doc "用户注册"
 	@handler register
-	post /api/user/register (RegisterReq) returns (LoginAndRegisterRsp)
+	post /api/user/register (RegisterReq) returns (BaseReturnData)
 }
 
 @server (
@@ -424,35 +406,35 @@ service slowwild {
 service slowwild {
 	@doc "获取用户信息"
 	@handler getUserInfo
-	get /api/user/info (GetUserInfoReq) returns (GetUserInfoResp)
+	get /api/user/info (GetUserInfoReq) returns (BaseReturnData)
 
 	@doc "查询用户"
 	@handler findUser
-	post /api/user/find (FindUserReq) returns (FindUserResp)
+	post /api/user/find (FindUserReq) returns (BaseReturnData)
 
 	@doc "关注用户"
 	@handler followUser
-	post /api/user/follow (FollowUserReq) returns (FollowUserRes)
+	post /api/user/follow (FollowUserReq) returns (BaseReturnData)
 
 	@doc "取消关注用户"
 	@handler unfollowUser
-	post /api/user/unfollow (UnFollowUserReq) returns (UnFollowUserRes)
+	post /api/user/unfollow (UnFollowUserReq) returns (BaseReturnData)
 
 	@doc "获取粉丝"
 	@handler getFans
-	get /api/user/fans (GetFollowingReq) returns (GetFollowingRes)
+	get /api/user/fans (GetFollowingReq) returns (BaseReturnData)
 
 	@doc "获取关注列表"
 	@handler getFollows
-	get /api/user/follows (GetFollowReq) returns (GetFollowRes)
+	get /api/user/follows (GetFollowReq) returns (BaseReturnData)
 
 	@doc "获取用户信息"
 	@handler getUserProfile
-	get /api/user/profile (GetUserProfileReq) returns (GetUserProfileRes)
+	get /api/user/profile (GetUserProfileReq) returns (BaseReturnData)
 
 	@doc "搜索用户"
 	@handler searchUsername
-	get /api/user/search (SearchUsernameReq) returns (SearchUsernameRes)
+	get /api/user/search (SearchUsernameReq) returns (BaseReturnData)
 }
 
 @server (
@@ -462,39 +444,39 @@ service slowwild {
 service slowwild {
 	@doc "创建帖子"
 	@handler createPost
-	post /api/post/create (CreatePostReq) returns (CreatePostRsp)
+	post /api/post/create (CreatePostReq) returns (BaseReturnData)
 
 	@doc "帖子点赞"
 	@handler postUpvote
-	post /api/post/upvote (PostUpvoteReq) returns (PostUpvoteRsp)
+	post /api/post/upvote (PostUpvoteReq) returns (BaseReturnData)
 
 	@doc "帖子收藏"
 	@handler postCollection
-	post /api/post/collection (PostCollectionReq) returns (PostCollectionRsp)
+	post /api/post/collection (PostCollectionReq) returns (BaseReturnData)
 
 	@doc "帖子分享"
 	@handler postShare
-	post /api/post/share (PostShareReq) returns (PostShareRsp)
+	post /api/post/share (PostShareReq) returns (BaseReturnData)
 
 	@doc "发布评论"
 	@handler postComment
-	post /api/post/comment (PostCommentReq) returns (PostCommentRsp)
+	post /api/post/comment (PostCommentReq) returns (BaseReturnData)
 
 	@doc "回复评论"
 	@handler postReply
-	post /api/post/reply (PostReplyReq) returns (PostReplyRsp)
+	post /api/post/reply (PostReplyReq) returns (BaseReturnData)
 
 	@doc "评论点赞"
 	@handler postCommentUpvote
-	post /api/post/comment/upvote (PostCommentUpvoteReq) returns (PostCommentUpvoteRsp)
+	post /api/post/comment/upvote (PostCommentUpvoteReq) returns (BaseReturnData)
 
 	@doc "帖子删除"
 	@handler postDelete
-	post /api/post/delete (PostDeleteReq) returns (PostDeleteRsp)
+	post /api/post/delete (PostDeleteReq) returns (BaseReturnData)
 
 	@doc "评论删除"
 	@handler commentDelete
-	post /api/comment/delete (CommentDeleteReq) returns (CommentDeleteRsp)
+	post /api/comment/delete (CommentDeleteReq) returns (BaseReturnData)
 }
 
 @server (
@@ -504,38 +486,38 @@ service slowwild {
 service slowwild {
 	@doc "获取话题列表"
 	@handler getTagList
-	get /api/tag/list (GetTagListReq) returns (GetTagListRsp)
+	get /api/tag/list (GetTagListReq) returns (BaseReturnData)
 
 	@doc "获取话题详情"
 	@handler getTag
-	get /api/tag (GetTagReq) returns (GetTagRsp)
+	get /api/tag (GetTagReq) returns (BaseReturnData)
 
 	@doc "获取帖子列表"
 	@handler getPostList
-	get /api/post/list (GetPostListReq) returns (GetPostListRsp)
+	get /api/post/list (GetPostListReq) returns (BaseReturnData)
 
 	@doc "获取帖子详情"
 	@handler getPost
-	get /api/post (GetPostReq) returns (GetPostRsp)
+	get /api/post (GetPostReq) returns (BaseReturnData)
 
 	@doc "获取评论列表"
 	@handler getPostCommentList
-	get /api/post/comment/list (GetPostCommentListReq) returns (GetPostCommentListRsp)
+	get /api/post/comment/list (GetPostCommentListReq) returns (BaseReturnData)
 
 	@doc "获取回复列表"
 	@handler getReplyList
-	get /api/post/reply/list (GetReplyListReq) returns (GetReplyListRsp)
+	get /api/post/reply/list (GetReplyListReq) returns (BaseReturnData)
 
 	@doc "获取用户发布的帖子列表"
 	@handler getUserPostList
-	get /api/user/post/list (GetUserPostListReq) returns (GetUserPostListRsp)
+	get /api/user/post/list (GetUserPostListReq) returns (BaseReturnData)
 
 	@doc "获取用户收藏的帖子列表"
 	@handler getUserPostCollectionList
-	get /api/user/post/collection/list (GetUserPostCollectionListReq) returns (GetUserPostCollectionListRsp)
+	get /api/user/post/collection/list (GetUserPostCollectionListReq) returns (BaseReturnData)
 
 	@doc "获取用户点赞的帖子列表"
 	@handler getUserPostLikeList
-	get /api/user/post/like/list (GetUserPostLikeListReq) returns (GetUserPostLikeListRsp)
+	get /api/user/post/like/list (GetUserPostLikeListReq) returns (BaseReturnData)
 }
 

+ 5 - 0
apps/internal/constants/common.go

@@ -0,0 +1,5 @@
+package constants
+
+const (
+	UserIdKey = "user_id"
+)

+ 4 - 2
apps/internal/handler/commentdeletehandler.go

@@ -1,19 +1,21 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 评论删除
 func commentDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.CommentDeleteReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 

+ 5 - 4
apps/internal/handler/createposthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 创建帖子
 func createPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.CreatePostReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewCreatePostLogic(r.Context(), svcCtx)
 		resp, err := l.CreatePost(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/finduserhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 查询用户
 func findUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.FindUserReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewFindUserLogic(r.Context(), svcCtx)
 		resp, err := l.FindUser(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/followuserhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 关注用户
 func followUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.FollowUserReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewFollowUserLogic(r.Context(), svcCtx)
 		resp, err := l.FollowUser(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getfanshandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取粉丝
 func getFansHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetFollowingReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetFansLogic(r.Context(), svcCtx)
 		resp, err := l.GetFans(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getfollowshandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取关注列表
 func getFollowsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetFollowReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetFollowsLogic(r.Context(), svcCtx)
 		resp, err := l.GetFollows(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getpostcommentlisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取评论列表
 func getPostCommentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetPostCommentListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetPostCommentListLogic(r.Context(), svcCtx)
 		resp, err := l.GetPostCommentList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getposthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取帖子详情
 func getPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetPostReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetPostLogic(r.Context(), svcCtx)
 		resp, err := l.GetPost(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getpostlisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取帖子列表
 func getPostListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetPostListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetPostListLogic(r.Context(), svcCtx)
 		resp, err := l.GetPostList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getreplylisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取回复列表
 func getReplyListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetReplyListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetReplyListLogic(r.Context(), svcCtx)
 		resp, err := l.GetReplyList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/gettaghandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取话题详情
 func getTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetTagReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetTagLogic(r.Context(), svcCtx)
 		resp, err := l.GetTag(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/gettaglisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取话题列表
 func getTagListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetTagListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetTagListLogic(r.Context(), svcCtx)
 		resp, err := l.GetTagList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getuserinfohandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取用户信息
 func getUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetUserInfoReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetUserInfoLogic(r.Context(), svcCtx)
 		resp, err := l.GetUserInfo(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getuserpostcollectionlisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取用户收藏的帖子列表
 func getUserPostCollectionListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetUserPostCollectionListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetUserPostCollectionListLogic(r.Context(), svcCtx)
 		resp, err := l.GetUserPostCollectionList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getuserpostlikelisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取用户点赞的帖子列表
 func getUserPostLikeListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetUserPostLikeListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetUserPostLikeListLogic(r.Context(), svcCtx)
 		resp, err := l.GetUserPostLikeList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getuserpostlisthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取用户发布的帖子列表
 func getUserPostListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetUserPostListReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetUserPostListLogic(r.Context(), svcCtx)
 		resp, err := l.GetUserPostList(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/getuserprofilehandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 获取用户信息
 func getUserProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.GetUserProfileReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewGetUserProfileLogic(r.Context(), svcCtx)
 		resp, err := l.GetUserProfile(&req)
-		response.Response(w, resp, err) 
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/loginhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 登录方法
 func loginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.LoginReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewLoginLogic(r.Context(), svcCtx)
 		resp, err := l.Login(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postcollectionhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 帖子收藏
 func postCollectionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostCollectionReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostCollectionLogic(r.Context(), svcCtx)
 		resp, err := l.PostCollection(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postcommenthandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 发布评论
 func postCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostCommentReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostCommentLogic(r.Context(), svcCtx)
 		resp, err := l.PostComment(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postcommentupvotehandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 评论点赞
 func postCommentUpvoteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostCommentUpvoteReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostCommentUpvoteLogic(r.Context(), svcCtx)
 		resp, err := l.PostCommentUpvote(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postdeletehandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 帖子删除
 func postDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostDeleteReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostDeleteLogic(r.Context(), svcCtx)
 		resp, err := l.PostDelete(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postreplyhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 回复评论
 func postReplyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostReplyReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostReplyLogic(r.Context(), svcCtx)
 		resp, err := l.PostReply(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postsharehandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 帖子分享
 func postShareHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostShareReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostShareLogic(r.Context(), svcCtx)
 		resp, err := l.PostShare(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/postupvotehandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 帖子点赞
 func postUpvoteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.PostUpvoteReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewPostUpvoteLogic(r.Context(), svcCtx)
 		resp, err := l.PostUpvote(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/registerhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 用户注册
 func registerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.RegisterReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewRegisterLogic(r.Context(), svcCtx)
 		resp, err := l.Register(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 28 - 0
apps/internal/handler/routes.go

@@ -13,11 +13,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	server.AddRoutes(
 		[]rest.Route{
 			{
+				// 登录方法
 				Method:  http.MethodPost,
 				Path:    "/api/user/login",
 				Handler: loginHandler(serverCtx),
 			},
 			{
+				// 用户注册
 				Method:  http.MethodPost,
 				Path:    "/api/user/register",
 				Handler: registerHandler(serverCtx),
@@ -28,41 +30,49 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	server.AddRoutes(
 		[]rest.Route{
 			{
+				// 获取粉丝
 				Method:  http.MethodGet,
 				Path:    "/api/user/fans",
 				Handler: getFansHandler(serverCtx),
 			},
 			{
+				// 查询用户
 				Method:  http.MethodPost,
 				Path:    "/api/user/find",
 				Handler: findUserHandler(serverCtx),
 			},
 			{
+				// 关注用户
 				Method:  http.MethodPost,
 				Path:    "/api/user/follow",
 				Handler: followUserHandler(serverCtx),
 			},
 			{
+				// 获取关注列表
 				Method:  http.MethodGet,
 				Path:    "/api/user/follows",
 				Handler: getFollowsHandler(serverCtx),
 			},
 			{
+				// 获取用户信息
 				Method:  http.MethodGet,
 				Path:    "/api/user/info",
 				Handler: getUserInfoHandler(serverCtx),
 			},
 			{
+				// 获取用户信息
 				Method:  http.MethodGet,
 				Path:    "/api/user/profile",
 				Handler: getUserProfileHandler(serverCtx),
 			},
 			{
+				// 搜索用户
 				Method:  http.MethodGet,
 				Path:    "/api/user/search",
 				Handler: searchUsernameHandler(serverCtx),
 			},
 			{
+				// 取消关注用户
 				Method:  http.MethodPost,
 				Path:    "/api/user/unfollow",
 				Handler: unfollowUserHandler(serverCtx),
@@ -74,46 +84,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	server.AddRoutes(
 		[]rest.Route{
 			{
+				// 评论删除
 				Method:  http.MethodPost,
 				Path:    "/api/comment/delete",
 				Handler: commentDeleteHandler(serverCtx),
 			},
 			{
+				// 帖子收藏
 				Method:  http.MethodPost,
 				Path:    "/api/post/collection",
 				Handler: postCollectionHandler(serverCtx),
 			},
 			{
+				// 发布评论
 				Method:  http.MethodPost,
 				Path:    "/api/post/comment",
 				Handler: postCommentHandler(serverCtx),
 			},
 			{
+				// 评论点赞
 				Method:  http.MethodPost,
 				Path:    "/api/post/comment/upvote",
 				Handler: postCommentUpvoteHandler(serverCtx),
 			},
 			{
+				// 创建帖子
 				Method:  http.MethodPost,
 				Path:    "/api/post/create",
 				Handler: createPostHandler(serverCtx),
 			},
 			{
+				// 帖子删除
 				Method:  http.MethodPost,
 				Path:    "/api/post/delete",
 				Handler: postDeleteHandler(serverCtx),
 			},
 			{
+				// 回复评论
 				Method:  http.MethodPost,
 				Path:    "/api/post/reply",
 				Handler: postReplyHandler(serverCtx),
 			},
 			{
+				// 帖子分享
 				Method:  http.MethodPost,
 				Path:    "/api/post/share",
 				Handler: postShareHandler(serverCtx),
 			},
 			{
+				// 帖子点赞
 				Method:  http.MethodPost,
 				Path:    "/api/post/upvote",
 				Handler: postUpvoteHandler(serverCtx),
@@ -127,46 +146,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			[]rest.Middleware{serverCtx.OptionalJwtMiddleware},
 			[]rest.Route{
 				{
+					// 获取帖子详情
 					Method:  http.MethodGet,
 					Path:    "/api/post",
 					Handler: getPostHandler(serverCtx),
 				},
 				{
+					// 获取评论列表
 					Method:  http.MethodGet,
 					Path:    "/api/post/comment/list",
 					Handler: getPostCommentListHandler(serverCtx),
 				},
 				{
+					// 获取帖子列表
 					Method:  http.MethodGet,
 					Path:    "/api/post/list",
 					Handler: getPostListHandler(serverCtx),
 				},
 				{
+					// 获取回复列表
 					Method:  http.MethodGet,
 					Path:    "/api/post/reply/list",
 					Handler: getReplyListHandler(serverCtx),
 				},
 				{
+					// 获取话题详情
 					Method:  http.MethodGet,
 					Path:    "/api/tag",
 					Handler: getTagHandler(serverCtx),
 				},
 				{
+					// 获取话题列表
 					Method:  http.MethodGet,
 					Path:    "/api/tag/list",
 					Handler: getTagListHandler(serverCtx),
 				},
 				{
+					// 获取用户收藏的帖子列表
 					Method:  http.MethodGet,
 					Path:    "/api/user/post/collection/list",
 					Handler: getUserPostCollectionListHandler(serverCtx),
 				},
 				{
+					// 获取用户点赞的帖子列表
 					Method:  http.MethodGet,
 					Path:    "/api/user/post/like/list",
 					Handler: getUserPostLikeListHandler(serverCtx),
 				},
 				{
+					// 获取用户发布的帖子列表
 					Method:  http.MethodGet,
 					Path:    "/api/user/post/list",
 					Handler: getUserPostListHandler(serverCtx),

+ 5 - 4
apps/internal/handler/searchusernamehandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 搜索用户
 func searchUsernameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.SearchUsernameReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewSearchUsernameLogic(r.Context(), svcCtx)
 		resp, err := l.SearchUsername(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 5 - 4
apps/internal/handler/unfollowuserhandler.go

@@ -1,25 +1,26 @@
 package handler
 
 import (
-	"github.com/zeromicro/go-zero/rest/httpx"
 	"net/http"
 	"slow_wild_api/apps/internal/logic"
 	"slow_wild_api/apps/internal/response"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
 )
 
+// 取消关注用户
 func unfollowUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		var req types.UnFollowUserReq
 		if err := httpx.Parse(r, &req); err != nil {
-			httpx.Error(w, err)
+			httpx.ErrorCtx(r.Context(), w, err)
 			return
 		}
 
 		l := logic.NewUnfollowUserLogic(r.Context(), svcCtx)
 		resp, err := l.UnfollowUser(&req)
-		response.Response(w, resp, err) //②
-
+		response.Response(w, resp, err)
 	}
 }

+ 9 - 12
apps/internal/logic/commentdeletelogic.go

@@ -16,6 +16,7 @@ type CommentDeleteLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 评论删除
 func NewCommentDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentDeleteLogic {
 	return &CommentDeleteLogic{
 		Logger: logx.WithContext(ctx),
@@ -24,19 +25,15 @@ func NewCommentDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Com
 	}
 }
 
-func (l *CommentDeleteLogic) CommentDelete(req *types.CommentDeleteReq) (resp *types.CommentDeleteRsp, err error) {
-	resp = &types.CommentDeleteRsp{
-		Success: false,
-	}
-	res, dErr := l.svcCtx.SlowWildPb.CommentDelete(l.ctx, &slowwildserver.CommentDeleteReq{
-		CommentId:   req.Comment_id,
-		CommentType: req.Comment_type,
+func (l *CommentDeleteLogic) CommentDelete(req *types.CommentDeleteReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.CommentDelete(l.ctx, &slowwildserver.CommentDeleteReq{
+		CommentId:   req.CommentId,
+		CommentType: req.CommentType,
 	})
-	if dErr != nil {
-		return nil, dErr
-	}
-	if res.Success {
-		resp.Success = true
+	if err != nil {
+		return nil, err
 	}
+	resp.Data = rpcResp
 	return
 }

+ 30 - 3
apps/internal/logic/createpostlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type CreatePostLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 创建帖子
 func NewCreatePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePostLogic {
 	return &CreatePostLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,33 @@ func NewCreatePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
 	}
 }
 
-func (l *CreatePostLogic) CreatePost(req *types.CreatePostReq) (resp *types.CreatePostRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *CreatePostLogic) CreatePost(req *types.CreatePostReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	var tags []*slowwildserver.CreateTag
+	if len(req.Tags) > 0 {
+		for _, tag := range req.Tags {
+			tags = append(tags, &slowwildserver.CreateTag{
+				Id:   tag.Id,
+				Name: tag.Name,
+			})
+		}
+	}
+	rpcResp, err := l.svcCtx.SlowWildPb.CreatePost(l.ctx, &slowwildserver.CreatePostReq{
+		Title:      req.Title,
+		Content:    req.Content,
+		Tags:       tags,
+		AtUserIds:  req.AtUserIds,
+		Type:       req.PostType,
+		Visibility: req.Visibility,
+		Images:     req.Images,
+		VideoCover: req.VideoCover,
+		VideoUrl:   req.VideoUrl,
+		Ip:         req.Ip,
+		IpLoc:      req.IpLoc,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 13 - 3
apps/internal/logic/finduserlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type FindUserLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 查询用户
 func NewFindUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindUserLogic {
 	return &FindUserLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,16 @@ func NewFindUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindUser
 	}
 }
 
-func (l *FindUserLogic) FindUser(req *types.FindUserReq) (resp *types.FindUserResp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *FindUserLogic) FindUser(req *types.FindUserReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.FindUser(l.ctx, &slowwildserver.FindUserReq{
+		Phone:    req.Phone,
+		Username: req.Username,
+		Ids:      req.Ids,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 14 - 3
apps/internal/logic/followuserlogic.go

@@ -3,9 +3,11 @@ package logic
 import (
 	"context"
 
+	"slow_wild_api/apps/internal/constants"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +17,7 @@ type FollowUserLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 关注用户
 func NewFollowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FollowUserLogic {
 	return &FollowUserLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +26,16 @@ func NewFollowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Follow
 	}
 }
 
-func (l *FollowUserLogic) FollowUser(req *types.FollowUserReq) (resp *types.FollowUserRes, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *FollowUserLogic) FollowUser(req *types.FollowUserReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	userId := l.ctx.Value(constants.UserIdKey).(int64)
+	rpcResp, err := l.svcCtx.SlowWildPb.UserFollow(l.ctx, &slowwildserver.FollowUserReq{
+		FollowUserId: req.FollowUserId,
+		UserId:       userId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 16 - 3
apps/internal/logic/getfanslogic.go

@@ -3,9 +3,11 @@ package logic
 import (
 	"context"
 
+	"slow_wild_api/apps/internal/constants"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +17,7 @@ type GetFansLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取粉丝
 func NewGetFansLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFansLogic {
 	return &GetFansLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +26,18 @@ func NewGetFansLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFansLo
 	}
 }
 
-func (l *GetFansLogic) GetFans(req *types.GetFollowingReq) (resp *types.GetFollowingRes, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetFansLogic) GetFans(req *types.GetFollowingReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	userId := l.ctx.Value(constants.UserIdKey).(int64)
+	rpcResp, err := l.svcCtx.SlowWildPb.GetFans(l.ctx, &slowwildserver.GetFollowingReq{
+		QueryUserId: req.QueryUserId,
+		Page:        req.Page,
+		PageSize:    req.PageSize,
+		UserId:      userId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 16 - 3
apps/internal/logic/getfollowslogic.go

@@ -3,9 +3,11 @@ package logic
 import (
 	"context"
 
+	"slow_wild_api/apps/internal/constants"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +17,7 @@ type GetFollowsLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取关注列表
 func NewGetFollowsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFollowsLogic {
 	return &GetFollowsLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +26,18 @@ func NewGetFollowsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFol
 	}
 }
 
-func (l *GetFollowsLogic) GetFollows(req *types.GetFollowReq) (resp *types.GetFollowRes, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetFollowsLogic) GetFollows(req *types.GetFollowReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	userId := l.ctx.Value(constants.UserIdKey).(int64)
+	rpcResp, err := l.svcCtx.SlowWildPb.GetFollows(l.ctx, &slowwildserver.GetFollowingReq{
+		QueryUserId: req.QueryUserId,
+		Page:        req.Page,
+		PageSize:    req.PageSize,
+		UserId:      userId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 13 - 3
apps/internal/logic/getpostcommentlistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetPostCommentListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取评论列表
 func NewGetPostCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostCommentListLogic {
 	return &GetPostCommentListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,16 @@ func NewGetPostCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 	}
 }
 
-func (l *GetPostCommentListLogic) GetPostCommentList(req *types.GetPostCommentListReq) (resp *types.GetPostCommentListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetPostCommentListLogic) GetPostCommentList(req *types.GetPostCommentListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetPostCommentList(l.ctx, &slowwildserver.GetPostCommentListReq{
+		PostId:   req.PostId,
+		Page:     req.Page,
+		PageSize: req.PageSize,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 15 - 3
apps/internal/logic/getpostlistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetPostListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取帖子列表
 func NewGetPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostListLogic {
 	return &GetPostListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,18 @@ func NewGetPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPo
 	}
 }
 
-func (l *GetPostListLogic) GetPostList(req *types.GetPostListReq) (resp *types.GetPostListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetPostListLogic) GetPostList(req *types.GetPostListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetPostList(l.ctx, &slowwildserver.GetPostListReq{
+		Page:       req.Page,
+		PageSize:   req.PageSize,
+		SearchType: req.SearchType,
+		SortType:   req.SortType,
+		Keyword:    req.Keyword,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 5
apps/internal/logic/getpostlogic.go

@@ -2,11 +2,11 @@ package logic
 
 import (
 	"context"
-	"fmt"
 
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -16,6 +16,7 @@ type GetPostLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取帖子详情
 func NewGetPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostLogic {
 	return &GetPostLogic{
 		Logger: logx.WithContext(ctx),
@@ -24,9 +25,14 @@ func NewGetPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostLo
 	}
 }
 
-func (l *GetPostLogic) GetPost(req *types.GetPostReq) (resp *types.GetPostRsp, err error) {
-	value := l.ctx.Value("user_id")
-	fmt.Println("存储的字段是:", value)
-
+func (l *GetPostLogic) GetPost(req *types.GetPostReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetPost(l.ctx, &slowwildserver.GetPostReq{
+		PostId: req.PostId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 13 - 3
apps/internal/logic/getreplylistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetReplyListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取回复列表
 func NewGetReplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetReplyListLogic {
 	return &GetReplyListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,16 @@ func NewGetReplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetR
 	}
 }
 
-func (l *GetReplyListLogic) GetReplyList(req *types.GetReplyListReq) (resp *types.GetReplyListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetReplyListLogic) GetReplyList(req *types.GetReplyListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetReplyList(l.ctx, &slowwildserver.GetReplyListReq{
+		CommentId: req.CommentId,
+		Page:      req.Page,
+		PageSize:  req.PageSize,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 12 - 3
apps/internal/logic/gettaglistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetTagListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取话题列表
 func NewGetTagListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagListLogic {
 	return &GetTagListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,15 @@ func NewGetTagListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTag
 	}
 }
 
-func (l *GetTagListLogic) GetTagList(req *types.GetTagListReq) (resp *types.GetTagListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetTagListLogic) GetTagList(req *types.GetTagListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetTagList(l.ctx, &slowwildserver.GetTagListReq{
+		Page:     req.Page,
+		PageSize: req.PageSize,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 3
apps/internal/logic/gettaglogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetTagLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取话题详情
 func NewGetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagLogic {
 	return &GetTagLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,14 @@ func NewGetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTagLogi
 	}
 }
 
-func (l *GetTagLogic) GetTag(req *types.GetTagReq) (resp *types.GetTagRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetTagLogic) GetTag(req *types.GetTagReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetTag(l.ctx, &slowwildserver.GetTagReq{
+		TagId: req.TagId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 15 - 3
apps/internal/logic/getuserinfologic.go

@@ -6,6 +6,9 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"slow_wild_api/apps/internal/constants"
+
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +18,7 @@ type GetUserInfoLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取用户信息
 func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
 	return &GetUserInfoLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +27,16 @@ func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
 	}
 }
 
-func (l *GetUserInfoLogic) GetUserInfo(req *types.GetUserInfoReq) (resp *types.GetUserInfoResp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetUserInfoLogic) GetUserInfo(req *types.GetUserInfoReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	userId := l.ctx.Value(constants.UserIdKey).(int64)
+	rpcResp, err := l.svcCtx.SlowWildPb.GetUserInfo(l.ctx, &slowwildserver.GetUserInfoReq{
+		QueryUserId: req.QueryUserId,
+		UserId:      userId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 13 - 3
apps/internal/logic/getuserpostcollectionlistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetUserPostCollectionListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取用户收藏的帖子列表
 func NewGetUserPostCollectionListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserPostCollectionListLogic {
 	return &GetUserPostCollectionListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,16 @@ func NewGetUserPostCollectionListLogic(ctx context.Context, svcCtx *svc.ServiceC
 	}
 }
 
-func (l *GetUserPostCollectionListLogic) GetUserPostCollectionList(req *types.GetUserPostCollectionListReq) (resp *types.GetUserPostCollectionListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetUserPostCollectionListLogic) GetUserPostCollectionList(req *types.GetUserPostCollectionListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetUserPostCollectionList(l.ctx, &slowwildserver.GetUserPostCollectionListReq{
+		QueryUserId: req.QueryUserId,
+		Page:        req.Page,
+		PageSize:    req.PageSize,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 13 - 3
apps/internal/logic/getuserpostlikelistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetUserPostLikeListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取用户点赞的帖子列表
 func NewGetUserPostLikeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserPostLikeListLogic {
 	return &GetUserPostLikeListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,16 @@ func NewGetUserPostLikeListLogic(ctx context.Context, svcCtx *svc.ServiceContext
 	}
 }
 
-func (l *GetUserPostLikeListLogic) GetUserPostLikeList(req *types.GetUserPostLikeListReq) (resp *types.GetUserPostLikeListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetUserPostLikeListLogic) GetUserPostLikeList(req *types.GetUserPostLikeListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetUserPostLikeList(l.ctx, &slowwildserver.GetUserPostLikeListReq{
+		QueryUserId: req.QueryUserId,
+		Page:        req.Page,
+		PageSize:    req.PageSize,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 13 - 3
apps/internal/logic/getuserpostlistlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type GetUserPostListLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取用户发布的帖子列表
 func NewGetUserPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserPostListLogic {
 	return &GetUserPostListLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,16 @@ func NewGetUserPostListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
 	}
 }
 
-func (l *GetUserPostListLogic) GetUserPostList(req *types.GetUserPostListReq) (resp *types.GetUserPostListRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *GetUserPostListLogic) GetUserPostList(req *types.GetUserPostListReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetUserPostList(l.ctx, &slowwildserver.GetUserPostListReq{
+		QueryUserId: req.QueryUserId,
+		Page:        req.Page,
+		PageSize:    req.PageSize,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 5
apps/internal/logic/getuserprofilelogic.go

@@ -2,11 +2,11 @@ package logic
 
 import (
 	"context"
-	"fmt"
 
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -16,6 +16,7 @@ type GetUserProfileLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 获取用户信息
 func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic {
 	return &GetUserProfileLogic{
 		Logger: logx.WithContext(ctx),
@@ -24,9 +25,14 @@ func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
 	}
 }
 
-func (l *GetUserProfileLogic) GetUserProfile(req *types.GetUserProfileReq) (resp *types.GetUserProfileRes, err error) {
-	value := l.ctx.Value("user_id")
-	fmt.Println("存储的字段是:", value)
-
+func (l *GetUserProfileLogic) GetUserProfile(req *types.GetUserProfileReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.GetUserProfile(l.ctx, &slowwildserver.GetUserProfileReq{
+		UserId: req.UserId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 15 - 3
apps/internal/logic/loginlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type LoginLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 登录方法
 func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
 	return &LoginLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,18 @@ func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic
 	}
 }
 
-func (l *LoginLogic) Login(req *types.LoginReq) (resp *types.LoginAndRegisterRsp, err error) {
-	// todo: add your logic here and delete this line
-	
+func (l *LoginLogic) Login(req *types.LoginReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.Login(l.ctx, &slowwildserver.LoginReq{
+		Phone:     req.Phone,
+		Password:  req.Password,
+		Code:      req.Code,
+		LoginType: req.LoginType,
+		LoginIp:   req.LoginIp,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 3
apps/internal/logic/postcollectionlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostCollectionLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 帖子收藏
 func NewPostCollectionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostCollectionLogic {
 	return &PostCollectionLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,14 @@ func NewPostCollectionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Po
 	}
 }
 
-func (l *PostCollectionLogic) PostCollection(req *types.PostCollectionReq) (resp *types.PostCollectionRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostCollectionLogic) PostCollection(req *types.PostCollectionReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostCollection(l.ctx, &slowwildserver.PostCollectionReq{
+		PostId: req.PostId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 16 - 3
apps/internal/logic/postcommentlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostCommentLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 发布评论
 func NewPostCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostCommentLogic {
 	return &PostCommentLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,19 @@ func NewPostCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostC
 	}
 }
 
-func (l *PostCommentLogic) PostComment(req *types.PostCommentReq) (resp *types.PostCommentRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostCommentLogic) PostComment(req *types.PostCommentReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostComment(l.ctx, &slowwildserver.PostCommentReq{
+		PostId:   req.PostId,
+		Content:  req.Content,
+		Image:    req.Image,
+		AtUserId: req.AtUserId,
+		Ip:       req.Ip,
+		IpLoc:    req.IpLoc,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 12 - 3
apps/internal/logic/postcommentupvotelogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostCommentUpvoteLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 评论点赞
 func NewPostCommentUpvoteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostCommentUpvoteLogic {
 	return &PostCommentUpvoteLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,15 @@ func NewPostCommentUpvoteLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 	}
 }
 
-func (l *PostCommentUpvoteLogic) PostCommentUpvote(req *types.PostCommentUpvoteReq) (resp *types.PostCommentUpvoteRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostCommentUpvoteLogic) PostCommentUpvote(req *types.PostCommentUpvoteReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostCommentUpvote(l.ctx, &slowwildserver.PostCommentUpvoteReq{
+		CommentId:   req.CommentId,
+		CommentType: req.CommentType,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 3
apps/internal/logic/postdeletelogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostDeleteLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 帖子删除
 func NewPostDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostDeleteLogic {
 	return &PostDeleteLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,14 @@ func NewPostDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostDe
 	}
 }
 
-func (l *PostDeleteLogic) PostDelete(req *types.PostDeleteReq) (resp *types.PostDeleteRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostDeleteLogic) PostDelete(req *types.PostDeleteReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostDelete(l.ctx, &slowwildserver.PostDeleteReq{
+		PostId: req.PostId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 16 - 3
apps/internal/logic/postreplylogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostReplyLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 回复评论
 func NewPostReplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostReplyLogic {
 	return &PostReplyLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,19 @@ func NewPostReplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostRep
 	}
 }
 
-func (l *PostReplyLogic) PostReply(req *types.PostReplyReq) (resp *types.PostReplyRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostReplyLogic) PostReply(req *types.PostReplyReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostReply(l.ctx, &slowwildserver.PostReplyReq{
+		CommentId: req.CommentId,
+		Content:   req.Content,
+		Image:     req.Image,
+		AtUserId:  req.AtUserId,
+		Ip:        req.Ip,
+		IpLoc:     req.IpLoc,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 3
apps/internal/logic/postsharelogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostShareLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 帖子分享
 func NewPostShareLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostShareLogic {
 	return &PostShareLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,14 @@ func NewPostShareLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostSha
 	}
 }
 
-func (l *PostShareLogic) PostShare(req *types.PostShareReq) (resp *types.PostShareRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostShareLogic) PostShare(req *types.PostShareReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostShare(l.ctx, &slowwildserver.PostShareReq{
+		PostId: req.PostId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 11 - 3
apps/internal/logic/postupvotelogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type PostUpvoteLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 帖子点赞
 func NewPostUpvoteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostUpvoteLogic {
 	return &PostUpvoteLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,14 @@ func NewPostUpvoteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostUp
 	}
 }
 
-func (l *PostUpvoteLogic) PostUpvote(req *types.PostUpvoteReq) (resp *types.PostUpvoteRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *PostUpvoteLogic) PostUpvote(req *types.PostUpvoteReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.PostUpvote(l.ctx, &slowwildserver.PostUpvoteReq{
+		PostId: req.PostId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 17 - 3
apps/internal/logic/registerlogic.go

@@ -6,6 +6,7 @@ import (
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +16,7 @@ type RegisterLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 用户注册
 func NewRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterLogic {
 	return &RegisterLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +25,20 @@ func NewRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Register
 	}
 }
 
-func (l *RegisterLogic) Register(req *types.RegisterReq) (resp *types.LoginAndRegisterRsp, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *RegisterLogic) Register(req *types.RegisterReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	rpcResp, err := l.svcCtx.SlowWildPb.Register(l.ctx, &slowwildserver.RegisterReq{
+		Phone:    req.Phone,
+		Nickname: req.Nickname,
+		Password: req.Password,
+		Avatar:   req.Avatar,
+		Sex:      req.Sex,
+		Username: req.Username,
+		Code:     req.Code,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 16 - 3
apps/internal/logic/searchusernamelogic.go

@@ -3,9 +3,11 @@ package logic
 import (
 	"context"
 
+	"slow_wild_api/apps/internal/constants"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
@@ -15,6 +17,7 @@ type SearchUsernameLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 搜索用户
 func NewSearchUsernameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchUsernameLogic {
 	return &SearchUsernameLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +26,18 @@ func NewSearchUsernameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Se
 	}
 }
 
-func (l *SearchUsernameLogic) SearchUsername(req *types.SearchUsernameReq) (resp *types.SearchUsernameRes, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *SearchUsernameLogic) SearchUsername(req *types.SearchUsernameReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	userId := l.ctx.Value(constants.UserIdKey).(int64)
+	rpcResp, err := l.svcCtx.SlowWildPb.SearchUsername(l.ctx, &slowwildserver.SearchUsernameReq{
+		Keyword:  req.Keyword,
+		Page:     req.Page,
+		PageSize: req.PageSize,
+		UserId:   userId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 15 - 3
apps/internal/logic/unfollowuserlogic.go

@@ -3,10 +3,13 @@ package logic
 import (
 	"context"
 
+	"slow_wild_api/apps/internal/constants"
 	"slow_wild_api/apps/internal/svc"
 	"slow_wild_api/apps/internal/types"
 
 	"github.com/zeromicro/go-zero/core/logx"
+
+	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserver"
 )
 
 type UnfollowUserLogic struct {
@@ -15,6 +18,7 @@ type UnfollowUserLogic struct {
 	svcCtx *svc.ServiceContext
 }
 
+// 取消关注用户
 func NewUnfollowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UnfollowUserLogic {
 	return &UnfollowUserLogic{
 		Logger: logx.WithContext(ctx),
@@ -23,8 +27,16 @@ func NewUnfollowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Unfo
 	}
 }
 
-func (l *UnfollowUserLogic) UnfollowUser(req *types.UnFollowUserReq) (resp *types.UnFollowUserRes, err error) {
-	// todo: add your logic here and delete this line
-
+func (l *UnfollowUserLogic) UnfollowUser(req *types.UnFollowUserReq) (resp *types.BaseReturnData, err error) {
+	resp = &types.BaseReturnData{}
+	userId := l.ctx.Value(constants.UserIdKey).(int64)
+	rpcResp, err := l.svcCtx.SlowWildPb.UnUserFollow(l.ctx, &slowwildserver.UnFollowUserReq{
+		UnFollowUserId: req.UnFollowUserId,
+		UserId:         userId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	resp.Data = rpcResp
 	return
 }

+ 2 - 0
apps/internal/middleware/optionaljwtmiddleware.go

@@ -3,6 +3,7 @@ package middleware
 import (
 	"context"
 	"errors"
+	"fmt"
 	"net/http"
 	"strings"
 
@@ -58,6 +59,7 @@ func (m *OptionalJwtMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
 								ctx = context.WithValue(ctx, k, v)
 							}
 						}
+						fmt.Println("vvvvvvvv: ")
 					}
 				}
 			}

+ 31 - 6
apps/internal/svc/servicecontext.go

@@ -1,25 +1,50 @@
 package svc
 
 import (
+	"context"
+	"fmt"
 	"slow_wild_api/apps/internal/config"
 	"slow_wild_api/apps/internal/middleware"
 
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/metadata"
+
 	"git.banshen.xyz/huangguangrong/slow_wild_protobuff/slowwild/slowwildserverclient"
 	"github.com/zeromicro/go-zero/rest"
+	"github.com/zeromicro/go-zero/zrpc"
 )
 
 type ServiceContext struct {
-	Config     config.Config
-	SlowWildPb slowwildserverclient.SlowWildServer
-
+	Config                config.Config
+	SlowWildPb            slowwildserverclient.SlowWildServer
 	OptionalJwtMiddleware rest.Middleware
 }
 
+// 创建 gRPC 拦截器
+func userAuthInterceptor() grpc.UnaryClientInterceptor {
+	return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
+		// 从context中获取user_id
+		if userId := ctx.Value("user_id"); userId != nil {
+			// 创建metadata
+			md := metadata.New(map[string]string{
+				"user_id": fmt.Sprint(userId),
+			})
+			// 将metadata添加到context
+			ctx = metadata.NewOutgoingContext(ctx, md)
+		}
+
+		return invoker(ctx, method, req, reply, cc, opts...)
+	}
+}
+
 func NewServiceContext(c config.Config) *ServiceContext {
+	// 创建带有拦截器的 gRPC 客户端
+	client := zrpc.MustNewClient(c.SlowwildRpc,
+		zrpc.WithUnaryClientInterceptor(userAuthInterceptor()))
+
 	return &ServiceContext{
-		Config: c,
-		// SlowWildPb: slowwildserverclient.NewSlowWildServer(zrpc.MustNewClient(c.SlowwildRpc)),
-		// 定义可选的 JWT 中间件
+		Config:                c,
+		SlowWildPb:            slowwildserverclient.NewSlowWildServer(client),
 		OptionalJwtMiddleware: middleware.NewOptionalJwtMiddleware(c.Auth.AccessSecret).Handle,
 	}
 }

+ 205 - 223
apps/internal/types/types.go

@@ -1,10 +1,13 @@
 // Code generated by goctl. DO NOT EDIT.
 package types
 
+type BaseReturnData struct {
+	Data interface{} `json:"data"`
+}
+
 type CommentDeleteReq struct {
-	User_id      int64 `json:"user_id"`
-	Comment_id   int64 `json:"comment_id"`
-	Comment_type int32 `json:"comment_type"`
+	CommentId   int64 `json:"comment_id"`
+	CommentType int32 `json:"comment_type"`
 }
 
 type CommentDeleteRsp struct {
@@ -12,38 +15,37 @@ type CommentDeleteRsp struct {
 }
 
 type CommentItem struct {
-	Id           int64         `json:"id"`
-	Post_id      int64         `json:"post_id"`
-	User         UserInfo      `json:"user"`
-	Ip_loc       string        `json:"ip_loc"`
-	Content      string        `json:"content"`
-	Image        string        `json:"image"`
-	With_user    []UserInfo    `json:"with_user"`
-	Reply_count  int64         `json:"reply_count"`
-	Upvote_count int64         `json:"upvote_count"`
-	Reply_item   []RepliesItem `json:"reply_item"`
-	Is_liked     bool          `json:"is_liked"`
-	Is_mine      bool          `json:"is_mine"`
-	Created_on   int64         `json:"created_on"`
+	Id          int64         `json:"id"`
+	PostId      int64         `json:"post_id"`
+	User        UserInfo      `json:"user"`
+	IpLoc       string        `json:"ip_loc"`
+	Content     string        `json:"content"`
+	Image       string        `json:"image"`
+	WithUser    []UserInfo    `json:"with_user"`
+	ReplyCount  int64         `json:"reply_count"`
+	UpvoteCount int64         `json:"upvote_count"`
+	ReplyItem   []RepliesItem `json:"reply_item"`
+	IsLiked     bool          `json:"is_liked"`
+	IsMine      bool          `json:"is_mine"`
+	CreatedOn   int64         `json:"created_on"`
 }
 
 type CreatePostReq struct {
-	User_id     int64       `json:"user_id"`
-	Title       string      `json:"title"`
-	Content     string      `json:"content"`
-	Tags        []CreateTag `json:"tags"`
-	At_user_ids []int64     `json:"at_user_ids"`
-	Post_type   int32       `json:"post_type"`
-	Visibility  int32       `json:"visibility"`
-	Images      []string    `json:"images"`
-	Video_cover string      `json:"video_cover"`
-	Video_url   string      `json:"video_url"`
-	Ip          string      `json:"ip"`
-	Ip_loc      string      `json:"ip_loc"`
+	Title      string      `json:"title"`
+	Content    string      `json:"content"`
+	Tags       []CreateTag `json:"tags"`
+	AtUserIds  []int64     `json:"at_user_ids"`
+	PostType   int32       `json:"post_type"`
+	Visibility int32       `json:"visibility"`
+	Images     []string    `json:"images"`
+	VideoCover string      `json:"video_cover"`
+	VideoUrl   string      `json:"video_url"`
+	Ip         string      `json:"ip"`
+	IpLoc      string      `json:"ip_loc"`
 }
 
 type CreatePostRsp struct {
-	Post_id int64 `json:"post_id"`
+	PostId int64 `json:"post_id"`
 }
 
 type CreateTag struct {
@@ -58,17 +60,16 @@ type FindUserReq struct {
 }
 
 type FindUserResp struct {
-	User_list []UserInfo `json:"user_list"`
+	UserList []UserInfo `json:"user_list"`
 }
 
 type FollowUserInfo struct {
-	User             UserInfo `json:"user"`
-	Is_mutual_follow bool     `json:"is_mutual_follow"`
+	User           UserInfo `json:"user"`
+	IsMutualFollow bool     `json:"is_mutual_follow"`
 }
 
 type FollowUserReq struct {
-	User_id        int64 `json:"user_id"`
-	Follow_user_id int64 `json:"follow_user_id"`
+	FollowUserId int64 `json:"follow_user_id"`
 }
 
 type FollowUserRes struct {
@@ -76,10 +77,9 @@ type FollowUserRes struct {
 }
 
 type GetFollowReq struct {
-	User_id       int64 `json:"user_id"`
-	Page_size     int32 `json:"page_size"`
-	Page          int32 `json:"page"`
-	Query_user_id int64 `json:"query_user_id"`
+	PageSize    int32 `json:"page_size"`
+	Page        int32 `json:"page"`
+	QueryUserId int64 `json:"query_user_id"`
 }
 
 type GetFollowRes struct {
@@ -88,10 +88,9 @@ type GetFollowRes struct {
 }
 
 type GetFollowingReq struct {
-	User_id       int64 `json:"user_id"`
-	Page_size     int32 `json:"page_size"`
-	Page          int32 `json:"page"`
-	Query_user_id int64 `json:"query_user_id"`
+	PageSize    int32 `json:"page_size"`
+	Page        int32 `json:"page"`
+	QueryUserId int64 `json:"query_user_id"`
 }
 
 type GetFollowingRes struct {
@@ -100,10 +99,9 @@ type GetFollowingRes struct {
 }
 
 type GetPostCommentListReq struct {
-	Page      int32 `json:"page"`
-	Page_size int32 `json:"page_size"`
-	Post_id   int64 `json:"post_id"`
-	User_id   int64 `json:"user_id"`
+	Page     int32 `json:"page"`
+	PageSize int32 `json:"page_size"`
+	PostId   int64 `json:"post_id"`
 }
 
 type GetPostCommentListRsp struct {
@@ -112,35 +110,34 @@ type GetPostCommentListRsp struct {
 }
 
 type GetPostListItem struct {
-	Id               int64     `json:"id"`
-	User             UserInfo  `json:"user"`
-	Title            string    `json:"title"`
-	Content_summary  string    `json:"content_summary"`
-	Post_type        int32     `json:"post_type"`
-	Comment_count    int64     `json:"comment_count"`
-	Upvote_count     int64     `json:"upvote_count"`
-	Collection_count int64     `json:"collection_count"`
-	Share_count      int64     `json:"share_count"`
-	Visibility       int32     `json:"visibility"`
-	Ip_loc           string    `json:"ip_loc"`
-	Hot_num          int64     `json:"hot_num"`
-	Images           []string  `json:"images"`
-	Video_url        string    `json:"video_url"`
-	Video_cover      string    `json:"video_cover"`
-	Created_on       int64     `json:"created_on"`
-	Tags             []TagItem `json:"tags"`
-	Is_liked         bool      `json:"is_liked"`
-	Is_collected     bool      `json:"is_collected"`
-	Is_mine          bool      `json:"is_mine"`
+	Id              int64     `json:"id"`
+	User            UserInfo  `json:"user"`
+	Title           string    `json:"title"`
+	ContentSummary  string    `json:"content_summary"`
+	PostYype        int32     `json:"post_type"`
+	CommentCount    int64     `json:"comment_count"`
+	UpvoteCount     int64     `json:"upvote_count"`
+	CollectionCount int64     `json:"collection_count"`
+	ShareCount      int64     `json:"share_count"`
+	Visibility      int32     `json:"visibility"`
+	IpLoc           string    `json:"ip_loc"`
+	HotNum          int64     `json:"hot_num"`
+	Images          []string  `json:"images"`
+	VideoUrl        string    `json:"video_url"`
+	VideoCover      string    `json:"video_cover"`
+	CreatedOn       int64     `json:"created_on"`
+	Tags            []TagItem `json:"tags"`
+	IsLiked         bool      `json:"is_liked"`
+	IsCollected     bool      `json:"is_collected"`
+	IsMine          bool      `json:"is_mine"`
 }
 
 type GetPostListReq struct {
-	Page        int32  `json:"page"`
-	Page_size   int32  `json:"page_size"`
-	Search_type int32  `json:"search_type"`
-	Sort_type   int32  `json:"sort_type"`
-	Keyword     string `json:"keyword"`
-	User_id     int64  `json:"user_id"`
+	Page       int32  `json:"page"`
+	PageSize   int32  `json:"page_size"`
+	SearchType int32  `json:"search_type"`
+	SortType   int32  `json:"sort_type"`
+	Keyword    string `json:"keyword"`
 }
 
 type GetPostListRsp struct {
@@ -149,41 +146,39 @@ type GetPostListRsp struct {
 }
 
 type GetPostReq struct {
-	User_id int64 `json:"user_id"`
-	Post_id int64 `json:"post_id"`
+	PostId int64 `json:"post_id"`
 }
 
 type GetPostRsp struct {
-	Id                int64      `json:"id"`
-	User              UserInfo   `json:"user"`
-	Title             string     `json:"title"`
-	Content_summary   string     `json:"content_summary"`
-	Post_type         int32      `json:"post_type"`
-	Comment_count     int64      `json:"comment_count"`
-	Upvote_count      int64      `json:"upvote_count"`
-	Collection_count  int64      `json:"collection_count"`
-	Share_count       int64      `json:"share_count"`
-	Visibility        int32      `json:"visibility"`
-	Ip_loc            string     `json:"ip_loc"`
-	Hot_num           int64      `json:"hot_num"`
-	Images            []string   `json:"images"`
-	Video_url         string     `json:"video_url"`
-	Video_cover       string     `json:"video_cover"`
-	Content           string     `json:"content"`
-	Created_on        int64      `json:"created_on"`
-	Tags              []TagItem  `json:"tags"`
-	With_user         []UserInfo `json:"with_user"`
-	Latest_replied_on int64      `json:"latest_replied_on"`
-	Is_liked          bool       `json:"is_liked"`
-	Is_collected      bool       `json:"is_collected"`
-	Is_mine           bool       `json:"is_mine"`
+	Id              int64      `json:"id"`
+	User            UserInfo   `json:"user"`
+	Title           string     `json:"title"`
+	ContentSummary  string     `json:"content_summary"`
+	PostYype        int32      `json:"post_type"`
+	CommentCount    int64      `json:"comment_count"`
+	UpvoteCount     int64      `json:"upvote_count"`
+	CollectionCount int64      `json:"collection_count"`
+	ShareCount      int64      `json:"share_count"`
+	Visibility      int32      `json:"visibility"`
+	IpLoc           string     `json:"ip_loc"`
+	HotNum          int64      `json:"hot_num"`
+	Images          []string   `json:"images"`
+	VideoUrl        string     `json:"video_url"`
+	VideoCover      string     `json:"video_cover"`
+	Content         string     `json:"content"`
+	CreatedOn       int64      `json:"created_on"`
+	Tags            []TagItem  `json:"tags"`
+	WithUser        []UserInfo `json:"with_user"`
+	LatestRepliedOn int64      `json:"latest_replied_on"`
+	IsLiked         bool       `json:"is_liked"`
+	IsCollected     bool       `json:"is_collected"`
+	IsMine          bool       `json:"is_mine"`
 }
 
 type GetReplyListReq struct {
-	Page       int32 `json:"page"`
-	Page_size  int32 `json:"page_size"`
-	Comment_id int64 `json:"comment_id"`
-	User_id    int64 `json:"user_id"`
+	Page      int32 `json:"page"`
+	PageSize  int32 `json:"page_size"`
+	CommentId int64 `json:"comment_id"`
 }
 
 type GetReplyListRsp struct {
@@ -192,51 +187,48 @@ type GetReplyListRsp struct {
 }
 
 type GetTagListReq struct {
-	Page      int32  `json:"page"`
-	Page_size int32  `json:"page_size"`
-	Tag_name  string `json:"tag_name"`
-	Sort_by   int32  `json:"sort_by"`
+	Page     int32  `json:"page"`
+	PageSize int32  `json:"page_size"`
+	TagName  string `json:"tag_name"`
+	SortBy   int32  `json:"sort_by"`
 }
 
 type GetTagListRsp struct {
-	Tag_list []TagItem `json:"tag_list"`
-	Total    int32     `json:"total"`
+	TagList []TagItem `json:"tag_list"`
+	Total   int32     `json:"total"`
 }
 
 type GetTagReq struct {
-	Tag_id  int64 `json:"tag_id"`
-	User_id int64 `json:"user_id"`
+	TagId int64 `json:"tag_id"`
 }
 
 type GetTagRsp struct {
-	Name         string   `json:"name"`
-	Hot_num      int64    `json:"hot_num"`
-	User         UserInfo `json:"user"`
-	Id           int64    `json:"id"`
-	Created_on   int64    `json:"created_on"`
-	Post_count   int64    `json:"post_count"`
-	Follow_count int64    `json:"follow_count"`
-	Is_followed  bool     `json:"is_followed"`
+	Name        string   `json:"name"`
+	HotNum      int64    `json:"hot_num"`
+	User        UserInfo `json:"user"`
+	Id          int64    `json:"id"`
+	CreatedOn   int64    `json:"created_on"`
+	PostCount   int64    `json:"post_count"`
+	FollowCount int64    `json:"follow_count"`
+	IsFollowed  bool     `json:"is_followed"`
 }
 
 type GetUserInfoReq struct {
-	User_id       int64 `json:"user_id"`
-	Query_user_id int64 `json:"query_user_id"`
+	QueryUserId int64 `json:"query_user_id"`
 }
 
 type GetUserInfoResp struct {
-	Id        int64  `json:"id"`
-	Avatar    string `json:"avatar"`
-	Nickname  string `json:"nickname"`
-	Sex       int32  `json:"sex"`
-	Is_follow bool   `json:"is_follow"`
+	Id       int64  `json:"id"`
+	Avatar   string `json:"avatar"`
+	Nickname string `json:"nickname"`
+	Sex      int32  `json:"sex"`
+	IsFollow bool   `json:"is_follow"`
 }
 
 type GetUserPostCollectionListReq struct {
-	User_id       int64 `json:"user_id"`
-	Page          int64 `json:"page"`
-	Page_size     int64 `json:"page_size"`
-	Query_user_id int64 `json:"query_user_id"`
+	Page        int64 `json:"page"`
+	PageSize    int64 `json:"page_size"`
+	QueryUserId int64 `json:"query_user_id"`
 }
 
 type GetUserPostCollectionListRsp struct {
@@ -245,10 +237,9 @@ type GetUserPostCollectionListRsp struct {
 }
 
 type GetUserPostLikeListReq struct {
-	User_id       int64 `json:"user_id"`
-	Page          int64 `json:"page"`
-	Page_size     int64 `json:"page_size"`
-	Query_user_id int64 `json:"query_user_id"`
+	Page        int64 `json:"page"`
+	PageSize    int64 `json:"page_size"`
+	QueryUserId int64 `json:"query_user_id"`
 }
 
 type GetUserPostLikeListRsp struct {
@@ -257,10 +248,9 @@ type GetUserPostLikeListRsp struct {
 }
 
 type GetUserPostListReq struct {
-	User_id       int64 `json:"user_id"`
-	Page          int64 `json:"page"`
-	Page_size     int64 `json:"page_size"`
-	Query_user_id int64 `json:"query_user_id"`
+	Page        int64 `json:"page"`
+	PageSize    int64 `json:"page_size"`
+	QueryUserId int64 `json:"query_user_id"`
 }
 
 type GetUserPostListRsp struct {
@@ -269,24 +259,24 @@ type GetUserPostListRsp struct {
 }
 
 type GetUserProfileReq struct {
-	User_id int64 `json:"user_id"`
+	UserId int64 `json:"user_id"`
 }
 
 type GetUserProfileRes struct {
-	Id                   int64  `json:"id"`
-	Nickname             string `json:"nickname"`
-	Username             string `json:"username"`
-	Status               int32  `json:"status"`
-	Avatar               string `json:"avatar"`
-	Phone                string `json:"phone"`
-	Tweet_count          int32  `json:"tweet_count"`
-	Is_following         bool   `json:"is_following"`
-	Created_on           int64  `json:"created_on"`
-	Follows              int64  `json:"follows"`
-	Fans                 int64  `json:"fans"`
-	Get_likes_count      int32  `json:"get_likes_count"`
-	Get_collection_count int32  `json:"get_collection_count"`
-	Sex                  int32  `json:"sex"`
+	Id                 int64  `json:"id"`
+	Nickname           string `json:"nickname"`
+	Username           string `json:"username"`
+	Status             int32  `json:"status"`
+	Avatar             string `json:"avatar"`
+	Phone              string `json:"phone"`
+	TweetCount         int32  `json:"tweet_count"`
+	IsFollowing        bool   `json:"is_following"`
+	CreatedOn          int64  `json:"created_on"`
+	Follows            int64  `json:"follows"`
+	Fans               int64  `json:"fans"`
+	GetLikesCount      int32  `json:"get_likes_count"`
+	GetCollectionCount int32  `json:"get_collection_count"`
+	Sex                int32  `json:"sex"`
 }
 
 type LoginAndRegisterRsp struct {
@@ -295,16 +285,15 @@ type LoginAndRegisterRsp struct {
 }
 
 type LoginReq struct {
-	Phone      string `json:"phone"`
-	Password   string `json:"password"`
-	Code       string `json:"code"`
-	Login_type int32  `json:"login_type"`
-	Login_ip   string `json:"login_ip"`
+	Phone     string `json:"phone"`
+	Password  string `json:"password"`
+	Code      string `json:"code"`
+	LoginType int32  `json:"login_type"`
+	LoginIp   string `json:"login_ip"`
 }
 
 type PostCollectionReq struct {
-	Post_id int64 `json:"post_id"`
-	User_id int64 `json:"user_id"`
+	PostId int64 `json:"post_id"`
 }
 
 type PostCollectionRsp struct {
@@ -312,23 +301,21 @@ type PostCollectionRsp struct {
 }
 
 type PostCommentReq struct {
-	Post_id    int64  `json:"post_id"`
-	User_id    int64  `json:"user_id"`
-	Content    string `json:"content"`
-	Image      string `json:"image"`
-	At_user_id int64  `json:"at_user_id"`
-	Ip         string `json:"ip"`
-	Ip_loc     string `json:"ip_loc"`
+	PostId   int64  `json:"post_id"`
+	Content  string `json:"content"`
+	Image    string `json:"image"`
+	AtUserId int64  `json:"at_user_id"`
+	Ip       string `json:"ip"`
+	IpLoc    string `json:"ip_loc"`
 }
 
 type PostCommentRsp struct {
-	Comment_id int64 `json:"comment_id"`
+	CommentId int64 `json:"comment_id"`
 }
 
 type PostCommentUpvoteReq struct {
-	User_id      int64 `json:"user_id"`
-	Comment_id   int64 `json:"comment_id"`
-	Comment_type int32 `json:"comment_type"`
+	CommentId   int64 `json:"comment_id"`
+	CommentType int32 `json:"comment_type"`
 }
 
 type PostCommentUpvoteRsp struct {
@@ -336,8 +323,7 @@ type PostCommentUpvoteRsp struct {
 }
 
 type PostDeleteReq struct {
-	User_id int64 `json:"user_id"`
-	Post_id int64 `json:"post_id"`
+	PostId int64 `json:"post_id"`
 }
 
 type PostDeleteRsp struct {
@@ -345,24 +331,22 @@ type PostDeleteRsp struct {
 }
 
 type PostReplyReq struct {
-	Post_id     int64  `json:"post_id"`
-	User_id     int64  `json:"user_id"`
-	Content     string `json:"content"`
-	Image       string `json:"image"`
-	At_user_id  int64  `json:"at_user_id"`
-	Ip          string `json:"ip"`
-	Ip_loc      string `json:"ip_loc"`
-	Comment_id  int64  `json:"comment_id"`
-	To_reply_id int64  `json:"to_reply_id"`
+	PostId    int64  `json:"post_id"`
+	Content   string `json:"content"`
+	Image     string `json:"image"`
+	AtUserId  int64  `json:"at_user_id"`
+	Ip        string `json:"ip"`
+	IpLoc     string `json:"ip_loc"`
+	CommentId int64  `json:"comment_id"`
+	ToReplyId int64  `json:"to_reply_id"`
 }
 
 type PostReplyRsp struct {
-	Reply_id int64 `json:"reply_id"`
+	ReplyId int64 `json:"reply_id"`
 }
 
 type PostShareReq struct {
-	Post_id int64 `json:"post_id"`
-	User_id int64 `json:"user_id"`
+	PostId int64 `json:"post_id"`
 }
 
 type PostShareRsp struct {
@@ -370,8 +354,7 @@ type PostShareRsp struct {
 }
 
 type PostUpvoteReq struct {
-	Post_id int64 `json:"post_id"`
-	User_id int64 `json:"user_id"`
+	PostId int64 `json:"post_id"`
 }
 
 type PostUpvoteRsp struct {
@@ -389,32 +372,32 @@ type RegisterReq struct {
 }
 
 type RepliesItem struct {
-	Id           int64      `json:"id"`
-	Post_id      int64      `json:"post_id"`
-	User         UserInfo   `json:"user"`
-	Ip_loc       string     `json:"ip_loc"`
-	Content      string     `json:"content"`
-	Image        string     `json:"image"`
-	With_user    []UserInfo `json:"with_user"`
-	Upvote_count int64      `json:"upvote_count"`
-	Is_liked     bool       `json:"is_liked"`
-	Is_mine      bool       `json:"is_mine"`
-	Created_on   int64      `json:"created_on"`
+	Id          int64      `json:"id"`
+	PostId      int64      `json:"post_id"`
+	User        UserInfo   `json:"user"`
+	IpLoc       string     `json:"ip_loc"`
+	Content     string     `json:"content"`
+	Image       string     `json:"image"`
+	WithUser    []UserInfo `json:"with_user"`
+	UpvoteCount int64      `json:"upvote_count"`
+	IsLiked     bool       `json:"is_liked"`
+	IsMine      bool       `json:"is_mine"`
+	CreatedOn   int64      `json:"created_on"`
 }
 
 type SearchUsernameItem struct {
-	Nickname  string `json:"nickname"`
-	Avatar    string `json:"avatar"`
-	Id        int64  `json:"id"`
-	Sex       int32  `json:"sex"`
-	Is_follow bool   `json:"is_follow"`
+	Nickname string `json:"nickname"`
+	Avatar   string `json:"avatar"`
+	Id       int64  `json:"id"`
+	Sex      int32  `json:"sex"`
+	IsFollow bool   `json:"is_follow"`
 }
 
 type SearchUsernameReq struct {
-	Keyword   string `json:"keyword"`
-	Page      int32  `json:"page"`
-	Page_size int32  `json:"page_size"`
-	User_id   int64  `json:"user_id"`
+	Keyword  string `json:"keyword"`
+	Page     int32  `json:"page"`
+	PageSize int32  `json:"page_size"`
+	UserId   int64  `json:"user_id"`
 }
 
 type SearchUsernameRes struct {
@@ -423,16 +406,15 @@ type SearchUsernameRes struct {
 }
 
 type TagItem struct {
-	Name       string   `json:"name"`
-	Hot_num    int64    `json:"hot_num"`
-	User       UserInfo `json:"user"`
-	Id         int64    `json:"id"`
-	Created_on int64    `json:"created_on"`
+	Name      string   `json:"name"`
+	HotNum    int64    `json:"hot_num"`
+	User      UserInfo `json:"user"`
+	Id        int64    `json:"id"`
+	CreatedOn int64    `json:"created_on"`
 }
 
 type UnFollowUserReq struct {
-	User_id           int64 `json:"user_id"`
-	Un_follow_user_id int64 `json:"un_follow_user_id"`
+	UnFollowUserId int64 `json:"un_follow_user_id"`
 }
 
 type UnFollowUserRes struct {
@@ -440,17 +422,17 @@ type UnFollowUserRes struct {
 }
 
 type UserEntity struct {
-	Id                   int64  `json:"id"`
-	Avatar               string `json:"avatar"`
-	Nickname             string `json:"nickname"`
-	Username             string `json:"username"`
-	Phone                string `json:"phone"`
-	Status               int32  `json:"status"`
-	Sex                  int32  `json:"sex"`
-	Follows              int64  `json:"follows"`
-	Followings           int64  `json:"followings"`
-	Get_likes_count      int32  `json:"get_likes_count"`
-	Get_collection_count int32  `json:"get_collection_count"`
+	Id                 int64  `json:"id"`
+	Avatar             string `json:"avatar"`
+	Nickname           string `json:"nickname"`
+	Username           string `json:"username"`
+	Phone              string `json:"phone"`
+	Status             int32  `json:"status"`
+	Sex                int32  `json:"sex"`
+	Follows            int64  `json:"follows"`
+	Followings         int64  `json:"followings"`
+	GetLikesCount      int32  `json:"get_likes_count"`
+	GetCollectionCount int32  `json:"get_collection_count"`
 }
 
 type UserInfo struct {

+ 36 - 0
apps/internal/utils/ip.go

@@ -0,0 +1,36 @@
+package utils
+
+import (
+	"net/http"
+	"strings"
+)
+
+// 获取真实IP地址
+func GetRealIP(r *http.Request) string {
+	// 尝试从 X-Real-IP 获取
+	if ip := r.Header.Get("X-Real-IP"); ip != "" {
+		return ip
+	}
+
+	// 尝试从 X-Forwarded-For 获取
+	if ip := r.Header.Get("X-Forwarded-For"); ip != "" {
+		// X-Forwarded-For 可能包含多个 IP,第一个是真实 IP
+		ips := strings.Split(ip, ",")
+		if len(ips) > 0 {
+			return strings.TrimSpace(ips[0])
+		}
+	}
+
+	// 尝试从 RemoteAddr 获取
+	ip := r.RemoteAddr
+	// RemoteAddr 包含端口号,需要去除
+	if colonIndex := strings.LastIndex(ip, ":"); colonIndex != -1 {
+		ip = ip[:colonIndex]
+	}
+
+	// 去除 IPv6 的中括号
+	ip = strings.TrimPrefix(ip, "[")
+	ip = strings.TrimSuffix(ip, "]")
+
+	return ip
+}

+ 0 - 1
apps/slowwild.go

@@ -28,5 +28,4 @@ func main() {
 
 	fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
 	server.Start()
-
 }

+ 13 - 14
go.mod

@@ -2,12 +2,12 @@ module slow_wild_api
 
 go 1.22.0
 
-toolchain go1.22.7
-
 require (
-	git.banshen.xyz/huangguangrong/slow_wild_protobuff v0.1.7
+	git.banshen.xyz/huangguangrong/slow_wild_protobuff v0.1.8
 	github.com/golang-jwt/jwt/v4 v4.5.1
-	github.com/zeromicro/go-zero v1.8.0
+	github.com/pkg/errors v0.9.1
+	github.com/zeromicro/go-zero v1.8.1
+	google.golang.org/grpc v1.70.0
 )
 
 require (
@@ -35,7 +35,7 @@ require (
 	github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
-	github.com/klauspost/compress v1.17.9 // indirect
+	github.com/klauspost/compress v1.17.11 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/mattn/go-colorable v0.1.13 // indirect
 	github.com/mattn/go-isatty v0.0.20 // indirect
@@ -44,11 +44,11 @@ require (
 	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 	github.com/openzipkin/zipkin-go v0.4.3 // indirect
 	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
-	github.com/prometheus/client_golang v1.20.5 // indirect
+	github.com/prometheus/client_golang v1.21.0 // indirect
 	github.com/prometheus/client_model v0.6.1 // indirect
-	github.com/prometheus/common v0.55.0 // indirect
+	github.com/prometheus/common v0.62.0 // indirect
 	github.com/prometheus/procfs v0.15.1 // indirect
-	github.com/redis/go-redis/v9 v9.7.0 // indirect
+	github.com/redis/go-redis/v9 v9.7.1 // indirect
 	github.com/spaolacci/murmur3 v1.1.0 // indirect
 	go.etcd.io/etcd/api/v3 v3.5.15 // indirect
 	go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
@@ -68,15 +68,14 @@ require (
 	go.uber.org/automaxprocs v1.6.0 // indirect
 	go.uber.org/multierr v1.9.0 // indirect
 	go.uber.org/zap v1.24.0 // indirect
-	golang.org/x/net v0.34.0 // indirect
+	golang.org/x/net v0.35.0 // indirect
 	golang.org/x/oauth2 v0.24.0 // indirect
-	golang.org/x/sys v0.29.0 // indirect
-	golang.org/x/term v0.28.0 // indirect
-	golang.org/x/text v0.21.0 // indirect
-	golang.org/x/time v0.9.0 // indirect
+	golang.org/x/sys v0.30.0 // indirect
+	golang.org/x/term v0.29.0 // indirect
+	golang.org/x/text v0.22.0 // indirect
+	golang.org/x/time v0.10.0 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a // indirect
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
-	google.golang.org/grpc v1.70.0 // indirect
 	google.golang.org/protobuf v1.36.5 // indirect
 	gopkg.in/inf.v0 v0.9.1 // indirect
 	gopkg.in/yaml.v2 v2.4.0 // indirect

+ 22 - 22
go.sum

@@ -1,5 +1,5 @@
-git.banshen.xyz/huangguangrong/slow_wild_protobuff v0.1.7 h1:60g8xVMAa0XSX1TNTQ3znzzho1aGQ0948yNiAGvjoNM=
-git.banshen.xyz/huangguangrong/slow_wild_protobuff v0.1.7/go.mod h1:RvtFTWaCnJcB8iy/clOqBoimd7UxSx5+KB96G+bdq5c=
+git.banshen.xyz/huangguangrong/slow_wild_protobuff v0.1.8 h1:BW3DLwhDNATa45Jyzp18LCbXPNGEcz9k3v9mct81ayE=
+git.banshen.xyz/huangguangrong/slow_wild_protobuff v0.1.8/go.mod h1:RvtFTWaCnJcB8iy/clOqBoimd7UxSx5+KB96G+bdq5c=
 github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
 github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
 github.com/alicebob/miniredis/v2 v2.34.0 h1:mBFWMaJSNL9RwdGRyEDoAAv8OQc5UlEhLDQggTglU/0=
@@ -76,8 +76,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
-github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
-github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
+github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
+github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
 github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
 github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
 github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -115,16 +115,16 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
 github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
-github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
-github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.21.0 h1:DIsaGmiaBkSangBgMtWdNfxbMNdku5IK6iNhrEqWvdA=
+github.com/prometheus/client_golang v1.21.0/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
 github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
 github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
-github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
-github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
+github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
+github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
 github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
 github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
-github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
-github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
+github.com/redis/go-redis/v9 v9.7.1 h1:4LhKRCIduqXqtvCUlaq9c8bdHOkICjDMrr1+Zb3osAc=
+github.com/redis/go-redis/v9 v9.7.1/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
 github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
 github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
 github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
@@ -149,8 +149,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
 github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
-github.com/zeromicro/go-zero v1.8.0 h1:4g/8VW+fOyM51HZYPeI3mXIZdEX+Fl6SsdYX2H5PYw4=
-github.com/zeromicro/go-zero v1.8.0/go.mod h1:xDBF+/iDzj30zPvu6HNUIbpz1J6+/g3Sx9D/DytJfss=
+github.com/zeromicro/go-zero v1.8.1 h1:iUYQEMQzS9Pb8ebzJtV3FGtv/YTjZxAh/NvLW/316wo=
+github.com/zeromicro/go-zero v1.8.1/go.mod h1:gc54Ad4qt7OJ0PbKajnYsSKsZBYN4JLRIXKlqDX2A2I=
 go.etcd.io/etcd/api/v3 v3.5.15 h1:3KpLJir1ZEBrYuV2v+Twaa/e2MdDCEZ/70H+lzEiwsk=
 go.etcd.io/etcd/api/v3 v3.5.15/go.mod h1:N9EhGzXq58WuMllgH9ZvnEr7SI9pS0k0+DHZezGp7jM=
 go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5fWlA=
@@ -202,8 +202,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
-golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
-golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
+golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
+golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
 golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
 golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -218,17 +218,17 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
-golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
+golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
-golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
+golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
+golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
-golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
-golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
-golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
+golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
+golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
+golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
+golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=