...
|
...
|
@@ -191,6 +191,32 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf |
|
|
}
|
|
|
}
|
|
|
|
|
|
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))
|
|
|
}
|
|
|
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
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func NewCooperationModeRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationModeRepository, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|