You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
388 B

  1. package initialize
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/jinzhu/gorm"
  5. )
  6. type Plug interface {
  7. InitRouter([2]*gin.RouterGroup) error
  8. InitModel(*gorm.DB) error
  9. }
  10. func InstallPlug(db *gorm.DB, router [2]*gin.RouterGroup, p Plug) (err error) {
  11. err = p.InitModel(db)
  12. if err != nil {
  13. return err
  14. }
  15. err = p.InitRouter(router)
  16. if err != nil {
  17. return err
  18. }
  19. return nil
  20. }