zcy 2021-12-31 00:39:11 +08:00
commit da8ae4eb1d
2 changed files with 77 additions and 56 deletions

26
main.go
View File

@ -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) OnConected(c *network.ConnectionContext) {
log.Print(c.IpAdress,c.Cnntime)
log.Print(c.IpAdress, c.Cnntime)
}
func (this WsHandle) OnDataRecv(p *network.ConnectionContext, dat []byte) {
log.Print(p.IpAdress)
logger.LogRealeaseInfo(string(dat))
}
func main() {
InitConfig()
InitLogs()
@ -120,8 +119,8 @@ func main() {
r.Use(sessions.Middleware("sess_store", store))
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 {
@ -163,8 +162,8 @@ func main() {
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("/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) //获取所有文章个数
@ -190,7 +189,6 @@ func main() {
api.GET("/memo", controller.GetMemo) // 单独读取备忘录
api.GET("/memocnt", controller.GetMemoCnt) // 单独读取备忘录
api.GET("doc_groups", controller.GetDocGroup) // 获取所有的文章分组
api.POST("type_group", controller.GetDocTypeGroup) // 获取类所在的组
api.POST("group_type", controller.GetDoGroupcType) // 获取类所在的组
@ -219,11 +217,11 @@ func main() {
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.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")
{

View File

@ -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")