🐛 fixed comment reply list bug

This commit is contained in:
2024-11-27 18:57:16 +08:00
parent 3696827879
commit 0879c9d257
5 changed files with 10 additions and 11 deletions

8
.idea/GOHCache.xml generated
View File

@@ -1751,7 +1751,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/middleware/casbinverify_middleware.go"> <entry key="file://$PROJECT_DIR$/app/core/api/internal/middleware/casbinverify_middleware.go">
<value> <value>
<ScannedPath> <ScannedPath>
<option name="lastModified" value="1731933523737" /> <option name="lastModified" value="1732502377314" />
<option name="schema"> <option name="schema">
<list> <list>
<option value="CasbinVerifyMiddleware" /> <option value="CasbinVerifyMiddleware" />
@@ -1775,7 +1775,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/internal/svc/service_context.go"> <entry key="file://$PROJECT_DIR$/app/core/api/internal/svc/service_context.go">
<value> <value>
<ScannedPath> <ScannedPath>
<option name="lastModified" value="1732275098629" /> <option name="lastModified" value="1732502377305" />
<option name="schema"> <option name="schema">
<list> <list>
<option value="ServiceContext" /> <option value="ServiceContext" />
@@ -1878,7 +1878,7 @@
<entry key="file://$PROJECT_DIR$/app/core/api/repository/casbinx/casbin.go"> <entry key="file://$PROJECT_DIR$/app/core/api/repository/casbinx/casbin.go">
<value> <value>
<ScannedPath> <ScannedPath>
<option name="lastModified" value="1732159281356" /> <option name="lastModified" value="1732502718747" />
</ScannedPath> </ScannedPath>
</value> </value>
</entry> </entry>
@@ -2477,6 +2477,6 @@
<entry key="wechat_callback_logic" value="WechatCallbackLogic" /> <entry key="wechat_callback_logic" value="WechatCallbackLogic" />
</map> </map>
</option> </option>
<option name="lastTimeChecked" value="1732450867228" /> <option name="lastTimeChecked" value="1732555132343" />
</component> </component>
</project> </project>

View File

@@ -66,7 +66,7 @@ func (l *GetReplyListLogic) GetReplyList(req *types.ReplyListRequest) (resp *typ
replyUser.Nickname.As("reply_nickname"), replyUser.Nickname.As("reply_nickname"),
).LeftJoin(commentUser, reply.UserID.EqCol(commentUser.UID)). ).LeftJoin(commentUser, reply.UserID.EqCol(commentUser.UID)).
LeftJoin(replyUser, reply.ReplyUser.EqCol(replyUser.UID)). LeftJoin(replyUser, reply.ReplyUser.EqCol(replyUser.UID)).
Where(reply.TopicID.Eq(req.TopicId), reply.CommentType.Eq(constant.REPLY)). Where(reply.TopicID.Eq(req.TopicId), reply.ReplyID.Eq(req.CommentId), reply.CommentType.Eq(constant.REPLY)).
Order(reply.Likes.Desc(), reply.CreatedAt.Desc()). Order(reply.Likes.Desc(), reply.CreatedAt.Desc()).
ScanByPage(&replyQueryList, (req.Page-1)*req.Size, req.Size) ScanByPage(&replyQueryList, (req.Page-1)*req.Size, req.Size)
if err != nil { if err != nil {

View File

@@ -10,11 +10,11 @@ import (
) )
type CasbinVerifyMiddleware struct { type CasbinVerifyMiddleware struct {
casbin *casbin.CachedEnforcer casbin *casbin.SyncedCachedEnforcer
session *redisstore.RedisStore session *redisstore.RedisStore
} }
func NewCasbinVerifyMiddleware(casbin *casbin.CachedEnforcer, session *redisstore.RedisStore) *CasbinVerifyMiddleware { func NewCasbinVerifyMiddleware(casbin *casbin.SyncedCachedEnforcer, session *redisstore.RedisStore) *CasbinVerifyMiddleware {
return &CasbinVerifyMiddleware{ return &CasbinVerifyMiddleware{
casbin: casbin, casbin: casbin,
session: session, session: session,

View File

@@ -35,7 +35,7 @@ type ServiceContext struct {
MongoClient *mongo.Database MongoClient *mongo.Database
Session *redisstore.RedisStore Session *redisstore.RedisStore
Ip2Region *xdb.Searcher Ip2Region *xdb.Searcher
CasbinEnforcer *casbin.CachedEnforcer CasbinEnforcer *casbin.SyncedCachedEnforcer
WechatPublic *officialAccount.OfficialAccount WechatPublic *officialAccount.OfficialAccount
Sensitive *sensitive.Manager Sensitive *sensitive.Manager
RotateCaptcha rotate.Captcha RotateCaptcha rotate.Captcha

View File

@@ -11,7 +11,7 @@ import (
) )
// NewCasbin creates a new casbinx enforcer with a mysql adapter and loads the policy from the file system. // NewCasbin creates a new casbinx enforcer with a mysql adapter and loads the policy from the file system.
func NewCasbin(engine *gorm.DB) *casbin.CachedEnforcer { func NewCasbin(engine *gorm.DB) *casbin.SyncedCachedEnforcer {
a, err := gormadapter.NewAdapterByDBUseTableName(engine, "sca_auth_", "permission_rule") a, err := gormadapter.NewAdapterByDBUseTableName(engine, "sca_auth_", "permission_rule")
if err != nil { if err != nil {
panic(err) panic(err)
@@ -25,12 +25,11 @@ func NewCasbin(engine *gorm.DB) *casbin.CachedEnforcer {
if err != nil { if err != nil {
panic(err) panic(err)
} }
e, err := casbin.NewCachedEnforcer(modelFile, a) e, err := casbin.NewSyncedCachedEnforcer(modelFile, a)
if err != nil { if err != nil {
panic(err) panic(err)
} }
e.EnableCache(true) e.EnableCache(true)
e.SetExpireTime(60 * 60)
err = e.LoadPolicy() err = e.LoadPolicy()
if err != nil { if err != nil {
panic(err) panic(err)