作者 yangfu

用户关注

... ... @@ -731,7 +731,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniHomePageRespose"
"$ref": "#/definitions/MiniHomePageResponse"
}
}
},
... ... @@ -741,7 +741,35 @@
]
}
},
"v1/mini/user/apply-join-company": {
"v1/mini/show/search_article": {
"post": {
"summary": "小程序首页搜索文章",
"operationId": "MiniSearchArticlePage",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniSearchArticleResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniSearchArticleRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/user/apply_join_company": {
"post": {
"summary": "用户申请加入公司",
"operationId": "miniUserApplyJoinCompany",
... ... @@ -795,7 +823,7 @@
]
}
},
"v1/mini/user/audit-list": {
"v1/mini/user/audit_list": {
"post": {
"summary": "用户审核列表",
"operationId": "miniUserAuditList",
... ... @@ -823,16 +851,14 @@
]
}
},
"v1/mini/user/department-users": {
"v1/mini/user/department_users": {
"post": {
"summary": "部门用户列表",
"operationId": "miniUserDepartmentUsers",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniUserInfoResponse"
}
"schema": {}
}
},
"parameters": [
... ... @@ -933,6 +959,60 @@
]
}
},
"v1/mini/user/following/latest_unread_list": {
"post": {
"summary": "我关注的人-最新未读列表(未读标红)",
"operationId": "miniUserFollowingLatestUnreadList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniUserFollowedSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUserFollowedSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/following/mark_read": {
"post": {
"summary": "我关注的人-标记已读",
"operationId": "miniUserFollowingMarkRead",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUserFollowingMarkReadRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/info": {
"post": {
"summary": "用户信息",
... ... @@ -989,7 +1069,63 @@
]
}
},
"v1/mini/user/switch-account": {
"v1/mini/user/news": {
"post": {
"summary": "用户快讯",
"operationId": "miniUserNews",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniUserNewsResposne"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUserNewsRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/statistics": {
"post": {
"summary": "用户统计",
"operationId": "miniUserStatistics",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/UserStatisticsResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/UserStatisticsRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/switch_account": {
"post": {
"summary": "切换账号",
"operationId": "miniUserSwitchAccount",
... ... @@ -1043,6 +1179,32 @@
]
}
},
"v1/mini/user/user_list": {
"post": {
"summary": "用户列表",
"operationId": "miniUsersList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUsersListRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/system/account": {
"post": {
"summary": "系统新增账号",
... ... @@ -1997,6 +2159,32 @@
]
}
},
"v1/system/user/user_list": {
"post": {
"summary": "用户列表",
"operationId": "systemUsersList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUsersListRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/system/user/{id}": {
"get": {
"summary": "用户详情",
... ... @@ -2375,7 +2563,7 @@
"ArticleTagCount": {
"type": "object",
"properties": {
"tagGroup": {
"tagCategory": {
"type": "string",
"description": " 标签分组"
},
... ... @@ -2409,7 +2597,7 @@
},
"title": "ArticleTagCount",
"required": [
"tagGroup",
"tagCategory",
"tagId",
"tagImage",
"tagName",
... ... @@ -2421,7 +2609,7 @@
"ArticleTagGroup": {
"type": "object",
"properties": {
"group": {
"category": {
"type": "string"
},
"tags": {
... ... @@ -2433,7 +2621,7 @@
},
"title": "ArticleTagGroup",
"required": [
"group",
"category",
"tags"
]
},
... ... @@ -2444,7 +2632,7 @@
"type": "integer",
"format": "int64"
},
"group": {
"category": {
"type": "string"
},
"name": {
... ... @@ -2457,7 +2645,7 @@
"title": "ArticleTagItem",
"required": [
"id",
"group",
"category",
"name",
"image"
]
... ... @@ -3698,7 +3886,7 @@
"show": {
"type": "integer",
"format": "int32",
"description": " 评论的展示状态(0显示、1不显示)"
"description": " 评论的展示状态(1显示、2不显示)"
},
"edit": {
"type": "integer",
... ... @@ -3709,6 +3897,13 @@
"type": "integer",
"format": "int32",
"description": " 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "文章的标签"
}
},
"title": "MiniArticleGetResponse",
... ... @@ -3728,7 +3923,8 @@
"countRead",
"show",
"edit",
"meLoveFlag"
"meLoveFlag",
"tags"
]
},
"MiniArticleMarkItem": {
... ... @@ -4157,9 +4353,15 @@
},
"title": "MiniHomePageRequest"
},
"MiniHomePageRespose": {
"MiniHomePageResponse": {
"type": "object",
"properties": {
"tagCategory": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
... ... @@ -4167,8 +4369,9 @@
}
}
},
"title": "MiniHomePageRespose",
"title": "MiniHomePageResponse",
"required": [
"tagCategory",
"tags"
]
},
... ... @@ -4265,6 +4468,115 @@
"total"
]
},
"MiniSearchArticleItem": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string"
},
"author": {
"type": "string",
"description": " 发布人"
},
"images": {
"type": "array",
"items": {
"type": "string"
}
},
"createdAt": {
"type": "integer",
"format": "int64"
},
"meReadFlag": {
"type": "integer",
"format": "int32",
"description": "已读标识 [0:未读] [1:已读]"
}
},
"title": "MiniSearchArticleItem",
"required": [
"articleId",
"title",
"author",
"images",
"createdAt",
"meReadFlag"
]
},
"MiniSearchArticleRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"tagCategory": {
"type": "string"
},
"tagId": {
"type": "integer",
"format": "int64"
},
"beginTime": {
"type": "integer",
"format": "int64"
},
"endTime": {
"type": "integer",
"format": "int64"
},
"searchWord": {
"type": "string"
}
},
"title": "MiniSearchArticleRequest",
"required": [
"page",
"size",
"tagCategory",
"tagId",
"beginTime",
"endTime",
"searchWord"
]
},
"MiniSearchArticleResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MiniSearchArticleItem"
}
}
},
"title": "MiniSearchArticleResponse",
"required": [
"total",
"list"
]
},
"MiniSetUserLikeRequset": {
"type": "object",
"properties": {
... ... @@ -4458,6 +4770,19 @@
"total"
]
},
"MiniUserFollowingMarkReadRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniUserFollowingMarkReadRequest",
"required": [
"userId"
]
},
"MiniUserInfoRequest": {
"type": "object",
"title": "MiniUserInfoRequest"
... ... @@ -4610,6 +4935,51 @@
"success"
]
},
"MiniUserNewsRequest": {
"type": "object",
"properties": {
"authorId": {
"type": "integer",
"format": "int64",
"description": " 特定作者ID"
},
"lastArticleId": {
"type": "integer",
"format": "int64",
"description": " 最后文章ID"
},
"size": {
"type": "integer",
"format": "int32",
"description": " 数量"
}
},
"title": "MiniUserNewsRequest",
"required": [
"size"
]
},
"MiniUserNewsResposne": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/UserNewsItem"
}
},
"lastArticleId": {
"type": "integer",
"format": "int64",
"description": " 最后文章ID"
}
},
"title": "MiniUserNewsResposne",
"required": [
"list",
"lastArticleId"
]
},
"MiniUserSwitchAccountRequest": {
"type": "object",
"properties": {
... ... @@ -4623,6 +4993,22 @@
"companyId"
]
},
"MiniUsersListRequest": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64",
"description": " 按文章ID(返回文章可见的用户)"
},
"roleId": {
"type": "integer",
"format": "int64",
"description": " 按角色角色关联的用户"
}
},
"title": "MiniUsersListRequest"
},
"MyLikeItem": {
"type": "object",
"properties": {
... ... @@ -6738,6 +7124,11 @@
"type": "boolean",
"format": "boolean",
"description": " 互相关注标识"
},
"readFlag": {
"type": "boolean",
"format": "boolean",
"description": " 已读标识 true:已读 false:未读(小红点)"
}
},
"title": "UserFollowItem",
... ... @@ -6748,7 +7139,8 @@
"avatar",
"position",
"followed",
"mutualFollowed"
"mutualFollowed",
"readFlag"
]
},
"UserItem": {
... ... @@ -6768,6 +7160,10 @@
"type": "string",
"description": " 公司名称"
},
"companyCode": {
"type": "string",
"description": " 公司编码(邀请码)"
},
"flag": {
"type": "integer",
"format": "int32",
... ... @@ -6832,6 +7228,7 @@
"id",
"companyId",
"companyName",
"companyCode",
"flag",
"name",
"avatar",
... ... @@ -6845,6 +7242,47 @@
"accountFrom"
]
},
"UserNewsItem": {
"type": "object",
"properties": {
"newsId": {
"type": "integer",
"format": "int64",
"description": " 快讯ID"
},
"type": {
"type": "string",
"description": " 快讯类型 文章:Article 讨论:Discuss ..."
},
"title": {
"type": "string",
"description": " 标题"
},
"summary": {
"type": "string",
"description": " 快讯概要"
},
"time": {
"type": "integer",
"format": "int64",
"description": " 时间"
},
"readFlag": {
"type": "boolean",
"format": "boolean",
"description": " 已读标识 true:已读 false:未读"
}
},
"title": "UserNewsItem",
"required": [
"newsId",
"type",
"title",
"summary",
"time",
"readFlag"
]
},
"UserSearchRequest": {
"type": "object",
"properties": {
... ...
... ... @@ -86,6 +86,7 @@ service Core {
@server(
prefix: v1/system
group: article
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
... ...
... ... @@ -11,6 +11,7 @@ info(
@server(
prefix: v1/system
group: tags
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
... ...
... ... @@ -35,6 +35,7 @@ service Core {
@server(
prefix: v1
group: company
middleware: LoginStatusCheck
jwt : SystemAuth
)
service Core {
... ...
... ... @@ -131,7 +131,7 @@ type(
}
MiniUserNewsResposne{
List []UserNewsItem `json:"list"`
Total int64 `json:"total"`
LastArticleId int64 `json:"lastArticleId"`// 最后文章ID
}
UserNewsItem{
NewsId int64 `json:"newsId"` // 快讯ID
... ...
Name: discuss
Host: 0.0.0.0
Port: 8081
Verbose: false
Verbose: true
Migrate: false
Timeout: 30000
Log:
... ...
... ... @@ -93,38 +93,41 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_tag",
Handler: tags.CreateTagHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article_tag",
Handler: tags.EditTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/:id",
Handler: tags.GetTagHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_tag/:id",
Handler: tags.DeleteTagHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_tag/search",
Handler: tags.SearchTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/options",
Handler: tags.OptionsHandler(serverCtx),
},
},
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_tag",
Handler: tags.CreateTagHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article_tag",
Handler: tags.EditTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/:id",
Handler: tags.GetTagHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_tag/:id",
Handler: tags.DeleteTagHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_tag/search",
Handler: tags.SearchTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/options",
Handler: tags.OptionsHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
... ... @@ -316,13 +319,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/system/company/search",
Handler: company.SystemCompanySearchHandler(serverCtx),
},
},
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/system/company/search",
Handler: company.SystemCompanySearchHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1"),
)
... ... @@ -420,43 +426,46 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/article/:id",
Handler: article.SystemGetArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search",
Handler: article.SystemSearchArticleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article",
Handler: article.SystemUpdateArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/history",
Handler: article.SystemHistoryArticleHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article/history/:id",
Handler: article.SystemArticleGetHistoryHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.SystemArticleSearchMeHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/restore",
Handler: article.SystemArticleRestoreHandler(serverCtx),
},
},
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck},
[]rest.Route{
{
Method: http.MethodGet,
Path: "/article/:id",
Handler: article.SystemGetArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search",
Handler: article.SystemSearchArticleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article",
Handler: article.SystemUpdateArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/history",
Handler: article.SystemHistoryArticleHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article/history/:id",
Handler: article.SystemArticleGetHistoryHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.SystemArticleSearchMeHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/restore",
Handler: article.SystemArticleRestoreHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
... ...
... ... @@ -49,6 +49,9 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res
if err != nil {
return
}
if loginInfo.User == nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
var userJwtToken = tool.UserToken{}
if loginInfo.User != nil {
userJwtToken.UserId = loginInfo.User.Id
... ...
... ... @@ -2,6 +2,10 @@ package user
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -24,7 +28,51 @@ func NewMiniUserNewsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini
}
func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *types.MiniUserNewsResposne, err error) {
// todo: add your logic here and delete this line
var (
conn = l.svcCtx.DefaultDBConn()
user *domain.User
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
articles []*domain.Article
readedArticles = make([]*domain.UserReadArticle, 0)
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
var (
users = user.Following
)
if req.AuthorId > 0 {
users = []int64{req.AuthorId}
}
if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil {
return nil, xerr.NewErrMsgErr("获取快讯异常", err)
}
resp = &types.MiniUserNewsResposne{
List: make([]types.UserNewsItem, 0),
}
articleIds := domain.Values(articles, func(item *domain.Article) int64 {
return item.Id
})
if len(articleIds) > 0 {
resp.LastArticleId = articleIds[len(articleIds)-1]
_, readedArticles, _ = l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithKV("articleIds", articleIds))
}
readArticlesMap := lo.KeyBy(readedArticles, func(item *domain.UserReadArticle) int64 {
return item.ArticleId
})
lo.ForEach(articles, func(item *domain.Article, index int) {
newsItem := types.UserNewsItem{
NewsId: item.Id,
Type: "article",
Title: item.Title,
Summary: item.Summary,
Time: item.CreatedAt,
ReadFlag: false,
}
if _, ok := readArticlesMap[item.Id]; ok {
newsItem.ReadFlag = true
}
resp.List = append(resp.List, newsItem)
})
return
}
... ...
... ... @@ -387,8 +387,8 @@ type MiniUserNewsRequest struct {
}
type MiniUserNewsResposne struct {
List []UserNewsItem `json:"list"`
Total int64 `json:"total"`
List []UserNewsItem `json:"list"`
LastArticleId int64 `json:"lastArticleId"` // 最后文章ID
}
type UserNewsItem struct {
... ...
... ... @@ -168,12 +168,14 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).
Where("id < ?", lastId).
Where("company_id=?", companyId).
Where("author_id in (?)", authors).
Where("target_user=0 or who_read @>'[?]'", whoRead).
Where("show = 1").
Order("id desc")
Where(fmt.Sprintf("target_user=0 or who_read @>'[%d]'", whoRead)).
Where("show = 1")
if lastId > 0 {
tx.Where("id < ?", lastId)
}
tx.Order("id desc")
if limit > 0 {
tx.Limit(limit)
}
... ...
... ... @@ -40,6 +40,7 @@ type ArticleRepository interface {
Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*Article, error)
FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*Article, error)
IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //点赞数量变动
IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //评论数量变动
IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //浏览数量变动
... ...