example

package module
v0.0.0-...-26782db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 5 Imported by: 0

README

Example entity

Example entity for May CMF aims to show how to create custom modules and entity for MaySMF.

Usage

Get code
$ go get github.com/MayCMF/example

in app.go file:

import (
    ...
	"github.com/MayCMF/core/src/example"
	...
)

// BuildContainer Create a dependency injection container
func BuildContainer() (*dig.Container, func()) {
    ...
	err = example.InjectControllers(container)
    handleError(err)
    ...
}

in migrate.go file:

import (
	...
    example "github.com/MayCMF/example/model/impl/gorm/entity"
    ...
)

// AutoMigrate - Automatic mapping data table
func AutoMigrate(db *gorm.DB) error {
	return db.AutoMigrate(
        ...
        new(example.Example),
        ...
	).Error
}

in storage.go file:

import (
	...
    exampleIject "github.com/MayCMF/example"
    ...
)

// InitStore - Initialize storage
func InitStore(container *dig.Container) (func(), error) {
    ...
    i18nIject.InjectStarage(container)
    // Inject Example datatables to storage
    exampleIject.InjectStarage(container)
    ...
}

in web.go file:

import (
	...
	exampleApi "github.com/MayCMF/cexample/routers/api"
    ...
)

// InitWeb - Initialize the web engine
func InitWeb(container *dig.Container) *gin.Engine {
    ...
	// Registration Example /api routing
	_ = exampleApi.RegisterRouter(app, container)
    ...
}

In the future versions of CMF will be combine in one file

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectControllers

func InjectControllers(container *dig.Container) error

Inject - injection controllers implementation

func InjectStarage

func InjectStarage(container *dig.Container) error

Inject - Injection of gorm

Types

This section is empty.

Directories

Path Synopsis
routers
api
Package test Interface test How to use: go test -v
Package test Interface test How to use: go test -v

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL