Skip to content

Commit 2903566

Browse files
author
wangkaikai
committed
文章分类增加model文件
1 parent 8193987 commit 2903566

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

models/Ali_category.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Created by Goland.
3+
* User: wangkaikai
4+
* Date: 2018/12/05
5+
* Time: 22:01
6+
*/
7+
package models
8+
9+
import (
10+
db "www.alisleepy.com/database"
11+
"log"
12+
)
13+
type Ali_category struct {
14+
CatId int `json:"catId" form:"catId"`
15+
CatName string `json:"catName" form:"catName"`
16+
}
17+
18+
func GetCategoryList()(categorys[] *Ali_category){
19+
datas, err := db.SqlDB.Query("select * from ali_catogory")
20+
if err != nil{
21+
log.Println(err)
22+
}
23+
defer datas.Close()
24+
for datas.Next(){
25+
var category Ali_category
26+
datas.Scan(&category.CatId, &category.CatName)
27+
categorys = append(categorys, category)
28+
}
29+
if err = datas.Err(); err != nil {
30+
return nil
31+
}
32+
return categorys
33+
}

views/header.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ <h1 class="logo hvr-bounce-in"><a href="#" title="alisleepy小站"><img src="/st
2626
<ul class="nav navbar-nav navbar-right">
2727
<li><a data-cont="首页" title="alisleepy小站-首页" href="/">首页</a></li>
2828
<li><a data-cont="添加文章" title="添加文章" href="/home/addBlog">添加文章</a></li>
29+
<li><a data-cont="API文档" target="_blank" title="API文档" href="http://www.api.alisleepy.top">API文档</a></li>
2930
</ul>
3031
</div>
3132
</div>

0 commit comments

Comments
 (0)