添加是否公开判断
parent
6baf8c4546
commit
f3e54bd866
|
@ -135,6 +135,7 @@ func UpdateArtilce(c *gin.Context) {
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
author string `json:"author"`
|
author string `json:"author"`
|
||||||
Type int64 `json:"type"`
|
Type int64 `json:"type"`
|
||||||
|
IsPublic int `json:"is_public"`
|
||||||
}
|
}
|
||||||
var req ReqUpdateArticle
|
var req ReqUpdateArticle
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -156,6 +157,7 @@ func UpdateArtilce(c *gin.Context) {
|
||||||
Content:req.Content,
|
Content:req.Content,
|
||||||
Author:req.author,
|
Author:req.author,
|
||||||
ID:req.Id,
|
ID:req.Id,
|
||||||
|
IsPublic:req.IsPublic,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if nil != e{
|
if nil != e{
|
||||||
|
@ -174,6 +176,7 @@ func AddArticle(c *gin.Context) {
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
author string `json:"author"`
|
author string `json:"author"`
|
||||||
Type int64 `json:"type"`
|
Type int64 `json:"type"`
|
||||||
|
Ispublic int `json:"ispublic"`
|
||||||
}
|
}
|
||||||
var req ReqAddArticle
|
var req ReqAddArticle
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -194,6 +197,7 @@ func AddArticle(c *gin.Context) {
|
||||||
Title:req.Title,
|
Title:req.Title,
|
||||||
Content:req.Content,
|
Content:req.Content,
|
||||||
Author:req.author,
|
Author:req.author,
|
||||||
|
IsPublic:req.Ispublic,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if nil != e{
|
if nil != e{
|
||||||
|
|
|
@ -14,6 +14,7 @@ type Doc struct {
|
||||||
Type int64 `sql:"type" json:"type"`
|
Type int64 `sql:"type" json:"type"`
|
||||||
Content string `sql:"content" json:"content"`
|
Content string `sql:"content" json:"content"`
|
||||||
Author string `sql:"author" json:"author"`
|
Author string `sql:"author" json:"author"`
|
||||||
|
IsPublic int `sql:"is_public" json:"is_public"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArticleType struct {
|
type ArticleType struct {
|
||||||
|
@ -35,15 +36,17 @@ func GetArticlesType() []ArticleType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateDoc(doc Doc) error {
|
func CreateDoc(doc Doc) error {
|
||||||
sql := fmt.Sprintf(`INSERT INTO doc ( doc.title, doc.content, doc.author, doc.type ) SELECT
|
sql := fmt.Sprintf(`INSERT INTO doc ( doc.title, doc.content, doc.author, doc.type,doc.is_public) SELECT
|
||||||
'%s',
|
'%s',
|
||||||
'%s',
|
'%s',
|
||||||
'%s',
|
'%s',
|
||||||
|
%d ,
|
||||||
%d
|
%d
|
||||||
FROM
|
FROM
|
||||||
DUAL
|
DUAL
|
||||||
WHERE
|
WHERE
|
||||||
NOT EXISTS ( SELECT * FROM doc WHERE doc.title = '%s' );`, doc.Title, strings.Replace(doc.Content, "'", "\\'", -1), doc.Author, doc.Type,doc.Title)
|
NOT EXISTS ( SELECT * FROM doc WHERE doc.title = '%s' );`, doc.Title, strings.Replace(doc.Content, "'", "\\'", -1),
|
||||||
|
doc.Author, doc.Type,doc.IsPublic,doc.Title)
|
||||||
_, e := db.GetMysqlClient().Query(sql)
|
_, e := db.GetMysqlClient().Query(sql)
|
||||||
if nil != e {
|
if nil != e {
|
||||||
logs.Error(e.Error())
|
logs.Error(e.Error())
|
||||||
|
|
|
@ -54,3 +54,4 @@ func GetHardwares(limit int,size int) ([]Hardware,error){
|
||||||
}
|
}
|
||||||
return ret,nil
|
return ret,nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue