本文整理匯總了Golang中github.com/elivoa/got/db.QueryParser類的典型用法代碼示例。如果您正苦於以下問題:Golang QueryParser類的具體用法?Golang QueryParser怎麽用?Golang QueryParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QueryParser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ListPersonByIdSet
func ListPersonByIdSet(ids ...int64) (map[int64]*model.Person, error) {
if nil == ids || len(ids) == 0 {
return nil, nil
}
var query *db.QueryParser
parser := em.Select().Where()
query = parser.InInt64(em.PK, ids...).OrderBy(em.PK, db.DESC)
models := make([]*model.Person, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
p := new(model.Person)
err := rows.Scan(
&p.Id, &p.Name, &p.Type, &p.Phone, &p.City, &p.Address, &p.PostalCode, &p.QQ,
&p.Website, &p.Note, &p.AccountBallance, &p.CreateTime, &p.UpdateTime,
)
models = append(models, p)
return true, err
},
); err != nil {
return nil, err
}
// return the map
var resultmap = map[int64]*model.Person{}
for _, u := range models {
resultmap[int64(u.Id)] = u
}
return resultmap, nil
}
示例2: ListUserAction
func ListUserAction(parser *db.QueryParser) ([]*model.UserAction, error) {
parser.SetEntity(historyEm) // set entity manager into query parser.
parser.Reset() // to prevent if parser is used before. TODO:Is this necessary?
// append default behavore.
parser.DefaultOrderBy("create_time", db.DESC)
parser.DefaultLimit(0, config.LIST_PAGE_SIZE)
parser.Select()
return _listUserAction(parser)
}
示例3: List
func List(parser *db.QueryParser) ([]*model.InventoryGroup, error) {
// var query *db.QueryParser
parser.SetEntity(em) // set entity manager into query parser.
parser.Reset() // to prevent if parser is used before. TODO:Is this necessary?
// append default behavore.
parser.DefaultOrderBy("send_time", db.DESC)
parser.DefaultLimit(0, config.LIST_PAGE_SIZE)
parser.Select()
return _list(parser)
}
示例4: _list
// the last part, read the list from rows
func _list(query *db.QueryParser) ([]*model.Const, error) {
models := make([]*model.Const, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
m := &model.Const{}
err := rows.Scan(&m.Id, &m.Name, &m.Key, &m.Value, &m.FloatValue, &m.Time)
models = append(models, m)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例5: _one
// only return the first result;
func _one(query *db.QueryParser) (*model.Person, error) {
m := &model.Person{}
if err := query.Query( // TODO: change to QueryOne
func(rows *sql.Rows) (bool, error) {
err := rows.Scan(
&m.Id, &m.Name, &m.Type, &m.Phone, &m.City, &m.Address, &m.PostalCode, &m.QQ,
&m.Website, &m.Note, &m.AccountBallance, &m.CreateTime, &m.UpdateTime,
)
return false, err // don't fetch the second line. first is enough;
},
); err != nil {
return nil, err
}
return m, nil
}
示例6: list_incoming
// list_incoming is an common function that accept a query and query a list of result, and error.
func list_incoming(query *db.QueryParser) ([]*model.AccountIncoming, error) {
incomings := make([]*model.AccountIncoming, 0)
err := query.Query(
func(rows *sql.Rows) (bool, error) {
p := new(model.AccountIncoming)
err := rows.Scan(&p.Id, &p.CustomeId, &p.Incoming, &p.Time)
incomings = append(incomings, p)
return true, err
},
)
if err != nil {
return nil, err
}
return incomings, nil
}
示例7: _listUserAction
// the last part, read the list from rows
func _listUserAction(query *db.QueryParser) ([]*model.UserAction, error) {
models := make([]*model.UserAction, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
m := &model.UserAction{}
err := rows.Scan(
&m.Id, &m.UserId, &m.Action, &m.Context, &m.CreateTime,
)
models = append(models, m)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例8: _list
// the last part, read the list from rows
func _list(query *db.QueryParser) ([]*model.Person, error) {
models := make([]*model.Person, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
m := &model.Person{}
err := rows.Scan(
&m.Id, &m.Name, &m.Type, &m.Phone, &m.City, &m.Address, &m.PostalCode, &m.QQ,
&m.Website, &m.Note, &m.AccountBallance, &m.CreateTime, &m.UpdateTime,
)
models = append(models, m)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例9: _list
func _list(query *db.QueryParser) ([]*model.Product, error) {
models := make([]*model.Product, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
m := &model.Product{}
err := rows.Scan(
&m.Id, &m.Name, &m.ProductId, &m.Status, &m.Brand, &m.Price, &m.Supplier, &m.FactoryPrice,
&m.Stock, &m.ShelfNo, &m.Capital, &m.Note, &m.Pictures, &m.CreateTime, &m.UpdateTime,
)
models = append(models, m)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例10: _list
// the last part, read the list from rows
func _list(query *db.QueryParser) ([]*model.FactorySettleAccount, error) {
models := make([]*model.FactorySettleAccount, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
m := &model.FactorySettleAccount{}
err := rows.Scan(
&m.Id, &m.FactoryId, &m.GoodsDescription, &m.FromTime, &m.SettleTime,
&m.ShouldPay, &m.Paid, &m.Note, &m.Operator,
)
models = append(models, m)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例11: _list
func _list(query *db.QueryParser) ([]*model.User, error) {
models := make([]*model.User, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
p := &model.User{}
err := rows.Scan(
&p.Id, &p.Username, &p.Password, &p.Gender, &p.QQ, &p.Mobile, &p.City, &p.Role,
&p.Store, &p.CreateTime, &p.UpdateTime,
)
models = append(models, p)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例12: _list
// the last part, read the list from rows
func _list(query *db.QueryParser) ([]*model.InventoryTrackItem, error) {
models := make([]*model.InventoryTrackItem, 0)
if err := query.Query(
func(rows *sql.Rows) (bool, error) {
m := &model.InventoryTrackItem{}
err := rows.Scan(
&m.Id, &m.ProductId, &m.Color, &m.Size, &m.StockChagneTo, &m.OldStock, &m.Delta,
&m.UserId, &m.UserId, &m.Reason, &m.Context, &m.Time,
)
models = append(models, m)
return true, err
},
); err != nil {
return nil, err
}
return models, nil
}
示例13: _one
func _one(query *db.QueryParser) (*model.Product, error) {
m := new(model.Product)
err := query.Query(
func(rows *sql.Rows) (bool, error) {
return false, rows.Scan(
&m.Id, &m.Name, &m.ProductId, &m.Status, &m.Brand, &m.Price, &m.Supplier, &m.FactoryPrice,
&m.Stock, &m.ShelfNo, &m.Capital, &m.Note, &m.Pictures, &m.CreateTime, &m.UpdateTime,
)
},
)
if err != nil {
return nil, err
}
if m.Id > 0 {
return m, nil
}
return nil, nil
}
示例14: _one
func _one(query *db.QueryParser) (*model.InventoryGroup, error) {
m := new(model.InventoryGroup)
err := query.Query(
func(rows *sql.Rows) (bool, error) {
return false, rows.Scan(
&m.Id, &m.Status, &m.Type, &m.Note, &m.ProviderId, &m.OperatorId,
&m.Summary, &m.TotalQuantity, &m.SendTime, &m.ReceiveTime, &m.CreateTime, &m.UpdateTime,
)
},
)
if err != nil {
return nil, err
}
if m.Id > 0 {
return m, nil
}
return nil, nil
}
示例15: list_account_changelog
// list_incoming is an common function that accept a query and query a list of result, and error.
func list_account_changelog(query *db.QueryParser) ([]*model.AccountChangeLog, error) {
changeLogs := make([]*model.AccountChangeLog, 0)
err := query.Query(
func(rows *sql.Rows) (bool, error) {
p := new(model.AccountChangeLog)
err := rows.Scan(
&p.Id, &p.CustomerId, &p.Delta, &p.Account, &p.Type,
&p.RelatedOrderTN, &p.Reason, &p.Time,
)
changeLogs = append(changeLogs, p)
return true, err
},
)
if err != nil {
return nil, err
}
return changeLogs, nil
}