From 33aa3354be4342f8a58fd60b1495777209a2715d Mon Sep 17 00:00:00 2001 From: truongpx-Mac Date: Thu, 2 Nov 2023 20:09:46 +0700 Subject: [PATCH] update --- cmd/openim-api/docs/docs.go | 362 +++++++++++++++++++++++++++++++ cmd/openim-api/docs/swagger.json | 342 +++++++++++++++++++++++++++++ cmd/openim-api/docs/swagger.yaml | 231 ++++++++++++++++++++ cmd/openim-api/main.go | 49 +++-- config/config.yaml | 13 +- docker-compose.yml | 122 ++++++----- go.mod | 14 ++ go.sum | 63 ++++++ internal/api/auth.go | 14 +- internal/api/route.go | 33 +++ internal/api/user.go | 43 +++- pkg/common/cmd/root.go | 3 +- 12 files changed, 1211 insertions(+), 78 deletions(-) create mode 100644 cmd/openim-api/docs/docs.go create mode 100644 cmd/openim-api/docs/swagger.json create mode 100644 cmd/openim-api/docs/swagger.yaml diff --git a/cmd/openim-api/docs/docs.go b/cmd/openim-api/docs/docs.go new file mode 100644 index 000000000..7ec51b36c --- /dev/null +++ b/cmd/openim-api/docs/docs.go @@ -0,0 +1,362 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/auth/user_token": { + "post": { + "description": "Get the user token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "User login", + "operationId": "UserToken", + "parameters": [ + { + "type": "string", + "description": "OperationId", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Secret is the Openim key. For details, see the server Config.yaml Secret field \u003cbr\u003e Platform is the platform ID", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/auth.UserTokenReq" + } + } + ], + "responses": { + "0": { + "description": "", + "schema": { + "$ref": "#/definitions/auth.UserTokenResp" + } + }, + "400": { + "description": "Errcode is 400, which is generally a parameter input error.", + "schema": {} + }, + "500": { + "description": "ERRCODE is 500 generally an internal error of the server", + "schema": {} + } + } + } + }, + "/user/get_users_info": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Obtain user information in batches according to the user list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get user information", + "operationId": "GetUsersInfo", + "parameters": [ + { + "type": "string", + "description": "Operation Id", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.GetDesignateUsersReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.GetDesignateUsersResp" + } + }, + "400": { + "description": "errcode is 400 一Input errors in the parameter, token is not brought up", + "schema": {} + }, + "500": { + "description": "Errcode is 500 一For the internal error of the server", + "schema": {} + } + } + } + }, + "/user/update_user_info": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Modify user information Userid Faceurl, etc.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Modify user information", + "operationId": "UpdateUserInfo", + "parameters": [ + { + "type": "string", + "description": "Operation Id", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.UpdateUserInfoReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.UpdateUserInfoResp" + } + }, + "400": { + "description": "Errcode is 400, which is generally a parameter input error.", + "schema": {} + }, + "500": { + "description": "ERRCODE is 500 generally an internal error of the server", + "schema": {} + } + } + } + }, + "/user/user_register": { + "post": { + "description": "User registration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "User registration", + "operationId": "UserRegister", + "parameters": [ + { + "type": "string", + "description": "Operation Id", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Secret is the Openim key. For details, see the server Config.yaml Secret field.", + "name": "UserInfo", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.UserRegisterReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.UserRegisterResp" + } + }, + "400": { + "description": "Errcode is 400, which is generally a parameter input error.", + "schema": {} + }, + "500": { + "description": "ERRCODE is 500 generally an internal error of the server", + "schema": {} + } + } + } + } + }, + "definitions": { + "auth.UserTokenReq": { + "type": "object", + "properties": { + "platformID": { + "type": "integer" + }, + "secret": { + "type": "string" + }, + "userID": { + "type": "string" + } + } + }, + "auth.UserTokenResp": { + "type": "object", + "properties": { + "expireTimeSeconds": { + "type": "integer" + }, + "token": { + "type": "string" + } + } + }, + "sdkws.UserInfo": { + "type": "object", + "properties": { + "appMangerLevel": { + "type": "integer" + }, + "createTime": { + "type": "integer" + }, + "ex": { + "type": "string" + }, + "faceURL": { + "type": "string" + }, + "globalRecvMsgOpt": { + "type": "integer" + }, + "nickname": { + "type": "string" + }, + "userID": { + "type": "string" + } + } + }, + "user.GetDesignateUsersReq": { + "type": "object", + "properties": { + "userIDs": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "user.GetDesignateUsersResp": { + "type": "object", + "properties": { + "usersInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/sdkws.UserInfo" + } + } + } + }, + "user.UpdateUserInfoReq": { + "type": "object", + "properties": { + "userInfo": { + "$ref": "#/definitions/sdkws.UserInfo" + } + } + }, + "user.UpdateUserInfoResp": { + "type": "object" + }, + "user.UserRegisterReq": { + "type": "object", + "properties": { + "secret": { + "type": "string" + }, + "users": { + "type": "array", + "items": { + "$ref": "#/definitions/sdkws.UserInfo" + } + } + } + }, + "user.UserRegisterResp": { + "type": "object" + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "description": "Description for what is this security definition being used", + "type": "apiKey", + "name": "token", + "in": "header" + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:10002", + BasePath: "/", + Schemes: []string{"http", "https"}, + Title: "open-IM-Server API", + Description: "Open-IM-Server API server document, all requests in the document have an OperationId field for link tracking", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/cmd/openim-api/docs/swagger.json b/cmd/openim-api/docs/swagger.json new file mode 100644 index 000000000..01db6bde3 --- /dev/null +++ b/cmd/openim-api/docs/swagger.json @@ -0,0 +1,342 @@ +{ + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "Open-IM-Server API server document, all requests in the document have an OperationId field for link tracking", + "title": "open-IM-Server API", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1.0" + }, + "host": "localhost:10002", + "basePath": "/", + "paths": { + "/auth/user_token": { + "post": { + "description": "Get the user token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authentication" + ], + "summary": "User login", + "operationId": "UserToken", + "parameters": [ + { + "type": "string", + "description": "OperationId", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Secret is the Openim key. For details, see the server Config.yaml Secret field \u003cbr\u003e Platform is the platform ID", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/auth.UserTokenReq" + } + } + ], + "responses": { + "0": { + "description": "", + "schema": { + "$ref": "#/definitions/auth.UserTokenResp" + } + }, + "400": { + "description": "Errcode is 400, which is generally a parameter input error.", + "schema": {} + }, + "500": { + "description": "ERRCODE is 500 generally an internal error of the server", + "schema": {} + } + } + } + }, + "/user/get_users_info": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Obtain user information in batches according to the user list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get user information", + "operationId": "GetUsersInfo", + "parameters": [ + { + "type": "string", + "description": "Operation Id", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.GetDesignateUsersReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.GetDesignateUsersResp" + } + }, + "400": { + "description": "errcode is 400 一Input errors in the parameter, token is not brought up", + "schema": {} + }, + "500": { + "description": "Errcode is 500 一For the internal error of the server", + "schema": {} + } + } + } + }, + "/user/update_user_info": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Modify user information Userid Faceurl, etc.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Modify user information", + "operationId": "UpdateUserInfo", + "parameters": [ + { + "type": "string", + "description": "Operation Id", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Request", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.UpdateUserInfoReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.UpdateUserInfoResp" + } + }, + "400": { + "description": "Errcode is 400, which is generally a parameter input error.", + "schema": {} + }, + "500": { + "description": "ERRCODE is 500 generally an internal error of the server", + "schema": {} + } + } + } + }, + "/user/user_register": { + "post": { + "description": "User registration", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "User registration", + "operationId": "UserRegister", + "parameters": [ + { + "type": "string", + "description": "Operation Id", + "name": "OperationId", + "in": "header", + "required": true + }, + { + "description": "Secret is the Openim key. For details, see the server Config.yaml Secret field.", + "name": "UserInfo", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user.UserRegisterReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/user.UserRegisterResp" + } + }, + "400": { + "description": "Errcode is 400, which is generally a parameter input error.", + "schema": {} + }, + "500": { + "description": "ERRCODE is 500 generally an internal error of the server", + "schema": {} + } + } + } + } + }, + "definitions": { + "auth.UserTokenReq": { + "type": "object", + "properties": { + "platformID": { + "type": "integer" + }, + "secret": { + "type": "string" + }, + "userID": { + "type": "string" + } + } + }, + "auth.UserTokenResp": { + "type": "object", + "properties": { + "expireTimeSeconds": { + "type": "integer" + }, + "token": { + "type": "string" + } + } + }, + "sdkws.UserInfo": { + "type": "object", + "properties": { + "appMangerLevel": { + "type": "integer" + }, + "createTime": { + "type": "integer" + }, + "ex": { + "type": "string" + }, + "faceURL": { + "type": "string" + }, + "globalRecvMsgOpt": { + "type": "integer" + }, + "nickname": { + "type": "string" + }, + "userID": { + "type": "string" + } + } + }, + "user.GetDesignateUsersReq": { + "type": "object", + "properties": { + "userIDs": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "user.GetDesignateUsersResp": { + "type": "object", + "properties": { + "usersInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/sdkws.UserInfo" + } + } + } + }, + "user.UpdateUserInfoReq": { + "type": "object", + "properties": { + "userInfo": { + "$ref": "#/definitions/sdkws.UserInfo" + } + } + }, + "user.UpdateUserInfoResp": { + "type": "object" + }, + "user.UserRegisterReq": { + "type": "object", + "properties": { + "secret": { + "type": "string" + }, + "users": { + "type": "array", + "items": { + "$ref": "#/definitions/sdkws.UserInfo" + } + } + } + }, + "user.UserRegisterResp": { + "type": "object" + } + }, + "securityDefinitions": { + "ApiKeyAuth": { + "description": "Description for what is this security definition being used", + "type": "apiKey", + "name": "token", + "in": "header" + } + } +} \ No newline at end of file diff --git a/cmd/openim-api/docs/swagger.yaml b/cmd/openim-api/docs/swagger.yaml new file mode 100644 index 000000000..52b83e51b --- /dev/null +++ b/cmd/openim-api/docs/swagger.yaml @@ -0,0 +1,231 @@ +basePath: / +definitions: + auth.UserTokenReq: + properties: + platformID: + type: integer + secret: + type: string + userID: + type: string + type: object + auth.UserTokenResp: + properties: + expireTimeSeconds: + type: integer + token: + type: string + type: object + sdkws.UserInfo: + properties: + appMangerLevel: + type: integer + createTime: + type: integer + ex: + type: string + faceURL: + type: string + globalRecvMsgOpt: + type: integer + nickname: + type: string + userID: + type: string + type: object + user.GetDesignateUsersReq: + properties: + userIDs: + items: + type: string + type: array + type: object + user.GetDesignateUsersResp: + properties: + usersInfo: + items: + $ref: '#/definitions/sdkws.UserInfo' + type: array + type: object + user.UpdateUserInfoReq: + properties: + userInfo: + $ref: '#/definitions/sdkws.UserInfo' + type: object + user.UpdateUserInfoResp: + type: object + user.UserRegisterReq: + properties: + secret: + type: string + users: + items: + $ref: '#/definitions/sdkws.UserInfo' + type: array + type: object + user.UserRegisterResp: + type: object +host: localhost:10002 +info: + contact: {} + description: Open-IM-Server API server document, all requests in the document have + an OperationId field for link tracking + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + title: open-IM-Server API + version: "1.0" +paths: + /auth/user_token: + post: + consumes: + - application/json + description: Get the user token + operationId: UserToken + parameters: + - description: OperationId + in: header + name: OperationId + required: true + type: string + - description: Secret is the Openim key. For details, see the server Config.yaml + Secret field
Platform is the platform ID + in: body + name: req + required: true + schema: + $ref: '#/definitions/auth.UserTokenReq' + produces: + - application/json + responses: + "0": + description: "" + schema: + $ref: '#/definitions/auth.UserTokenResp' + "400": + description: Errcode is 400, which is generally a parameter input error. + schema: {} + "500": + description: ERRCODE is 500 generally an internal error of the server + schema: {} + summary: User login + tags: + - Authentication + /user/get_users_info: + post: + consumes: + - application/json + description: Obtain user information in batches according to the user list + operationId: GetUsersInfo + parameters: + - description: Operation Id + in: header + name: OperationId + required: true + type: string + - description: Request + in: body + name: req + required: true + schema: + $ref: '#/definitions/user.GetDesignateUsersReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.GetDesignateUsersResp' + "400": + description: errcode is 400 一Input errors in the parameter, token is not + brought up + schema: {} + "500": + description: Errcode is 500 一For the internal error of the server + schema: {} + security: + - ApiKeyAuth: [] + summary: Get user information + tags: + - User + /user/update_user_info: + post: + consumes: + - application/json + description: Modify user information Userid Faceurl, etc. + operationId: UpdateUserInfo + parameters: + - description: Operation Id + in: header + name: OperationId + required: true + type: string + - description: Request + in: body + name: req + required: true + schema: + $ref: '#/definitions/user.UpdateUserInfoReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.UpdateUserInfoResp' + "400": + description: Errcode is 400, which is generally a parameter input error. + schema: {} + "500": + description: ERRCODE is 500 generally an internal error of the server + schema: {} + security: + - ApiKeyAuth: [] + summary: Modify user information + tags: + - User + /user/user_register: + post: + consumes: + - application/json + description: User registration + operationId: UserRegister + parameters: + - description: Operation Id + in: header + name: OperationId + required: true + type: string + - description: Secret is the Openim key. For details, see the server Config.yaml + Secret field. + in: body + name: UserInfo + required: true + schema: + $ref: '#/definitions/user.UserRegisterReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/user.UserRegisterResp' + "400": + description: Errcode is 400, which is generally a parameter input error. + schema: {} + "500": + description: ERRCODE is 500 generally an internal error of the server + schema: {} + summary: User registration + tags: + - User +schemes: +- http +- https +securityDefinitions: + ApiKeyAuth: + description: Description for what is this security definition being used + in: header + name: token + type: apiKey +swagger: "2.0" diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index 3aa8e1170..7319c3e3f 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -1,19 +1,40 @@ -// Copyright © 2023 OpenIM. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// // Copyright © 2023 OpenIM. All rights reserved. +// // +// // Licensed under the Apache License, Version 2.0 (the "License"); +// // you may not use this file except in compliance with the License. +// // You may obtain a copy of the License at +// // +// // http://www.apache.org/licenses/LICENSE-2.0 +// // +// // Unless required by applicable law or agreed to in writing, software +// // distributed under the License is distributed on an "AS IS" BASIS, +// // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// // See the License for the specific language governing permissions and +// // limitations under the License. package main +// import ( +// "net/http" + +// "github.com/gin-gonic/gin" +// ) + +// func main() { +// r := gin.Default() +// r.POST("/ping", func(c *gin.Context) { +// var f interface{} +// err2 := c.ShouldBindJSON(&f) +// if err2 == nil { + +// } +// c.JSON(http.StatusOK, gin.H{ +// "message": "pong", +// }) +// }) +// r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") +// } + import ( "context" "fmt" @@ -34,6 +55,8 @@ import ( "github.com/openimsdk/open-im-server/v3/pkg/common/db/cache" ) +//swag init --parseInternal --pd --dir cmd/openim-api,internal/api/ -g ../../internal/api/route.go --output cmd/openim-api/docs + func main() { apiCmd := cmd.NewApiCmd() apiCmd.AddPortFlag() diff --git a/config/config.yaml b/config/config.yaml index d2162d4b2..510f6d429 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -28,7 +28,8 @@ # Zookeeper password zookeeper: schema: openim - address: [ 172.28.0.1:12181 ] + # address: [ 172.28.0.1:12181 ] + address: [ 127.0.0.1:12181 ] username: '' password: '' @@ -42,7 +43,8 @@ zookeeper: # Log level: 1=slient, 2=error, 3=warn, 4=info # Slow query threshold in milliseconds mysql: - address: [ 172.28.0.1:13306 ] + # address: [ 172.28.0.1:13306 ] + address: [ 127.0.0.1:13306 ] username: root password: openIM123 database: openIM_v3 @@ -72,7 +74,8 @@ mongo: # # Username is required only for Redis version 6.0+ redis: - address: [ 172.28.0.1:16379 ] + # address: [ 172.28.0.1:16379 ] + address: [ 127.0.0.1:16379 ] username: '' password: openIM123 @@ -105,8 +108,10 @@ kafka: # IP address to register with zookeeper when starting RPC, the IP and corresponding rpcPort should be accessible by api/gateway # Default listen IP is 0.0.0.0 rpc: - registerIP: '' + # registerIP: '' + registerIP : 127.0.0.1 listenIP: 0.0.0.0 + # listenIP: 127.0.0.1 ###################### API configuration information ###################### # API configuration diff --git a/docker-compose.yml b/docker-compose.yml index 4f8983660..3cec46df3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,31 +12,34 @@ networks: services: mysql: - image: mysql:5.7 + image: bitnami/mysql:latest ports: - - "${MYSQL_PORT}:3306" + - '${MYSQL_PORT}:3306' container_name: mysql volumes: - - "${DATA_DIR}/components/mysql/data:/var/lib/mysql" - - "/etc/localtime:/etc/localtime" + - '${DATA_DIR}/components/mysql/data:/var/lib/mysql' + - '/etc/localtime:/etc/localtime' environment: - MYSQL_ROOT_PASSWORD: "${MYSQL_PASSWORD}" + MYSQL_ROOT_PASSWORD: '${MYSQL_PASSWORD}' restart: always networks: server: ipv4_address: ${MYSQL_NETWORK_ADDRESS} mongodb: - image: mongo:6.0.2 + # image: arm64v8/mongo:7.0-rc-jammy + # image: bitnami/mongodb:latest + image: mongo:7.0-rc-jammy ports: - - "${MONGO_PORT}:27017" + - '${MONGO_PORT}:27017' container_name: mongo command: --wiredTigerCacheSizeGB 1 --auth volumes: - - "${DATA_DIR}/components/mongodb/data/db:/data/db" - - "${DATA_DIR}/components/mongodb/data/logs:/data/logs" - - "${DATA_DIR}/components/mongodb/data/conf:/etc/mongo" - - ./scripts/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh:ro" + - '${DATA_DIR}/components/mongodb/data/db:/data/db' + - '${DATA_DIR}/components/mongodb/data/logs:/data/logs' + - '${DATA_DIR}/components/mongodb/data/conf:/etc/mongo' + - ./scripts/mongo-init.sh:/bitnami/scripts/mongo-init.sh:ro + # - ./scripts/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh:ro" environment: - TZ=Asia/Shanghai - wiredTigerCacheSizeGB=1 @@ -49,13 +52,14 @@ services: ipv4_address: ${MONGO_NETWORK_ADDRESS} redis: - image: redis:7.0.0 + image: bitnami/redis:latest + user: root container_name: redis ports: - - "${REDIS_PORT}:6379" + - '${REDIS_PORT}:6379' volumes: - - "${DATA_DIR}/components/redis/data:/data" - - "${DATA_DIR}/components/redis/config/redis.conf:/usr/local/redis/config/redis.conf" + - '${DATA_DIR}/components/redis/data:/data' + - '${DATA_DIR}/components/redis/config/redis.conf:/usr/local/redis/config/redis.conf' environment: TZ: Asia/Shanghai restart: always @@ -67,27 +71,29 @@ services: ipv4_address: ${REDIS_NETWORK_ADDRESS} zookeeper: - image: bitnami/zookeeper:3.8 - container_name: zookeeper - ports: - - "${ZOOKEEPER_PORT}:2181" - volumes: - - "/etc/localtime:/etc/localtime" - environment: - - ALLOW_ANONYMOUS_LOGIN=yes - - TZ="Asia/Shanghai" - restart: always - networks: + image: bitnami/zookeeper:3.8 + container_name: zookeeper + ports: + - '${ZOOKEEPER_PORT}:2181' + volumes: + - '/etc/localtime:/etc/localtime' + environment: + - ALLOW_ANONYMOUS_LOGIN=yes + - TZ="Asia/Shanghai" + restart: always + networks: server: ipv4_address: ${ZOOKEEPER_NETWORK_ADDRESS} kafka: - image: 'bitnami/kafka:3.5.1' + # image: 'bitnami/kafka:3.5.1' + image: 'bitnami/kafka:latest' container_name: kafka user: root + # user: nfsnobody restart: always ports: - - "${KAFKA_PORT}:9094" + - '${KAFKA_PORT}:9094' volumes: - ./scripts/create_topic.sh:/opt/bitnami/kafka/create_topic.sh - ${DATA_DIR}/components/kafka:/bitnami/kafka @@ -96,52 +102,52 @@ services: /opt/bitnami/scripts/kafka/run.sh & sleep 5; /opt/bitnami/kafka/create_topic.sh; wait " environment: - - TZ=Asia/Shanghai - - KAFKA_CFG_NODE_ID=0 - - KAFKA_CFG_PROCESS_ROLES=controller,broker - - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@:9093 - - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 - - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY}:${KAFKA_PORT} - - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT - - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER + - TZ=Asia/Shanghai + - KAFKA_CFG_NODE_ID=0 + - KAFKA_CFG_PROCESS_ROLES=controller,broker + - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@:9093 + - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 + - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY}:${KAFKA_PORT} + - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT + - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER networks: server: ipv4_address: ${KAFKA_NETWORK_ADDRESS} minio: image: minio/minio + user: root ports: - - "${MINIO_PORT}:9000" - - "9090:9090" + - '${MINIO_PORT}:9000' + - '9090:9090' container_name: minio volumes: - - "${DATA_DIR}/components/mnt/data:/data" - - "${DATA_DIR}/components/mnt/config:/root/.minio" + - '${DATA_DIR}/components/mnt/data:/data' + - '${DATA_DIR}/components/mnt/config:/root/.minio' environment: - MINIO_ROOT_USER: "${MINIO_ACCESS_KEY}" - MINIO_ROOT_PASSWORD: "${MINIO_SECRET_KEY}" + MINIO_ROOT_USER: '${MINIO_ACCESS_KEY}' + MINIO_ROOT_PASSWORD: '${MINIO_SECRET_KEY}' restart: always command: minio server /data --console-address ':9090' networks: server: ipv4_address: ${MINIO_NETWORK_ADDRESS} - openim-web: - # image: ghcr.io/openimsdk/openim-web:latest - # image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-web:latest - # image: openim/openim-web:latest - image: ${IMAGE_REGISTRY}/openim-web:latest - container_name: openim-web - environment: - - OPENIM_WEB_DIST_PATH=${OPENIM_WEB_DIST_PATH} - - OPENIM_WEB_PORT=${OPENIM_WEB_PORT} - restart: always - ports: - - "${OPENIM_WEB_PORT}:11001" - networks: - server: - ipv4_address: ${OPENIM_WEB_NETWORK_ADDRESS} - + # openim-web: + # # image: ghcr.io/openimsdk/openim-web:latest + # # image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-web:latest + # # image: openim/openim-web:latest + # image: ${IMAGE_REGISTRY}/openim-web:latest + # container_name: openim-web + # environment: + # - OPENIM_WEB_DIST_PATH=${OPENIM_WEB_DIST_PATH} + # - OPENIM_WEB_PORT=${OPENIM_WEB_PORT} + # restart: always + # ports: + # - "${OPENIM_WEB_PORT}:11001" + # networks: + # server: + # ipv4_address: ${OPENIM_WEB_NETWORK_ADDRESS} # openim-server: # # image: ghcr.io/openimsdk/openim-server:main # # image: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:main diff --git a/go.mod b/go.mod index ef20f61e9..f3c9d6646 100644 --- a/go.mod +++ b/go.mod @@ -54,6 +54,9 @@ require ( cloud.google.com/go/iam v1.1.4 // indirect cloud.google.com/go/longrunning v0.5.3 // indirect cloud.google.com/go/storage v1.33.0 // indirect + github.com/KyleBanks/depth v1.2.1 // indirect + github.com/PuerkitoBio/purell v1.2.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bytedance/sonic v1.10.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect @@ -68,6 +71,10 @@ require ( github.com/eapache/queue v1.1.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-openapi/jsonpointer v0.20.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/spec v0.20.9 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-zookeeper/zk v1.0.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -87,11 +94,13 @@ require ( github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.2 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/lithammer/shortuuid v3.0.0+incompatible // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/sha256-simd v1.0.1 // indirect @@ -110,6 +119,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rs/xid v1.5.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/swaggo/swag v1.16.2 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect @@ -124,11 +134,13 @@ require ( golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) require ( @@ -137,6 +149,8 @@ require ( github.com/lestrrat-go/strftime v1.0.6 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/spf13/cobra v1.7.0 + github.com/swaggo/files v1.0.1 + github.com/swaggo/gin-swagger v1.6.0 github.com/ugorji/go/codec v1.2.11 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/crypto v0.14.0 // indirect diff --git a/go.sum b/go.sum index a415767a3..b33765540 100644 --- a/go.sum +++ b/go.sum @@ -18,10 +18,18 @@ firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIw github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c= github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/OpenIMSDK/protocol v0.0.30 h1:MiHO6PyQMR9ojBHNnSFxCHLmsoE2xZqaiYj975JiZnM= github.com/OpenIMSDK/protocol v0.0.30/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/tools v0.0.16 h1:te/GIq2imCMsrRPgU9OObYKbzZ3rT08Lih/o+3QFIz0= github.com/OpenIMSDK/tools v0.0.16/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.2.1 h1:QsZ4TjvwiMpat6gBCBxEQI0rcS9ehtkKtSpiUnd9N28= +github.com/PuerkitoBio/purell v1.2.1/go.mod h1:ZwHcC/82TOaovDi//J/804umJFFmbOHPngi8iYYv/Eo= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible h1:Sg/2xHwDrioHpxTN6WMiwbXTpUEinBpHsN7mG21Rc2k= github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= @@ -52,6 +60,7 @@ github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5P github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -82,6 +91,27 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= +github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.9 h1:xnlYNQAwKd2VQRRfwTEI0DcK+2cbuvI/0c7jx3gA8/8= +github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -187,6 +217,8 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -199,8 +231,13 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= @@ -211,6 +248,12 @@ github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205Ah github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w= github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= @@ -237,6 +280,7 @@ github.com/mozillazg/go-httpheader v0.4.0 h1:aBn6aRXtFzyDLZ4VIRLsZbbJloagQfMnCiY github.com/mozillazg/go-httpheader v0.4.0/go.mod h1:PuT8h0pw6efvp8ZeUec1Rs7dwjK08bt6gKSReGMqtdA= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -290,6 +334,7 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -297,6 +342,14 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= +github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= +github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M= +github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= +github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w= +github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its= +github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04= +github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0= github.com/tencentyun/cos-go-sdk-v5 v0.7.45 h1:5/ZGOv846tP6+2X7w//8QjLgH2KcUK+HciFbfjWquFU= @@ -360,6 +413,7 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -390,6 +444,7 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -423,6 +478,10 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -465,7 +524,10 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -477,6 +539,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs= diff --git a/internal/api/auth.go b/internal/api/auth.go index 44a97a013..ff951db83 100644 --- a/internal/api/auth.go +++ b/internal/api/auth.go @@ -17,7 +17,7 @@ package api import ( "github.com/gin-gonic/gin" - "github.com/OpenIMSDK/protocol/auth" + auth "github.com/OpenIMSDK/protocol/auth" "github.com/OpenIMSDK/tools/a2r" "github.com/openimsdk/open-im-server/v3/pkg/rpcclient" @@ -29,6 +29,18 @@ func NewAuthApi(client rpcclient.Auth) AuthApi { return AuthApi(client) } +// @Summary User login +// @Description Get the user token +// @Tags Authentication +// @ID UserToken +// @Accept json +// @Param OperationId header string true "OperationId" +// @Param req body auth.UserTokenReq true "Secret is the Openim key. For details, see the server Config.yaml Secret field
Platform is the platform ID" +// @Produce json +// @Success 0 {object} auth.UserTokenResp +// @Failure 500 {object} error "ERRCODE is 500 generally an internal error of the server" +// @Failure 400 {object} error "Errcode is 400, which is generally a parameter input error." +// @Router /auth/user_token [post] func (o *AuthApi) UserToken(c *gin.Context) { a2r.Call(auth.AuthClient.UserToken, o.Client, c) } diff --git a/internal/api/route.go b/internal/api/route.go index 9a639a2de..7844b2429 100644 --- a/internal/api/route.go +++ b/internal/api/route.go @@ -41,8 +41,39 @@ import ( "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/prome" "github.com/openimsdk/open-im-server/v3/pkg/rpcclient" + + _ "github.com/openimsdk/open-im-server/v3/cmd/openim-api/docs" + + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" ) +//swag init --parseInternal --dir ../../internal/api/ +//swag init --parseInternal --dir cmd/openim-api,internal/api/ -g ../../internal/api/route.go +//swag init --parseInternal --pd --dir cmd/openim-api,internal/api/ -g ../../internal/api/route.go --output cmd/openim-api/docs + +// @title open-IM-Server API +// @version 1.0 +// @description Open-IM-Server API server document, all requests in the document have an OperationId field for link tracking + +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html + +// @host localhost:10002 +// @BasePath / + +// @schemes http https + +// @securityDefinitions.apikey ApiKeyAuth +// @in header +// @name token +// @description Description for what is this security definition being used + +//// @securityDefinitions.basic OperationId +//// @in header +//// @name OperationId +//// @description OperationId for link tracking + func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine { discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) // 默认RPC中间件 gin.SetMode(gin.ReleaseMode) @@ -52,6 +83,8 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive } log.ZInfo(context.Background(), "load config", "config", config.Config) r.Use(gin.Recovery(), mw.CorsHandler(), mw.GinParseOperationID()) + + r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) // init rpc client here userRpc := rpcclient.NewUser(discov) groupRpc := rpcclient.NewGroup(discov) diff --git a/internal/api/user.go b/internal/api/user.go index 0a5a12698..4028afdd9 100644 --- a/internal/api/user.go +++ b/internal/api/user.go @@ -19,7 +19,7 @@ import ( "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msggateway" - "github.com/OpenIMSDK/protocol/user" + user "github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/apiresp" "github.com/OpenIMSDK/tools/errs" @@ -35,10 +35,36 @@ func NewUserApi(client rpcclient.User) UserApi { return UserApi(client) } +// UserRegisterReq +// @Summary User registration +// @Description User registration +// @Tags User +// @ID UserRegister +// @Accept json +// @Param OperationId header string true "Operation Id" +// @Param UserInfo body user.UserRegisterReq true "Secret is the Openim key. For details, see the server Config.yaml Secret field." +// @Produce json +// @Success 200 {object} user.UserRegisterResp +// @Failure 500 {object} error "ERRCODE is 500 generally an internal error of the server" +// @Failure 400 {object} error "Errcode is 400, which is generally a parameter input error."" +// @Router /user/user_register [post] func (u *UserApi) UserRegister(c *gin.Context) { a2r.Call(user.UserClient.UserRegister, u.Client, c) } +// @Summary Modify user information +// @Description Modify user information Userid Faceurl, etc. +// @Tags User +// @ID UpdateUserInfo +// @Accept json +// @Param OperationId header string true "Operation Id" +// @Param req body user.UpdateUserInfoReq true "Request" +// @Produce json +// @Success 200 {object} user.UpdateUserInfoResp +// @Failure 500 {object} error "ERRCODE is 500 generally an internal error of the server" +// @Failure 400 {object} error "Errcode is 400, which is generally a parameter input error." +// @Security ApiKeyAuth +// @Router /user/update_user_info [post] func (u *UserApi) UpdateUserInfo(c *gin.Context) { a2r.Call(user.UserClient.UpdateUserInfo, u.Client, c) } @@ -47,6 +73,21 @@ func (u *UserApi) SetGlobalRecvMessageOpt(c *gin.Context) { a2r.Call(user.UserClient.SetGlobalRecvMessageOpt, u.Client, c) } +//// @Success 0 {object} user.GetDesignateUsersResp{usersInfo=[]sdkws.UserInfo} + +// @Summary Get user information +// @Description Obtain user information in batches according to the user list +// @Tags User +// @ID GetUsersInfo +// @Accept json +// @Param OperationId header string true "Operation Id" +// @Param req body user.GetDesignateUsersReq true "Request" +// @Produce json +// @Success 200 {object} user.GetDesignateUsersResp +// @Failure 500 {object} error "Errcode is 500 一For the internal error of the server" +// @Failure 400 {object} error "errcode is 400 一Input errors in the parameter, token is not brought up" +// @Security ApiKeyAuth +// @Router /user/get_users_info [post] func (u *UserApi) GetUsersPublicInfo(c *gin.Context) { a2r.Call(user.UserClient.GetDesignateUsers, u.Client, c) } diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index 508ef8377..600498f75 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -52,7 +52,8 @@ func WithLogName(logName string) func(*CmdOpts) { func NewRootCmd(name string, opts ...func(*CmdOpts)) (rootCmd *RootCmd) { rootCmd = &RootCmd{Name: name} c := cobra.Command{ - Use: "start openIM application", + // Use: "start openIM ${{name}}", + Use: fmt.Sprintf("start openIM %s", name), Short: fmt.Sprintf(`Start %s `, name), Long: fmt.Sprintf(`Start %s `, name), PersistentPreRunE: func(cmd *cobra.Command, args []string) error {