Browse Source

修改地址

vue
nelson 4 years ago
parent
commit
0ed5df87eb
  1. 3
      controllers/BlogController.go
  2. 2
      go.mod
  3. 2
      static/css/common.css
  4. 4
      static/css/common.min.css
  5. 31
      utils/EsUtil.go
  6. 8
      views/T.header.tpl

3
controllers/BlogController.go

@ -140,6 +140,9 @@ func (this *BlogController) Get() {
userService.CountBrows(blog.UserId) userService.CountBrows(blog.UserId)
blogService.EditBlogBrows(id) blogService.EditBlogBrows(id)
} }
blog.User.Salt = ""
blog.User.UserPwd = ""
utils.ESSave(blog)
return return
} }

2
go.mod

@ -10,3 +10,5 @@ require (
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
google.golang.org/appengine v1.6.1 // indirect google.golang.org/appengine v1.6.1 // indirect
) )
go 1.13

2
static/css/common.css

@ -263,7 +263,7 @@ img {
.home-container{ .home-container{
height: 100%; height: 100%;
margin: 50px 5% 0 5%; margin: 50px 5% 60px 5%;
} }
.home-container hr{ .home-container hr{
margin: 0; margin: 0;

4
static/css/common.min.css

File diff suppressed because one or more lines are too long

31
utils/EsUtil.go

@ -11,8 +11,10 @@ import (
"strconv" "strconv"
"time" "time"
) )
var client *elastic.Client var client *elastic.Client
var host = "http://106.12.3.97:8209/" var host = "http://47.98.109.5:8209/"
const mapping = ` const mapping = `
{ {
"settings":{ "settings":{
@ -61,7 +63,7 @@ func init() {
} }
} }
func Index() { func Index() {
ctx := context.Background() ctx := context.Background()
exists, err := client.IndexExists("beeblog").Do(ctx) exists, err := client.IndexExists("beeblog").Do(ctx)
if err != nil { if err != nil {
@ -81,15 +83,16 @@ func Index() {
} }
} }
func ESSave(blog *models.Blog) { func ESSave(blog *models.Blog) {
ctx := context.Background() ctx := context.Background()
id := strconv.FormatInt(blog.Id,10) id := strconv.FormatInt(blog.Id, 10)
_, err := client.Index().Index("beeblog").Type("beeblog").Id(id).BodyJson(blog).Do(ctx) _, err := client.Index().Index("beeblog").Type("beeblog").Id(id).BodyJson(blog).Do(ctx)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
} }
//删除 //删除
func ESDelete(id string) { func ESDelete(id string) {
_, err := client.Delete().Index("beeblog"). _, err := client.Delete().Index("beeblog").
@ -102,20 +105,20 @@ func ESDelete(id string) {
} }
} }
func Search(key string) (*models.Blog,error) { func Search(key string) (*models.Blog, error) {
ctx := context.Background() ctx := context.Background()
query := elastic.NewMultiMatchQuery(key,"Title","BlogHtml") query := elastic.NewMultiMatchQuery(key, "Title", "BlogHtml")
searchResult, err := client.Search(). searchResult, err := client.Search().
Index("beeblog"). // 指定index,返回一个*SearchService对象 Index("beeblog"). // 指定index,返回一个*SearchService对象
//Type("beeblog"). //Type("beeblog").
Query(query). // 设置查询体,返回同一个*SearchService对象 Query(query). // 设置查询体,返回同一个*SearchService对象
//Sort("user", true). // 按照user升序排列 //Sort("user", true). // 按照user升序排列
//From(0).Size(10). // 从第一条数据,找十条,即0-9 //From(0).Size(10). // 从第一条数据,找十条,即0-9
Pretty(true). // 使查询request和返回的结果格式美观 Pretty(true). // 使查询request和返回的结果格式美观
Do(ctx) // 返回一个*SearchResult Do(ctx) // 返回一个*SearchResult
if err != nil { if err != nil {
println("search error",err.Error()) println("search error", err.Error())
return nil,err return nil, err
} }
fmt.Printf("找到 [%d] 组tweets\n", searchResult.Hits.TotalHits) fmt.Printf("找到 [%d] 组tweets\n", searchResult.Hits.TotalHits)
// 查看匹配到多少组数据 // 查看匹配到多少组数据
@ -124,10 +127,10 @@ func Search(key string) (*models.Blog,error) {
for _, item := range searchResult.Each(reflect.TypeOf(typ)) { //从搜索结果中取数据的方法 for _, item := range searchResult.Each(reflect.TypeOf(typ)) { //从搜索结果中取数据的方法
t := item.(models.Blog) t := item.(models.Blog)
fmt.Printf("%#v\n", t) fmt.Printf("%#v\n", t)
return &t,nil return &t, nil
} }
if err != nil { if err != nil {
panic(err) panic(err)
} }
return nil,nil return nil, nil
} }

8
views/T.header.tpl

@ -8,17 +8,15 @@
{{else}} {{else}}
<meta name="description" content="码农随笔,个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com"> <meta name="description" content="码农随笔,个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com">
{{end}} {{end}}
<link type="text/css" rel="styleSheet" href="/static/css/common.css"/> <link type="text/css" rel="styleSheet" href="/static/css/common.min.css"/>
<script type="text/javascript" src="/static/js/vue.min.js"></script> <script type="text/javascript" src="/static/js/vue.min.js"></script>
<link rel="stylesheet" href="/static/css/iview.css"> <link rel="stylesheet" href="/static/css/iview.css">
<script src="/static/js/iview.min.js"></script> <script src="/static/js/iview.min.js"></script>
{{/* <script src="/static/js/jquery-1.11.1.min.js"/>*/}}
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script> <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/layer.js"></script> <script type="text/javascript" src="/static/js/layer.js"></script>
<link rel="stylesheet" href="/static/layui/css/layui.css"> <link rel="stylesheet" href="/static/layui/css/layui.css">
{{/* <script type="text/javascript" src="/static/js/checkm.js"></script>*/}} <script type="text/javascript" src="/static/js/checkm.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script> <script type="text/javascript" src="/static/layui/layui.js"></script>
{{/* <link type="text/css" rel="styleSheet" href="/static/css/common.min.css"/>*/}} <script type="text/javascript" src="https://tajs.qq.com/stats?sId=66471694" charset="UTF-8"></script>
{{/* <script type="text/javascript" src="https://tajs.qq.com/stats?sId=66471694" charset="UTF-8"></script>*/}}
{{end}} {{end}}
Loading…
Cancel
Save