no message

master
zcy 2021-11-04 00:46:33 +08:00
parent e955bc2f0f
commit e177f9d138
4 changed files with 72 additions and 20 deletions

View File

@ -243,7 +243,9 @@ func SearchArticleESHightLight(c *gin.Context) {
highlight = highlight.Fields(elastic.NewHighlighterField("content"))
highlight = highlight.PreTags("<span>").PostTags("</span>")
x := []RetHighlight{}
_, e = db.GetElastic().QueryHighlight("doc", query, &x,highlight, 10, 0)
_, e = db.GetElastic().
QueryHighlight("doc", query, &x,highlight, 10, 0)
log.Print(x)
if nil != e {
log.Print(e.Error())
return

View File

@ -80,6 +80,57 @@ func (this *FileController) OnUpload(c *gin.Context) {
}
func (this *FileController) OnUploadOrigin(c *gin.Context) {
uid, e := uuid.NewV1()
if nil != e {
log.Print(e.Error())
return
}
imgtype := c.Query("type")
file, _, err := c.Request.FormFile("image")
if nil != err || nil == file {
log.Print(err.Error())
return
}
if imgtype == "gif" {
allgifs, er := gif.DecodeAll(file)
if nil != er {
log.Print("decode error", er.Error())
return
}
datout, err := os.Create("image/" + uid.String() + ".gif")
defer datout.Close()
if err != nil {
log.Fatal(err)
return
}
gif.EncodeAll(datout, allgifs)
c.JSON(200, map[string]interface{}{"url": uid.String() + ".gif"})
} else {
img, name, err := image.Decode(file)
if nil != err {
log.Print(err.Error())
return
}
dx := img.Bounds().Dx()
// resize to width 1000 using Lanczos resampling
// and preserve aspect ratio
m := resize.Resize(uint(dx), 0, img, resize.Lanczos3)
datout, err := os.Create("image/" + uid.String() + "." + name)
defer datout.Close()
if err != nil {
log.Fatal(err)
}
jpeg.Encode(datout, m, nil)
c.JSON(200, map[string]interface{}{"url": uid.String() + "." + name})
}
}
func (this *FileController) FileList(c *gin.Context) {
var nodes utils.FileDesc
path := c.Query("path")

View File

@ -289,25 +289,24 @@ func (this *UserController) Login(c *gin.Context) {
}
}
//存储session
session := sessions.Get(c)
log.Println("set session", string(sessionInfo))
session.Set("", string(sessionInfo))
session.Clear()
// session := sessions.Get(c)
// log.Println("set session", string(sessionInfo))
// session.Set("", string(sessionInfo))
// session.Clear()
//session.
var Options *sessions.Options
if req.RememberMe == 1 {
Options = &sessions.Options{
MaxAge: 2 * 24 * 3600 * 1000,
}
} else {
Options = &sessions.Options{
MaxAge: 8 * 3600 * 1000,
}
}
session.Options(*Options)
session.Save()
// var Options *sessions.Options
// if req.RememberMe == 1 {
// Options = &sessions.Options{
// MaxAge: 2 * 24 * 3600 * 1000,
// }
// } else {
// Options = &sessions.Options{
// MaxAge: 8 * 3600 * 1000,
// }
// }
// session.Options(*Options)
// session.Save()
resp.Msg = "登录成功"
resp.Status = 0

View File

@ -168,7 +168,8 @@ func main() {
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", 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) // 获取所有的文章类型
@ -223,7 +224,6 @@ func main() {
api.DELETE("/doc_template/:id",controller.DeleteDocTemplate) // 删除文章模板
api.GET("/doc_template/:id",controller.GetDocTemplateId) //获得单个文章模板信息
}
openapi := r.Group("openapi")
{
openapi.POST("/diff") // 比较两个文档差异