添加获取文章列表接口

master
a7458969 2020-01-25 00:07:37 +08:00
parent 2b7c0450bb
commit 3b2aaa604e
7 changed files with 105 additions and 1 deletions

27
c@192.168.0.101 Normal file
View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAxfs9xpGkF/tF7eCrkTI73CDA1VW/iIAR6/fOEPKlDsDcRKMR
uwb3rVaWrbTTG9doCjiAI7xtwuP0N9oka4N8nYbywACoWNTzQn4+V302yKIA/jiU
sSe1dNofNxlY1QSz/lu/D+zeJ3qHdelicRJsQUSh150ug5gJadF3zYfhotix7K3i
sLhpm+HQ5mbRk5b4AypXMqEB6M2cb1iTZYtKBmDMh6ZzOdiWg6ohjlmKwq7oeJWQ
6oXDmT3jChbUMhAmQ4AEi8f9555lw6nk0MzZXhMH+9mt1XwU6klt8+Rwz4f2t9Ob
ST/8U+oWMrCB1jO14J/s+c3ymMqsIbSccVtNdwIDAQABAoIBADYM1Vy0vjvd2cWL
pMtLD5SVTI/xjQzTChGF4bg2xmE0ve3vJxQMXunvzcs2prvfHwRLUJBxDPY8DZyB
7Zd8mjTXdsZ8Z3l5CcCJfrOb96zmraa6A74pvRxdwE/ml53wXsN+gLb0T+IvTXQf
d0SvZuaauiSHQP+kLk25Zh+yjSNL0qHJxFRSnAPjAXGLpgkTAFCC4KegliDdhpRb
c9taytlwet3KyB7d6MzqY5+UuMNLHkWqZsb1lOEjSRjdRyYuMd41srbw+Of6+5iK
RA1C6hwshhSgiTV9qNVcO5xykGsdk+JNsp5pUoaygUkxn47gMoPBk8ZwpwtzKbWQ
7r9NbsECgYEA6j4JyhbVaS97HaWLIYJlhe4Gxi6jfBo4ZhbzzK800/8iB2iHGWa+
8qxhQes8mkoGj9XtDVwwlgM6xKnhEysfDSZXpO6pPdxy1f3wnrukGx7jNgVcL8F2
c1K6Zda8HiRqe8Fb6PGqvxRZAwfZmkuG+N5phFR3rSRSEvVxdH5p118CgYEA2F73
y+/sCh4Bx9ld1wgxXlgrY/7DsWWuWF8eNKwrcrScgxmpbM1ZDuHTth2VzxrMYVLP
QPmyAtoPGv85eVKkEBC+mFJhFaZFb8lNfzUNZSYyImo70h+ZXyjMiuFC7G1yirQO
NFCooKkWmRheehs/O6oS0SbY9/YDbWE4vDwGuOkCgYAf9A6JzsuV6bA1vxtXmt4W
gv3RkxMiHsGKy56+UTg3oxoVQKENSgLKP9GUmG5P7cEvZdNMe0L1c8NUiIf3gW5e
8NgL27KiiavwnQ9x187vFCuSdvC4Yv+xg5uBwOUwh28vKpVLFYxhPHlX/H4mmh7z
XAOw1YTtzYKUq36qkYQGqQKBgQCpUIdwGusGb7zM+peoMU0QmsY5lZ7lLsBjfutQ
JHpLZHIlVOtzrK1ILAdTt4sHad0NO5PbMInQGXtAkQAUpEqmF7RN1gkKu/YSJ+Bw
7r7wrBcHP0JYh0mpYW/OLcAE6xB64bNL1OJf9nEslBk6TCALPGdFK7UVNHoyGaYg
BojsIQKBgAWqp6p8VF1Hp7pIswCnWN5YrmRlwIEANBLNgdk53UpXlIjZracoRqTe
LSINSpTgBgEe5FHPqa9Yxu0rS7ievLlGfVNscXtUaW1YiisU0y7iUjvxiW0u8afX
elQGUJgoAa9MPQFNJ3cNVqzSLfbhCRANc0zzqf5d2lNPPWgfg6R+
-----END RSA PRIVATE KEY-----

View File

