Refactor backend APIs to RESTful route patterns.

Align group and conversation handlers/services with path-based endpoints, and unify response/service error handling for related modules.

Made-with: Cursor
This commit is contained in:
2026-03-10 20:52:50 +08:00
parent 86ef150fec
commit 21293644b8
10 changed files with 217 additions and 189 deletions

View File

@@ -25,23 +25,23 @@ const (
// 群组服务错误定义
var (
ErrGroupNotFound = errors.New("群组不存在")
ErrNotGroupMember = errors.New("不是群成员")
ErrNotGroupAdmin = errors.New("不是群管理员")
ErrNotGroupOwner = errors.New("不是群主")
ErrGroupFull = errors.New("群已满")
ErrAlreadyMember = errors.New("已经是群成员")
ErrCannotRemoveOwner = errors.New("不能移除群主")
ErrCannotMuteOwner = errors.New("不能禁言群主")
ErrMuted = errors.New("你已被禁言")
ErrMuteAllEnabled = errors.New("全员禁言中")
ErrCannotJoin = errors.New("该群不允许加入")
ErrJoinRequestPending = errors.New("加群申请已提交")
ErrGroupRequestNotFound = errors.New("加群请求不存在")
ErrGroupRequestHandled = errors.New("该加群请求已处理")
ErrNotRequestTarget = errors.New("不是邀请目标用户")
ErrNoEligibleInvitee = errors.New("没有可邀请的用户")
ErrNotMutualFollow = errors.New("仅支持邀请互相关注用户")
ErrGroupNotFound = &ServiceError{Code: 404, Message: "群组不存在"}
ErrNotGroupMember = &ServiceError{Code: 403, Message: "不是群成员"}
ErrNotGroupAdmin = &ServiceError{Code: 403, Message: "不是群管理员"}
ErrNotGroupOwner = &ServiceError{Code: 403, Message: "不是群主"}
ErrGroupFull = &ServiceError{Code: 400, Message: "群已满"}
ErrAlreadyMember = &ServiceError{Code: 400, Message: "已经是群成员"}
ErrCannotRemoveOwner = &ServiceError{Code: 400, Message: "不能移除群主"}
ErrCannotMuteOwner = &ServiceError{Code: 400, Message: "不能禁言群主"}
ErrMuted = &ServiceError{Code: 403, Message: "你已被禁言"}
ErrMuteAllEnabled = &ServiceError{Code: 403, Message: "全员禁言中"}
ErrCannotJoin = &ServiceError{Code: 400, Message: "该群不允许加入"}
ErrJoinRequestPending = &ServiceError{Code: 400, Message: "加群申请已提交"}
ErrGroupRequestNotFound = &ServiceError{Code: 404, Message: "加群请求不存在"}
ErrGroupRequestHandled = &ServiceError{Code: 400, Message: "该加群请求已处理"}
ErrNotRequestTarget = &ServiceError{Code: 400, Message: "不是邀请目标用户"}
ErrNoEligibleInvitee = &ServiceError{Code: 400, Message: "没有可邀请的用户"}
ErrNotMutualFollow = &ServiceError{Code: 400, Message: "仅支持邀请互相关注用户"}
)
// GroupService 群组服务接口