...
|
...
|
@@ -175,32 +175,12 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf |
|
|
if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
|
|
|
query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
|
|
|
}
|
|
|
query.SetOffsetAndLimit(20)
|
|
|
query.SetOrderDirect("cooperation_mode_id", "DESC")
|
|
|
if count, err := query.SelectAndCount(); err != nil {
|
|
|
return 0, cooperationModes, err
|
|
|
} else {
|
|
|
for _, cooperationModeModel := range cooperationModeModels {
|
|
|
if cooperationMode, err := transform.TransformToCooperationModeDomainModelFromPgModels(cooperationModeModel); err != nil {
|
|
|
return 0, cooperationModes, err
|
|
|
} else {
|
|
|
cooperationModes = append(cooperationModes, cooperationMode)
|
|
|
}
|
|
|
}
|
|
|
return int64(count), cooperationModes, nil
|
|
|
offsetLimitFlag := true
|
|
|
if limit, ok := queryOptions["limit"]; ok {
|
|
|
offsetLimitFlag = limit.(bool)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (repository *CooperationModeRepository) FindAll(queryOptions map[string]interface{}) (int64, []*domain.CooperationMode, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
var cooperationModeModels []*models.CooperationMode
|
|
|
cooperationModes := make([]*domain.CooperationMode, 0)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(&cooperationModeModels), queryOptions)
|
|
|
if cooperationModeName, ok := queryOptions["cooperationModeName"]; ok && cooperationModeName != "" {
|
|
|
query.Where("cooperation_mode_name like ?", fmt.Sprintf("%%%s%%", cooperationModeName))
|
|
|
}
|
|
|
if organizationName, ok := queryOptions["organizationName"]; ok && organizationName != "" {
|
|
|
query.Where("org->>'orgName' like ?", fmt.Sprintf("%%%s%%", organizationName))
|
|
|
if offsetLimitFlag {
|
|
|
query.SetOffsetAndLimit(20)
|
|
|
}
|
|
|
query.SetOrderDirect("cooperation_mode_id", "DESC")
|
|
|
if count, err := query.SelectAndCount(); err != nil {
|
...
|
...
|
|