| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package infrastructure
- import (
- "git.sxidc.com/go-framework/baize/infrastructure/database/data_service"
- "git.sxidc.com/go-framework/baize/infrastructure/database/operations"
- )
- type Config struct {
- DatabaseConfig
- }
- type DatabaseConfig struct {
- Operations *operations.Config
- }
- type Infrastructure struct {
- dbOperations *operations.Operations
- dataService *data_service.DataService
- }
- func NewInfrastructure(config Config) *Infrastructure {
- i := new(Infrastructure)
- if config.DatabaseConfig.Operations != nil {
- op, err := operations.NewOperations(config.DatabaseConfig.Operations)
- if err != nil {
- panic("创建数据库操作失败" + err.Error())
- }
- i.dbOperations = op
- }
- return i
- }
- func DestroyInfrastructure(i *Infrastructure) {
- if i == nil {
- return
- }
- if i.dbOperations != nil {
- err := operations.DestroyOperation(i.dbOperations)
- if err != nil {
- panic("销毁数据库操作失败" + err.Error())
- }
- }
- return
- }
- func (i Infrastructure) GetDBOperations() *operations.Operations {
- return i.dbOperations
- }
- func (i Infrastructure) GetDataService() *data_service.DataService {
- return i.dataService
- }
|