app-cloudep-order-server/internal/svc/init_mongo.go

24 lines
503 B
Go
Raw Normal View History

2024-10-12 09:49:58 +00:00
package svc
import (
"app-cloudep-order-server/internal/config"
model "app-cloudep-order-server/internal/model/mongo"
"fmt"
)
func mustMongoConnectURL(c config.Config) string {
return fmt.Sprintf("%s://%s:%s",
c.Mongo.Schema,
c.Mongo.Host,
c.Mongo.Port,
)
}
// TODO 思考快取做在那邊
func MustOrderModel(c config.Config) model.OrderModel {
orderCollection := model.Order{}
return model.NewOrderModel(mustMongoConnectURL(c), c.Mongo.Database, orderCollection.CollectionName())
}