123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- package dao
- import (
- "context"
- xsql "database/sql"
- notice "go-common/app/service/bbq/notice-service/api/v1"
- "go-common/app/service/bbq/user/api"
- "go-common/app/service/bbq/user/internal/model"
- acc "go-common/app/service/main/account/api"
- "go-common/library/database/sql"
- "go-common/library/time"
- "reflect"
- "github.com/bouk/monkey"
- )
- // MockUserBase .
- func (d *Dao) MockUserBase(res map[int64]*api.UserBase, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UserBase", func(_ *Dao, _ context.Context, _ []int64) (map[int64]*api.UserBase, error) {
- return res, err
- })
- }
- // MockPing .
- func (d *Dao) MockPing(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "Ping", func(_ *Dao, _ context.Context) error {
- return err
- })
- }
- // MockBeginTran .
- func (d *Dao) MockBeginTran(p1 *xsql.Tx, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "BeginTran", func(_ *Dao, _ context.Context) (*xsql.Tx, error) {
- return p1, err
- })
- }
- // MockCreateNotice .
- func (d *Dao) MockCreateNotice(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CreateNotice", func(_ *Dao, _ context.Context, _ *notice.NoticeBase) error {
- return err
- })
- }
- // MockFilter .
- func (d *Dao) MockFilter(level int32, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "Filter", func(_ *Dao, _ context.Context, _ string, _ string) (int32, error) {
- return level, err
- })
- }
- // MockForbidUser .
- func (d *Dao) MockForbidUser(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "ForbidUser", func(_ *Dao, _ context.Context, _ uint64, _ uint64) error {
- return err
- })
- }
- // MockReleaseUser .
- func (d *Dao) MockReleaseUser(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "ReleaseUser", func(_ *Dao, _ context.Context, _ uint64) error {
- return err
- })
- }
- // MockGetLocation .
- func (d *Dao) MockGetLocation(p1 *api.LocationItem, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetLocation", func(_ *Dao, _ context.Context, _ int32) (*api.LocationItem, error) {
- return p1, err
- })
- }
- // MockGetUserBProfile .
- func (d *Dao) MockGetUserBProfile(res *acc.ProfileReply, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetUserBProfile", func(_ *Dao, _ context.Context, _ *api.PhoneCheckReq) (*acc.ProfileReply, error) {
- return res, err
- })
- }
- // MockRawUserBase .
- func (d *Dao) MockRawUserBase(res map[int64]*api.UserBase, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "RawUserBase", func(_ *Dao, _ context.Context, _ []int64) (map[int64]*api.UserBase, error) {
- return res, err
- })
- }
- // MockCacheUserBase .
- func (d *Dao) MockCacheUserBase(res map[int64]*api.UserBase, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CacheUserBase", func(_ *Dao, _ context.Context, _ []int64) (map[int64]*api.UserBase, error) {
- return res, err
- })
- }
- // MockAddCacheUserBase .
- func (d *Dao) MockAddCacheUserBase(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "AddCacheUserBase", func(_ *Dao, _ context.Context, _ map[int64]*api.UserBase) error {
- return err
- })
- }
- // MockUpdateUserField .
- func (d *Dao) MockUpdateUserField(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UpdateUserField", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ string, _ interface{}) (int64, error) {
- return num, err
- })
- }
- // MockAddUserBase .
- func (d *Dao) MockAddUserBase(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "AddUserBase", func(_ *Dao, _ context.Context, _ *api.UserBase) (int64, error) {
- return num, err
- })
- }
- // MockUpdateUserBaseUname .
- func (d *Dao) MockUpdateUserBaseUname(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UpdateUserBaseUname", func(_ *Dao, _ context.Context, _ int64, _ string) (int64, error) {
- return num, err
- })
- }
- // MockUpdateUserBase .
- func (d *Dao) MockUpdateUserBase(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UpdateUserBase", func(_ *Dao, _ context.Context, _ int64, _ *api.UserBase) (int64, error) {
- return num, err
- })
- }
- // MockCheckUname .
- func (d *Dao) MockCheckUname(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CheckUname", func(_ *Dao, _ context.Context, _ int64, _ string) error {
- return err
- })
- }
- // MockTxAddUserBlack .
- func (d *Dao) MockTxAddUserBlack(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxAddUserBlack", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxCancelUserBlack .
- func (d *Dao) MockTxCancelUserBlack(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxCancelUserBlack", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockFetchBlackList .
- func (d *Dao) MockFetchBlackList(upMid []int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "FetchBlackList", func(_ *Dao, _ context.Context, _ int64) ([]int64, error) {
- return upMid, err
- })
- }
- // MockFetchPartBlackList .
- func (d *Dao) MockFetchPartBlackList(MID2IDMap map[int64]time.Time, blackMIDs []int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "FetchPartBlackList", func(_ *Dao, _ context.Context, _ int64, _ model.CursorValue, _ int) (map[int64]time.Time, []int64, error) {
- return MID2IDMap, blackMIDs, err
- })
- }
- // MockIsBlack .
- func (d *Dao) MockIsBlack(MIDMap map[int64]bool) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "IsBlack", func(_ *Dao, _ context.Context, _ int64, _ []int64) map[int64]bool {
- return MIDMap
- })
- }
- // MockRawUserCard .
- func (d *Dao) MockRawUserCard(userCard *model.UserCard, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "RawUserCard", func(_ *Dao, _ context.Context, _ int64) (*model.UserCard, error) {
- return userCard, err
- })
- }
- // MockRawUserCards .
- func (d *Dao) MockRawUserCards(userCards map[int64]*model.UserCard, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "RawUserCards", func(_ *Dao, _ context.Context, _ []int64) (map[int64]*model.UserCard, error) {
- return userCards, err
- })
- }
- // MockRawUserAccCards .
- func (d *Dao) MockRawUserAccCards(res *acc.CardsReply, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "RawUserAccCards", func(_ *Dao, _ context.Context, _ []int64) (*acc.CardsReply, error) {
- return res, err
- })
- }
- // MockTxAddUserFan .
- func (d *Dao) MockTxAddUserFan(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxAddUserFan", func(_ *Dao, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxCancelUserFan .
- func (d *Dao) MockTxCancelUserFan(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxCancelUserFan", func(_ *Dao, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockIsFan .
- func (d *Dao) MockIsFan(MIDMap map[int64]bool) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "IsFan", func(_ *Dao, _ context.Context, _ int64, _ []int64) map[int64]bool {
- return MIDMap
- })
- }
- // MockFetchPartFanList .
- func (d *Dao) MockFetchPartFanList(MID2IDMap map[int64]time.Time, followedMIDs []int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "FetchPartFanList", func(_ *Dao, _ context.Context, _ int64, _ model.CursorValue, _ int) (map[int64]time.Time, []int64, error) {
- return MID2IDMap, followedMIDs, err
- })
- }
- // MockTxAddUserFollow .
- func (d *Dao) MockTxAddUserFollow(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxAddUserFollow", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxCancelUserFollow .
- func (d *Dao) MockTxCancelUserFollow(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxCancelUserFollow", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockFetchFollowList .
- func (d *Dao) MockFetchFollowList(upMid []int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "FetchFollowList", func(_ *Dao, _ context.Context, _ int64) ([]int64, error) {
- return upMid, err
- })
- }
- // MockFetchPartFollowList .
- func (d *Dao) MockFetchPartFollowList(MID2IDMap map[int64]time.Time, followedMIDs []int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "FetchPartFollowList", func(_ *Dao, _ context.Context, _ int64, _ model.CursorValue, _ int) (map[int64]time.Time, []int64, error) {
- return MID2IDMap, followedMIDs, err
- })
- }
- // MockIsFollow .
- func (d *Dao) MockIsFollow(MIDMap map[int64]bool) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "IsFollow", func(_ *Dao, _ context.Context, _ int64, _ []int64) map[int64]bool {
- return MIDMap
- })
- }
- // MockTxAddUserLike .
- func (d *Dao) MockTxAddUserLike(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxAddUserLike", func(_ *Dao, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxCancelUserLike .
- func (d *Dao) MockTxCancelUserLike(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxCancelUserLike", func(_ *Dao, _ *sql.Tx, _ int64, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockCheckUserLike .
- func (d *Dao) MockCheckUserLike(res []int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CheckUserLike", func(_ *Dao, _ context.Context, _ int64, _ []int64) ([]int64, error) {
- return res, err
- })
- }
- // MockGetUserLikeList .
- func (d *Dao) MockGetUserLikeList(likeSvs []*api.LikeSv, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetUserLikeList", func(_ *Dao, _ context.Context, _ int64, _ bool, _ model.CursorValue, _ int) ([]*api.LikeSv, error) {
- return likeSvs, err
- })
- }
- // MockRawBatchUserStatistics .
- func (d *Dao) MockRawBatchUserStatistics(res map[int64]*api.UserStat, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "RawBatchUserStatistics", func(_ *Dao, _ context.Context, _ []int64) (map[int64]*api.UserStat, error) {
- return res, err
- })
- }
- // MockTxIncrUserStatisticsFollow .
- func (d *Dao) MockTxIncrUserStatisticsFollow(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxIncrUserStatisticsFollow", func(_ *Dao, _ *sql.Tx, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxIncrUserStatisticsFan .
- func (d *Dao) MockTxIncrUserStatisticsFan(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxIncrUserStatisticsFan", func(_ *Dao, _ *sql.Tx, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxDecrUserStatisticsFollow .
- func (d *Dao) MockTxDecrUserStatisticsFollow(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxDecrUserStatisticsFollow", func(_ *Dao, _ *sql.Tx, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxDecrUserStatisticsFan .
- func (d *Dao) MockTxDecrUserStatisticsFan(num int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxDecrUserStatisticsFan", func(_ *Dao, _ *sql.Tx, _ int64) (int64, error) {
- return num, err
- })
- }
- // MockTxIncrUserStatisticsField .
- func (d *Dao) MockTxIncrUserStatisticsField(rowsAffected int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxIncrUserStatisticsField", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ string) (int64, error) {
- return rowsAffected, err
- })
- }
- // MockTxDescUserStatisticsField .
- func (d *Dao) MockTxDescUserStatisticsField(rowsAffected int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "TxDescUserStatisticsField", func(_ *Dao, _ context.Context, _ *sql.Tx, _ int64, _ string) (int64, error) {
- return rowsAffected, err
- })
- }
- // MockUpdateUserVideoView .
- func (d *Dao) MockUpdateUserVideoView(err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UpdateUserVideoView", func(_ *Dao, _ context.Context, _ int64, _ int64) error {
- return err
- })
- }
|