Skip to content

Commit

Permalink
Merge pull request #147 from Baihhh/bugFix
Browse files Browse the repository at this point in the history
fix: add article
  • Loading branch information
IRONICBo authored Feb 19, 2024
2 parents 3c9069a + d57dfae commit c3804aa
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 121 deletions.
186 changes: 93 additions & 93 deletions cmd/gopcomm/gop_autogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,237 +204,237 @@ func (this *community) MainEntry() {
//line cmd/gopcomm/community_yap.gox:167:1
err = this.community.DeleteArticle(todo, uid, id)
//line cmd/gopcomm/community_yap.gox:168:1
xLog.Info("err", err)
//line cmd/gopcomm/community_yap.gox:169:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:170:1
//line cmd/gopcomm/community_yap.gox:169:1
ctx.Json__1(map[string]interface {
}{"code": 0, "err": "delete failed"})
} else {
//line cmd/gopcomm/community_yap.gox:175:1
//line cmd/gopcomm/community_yap.gox:174:1
ctx.Json__1(map[string]interface {
}{"code": 200, "msg": "delete success"})
}
})
//line cmd/gopcomm/community_yap.gox:182:1
//line cmd/gopcomm/community_yap.gox:181:1
this.Get("/medias", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:183:1
//line cmd/gopcomm/community_yap.gox:182:1
format := ctx.Param("format")
//line cmd/gopcomm/community_yap.gox:184:1
//line cmd/gopcomm/community_yap.gox:183:1
uid := ctx.Param("uid")
//line cmd/gopcomm/community_yap.gox:185:1
//line cmd/gopcomm/community_yap.gox:184:1
files, err := this.community.ListMediaByUserId(todo, uid, format)
//line cmd/gopcomm/community_yap.gox:186:1
//line cmd/gopcomm/community_yap.gox:185:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:187:1
//line cmd/gopcomm/community_yap.gox:186:1
ctx.Json__1(map[string]interface {
}{"code": 0, "err": "get media failed"})
} else {
//line cmd/gopcomm/community_yap.gox:192:1
//line cmd/gopcomm/community_yap.gox:191:1
ctx.Json__1(map[string]interface {
}{"code": 200, "items": files})
}
})
//line cmd/gopcomm/community_yap.gox:199:1
//line cmd/gopcomm/community_yap.gox:198:1
this.Get("/delMedia", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:200:1
//line cmd/gopcomm/community_yap.gox:199:1
id := ctx.Param("id")
//line cmd/gopcomm/community_yap.gox:201:1
//line cmd/gopcomm/community_yap.gox:200:1
token, err := core.GetToken(ctx)
//line cmd/gopcomm/community_yap.gox:202:1
//line cmd/gopcomm/community_yap.gox:201:1
uid, err := this.community.ParseJwtToken(token.Value)
//line cmd/gopcomm/community_yap.gox:203:1
//line cmd/gopcomm/community_yap.gox:202:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:204:1
//line cmd/gopcomm/community_yap.gox:203:1
xLog.Error("token parse error")
//line cmd/gopcomm/community_yap.gox:205:1
//line cmd/gopcomm/community_yap.gox:204:1
ctx.Json__1(map[string]interface {
}{"code": 0, "err": err.Error()})
}
//line cmd/gopcomm/community_yap.gox:210:1
//line cmd/gopcomm/community_yap.gox:209:1
err = this.community.DelMedia(todo, uid, id)
//line cmd/gopcomm/community_yap.gox:211:1
//line cmd/gopcomm/community_yap.gox:210:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:212:1
//line cmd/gopcomm/community_yap.gox:211:1
ctx.Json__1(map[string]interface {
}{"code": 0, "err": "delete failed"})
} else {
//line cmd/gopcomm/community_yap.gox:217:1
//line cmd/gopcomm/community_yap.gox:216:1
ctx.Json__1(map[string]interface {
}{"code": 200, "msg": "delete success"})
}
})
//line cmd/gopcomm/community_yap.gox:224:1
//line cmd/gopcomm/community_yap.gox:223:1
this.Get("/", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:226:1
//line cmd/gopcomm/community_yap.gox:225:1
// Get User Info
var user *core.User
//line cmd/gopcomm/community_yap.gox:227:1
//line cmd/gopcomm/community_yap.gox:226:1
userId := ""
//line cmd/gopcomm/community_yap.gox:228:1
//line cmd/gopcomm/community_yap.gox:227:1
token, err := core.GetToken(ctx)
//line cmd/gopcomm/community_yap.gox:229:1
//line cmd/gopcomm/community_yap.gox:228:1
if err == nil {
//line cmd/gopcomm/community_yap.gox:230:1
//line cmd/gopcomm/community_yap.gox:229:1
user, err = this.community.GetUser(token.Value)
//line cmd/gopcomm/community_yap.gox:231:1
//line cmd/gopcomm/community_yap.gox:230:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:232:1
//line cmd/gopcomm/community_yap.gox:231:1
xLog.Error("get user error:", err)
} else {
//line cmd/gopcomm/community_yap.gox:234:1
//line cmd/gopcomm/community_yap.gox:233:1
userId = user.Id
}
}
//line cmd/gopcomm/community_yap.gox:238:1
//line cmd/gopcomm/community_yap.gox:237:1
articles, next, _ := this.community.ListArticle(todo, core.MarkBegin, limitConst, "")
//line cmd/gopcomm/community_yap.gox:239:1
//line cmd/gopcomm/community_yap.gox:238:1
articlesJson, _ := json.Marshal(&articles)
//line cmd/gopcomm/community_yap.gox:240:1
//line cmd/gopcomm/community_yap.gox:239:1
ctx.Yap__1("home", map[string]interface {
}{"UserId": userId, "User": user, "Items": strings.Replace(string(articlesJson), `\"`, `"`, -1), "Next": next})
})
//line cmd/gopcomm/community_yap.gox:248:1
//line cmd/gopcomm/community_yap.gox:247:1
this.Get("/get", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:249:1
//line cmd/gopcomm/community_yap.gox:248:1
from := ctx.Param("from")
//line cmd/gopcomm/community_yap.gox:250:1
//line cmd/gopcomm/community_yap.gox:249:1
limit := ctx.Param("limit")
//line cmd/gopcomm/community_yap.gox:251:1
//line cmd/gopcomm/community_yap.gox:250:1
searchValue := ctx.Param("value")
//line cmd/gopcomm/community_yap.gox:253:1
//line cmd/gopcomm/community_yap.gox:252:1
limitInt, err := strconv.Atoi(limit)
//line cmd/gopcomm/community_yap.gox:254:1
//line cmd/gopcomm/community_yap.gox:253:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:255:1
//line cmd/gopcomm/community_yap.gox:254:1
limitInt = limitConst
}
//line cmd/gopcomm/community_yap.gox:258:1
//line cmd/gopcomm/community_yap.gox:257:1
articles, next, _ := this.community.ListArticle(todo, from, limitInt, searchValue)
//line cmd/gopcomm/community_yap.gox:259:1
//line cmd/gopcomm/community_yap.gox:258:1
ctx.Json__1(map[string]interface {
}{"code": 200, "items": articles, "next": next, "value": searchValue})
})
//line cmd/gopcomm/community_yap.gox:267:1
//line cmd/gopcomm/community_yap.gox:266:1
this.Get("/search", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:268:1
//line cmd/gopcomm/community_yap.gox:267:1
searchValue := ctx.Param("value")
//line cmd/gopcomm/community_yap.gox:277:1
//line cmd/gopcomm/community_yap.gox:276:1
// todo middleware
var user *core.User
//line cmd/gopcomm/community_yap.gox:278:1
//line cmd/gopcomm/community_yap.gox:277:1
userId := ""
//line cmd/gopcomm/community_yap.gox:279:1
//line cmd/gopcomm/community_yap.gox:278:1
token, err := core.GetToken(ctx)
//line cmd/gopcomm/community_yap.gox:280:1
//line cmd/gopcomm/community_yap.gox:279:1
if err == nil {
//line cmd/gopcomm/community_yap.gox:281:1
//line cmd/gopcomm/community_yap.gox:280:1
user, err = this.community.GetUser(token.Value)
//line cmd/gopcomm/community_yap.gox:282:1
//line cmd/gopcomm/community_yap.gox:281:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:283:1
//line cmd/gopcomm/community_yap.gox:282:1
xLog.Error("get user error:", err)
} else {
//line cmd/gopcomm/community_yap.gox:285:1
//line cmd/gopcomm/community_yap.gox:284:1
userId = user.Id
}
}
//line cmd/gopcomm/community_yap.gox:289:1
//line cmd/gopcomm/community_yap.gox:288:1
articles, next, _ := this.community.ListArticle(todo, core.MarkBegin, limitConst, searchValue)
//line cmd/gopcomm/community_yap.gox:290:1
//line cmd/gopcomm/community_yap.gox:289:1
articlesJson, _ := json.Marshal(&articles)
//line cmd/gopcomm/community_yap.gox:291:1
//line cmd/gopcomm/community_yap.gox:290:1
ctx.Yap__1("home", map[string]interface {
}{"UserId": userId, "User": user, "Items": strings.Replace(string(articlesJson), `\"`, `"`, -1), "Value": searchValue, "Next": next})
})
//line cmd/gopcomm/community_yap.gox:300:1
//line cmd/gopcomm/community_yap.gox:299:1
this.Get("/edit/:id", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:301:1
//line cmd/gopcomm/community_yap.gox:300:1
var user *core.User
//line cmd/gopcomm/community_yap.gox:302:1
//line cmd/gopcomm/community_yap.gox:301:1
token, err := core.GetToken(ctx)
//line cmd/gopcomm/community_yap.gox:303:1
//line cmd/gopcomm/community_yap.gox:302:1
if err == nil {
//line cmd/gopcomm/community_yap.gox:304:1
//line cmd/gopcomm/community_yap.gox:303:1
user, err = this.community.GetUser(token.Value)
//line cmd/gopcomm/community_yap.gox:305:1
//line cmd/gopcomm/community_yap.gox:304:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:306:1
//line cmd/gopcomm/community_yap.gox:305:1
xLog.Error("get user error:", err)
}
}
//line cmd/gopcomm/community_yap.gox:310:1
//line cmd/gopcomm/community_yap.gox:309:1
uid := user.Id
//line cmd/gopcomm/community_yap.gox:311:1
//line cmd/gopcomm/community_yap.gox:310:1
id := ctx.Param("id")
//line cmd/gopcomm/community_yap.gox:312:1
//line cmd/gopcomm/community_yap.gox:311:1
if id != "" {
//line cmd/gopcomm/community_yap.gox:313:1
//line cmd/gopcomm/community_yap.gox:312:1
if
//line cmd/gopcomm/community_yap.gox:313:1
//line cmd/gopcomm/community_yap.gox:312:1
editable, _ := this.community.CanEditable(todo, uid, id); !editable {
//line cmd/gopcomm/community_yap.gox:314:1
//line cmd/gopcomm/community_yap.gox:313:1
xLog.Error("no permissions")
//line cmd/gopcomm/community_yap.gox:315:1
//line cmd/gopcomm/community_yap.gox:314:1
http.Redirect(ctx.ResponseWriter, ctx.Request, "/error", http.StatusTemporaryRedirect)
}
//line cmd/gopcomm/community_yap.gox:317:1
//line cmd/gopcomm/community_yap.gox:316:1
article, _ := this.community.Article(todo, id)
//line cmd/gopcomm/community_yap.gox:318:1
//line cmd/gopcomm/community_yap.gox:317:1
articleJson, _ := json.Marshal(&article)
//line cmd/gopcomm/community_yap.gox:319:1
//line cmd/gopcomm/community_yap.gox:318:1
ctx.Yap__1("edit", map[string]interface {
}{"User": user, "Article": strings.Replace(string(articleJson), `\"`, `"`, -1)})
}
})
//line cmd/gopcomm/community_yap.gox:326:1
//line cmd/gopcomm/community_yap.gox:325:1
this.Get("/getTrans", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:327:1
//line cmd/gopcomm/community_yap.gox:326:1
id := ctx.Param("id")
//line cmd/gopcomm/community_yap.gox:328:1
//line cmd/gopcomm/community_yap.gox:327:1
htmlUrl, err := this.community.TransHtmlUrl(todo, id)
//line cmd/gopcomm/community_yap.gox:329:1
//line cmd/gopcomm/community_yap.gox:328:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:330:1
//line cmd/gopcomm/community_yap.gox:329:1
ctx.Json__1(map[string]interface {
}{"code": 500, "err": err.Error()})
}
//line cmd/gopcomm/community_yap.gox:335:1
//line cmd/gopcomm/community_yap.gox:334:1
ctx.Json__1(map[string]interface {
}{"code": 200, "data": htmlUrl})
})
//line cmd/gopcomm/community_yap.gox:342:1
//line cmd/gopcomm/community_yap.gox:341:1
this.Post("/commit", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:345:1
//line cmd/gopcomm/community_yap.gox:344:1
id := ctx.Param("id")
//line cmd/gopcomm/community_yap.gox:346:1
//line cmd/gopcomm/community_yap.gox:345:1
mdData := ctx.Param("content")
//line cmd/gopcomm/community_yap.gox:347:1
//line cmd/gopcomm/community_yap.gox:346:1
transData := ctx.Param("trans_data")
//line cmd/gopcomm/community_yap.gox:349:1
//line cmd/gopcomm/community_yap.gox:348:1
token, err := core.GetToken(ctx)
//line cmd/gopcomm/community_yap.gox:350:1
//line cmd/gopcomm/community_yap.gox:349:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:351:1
//line cmd/gopcomm/community_yap.gox:350:1
xLog.Info("token", err)
//line cmd/gopcomm/community_yap.gox:352:1
//line cmd/gopcomm/community_yap.gox:351:1
ctx.Json__1(map[string]interface {
}{"code": 0, "err": "no token"})
}
//line cmd/gopcomm/community_yap.gox:357:1
//line cmd/gopcomm/community_yap.gox:356:1
uid, err := this.community.ParseJwtToken(token.Value)
//line cmd/gopcomm/community_yap.gox:358:1
//line cmd/gopcomm/community_yap.gox:357:1
if err != nil {
//line cmd/gopcomm/community_yap.gox:359:1
//line cmd/gopcomm/community_yap.gox:358:1
xLog.Info("uid", err)
//line cmd/gopcomm/community_yap.gox:360:1
//line cmd/gopcomm/community_yap.gox:359:1
ctx.Json__1(map[string]interface {
}{"code": 0, "err": err.Error()})
}
//line cmd/gopcomm/community_yap.gox:366:1
//line cmd/gopcomm/community_yap.gox:365:1
article := &core.Article{ArticleEntry: core.ArticleEntry{ID: id, Title: ctx.Param("title"), UId: uid, Cover: ctx.Param("cover"), Tags: ctx.Param("tags"), Abstract: ctx.Param("abstract")}, Content: mdData, TransContent: transData}
//line cmd/gopcomm/community_yap.gox:377:1
id, err = this.community.PutArticle(todo, uid, article)
//line cmd/gopcomm/community_yap.gox:378:1
id, _ = this.community.PutArticle(todo, uid, article)
xLog.Info("err", err)
//line cmd/gopcomm/community_yap.gox:379:1
ctx.Json__1(map[string]interface {
}{"code": 200, "data": id})
Expand Down
Loading

0 comments on commit c3804aa

Please sign in to comment.