...
|
...
|
@@ -23,7 +23,7 @@ func NewOrderBaseRepository(transactionContext *transaction.TransactionContext) |
|
|
return &OrderBaseRepository{transactionContext: transactionContext}, nil
|
|
|
}
|
|
|
|
|
|
func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel *models.OrderBase) (order domain.OrderBase, err error) {
|
|
|
func (repository OrderBaseRepository) transformPgModelToDomainModel(orderModel *models.OrderBase) (order domain.OrderBase, err error) {
|
|
|
order = domain.OrderBase{
|
|
|
Id: orderModel.Id, OrderType: orderModel.OrderType, OrderCode: orderModel.OrderCode,
|
|
|
DeliveryCode: orderModel.DeliveryCode, Buyer: orderModel.Buyer, RegionInfo: orderModel.RegionInfo,
|
...
|
...
|
@@ -50,10 +50,10 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel |
|
|
return order, nil
|
|
|
}
|
|
|
|
|
|
func (reponsitory OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
|
|
|
func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
|
|
|
var (
|
|
|
err error
|
|
|
tx = reponsitory.transactionContext.PgTx
|
|
|
tx = repository.transactionContext.PgTx
|
|
|
)
|
|
|
m := &models.OrderBase{
|
|
|
Id: orderInfo.Id, OrderType: orderInfo.OrderType, OrderCode: orderInfo.OrderCode,
|
...
|
...
|
@@ -90,8 +90,8 @@ func (reponsitory OrderBaseRepository) Save(orderInfo *domain.OrderBase) error { |
|
|
return err
|
|
|
}
|
|
|
|
|
|
func (reponsitory OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery) ([]domain.OrderBase, int, error) {
|
|
|
db := reponsitory.transactionContext.GetDB()
|
|
|
func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery) ([]domain.OrderBase, int, error) {
|
|
|
db := repository.transactionContext.GetDB()
|
|
|
orderModels := []models.OrderBase{}
|
|
|
query := db.Model(&orderModels)
|
|
|
if queryOption.PartnerId > 0 {
|
...
|
...
|
@@ -127,7 +127,7 @@ func (reponsitory OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuer |
|
|
return ordersReturn, 0, err
|
|
|
}
|
|
|
for i := range orderModels {
|
|
|
domainOrder, err := reponsitory.transformPgModelToDomainModel(&orderModels[i])
|
|
|
domainOrder, err := repository.transformPgModelToDomainModel(&orderModels[i])
|
|
|
if err != nil {
|
|
|
return ordersReturn, 0, err
|
|
|
}
|
...
|
...
|
@@ -136,29 +136,29 @@ func (reponsitory OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuer |
|
|
return ordersReturn, count, nil
|
|
|
}
|
|
|
|
|
|
func (reponsitory OrderBaseRepository) FindOne(qureyOptions domain.OrderBaseFindOneQuery) (*domain.OrderBase, error) {
|
|
|
func (repository OrderBaseRepository) FindOne(queryOptions domain.OrderBaseFindOneQuery) (*domain.OrderBase, error) {
|
|
|
var (
|
|
|
err error
|
|
|
tx = reponsitory.transactionContext.PgDd
|
|
|
tx = repository.transactionContext.PgDd
|
|
|
)
|
|
|
m := new(models.OrderBase)
|
|
|
query := tx.Model(m).
|
|
|
Where("id=?", qureyOptions.OrderId)
|
|
|
if qureyOptions.CompanyId > 0 {
|
|
|
query = query.Where("company_id=?", qureyOptions.CompanyId)
|
|
|
Where("id=?", queryOptions.OrderId)
|
|
|
if queryOptions.CompanyId > 0 {
|
|
|
query = query.Where("company_id=?", queryOptions.CompanyId)
|
|
|
}
|
|
|
err = query.First()
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
result, err := reponsitory.transformPgModelToDomainModel(m)
|
|
|
result, err := repository.transformPgModelToDomainModel(m)
|
|
|
return &result, err
|
|
|
}
|
|
|
|
|
|
func (reponsitory OrderBaseRepository) Remove(id int64, companyId int64) error {
|
|
|
func (repository OrderBaseRepository) Remove(id int64, companyId int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
tx = reponsitory.transactionContext.PgTx
|
|
|
tx = repository.transactionContext.PgTx
|
|
|
)
|
|
|
m := &models.OrderBase{
|
|
|
Id: id,
|
...
|
...
|
|