Skip to content

Build a simple and modernization admin management panel for xorm

License

Notifications You must be signed in to change notification settings

23233/simple_admin

Repository files navigation

about simple_admin

First time , very thanks for iris framework and developer to helps~

Now talk something , this library just resolve a small and simple problem :

Xorm or gorm Why not provide a simple or small struct model visible dashboard

My trust 99% golang uses people need this

Wait long time not has , start with me , but i time and ability is small and limited !

So I'm just use i familiar technology :

  • iris
  • xorm
  • casbin -> rbac
  • react -> ant.design

Hope to help everyone !

preview

welcome dashBoard dataList guest userManage

use

Install

go get https://github.com/23233/simple_admin

Examples -> https://github.com/23233/simple_admin/tree/master/_examples


Ready -> Defined you struct

type TestModelA struct {
	Id   uint64 `xorm:"autoincr pk unique" json:"id"`
	Name string `xorm:"varchar(20)"`
}

type TestModelB struct {
	Id   uint64 `xorm:"autoincr pk unique" json:"id"`
	Desc string `xorm:"varchar(60)"`
}

Ready -> Defined you xorm engine


Engine, err = xorm.NewEngine("mysql", dbUrl)

Ready -> Defined iris application

app := iris.New()

Go -> Register simple_admin

modelList := []interface{}{new(TestModelA), new(TestModelB)}

_, err := simple_admin.New(simple_admin.Config{
    Engine:    engine,
    App:       app,
    ModelList: modelList,
    Name:      "app name",
    RunSync:   true, // this is xorm sync2
    Prefix:    "/admin", // path prefix like app.Prefix("/admin")
})

Go -> Run you app open browser http://127.0.0.1:8080/admin Yes god job

app.Listen(":8080")

warning

  • first, now don't support xorm deleted tag delete use Unscoped methods!
  • the best you do not use custom usermodel , admin isolation is good!

model custom tags (sp) now support

example: sp("key:value") sp("key(value)") sp("key('value')")
  • autogen -> mark columns is code auto generate not handle
sp("autogen")
  • lineTo -> if custom action , default value use this define for select row
sp("lineTo(Id)")
  • fk -> foreign key , support one to tone and many to one , if use multiple is many to one , just only support id columns , must be have id field !!!
sp("fk('ComplexModelC')") 
sp("fk('ComplexModelC') multiple")
  • tag -> front show whats ? now support custom tag , default show text , options: img
sp:"tag(img)"

event support

  • SpInsertBefore
  • SpInsertAfter
  • SpUpdateBefore
  • SpUpdateAfter
  • SpDeleteBefore()
  • SpDeleteAfter()

custom action

  • func name must use SpAction , just like SpAction() SpAction123() is ok , must return simple_admin.CustomAction struct !

todo features

  • [] full test
  • [] gorm support
  • [] gin support
  • dashboard
  • simple event monitor
  • add spider visit monitor options enable!
  • custom action
  • [] fine permission manage
  • [] support micro frontend , use qiankun
  • [] beat more features