diff --git a/main.go b/main.go index a1d0223..d0f1b3d 100644 --- a/main.go +++ b/main.go @@ -93,21 +93,20 @@ func InitLogs() { logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile) } -type WsHandle struct{ +type WsHandle struct { +} + +func (this WsHandle) OnDisConected(*network.ConnectionContext) { } -func (this WsHandle) OnDisConected(*network.ConnectionContext) { - +func (this WsHandle) OnConected(c *network.ConnectionContext) { + log.Print(c.IpAdress, c.Cnntime) } -func (this WsHandle) OnConected(c *network.ConnectionContext) { - log.Print(c.IpAdress,c.Cnntime) -} -func (this WsHandle) OnDataRecv(p *network.ConnectionContext, dat []byte) { +func (this WsHandle) OnDataRecv(p *network.ConnectionContext, dat []byte) { log.Print(p.IpAdress) logger.LogRealeaseInfo(string(dat)) } - func main() { InitConfig() InitLogs() @@ -118,10 +117,10 @@ func main() { r := gin.Default() store := sessions.NewCookieStore([]byte("secret123")) r.Use(sessions.Middleware("sess_store", store)) - r.Use(CORSMiddleware) // Cross domain + r.Use(CORSMiddleware) // Cross domain - go func () { - server := network.ServerFactory("0.0.0.0",config.ApiConfig().WsServerConf) + go func() { + server := network.ServerFactory("0.0.0.0", config.ApiConfig().WsServerConf) server.SetHandle(WsHandle{}) e := server.Run() if nil != e { @@ -156,40 +155,39 @@ func main() { /** 修改密码**/ api.POST("modify_pass", middle.AuthMiddle, userController.ModifyPasswd) - api.GET("/article/:id", controller.GetArticle) //获取文章 - api.POST("/articles", controller.GetArticles) // 获取所有文章 - api.PUT("/article", controller.AddArticle) // 添加文章 - api.PUT("/article_search", controller.SearchArticles) // 添加文章 - api.GET("/article_type", controller.ArticlesType) //获取所有文章分类 - api.PUT("/article_type", controller.AddArticleType) // 添加文章分类 - api.DELETE("/article_type", controller.DeleteArticleType) // 删除文章分类 - api.POST("/doc_search_term",controller.SearchArticleES) // 文章内容搜索,基于es的倒排 - api.POST("/doc_match_search_hightlight",controller.SearchArticleESHightLight) // 文章内容搜索,基于es的倒排 + api.GET("/article/:id", controller.GetArticle) //获取文章 + api.POST("/articles", controller.GetArticles) // 获取所有文章 + api.PUT("/article", controller.AddArticle) // 添加文章 + api.PUT("/article_search", controller.SearchArticles) // 添加文章 + api.GET("/article_type", controller.ArticlesType) //获取所有文章分类 + api.PUT("/article_type", controller.AddArticleType) // 添加文章分类 + api.DELETE("/article_type", controller.DeleteArticleType) // 删除文章分类 + api.POST("/doc_search_term", controller.SearchArticleES) // 文章内容搜索,基于es的倒排 + api.POST("/doc_match_search_hightlight", controller.SearchArticleESHightLight) // 文章内容搜索,基于es的倒排 - api.POST("/article_update", controller.UpdateArtilce) //更新文章 - api.GET("/articleCount", controller.GetArticleCount) //获取所有文章个数 - api.DELETE("/article/:id", controller.DeleteArticle) ////删除文章 - api.POST("/image_upload", fileController.OnUpload) // 上传图片,如果图片太大自动裁减为原来的一半 - api.POST("/image_upload_origin", fileController.OnUploadOrigin) // 上传图片 - api.GET("/image_download/:file", fileController.OnDownLoad) // 下载图片 - api.GET("/image_thumbnail/:file", fileController.OnThumbnail) // 下载图片 - api.GET("/doc_types", controller.ArticlesTypes) // 获取所有的文章类型 - api.POST("/hardware", controller.AddHardware) // 新增硬件 - api.GET("/hardware", controller.ReadHardWare) // 读取硬件 - api.DELETE("/hardware", controller.DeleteHardWare) // 读取硬件 + api.POST("/article_update", controller.UpdateArtilce) //更新文章 + api.GET("/articleCount", controller.GetArticleCount) //获取所有文章个数 + api.DELETE("/article/:id", controller.DeleteArticle) ////删除文章 + api.POST("/image_upload", fileController.OnUpload) // 上传图片,如果图片太大自动裁减为原来的一半 + api.POST("/image_upload_origin", fileController.OnUploadOrigin) // 上传图片 + api.GET("/image_download/:file", fileController.OnDownLoad) // 下载图片 + api.GET("/image_thumbnail/:file", fileController.OnThumbnail) // 下载图片 + api.GET("/doc_types", controller.ArticlesTypes) // 获取所有的文章类型 + api.POST("/hardware", controller.AddHardware) // 新增硬件 + api.GET("/hardware", controller.ReadHardWare) // 读取硬件 + api.DELETE("/hardware", controller.DeleteHardWare) // 读取硬件 api.PUT("/file", fileController.OnFileUploadFile) // 上传文件 api.GET("/file", fileController.DownloadFile) // 下载 文件 api.GET("/filelist", fileController.FileList) // 文件列表 api.GET("/fileType", fileController.FileType) // 文件类型 - api.PUT("/memo", controller.CreateMemo) // 备忘录新建 - api.POST("/memo", controller.UpdateMemo) // 备忘录更新 - api.POST("/memos", controller.GetMemos) // 备忘录批量 - api.POST("/delmemo", controller.DeleteMemos) //删除备忘录 - api.GET("/memo", controller.GetMemo) // 单独读取备忘录 - api.GET("/memocnt", controller.GetMemoCnt) // 单独读取备忘录 - + api.PUT("/memo", controller.CreateMemo) // 备忘录新建 + api.POST("/memo", controller.UpdateMemo) // 备忘录更新 + api.POST("/memos", controller.GetMemos) // 备忘录批量 + api.POST("/delmemo", controller.DeleteMemos) //删除备忘录 + api.GET("/memo", controller.GetMemo) // 单独读取备忘录 + api.GET("/memocnt", controller.GetMemoCnt) // 单独读取备忘录 api.GET("doc_groups", controller.GetDocGroup) // 获取所有的文章分组 api.POST("type_group", controller.GetDocTypeGroup) // 获取类所在的组 @@ -210,28 +208,28 @@ func main() { api.POST("/plan_days", planController.PlanDay) // 获取本月有计划天数 api.GET("/plan_types", planController.Types) - api.PUT("/undo", planController.CreateUndo) // 新增待办事项 - api.POST("/undo", planController.UpdateUndo) // 更新待办事项 - api.POST("/undo_finish/:id", planController.FinishUndo) // 完成待办事项 - api.POST("/undo_unfinish/:id", planController.UnFinishUndo) // 已完成事项改未完成 - api.GET("/undo", planController.GetUndo) // 获得待办事项 - api.GET("/done", planController.GetDone) // 获得待办事项 + api.PUT("/undo", planController.CreateUndo) // 新增待办事项 + api.POST("/undo", planController.UpdateUndo) // 更新待办事项 + api.POST("/undo_finish/:id", planController.FinishUndo) // 完成待办事项 + api.POST("/undo_unfinish/:id", planController.UnFinishUndo) // 已完成事项改未完成 + api.GET("/undo", planController.GetUndo) // 获得待办事项 + api.GET("/done", planController.GetDone) // 获得待办事项 - api.DELETE("/undo/:id", planController.DeleteUndo) // 删除待办事项 - - api.PUT("/doc_template",controller.CreateDocTemplate) // 创建文章模板 - api.POST("/doc_template",controller.UpdateDocTemplate) // 更新文章模板 - api.POST("/get_doc_template",controller.GetDocTemplate) // 获得文章模板 - api.DELETE("/doc_template/:id",controller.DeleteDocTemplate) // 删除文章模板 - api.GET("/doc_template/:id",controller.GetDocTemplateId) //获得单个文章模板信息 + api.DELETE("/undo/:id", planController.DeleteUndo) // 删除待办事项 + + api.PUT("/doc_template", controller.CreateDocTemplate) // 创建文章模板 + api.POST("/doc_template", controller.UpdateDocTemplate) // 更新文章模板 + api.POST("/get_doc_template", controller.GetDocTemplate) // 获得文章模板 + api.DELETE("/doc_template/:id", controller.DeleteDocTemplate) // 删除文章模板 + api.GET("/doc_template/:id", controller.GetDocTemplateId) //获得单个文章模板信息 } openapi := r.Group("openapi") { - openapi.POST("/diff") // 比较两个文档差异 - openapi.POST("/ddl2orm", openapiController.DDL2ORM) // sql ddl转gorm 结构体 - openapi.POST("/ddl2markdown", openapiController.DDL2Markdown) // sql ddl转markdown 文档 - openapi.POST("/ui2css", openapiController.UI2CSS) // qt ui文件转css文档 - openapi.POST("/duilib_xml2cpp", openapiController.DuilibXml2Cpp) // duilib to cpp + openapi.POST("/diff") // 比较两个文档差异 + openapi.POST("/ddl2orm", openapiController.DDL2ORM) // sql ddl转gorm 结构体 + openapi.POST("/ddl2markdown", openapiController.DDL2Markdown) // sql ddl转markdown 文档 + openapi.POST("/ui2css", openapiController.UI2CSS) // qt ui文件转css文档 + openapi.POST("/duilib_xml2cpp", openapiController.DuilibXml2Cpp) // duilib to cpp } e := r.Run(":" + strconv.Itoa(config.GetPort())) if nil != e { diff --git a/model/blog.go b/model/blog.go index 1f9f1b9..7f4ce74 100644 --- a/model/blog.go +++ b/model/blog.go @@ -12,6 +12,7 @@ import ( ) type Doc struct { +<<<<<<< .merge_file_a12396 ID int64 `json:"id" gorm:"column:id" sql:"id"` Title string `json:"title" gorm:"column:title" sql:"title"` Type int32 `json:"type" gorm:"column:type" sql:"type"` @@ -24,6 +25,20 @@ type Doc struct { IsPublic int32 `json:"is_public" gorm:"column:is_public" sql:"is_public"` Deleted int32 `json:"deleted" gorm:"column:deleted" sql:"deleted"` OriginUrl string `json:"origin_url" gorm:"column:origin_url" sql:"origin_url"` +======= + ID int64 `json:"id" gorm:"column:id" sql:"id"` + Title string `json:"title" gorm:"column:title" sql:"title"` + Type int32 `json:"type" gorm:"column:type" sql:"type"` + Content string `json:"content" gorm:"column:content" sql:"content"` + Author string `json:"author" gorm:"column:author" sql:"author"` + CreateTime time.Time `json:"create_time" gorm:"column:create_time" sql:"create_time"` + UpdateTime time.Time `json:"update_time" gorm:"column:update_time" sql:"update_time"` + DeleteTime time.Time `json:"delete_time" gorm:"column:delete_time" sql:"delete_time"` + Version int32 `json:"version" gorm:"column:version" sql:"version"` + IsPublic int32 `json:"is_public" gorm:"column:is_public" sql:"is_public"` + Deleted int32 `json:"deleted" gorm:"column:deleted" sql:"deleted"` + OriginUrl string `json:"origin_url" gorm:"column:origin_url" sql:"origin_url"` +>>>>>>> .merge_file_a29080 } type DocGroup struct { @@ -90,7 +105,11 @@ UpdateDoc 更新文档 func UpdateDoc(doc Doc) error { sql := fmt.Sprintf(`update doc set doc.author = '%s' ,doc.title = '%s',doc.type = '%d',doc.content = '%s' ,doc.update_time = '%s' ,doc.version = '%d' where doc.id = '%d'; `, doc.Author, doc.Title, doc.Type, +<<<<<<< .merge_file_a12396 strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05"),doc.Version, doc.ID) +======= + strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05"), doc.Version, doc.ID) +>>>>>>> .merge_file_a29080 _, e := db.GetMysqlClient().Query(sql) if nil != e { logs.Error(e.Error()) @@ -153,6 +172,10 @@ func DeleteArticleType(id int32) error { return nil } +<<<<<<< .merge_file_a12396 +======= + +>>>>>>> .merge_file_a29080 func GetAllDocs() ([]Doc, error) { ret := []Doc{} sql := fmt.Sprintf("select * from doc")