feature/init_member #1
46
Makefile
46
Makefile
|
@ -1,5 +1,3 @@
|
|||
GO_CTL_NAME=goctl
|
||||
|
||||
# go-zero 生成風格
|
||||
GO_ZERO_STYLE=go_zero
|
||||
|
||||
|
@ -21,8 +19,7 @@ fmt: # 格式優化
|
|||
|
||||
.PHONY: gen-rpc
|
||||
gen-rpc: # 建立 rpc code
|
||||
$(GO_CTL_NAME) rpc protoc ./generate/protobuf/service.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
|
||||
copy ./etc/service.yaml ./etc/service.example.yaml
|
||||
goctl rpc protoc ./generate/protobuf/service.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
|
||||
go mod tidy
|
||||
@echo "Generate core-api files successfully"
|
||||
|
||||
|
@ -48,20 +45,37 @@ build-docker:
|
|||
rm -rf Dockerfile
|
||||
@echo "Generate core-api files successfully"
|
||||
|
||||
.PHONY: gen-model
|
||||
gen-model: # 建立 rpc 資料庫
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_table.up.sql --style go_zero -d ./internal/model -i ''
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_uid_table.up.sql --style go_zero -d ./internal/model -i ''
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_user_table.up.sql --style go_zero -d ./internal/model -i ''
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230719061241_machine_node.up.sql --style go_zero -d ./internal/model -i ''
|
||||
@echo "Generate model files successfully"
|
||||
.PHONY: gen-my-sql-model
|
||||
gen-my-sql-model: # 建立 rpc 資料庫
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_table.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_uid_table.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_user_table.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
|
||||
goctl model mysql ddl -c no -s ./generate/database/mysql/20230719061241_machine_node.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
|
||||
@echo "Generate mysql model files successfully"
|
||||
|
||||
gen-mongo-model: # 建立 rpc 資料庫
|
||||
# 只產生 Model 剩下的要自己撰寫,連欄位名稱也是
|
||||
goctl model mongo -t AutoId -c --dir ./internal/model/mongo --style go_zero
|
||||
goctl model mongo -t AutoId --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
|
||||
@echo "Generate mongo model files successfully"
|
||||
|
||||
#goctl model mysql ddl -s ./generate/database/mysql/20240819090248_create_role_permission_table.up.sql --style go_zero -d ./internal/model -i '' (沒cache)
|
||||
#goctl model mysql ddl -c no -s ./generate/database/mysql/20240816014305_create_permission_table.up.sql --style go_zero -d ./internal/model -i '' (有cache)
|
||||
|
||||
#.PHONY: mock-gen
|
||||
#mock-gen: # 建立 mock 資料
|
||||
# mockgen -source=./order.go -destination=../../repository/mock/order.go -package=mock
|
||||
# @echo "Generate model files successfully"
|
||||
.PHONY: mock-gen
|
||||
mock-gen: # 建立 mock 資料
|
||||
mockgen -source=./internal/domain/usecase/uid_generate.go -destination=./internal/mock/usecase/uid_generate.go -package=mock
|
||||
mockgen -source=./internal/model/account_model_gen.go -destination=./internal/mock/model/account_model_gen.go -package=mock
|
||||
mockgen -source=./internal/model/account_model.go -destination=./internal/mock/model/account_model.go -package=mock
|
||||
mockgen -source=./internal/model/account_to_uid_model_gen.go -destination=./internal/mock/model/account_to_uid_model_gen.go -package=mock
|
||||
mockgen -source=./internal/model/account_to_uid_model.go -destination=./internal/mock/model/account_to_uidmodel.go -package=mock
|
||||
mockgen -source=./internal/model/machine_node_model_gen.go -destination=./internal/mock/model/machine_node_model_gen.go -package=mock
|
||||
mockgen -source=./internal/model/machine_node_model.go -destination=./internal/mock/model/machine_node_model.go -package=mock
|
||||
mockgen -source=./internal/model/user_table_model_gen.go -destination=./internal/mock/model/user_table_model_gen.go -package=mock
|
||||
mockgen -source=./internal/model/user_table_model.go -destination=./internal/mock/model/user_table_model.go -package=mock
|
||||
mockgen -source=./internal/model/mongo/auto_id_model_gen.go -destination=./internal/mock/model/auto_id_model_gen.go -package=mock
|
||||
mockgen -source=./internal/model/mongo/auto_id_model.go -destination=./internal/mock/model/auto_id_model.go -package=mock
|
||||
@echo "Generate mock files successfully"
|
||||
|
||||
.PHONY: migrate-database
|
||||
migrate-database:
|
||||
migrate -source file://generate/database/mysql -database 'mysql://root:yytt@tcp(127.0.0.1:3306)/digimon_member' up
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
use digimon_member;
|
||||
db.getCollection("count").createIndex({ "name": 1 });
|
|
@ -1 +1 @@
|
|||
DROP DATABASE IF EXISTS `ark_member`;
|
||||
DROP DATABASE IF EXISTS `digimon_member`;
|
|
@ -1 +1 @@
|
|||
CREATE DATABASE IF NOT EXISTS `ark_member`;
|
||||
CREATE DATABASE IF NOT EXISTS `digimon_member`;
|
|
@ -14,6 +14,7 @@ enum VerifyType {
|
|||
VERIFY_EMAIL = 1;
|
||||
VERIFY_PHONE = 2;
|
||||
VERIFY_GOOGLE = 3; // google 驗證器
|
||||
VERIFY_NOT = 4; // 尚未
|
||||
}
|
||||
|
||||
enum AlarmType {
|
||||
|
@ -57,6 +58,12 @@ message BindingUserReq {
|
|||
int64 type = 3;
|
||||
}
|
||||
|
||||
message BindingUserResp {
|
||||
string uid = 1;
|
||||
string login_id = 2;
|
||||
int64 type = 3;
|
||||
}
|
||||
|
||||
message CreateUserInfoReq {
|
||||
string uid = 1;
|
||||
VerifyType verify_type = 2;
|
||||
|
@ -64,9 +71,8 @@ message CreateUserInfoReq {
|
|||
MemberStatus status = 4;
|
||||
string language = 5;
|
||||
string currency = 6;
|
||||
optional string nick_name = 7;
|
||||
optional uint32 gender = 8;
|
||||
optional int64 birthday = 9;
|
||||
optional string avatar= 7;
|
||||
optional string nick_name = 8;
|
||||
}
|
||||
|
||||
message GetAccountInfoResp {
|
||||
|
@ -168,7 +174,7 @@ service Account {
|
|||
// GetUidByAccount 用帳號換取 UID
|
||||
rpc GetUidByAccount(GetUIDByAccountReq) returns(GetUidByAccountResp);
|
||||
// BindAccount 綁定帳號 -> account bind to UID
|
||||
rpc BindAccount(BindingUserReq) returns(OKResp);
|
||||
rpc BindAccount(BindingUserReq) returns(BindingUserResp);
|
||||
// BindUserInfo 初次,綁定 User Info
|
||||
rpc BindUserInfo(CreateUserInfoReq) returns(OKResp);
|
||||
// UpdateUserInfo 更新 User Info
|
||||
|
|
17
go.mod
17
go.mod
|
@ -5,15 +5,21 @@ go 1.22.3
|
|||
require (
|
||||
code.30cm.net/digimon/library-go/errors v1.0.1
|
||||
code.30cm.net/digimon/library-go/validator v1.0.0
|
||||
github.com/alicebob/miniredis/v2 v2.33.0
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/go-sql-driver/mysql v1.8.1
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/zeromicro/go-zero v1.7.0
|
||||
go.mongodb.org/mongo-driver v1.16.0
|
||||
go.uber.org/goleak v1.3.0
|
||||
go.uber.org/mock v0.4.0
|
||||
google.golang.org/grpc v1.65.0
|
||||
google.golang.org/protobuf v1.34.2
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
|
@ -32,10 +38,10 @@ require (
|
|||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.22.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.8 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
|
@ -43,21 +49,29 @@ require (
|
|||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.8 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/redis/go-redis/v9 v9.6.1 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||
github.com/yuin/gopher-lua v1.1.1 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.15 // indirect
|
||||
|
@ -79,6 +93,7 @@ require (
|
|||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/oauth2 v0.20.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/term v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
|
|
|
@ -6,7 +6,7 @@ const (
|
|||
Scope = 10
|
||||
)
|
||||
|
||||
const InitAutoId = 1000000
|
||||
const InitAutoId = 10000000
|
||||
const DefaultReferralCodeLen = 8
|
||||
|
||||
var ConvertTable = [...]string{
|
||||
|
@ -16,3 +16,15 @@ var ConvertTable = [...]string{
|
|||
"L", "M", "N", "Z", "K",
|
||||
"P", "V", "R", "S", "T",
|
||||
}
|
||||
|
||||
type AccountType int8
|
||||
|
||||
func (a AccountType) ToInt64() int64 {
|
||||
return int64(a)
|
||||
}
|
||||
|
||||
const (
|
||||
AccountTypePhone AccountType = 1
|
||||
AccountTypeMail AccountType = 2
|
||||
AccountTypeAccount AccountType = 3
|
||||
)
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./validate.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./validate.go -destination=../../mock/lib/validate.go -package=lib
|
||||
//
|
||||
|
||||
// Package lib is a generated GoMock package.
|
||||
package lib
|
||||
|
||||
import (
|
||||
required "code.30cm.net/digimon/library-go/validator"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockValidate is a mock of Validate interface.
|
||||
type MockValidate struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockValidateMockRecorder
|
||||
}
|
||||
|
||||
// MockValidateMockRecorder is the mock recorder for MockValidate.
|
||||
type MockValidateMockRecorder struct {
|
||||
mock *MockValidate
|
||||
}
|
||||
|
||||
// NewMockValidate creates a new mock instance.
|
||||
func NewMockValidate(ctrl *gomock.Controller) *MockValidate {
|
||||
mock := &MockValidate{ctrl: ctrl}
|
||||
mock.recorder = &MockValidateMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockValidate) EXPECT() *MockValidateMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// BindToValidator mocks base method.
|
||||
func (m *MockValidate) BindToValidator(opts ...required.Option) error {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{}
|
||||
for _, a := range opts {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "BindToValidator", varargs...)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// BindToValidator indicates an expected call of BindToValidator.
|
||||
func (mr *MockValidateMockRecorder) BindToValidator(opts ...any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindToValidator", reflect.TypeOf((*MockValidate)(nil).BindToValidator), opts...)
|
||||
}
|
||||
|
||||
// ValidateAll mocks base method.
|
||||
func (m *MockValidate) ValidateAll(obj any) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ValidateAll", obj)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ValidateAll indicates an expected call of ValidateAll.
|
||||
func (mr *MockValidateMockRecorder) ValidateAll(obj any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateAll", reflect.TypeOf((*MockValidate)(nil).ValidateAll), obj)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/account_model.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/account_model.go -destination=./internal/mock/model/account_model.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockAccountModel is a mock of AccountModel interface.
|
||||
type MockAccountModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockAccountModelMockRecorder
|
||||
}
|
||||
|
||||
// MockAccountModelMockRecorder is the mock recorder for MockAccountModel.
|
||||
type MockAccountModelMockRecorder struct {
|
||||
mock *MockAccountModel
|
||||
}
|
||||
|
||||
// NewMockAccountModel creates a new mock instance.
|
||||
func NewMockAccountModel(ctrl *gomock.Controller) *MockAccountModel {
|
||||
mock := &MockAccountModel{ctrl: ctrl}
|
||||
mock.recorder = &MockAccountModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockAccountModel) EXPECT() *MockAccountModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockAccountModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockAccountModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockAccountModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockAccountModel) FindOne(ctx context.Context, id int64) (*model.Account, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.Account)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockAccountModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockAccountModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// FindOneByAccount mocks base method.
|
||||
func (m *MockAccountModel) FindOneByAccount(ctx context.Context, account string) (*model.Account, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOneByAccount", ctx, account)
|
||||
ret0, _ := ret[0].(*model.Account)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOneByAccount indicates an expected call of FindOneByAccount.
|
||||
func (mr *MockAccountModelMockRecorder) FindOneByAccount(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByAccount", reflect.TypeOf((*MockAccountModel)(nil).FindOneByAccount), ctx, account)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockAccountModel) Insert(ctx context.Context, data *model.Account) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockAccountModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockAccountModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockAccountModel) Update(ctx context.Context, data *model.Account) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockAccountModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockAccountModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/account_model_gen.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/account_model_gen.go -destination=./internal/mock/model/account_model_gen.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockaccountModel is a mock of accountModel interface.
|
||||
type MockaccountModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockaccountModelMockRecorder
|
||||
}
|
||||
|
||||
// MockaccountModelMockRecorder is the mock recorder for MockaccountModel.
|
||||
type MockaccountModelMockRecorder struct {
|
||||
mock *MockaccountModel
|
||||
}
|
||||
|
||||
// NewMockaccountModel creates a new mock instance.
|
||||
func NewMockaccountModel(ctrl *gomock.Controller) *MockaccountModel {
|
||||
mock := &MockaccountModel{ctrl: ctrl}
|
||||
mock.recorder = &MockaccountModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockaccountModel) EXPECT() *MockaccountModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockaccountModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockaccountModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockaccountModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockaccountModel) FindOne(ctx context.Context, id int64) (*model.Account, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.Account)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockaccountModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockaccountModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// FindOneByAccount mocks base method.
|
||||
func (m *MockaccountModel) FindOneByAccount(ctx context.Context, account string) (*model.Account, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOneByAccount", ctx, account)
|
||||
ret0, _ := ret[0].(*model.Account)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOneByAccount indicates an expected call of FindOneByAccount.
|
||||
func (mr *MockaccountModelMockRecorder) FindOneByAccount(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByAccount", reflect.TypeOf((*MockaccountModel)(nil).FindOneByAccount), ctx, account)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockaccountModel) Insert(ctx context.Context, data *model.Account) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockaccountModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockaccountModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockaccountModel) Update(ctx context.Context, data *model.Account) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockaccountModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockaccountModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/account_to_uid_model_gen.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/account_to_uid_model_gen.go -destination=./internal/mock/model/account_to_uid_model_gen.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockaccountToUidModel is a mock of accountToUidModel interface.
|
||||
type MockaccountToUidModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockaccountToUidModelMockRecorder
|
||||
}
|
||||
|
||||
// MockaccountToUidModelMockRecorder is the mock recorder for MockaccountToUidModel.
|
||||
type MockaccountToUidModelMockRecorder struct {
|
||||
mock *MockaccountToUidModel
|
||||
}
|
||||
|
||||
// NewMockaccountToUidModel creates a new mock instance.
|
||||
func NewMockaccountToUidModel(ctrl *gomock.Controller) *MockaccountToUidModel {
|
||||
mock := &MockaccountToUidModel{ctrl: ctrl}
|
||||
mock.recorder = &MockaccountToUidModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockaccountToUidModel) EXPECT() *MockaccountToUidModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockaccountToUidModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockaccountToUidModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockaccountToUidModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockaccountToUidModel) FindOne(ctx context.Context, id int64) (*model.AccountToUid, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.AccountToUid)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockaccountToUidModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockaccountToUidModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// FindOneByAccount mocks base method.
|
||||
func (m *MockaccountToUidModel) FindOneByAccount(ctx context.Context, account string) (*model.AccountToUid, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOneByAccount", ctx, account)
|
||||
ret0, _ := ret[0].(*model.AccountToUid)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOneByAccount indicates an expected call of FindOneByAccount.
|
||||
func (mr *MockaccountToUidModelMockRecorder) FindOneByAccount(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByAccount", reflect.TypeOf((*MockaccountToUidModel)(nil).FindOneByAccount), ctx, account)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockaccountToUidModel) Insert(ctx context.Context, data *model.AccountToUid) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockaccountToUidModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockaccountToUidModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockaccountToUidModel) Update(ctx context.Context, data *model.AccountToUid) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockaccountToUidModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockaccountToUidModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/account_to_uid_model.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/account_to_uid_model.go -destination=./internal/mock/model/account_to_uidmodel.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockAccountToUidModel is a mock of AccountToUidModel interface.
|
||||
type MockAccountToUidModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockAccountToUidModelMockRecorder
|
||||
}
|
||||
|
||||
// MockAccountToUidModelMockRecorder is the mock recorder for MockAccountToUidModel.
|
||||
type MockAccountToUidModelMockRecorder struct {
|
||||
mock *MockAccountToUidModel
|
||||
}
|
||||
|
||||
// NewMockAccountToUidModel creates a new mock instance.
|
||||
func NewMockAccountToUidModel(ctrl *gomock.Controller) *MockAccountToUidModel {
|
||||
mock := &MockAccountToUidModel{ctrl: ctrl}
|
||||
mock.recorder = &MockAccountToUidModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockAccountToUidModel) EXPECT() *MockAccountToUidModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockAccountToUidModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockAccountToUidModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockAccountToUidModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockAccountToUidModel) FindOne(ctx context.Context, id int64) (*model.AccountToUid, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.AccountToUid)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockAccountToUidModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockAccountToUidModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// FindOneByAccount mocks base method.
|
||||
func (m *MockAccountToUidModel) FindOneByAccount(ctx context.Context, account string) (*model.AccountToUid, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOneByAccount", ctx, account)
|
||||
ret0, _ := ret[0].(*model.AccountToUid)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOneByAccount indicates an expected call of FindOneByAccount.
|
||||
func (mr *MockAccountToUidModelMockRecorder) FindOneByAccount(ctx, account any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByAccount", reflect.TypeOf((*MockAccountToUidModel)(nil).FindOneByAccount), ctx, account)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockAccountToUidModel) Insert(ctx context.Context, data *model.AccountToUid) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockAccountToUidModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockAccountToUidModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockAccountToUidModel) Update(ctx context.Context, data *model.AccountToUid) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockAccountToUidModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockAccountToUidModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/mongo/auto_id_model.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/mongo/auto_id_model.go -destination=./internal/mock/model/auto_id_model.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model/mongo"
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
mongo "go.mongodb.org/mongo-driver/mongo"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockAutoIdModel is a mock of AutoIdModel interface.
|
||||
type MockAutoIdModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockAutoIdModelMockRecorder
|
||||
}
|
||||
|
||||
// MockAutoIdModelMockRecorder is the mock recorder for MockAutoIdModel.
|
||||
type MockAutoIdModelMockRecorder struct {
|
||||
mock *MockAutoIdModel
|
||||
}
|
||||
|
||||
// NewMockAutoIdModel creates a new mock instance.
|
||||
func NewMockAutoIdModel(ctrl *gomock.Controller) *MockAutoIdModel {
|
||||
mock := &MockAutoIdModel{ctrl: ctrl}
|
||||
mock.recorder = &MockAutoIdModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockAutoIdModel) EXPECT() *MockAutoIdModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockAutoIdModel) Delete(ctx context.Context, id string) (int64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(int64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockAutoIdModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockAutoIdModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockAutoIdModel) FindOne(ctx context.Context, id string) (*model.AutoId, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.AutoId)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockAutoIdModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockAutoIdModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// Inc mocks base method.
|
||||
func (m *MockAutoIdModel) Inc(ctx context.Context, data *model.AutoId) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Inc", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Inc indicates an expected call of Inc.
|
||||
func (mr *MockAutoIdModelMockRecorder) Inc(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Inc", reflect.TypeOf((*MockAutoIdModel)(nil).Inc), ctx, data)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockAutoIdModel) Insert(ctx context.Context, data *model.AutoId) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockAutoIdModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockAutoIdModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockAutoIdModel) Update(ctx context.Context, data *model.AutoId) (*mongo.UpdateResult, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(*mongo.UpdateResult)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockAutoIdModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockAutoIdModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/mongo/auto_id_model_gen.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/mongo/auto_id_model_gen.go -destination=./internal/mock/model/auto_id_model_gen.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model/mongo"
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
mongo "go.mongodb.org/mongo-driver/mongo"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockautoIdModel is a mock of autoIdModel interface.
|
||||
type MockautoIdModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockautoIdModelMockRecorder
|
||||
}
|
||||
|
||||
// MockautoIdModelMockRecorder is the mock recorder for MockautoIdModel.
|
||||
type MockautoIdModelMockRecorder struct {
|
||||
mock *MockautoIdModel
|
||||
}
|
||||
|
||||
// NewMockautoIdModel creates a new mock instance.
|
||||
func NewMockautoIdModel(ctrl *gomock.Controller) *MockautoIdModel {
|
||||
mock := &MockautoIdModel{ctrl: ctrl}
|
||||
mock.recorder = &MockautoIdModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockautoIdModel) EXPECT() *MockautoIdModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockautoIdModel) Delete(ctx context.Context, id string) (int64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(int64)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockautoIdModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockautoIdModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockautoIdModel) FindOne(ctx context.Context, id string) (*model.AutoId, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.AutoId)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockautoIdModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockautoIdModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockautoIdModel) Insert(ctx context.Context, data *model.AutoId) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockautoIdModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockautoIdModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockautoIdModel) Update(ctx context.Context, data *model.AutoId) (*mongo.UpdateResult, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(*mongo.UpdateResult)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockautoIdModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockautoIdModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/machine_node_model.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/machine_node_model.go -destination=./internal/mock/model/machine_node_model.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockMachineNodeModel is a mock of MachineNodeModel interface.
|
||||
type MockMachineNodeModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockMachineNodeModelMockRecorder
|
||||
}
|
||||
|
||||
// MockMachineNodeModelMockRecorder is the mock recorder for MockMachineNodeModel.
|
||||
type MockMachineNodeModelMockRecorder struct {
|
||||
mock *MockMachineNodeModel
|
||||
}
|
||||
|
||||
// NewMockMachineNodeModel creates a new mock instance.
|
||||
func NewMockMachineNodeModel(ctrl *gomock.Controller) *MockMachineNodeModel {
|
||||
mock := &MockMachineNodeModel{ctrl: ctrl}
|
||||
mock.recorder = &MockMachineNodeModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockMachineNodeModel) EXPECT() *MockMachineNodeModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockMachineNodeModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockMachineNodeModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockMachineNodeModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockMachineNodeModel) FindOne(ctx context.Context, id int64) (*model.MachineNode, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.MachineNode)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockMachineNodeModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockMachineNodeModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockMachineNodeModel) Insert(ctx context.Context, data *model.MachineNode) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockMachineNodeModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockMachineNodeModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockMachineNodeModel) Update(ctx context.Context, data *model.MachineNode) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockMachineNodeModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockMachineNodeModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/machine_node_model_gen.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/machine_node_model_gen.go -destination=./internal/mock/model/machine_node_model_gen.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockmachineNodeModel is a mock of machineNodeModel interface.
|
||||
type MockmachineNodeModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockmachineNodeModelMockRecorder
|
||||
}
|
||||
|
||||
// MockmachineNodeModelMockRecorder is the mock recorder for MockmachineNodeModel.
|
||||
type MockmachineNodeModelMockRecorder struct {
|
||||
mock *MockmachineNodeModel
|
||||
}
|
||||
|
||||
// NewMockmachineNodeModel creates a new mock instance.
|
||||
func NewMockmachineNodeModel(ctrl *gomock.Controller) *MockmachineNodeModel {
|
||||
mock := &MockmachineNodeModel{ctrl: ctrl}
|
||||
mock.recorder = &MockmachineNodeModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockmachineNodeModel) EXPECT() *MockmachineNodeModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockmachineNodeModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockmachineNodeModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockmachineNodeModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockmachineNodeModel) FindOne(ctx context.Context, id int64) (*model.MachineNode, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.MachineNode)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockmachineNodeModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockmachineNodeModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockmachineNodeModel) Insert(ctx context.Context, data *model.MachineNode) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockmachineNodeModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockmachineNodeModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockmachineNodeModel) Update(ctx context.Context, data *model.MachineNode) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockmachineNodeModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockmachineNodeModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/user_table_model.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/user_table_model.go -destination=./internal/mock/model/user_table_model.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockUserTableModel is a mock of UserTableModel interface.
|
||||
type MockUserTableModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockUserTableModelMockRecorder
|
||||
}
|
||||
|
||||
// MockUserTableModelMockRecorder is the mock recorder for MockUserTableModel.
|
||||
type MockUserTableModelMockRecorder struct {
|
||||
mock *MockUserTableModel
|
||||
}
|
||||
|
||||
// NewMockUserTableModel creates a new mock instance.
|
||||
func NewMockUserTableModel(ctrl *gomock.Controller) *MockUserTableModel {
|
||||
mock := &MockUserTableModel{ctrl: ctrl}
|
||||
mock.recorder = &MockUserTableModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockUserTableModel) EXPECT() *MockUserTableModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockUserTableModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockUserTableModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUserTableModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockUserTableModel) FindOne(ctx context.Context, id int64) (*model.UserTable, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.UserTable)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockUserTableModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockUserTableModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// FindOneByUid mocks base method.
|
||||
func (m *MockUserTableModel) FindOneByUid(ctx context.Context, uid string) (*model.UserTable, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOneByUid", ctx, uid)
|
||||
ret0, _ := ret[0].(*model.UserTable)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOneByUid indicates an expected call of FindOneByUid.
|
||||
func (mr *MockUserTableModelMockRecorder) FindOneByUid(ctx, uid any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByUid", reflect.TypeOf((*MockUserTableModel)(nil).FindOneByUid), ctx, uid)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockUserTableModel) Insert(ctx context.Context, data *model.UserTable) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockUserTableModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockUserTableModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockUserTableModel) Update(ctx context.Context, data *model.UserTable) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockUserTableModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUserTableModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/model/user_table_model_gen.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/model/user_table_model_gen.go -destination=./internal/mock/model/user_table_model_gen.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
model "app-cloudep-member-server/internal/model"
|
||||
context "context"
|
||||
sql "database/sql"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockuserTableModel is a mock of userTableModel interface.
|
||||
type MockuserTableModel struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockuserTableModelMockRecorder
|
||||
}
|
||||
|
||||
// MockuserTableModelMockRecorder is the mock recorder for MockuserTableModel.
|
||||
type MockuserTableModelMockRecorder struct {
|
||||
mock *MockuserTableModel
|
||||
}
|
||||
|
||||
// NewMockuserTableModel creates a new mock instance.
|
||||
func NewMockuserTableModel(ctrl *gomock.Controller) *MockuserTableModel {
|
||||
mock := &MockuserTableModel{ctrl: ctrl}
|
||||
mock.recorder = &MockuserTableModelMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockuserTableModel) EXPECT() *MockuserTableModelMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockuserTableModel) Delete(ctx context.Context, id int64) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Delete", ctx, id)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Delete indicates an expected call of Delete.
|
||||
func (mr *MockuserTableModelMockRecorder) Delete(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockuserTableModel)(nil).Delete), ctx, id)
|
||||
}
|
||||
|
||||
// FindOne mocks base method.
|
||||
func (m *MockuserTableModel) FindOne(ctx context.Context, id int64) (*model.UserTable, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOne", ctx, id)
|
||||
ret0, _ := ret[0].(*model.UserTable)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOne indicates an expected call of FindOne.
|
||||
func (mr *MockuserTableModelMockRecorder) FindOne(ctx, id any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockuserTableModel)(nil).FindOne), ctx, id)
|
||||
}
|
||||
|
||||
// FindOneByUid mocks base method.
|
||||
func (m *MockuserTableModel) FindOneByUid(ctx context.Context, uid string) (*model.UserTable, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "FindOneByUid", ctx, uid)
|
||||
ret0, _ := ret[0].(*model.UserTable)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindOneByUid indicates an expected call of FindOneByUid.
|
||||
func (mr *MockuserTableModelMockRecorder) FindOneByUid(ctx, uid any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOneByUid", reflect.TypeOf((*MockuserTableModel)(nil).FindOneByUid), ctx, uid)
|
||||
}
|
||||
|
||||
// Insert mocks base method.
|
||||
func (m *MockuserTableModel) Insert(ctx context.Context, data *model.UserTable) (sql.Result, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Insert", ctx, data)
|
||||
ret0, _ := ret[0].(sql.Result)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Insert indicates an expected call of Insert.
|
||||
func (mr *MockuserTableModelMockRecorder) Insert(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockuserTableModel)(nil).Insert), ctx, data)
|
||||
}
|
||||
|
||||
// Update mocks base method.
|
||||
func (m *MockuserTableModel) Update(ctx context.Context, data *model.UserTable) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Update", ctx, data)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Update indicates an expected call of Update.
|
||||
func (mr *MockuserTableModelMockRecorder) Update(ctx, data any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockuserTableModel)(nil).Update), ctx, data)
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./internal/domain/usecase/uid_generate.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=./internal/domain/usecase/uid_generate.go -destination=./internal/mock/usecase/uid_generate.go -package=mock
|
||||
//
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockUIDGenerateUseCase is a mock of UIDGenerateUseCase interface.
|
||||
type MockUIDGenerateUseCase struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockUIDGenerateUseCaseMockRecorder
|
||||
}
|
||||
|
||||
// MockUIDGenerateUseCaseMockRecorder is the mock recorder for MockUIDGenerateUseCase.
|
||||
type MockUIDGenerateUseCaseMockRecorder struct {
|
||||
mock *MockUIDGenerateUseCase
|
||||
}
|
||||
|
||||
// NewMockUIDGenerateUseCase creates a new mock instance.
|
||||
func NewMockUIDGenerateUseCase(ctrl *gomock.Controller) *MockUIDGenerateUseCase {
|
||||
mock := &MockUIDGenerateUseCase{ctrl: ctrl}
|
||||
mock.recorder = &MockUIDGenerateUseCaseMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockUIDGenerateUseCase) EXPECT() *MockUIDGenerateUseCaseMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Generate mocks base method.
|
||||
func (m *MockUIDGenerateUseCase) Generate(ctx context.Context) (string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Generate", ctx)
|
||||
ret0, _ := ret[0].(string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Generate indicates an expected call of Generate.
|
||||
func (mr *MockUIDGenerateUseCaseMockRecorder) Generate(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generate", reflect.TypeOf((*MockUIDGenerateUseCase)(nil).Generate), ctx)
|
||||
}
|
|
@ -2,10 +2,10 @@ package model
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/monc"
|
||||
"github.com/zeromicro/go-zero/core/stores/mon"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ AutoIdModel = (*customAutoIdModel)(nil)
|
||||
|
@ -24,23 +24,26 @@ type (
|
|||
)
|
||||
|
||||
// NewAutoIdModel returns a model for the mongo.
|
||||
func NewAutoIdModel(url, db, collection string, c cache.CacheConf) AutoIdModel {
|
||||
conn := monc.MustNewModel(url, db, collection, c)
|
||||
func NewAutoIdModel(url, db, collection string) AutoIdModel {
|
||||
conn := mon.MustNewModel(url, db, collection)
|
||||
return &customAutoIdModel{
|
||||
defaultAutoIdModel: newDefaultAutoIdModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customAutoIdModel) Inc(ctx context.Context, data *AutoId) error {
|
||||
filter := bson.M{"admin": "auto_id"}
|
||||
update := bson.M{"$inc": bson.M{"counter": 1}}
|
||||
// 定義查詢的條件
|
||||
filter := bson.M{"name": "auto_id"}
|
||||
|
||||
key := prefixAutoIdCacheKey + "count"
|
||||
|
||||
err := m.conn.FindOneAndUpdate(ctx, key, data, filter, update,
|
||||
// 定義更新的操作,包括自增和更新時間
|
||||
update := bson.M{
|
||||
"$inc": bson.M{"counter": 1}, // 自增 counter
|
||||
"$set": bson.M{"updateAt": time.Now().UTC()}, // 設置 updateAt 為當前時間
|
||||
}
|
||||
// 使用 FindOneAndUpdate 並將結果解碼到 data 中
|
||||
err := m.conn.FindOneAndUpdate(ctx, &data, filter, update,
|
||||
options.FindOneAndUpdate().SetUpsert(true),
|
||||
options.FindOneAndUpdate().SetReturnDocument(options.After),
|
||||
)
|
||||
options.FindOneAndUpdate().SetReturnDocument(options.After))
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/monc"
|
||||
"github.com/zeromicro/go-zero/core/stores/mon"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
var prefixAutoIdCacheKey = "cache:autoId:"
|
||||
|
||||
type autoIdModel interface {
|
||||
Insert(ctx context.Context, data *AutoId) error
|
||||
FindOne(ctx context.Context, id string) (*AutoId, error)
|
||||
|
@ -21,22 +19,21 @@ type autoIdModel interface {
|
|||
}
|
||||
|
||||
type defaultAutoIdModel struct {
|
||||
conn *monc.Model
|
||||
conn *mon.Model
|
||||
}
|
||||
|
||||
func newDefaultAutoIdModel(conn *monc.Model) *defaultAutoIdModel {
|
||||
func newDefaultAutoIdModel(conn *mon.Model) *defaultAutoIdModel {
|
||||
return &defaultAutoIdModel{conn: conn}
|
||||
}
|
||||
|
||||
func (m *defaultAutoIdModel) Insert(ctx context.Context, data *AutoId) error {
|
||||
if data.ID.IsZero() {
|
||||
data.ID = primitive.NewObjectID()
|
||||
data.CreateAt = time.Now()
|
||||
data.UpdateAt = time.Now()
|
||||
data.CreateAt = time.Now().UTC()
|
||||
data.UpdateAt = time.Now().UTC()
|
||||
}
|
||||
|
||||
key := prefixAutoIdCacheKey + data.ID.Hex()
|
||||
_, err := m.conn.InsertOne(ctx, key, data)
|
||||
_, err := m.conn.InsertOne(ctx, data)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -47,12 +44,12 @@ func (m *defaultAutoIdModel) FindOne(ctx context.Context, id string) (*AutoId, e
|
|||
}
|
||||
|
||||
var data AutoId
|
||||
key := prefixAutoIdCacheKey + id
|
||||
err = m.conn.FindOne(ctx, key, &data, bson.M{"_id": oid})
|
||||
|
||||
err = m.conn.FindOne(ctx, &data, bson.M{"_id": oid})
|
||||
switch err {
|
||||
case nil:
|
||||
return &data, nil
|
||||
case monc.ErrNotFound:
|
||||
case mon.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
|
@ -60,9 +57,9 @@ func (m *defaultAutoIdModel) FindOne(ctx context.Context, id string) (*AutoId, e
|
|||
}
|
||||
|
||||
func (m *defaultAutoIdModel) Update(ctx context.Context, data *AutoId) (*mongo.UpdateResult, error) {
|
||||
data.UpdateAt = time.Now()
|
||||
key := prefixAutoIdCacheKey + data.ID.Hex()
|
||||
res, err := m.conn.UpdateOne(ctx, key, bson.M{"_id": data.ID}, bson.M{"$set": data})
|
||||
data.UpdateAt = time.Now().UTC()
|
||||
|
||||
res, err := m.conn.UpdateOne(ctx, bson.M{"_id": data.ID}, bson.M{"$set": data})
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
@ -71,7 +68,7 @@ func (m *defaultAutoIdModel) Delete(ctx context.Context, id string) (int64, erro
|
|||
if err != nil {
|
||||
return 0, ErrInvalidObjectId
|
||||
}
|
||||
key := prefixAutoIdCacheKey + id
|
||||
res, err := m.conn.DeleteOne(ctx, key, bson.M{"_id": oid})
|
||||
|
||||
res, err := m.conn.DeleteOne(ctx, bson.M{"_id": oid})
|
||||
return res, err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
type AutoId struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
|
||||
Name string `bson:"name,omitempty" json:"name,omitempty"`
|
||||
Count uint64 `bson:"count,omitempty" json:"count,omitempty"`
|
||||
Counter uint64 `bson:"counter" json:"counter"`
|
||||
UpdateAt time.Time `bson:"updateAt,omitempty" json:"updateAt,omitempty"`
|
||||
CreateAt time.Time `bson:"createAt,omitempty" json:"createAt,omitempty"`
|
||||
}
|
||||
|
|
|
@ -36,11 +36,10 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
}
|
||||
mongo := mgo.NewAutoIdModel(
|
||||
fmt.Sprintf(
|
||||
"%s://%s:%s@%s:%s", c.Mongo.Schema,
|
||||
c.Mongo.User, c.Mongo.Password, c.Mongo.Host, c.Mongo.Port),
|
||||
"%s://%s:%s", c.Mongo.Schema,
|
||||
c.Mongo.Host, c.Mongo.Port),
|
||||
c.Mongo.Database,
|
||||
c.Mongo.Collection,
|
||||
c.Cache)
|
||||
c.Mongo.Collection)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -25,14 +25,15 @@ func MustGenerateUseCase(param GenerateUseCaseParam) usecase.UIDGenerateUseCase
|
|||
}
|
||||
|
||||
// Generate 利用 mongo 創立全局唯一的 ark id
|
||||
// 如果之後有效能問題,扛在同一個 mongo 資料庫,在改成雪花算法
|
||||
// TODO 如果之後有效能問題,扛在同一個 mongo 資料庫,在改成雪花算法
|
||||
func (g GenerateUseCase) Generate(ctx context.Context) (string, error) {
|
||||
var data mgo.AutoId
|
||||
err := g.generateUIDRepo.Inc(ctx, &data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
uid := strconv.Itoa(int(domain.InitAutoId + data.Count))
|
||||
|
||||
uid := strconv.Itoa(int(domain.InitAutoId + data.Counter))
|
||||
code, err := generateReferralCode(uid)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -53,7 +54,7 @@ func generateReferralCode(uid string) (string, error) {
|
|||
return "", usecase.UIDOutOfRangeErrorCodeError("uid encode out of range")
|
||||
}
|
||||
|
||||
encoded := encodeToBase(uidInt, len(domain.ConvertTable), domain.DefaultReferralCodeLen)
|
||||
encoded := encodeToBase(uidInt, 10, domain.DefaultReferralCodeLen)
|
||||
|
||||
return encoded, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package usecase
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// 單元測試
|
||||
func TestEncodeToBase(t *testing.T) {
|
||||
tests := []struct {
|
||||
num int64
|
||||
base int
|
||||
length int
|
||||
want string
|
||||
}{
|
||||
// 測試基礎情況
|
||||
{num: 0, base: 10, length: 6, want: "OOOOOO"},
|
||||
{num: 1, base: 10, length: 6, want: "OOOOOD"},
|
||||
|
||||
{num: 24, base: 10, length: 6, want: "OOOOWY"},
|
||||
{num: 25, base: 10, length: 6, want: "OOOOWG"},
|
||||
{num: 1, base: 10, length: 4, want: "OOOD"},
|
||||
{num: 24, base: 10, length: 4, want: "OOWY"},
|
||||
{num: 25, base: 10, length: 5, want: "OOOWG"},
|
||||
{num: 1234567890, base: 10, length: 10, want: "DWXYGBCHEO"}, // 測試大數情況
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run("encodeToBase", func(t *testing.T) {
|
||||
got := encodeToBase(tt.num, tt.base, tt.length)
|
||||
if got != tt.want {
|
||||
t.Errorf("encodeToBase(%d, %d, %d) = %s; want %s", tt.num, tt.base, tt.length, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func HashPassword(password string, cost int) (string, error) {
|
||||
bytes, err := bcrypt.GenerateFromPassword([]byte(password), cost)
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
func CheckPasswordHash(password, hash string) bool {
|
||||
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func GetHashingCost(hashedPassword []byte) int {
|
||||
cost, _ := bcrypt.Cost(hashedPassword)
|
||||
return cost
|
||||
}
|
Loading…
Reference in New Issue