作者 yangfu

角色权限

正在显示 29 个修改的文件 包含 2725 行增加407 行删除
... ... @@ -3,4 +3,5 @@ import "core/message.api"
import "core/article_tag.api"
import "core/user.api"
import "core/company.api"
import "core/article.api"
\ No newline at end of file
import "core/article.api"
import "core/role.api"
\ No newline at end of file
... ...
... ... @@ -15,15 +15,15 @@
"application/json"
],
"paths": {
"v1/mini/article_tag": {
"delete": {
"summary": "后台删除文章标签",
"operationId": "DeleteTag",
"v1/mini/article": {
"post": {
"summary": "小程序创建发布内容",
"operationId": "MiniCreateArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagDeleteResponse"
"$ref": "#/definitions/MiniArticleCreateResponse"
}
}
},
... ... @@ -33,23 +33,25 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagDeleteRequest"
"$ref": "#/definitions/MiniArticleCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
"article"
]
},
}
},
"v1/mini/article/search/me": {
"post": {
"summary": "后台创建文章标签",
"operationId": "CreateTag",
"summary": "小程序获取我发布的文章",
"operationId": "MiniArticleSearchMe",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagCreateResponse"
"$ref": "#/definitions/MiniArticleSearchMeResponse"
}
}
},
... ... @@ -59,23 +61,25 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagCreateRequest"
"$ref": "#/definitions/MiniArticleSearchMeRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
"article"
]
},
"put": {
"summary": "后台编辑文章标签",
"operationId": "EditTag",
}
},
"v1/mini/article/user_like/list": {
"post": {
"summary": "小程序获取文章的点赞人员列表",
"operationId": "MiniUserLikeArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagEditResponse"
"$ref": "#/definitions/MiniUserLikeArticleResponse"
}
}
},
... ... @@ -85,25 +89,53 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagEditRequest"
"$ref": "#/definitions/MiniUserLikeArticleRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
"article"
]
}
},
"v1/mini/article/user_like/set": {
"post": {
"summary": "小程序人员操作点赞文章/评论",
"operationId": "MiniSetUserLike",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniSetUserLikeResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniSetUserLikeRequset"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/article_tag/{id}": {
"v1/mini/article/{id}": {
"get": {
"summary": "后台获取文章标签",
"operationId": "GetTag",
"summary": "小程序获取文章内容详情",
"operationId": "MiniGetArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagGetResponse"
"$ref": "#/definitions/MiniArticleGetResponse"
}
}
},
... ... @@ -113,18 +145,11 @@
"in": "path",
"required": true,
"type": "string"
},
{
"name": "id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
}
],
"requestBody": {},
"tags": [
"tags"
"article"
]
}
},
... ... @@ -374,7 +399,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/UserSearchResponse"
"$ref": "#/definitions/MiniUserFollowedSearchResponse"
}
}
},
... ... @@ -384,7 +409,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/UserSearchRequest"
"$ref": "#/definitions/MiniUserFollowedSearchRequest"
}
}
],
... ... @@ -402,7 +427,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/UserSearchResponse"
"$ref": "#/definitions/MiniUserFollowedSearchResponse"
}
}
},
... ... @@ -412,7 +437,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/UserSearchRequest"
"$ref": "#/definitions/MiniUserFollowedSearchRequest"
}
}
],
... ... @@ -478,6 +503,34 @@
]
}
},
"v1/mini/user/switch-account": {
"post": {
"summary": "切换账号",
"operationId": "miniUserSwitchAccount",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniUserLoginResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUserSwitchAccountRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/unfollow": {
"post": {
"summary": "取消关注",
... ... @@ -504,6 +557,146 @@
]
}
},
"v1/system/article_tag": {
"post": {
"summary": "后台创建文章标签",
"operationId": "CreateTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagCreateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
},
"put": {
"summary": "后台编辑文章标签",
"operationId": "EditTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagEditResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagEditRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/system/article_tag/search": {
"post": {
"summary": "后台搜索标签",
"operationId": "SearchTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagListResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagListRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/system/article_tag/{id}": {
"get": {
"summary": "后台获取文章标签",
"operationId": "GetTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"tags"
]
},
"delete": {
"summary": "后台删除文章标签",
"operationId": "DeleteTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagDeleteResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/system/comment": {
"get": {
"summary": "系统评论",
... ... @@ -549,64 +742,911 @@
"company"
]
}
}
},
"definitions": {
"Comment": {
"type": "object",
"title": "Comment"
},
"CommentRequest": {
"type": "object",
"title": "CommentRequest"
},
"CommentResposne": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Comment"
"v1/system/role": {
"post": {
"operationId": "systemSaveRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSaveResponse"
}
}
}
},
"title": "CommentResposne",
"required": [
"list"
]
},
"Company": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 唯一标识"
},
"name": {
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleSaveRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
}
},
"v1/system/role/search": {
"post": {
"operationId": "systemSearchRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
}
},
"v1/system/role/{id}": {
"delete": {
"operationId": "systemDeleteRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleDeleteResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
},
"post": {
"operationId": "systemGetRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleGetRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
},
"put": {
"operationId": "systemUpdateRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleUpdateResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/RoleUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"role"
]
}
}
},
"definitions": {
"Account": {
"type": "object",
"properties": {
"companyId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
},
"companyName": {
"type": "string",
"description": " 公司名称"
},
"logo": {
"type": "string",
"description": " 公司图标"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 用户ID"
},
"name": {
"type": "string",
"description": " 名称"
},
"position": {
"type": "string",
"description": " 职位"
}
},
"title": "Account",
"required": [
"companyId",
"companyName",
"logo",
"userId",
"name",
"position"
]
},
"ArticleSearchMe": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"title": {
"type": "string",
"description": "标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": "文章的创建日期"
},
"countLove": {
"type": "integer",
"format": "int32",
"description": "点赞数量"
},
"CountComment": {
"type": "integer",
"format": "int32",
"description": "评论数量"
},
"show": {
"type": "integer",
"format": "int32",
"description": "是否隐藏 [0显示、1不显示]"
}
},
"title": "ArticleSearchMe",
"required": [
"id",
"title",
"images",
"createdAt",
"countLove",
"CountComment",
"show"
]
},
"ArticleSection": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "段落id"
},
"content": {
"type": "string",
"description": " 文本内容"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": " 排序"
},
"totalComment": {
"type": "integer",
"format": "int32",
"description": " 评论的数量"
}
},
"title": "ArticleSection",
"required": [
"id",
"content",
"sortBy",
"totalComment"
]
},
"Auth": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " ID"
},
"name": {
"type": "string",
"description": " 名称"
},
"code": {
"type": "string",
"description": " 编码(搜索使用,4位字母数字)"
"code": {
"type": "string",
"description": " 编码"
}
},
"title": "Auth",
"required": [
"id",
"name",
"code"
]
},
"Author": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 人员id"
},
"name": {
"type": "string",
"description": " 人员的名字"
},
"avatar": {
"type": "string",
"description": " 人员头像URL"
},
"group": {
"type": "string",
"description": " 人员的分组"
},
"position": {
"type": "string",
"description": " 职位"
},
"company": {
"type": "string",
"description": " 公司"
}
},
"title": "Author",
"required": [
"id",
"name",
"avatar",
"group",
"position",
"company"
]
},
"Comment": {
"type": "object",
"title": "Comment"
},
"CommentRequest": {
"type": "object",
"title": "CommentRequest"
},
"CommentResposne": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Comment"
}
}
},
"title": "CommentResposne",
"required": [
"list"
]
},
"Company": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 唯一标识"
},
"name": {
"type": "string",
"description": " 名称"
},
"code": {
"type": "string",
"description": " 编码(搜索使用,4位字母数字)"
},
"logo": {
"type": "string",
"description": " 公司LOGO"
}
},
"title": "Company",
"required": [
"id",
"name",
"code",
"logo"
]
},
"CompanySearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 按用户搜索"
},
"code": {
"type": "string",
"description": " 按编码搜索"
}
},
"title": "CompanySearchRequest",
"required": [
"page",
"size"
]
},
"CompanySearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Company"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "CompanySearchResponse",
"required": [
"list",
"total"
]
},
"Department": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 部门ID"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
},
"parentId": {
"type": "integer",
"format": "int64",
"description": " 父级ID"
},
"name": {
"type": "string",
"description": " 部门名称"
}
},
"title": "Department",
"required": [
"id",
"companyId",
"parentId",
"name"
]
},
"FollowRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int64"
}
},
"title": "FollowRequest",
"required": [
"userId"
]
},
"Location": {
"type": "object",
"properties": {
"longitude": {
"type": "number",
"format": "double",
"description": "经度"
},
"latitude": {
"type": "number",
"format": "double",
"description": "纬度"
},
"descript": {
"type": "string",
"description": "地点描述"
}
},
"title": "Location"
},
"MessageBusinessItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 分类 (1回复 2点赞 3被采纳)"
},
"optType": {
"type": "integer",
"format": "int32",
"description": " 操作类型(1针对文章、1针对评论、2针对圆桌)"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": " 操作人公司ID"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 操作人用户ID"
},
"recipientId": {
"type": "integer",
"format": "int64",
"description": " 接收者ID"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章ID"
},
"commentId": {
"type": "integer",
"format": "int64",
"description": " 评论ID"
},
"discussionId": {
"type": "integer",
"format": "int64",
"description": " 圆桌ID"
},
"discussionOpinionId": {
"type": "integer",
"format": "int64",
"description": " 观点ID"
},
"content": {
"type": "string",
"description": " 消息内容"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 创建时间"
},
"user": {
"$ref": "#/definitions/User",
"description": " 操作人"
},
"article": {
"$ref": "#/definitions/SimpleArticle",
"description": " 文章"
},
"comment": {
"$ref": "#/definitions/Comment",
"description": " 评论(不一定是自己,可能是被人@到)"
}
},
"title": "MessageBusinessItem",
"required": [
"id",
"type",
"optType",
"companyId",
"userId",
"recipientId",
"articleId",
"commentId",
"discussionId",
"discussionOpinionId",
"content",
"createdAt",
"user",
"article",
"comment"
]
},
"MessageBusinessRequest": {
"type": "object",
"properties": {
"type": {
"type": "integer",
"format": "int32"
},
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MessageBusinessRequest",
"required": [
"type",
"page",
"size"
]
},
"MessageBusinessResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageBusinessItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MessageBusinessResponse",
"required": [
"list",
"total"
]
},
"MessageSystemItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " ID"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 系统分类"
},
"title": {
"type": "string",
"description": " 标题"
},
"content": {
"type": "string",
"description": " 内容"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 创建时间"
}
},
"title": "MessageSystemItem",
"required": [
"id",
"type",
"title",
"content",
"createdAt"
]
},
"MessageSystemRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MessageSystemRequest",
"required": [
"page",
"size"
]
},
"MessageSystemResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageSystemItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MessageSystemResponse",
"required": [
"list",
"total"
]
},
"MiniArticleCreateRequest": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "标题"
},
"section": {
"type": "array",
"items": {
"type": "string"
},
"description": "文章的文本内容"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"location": {
"$ref": "#/definitions/Location",
"description": "定位坐标"
}
},
"title": "MiniArticleCreateRequest",
"required": [
"title",
"section"
]
},
"MiniArticleCreateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleCreateResponse",
"required": [
"id"
]
},
"MiniArticleGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"companyId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleGetRequest",
"required": [
"id",
"-"
]
},
"MiniArticleGetResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"logo": {
"title": {
"type": "string",
"description": " 公司LOGO"
"description": "标题"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人id"
},
"author": {
"$ref": "#/definitions/Author",
"description": "发布人"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": "文章的发布时间"
},
"section": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
},
"description": "文章的文本内容"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可查看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": "谁可评论"
},
"location": {
"$ref": "#/definitions/Location",
"description": "定位坐标"
},
"countLove": {
"type": "integer",
"format": "int32",
"description": " 点赞数量"
},
"countComment": {
"type": "integer",
"format": "int32",
"description": " 评论数量"
},
"countRead": {
"type": "integer",
"format": "int32",
"description": " 浏览数量"
},
"show": {
"type": "integer",
"format": "int32",
"description": " 评论的展示状态(0显示、1不显示)"
}
},
"title": "Company",
"title": "MiniArticleGetResponse",
"required": [
"id",
"name",
"code",
"logo"
"title",
"authorId",
"author",
"createdAt",
"section",
"images",
"whoRead",
"whoReview",
"location",
"countLove",
"countComment",
"countRead",
"show"
]
},
"CompanySearchRequest": {
"MiniArticleSearchMeRequest": {
"type": "object",
"properties": {
"authorId": {
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64"
},
"page": {
"type": "integer",
"format": "int32"
... ... @@ -614,462 +1654,571 @@
"size": {
"type": "integer",
"format": "int32"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 按用户搜索"
},
"code": {
"type": "string",
"description": " 按编码搜索"
}
},
"title": "CompanySearchRequest",
"title": "MiniArticleSearchMeRequest",
"required": [
"-",
"page",
"size"
]
},
"CompanySearchResponse": {
"MiniArticleSearchMeResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Company"
"$ref": "#/definitions/ArticleSearchMe"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "CompanySearchResponse",
"title": "MiniArticleSearchMeResponse",
"required": [
"list",
"total"
"total",
"list"
]
},
"Department": {
"MiniSetUserLikeRequset": {
"type": "object",
"properties": {
"id": {
"articleId": {
"type": "integer",
"format": "int64",
"description": " 部门ID"
"description": "文章id"
},
"companyId": {
"commentId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
"description": "评论id"
},
"parentId": {
"userId": {
"type": "integer",
"format": "int64",
"description": " 父级ID"
"description": "操作人"
},
"name": {
"type": "string",
"description": " 部门名称"
"flag": {
"type": "integer",
"format": "int32",
"description": "点赞标志 1、点赞 2 、取消点赞"
}
},
"title": "Department",
"title": "MiniSetUserLikeRequset",
"required": [
"id",
"companyId",
"parentId",
"name"
"articleId",
"commentId",
"-",
"flag"
]
},
"FollowRequest": {
"MiniSetUserLikeResponse": {
"type": "object",
"properties": {
"userId": {
"articleId": {
"type": "integer",
"format": "int64"
"format": "int64",
"description": "文章id"
},
"commentId": {
"type": "integer",
"format": "int64",
"description": "评论id"
},
"count": {
"type": "integer",
"format": "int32",
"description": "现有的点赞数量"
}
},
"title": "FollowRequest",
"title": "MiniSetUserLikeResponse",
"required": [
"userId"
"articleId",
"commentId",
"count"
]
},
"MessageBusinessItem": {
"MiniUserApplyJoinCompanyRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 分类 (1回复 2点赞 3被采纳)"
},
"optType": {
"type": "integer",
"format": "int32",
"description": " 操作类型(1针对文章、1针对评论、2针对圆桌)"
"phone": {
"type": "string"
},
"companyId": {
"code": {
"type": "string"
}
},
"title": "MiniUserApplyJoinCompanyRequest",
"required": [
"phone",
"code"
]
},
"MiniUserApplyJoinCompanyResponse": {
"type": "object",
"title": "MiniUserApplyJoinCompanyResponse"
},
"MiniUserAuditRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int64",
"description": " 操作人公司ID"
"description": " 用户ID"
},
"userId": {
"status": {
"type": "integer",
"format": "int64",
"description": " 操作人用户ID"
"format": "int32",
"description": " 审核状态 1:审核通过 2:拒绝"
}
},
"title": "MiniUserAuditRequest",
"required": [
"userId",
"status"
]
},
"MiniUserDepartmentUsersRequest": {
"type": "object",
"title": "MiniUserDepartmentUsersRequest"
},
"MiniUserDepartmentUsersResponse": {
"type": "object",
"properties": {
"departments": {
"type": "array",
"items": {
"$ref": "#/definitions/Department"
}
},
"recipientId": {
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/UserItem"
}
}
},
"title": "MiniUserDepartmentUsersResponse",
"required": [
"departments",
"users"
]
},
"MiniUserFollowedSearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int64",
"description": " 接收者ID"
"format": "int32"
},
"articleId": {
"size": {
"type": "integer",
"format": "int64",
"description": " 文章ID"
"format": "int32"
}
},
"title": "MiniUserFollowedSearchRequest"
},
"MiniUserFollowedSearchResponse": {
"type": "object",
"properties": {
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/UserFollowItem"
}
},
"commentId": {
"total": {
"type": "integer",
"format": "int64",
"description": " 评论ID"
"format": "int64"
}
},
"title": "MiniUserFollowedSearchResponse",
"required": [
"users",
"total"
]
},
"MiniUserInfoRequest": {
"type": "object",
"title": "MiniUserInfoRequest"
},
"MiniUserInfoResponse": {
"type": "object",
"properties": {
"user": {
"$ref": "#/definitions/UserItem",
"description": " 用户信息"
},
"discussionId": {
"totalArticle": {
"type": "integer",
"format": "int64",
"description": " 圆桌ID"
"description": " 累计信息发布"
},
"discussionOpinionId": {
"totalLoved": {
"type": "integer",
"format": "int64",
"description": " 观点ID"
},
"content": {
"type": "string",
"description": " 消息内容"
"description": " 累计收到的赞"
},
"createdAt": {
"totalAccepted": {
"type": "integer",
"format": "int64",
"description": " 创建时间"
},
"user": {
"$ref": "#/definitions/User",
"description": " 操作人"
},
"article": {
"$ref": "#/definitions/SimpleArticle",
"description": " 文章"
"description": " 累计被采纳"
},
"comment": {
"$ref": "#/definitions/Comment",
"description": " 评论(不一定是自己,可能是被人@到)"
"accounts": {
"type": "array",
"items": {
"$ref": "#/definitions/Account"
},
"description": " 公司账号"
}
},
"title": "MessageBusinessItem",
"title": "MiniUserInfoResponse",
"required": [
"id",
"type",
"optType",
"companyId",
"userId",
"recipientId",
"articleId",
"commentId",
"discussionId",
"discussionOpinionId",
"content",
"createdAt",
"user",
"article",
"comment"
"totalArticle",
"totalLoved",
"totalAccepted",
"accounts"
]
},
"MessageBusinessRequest": {
"MiniUserLikeArticleRequest": {
"type": "object",
"properties": {
"type": {
"articleId": {
"type": "integer",
"format": "int32"
"format": "int64",
"description": " 文章id"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": "公司id"
},
"page": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": "分页,第几页"
},
"size": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": "分页,每页几条"
}
},
"title": "MessageBusinessRequest",
"title": "MiniUserLikeArticleRequest",
"required": [
"type",
"articleId",
"-",
"page",
"size"
]
},
"MessageBusinessResponse": {
"MiniUserLikeArticleResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64",
"description": "总数"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageBusinessItem"
}
},
"total": {
"type": "integer",
"format": "int64"
"$ref": "#/definitions/WhichUserLikeArticle"
},
"description": "列表"
}
},
"title": "MessageBusinessResponse",
"title": "MiniUserLikeArticleResponse",
"required": [
"list",
"total"
"total",
"list"
]
},
"MessageSystemItem": {
"MiniUserLoginRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " ID"
"loginType": {
"type": "string",
"description": " 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 系统分类"
"wechatAuthcode": {
"type": "string",
"description": " 微信登录 授权码"
},
"title": {
"wechatEncryptedData": {
"type": "string",
"description": " 标题"
"description": " 微信登录 加密数据"
},
"content": {
"wechatIV": {
"type": "string",
"description": " 内容"
"description": " 微信登录 加密算法初始向量"
},
"createdAt": {
"phone": {
"type": "string",
"description": " 手机号"
},
"password": {
"type": "string",
"description": " 密码"
},
"smsCode": {
"type": "string",
"description": " 短信验证码"
}
},
"title": "MiniUserLoginRequest",
"required": [
"loginType"
]
},
"MiniUserLoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string",
"description": " x-token"
},
"phone": {
"type": "string",
"description": " 手机号"
},
"message": {
"type": "string",
"description": " 失败消息(审核中,注册成功等待审核)"
},
"success": {
"type": "boolean",
"format": "boolean",
"description": " 成功标识"
}
},
"title": "MiniUserLoginResponse",
"required": [
"token",
"phone",
"message",
"success"
]
},
"MiniUserSwitchAccountRequest": {
"type": "object",
"properties": {
"companyId": {
"type": "integer",
"format": "int64",
"description": " 创建时间"
"format": "int64"
}
},
"title": "MessageSystemItem",
"title": "MiniUserSwitchAccountRequest",
"required": [
"id",
"type",
"title",
"content",
"createdAt"
"companyId"
]
},
"MessageSystemRequest": {
"RoleDeleteRequest": {
"type": "object",
"properties": {
"page": {
"id": {
"type": "integer",
"format": "int32"
},
"size": {
"format": "int64"
}
},
"title": "RoleDeleteRequest",
"required": [
"id"
]
},
"RoleDeleteResponse": {
"type": "object",
"title": "RoleDeleteResponse"
},
"RoleGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
"format": "int64"
}
},
"title": "MessageSystemRequest",
"title": "RoleGetRequest",
"required": [
"page",
"size"
"id"
]
},
"MessageSystemResponse": {
"RoleGetResponse": {
"type": "object",
"properties": {
"list": {
"role": {
"$ref": "#/definitions/RoleItem"
},
"authList": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageSystemItem"
"$ref": "#/definitions/Auth"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MessageSystemResponse",
"title": "RoleGetResponse",
"required": [
"list",
"total"
"role",
"authList"
]
},
"MiniUserApplyJoinCompanyRequest": {
"RoleItem": {
"type": "object",
"properties": {
"phone": {
"type": "string"
"id": {
"type": "integer",
"format": "int64",
"description": " 角色ID"
},
"code": {
"type": "string"
"companyId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
},
"name": {
"type": "string",
"description": " 角色名称"
},
"authIds": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 角色权限列表"
},
"authsDesc": {
"type": "string",
"description": " 权限列表描述"
},
"usersDesc": {
"type": "string",
"description": " 用户列表描述"
},
"remark": {
"type": "string",
"description": " 备注"
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/RoleUser"
},
"description": " 绑定的用户"
},
"updatedAt": {
"type": "integer",
"format": "int64",
"description": " 更新时间"
}
},
"title": "MiniUserApplyJoinCompanyRequest",
"title": "RoleItem",
"required": [
"phone",
"code"
"name",
"authIds",
"authsDesc",
"usersDesc",
"remark",
"updatedAt"
]
},
"RoleSaveRequest": {
"type": "object",
"properties": {
"role": {
"$ref": "#/definitions/RoleItem"
}
},
"title": "RoleSaveRequest",
"required": [
"role"
]
},
"MiniUserApplyJoinCompanyResponse": {
"RoleSaveResponse": {
"type": "object",
"title": "MiniUserApplyJoinCompanyResponse"
"title": "RoleSaveResponse"
},
"MiniUserAuditRequest": {
"RoleSearchRequest": {
"type": "object",
"properties": {
"userId": {
"page": {
"type": "integer",
"format": "int64",
"description": " 用户ID"
"format": "int32"
},
"status": {
"size": {
"type": "integer",
"format": "int32",
"description": " 审核状态 1:审核通过 2:拒绝"
"format": "int32"
},
"style": {
"type": "string",
"description": " simple:只返回角色ID名称 full:所有字段都返回"
}
},
"title": "MiniUserAuditRequest",
"title": "RoleSearchRequest",
"required": [
"userId",
"status"
"style"
]
},
"MiniUserDepartmentUsersRequest": {
"type": "object",
"title": "MiniUserDepartmentUsersRequest"
},
"MiniUserDepartmentUsersResponse": {
"RoleSearchResponse": {
"type": "object",
"properties": {
"departments": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/Department"
"$ref": "#/definitions/RoleItem"
}
},
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/UserItem"
}
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniUserDepartmentUsersResponse",
"title": "RoleSearchResponse",
"required": [
"departments",
"users"
"list",
"total"
]
},
"MiniUserInfoRequest": {
"type": "object",
"title": "MiniUserInfoRequest"
},
"MiniUserInfoResponse": {
"RoleUpdateRequest": {
"type": "object",
"properties": {
"user": {
"$ref": "#/definitions/UserItem",
"description": " 用户信息"
},
"totalArticle": {
"type": "integer",
"format": "int64",
"description": " 累计信息发布"
},
"totalLoved": {
"id": {
"type": "integer",
"format": "int64",
"description": " 累计收到的赞"
"format": "int64"
},
"totalAccepted": {
"type": "integer",
"format": "int64",
"description": " 累计被采纳"
"role": {
"$ref": "#/definitions/RoleItem"
}
},
"title": "MiniUserInfoResponse",
"title": "RoleUpdateRequest",
"required": [
"user",
"totalArticle",
"totalLoved",
"totalAccepted"
"id",
"role"
]
},
"MiniUserLoginRequest": {
"RoleUpdateResponse": {
"type": "object",
"properties": {
"loginType": {
"type": "string",
"description": " 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login"
},
"wechatAuthcode": {
"type": "string",
"description": " 微信登录 授权码"
},
"wechatEncryptedData": {
"type": "string",
"description": " 微信登录 加密数据"
},
"wechatIV": {
"type": "string",
"description": " 微信登录 加密算法初始向量"
},
"phone": {
"type": "string",
"description": " 手机号"
},
"password": {
"type": "string",
"description": " 密码"
},
"smsCode": {
"type": "string",
"description": " 短信验证码"
}
},
"title": "MiniUserLoginRequest",
"required": [
"loginType"
]
"title": "RoleUpdateResponse"
},
"MiniUserLoginResponse": {
"RoleUser": {
"type": "object",
"properties": {
"token": {
"type": "string",
"description": " x-token"
},
"phone": {
"type": "string",
"description": " 手机号"
},
"message": {
"type": "string",
"description": " 失败消息(审核中,注册成功等待审核)"
"id": {
"type": "integer",
"format": "int64"
},
"success": {
"type": "boolean",
"format": "boolean",
"description": " 成功标识"
"name": {
"type": "string"
}
},
"title": "MiniUserLoginResponse",
"title": "RoleUser",
"required": [
"token",
"phone",
"message",
"success"
"id",
"name"
]
},
"SimpleArticle": {
... ... @@ -1130,8 +2279,7 @@
"companyId",
"image",
"name",
"group",
"remark"
"group"
]
},
"TagCreateResponse": {
... ... @@ -1153,11 +2301,16 @@
"id": {
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64"
}
},
"title": "TagDeleteRequest",
"required": [
"id"
"id",
"-"
]
},
"TagDeleteResponse": {
... ... @@ -1203,11 +2356,10 @@
"title": "TagEditRequest",
"required": [
"id",
"companyId",
"-",
"image",
"name",
"group",
"remark"
"group"
]
},
"TagEditResponse": {
... ... @@ -1229,11 +2381,16 @@
"id": {
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64"
}
},
"title": "TagGetRequest",
"required": [
"id"
"id",
"-"
]
},
"TagGetResponse": {
... ... @@ -1315,12 +2472,26 @@
"size": {
"type": "integer",
"format": "int32"
},
"companyId": {
"type": "integer",
"format": "int64"
},
"tagName": {
"type": "string"
},
"group": {
"type": "string"
},
"remark": {
"type": "string"
}
},
"title": "TagListRequest",
"required": [
"page",
"size"
"size",
"-"
]
},
"TagListResponse": {
... ... @@ -1328,7 +2499,7 @@
"properties": {
"total": {
"type": "integer",
"format": "int32"
"format": "int64"
},
"list": {
"type": "array",
... ... @@ -1382,7 +2553,7 @@
"position"
]
},
"UserItem": {
"UserFollowItem": {
"type": "object",
"properties": {
"id": {
... ... @@ -1390,23 +2561,60 @@
"format": "int64",
"description": " 用户ID"
},
"companyId": {
"name": {
"type": "string",
"description": " 名称"
},
"companyName": {
"type": "string",
"description": " 公司名称"
},
"avatar": {
"type": "string",
"description": " 头像"
},
"position": {
"type": "string",
"description": " 职位"
},
"followed": {
"type": "boolean",
"format": "boolean",
"description": " 关注"
},
"mutualFollowed": {
"type": "boolean",
"format": "boolean",
"description": " 互相关注标识"
}
},
"title": "UserFollowItem",
"required": [
"id",
"name",
"companyName",
"avatar",
"position",
"followed",
"mutualFollowed"
]
},
"UserItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
"description": " 用户ID"
},
"departmentId": {
"companyId": {
"type": "integer",
"format": "int64",
"description": " 部门ID"
"description": " 公司ID"
},
"roleId": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 角色"
"companyName": {
"type": "string",
"description": " 公司名称"
},
"flag": {
"type": "integer",
... ... @@ -1435,8 +2643,7 @@
"description": " 启用状态 1:启用 2:禁用"
},
"auditStatus": {
"type": "integer",
"format": "int32",
"$ref": "#/definitions/int",
"description": " 审核状态 0:待审核 1:审核通过 2:拒绝"
},
"followers": {
... ... @@ -1454,14 +2661,25 @@
"format": "int64"
},
"description": " 我关注的人 (冗余)"
},
"departments": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 所属部门"
},
"accountFrom": {
"type": "string",
"description": " 账号来源 后台新增、扫码注册"
}
},
"title": "UserItem",
"required": [
"id",
"companyId",
"departmentId",
"roleId",
"companyName",
"flag",
"name",
"avatar",
... ... @@ -1470,7 +2688,9 @@
"enable",
"auditStatus",
"followers",
"following"
"following",
"departments",
"accountFrom"
]
},
"UserSearchRequest": {
... ... @@ -1510,6 +2730,42 @@
"list",
"total"
]
},
"WhichUserLikeArticle": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 人员id"
},
"name": {
"type": "string",
"description": " 人员名称"
},
"avatar": {
"type": "string",
"description": " 人员头像"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 点赞记录的时间"
}
},
"title": "WhichUserLikeArticle",
"required": [
"articleId",
"userId",
"name",
"avatar",
"createdAt"
]
}
},
"securityDefinitions": {
... ...
syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
)
@server(
prefix: v1
group: role
jwt: SystemAuth
)
service Core {
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
}
type (
RoleGetRequest {
Id int64 `path:"id"`
}
RoleGetResponse struct{
Role RoleItem `json:"role"`
AuthList []Auth `json:"authList"`
}
RoleSaveRequest struct{
Role RoleItem `json:"role"`
}
RoleSaveResponse struct{}
RoleDeleteRequest struct{
Id int64 `path:"id"`
}
RoleDeleteResponse struct{}
RoleUpdateRequest struct{
Id int64 `path:"id"`
Role RoleItem `json:"role"`
}
RoleUpdateResponse struct{}
RoleSearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
}
RoleSearchResponse{
List []RoleItem `json:"list"`
Total int64 `json:"total"`
}
RoleItem struct{
Id int64 `json:"id,optional"` // 角色ID
CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID
Name string `json:"name"` // 角色名称
AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
Remark string `json:"remark,optional,omitempty"` // 备注
Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
}
RoleUser {
Id int64 `json:"id"`
Name string `json:"name"`
}
Auth {
Id int64 `json:"id"` // ID
Name string `json:"name"` // 名称
Code string `json:"code"` // 编码
}
)
\ No newline at end of file
... ...
... ... @@ -27,6 +27,9 @@ service Core {
jwt: MiniAuth
)
service Core {
@doc "切换账号"
@handler miniUserSwitchAccount
post /mini/user/switch-account (MiniUserSwitchAccountRequest) returns (MiniUserLoginResponse)
@doc "用户信息"
@handler miniUserInfo
post /mini/user/info (MiniUserInfoRequest) returns (MiniUserInfoResponse)
... ... @@ -69,6 +72,9 @@ type(
Message string `json:"message"` // 失败消息(审核中,注册成功等待审核)
Success bool `json:"success"` // 成功标识
}
MiniUserSwitchAccountRequest{
CompanyId int64 `json:"companyId"`
}
MiniUserInfoRequest {
//MyStatisticsFlag bool `json:"myStatisticsFlag"` // true:返回统计信息 false;统计信息不返回
... ... @@ -78,6 +84,7 @@ type(
TotalArticle int64 `json:"totalArticle"` // 累计信息发布
TotalLoved int64 `json:"totalLoved"` // 累计收到的赞
TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳
Accounts []Account `json:"accounts"` // 公司账号
}
MiniUserApplyJoinCompanyRequest{
Phone string `json:"phone"`
... ... @@ -123,6 +130,14 @@ type(
Departments []int64 `json:"departments,omitempty"` // 所属部门
AccountFrom string `json:"accountFrom,omitempty"` // 账号来源 后台新增、扫码注册
}
Account {
CompanyId int64 `json:"companyId"` // 公司ID
CompanyName string `json:"companyName"` // 公司名称
Logo string `json:"logo"` // 公司图标
UserId int64 `json:"userId"` // 用户ID
Name string `json:"name"` // 名称
Position string `json:"position"`// 职位
}
Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
... ...
package role
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemDeleteRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RoleDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := role.NewSystemDeleteRoleLogic(r.Context(), svcCtx)
resp, err := l.SystemDeleteRole(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package role
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemGetRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RoleGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := role.NewSystemGetRoleLogic(r.Context(), svcCtx)
resp, err := l.SystemGetRole(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package role
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemSaveRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RoleSaveRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := role.NewSystemSaveRoleLogic(r.Context(), svcCtx)
resp, err := l.SystemSaveRole(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package role
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemSearchRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RoleSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := role.NewSystemSearchRoleLogic(r.Context(), svcCtx)
resp, err := l.SystemSearchRole(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package role
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/role"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func SystemUpdateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RoleUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := role.NewSystemUpdateRoleLogic(r.Context(), svcCtx)
resp, err := l.SystemUpdateRole(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -8,6 +8,7 @@ import (
comment "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/comment"
company "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/company"
message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message"
role "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/role"
tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags"
user "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
... ... @@ -109,6 +110,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
[]rest.Route{
{
Method: http.MethodPost,
Path: "/mini/user/switch-account",
Handler: user.MiniUserSwitchAccountHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/mini/user/info",
Handler: user.MiniUserInfoHandler(serverCtx),
},
... ... @@ -206,4 +212,36 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/system/role/:id",
Handler: role.SystemGetRoleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/role",
Handler: role.SystemSaveRoleHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/system/role/:id",
Handler: role.SystemDeleteRoleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/system/role/:id",
Handler: role.SystemUpdateRoleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/system/role/search",
Handler: role.SystemSearchRoleHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1"),
)
}
... ...
package user
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniUserSwitchAccountHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniUserSwitchAccountRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := user.NewMiniUserSwitchAccountLogic(r.Context(), svcCtx)
resp, err := l.MiniUserSwitchAccount(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package role
import (
"context"
"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"
"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"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemDeleteRoleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemDeleteRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteRoleLogic {
return &SystemDeleteRoleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemDeleteRoleLogic) SystemDeleteRole(req *types.RoleDeleteRequest) (resp *types.RoleDeleteResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
role *domain.Role
userRemoveRoleList []*domain.User
)
if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("角色不存在", err)
}
for _, item := range role.Users {
var user *domain.User
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, item.Id); err != nil {
return nil, xerr.NewErrMsgErr("用户存在", err)
}
userRemoveRoleList = append(userRemoveRoleList, user)
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
if role, err = l.svcCtx.RoleRepository.Delete(l.ctx, conn, role); err != nil {
return err
}
for _, user := range userRemoveRoleList {
user.RemoveRole(role.Id)
if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
return err
}
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("删除角色失败", err)
}
resp = &types.RoleDeleteResponse{}
return
}
... ...
package role
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"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"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemGetRoleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemGetRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetRoleLogic {
return &SystemGetRoleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemGetRoleLogic) SystemGetRole(req *types.RoleGetRequest) (resp *types.RoleGetResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
role *domain.Role
)
if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("角色不存在", err)
}
resp = &types.RoleGetResponse{
Role: NewTypesRole(role),
}
for _, auth := range domain.Auths {
resp.AuthList = append(resp.AuthList, types.Auth{
Id: auth.Id,
Name: auth.Name,
Code: auth.Code,
})
}
return
}
... ...
package role
import (
"context"
"fmt"
"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"
"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"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemSaveRoleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemSaveRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSaveRoleLogic {
return &SystemSaveRoleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemSaveRoleLogic) SystemSaveRole(req *types.RoleSaveRequest) (resp *types.RoleSaveResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userAddRoleList []*domain.User
)
role := NewDomainRole(l.ctx, req.Role)
for _, authId := range req.Role.AuthIds {
if auth := role.GetAuth(authId); auth == nil {
return nil, xerr.NewErrMsg(fmt.Sprintf("unknown auth %d ", authId))
}
}
for _, item := range req.Role.Users {
var user *domain.User
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, item.Id); err != nil {
return nil, xerr.NewErrMsgErr("用户存在", err)
}
userAddRoleList = append(userAddRoleList, user)
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
if role, err = l.svcCtx.RoleRepository.Insert(ctx, conn, role); err != nil {
return err
}
for _, user := range userAddRoleList {
user.AddRole(role.Id)
if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
return err
}
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("添加角色失败", err)
}
resp = &types.RoleSaveResponse{}
return
}
func NewDomainRole(ctx context.Context, item types.RoleItem) *domain.Role {
var (
role *domain.Role
users []domain.User = make([]domain.User, 0)
userToken = contextdata.GetUserTokenFromCtx(ctx)
)
lo.ForEach(item.Users, func(item types.RoleUser, index int) {
users = append(users, domain.User{
Id: item.Id,
Name: item.Name,
})
})
role = &domain.Role{
CompanyId: userToken.CompanyId,
Name: item.Name,
Auths: item.AuthIds,
Remark: item.Remark,
Users: users,
}
return role
}
func NewTypesRole(item *domain.Role) types.RoleItem {
var (
role types.RoleItem
users []types.RoleUser = make([]types.RoleUser, 0)
)
lo.ForEach(item.Users, func(item domain.User, index int) {
users = append(users, types.RoleUser{
Id: item.Id,
Name: item.Name,
})
})
role = types.RoleItem{
Id: item.Id,
CompanyId: item.CompanyId,
Name: item.Name,
AuthIds: item.Auths,
Remark: item.Remark,
Users: users,
UpdatedAt: item.UpdatedAt,
}
return role
}
... ...
package role
import (
"context"
"fmt"
"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"
"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"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemSearchRoleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemSearchRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchRoleLogic {
return &SystemSearchRoleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemSearchRoleLogic) SystemSearchRole(req *types.RoleSearchRequest) (resp *types.RoleSearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
roles []*domain.Role
total int64
)
queryOptions := domain.IndexCompanyId(userToken.CompanyId)()
if req.Page != 0 && req.Size != 0 {
queryOptions.WithOffsetLimit(req.Page, req.Size)
}
total, roles, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索角色异常", err)
}
resp = &types.RoleSearchResponse{
Total: total,
List: make([]types.RoleItem, 0),
}
if req.Style == "simple" {
lo.ForEach(roles, func(item *domain.Role, index int) {
resp.List = append(resp.List, types.RoleItem{
Id: item.Id,
Name: item.Name,
})
})
return
}
lo.ForEach(roles, func(item *domain.Role, index int) {
role := NewTypesRole(item)
role.UsersDesc = usersDesc(item)
role.AuthsDesc = authsDesc(item)
resp.List = append(resp.List, role)
})
return
}
func usersDesc(item *domain.Role) string {
users := lo.Slice(item.Users, 0, 3)
var (
nameList = make([]string, 0)
desc string = " "
)
lo.ForEach(users, func(item domain.User, index int) {
nameList = append(nameList, item.Name)
})
if len(users) == 0 {
return desc
}
desc = fmt.Sprintf("%s%s", strings.Join(nameList, "、"),
lo.Ternary(len(item.Users) > 3, fmt.Sprintf("...共%d人", len(item.Users)), ""),
)
return desc
}
func authsDesc(role *domain.Role) string {
var (
nameList = make([]string, 0)
desc string = " "
)
lo.ForEach(role.Auths, func(item int64, index int) {
if auth := role.GetAuth(item); auth != nil {
nameList = append(nameList, auth.Name)
}
})
if len(nameList) == 0 {
return desc
}
desc = strings.Join(nameList, "、")
return desc
}
... ...
package role
import (
"context"
"fmt"
"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"
"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"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemUpdateRoleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemUpdateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateRoleLogic {
return &SystemUpdateRoleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemUpdateRoleLogic) SystemUpdateRole(req *types.RoleUpdateRequest) (resp *types.RoleUpdateResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
role *domain.Role
beforeUserIds []int64
afterUserIds []int64
userRemoveRoleList []*domain.User
userAddRoleList []*domain.User
)
if role, err = l.svcCtx.RoleRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("角色不存在", err)
}
for _, authId := range req.Role.AuthIds {
if auth := role.GetAuth(authId); auth == nil {
return nil, xerr.NewErrMsg(fmt.Sprintf("unknown auth %d ", authId))
}
}
lo.ForEach(role.Users, func(item domain.User, index int) {
beforeUserIds = append(beforeUserIds, item.Id)
})
tempRole := NewDomainRole(l.ctx, req.Role)
lo.ForEach(tempRole.Users, func(item domain.User, index int) {
afterUserIds = append(afterUserIds, item.Id)
})
removeList, addList := lo.Difference(beforeUserIds, afterUserIds)
for _, id := range removeList {
var user *domain.User
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, id); err != nil {
return nil, xerr.NewErrMsgErr("更新角色失败", err)
}
userRemoveRoleList = append(userRemoveRoleList, user)
}
for _, id := range addList {
var user *domain.User
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, id); err != nil {
return nil, xerr.NewErrMsgErr("更新角色失败", err)
}
userAddRoleList = append(userAddRoleList, user)
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
role.Name = tempRole.Name
role.Auths = tempRole.Auths
role.Remark = tempRole.Remark
role.Users = tempRole.Users
if role, err = l.svcCtx.RoleRepository.UpdateWithVersion(ctx, conn, role); err != nil {
return err
}
for _, user := range userRemoveRoleList {
user.RemoveRole(role.Id)
if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
return err
}
}
for _, user := range userAddRoleList {
user.AddRole(role.Id)
if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
return err
}
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("更新角色失败", err)
}
resp = &types.RoleUpdateResponse{}
return
}
... ...
... ... @@ -2,9 +2,13 @@ package user
import (
"context"
"github.com/samber/lo"
"github.com/zeromicro/go-zero/core/collection"
"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"
)
... ... @@ -23,8 +27,49 @@ func NewMiniUserDepartmentUsersLogic(ctx context.Context, svcCtx *svc.ServiceCon
}
}
func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUserDepartmentUsersRequest) (resp *types.MiniUserInfoResponse, err error) {
// todo: add your logic here and delete this line
func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUserDepartmentUsersRequest) (resp interface{}, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
users []*domain.User
departments []*domain.Department
)
resp = map[string]interface{}{
"list": make([]DepartmentUser, 0),
}
_, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly())
if err != nil {
return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
}
_, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().WithFindOnly())
if err != nil {
return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
}
lo.ForEach(departments, func(item *domain.Department, index int) {
group := DepartmentUser{
Id: item.Id,
Name: item.Name,
Users: make([]*domain.User, 0),
}
groupUserSet := collection.NewSet()
for _, user := range users {
if len(user.Departments) == 0 {
continue
}
if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) {
group.Users = append(group.Users, &domain.User{
Id: user.Id,
Name: user.Name,
})
}
}
})
return
}
type DepartmentUser struct {
Id int64 `json:"id"` // 分组ID
Name string `json:"name"` // 分组名称
Users []*domain.User `json:"users"` // 用户
}
... ...
... ... @@ -2,6 +2,7 @@ package user
import (
"context"
"github.com/zeromicro/go-zero/core/collection"
"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"
... ... @@ -28,18 +29,68 @@ func NewMiniUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini
func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *types.MiniUserInfoResponse, err error) {
var (
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
conn = l.svcCtx.DefaultDBConn()
accounts []*domain.User
companyMap = make(map[int64]*domain.Company)
roles []*domain.Role
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if _, roles, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(user.CompanyId)().MustWithKV("ids", user.Roles)); err != nil {
return nil, xerr.NewErrMsgErr("角色不存在", err)
}
resp = &types.MiniUserInfoResponse{
User: &types.UserItem{
Id: user.Id,
Name: user.Name,
},
Accounts: make([]types.Account, 0),
Auths: make([]types.Auth, 0),
}
_, accounts, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().MustWithKV("phone", user.Phone).MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
if err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
// 拥有的账号
for _, account := range accounts {
if account.Enable != domain.UserEnable {
continue
}
var (
companyName = ""
logo = ""
)
if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, account.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil {
companyName = company.Name
logo = company.Logo
}
resp.Accounts = append(resp.Accounts, types.Account{
CompanyId: account.CompanyId,
CompanyName: companyName,
Logo: logo,
UserId: account.Id,
Name: user.Name,
Position: user.Position,
})
}
// 拥有的权限
authSet := collection.NewSet()
for _, role := range roles {
for _, auth := range role.Auths {
if !authSet.Contains(auth) {
authSet.Add(auth)
if item := role.GetAuth(auth); item != nil {
resp.Auths = append(resp.Auths, types.Auth{
Id: item.Id,
Name: item.Name,
Code: item.Code,
})
}
}
}
}
return
}
... ...
package user
import (
"context"
"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/tool"
"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"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniUserSwitchAccountLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniUserSwitchAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserSwitchAccountLogic {
return &MiniUserSwitchAccountLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniUserSwitchAccountLogic) MiniUserSwitchAccount(req *types.MiniUserSwitchAccountRequest) (resp *types.MiniUserLoginResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
token string
currentUser *domain.User
switchToUser *domain.User
)
if currentUser, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("当前账号异常", err)
}
if switchToUser, err = l.svcCtx.UserRepository.FindOneByCompanyIdAndPhone(l.ctx, conn, req.CompanyId, currentUser.Phone, []int{domain.UserAuditStatusPassed}); err != nil {
return nil, xerr.NewErrMsgErr("账号不可用", err)
}
if switchToUser.Enable != domain.UserEnable {
return nil, xerr.NewErrMsgErr("账号不可用", err)
}
var userJwtToken = tool.UserToken{}
if switchToUser != nil {
userJwtToken.UserId = switchToUser.Id
userJwtToken.CompanyId = switchToUser.CompanyId
userJwtToken.ClientType = "mini"
}
token, err = userJwtToken.GenerateToken(l.svcCtx.Config.MiniAuth.AccessSecret, l.svcCtx.Config.MiniAuth.AccessExpire)
if err != nil {
return nil, xerr.NewErrMsgErr("切换账号失败", err)
}
resp = &types.MiniUserLoginResponse{
Token: token,
Phone: "",
Success: true,
}
if switchToUser == nil {
resp.Success = false
}
return
}
... ...
... ... @@ -161,6 +161,10 @@ type MiniUserLoginResponse struct {
Success bool `json:"success"` // 成功标识
}
type MiniUserSwitchAccountRequest struct {
CompanyId int64 `json:"companyId"`
}
type MiniUserInfoRequest struct {
}
... ... @@ -169,6 +173,8 @@ type MiniUserInfoResponse struct {
TotalArticle int64 `json:"totalArticle"` // 累计信息发布
TotalLoved int64 `json:"totalLoved"` // 累计收到的赞
TotalAccepted int64 `json:"totalAccepted"` // 累计被采纳
Accounts []Account `json:"accounts"` // 公司账号
Auths []Auth `json:"auths"` // 权限
}
type MiniUserApplyJoinCompanyRequest struct {
... ... @@ -219,6 +225,15 @@ type UserItem struct {
AccountFrom string `json:"accountFrom,omitempty"` // 账号来源 后台新增、扫码注册
}
type Account struct {
CompanyId int64 `json:"companyId"` // 公司ID
CompanyName string `json:"companyName"` // 公司名称
Logo string `json:"logo"` // 公司图标
UserId int64 `json:"userId"` // 用户ID
Name string `json:"name"` // 名称
Position string `json:"position"` // 职位
}
type Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
... ... @@ -382,3 +397,68 @@ type MiniSetUserLikeResponse struct {
CommentId int64 `json:"commentId"` //评论id
Count int `json:"count"` //现有的点赞数量
}
type RoleGetRequest struct {
Id int64 `path:"id"`
}
type RoleGetResponse struct {
Role RoleItem `json:"role"`
AuthList []Auth `json:"authList"`
}
type RoleSaveRequest struct {
Role RoleItem `json:"role"`
}
type RoleSaveResponse struct {
}
type RoleDeleteRequest struct {
Id int64 `path:"id"`
}
type RoleDeleteResponse struct {
}
type RoleUpdateRequest struct {
Id int64 `path:"id"`
Role RoleItem `json:"role"`
}
type RoleUpdateResponse struct {
}
type RoleSearchRequest struct {
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
}
type RoleSearchResponse struct {
List []RoleItem `json:"list"`
Total int64 `json:"total"`
}
type RoleItem struct {
Id int64 `json:"id,optional"` // 角色ID
CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID
Name string `json:"name"` // 角色名称
AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
Remark string `json:"remark,optional,omitempty"` // 备注
Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
}
type RoleUser struct {
Id int64 `json:"id"`
Name string `json:"name"`
}
type Auth struct {
Id int64 `json:"id"` // ID
Name string `json:"name"` // 名称
Code string `json:"code"` // 编码
}
... ...
... ... @@ -20,6 +20,7 @@ func Migrate(db *gorm.DB) {
&models.UserFollow{},
&models.MessageSystem{},
&models.MessageBusiness{},
&models.Department{},
}
db.AutoMigrate(modelsList...)
... ...
... ... @@ -4,15 +4,20 @@ import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
)
type Department struct {
Id int64 // 唯一标识
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
Id int64 // 唯一标识
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
}
func (m *Department) TableName() string {
... ...
... ... @@ -9,11 +9,12 @@ import (
)
type Role struct {
Id int64 // 唯一标识
Name string `json:"name"` // 角色名称
Auths []int64 `gorm:"type:jsonb;serializer:json"` // 角色权限列表
Remark string `json:"remark"` // 备注
Users []int64 `gorm:"type:jsonb;serializer:json"` // 绑定的用户
Id int64 // 唯一标识
CompanyId int64
Name string `json:"name"` // 角色名称
Auths []int64 `gorm:"type:jsonb;serializer:json"` // 角色权限列表
Remark string `json:"remark"` // 备注
Users []domain.User `gorm:"type:jsonb;serializer:json"` // 绑定的用户
CreatedAt int64
UpdatedAt int64
... ...
... ... @@ -120,6 +120,9 @@ func (repository *DepartmentRepository) Find(ctx context.Context, conn transacti
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["companyId"]; ok {
tx.Where("company_id = ?", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -120,12 +120,17 @@ func (repository *RoleRepository) Find(ctx context.Context, conn transaction.Con
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["companyId"]; ok {
tx.Where("company_id = ?", v)
}
if v, ok := queryOptions["ids"]; ok {
tx.Where("id in (?)", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
return dms, nil
}
if _, err := repository.Query(queryFunc); err != nil {
return 0, nil, err
}
... ...
... ... @@ -141,7 +141,7 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
tx = tx.Model(&ms).Order("id asc")
if v, ok := queryOptions["companyId"]; ok {
tx.Where("company_id = ?", v)
}
... ... @@ -174,6 +174,39 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con
return total, dms, nil
}
func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.User, error) {
var (
tx = conn.DB()
ms []*models.User
dms = make([]*domain.User, 0)
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
tx.Select("id", "name", "departments")
tx.Where("company_id = ?", companyId)
tx.Where("audit_status in (?)", domain.UserAuditStatusPassed)
tx.Where("enable = ?", domain.UserEnable)
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
return dms, nil
}
if _, err := repository.Query(queryFunc); err != nil {
return 0, nil, err
}
for _, item := range ms {
if dm, err := repository.ModelToDomainModel(item); err != nil {
return 0, dms, err
} else {
dms = append(dms, dm)
}
}
return total, dms, nil
}
func (repository *UserRepository) ModelToDomainModel(from *models.User) (*domain.User, error) {
to := &domain.User{}
err := copier.Copy(to, from)
... ...
... ... @@ -76,3 +76,15 @@ func LazyLoad[K comparable, T any](source map[K]T, ctx context.Context, conn tra
return v, nil
}
}
/*************** 索引函数 ****************/
func IndexCompanyId(companyId int64) IndexQueryOptionFunc {
return func() QueryOptions {
return NewQueryOptions().WithKV("companyId", companyId)
}
}
func IndexUserId(userId int64) IndexQueryOptionFunc {
return func() QueryOptions {
return NewQueryOptions().WithKV("userId", userId)
}
}
... ...
... ... @@ -6,11 +6,12 @@ import (
)
type Role struct {
Id int64 `json:"id"` // 角色ID
Name string `json:"name"` // 角色名称
Auths []int64 `json:"auths"` // 角色权限列表
Remark string `json:"remark"` // 备注
Users []int64 `json:"users"` // 绑定的用户
Id int64 `json:"id"` // 角色ID
CompanyId int64 `json:"companyId"` // 公司ID
Name string `json:"name"` // 角色名称
Auths []int64 `json:"auths"` // 角色权限列表
Remark string `json:"remark"` // 备注
Users []User `json:"users"` // 绑定的用户
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
... ... @@ -33,3 +34,35 @@ func (m *Role) Identify() interface{} {
}
return m.Id
}
func (m *Role) GetAuth(id int64) *Auth {
for _, auth := range Auths {
if auth.Id == id {
return &auth
}
}
return nil
}
type Auth struct {
Id int64 `json:"id,omitempty"` // 菜单ID
ParentId int64 `json:"parentId"` // 父级ID
Name string `json:"name,omitempty"` // 菜单名称
Code string `json:"code,omitempty"` // 菜单编码
}
var Auths = []Auth{
NewAuth(1001, "邀请注册", "MINI_INVITE-REGISTRATION", 0),
NewAuth(1002, "帖子定性", "SYSTEM_POST-JUDGMENT", 0),
//NewAuth(1003, "圆桌判定", "SYSTEM_STUDENT-MANAGE", 0),
//NewAuth(1004, "圆桌运营", "SYSTEM_FEEDBACK-MANAGE", 0),
}
func NewAuth(id int64, name, code string, pid int64) Auth {
return Auth{
Id: id,
Name: name,
Code: code,
ParentId: pid,
}
}
... ...
... ... @@ -37,6 +37,7 @@ type UserRepository interface {
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*User, error)
FindOneByCompanyIdAndPhone(ctx context.Context, conn transaction.Conn, companyId int64, phone string, status []int) (*User, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*User, error)
FindDepartmentUsers(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*User, error)
}
func (m *User) Identify() interface{} {
... ... @@ -85,6 +86,7 @@ func (m *User) Audit(status int) error {
return nil
}
// Follow 关注
func (m *User) Follow(targetUser *User) error {
if lo.Contains(m.Following, targetUser.Id) {
return fmt.Errorf("已关注用户%v", targetUser.Name)
... ... @@ -96,12 +98,29 @@ func (m *User) Follow(targetUser *User) error {
return nil
}
// Unfollow 取消关注
func (m *User) Unfollow(targetUser *User) error {
m.Following = lo.Without(m.Following, targetUser.Id)
targetUser.Follower = lo.Without(targetUser.Follower, m.Id)
return nil
}
// AddRole 添加角色
func (m *User) AddRole(roleId int64) {
if lo.Contains(m.Roles, roleId) {
return
}
m.Roles = append(m.Roles, roleId)
}
// RemoveRole 移除角色
func (m *User) RemoveRole(roleId int64) {
if !lo.Contains(m.Roles, roleId) {
return
}
m.Roles = lo.Without(m.Roles, roleId)
}
type (
LoginCreator interface {
WechatLogin(r WechatLoginRequest) (*LoginInfo, error)
... ...