Documentation ¶
Index ¶
- Variables
- func BuildRoute(controller ControllerInterface) (path, resourceName, routeId string)
- func CheckUpdateCondition(m ResourceInterface, condition map[string]interface{})
- func CreateRoutes(group *gin.RouterGroup, controller ControllerInterface, actions ...string)
- func ExsitAndFirst(res ResourceInterface)
- func FindListByMap(res interface{}, where map[string]interface{}, order string, page int, ...)
- func GetRouteID(controller ControllerInterface) (routeId string)
- func MergeUrlCondition(condition map[string]interface{}, query url.Values, obj interface{})
- func ReturnSuccess(c *gin.Context, code int, data interface{})
- func SetForbidUpdateFields(fs ...string) []string
- type BaseController
- type Controller
- func (action *Controller) Create(c *gin.Context)
- func (action *Controller) Delete(c *gin.Context)
- func (action *Controller) Info(c *gin.Context)
- func (action *Controller) Init(r ControllerInterface)
- func (action *Controller) IsRestRoutePk() bool
- func (action *Controller) List(c *gin.Context)
- func (action *Controller) ParentNode() ControllerInterface
- func (action *Controller) RouteName() string
- func (action *Controller) Update(c *gin.Context)
- type ControllerInterface
- type ForbidUpdateResource
- type JsonSuccess
- type Model
- type ResourceInterface
- func Create(res ResourceInterface) ResourceInterface
- func DeleteByID(res ResourceInterface, id int) ResourceInterface
- func FindOneByID(res ResourceInterface, id int) ResourceInterface
- func FindOneByMap(res ResourceInterface, where map[string]interface{}) ResourceInterface
- func UpdateByID(id int, res ResourceInterface) ResourceInterface
- func UpdateWhere(where map[string]interface{}, res ResourceInterface) ResourceInterface
Constants ¶
This section is empty.
Variables ¶
View Source
var Db *gorm.DB
View Source
var PerPage = 20
Functions ¶
func BuildRoute ¶
func BuildRoute(controller ControllerInterface) (path, resourceName, routeId string)
func CheckUpdateCondition ¶
func CheckUpdateCondition(m ResourceInterface, condition map[string]interface{})
func CreateRoutes ¶
func CreateRoutes(group *gin.RouterGroup, controller ControllerInterface, actions ...string)
func ExsitAndFirst ¶
func ExsitAndFirst(res ResourceInterface)
func FindListByMap ¶
func GetRouteID ¶
func GetRouteID(controller ControllerInterface) (routeId string)
func MergeUrlCondition ¶
func ReturnSuccess ¶
func SetForbidUpdateFields ¶
Types ¶
type BaseController ¶
type BaseController struct{}
func (*BaseController) GetModel ¶
func (this *BaseController) GetModel() ResourceInterface
func (BaseController) GetModelSlice ¶
func (this BaseController) GetModelSlice() interface{}
func (BaseController) Rester ¶
func (this BaseController) Rester()
type Controller ¶
type Controller struct { ParentController ControllerInterface Rester ControllerInterface RestModel func() ResourceInterface RestModelSlice func() interface{} //https://golang.org/doc/faq#convert_slice_of_interface *BaseController }
func (*Controller) Create ¶
func (action *Controller) Create(c *gin.Context)
func (*Controller) Delete ¶
func (action *Controller) Delete(c *gin.Context)
func (*Controller) Info ¶
func (action *Controller) Info(c *gin.Context)
func (*Controller) Init ¶
func (action *Controller) Init(r ControllerInterface)
func (*Controller) IsRestRoutePk ¶
func (action *Controller) IsRestRoutePk() bool
func (*Controller) List ¶
func (action *Controller) List(c *gin.Context)
func (*Controller) ParentNode ¶
func (action *Controller) ParentNode() ControllerInterface
func (*Controller) RouteName ¶
func (action *Controller) RouteName() string
func (*Controller) Update ¶
func (action *Controller) Update(c *gin.Context)
type ControllerInterface ¶
type ControllerInterface interface { Update(c *gin.Context) Create(c *gin.Context) Info(c *gin.Context) List(c *gin.Context) Delete(c *gin.Context) IsRestRoutePk() bool //false id RouteName() string //rewrite resource name in route url ParentNode() ControllerInterface Init(r ControllerInterface) GetModel() ResourceInterface GetModelSlice() interface{} // contains filtered or unexported methods }
type ForbidUpdateResource ¶
type ForbidUpdateResource struct{}
func (ForbidUpdateResource) ForbidUpdate ¶
func (bf ForbidUpdateResource) ForbidUpdate() bool
type JsonSuccess ¶
type JsonSuccess struct {
Data interface{} `json:"data"`
}
type Model ¶
type Model struct { ID int `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"deleted_at"` }
func (Model) ForbidUpdateFields ¶
func (Model) InfoFields ¶
func (Model) ListFields ¶
type ResourceInterface ¶
type ResourceInterface interface { ListFields() []string InfoFields() []string ForbidUpdateFields() []string }
func Create ¶
func Create(res ResourceInterface) ResourceInterface
func DeleteByID ¶
func DeleteByID(res ResourceInterface, id int) ResourceInterface
func FindOneByID ¶
func FindOneByID(res ResourceInterface, id int) ResourceInterface
func FindOneByMap ¶
func FindOneByMap(res ResourceInterface, where map[string]interface{}) ResourceInterface
func UpdateByID ¶
func UpdateByID(id int, res ResourceInterface) ResourceInterface
func UpdateWhere ¶
func UpdateWhere(where map[string]interface{}, res ResourceInterface) ResourceInterface
Click to show internal directories.
Click to hide internal directories.