order.go 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. package dao
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. )
  5. // QueryOrder query order info: ps : pageNumber pn: pageSize
  6. func (d *Dao) QueryOrder(order *model.Order, pn int32, ps int32) (qor *model.QueryOrderResponse, err error) {
  7. qor = &model.QueryOrderResponse{}
  8. err = d.DB.Table(model.Order{}.TableName()).Where(model.Order{
  9. ID: order.ID, Name: order.Name, Broker: order.Broker, Type: order.Type, TestType: order.TestType,
  10. Project: order.Project, Department: order.Department, App: order.App, Status: order.Status, UpdateBy: order.UpdateBy,
  11. Active: 1, Handler: order.Handler}).Count(&qor.TotalSize).Offset((pn - 1) * ps).Limit(ps).Order("id desc").Find(&qor.Orders).Error
  12. qor.PageSize = ps
  13. qor.PageNum = pn
  14. return
  15. }
  16. // AddOrder add order by order object
  17. func (d *Dao) AddOrder(order *model.Order) error {
  18. return d.DB.Table(model.Order{}.TableName()).Create(order).Error
  19. }
  20. // UpdateOrder update order by order object
  21. func (d *Dao) UpdateOrder(order *model.Order) error {
  22. return d.DB.Model(&model.Order{}).Update(order).Where("ID=?", order.ID).Error
  23. }
  24. // DelOrder delete order by orderID
  25. func (d *Dao) DelOrder(id int64) error {
  26. return d.DB.Model(&model.Order{}).Where("ID=?", id).Update("active", -1).Error
  27. }