🎨 add gorm cache & update model structure
This commit is contained in:
@@ -59,13 +59,9 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
|
||||
browser, _ := ua.Browser()
|
||||
operatingSystem := ua.OS()
|
||||
var isAuthor int64 = 0
|
||||
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
uid, ok := session.Values["uid"].(string)
|
||||
uid, ok := l.ctx.Value("user_id").(string)
|
||||
if !ok {
|
||||
return nil, errors.New("uid not found in session")
|
||||
return nil, errors.New("user_id not found in context")
|
||||
}
|
||||
if uid == req.Author {
|
||||
isAuthor = 1
|
||||
|
@@ -57,14 +57,9 @@ func (l *SubmitReplyCommentLogic) SubmitReplyComment(r *http.Request, req *types
|
||||
|
||||
browser, _ := ua.Browser()
|
||||
operatingSystem := ua.OS()
|
||||
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uid, ok := session.Values["uid"].(string)
|
||||
uid, ok := l.ctx.Value("user_id").(string)
|
||||
if !ok {
|
||||
return nil, errors.New("uid not found in session")
|
||||
return nil, errors.New("user_id not found in context")
|
||||
}
|
||||
var isAuthor int64 = 0
|
||||
if uid == req.Author {
|
||||
|
@@ -64,14 +64,9 @@ func (l *SubmitReplyReplyLogic) SubmitReplyReply(r *http.Request, req *types.Rep
|
||||
browser, _ := ua.Browser()
|
||||
operatingSystem := ua.OS()
|
||||
|
||||
// 获取用户会话信息
|
||||
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
uid, ok := session.Values["uid"].(string)
|
||||
uid, ok := l.ctx.Value("user_id").(string)
|
||||
if !ok {
|
||||
return nil, errors.New("uid not found in session")
|
||||
return nil, errors.New("user_id not found in context")
|
||||
}
|
||||
|
||||
// 判断作者身份
|
||||
|
Reference in New Issue
Block a user