@ -203,8 +203,33 @@ func ArticlesType(c *gin.Context) {
rsp.Msg = "OK" rsp.Msg = "OK"
rsp.Status = 0 rsp.Status = 0
} }
func DeleteArticle(c *gin.Context) {
func AddArticleType(c *gin.Context) {
rsp := RespBase{Msg:"Fail",Status:210}
defer func() {
c.JSON(200,rsp)
}()
type ReqAddArticleType struct {
Id int64 `json:"id"`
Name string `json:"name"`
author string `json:"author"`
}
var req ReqAddArticleType
e := c.BindJSON(req)
if nil != e{
return
}
articleType := model.ArticleType{
Id: 0,
Name: req.Name,
}
rsp.Data = model.AddArticleType(articleType)
rsp.Msg = "OK"
rsp.Status = 0
}
func DeleteArticle(c *gin.Context) {
rsp := RespBase{Msg:"FAIL", Status:210,} rsp := RespBase{Msg:"FAIL", Status:210,}
defer func() { defer func() {
c.JSON(200,rsp) c.JSON(200,rsp)

View File

27
id_rsa_local Normal file
View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA1Ekg7QR6yjJWv82QpBdxYkwalhAbcLD2b4l4yx787vQKJvG/
Ylf8lmk+yVbxhFcrpZi0DtwbpyatqR4yvHmK7gBVotK5nVLPEZASIRB330k2ud1p
aUYVExf/8O3MS9WIPfQ3rz20protDS2LAufKq2FRGl+HLRqK2+FGfHxAy+SvuteC
CXYP+YwPewJ5e3Lw5i7DguW2Yxz2qx+tTZzkcv44z40MOjRZQtRYs6k2mJLr2VIh
rgjCClziAYNZbKnj8ZvRf/QFul10ouAz8n8uDmUfw2RfM+RFj5xwXDqbNFhAciKF
U0jFPmcRfLT9ldpVG58Nap2xZ06NMkduDFaR1QIDAQABAoIBABfgPbbKuTDCpqUd
7rW1+Uev/ZGBMETlcmIrGQ3nZ1VM11N3/ymFceBM6AXnJHTZBQyz9xRwxx9upzuN
LPGrzedk3Dza7It4Q9fa118mpgTUDDatY2y2uCoUmfG0HTUuSAuHyzeHfij+aZDA
3ZCvF0ldQazwr5hwEswWM0JPC06jLnUi6MY+RSLZtpJqxJFOJyQPHTyqLlcWXp1c
+I9kw+VJqO3IR7hsldAGnRa0JzO1B5wdZY/lCv7K/+JiLSCxCRWByYnHQIB+26Q8
PBLJfIqXn9CGqW9HDuH/qQ/D+vh0FWAoWjIY2FWNTVSSaEUnWHW1tPWO971xbOar
PdVgo8UCgYEA8MamKKfXoOxDJ0dr9gTP6g6/n7zt9M1kv9KOvYSEIxVeiaCqbd/o
eJTTTqx4AIg3T0N7cMXx+0RPBWKLjLvObglSvjuC4rcBX9qKzb1IBZMrQFhTzeww
GBWvp12c2FWMpE/+p+m6AcQPFLau1d8ndQC8XpOYbBJYqnfFAqOcsHMCgYEA4bVR
RQ7+NTiZZewQzQVAM8940b9AELoO18wcuvtx5iTI+Lo3sPqIgl1YNZHCY4f/QHCS
hqEUEj/JEk0j7K6yw5TDOLjd1Ymmm8cNh9x1hed51SH5ittleOjNG9ABlh9A76b+
lin/wybLVQdTrfaMD1Y8BZaHOQXfeO+A6KBiCpcCgYEAmbRmrDuBhsRsli2c+P/X
bradk667RXS9JUuYPdnTtMXWhQtg4SV4NUnknyuwq75JeLs+mR50PJA91dUz+tKF
lG81OCWrh2mGYheUVoTH7m8lxDzeuu1VQnrNmI1FLEFouBgtHCozyR7M9c8tS3Da
snGWztVwD0Wi/qfYx7eEtosCgYApHUA6liqUQ0UeHcxJrGUviuF1Q6NF6L5/bLzn
CpqK07SQKkuuv1RSevJwf6arPsCuWlM2luzzDg9weADNQl1p5xVQpcwy86oXwkCi
uPPnemzk+BVex+xKBA4ovNEtKXBIt2C0td3TDKQJTxZdIAYPXSP92Je1OW6ltusC
dQSm7QKBgEQs8OvuKGESk+TvpUBCcfpwCWpkmhhXQV54miRRhhz0Vc+DeWQsjOGl
xBIooPUI5DU70PhIsbV9g2lfoIa2BiXove6F5Rq6B+I75CIvJpqlxa56ikLVnAZE
tqWT5XeC/bs6BszNyL+5tLUNCL3AhVHNfyBR6Ik60kBG6v1hQvnb
-----END RSA PRIVATE KEY-----

View File

@ -102,6 +102,7 @@ func main() {
api.POST("/articles",controller.GetArticles) // 获取所有文章 api.POST("/articles",controller.GetArticles) // 获取所有文章
api.PUT("/article",controller.AddArticle) // 添加文章 api.PUT("/article",controller.AddArticle) // 添加文章
api.GET("article_type",controller.ArticlesType) //获取所有文章分类 api.GET("article_type",controller.ArticlesType) //获取所有文章分类
api.PUT("article_type",controller.AddArticleType)
api.POST("/article_update",controller.UpdateArtilce) //更新文章 api.POST("/article_update",controller.UpdateArtilce) //更新文章
api.GET("/articleCount",controller.GetArticleCount) //获取所有文章个数 api.GET("/articleCount",controller.GetArticleCount) //获取所有文章个数
api.DELETE("/article/:id",controller.DeleteArticle) ////删除文章 api.DELETE("/article/:id",controller.DeleteArticle) ////删除文章

View File

@ -70,3 +70,13 @@ func DeleteDoc(id int64) error{
} }
return nil return nil
} }
func AddArticleType(t ArticleType) error{
sql := fmt.Sprintf("insert into doc_type(id,type_name) values ('%d','%s')",t.Id,t.Name)
_, e := db.GetMysqlClient().Query(sql)
if nil != e {
logs.Error(e.Error())
return e
}
return nil
}

14
test_deploy.bat Normal file
View File

@ -0,0 +1,14 @@
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build ./
ssh -t -i ./id_rsa_local c@192.168.0.101 'rm /home/c/api/bin/userapi'
scp -i ./id_rsa_local background c@192.168.0.101:/home/c/api/bin/userapi
scp -i ./id_rsa_local user.yaml c@192.168.0.101:/home/c/api/bin/user.yaml
scp -i ./id_rsa_local pem/ca.pem c@192.168.0.101:/home/c/api/bin/pem/ca.pem
scp -i ./id_rsa_local pem/client-cert.pem c@192.168.0.101:/home/c/api/bin/pem/client-cert.pem
scp -i ./id_rsa_local pem/client-key.pem c@192.168.0.101: /home/c/api/bin/pem/client-key.pem