no message

master
DESKTOP-4RNDQIC\29019 2021-06-12 01:26:37 +08:00
parent fe0602f67c
commit 6ddaeaa759
3 changed files with 89 additions and 35 deletions

View File

@ -164,18 +164,14 @@ func (this *PlanController) CreateUndo(c *gin.Context) {
resp.Status = 0 resp.Status = 0
} }
func (this *PlanController) UpdateUndo(c *gin.Context) { func (this *PlanController) UnFinishUndo(c *gin.Context) {
resp := RespBase{} resp := RespBase{}
defer func() { defer func() {
c.JSON(200, resp) c.JSON(200, resp)
}() }()
var req model.Book id := c.Param("id")
e := c.BindJSON(&req)
if nil != e { e := db.GetOrm().Exec(fmt.Sprintf("update background.`undo` set done = '0' where id = '%s'",id )).Error
resp.Msg = "wrong input"
return
}
e = db.GetOrm().Model(&model.Book{}).Update(&req).Error
if nil != e { if nil != e {
logs.Error(e.Error()) logs.Error(e.Error())
return return
@ -185,6 +181,62 @@ func (this *PlanController) UpdateUndo(c *gin.Context) {
resp.Status = 0 resp.Status = 0
} }
func (this *PlanController) FinishUndo(c *gin.Context) {
resp := RespBase{}
defer func() {
c.JSON(200, resp)
}()
id := c.Param("id")
log.Print("finish undo id",id)
e := db.GetOrm().Exec(fmt.Sprintf("update background.`undo` set done = 1 where id = '%s'",id )).Error
log.Print(fmt.Sprintf("update undo set done = 1 where id = %d",1 ))
if nil != e {
logs.Error(e.Error())
return
}
resp.Data = nil
resp.Msg = "OK"
resp.Status = 0
}
func (this *PlanController) UpdateUndo(c *gin.Context) {
resp := RespBase{}
defer func() {
c.JSON(200, resp)
}()
var req model.Undo
e := c.BindJSON(&req)
if nil != e {
resp.Msg = "wrong input"
return
}
e = db.GetOrm().Model(&model.Undo{}).Update(&req).Error
if nil != e {
logs.Error(e.Error())
return
}
resp.Data = nil
resp.Msg = "OK"
resp.Status = 0
}
func (this *PlanController) GetDone(c *gin.Context) {
resp := RespBase{}
defer func() {
c.JSON(200, resp)
}()
undos := []model.Undo{}
e := db.GetOrm().Model(&model.Undo{}).Where("done = 1").Find(&undos).Error
if nil != e {
log.Print(e.Error())
return
}
resp.Data = undos
resp.Msg = "OK"
resp.Status = 0
}
func (this *PlanController) GetUndo(c *gin.Context) { func (this *PlanController) GetUndo(c *gin.Context) {
resp := RespBase{} resp := RespBase{}
defer func() { defer func() {

46
main.go
View File

@ -136,10 +136,9 @@ func main() {
api.PUT("/article", controller.AddArticle) // 添加文章 api.PUT("/article", controller.AddArticle) // 添加文章
api.PUT("/article_search", controller.SearchArticles) // 添加文章 api.PUT("/article_search", controller.SearchArticles) // 添加文章
api.GET("/article_type", controller.ArticlesType) //获取所有文章分类 api.GET("/article_type", controller.ArticlesType) //获取所有文章分类
api.PUT("/article_type", controller.AddArticleType) api.PUT("/article_type", controller.AddArticleType) // 添加文章分类
api.DELETE("/article_type", controller.DeleteArticleType) api.DELETE("/article_type", controller.DeleteArticleType) // 删除文章分类
api.POST("/doc_search_term",controller.SearchArticleES) api.POST("/doc_search_term",controller.SearchArticleES) // 文章内容搜索,基于es的倒排
api.POST("/article_update", controller.UpdateArtilce) //更新文章 api.POST("/article_update", controller.UpdateArtilce) //更新文章
api.GET("/articleCount", controller.GetArticleCount) //获取所有文章个数 api.GET("/articleCount", controller.GetArticleCount) //获取所有文章个数
@ -161,16 +160,17 @@ func main() {
api.POST("/memo", controller.UpdateMemo) // 备忘录更新 api.POST("/memo", controller.UpdateMemo) // 备忘录更新
api.POST("/memos", controller.GetMemos) // 备忘录批量 api.POST("/memos", controller.GetMemos) // 备忘录批量
api.POST("/delmemo", controller.DeleteMemos) //删除备忘录 api.POST("/delmemo", controller.DeleteMemos) //删除备忘录
api.GET("/memo", controller.GetMemo) // 单独读取 api.GET("/memo", controller.GetMemo) // 单独读取备忘录
api.GET("doc_groups", controller.GetDocGroup) // 获取所有的文章分组 api.GET("doc_groups", controller.GetDocGroup) // 获取所有的文章分组
api.POST("type_group", controller.GetDocTypeGroup) // 获取类所在的组 api.POST("type_group", controller.GetDocTypeGroup) // 获取类所在的组
api.POST("group_type", controller.GetDoGroupcType) // 获取类所在的组 api.POST("group_type", controller.GetDoGroupcType) // 获取类所在的组
api.GET("doc_versions", nil) // 获取文章的某个版本 api.GET("doc_versions", nil) // 获取文章的某个版本
api.PUT("/book", controller.CreateBook) // api.PUT("/book", controller.CreateBook) //新建书籍
api.POST("/book", controller.UpdateBook) // api.POST("/book", controller.UpdateBook) // 更新书籍
api.POST("/getbook", controller.GetBook) // 单书籍数据 api.POST("/getbook", controller.GetBook) // 单书籍数据
api.POST("/getbooks", controller.GetPageBook) // 批量书籍 api.POST("/getbooks", controller.GetPageBook) // 批量书籍
api.POST("/delbook", controller.Delbook) // 删除书籍 api.POST("/delbook", controller.Delbook) // 删除书籍
@ -182,26 +182,28 @@ func main() {
api.POST("/plan_days", planController.PlanDay) // 获取本月有计划天数 api.POST("/plan_days", planController.PlanDay) // 获取本月有计划天数
api.GET("/plan_types", planController.Types) api.GET("/plan_types", planController.Types)
api.PUT("/undo", planController.CreateUndo) api.PUT("/undo", planController.CreateUndo) // 新增待办事项
api.POST("/undo", planController.UpdateUndo) api.POST("/undo", planController.UpdateUndo) // 更新待办事项
api.GET("/undo", planController.GetUndo) api.POST("/undo_finish/:id", planController.FinishUndo) // 完成待办事项
api.DELETE("/undo/:id", planController.DeleteUndo) 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.PUT("/doc_template",controller.CreateDocTemplate) // 创建文章模板
api.POST("/doc_template",controller.UpdateDocTemplate) api.POST("/doc_template",controller.UpdateDocTemplate) // 更新文章模板
api.POST("/get_doc_template",controller.GetDocTemplate) api.POST("/get_doc_template",controller.GetDocTemplate) // 获得文章模板
api.DELETE("/doc_template/:id",controller.DeleteDocTemplate) api.DELETE("/doc_template/:id",controller.DeleteDocTemplate) // 删除文章模板
api.GET("/doc_template/:id",controller.GetDocTemplateId) api.GET("/doc_template/:id",controller.GetDocTemplateId) //获得单个文章模板信息
} }
openapi := r.Group("openapi") openapi := r.Group("openapi")
{ {
openapi.POST("/diff") openapi.POST("/diff") // 比较两个文档差异
openapi.POST("/ddl2orm", openapiController.DDL2ORM) openapi.POST("/ddl2orm", openapiController.DDL2ORM) // sql ddl转gorm 结构体
openapi.POST("/ddl2markdown", openapiController.DDL2Markdown) openapi.POST("/ddl2markdown", openapiController.DDL2Markdown) // sql ddl转markdown 文档
openapi.POST("/ui2css", openapiController.UI2CSS) openapi.POST("/ui2css", openapiController.UI2CSS) // qt ui文件转css文档
} }
e := r.Run(":" + strconv.Itoa(config.GetPort())) e := r.Run(":" + strconv.Itoa(config.GetPort()))
if nil != e { if nil != e {

View File

@ -59,10 +59,10 @@ func TestPortDocToElastic(t *testing.T) {
InitRedisConfig() InitRedisConfig()
InitMysql() InitMysql()
db.InitELK() db.InitELK()
// e := model.PortDocumentToElasticsearch("doc") e := model.PortDocumentToElasticsearch("doc")
// if nil != e { if nil != e {
// log.Print(e.Error()) log.Print(e.Error())
// } }
} }
func TestReflect(t *testing.T) { func TestReflect(t *testing.T) {