作者 yangfu

索引优化

... ... @@ -58,6 +58,8 @@ type SearchCooperationProjectQuery struct {
SearchCooperationProjectExtQueries []*SearchCooperationProjectExtQuery `cname:"额外的查询条件" json:"searchCooperationProjectExtQueries"`
// 按共创项目状态排序
SortByStatus int32 `cname:"按共创项目状态排序" json:"sortByStatus,omitempty"`
// 是否跳过获取共创模式
IsSkipFetchProjectModel bool `cname:"是否跳过获取共创模式" json:"isSkipFetchProjectModel,omitempty"`
}
func (searchCooperationProjectQuery *SearchCooperationProjectQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -341,6 +341,14 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
} else {
if count > 0 {
for _, cooperationProjectModel := range cooperationProjectModels {
if v, ok := queryOptions["isSkipFetchProjectModel"]; ok && v.(bool) {
if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, &models.CooperationMode{}); err != nil {
return 0, cooperationProjects, err
} else {
cooperationProjects = append(cooperationProjects, cooperationProject)
}
continue
}
// 获取共创模式
var cooperationModeModels []*models.CooperationMode
cooperationModeQuery := tx.Model(&cooperationModeModels)
... ...