作者 陈志颖

fix:共创项目编号查询

... ... @@ -34,7 +34,6 @@ type SearchCooperationProjectQuery struct {
}
func (searchCooperationProjectQuery *SearchCooperationProjectQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (searchCooperationProjectQuery *SearchCooperationProjectQuery) ValidateQuery() error {
... ...
... ... @@ -269,17 +269,19 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
if count, err := query.SelectAndCount(); err != nil {
return 0, cooperationProjects, err
} else {
for _, cooperationProjectModel := range cooperationProjectModels {
// 获取共创模式
cooperationModeModel := new(models.CooperationMode)
cooperationModeQuery := tx.Model(cooperationModeModel)
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
return 0, nil, err
}
if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil {
return 0, cooperationProjects, err
} else {
cooperationProjects = append(cooperationProjects, cooperationProject)
if count > 0 {
for _, cooperationProjectModel := range cooperationProjectModels {
// 获取共创模式
cooperationModeModel := new(models.CooperationMode)
cooperationModeQuery := tx.Model(cooperationModeModel)
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil {
return 0, nil, err
}
if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil {
return 0, cooperationProjects, err
} else {
cooperationProjects = append(cooperationProjects, cooperationProject)
}
}
}
return int64(count), cooperationProjects, nil
... ...