sqlx: add miss method for following

r/paopao-ce-plus
Michael Li 2 years ago
parent 4f1b995412
commit 56b8463707
No known key found for this signature in database

@ -0,0 +1,59 @@
// Copyright 2023 ROC. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package sakila
import (
"github.com/jmoiron/sqlx"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
)
var (
_ core.FollowingManageService = (*followingManageSrv)(nil)
)
type followingManageSrv struct {
*sqlxSrv
q *cc.FollowingManager
}
func (s *followingManageSrv) FollowUser(userId int64, followId int64) error {
// TODO
return cs.ErrNotImplemented
}
func (s *followingManageSrv) UnfollowUser(userId int64, followId int64) error {
// TDOO
return cs.ErrNotImplemented
}
func (s *followingManageSrv) ListFollows(userId int64, limit, offset int) (*ms.ContactList, error) {
// TODO
return nil, cs.ErrNotImplemented
}
func (s *followingManageSrv) ListFollowings(userId int64, limit, offset int) (*ms.ContactList, error) {
// TODO
return nil, cs.ErrNotImplemented
}
func (s *followingManageSrv) GetFollowCount(userId int64) (int64, int64, error) {
// TODO
return 0, 0, cs.ErrNotImplemented
}
func (s *followingManageSrv) IsFollow(userId int64, followId int64) bool {
// TODO
return false
}
func newFollowingManageService(db *sqlx.DB) core.FollowingManageService {
return &followingManageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildFollowingManager),
}
}

@ -38,6 +38,7 @@ type dataSrv struct {
core.CommentManageService core.CommentManageService
core.UserManageService core.UserManageService
core.ContactManageService core.ContactManageService
core.FollowingManageService
core.SecurityService core.SecurityService
core.AttachmentCheckService core.AttachmentCheckService
} }
@ -105,6 +106,7 @@ func NewDataService() (core.DataService, core.VersionInfo) {
CommentManageService: newCommentManageService(_db), CommentManageService: newCommentManageService(_db),
UserManageService: newUserManageService(_db), UserManageService: newUserManageService(_db),
ContactManageService: newContactManageService(_db), ContactManageService: newContactManageService(_db),
FollowingManageService: newFollowingManageService(_db),
SecurityService: newSecurityService(_db, pvs), SecurityService: newSecurityService(_db, pvs),
AttachmentCheckService: security.NewAttachmentCheckService(), AttachmentCheckService: security.NewAttachmentCheckService(),
} }

@ -52,6 +52,7 @@ const (
_ContactManager_TotalFriendsById = `SELECT count(*) FROM @contact WHERE user_id=? AND status=2 AND is_del=0` _ContactManager_TotalFriendsById = `SELECT count(*) FROM @contact WHERE user_id=? AND status=2 AND is_del=0`
_FollowIndexA_UserInfo = `SELECT * FROM @user WHERE username=?` _FollowIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_FollowIndex_UserInfo = `SELECT * FROM @user WHERE username=?` _FollowIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_FollowingManager_CreateFollowing = `INSERT INTO @following (user_id, follow_id, created_on) VALUES (?, ?, ?)`
_FriendIndexA_UserInfo = `SELECT * FROM @user WHERE username=?` _FriendIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_FriendIndex_UserInfo = `SELECT * FROM @user WHERE username=?` _FriendIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_LightIndexA_UserInfo = `SELECT * FROM @user WHERE username=?` _LightIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
@ -214,6 +215,11 @@ type FollowIndexA struct {
UserInfo *sqlx.Stmt `yesql:"user_info"` UserInfo *sqlx.Stmt `yesql:"user_info"`
} }
type FollowingManager struct {
yesql.Namespace `yesql:"following_manager"`
CreateFollowing *sqlx.Stmt `yesql:"create_following"`
}
type FriendIndex struct { type FriendIndex struct {
yesql.Namespace `yesql:"friend_index"` yesql.Namespace `yesql:"friend_index"`
UserInfo *sqlx.Stmt `yesql:"user_info"` UserInfo *sqlx.Stmt `yesql:"user_info"`
@ -564,6 +570,20 @@ func BuildFollowIndexA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Fo
return return
} }
func BuildFollowingManager(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FollowingManager, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &FollowingManager{}
if obj.CreateFollowing, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FollowingManager_CreateFollowing))); err != nil {
return
}
return
}
func BuildFriendIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FriendIndex, err error) { func BuildFriendIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FriendIndex, err error) {
var c context.Context var c context.Context
if len(ctx) > 0 && ctx[0] != nil { if len(ctx) > 0 && ctx[0] != nil {

@ -141,6 +141,14 @@ UPDATE @comment_reply
SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? SET thumbs_up_count=?, thumbs_down_count=?, modified_on=?
WHERE id=? AND is_del=0; WHERE id=? AND is_del=0;
--------------------------------------------------------------------------------
-- following_manager sql dml
--------------------------------------------------------------------------------
-- name: create_following@following_manager
-- prepare: stmt
INSERT INTO @following (user_id, follow_id, created_on) VALUES (?, ?, ?);
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- contact_manager sql dml -- contact_manager sql dml
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

Loading…
Cancel
Save