...
|
...
|
@@ -53,7 +53,9 @@ func (repository *CompanyRepository) Save(company *domain.Company) (*domain.Comp |
|
|
&company.UpdateAt,
|
|
|
&company.DeleteAt,
|
|
|
),
|
|
|
fmt.Sprintf("INSERT INTO companys (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
|
|
|
|
|
|
fmt.Sprintf("INSERT INTO companies (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
|
|
|
|
|
|
company.CompanyId,
|
|
|
company.CompanyInfo,
|
|
|
company.CreateAt,
|
...
|
...
|
@@ -71,7 +73,9 @@ func (repository *CompanyRepository) Save(company *domain.Company) (*domain.Comp |
|
|
&company.UpdateAt,
|
|
|
&company.DeleteAt,
|
|
|
),
|
|
|
fmt.Sprintf("UPDATE companys SET %s WHERE company_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
|
|
|
|
|
|
fmt.Sprintf("UPDATE companies SET %s WHERE company_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
|
|
|
|
|
|
company.CompanyId,
|
|
|
company.CompanyInfo,
|
|
|
company.CreateAt,
|
...
|
...
|
@@ -115,21 +119,23 @@ func (repository *CompanyRepository) FindOne(queryOptions map[string]interface{} |
|
|
func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Company, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
var companyModels []*models.Company
|
|
|
companys := make([]*domain.Company, 0)
|
|
|
|
|
|
companies := make([]*domain.Company, 0)
|
|
|
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(&companyModels), queryOptions)
|
|
|
query.SetOffsetAndLimit(20)
|
|
|
query.SetOrderDirect("company_id", "DESC")
|
|
|
if count, err := query.SelectAndCount(); err != nil {
|
|
|
return 0, companys, err
|
|
|
return 0, companies, err
|
|
|
} else {
|
|
|
for _, companyModel := range companyModels {
|
|
|
if company, err := transform.TransformToCompanyDomainModelFromPgModels(companyModel); err != nil {
|
|
|
return 0, companys, err
|
|
|
return 0, companies, err
|
|
|
} else {
|
|
|
companys = append(companys, company)
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
}
|
|
|
return int64(count), companys, nil
|
|
|
return int64(count), companies, nil
|
|
|
}
|
|
|
}
|
|
|
func NewCompanyRepository(transactionContext *pgTransaction.TransactionContext) (*CompanyRepository, error) {
|
...
|
...
|
|