Documentation ¶
Index ¶
- Variables
- func HandleConditions(session *xorm.Session, q *QueryParam) error
- type CRUDEvent
- type CRUDService
- func (s *CRUDService) AfterDelete(bean interface{})
- func (s *CRUDService) AfterInsert(bean interface{})
- func (s *CRUDService) AfterUpdate(bean interface{})
- func (s *CRUDService) BeforeDelete(bean interface{})
- func (s *CRUDService) BeforeInsert(bean interface{})
- func (s *CRUDService) BeforeUpdate(bean interface{})
- func (s *CRUDService) DB() *xorm.Engine
- func (s *CRUDService) Delete(id interface{}, bean interface{}) error
- func (s *CRUDService) Deletes(ids []interface{}, bean interface{}) error
- func (s *CRUDService) Get(id interface{}, bean interface{}) error
- func (s *CRUDService) Insert(bean interface{}) error
- func (s *CRUDService) Query(m *QueryParam, bean interface{}, beans interface{}) (int64, error)
- func (s *CRUDService) Session() *xorm.Session
- func (s *CRUDService) SetDB(db *xorm.Engine)
- func (s *CRUDService) SetSession(session *xorm.Session)
- func (s *CRUDService) Update(id interface{}, bean interface{}, fields []string) error
- type Condition
- type ICRUDEvent
- type ICRUDService
- type QueryParam
- func (q *QueryParam) Cols(session *xorm.Session) error
- func (q *QueryParam) Filter(session *xorm.Session) error
- func (q *QueryParam) GetItems(session *xorm.Session) error
- func (q *QueryParam) HandleSqlConditions(sql *string) (args []interface{}, err error)
- func (q *QueryParam) HandleSqlOrders(session *xorm.Session) string
- func (q *QueryParam) Limit(session *xorm.Session)
- func (q *QueryParam) NewCondition(Field string, Relation string, Operate string, Value interface{}) *QueryParam
- func (q *QueryParam) Orders(session *xorm.Session) error
- func (q *QueryParam) Query(sess *xorm.Session, bean interface{}, beans interface{}) (int64, error)
- func (q *QueryParam) SqlQuery(sess *xorm.Session, sql string, bean interface{}, beans interface{}, ...) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var InjectionMatch = regexp.MustCompile(`(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\b(select|update|and|or|delete|insert|trancate|char|chr|into|substr|ascii|declare|exec|count|master|into|drop|execute)\b)`)
SQL injection
Functions ¶
func HandleConditions ¶
func HandleConditions(session *xorm.Session, q *QueryParam) error
* @description: Attach QueryParam's Conditionss to session @param session: xorm.Session @param q: QueryParam @return: sql,count,error
Types ¶
type CRUDEvent ¶
type CRUDEvent struct {
ICRUDEvent
}
* @description: Struct Set ICRUDEvent Interface,Can Implement One or All Method s
type CRUDService ¶
type CRUDService struct {
// contains filtered or unexported fields
}
* @description: CRUDService @attribute db: Xorm DB Engine @attribute session: Xorm DB Engine Session @attribute event: CRUDEvent
func NewCRUD ¶
func NewCRUD(db *xorm.Engine, c ICRUDEvent) *CRUDService
* @description: NewCRUD @param db: Xorm Engine @param c: ICRUDEvent @return: CRUDService
func (*CRUDService) AfterDelete ¶
func (s *CRUDService) AfterDelete(bean interface{})
func (*CRUDService) AfterInsert ¶
func (s *CRUDService) AfterInsert(bean interface{})
func (*CRUDService) AfterUpdate ¶
func (s *CRUDService) AfterUpdate(bean interface{})
func (*CRUDService) BeforeDelete ¶
func (s *CRUDService) BeforeDelete(bean interface{})
func (*CRUDService) BeforeInsert ¶
func (s *CRUDService) BeforeInsert(bean interface{})
* @description: Some Implement Methods
func (*CRUDService) BeforeUpdate ¶
func (s *CRUDService) BeforeUpdate(bean interface{})
func (*CRUDService) DB ¶
func (s *CRUDService) DB() *xorm.Engine
* @description: DB @param : nil @return: xorm.Engine
func (*CRUDService) Delete ¶
func (s *CRUDService) Delete(id interface{}, bean interface{}) error
* @description: Delete One Record @param id: Record Id @param bean: Record Updated @return: error
func (*CRUDService) Deletes ¶
func (s *CRUDService) Deletes(ids []interface{}, bean interface{}) error
* @description: Delete Some Record @param id: Record Ids test @param bean: Record Updated @return: error
func (*CRUDService) Get ¶
func (s *CRUDService) Get(id interface{}, bean interface{}) error
* @description: Get The Record By Id @param id: Record Id @param bean: Record Updated @return: error
func (*CRUDService) Insert ¶
func (s *CRUDService) Insert(bean interface{}) error
* @description: Insert @param bean: insert record @return: error
func (*CRUDService) Query ¶
func (s *CRUDService) Query(m *QueryParam, bean interface{}, beans interface{}) (int64, error)
* @description: Query The Records @param m: Query Condition @param bean: Record @param beans: Records Return @return: Count And Error
func (*CRUDService) Session ¶
func (s *CRUDService) Session() *xorm.Session
* @description: Session @param : nil @return: Session
func (*CRUDService) SetDB ¶
func (s *CRUDService) SetDB(db *xorm.Engine)
* @description: Set The DB @param db: xorm.Engine @return:
func (*CRUDService) SetSession ¶
func (s *CRUDService) SetSession(session *xorm.Session)
* @description: SetSession @param session: xorm.Session @return:
func (*CRUDService) Update ¶
func (s *CRUDService) Update(id interface{}, bean interface{}, fields []string) error
* @description: Update @param id: Record Id @param bean: Record Updated @param fields: Update Some Fields @return: error
type Condition ¶
type Condition struct { Field string `json:"Field"` Relation string `json:"Relation"` Operate string `json:"Operate"` Value interface{} `json:"Value"` }
* @description: Condition @attribute Field: Field @attribute Relation: "and", "or" @attribute Operate: "like" , ">=" , "<=" , ">", "<", "nil" , "!=" , "in", "between" @attribute Value: Value
type ICRUDEvent ¶
type ICRUDEvent interface { BeforeInsert(bean interface{}) AfterInsert(bean interface{}) BeforeUpdate(bean interface{}) AfterUpdate(bean interface{}) BeforeDelete(bean interface{}) AfterDelete(bean interface{}) }
* @description: ICRUDEvent Interface,Can Implement One or All Methods @method BeforeInsert: the method before insert @method AfterInsert: the method after insert @method BeforeUpdate: the method before update @method AfterUpdate: the method after update @method BeforeDelete: the method before update @method AfterDelete: the method after update
type ICRUDService ¶
type ICRUDService interface { Insert(bean interface{}) error Update(id interface{}, bean interface{}, fields []string) error Delete(id interface{}, bean interface{}) error Deletes(ids []interface{}, bean interface{}) error Get(id interface{}, bean interface{}) error Query(m *QueryParam, bean interface{}, beans interface{}) (int64, error) }
* @description: ICRUDService Interface,Must Implement These Methods @method Insert: C @method Update: U @method Delete: D @method Deletes: D @method Get: Get One Record @method Query: R
type QueryParam ¶
type QueryParam struct { Size int `json:"size"` Index int `json:"index"` Count bool `json:"count"` Conditions []Condition `json:"conditions"` Order []map[string]int `json:"order"` Fields []map[string]int `json:"fields"` Params map[string]interface{} `json:"query"` }
* @description: QueryParam @attribute Size: Query Records Count @attribute Index: Query Records From Which Start @attribute Count: Is Calculate The Count of Records @attribute Conditions: Condition List @attribute Order: Orders Map,-1 Decs,1 Asc @attribute Fields: Select Which Columns @attribute Params: Some Other Params
func NewQuery ¶
func NewQuery() *QueryParam
* @description: NewQuery @param : nil @return: QueryParam
func (*QueryParam) Cols ¶
func (q *QueryParam) Cols(session *xorm.Session) error
* @description: Query Select Cols @param session: xorm.Session @return: error
func (*QueryParam) Filter ¶
func (q *QueryParam) Filter(session *xorm.Session) error
* @description: Query Filter Condition @param session: xorm.Session @return: error
func (*QueryParam) GetItems ¶
func (q *QueryParam) GetItems(session *xorm.Session) error
* @description: Query GetItems @param session: xorm.Session @return: error
func (*QueryParam) HandleSqlConditions ¶
func (q *QueryParam) HandleSqlConditions(sql *string) (args []interface{}, err error)
* @description: HandleSqlConditions,Parse QueryParam's Conditions to Sql @param sql: sql String @return: sql,count,error
func (*QueryParam) HandleSqlOrders ¶
func (q *QueryParam) HandleSqlOrders(session *xorm.Session) string
* @description: HandleSqlOrders,Parse QueryParam's Orders to Sql @param sql: sql String @return: sql,count,error
func (*QueryParam) Limit ¶
func (q *QueryParam) Limit(session *xorm.Session)
* @description: Query Limit @param session: xorm.Session @return:
func (*QueryParam) NewCondition ¶
func (q *QueryParam) NewCondition(Field string, Relation string, Operate string, Value interface{}) *QueryParam
* @description: NewCondition @param Field: nil @return: QueryParam
func (*QueryParam) Orders ¶
func (q *QueryParam) Orders(session *xorm.Session) error
* @description: Query Orders @param session: xorm.Session @return: error
func (*QueryParam) Query ¶
func (q *QueryParam) Query(sess *xorm.Session, bean interface{}, beans interface{}) (int64, error)
* @description: Query @param session: xorm.Session @param bean: Use For Counting Of The Results @param beans: Use For Storing The Results @return: count,error
func (*QueryParam) SqlQuery ¶
func (q *QueryParam) SqlQuery(sess *xorm.Session, sql string, bean interface{}, beans interface{}, sqlArgs ...interface{}) (int64, error)
* @description: Query By Sql String @param session: xorm.Session @param sql: Sql String @param bean: Use For Counting Of The Results @param beans: Use For Storing The Results @param sqlArgs: params from Sql String @return: count,error