|
@@ -53,7 +53,9 @@ func (repository *CompanyRepository) Save(company *domain.Company) (*domain.Comp |
|
@@ -53,7 +53,9 @@ func (repository *CompanyRepository) Save(company *domain.Company) (*domain.Comp |
53
|
&company.UpdateAt,
|
53
|
&company.UpdateAt,
|
54
|
&company.DeleteAt,
|
54
|
&company.DeleteAt,
|
55
|
),
|
55
|
),
|
56
|
- fmt.Sprintf("INSERT INTO companys (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
|
56
|
+
|
|
|
57
|
+ fmt.Sprintf("INSERT INTO companies (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
|
|
|
58
|
+
|
57
|
company.CompanyId,
|
59
|
company.CompanyId,
|
58
|
company.CompanyInfo,
|
60
|
company.CompanyInfo,
|
59
|
company.CreateAt,
|
61
|
company.CreateAt,
|
|
@@ -71,7 +73,9 @@ func (repository *CompanyRepository) Save(company *domain.Company) (*domain.Comp |
|
@@ -71,7 +73,9 @@ func (repository *CompanyRepository) Save(company *domain.Company) (*domain.Comp |
71
|
&company.UpdateAt,
|
73
|
&company.UpdateAt,
|
72
|
&company.DeleteAt,
|
74
|
&company.DeleteAt,
|
73
|
),
|
75
|
),
|
74
|
- fmt.Sprintf("UPDATE companys SET %s WHERE company_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
|
76
|
+
|
|
|
77
|
+ fmt.Sprintf("UPDATE companies SET %s WHERE company_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
|
|
|
78
|
+
|
75
|
company.CompanyId,
|
79
|
company.CompanyId,
|
76
|
company.CompanyInfo,
|
80
|
company.CompanyInfo,
|
77
|
company.CreateAt,
|
81
|
company.CreateAt,
|
|
@@ -115,21 +119,23 @@ func (repository *CompanyRepository) FindOne(queryOptions map[string]interface{} |
|
@@ -115,21 +119,23 @@ func (repository *CompanyRepository) FindOne(queryOptions map[string]interface{} |
115
|
func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Company, error) {
|
119
|
func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Company, error) {
|
116
|
tx := repository.transactionContext.PgTx
|
120
|
tx := repository.transactionContext.PgTx
|
117
|
var companyModels []*models.Company
|
121
|
var companyModels []*models.Company
|
118
|
- companys := make([]*domain.Company, 0)
|
122
|
+
|
|
|
123
|
+ companies := make([]*domain.Company, 0)
|
|
|
124
|
+
|
119
|
query := sqlbuilder.BuildQuery(tx.Model(&companyModels), queryOptions)
|
125
|
query := sqlbuilder.BuildQuery(tx.Model(&companyModels), queryOptions)
|
120
|
query.SetOffsetAndLimit(20)
|
126
|
query.SetOffsetAndLimit(20)
|
121
|
query.SetOrderDirect("company_id", "DESC")
|
127
|
query.SetOrderDirect("company_id", "DESC")
|
122
|
if count, err := query.SelectAndCount(); err != nil {
|
128
|
if count, err := query.SelectAndCount(); err != nil {
|
123
|
- return 0, companys, err
|
129
|
+ return 0, companies, err
|
124
|
} else {
|
130
|
} else {
|
125
|
for _, companyModel := range companyModels {
|
131
|
for _, companyModel := range companyModels {
|
126
|
if company, err := transform.TransformToCompanyDomainModelFromPgModels(companyModel); err != nil {
|
132
|
if company, err := transform.TransformToCompanyDomainModelFromPgModels(companyModel); err != nil {
|
127
|
- return 0, companys, err
|
133
|
+ return 0, companies, err
|
128
|
} else {
|
134
|
} else {
|
129
|
- companys = append(companys, company)
|
135
|
+ companies = append(companies, company)
|
130
|
}
|
136
|
}
|
131
|
}
|
137
|
}
|
132
|
- return int64(count), companys, nil
|
138
|
+ return int64(count), companies, nil
|
133
|
}
|
139
|
}
|
134
|
}
|
140
|
}
|
135
|
func NewCompanyRepository(transactionContext *pgTransaction.TransactionContext) (*CompanyRepository, error) {
|
141
|
func NewCompanyRepository(transactionContext *pgTransaction.TransactionContext) (*CompanyRepository, error) {
|