-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: MVP1 development tasks. #54
Conversation
I will rebase commits later. |
// Get User Info | ||
var userClaim *casdoorsdk.Claims | ||
token, err := ctx.Request.Cookie("token") | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there no reverse judgment? like
if err != nil {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will update it.
cmd/gopcomm/community_yap.gox
Outdated
"ID": id, | ||
"Title": article.Title, | ||
"Content": article.Content, | ||
"Content": article.HtmlUrl, | ||
"Tags": article.Tags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gop format
cmd/gopcomm/community_yap.gox
Outdated
|
||
get "/getArticle/:id", ctx => { | ||
id := ctx.param("id") | ||
article, _ := community.article(todo, id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Baihhh will fix it.
// Get User Info | ||
var userClaim *casdoorsdk.Claims | ||
token, err := ctx.Request.Cookie("token") | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle err != nil
scenario
cmd/gopcomm/community_yap.gox
Outdated
} | ||
} | ||
|
||
get "/getArticle/:id", ctx => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's duplicate with get /p/:id
? Also, it's better to use unified style for router,
var htmlId string | ||
sqlStr := "select id,title,user_id,cover,tags,content,html_id,ctime,mtime from article where id=?" | ||
err = p.db.QueryRow(sqlStr, id).Scan(&article.ID, &article.Title, &article.UId, &article.Cover, &article.Tags, &article.Content, &htmlId, &article.Ctime, &article.Mtime) | ||
if err == sql.ErrNoRows { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when err == nil, current logic still need two check operations which seems wasteful.
suggest:
if err != nil {
if err == ErrNotExist {
return article, ErrNotExist
}
log.Error("unexpected err", err)
return article, err
}
internal/core/community.go
Outdated
} else if err != nil { | ||
return article, err | ||
} | ||
// add author info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend to remove useless code
var htmlId string | ||
sqlStr := "select trans_html_id from article where id=?" | ||
err = p.db.QueryRow(sqlStr, id).Scan(&htmlId) | ||
if err == sql.ErrNoRows { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with above.
cmd/gopcomm/gop_autogen.go
Outdated
} | ||
//line cmd/gopcomm/community_yap.gox:11 | ||
//line cmd/gopcomm/community_yap.gox:23 | ||
func (this *community) MainEntry() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] receiver name should be a reflection of its identity; don't use generic names such as "this" or "self" (ST1006)
} | ||
|
||
type Account struct { | ||
casdoorConfig *CasdoorConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] field casdoorConfig is unused (U1000)
internal/core/community.go
Outdated
type Account struct { | ||
casdoorConfig *CasdoorConfig | ||
|
||
zlog *zap.SugaredLogger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] field zlog is unused (U1000)
internal/core/community.go
Outdated
func (p *Community) PutArticle(ctx context.Context, uid string, article *Article) (id string, err error) { | ||
// SaveHtml upload origin html(string) to media for html id and save id to database | ||
func (p *Community) SaveHtml(ctx context.Context, uid, htmlStr, mdData, id string) (articleId string, err error) { | ||
htmlId, err := p.SaveMedia(ctx, uid, []byte(htmlStr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] this value of err is never used (SA4006)
internal/core/community.go
Outdated
if err != nil { | ||
return "", err | ||
} | ||
articleId, err := res.LastInsertId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] this value of err is never used (SA4006)
internal/core/community.go
Outdated
if err != nil { | ||
return "", err | ||
} | ||
idInt, err := res.LastInsertId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] this value of err is never used (SA4006)
internal/core/community.go
Outdated
var htmlIds []string | ||
sqlStr := "select html_id from article where user_id=?" | ||
rows, err := p.db.Query(sqlStr, uid) | ||
defer rows.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] should check returned error before deferring rows.Close() (SA5001)
internal/core/media.go
Outdated
|
||
bucket := c.bucket | ||
r, err := bucket.NewReader(context.Background(), fileKey, nil) | ||
defer r.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] should check returned error before deferring r.Close() (SA5001)
translation/video_test.go
Outdated
mockAccessKey = os.Getenv("QINIU_ACCESS_KEY") | ||
mockSecretKey = os.Getenv("QINIU_SECRET_KEY") | ||
mockBucket = os.Getenv("QINIU_TEST_BUCKET") | ||
mockPipeline = os.Getenv("QINIU_TEST_PIPELINE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[staticcheck] var mockPipeline is unused (U1000)
Fix: use gop to build the project
BugFix: Fix the bug that using the branch name as the docker name
add Docs/share protocol
docs: update web module
docs: Update arch and translation.
[REBASE SUGGESTION] Hi @IRONICBo, your PR has commit messages like:
Which seems insignificant, recommend to use If you have any questions about this comment, feel free to raise an issue here: |
This PR have already moved to |
MVP1 Task: #38