...
|
...
|
@@ -38,19 +38,13 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec |
|
|
"product_record_info",
|
|
|
"ext",
|
|
|
}
|
|
|
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
|
|
|
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
|
|
|
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_record_id", "deleted_at"))
|
|
|
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_record_id", "deleted_at"))
|
|
|
returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
|
|
|
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "productRecord_id")
|
|
|
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_record_id", "deleted_at")
|
|
|
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
if productRecord.Identify() == nil {
|
|
|
productRecordId, err := repository.nextIdentify()
|
|
|
if err != nil {
|
|
|
return productRecord, err
|
|
|
} else {
|
|
|
productRecord.ProductRecordId = int(productRecordId)
|
|
|
}
|
|
|
if _, err := tx.QueryOne(
|
|
|
pg.Scan(
|
|
|
&productRecord.ProductRecordId,
|
...
|
...
|
@@ -65,8 +59,8 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec |
|
|
&productRecord.ProductRecordInfo,
|
|
|
&productRecord.Ext,
|
|
|
),
|
|
|
fmt.Sprintf("INSERT INTO product_records (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
|
|
|
productRecord.ProductRecordId,
|
|
|
fmt.Sprintf("INSERT INTO manufacture.product_records (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
|
|
|
//productRecord.ProductRecordId,
|
|
|
productRecord.CompanyId,
|
|
|
productRecord.OrgId,
|
|
|
productRecord.ProductRecordType,
|
...
|
...
|
@@ -74,7 +68,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec |
|
|
productRecord.WorkStation,
|
|
|
productRecord.CreatedAt,
|
|
|
productRecord.UpdatedAt,
|
|
|
productRecord.DeletedAt,
|
|
|
//productRecord.DeletedAt,
|
|
|
productRecord.ProductRecordInfo,
|
|
|
productRecord.Ext,
|
|
|
); err != nil {
|
...
|
...
|
@@ -95,8 +89,8 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec |
|
|
&productRecord.ProductRecordInfo,
|
|
|
&productRecord.Ext,
|
|
|
),
|
|
|
fmt.Sprintf("UPDATE product_records SET %s WHERE product_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
|
|
|
productRecord.ProductRecordId,
|
|
|
fmt.Sprintf("UPDATE manufacture.product_records SET %s WHERE product_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
|
|
|
//productRecord.ProductRecordId,
|
|
|
productRecord.CompanyId,
|
|
|
productRecord.OrgId,
|
|
|
productRecord.ProductRecordType,
|
...
|
...
|
@@ -104,7 +98,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec |
|
|
productRecord.WorkStation,
|
|
|
productRecord.CreatedAt,
|
|
|
productRecord.UpdatedAt,
|
|
|
productRecord.DeletedAt,
|
|
|
//productRecord.DeletedAt,
|
|
|
productRecord.ProductRecordInfo,
|
|
|
productRecord.Ext,
|
|
|
productRecord.Identify(),
|
...
|
...
|
|