From e76276723465fb336f6cc6e1c7b3a1dd08184c48 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Thu, 12 Nov 2020 12:08:22 +0800 Subject: [PATCH] no message --- .vscode/settings.json | 3 +++ README.md | 2 +- controller/data.go | 7 +++++++ controller/mail.go | 9 +++++---- controller/openapi.go | 37 +++++++++++++++++++++++++++++++++++++ controller/user.go | 5 ----- controller/webhook.go | 17 ----------------- main.go | 7 ++++--- 8 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 controller/data.go create mode 100644 controller/openapi.go diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5bbb269 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "vue3snippets.enable-compile-vue-file-on-did-save-code": false +} \ No newline at end of file diff --git a/README.md b/README.md index fb916c2..3b64197 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ 前端采用vue+iview框架 -#### 安装教程 +#### how to use? diff --git a/controller/data.go b/controller/data.go new file mode 100644 index 0000000..fef9bbd --- /dev/null +++ b/controller/data.go @@ -0,0 +1,7 @@ +package controller + +type RespBase struct { + Msg string + Status int + Data interface{} +} diff --git a/controller/mail.go b/controller/mail.go index 997fa1d..92588f0 100644 --- a/controller/mail.go +++ b/controller/mail.go @@ -1,11 +1,12 @@ package controller import ( + "background/config" + "background/db" "bufio" "bytes" "errors" "fmt" - "github.com/gin-gonic/gin" "io/ioutil" "log" "net/smtp" @@ -14,8 +15,8 @@ import ( "strings" "text/template" "time" - "background/config" - "background/db" + + "github.com/gin-gonic/gin" ) type MailController struct { @@ -266,7 +267,7 @@ func (this *MailController) OnSendEmailCode(c *gin.Context) { user := "c7458969@163.com" password := "caiyu123" host := "smtp.163.com:25" - + //抄送给自己 //e = SendToMail(user,password,host,req.From,req.Template,req.Content,"html") //发送 diff --git a/controller/openapi.go b/controller/openapi.go new file mode 100644 index 0000000..2e31b94 --- /dev/null +++ b/controller/openapi.go @@ -0,0 +1,37 @@ +package controller + +import ( + "log" + + "github.com/gin-gonic/gin" +) + +type OpenApiController struct { +} +type DiffRequest struct { + Origin string `json:"origin"` + New string `json:"new"` +} + +//from: 发送人邮箱 +//to:接收邮件,可以是"290198252@qq.com;29019822@qq.com;2901982@qq.com" 邮箱之间用分号隔开 +//template:模板名字 +//content :网页模板的参数 key-value结构 +//temp_data 模板内具体要替换的变量名字 Key-value结构 +//generate 是否生成静态html +func (this *OpenApiController) OndiffCallback(c *gin.Context) { + var req DiffRequest + var resp RespBase + defer func() { + c.JSON(200, resp) + }() + + e := c.Bind(&req) + if e != nil { + log.Println(e.Error()) + resp.Msg = "ParaErr" + return + } + + resp.Msg = "OK" +} diff --git a/controller/user.go b/controller/user.go index 5c5284f..5b7fb41 100644 --- a/controller/user.go +++ b/controller/user.go @@ -41,11 +41,6 @@ type SetUserGroupReq struct { GroupName string `json:"group_name"` UserIds []int `json:"user_ids"` } -type RespBase struct { - Msg string - Status int - Data interface{} -} func (this *UserController) Auth(c *gin.Context) { var resp RespBase diff --git a/controller/webhook.go b/controller/webhook.go index 0fab6c9..b0b429f 100644 --- a/controller/webhook.go +++ b/controller/webhook.go @@ -1,18 +1 @@ package controller - -import "github.com/gin-gonic/gin" -type WebHookController struct { - -} -func (this *WebHookController) PushHook(c *gin.Context) { - resp := RespBase{"unkown error",-231,nil} - defer func() { - c.JSON(200,resp) - }() - repo := c.Param("repo") - if "" == repo{ - return - } - -} - diff --git a/main.go b/main.go index 6832502..0402d28 100644 --- a/main.go +++ b/main.go @@ -97,7 +97,7 @@ func main() { InitLogs() InitRedisConfig() InitMysql() - InitElasticSearch() + //InitElasticSearch() //o := db.GetMongoDb() //mgo = mgo @@ -172,9 +172,10 @@ func main() { api.GET("doc_versions", nil) // 获取文章的某个版本 } - hookapi := r.Group("hookapi") + + openapi := r.Group("openapi") { - hookapi.POST("/push_hook/:repo", webhookController.PushHook) + openapi.POST("/diff") } e := r.Run(":" + strconv.Itoa(config.GetPort())) if nil != e {