二级文章分类
parent
17a4a998bf
commit
1c2ff37630
|
@ -3,6 +3,8 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="7cf7b6b3-0082-44ef-bb0f-bfcc57e19eb1" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/controller/blog.go" beforeDir="false" afterPath="$PROJECT_DIR$/controller/blog.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/model/blog.go" beforeDir="false" afterPath="$PROJECT_DIR$/model/blog.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -97,22 +99,22 @@
|
|||
<screen x="0" y="40" width="2048" height="1112" />
|
||||
</state>
|
||||
<state x="805" y="351" key="FileChooserDialogImpl/0.40.2048.1112@0.40.2048.1112" timestamp="1595431879732" />
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.bottom" timestamp="1595433941254">
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.bottom" timestamp="1595746777201">
|
||||
<screen x="0" y="40" width="2048" height="1112" />
|
||||
</state>
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.bottom/0.40.2048.1112@0.40.2048.1112" timestamp="1595433941254" />
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.center" timestamp="1595433941254">
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.bottom/0.40.2048.1112@0.40.2048.1112" timestamp="1595746777201" />
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.center" timestamp="1595746777200">
|
||||
<screen x="0" y="40" width="2048" height="1112" />
|
||||
</state>
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.center/0.40.2048.1112@0.40.2048.1112" timestamp="1595433941254" />
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.left" timestamp="1595433941254">
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.center/0.40.2048.1112@0.40.2048.1112" timestamp="1595746777200" />
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.left" timestamp="1595746777200">
|
||||
<screen x="0" y="40" width="2048" height="1112" />
|
||||
</state>
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.left/0.40.2048.1112@0.40.2048.1112" timestamp="1595433941254" />
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.right" timestamp="1595433941254">
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.left/0.40.2048.1112@0.40.2048.1112" timestamp="1595746777200" />
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.right" timestamp="1595746777200">
|
||||
<screen x="0" y="40" width="2048" height="1112" />
|
||||
</state>
|
||||
<state width="2005" height="376" key="GridCell.Tab.0.right/0.40.2048.1112@0.40.2048.1112" timestamp="1595433941254" />
|
||||
<state width="2005" height="305" key="GridCell.Tab.0.right/0.40.2048.1112@0.40.2048.1112" timestamp="1595746777200" />
|
||||
<state width="2005" height="376" key="GridCell.Tab.1.bottom" timestamp="1595433941254">
|
||||
<screen x="0" y="40" width="2048" height="1112" />
|
||||
</state>
|
||||
|
|
|
@ -280,6 +280,11 @@ func AddArticleType(c *gin.Context) {
|
|||
}()
|
||||
|
||||
typeName :=c.Query("name")
|
||||
group := c.Query("group")
|
||||
groupid,e := strconv.Atoi(group)
|
||||
if nil != e{
|
||||
return
|
||||
}
|
||||
id := c.Query("id")
|
||||
if id != ""{
|
||||
if typeName == ""{
|
||||
|
@ -288,6 +293,7 @@ func AddArticleType(c *gin.Context) {
|
|||
articleType := model.ArticleType{
|
||||
Id: 0,
|
||||
Name: typeName,
|
||||
Group: int32(groupid),
|
||||
}
|
||||
rsp.Data = model.UpdateArticleType(articleType)
|
||||
rsp.Msg = "OK"
|
||||
|
@ -299,13 +305,12 @@ func AddArticleType(c *gin.Context) {
|
|||
articleType := model.ArticleType{
|
||||
Id: 0,
|
||||
Name: typeName,
|
||||
Group: int32(groupid),
|
||||
}
|
||||
rsp.Data = model.AddArticleType(articleType)
|
||||
rsp.Msg = "OK"
|
||||
rsp.Status = 0
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func DeleteArticle(c *gin.Context) {
|
||||
|
@ -395,6 +400,20 @@ func UpdateMemo(c *gin.Context) {
|
|||
resp.Status = 0
|
||||
}
|
||||
|
||||
func GetDocGroup(c *gin.Context) {
|
||||
rsp := RespBase{"ERR",-1,nil}
|
||||
defer func() {
|
||||
c.JSON(200,rsp)
|
||||
}()
|
||||
group,e := model.GetAllGroup()
|
||||
if nil != e{
|
||||
log.Print(e.Error())
|
||||
return
|
||||
}
|
||||
rsp.Data = group
|
||||
rsp.Status = 0
|
||||
rsp.Msg = "OK"
|
||||
}
|
||||
func GetMemos(c *gin.Context) {
|
||||
rsp := RespBase{"ERR",-1,nil}
|
||||
defer func() {
|
||||
|
|
1
main.go
1
main.go
|
@ -161,6 +161,7 @@ func main() {
|
|||
api.POST("/memos", controller.GetMemos) // 备忘录批量
|
||||
api.POST("/delmemo", controller.DeleteMemos) //删除备忘录
|
||||
api.GET("/memo", controller.GetMemo) // 单独读取
|
||||
api.GET("doc_groups",controller.GetDocGroup) // 获取所有的文章分组
|
||||
}
|
||||
hookapi := r.Group("hookapi")
|
||||
{
|
||||
|
|
|
@ -92,7 +92,8 @@ func DeleteDoc(id int64) error{
|
|||
}
|
||||
|
||||
func AddArticleType(t ArticleType) error{
|
||||
sql := fmt.Sprintf("insert into doc_type(id,type_name) values ('%d','%s')",t.Id,t.Name)
|
||||
sql := fmt.Sprintf("insert into doc_type(id,type_name,`group`) values ('%d','%s','%d')",t.Id,t.Name,t.Group)
|
||||
log.Print(sql)
|
||||
_, e := db.GetMysqlClient().Query(sql)
|
||||
if nil != e {
|
||||
logs.Error(e.Error())
|
||||
|
@ -101,7 +102,7 @@ func AddArticleType(t ArticleType) error{
|
|||
return nil
|
||||
}
|
||||
func UpdateArticleType(t ArticleType) error{
|
||||
sql := fmt.Sprintf("update doc_type set type_name = '%s' where id = %d",t.Name,t.Id)
|
||||
sql := fmt.Sprintf("update doc_type set type_name = '%s' and group = '%d' where id = %d",t.Name,t.Group,t.Id)
|
||||
_, e := db.GetMysqlClient().Query(sql)
|
||||
if nil != e {
|
||||
logs.Error(e.Error())
|
||||
|
@ -131,3 +132,13 @@ func GetAllDocs() ([]Doc,error) {
|
|||
return ret,nil
|
||||
|
||||
}
|
||||
func GetAllGroup() ([]DocGroup,error) {
|
||||
ret := []DocGroup{}
|
||||
sql := fmt.Sprintf("select * from doc_group")
|
||||
e := db.GetMysqlClient().Query2(sql,&ret)
|
||||
if nil != e {
|
||||
logs.Error(e.Error())
|
||||
return nil,e
|
||||
}
|
||||
return ret,nil
|
||||
}
|
Loading…
Reference in New Issue