1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package dbmodel
- import (
- "encoding/json"
- "github.com/astaxie/beego/orm"
- )
- type TGdAdminRbacGroup struct {
- Id int64 `json:"id"`
- Name string `json:"name"`
- RbacNodeList string `json:"rbac_node_list"`
- Custom int `json:"custom"`
- CreatedAt string `json:"created_at"`
- UpdatedAt string `json:"updated_at"`
- }
- func (p *TGdAdminRbacGroup) TableName() string {
- return "t_gd_admin_rbac_group"
- }
- func (p TGdAdminRbacGroup) String() string {
- vals, _ := json.Marshal(p)
- return string(vals)
- }
- func (p *TGdAdminRbacGroup) Create(db orm.Ormer) (int64, error) {
- return db.Insert(p)
- }
- func (p *TGdAdminRbacGroup) Fetch(db orm.Ormer, mapFilter map[string]interface{}) error {
- qs := db.QueryTable(p.TableName())
- for k, v := range mapFilter {
- qs = qs.Filter(k, v)
- }
- return qs.One(p)
- }
- func (p *TGdAdminRbacGroup) FetchAll(db orm.Ormer, mapFilter map[string]interface{}, cols []string) (lists []TGdAdminRbacGroup, err error) {
- qa := db.QueryTable(p.TableName())
- for k, v := range mapFilter {
- qa = qa.Filter(k, v)
- }
- _, err = qa.All(&lists, cols...)
- return
- }
- func (p *TGdAdminRbacGroup) Save(db orm.Ormer, mapFilter, values map[string]interface{}) (int64, error) {
- params := orm.Params{}
- //不判断参数为空的情况
- for k, v := range values {
- //if v != nil {
- params[k] = v
- //}
- }
- qs := db.QueryTable(p.TableName())
- for k, v := range mapFilter {
- qs = qs.Filter(k, v)
- }
- return qs.Update(params)
- }
- func (p *TGdAdminRbacGroup) Delete(db orm.Ormer, mapFilter map[string]interface{}) (int64, error) {
- qs := db.QueryTable(p.TableName())
- for k, v := range mapFilter {
- qs = qs.Filter(k, v)
- }
- return qs.Delete()
- }
|