diff --git a/cmd/server.go b/cmd/server.go index 17cfd17..e210678 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -4,10 +4,7 @@ import ( "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" "github.com/spf13/cobra" - ginSwagger "github.com/swaggo/gin-swagger" - "github.com/swaggo/gin-swagger/swaggerFiles" "github.com/taoshihan1991/imaptool/controller" - "github.com/taoshihan1991/imaptool/docs" "github.com/taoshihan1991/imaptool/middleware" "github.com/taoshihan1991/imaptool/router" "github.com/taoshihan1991/imaptool/tools" @@ -66,16 +63,6 @@ func run() { router.InitViewRouter(engine) router.InitApiRouter(engine) - //文档服务 - docs.SwaggerInfo.Title = "GO-FLY接口文档" - docs.SwaggerInfo.Description = "go-fly即时通讯web客服管理系统 , 测试账户:kefu2 测试密码:123 类型:kefu" - docs.SwaggerInfo.Version = "0.0.7" - //docs.SwaggerInfo.Host = "127.0.0.1:"+port - docs.SwaggerInfo.Host = "gofly.sopans.com" - docs.SwaggerInfo.BasePath = "/" - docs.SwaggerInfo.Schemes = []string{"https"} - engine.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) - //logFile, _ := os.OpenFile("./fatal.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0660) //tools.RedirectStderr(logFile) diff --git a/config/model.conf b/config/model.conf deleted file mode 100644 index dc6da81..0000000 --- a/config/model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/config/policy.csv b/config/policy.csv deleted file mode 100644 index dce9197..0000000 --- a/config/policy.csv +++ /dev/null @@ -1,4 +0,0 @@ -p, role_1, /mysql, GET -p, role_1, /mysql, POST -p, role_1, /kefuinfo,POST -p, role_1, /kefuinfo,DELETE \ No newline at end of file diff --git a/controller/kefu.go b/controller/kefu.go index b2e93e1..3b58775 100644 --- a/controller/kefu.go +++ b/controller/kefu.go @@ -222,8 +222,7 @@ func PostKefuRegister(c *gin.Context) { return } models.CreateUserRole(uid, uint(roleId)) - ip, _ := tools.GetServerIP() - go ws.SendFlyServerJiang("admin register", name+"/"+password, ip.String()+":"+Port) + c.JSON(200, gin.H{ "code": 200, "msg": "注册完成", diff --git a/controller/login.go b/controller/login.go index e412781..48f6180 100644 --- a/controller/login.go +++ b/controller/login.go @@ -3,7 +3,6 @@ package controller import ( "github.com/gin-gonic/gin" "github.com/taoshihan1991/imaptool/tools" - "github.com/taoshihan1991/imaptool/ws" "time" ) @@ -30,8 +29,6 @@ func LoginCheckPass(c *gin.Context) { }) return } - ip, _ := tools.GetServerIP() - go ws.SendFlyServerJiang("adminlogin", c.Request.Host+"/"+username+"/"+password, ip.String()+":"+Port) userinfo["name"] = info.Name userinfo["kefu_id"] = info.ID diff --git a/docs/docs.go b/docs/docs.go deleted file mode 100644 index cf600bf..0000000 --- a/docs/docs.go +++ /dev/null @@ -1,270 +0,0 @@ -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT -// This file was generated by swaggo/swag at -// 2020-10-19 23:32:55.3852666 +0800 CST m=+0.208956401 - -package docs - -import ( - "bytes" - "encoding/json" - "strings" - - "github.com/alecthomas/template" - "github.com/swaggo/swag" -) - -var doc = `{ - "schemes": {{ marshal .Schemes }}, - "swagger": "2.0", - "info": { - "description": "{{.Description}}", - "title": "{{.Title}}", - "contact": {}, - "license": {}, - "version": "{{.Version}}" - }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", - "paths": { - "/check": { - "post": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "登陆验证接口", - "parameters": [ - { - "type": "string", - "description": "用户名", - "name": "username", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "密码", - "name": "password", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "类型", - "name": "type", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/message": { - "post": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "发送消息接口", - "parameters": [ - { - "type": "string", - "description": "来源uid", - "name": "from_id", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "目标uid", - "name": "to_id", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "内容", - "name": "content", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "类型|kefu,visitor", - "name": "type", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/messages": { - "get": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "获取访客聊天信息接口", - "parameters": [ - { - "type": "string", - "description": "访客ID", - "name": "visitorId", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "认证token", - "name": "token", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/visitors": { - "get": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "获取访客列表接口", - "parameters": [ - { - "type": "string", - "description": "分页", - "name": "page", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "认证token", - "name": "token", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/visitors_online": { - "get": { - "produces": [ - "application/json" - ], - "summary": "获取在线访客列表接口", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - } - }, - "definitions": { - "controller.Response": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "msg": { - "type": "string" - }, - "result": { - "type": "object" - } - } - } - } -}` - -type swaggerInfo struct { - Version string - Host string - BasePath string - Schemes []string - Title string - Description string -} - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = swaggerInfo{ - Version: "", - Host: "", - BasePath: "", - Schemes: []string{}, - Title: "", - Description: "", -} - -type s struct{} - -func (s *s) ReadDoc() string { - sInfo := SwaggerInfo - sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) - - t, err := template.New("swagger_info").Funcs(template.FuncMap{ - "marshal": func(v interface{}) string { - a, _ := json.Marshal(v) - return string(a) - }, - }).Parse(doc) - if err != nil { - return doc - } - - var tpl bytes.Buffer - if err := t.Execute(&tpl, sInfo); err != nil { - return doc - } - - return tpl.String() -} - -func init() { - swag.Register(swag.Name, &s{}) -} diff --git a/docs/swagger.json b/docs/swagger.json deleted file mode 100644 index a7b5ee4..0000000 --- a/docs/swagger.json +++ /dev/null @@ -1,202 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "contact": {}, - "license": {} - }, - "paths": { - "/check": { - "post": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "登陆验证接口", - "parameters": [ - { - "type": "string", - "description": "用户名", - "name": "username", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "密码", - "name": "password", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "类型", - "name": "type", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/message": { - "post": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "发送消息接口", - "parameters": [ - { - "type": "string", - "description": "来源uid", - "name": "from_id", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "目标uid", - "name": "to_id", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "内容", - "name": "content", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "类型|kefu,visitor", - "name": "type", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/messages": { - "get": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "获取访客聊天信息接口", - "parameters": [ - { - "type": "string", - "description": "访客ID", - "name": "visitorId", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "认证token", - "name": "token", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/visitors": { - "get": { - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "summary": "获取访客列表接口", - "parameters": [ - { - "type": "string", - "description": "分页", - "name": "page", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "认证token", - "name": "token", - "in": "header", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/visitors_online": { - "get": { - "produces": [ - "application/json" - ], - "summary": "获取在线访客列表接口", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - } - }, - "definitions": { - "controller.Response": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "msg": { - "type": "string" - }, - "result": { - "type": "object" - } - } - } - } -} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml deleted file mode 100644 index 80b52c2..0000000 --- a/docs/swagger.yaml +++ /dev/null @@ -1,132 +0,0 @@ -definitions: - controller.Response: - properties: - code: - type: integer - msg: - type: string - result: - type: object - type: object -info: - contact: {} - license: {} -paths: - /check: - post: - consumes: - - multipart/form-data - parameters: - - description: 用户名 - in: formData - name: username - required: true - type: string - - description: 密码 - in: formData - name: password - required: true - type: string - - description: 类型 - in: formData - name: type - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controller.Response' - summary: 登陆验证接口 - /message: - post: - consumes: - - multipart/form-data - parameters: - - description: 来源uid - in: formData - name: from_id - required: true - type: string - - description: 目标uid - in: formData - name: to_id - required: true - type: string - - description: 内容 - in: formData - name: content - required: true - type: string - - description: 类型|kefu,visitor - in: formData - name: type - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controller.Response' - summary: 发送消息接口 - /messages: - get: - consumes: - - multipart/form-data - parameters: - - description: 访客ID - in: query - name: visitorId - required: true - type: string - - description: 认证token - in: header - name: token - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controller.Response' - summary: 获取访客聊天信息接口 - /visitors: - get: - consumes: - - multipart/form-data - parameters: - - description: 分页 - in: query - name: page - required: true - type: string - - description: 认证token - in: header - name: token - required: true - type: string - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controller.Response' - summary: 获取访客列表接口 - /visitors_online: - get: - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/controller.Response' - summary: 获取在线访客列表接口 -swagger: "2.0" diff --git a/middleware/casbin.go b/middleware/casbin.go deleted file mode 100644 index df86794..0000000 --- a/middleware/casbin.go +++ /dev/null @@ -1,32 +0,0 @@ -package middleware - -import ( - "fmt" - "github.com/casbin/casbin/v2" - "github.com/gin-gonic/gin" - "log" -) - -func CasbinACL(c *gin.Context) { - roleId, _ := c.Get("role_id") - sub := fmt.Sprintf("%s_%d", "role", int(roleId.(float64))) - obj := c.Request.RequestURI - act := c.Request.Method - e, err := casbin.NewEnforcer("config/model.conf", "config/policy.csv") - log.Println(sub, obj, act, err) - ok, err := e.Enforce(sub, obj, act) - if err != nil { - c.JSON(200, gin.H{ - "code": 403, - "msg": "没有权限:" + err.Error(), - }) - c.Abort() - } - if !ok { - c.JSON(200, gin.H{ - "code": 403, - "msg": fmt.Sprintf("没有权限:%s,%s,%s", sub, obj, act), - }) - c.Abort() - } -} diff --git a/router/api.go b/router/api.go index fcf6d06..934d4a1 100644 --- a/router/api.go +++ b/router/api.go @@ -33,8 +33,6 @@ func InitApiRouter(engine *gin.Engine) { engine.GET("/messages", controller.GetVisitorMessage) engine.GET("/message_notice", controller.SendVisitorNotice) - //发送单条消息 - engine.POST("/message", middleware.Ipblack, controller.SendMessage) //上传文件 engine.POST("/uploadimg", middleware.Ipblack, controller.UploadImg) //上传文件 diff --git a/static/html/chat_kf_page.html b/static/html/chat_kf_page.html deleted file mode 100644 index e817800..0000000 --- a/static/html/chat_kf_page.html +++ /dev/null @@ -1,82 +0,0 @@ - -
- - - - -