Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss into dev
正在显示
11 个修改的文件
包含
288 行增加
和
4 行删除
| @@ -16,7 +16,7 @@ import ( | @@ -16,7 +16,7 @@ import ( | ||
| 16 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 16 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 17 | ) | 17 | ) |
| 18 | 18 | ||
| 19 | -var configFile = flag.String("f", "etc/core.yaml", "the config file") | 19 | +var configFile = flag.String("f", "cmd/discuss/api/etc/core.yaml", "the config file") |
| 20 | 20 | ||
| 21 | func main() { | 21 | func main() { |
| 22 | flag.Parse() | 22 | flag.Parse() |
cmd/discuss/api/dsl/core/message.api
0 → 100644
| 1 | +syntax = "v1" | ||
| 2 | + | ||
| 3 | +info( | ||
| 4 | + title: "消息中心" | ||
| 5 | + desc: "消息中心" | ||
| 6 | + author: "zz" | ||
| 7 | + email: "email" | ||
| 8 | + version: "v1" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +@server( | ||
| 12 | + prefix: v1 | ||
| 13 | + group: message | ||
| 14 | + jwt: MiniAuth | ||
| 15 | +) | ||
| 16 | +service Core { | ||
| 17 | + @doc "系统消息" | ||
| 18 | + @handler miniSystem | ||
| 19 | + post /mini/message/system (MessageSystemRequest) returns (MessageBusinessResponse) | ||
| 20 | + | ||
| 21 | + @doc "业务消息" | ||
| 22 | + @handler miniBusiness | ||
| 23 | + post /mini/message/business (MessageBusinessRequest) returns (MessageBusinessResponse) | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +type ( | ||
| 27 | + MessageSystemRequest struct { | ||
| 28 | + Page int `json:"page"` | ||
| 29 | + Size int `json:"size"` | ||
| 30 | + } | ||
| 31 | + MessageSystemResponse { | ||
| 32 | + List []MessageSystemItem `json:"list"` | ||
| 33 | + Total int64 `json:"total"` | ||
| 34 | + } | ||
| 35 | + MessageSystemItem struct { | ||
| 36 | + Id int64 `json:"id"` // ID | ||
| 37 | + Type int `json:"type"` // 系统分类 | ||
| 38 | + Title string `json:"title"` // 标题 | ||
| 39 | + Content string `json:"content"` // 内容 | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + MessageBusinessRequest struct { | ||
| 43 | + Page int `json:"page"` | ||
| 44 | + Size int `json:"size"` | ||
| 45 | + } | ||
| 46 | + MessageBusinessResponse { | ||
| 47 | + List []MessageBusinessItem `json:"list"` | ||
| 48 | + Total int64 `json:"total"` | ||
| 49 | + } | ||
| 50 | + MessageBusinessItem struct { | ||
| 51 | + Id int64 `json:"id"` | ||
| 52 | + CompanyId int64 `json:"companyId"` // 公司ID | ||
| 53 | + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
| 54 | + OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | ||
| 55 | + TriggerId int64 `json:"triggerId"` // 触发者ID | ||
| 56 | + RecipientId int64 `json:"recipientId"` // 接收者ID | ||
| 57 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 58 | + CommentId int64 `json:"commentId"` // 评论ID | ||
| 59 | + DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
| 60 | + DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
| 61 | + Content string `json:"content"` // 消息内容 | ||
| 62 | + CreatedAt int64 `json:"createdAt"` // 创建时间 | ||
| 63 | + UserTrigger User `json:"userTrigger"` // 触发者 | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + User struct { | ||
| 67 | + Id int64 `json:"id"` | ||
| 68 | + CompanyId int64 `json:"companyId,omitempty"` // 公司ID | ||
| 69 | + DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID | ||
| 70 | + Name string `json:"name,omitempty"` // 名称 | ||
| 71 | + Avatar string `json:"avatar,omitempty"` // 头像 | ||
| 72 | + Position string `json:"position,omitempty"` // 职位 | ||
| 73 | + } | ||
| 74 | +) |
| 1 | +package message | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func MiniBusinessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.MessageBusinessRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := message.NewMiniBusinessLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.MiniBusiness(&req) | ||
| 22 | + | ||
| 23 | + //result.HttpResult(r, w, resp, err) | ||
| 24 | + | ||
| 25 | + if err != nil { | ||
| 26 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 27 | + } else { | ||
| 28 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | +} |
| 1 | +package message | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func MiniSystemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.MessageSystemRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := message.NewMiniSystemLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.MiniSystem(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "net/http" | 5 | "net/http" |
| 6 | 6 | ||
| 7 | comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" | 7 | comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment" |
| 8 | + message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message" | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 9 | 10 | ||
| 10 | "github.com/zeromicro/go-zero/rest" | 11 | "github.com/zeromicro/go-zero/rest" |
| @@ -34,4 +35,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -34,4 +35,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 34 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 35 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| 35 | rest.WithPrefix("/v1"), | 36 | rest.WithPrefix("/v1"), |
| 36 | ) | 37 | ) |
| 38 | + | ||
| 39 | + server.AddRoutes( | ||
| 40 | + []rest.Route{ | ||
| 41 | + { | ||
| 42 | + Method: http.MethodPost, | ||
| 43 | + Path: "/mini/message/system", | ||
| 44 | + Handler: message.MiniSystemHandler(serverCtx), | ||
| 45 | + }, | ||
| 46 | + { | ||
| 47 | + Method: http.MethodPost, | ||
| 48 | + Path: "/mini/message/business", | ||
| 49 | + Handler: message.MiniBusinessHandler(serverCtx), | ||
| 50 | + }, | ||
| 51 | + }, | ||
| 52 | + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | ||
| 53 | + rest.WithPrefix("/v1"), | ||
| 54 | + ) | ||
| 37 | } | 55 | } |
| 1 | +package message | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type MiniBusinessLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniBusinessLogic { | ||
| 19 | + return &MiniBusinessLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package message | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type MiniSystemLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewMiniSystemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSystemLogic { | ||
| 19 | + return &MiniSystemLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *MiniSystemLogic) MiniSystem(req *types.MessageSystemRequest) (resp *types.MessageBusinessResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| @@ -9,6 +9,56 @@ type CommentResposne struct { | @@ -9,6 +9,56 @@ type CommentResposne struct { | ||
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | type Comment struct { | 11 | type Comment struct { |
| 12 | - Id int64 `json:"id"` | ||
| 13 | - Content string `json:"content"` | 12 | +} |
| 13 | + | ||
| 14 | +type MessageSystemRequest struct { | ||
| 15 | + Page int `json:"page"` | ||
| 16 | + Size int `json:"size"` | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +type MessageSystemResponse struct { | ||
| 20 | + List []MessageSystemItem `json:"list"` | ||
| 21 | + Total int64 `json:"total"` | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +type MessageSystemItem struct { | ||
| 25 | + Id int64 `json:"id"` // ID | ||
| 26 | + Type int `json:"type"` // 系统分类 | ||
| 27 | + Title string `json:"title"` // 标题 | ||
| 28 | + Content string `json:"content"` // 内容 | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +type MessageBusinessRequest struct { | ||
| 32 | + Page int `json:"page"` | ||
| 33 | + Size int `json:"size"` | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +type MessageBusinessResponse struct { | ||
| 37 | + List []MessageBusinessItem `json:"list"` | ||
| 38 | + Total int64 `json:"total"` | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +type MessageBusinessItem struct { | ||
| 42 | + Id int64 `json:"id"` | ||
| 43 | + CompanyId int64 `json:"companyId"` // 公司ID | ||
| 44 | + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
| 45 | + OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | ||
| 46 | + TriggerId int64 `json:"triggerId"` // 触发者ID | ||
| 47 | + RecipientId int64 `json:"recipientId"` // 接收者ID | ||
| 48 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 49 | + CommentId int64 `json:"commentId"` // 评论ID | ||
| 50 | + DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
| 51 | + DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
| 52 | + Content string `json:"content"` // 消息内容 | ||
| 53 | + CreatedAt int64 `json:"createdAt"` // 创建时间 | ||
| 54 | + UserTrigger User `json:"userTrigger"` // 触发者 | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +type User struct { | ||
| 58 | + Id int64 `json:"id"` | ||
| 59 | + CompanyId int64 `json:"companyId,omitempty"` // 公司ID | ||
| 60 | + DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID | ||
| 61 | + Name string `json:"name,omitempty"` // 名称 | ||
| 62 | + Avatar string `json:"avatar,omitempty"` // 头像 | ||
| 63 | + Position string `json:"position,omitempty"` // 职位 | ||
| 14 | } | 64 | } |
| @@ -23,6 +23,21 @@ type MessageBusiness struct { | @@ -23,6 +23,21 @@ type MessageBusiness struct { | ||
| 23 | Version int `json:",omitempty"` | 23 | Version int `json:",omitempty"` |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | +type MsgBusinessType int | ||
| 27 | +type MsgBusinessOpt int | ||
| 28 | + | ||
| 29 | +const ( | ||
| 30 | + MsgTypeReply MsgBusinessType = 1 // 消息分类-回复 | ||
| 31 | + MsgTypeLike MsgBusinessType = 2 // 消息分类-点赞 | ||
| 32 | + MsgTypeAccept MsgBusinessType = 3 // 消息分类-被采纳 | ||
| 33 | +) | ||
| 34 | + | ||
| 35 | +const ( | ||
| 36 | + OptTypeArticle MsgBusinessOpt = 1 // 操作分类-针对文章 | ||
| 37 | + OptTypeComment MsgBusinessOpt = 2 // 操作分类-针对评论 | ||
| 38 | + OptTypeDiscussion MsgBusinessOpt = 3 // 操作分类-针对讨论 | ||
| 39 | +) | ||
| 40 | + | ||
| 26 | type MessageBusinessRepository interface { | 41 | type MessageBusinessRepository interface { |
| 27 | Insert(ctx context.Context, conn transaction.Conn, dm *MessageBusiness) (*MessageBusiness, error) | 42 | Insert(ctx context.Context, conn transaction.Conn, dm *MessageBusiness) (*MessageBusiness, error) |
| 28 | Update(ctx context.Context, conn transaction.Conn, dm *MessageBusiness) (*MessageBusiness, error) | 43 | Update(ctx context.Context, conn transaction.Conn, dm *MessageBusiness) (*MessageBusiness, error) |
| @@ -18,6 +18,13 @@ type MessageSystem struct { | @@ -18,6 +18,13 @@ type MessageSystem struct { | ||
| 18 | Version int `json:",omitempty"` | 18 | Version int `json:",omitempty"` |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | +type MsgSystemType int | ||
| 22 | + | ||
| 23 | +const ( | ||
| 24 | + MsgTypeNormal MsgSystemType = 0 | ||
| 25 | + MsgTypeAbnormal MsgSystemType = 1 | ||
| 26 | +) | ||
| 27 | + | ||
| 21 | type MessageSystemRepository interface { | 28 | type MessageSystemRepository interface { |
| 22 | Insert(ctx context.Context, conn transaction.Conn, dm *MessageSystem) (*MessageSystem, error) | 29 | Insert(ctx context.Context, conn transaction.Conn, dm *MessageSystem) (*MessageSystem, error) |
| 23 | Update(ctx context.Context, conn transaction.Conn, dm *MessageSystem) (*MessageSystem, error) | 30 | Update(ctx context.Context, conn transaction.Conn, dm *MessageSystem) (*MessageSystem, error) |
-
请 注册 或 登录 后发表评论