作者 tangxvhui

Merge branch 'dev' into test

正在显示 30 个修改的文件 包含 801 行增加166 行删除
# 说明
### 测试环境
服务端域名 http://sumifcc-discuss-test.sumifcc.com/
### 可设置环境变量
- DataSource
数据库连接,样例
``` code
host=数据库IP地址 user=用户名 password=密码 dbname=数据库名 port=31543 sslmode=disable TimeZone=Asia/Shanghai
```
\ No newline at end of file
... ...
... ... @@ -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 {
... ... @@ -47,7 +48,7 @@ type (
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
TagCreateResponse {
... ... @@ -64,7 +65,7 @@ type (
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
TagEditResponse {
... ...
... ... @@ -248,7 +248,7 @@ type (
MiniArticleDraftGetMeResponse {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"Section"` // 填写的内容
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
... ... @@ -356,6 +356,7 @@ type (
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
... ...
... ... @@ -229,7 +229,7 @@ type (
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId"` // 文章顶层ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
AuthorId int64 `json:"authorId,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
... ...
... ... @@ -35,6 +35,7 @@ service Core {
@server(
prefix: v1
group: company
middleware: LoginStatusCheck
jwt : SystemAuth
)
service Core {
... ...
... ... @@ -71,9 +71,9 @@ type (
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
CompanyName string `json:"companyName,omitempty"` // 公司名称
Name string `json:"name,omitempty"` // 名称
Avatar string `json:"avatar,omitempty"` // 头像
Position string `json:"position,omitempty"` // 职位
Name string `json:"name"` // 名称
Avatar string `json:"avatar"` // 头像
Position string `json:"position"` // 职位
}
... ...
... ... @@ -71,7 +71,7 @@ service Core {
post /mini/user/unfollow (FollowRequest)
@doc "我点赞的文章或评论"
@handler miniMyLike
post /user/mylike (MiniMyLikeRequest)returns (MiniMyLikeResponse)
post /mini/user/mylike (MiniMyLikeRequest)returns (MiniMyLikeResponse)
}
type(
... ... @@ -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
... ... @@ -183,9 +183,10 @@ type(
}
Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
CompanyId int64 `json:"companyId"` // 公司ID
ParentId int64 `json:"parentId"` // 父级ID
Name string `json:"name"` // 部门名称
UserIds []int64 `json:"userIds"` // 部门下的用户
}
UserSearchRequest{
Page int `json:"page,optional"`
... ...
Name: discuss
Host: 0.0.0.0
Port: 8081
Verbose: false
Verbose: true
Migrate: false
Timeout: 30000
# CertFile: ./key/fjmaimaimai.com_bundle.crt
# KeyFile: ./key/fjmaimaimai.com.key
Log:
#Mode: file
Encoding: plain
... ...
... ... @@ -113,38 +113,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"),
)
... ... @@ -239,7 +242,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
{
Method: http.MethodPost,
Path: "/user/mylike",
Path: "/mini/user/mylike",
Handler: user.MiniMyLikeHandler(serverCtx),
},
},
... ... @@ -336,13 +339,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"),
)
... ... @@ -440,43 +446,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"),
)
... ...
... ... @@ -51,6 +51,8 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
}
if len(markRecord) > 0 {
markRecord[0].Author = articleData.Author
markRecord[0].Title = articleData.Title
_, err = l.svcCtx.UserReadArticleRepository.Update(l.ctx, conn, markRecord[0])
if err != nil {
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
... ...
... ... @@ -170,11 +170,11 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
//设置内容概要
if len(sectionList) > 0 {
// 截取内容 30个字
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range sectionList[0].Content {
if runeNumber > 30 {
if runeNumber > 50 {
break
}
runeNumber += 1
... ...
... ... @@ -47,11 +47,12 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
images = append(images, val.Url)
}
resp.List[i] = types.MiniArticleDraftItem{
Id: draftList[i].Id,
Template: draftList[i].Template,
Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
Id: draftList[i].Id,
Template: draftList[i].Template,
Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
CreatedAt: draftList[i].CreatedAt,
}
}
return resp, nil
... ...
... ... @@ -65,6 +65,7 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ
CountRead: article.CountRead,
Show: int(article.Show),
Tags: make([]types.ArticleTagItem, 0),
TargetUser: int(article.TargetUser),
}
//标签
if len(article.Tags) > 0 {
... ...
... ... @@ -4,6 +4,8 @@ import (
"context"
"strconv"
"strings"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
... ... @@ -11,7 +13,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"strings"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -147,11 +148,11 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
})
//设置内容概要
if len(req.Section) > 0 {
// 截取内容 30个字
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range req.Section[0].Content {
if runeNumber > 30 {
if runeNumber > 50 {
break
}
runeNumber += 1
... ...
... ... @@ -57,6 +57,7 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
if len(req.Ids) > 0 {
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithOffsetLimit(1, len(req.Ids)).WithFindOnly().
WithKV("ids", req.Ids).
WithKV("companyId", userToken.CompanyId))
if err != nil {
return err
... ...
... ... @@ -4,6 +4,8 @@ import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"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"
"github.com/zeromicro/go-zero/core/logx"
... ... @@ -24,17 +26,32 @@ func NewSystemGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemG
}
func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
var conn = l.svcCtx.DefaultDBConn()
department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsg("数据不存在")
}
// 部门下的用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().
WithKV("companyId", userToken.CompanyId).
WithKV("auditStatus", domain.UserAuditStatusPassed).
WithKV("departmentId", department.Id))
if err != nil {
return nil, err
}
ids := make([]int64, 0)
for i := range users {
ids = append(ids, users[i].Id)
}
resp = &types.DepartmentGetResponse{
Department: types.Department{
Id: department.Id,
CompanyId: department.CompanyId,
ParentId: department.ParentId,
Name: department.Name,
UserIds: ids,
},
}
return resp, nil
... ...
... ... @@ -43,10 +43,7 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
if cnt > 0 {
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
}
//获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
newTag := &domain.ArticleTag{
Id: 0,
CompanyId: req.CompanyId,
... ... @@ -54,17 +51,23 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
UpdatedAt: 0,
DeletedAt: 0,
Version: 0,
Image: domain.Image{
Image: domain.Image{},
Name: req.Name,
Category: req.Category,
Remark: req.Remark,
Other: req.Other,
}
if len(req.Image) > 0 {
//获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
newTag.Image = domain.Image{
Url: req.Image,
Width: w,
Height: h,
},
Name: req.Name,
Category: req.Category,
Remark: req.Remark,
Other: req.Other,
}
}
newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
... ...
... ... @@ -54,16 +54,19 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
if oldTag.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("修改标签失败")
}
//获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
oldTag.Category = req.Category
oldTag.Image = domain.Image{
Url: req.Image,
Width: w,
Height: h,
oldTag.Image = domain.Image{}
if len(req.Image) > 0 {
// 获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
oldTag.Image = domain.Image{
Url: req.Image,
Width: w,
Height: h,
}
}
oldTag.Category = req.Category
oldTag.Name = req.Name
oldTag.Remark = req.Remark
oldTag.Other = req.Other
... ...
... ... @@ -28,10 +28,10 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
if len(req.Category) > 0 {
queryOptions = queryOptions.MustWithKV("group", req.Category)
queryOptions = queryOptions.MustWithKV("group", "%"+req.Category+"%")
}
if len(req.TagName) > 0 {
queryOptions = queryOptions.MustWithKV("name", req.TagName)
queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%")
}
if len(req.Remark) > 0 {
... ...
... ... @@ -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
}
... ...
... ... @@ -93,12 +93,70 @@ func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (
}
}
}
err = l.initSystemData(companyId)
if err != nil {
return nil, err
}
return
}
// 后台登录时检查/设置公司的初始数据
// 后台登录时检查/设置公司的初始数据
func (l *SystemUserInfoLogic) initSystemData(companyId int64) error {
// TODO 初始设置文章标签
// 初始设置文章标签
queryOption := domain.NewQueryOptions().WithCountOnly()
conn := l.svcCtx.DefaultDBConn()
cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption)
if err != nil {
return xerr.NewErrMsgErr("初始话公司数据失败", err)
}
if cnt == 0 {
articleTags := []*domain.ArticleTag{
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9,
},
{
Id: 0, CompanyId: companyId, Image: domain.Image{Url: "", Width: 0, Height: 0},
Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10,
},
}
err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags)
if err != nil {
return xerr.NewErrMsgErr("初始话公司数据失败", err)
}
}
return nil
}
... ...
... ... @@ -140,7 +140,7 @@ type SystemArticleCommentSearchRequest struct {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId"` // 文章顶层ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
AuthorId int64 `json:"authorId,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
... ... @@ -296,9 +296,9 @@ type SimpleUser struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
CompanyName string `json:"companyName,omitempty"` // 公司名称
Name string `json:"name,omitempty"` // 名称
Avatar string `json:"avatar,omitempty"` // 头像
Position string `json:"position,omitempty"` // 职位
Name string `json:"name"` // 名称
Avatar string `json:"avatar"` // 头像
Position string `json:"position"` // 职位
}
type SimpleArticle struct {
... ... @@ -316,7 +316,7 @@ type TagCreateRequest struct {
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
type TagCreateResponse struct {
... ... @@ -330,7 +330,7 @@ type TagEditRequest struct {
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
type TagEditResponse struct {
... ... @@ -464,8 +464,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 {
... ... @@ -519,10 +519,11 @@ type Account struct {
}
type Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId"` // 公司ID
ParentId int64 `json:"parentId"` // 父级ID
Name string `json:"name"` // 部门名称
UserIds []int64 `json:"userIds"` // 部门下的用户
}
type UserSearchRequest struct {
... ... @@ -949,7 +950,7 @@ type MiniArticleDraftGetMeRequest struct {
type MiniArticleDraftGetMeResponse struct {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"Section"` // 填写的内容
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
... ... @@ -1047,6 +1048,7 @@ type SystemArticleGetResponse struct {
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleSearchRequest struct {
... ...
... ... @@ -136,7 +136,9 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
if v, ok := queryOptions["endCreatedAt"]; ok {
tx = tx.Where("created_at < ?", v)
}
if v, ok := queryOptions["authorId"]; ok {
tx = tx.Where("author_id=?", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ... @@ -168,12 +170,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)
}
... ...
... ... @@ -33,7 +33,28 @@ func (repository *ArticleTagRepository) Insert(ctx context.Context, conn transac
}
// func (repository *ArticleTagRepository) CreateInBatches
func (repository *ArticleTagRepository) CreateInBatches(ctx context.Context, conn transaction.Conn, dm []*domain.ArticleTag) error {
var (
ms = []*models.ArticleTag{}
tx = conn.DB()
)
for _, val := range dm {
m, err := repository.DomainModelToModel(val)
if err != nil {
return err
}
ms = append(ms, m)
}
if tx = tx.CreateInBatches(ms, 100); tx.Error != nil {
return tx.Error
}
for i, val := range ms {
dm[i].Id = val.Id
}
return nil
}
func (repository *ArticleTagRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTag) (*domain.ArticleTag, error) {
var (
... ... @@ -134,7 +155,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti
if v, ok := queryOptions["ids"]; ok {
tx = tx.Where("id in (?)", v)
}
if v, ok := queryOptions["remark"]; ok {
tx = tx.Where("remark like ?", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -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 //浏览数量变动
... ...
... ... @@ -24,6 +24,7 @@ type ArticleTag struct {
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
CreateInBatches(ctx context.Context, conn transaction.Conn, dm []*ArticleTag) error
Update(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
... ...
... ... @@ -10,7 +10,7 @@ type Auth struct {
}
type Config struct {
DB struct {
DataSource string
DataSource string `json:",env=DataSource"`
} `json:",optional"`
Cache cache.CacheConf `json:",optional"`
DTM DTM `json:",optional"`
... ...