This commit is contained in:
zhouwentao 2026-01-24 10:04:53 +08:00
parent 85819798ca
commit ee8c304284
3 changed files with 11 additions and 6 deletions

Binary file not shown.

View File

@ -38,6 +38,10 @@ type UserMajorDTO struct {
// PrivateStudentScore float64 `json:"privateStudentScore"` // 学生折合分(私有) // PrivateStudentScore float64 `json:"privateStudentScore"` // 学生折合分(私有)
// StudentConvertedScore float64 `json:"studentConvertedScore"` // 学生折合分(转换后) // StudentConvertedScore float64 `json:"studentConvertedScore"` // 学生折合分(转换后)
// FirstLevelDiscipline string `json:"firstLevelDiscipline"` // 一级学科 (需确认来源) // FirstLevelDiscipline string `json:"firstLevelDiscipline"` // 一级学科 (需确认来源)
Province string `json:"province"` // 省份
SchoolNature string `json:"schoolNature"` // 院校性质
InstitutionType string `json:"institutionType"` // 院校类型
} }
// SchoolMajorDTO 院校专业查询结果 DTO // SchoolMajorDTO 院校专业查询结果 DTO

View File

@ -125,8 +125,8 @@ func (m *YxCalculationMajorMapper) FindRecommendList(query dto.SchoolMajorQuery)
cm.limitation, cm.limitation,
cm.other_score_limitation, cm.other_score_limitation,
s.province as province, s.province as province,
s.school_nature as schoolNature, s.school_nature,
s.institution_type as institutionType s.institution_type
FROM %s cm FROM %s cm
LEFT JOIN yx_school_child sc ON sc.school_code = cm.school_code LEFT JOIN yx_school_child sc ON sc.school_code = cm.school_code
LEFT JOIN yx_school_research_teaching srt ON srt.school_id = sc.school_id LEFT JOIN yx_school_research_teaching srt ON srt.school_id = sc.school_id
@ -146,6 +146,7 @@ func (m *YxCalculationMajorMapper) FindRecommendList(query dto.SchoolMajorQuery)
mainSQL += " AND (cm.enroll_probability >= 93)" mainSQL += " AND (cm.enroll_probability >= 93)"
} }
mainSQL += " ORDER BY cm.enroll_probability DESC"
// 6. 分页参数合法性校验 // 6. 分页参数合法性校验
page := query.Page page := query.Page
size := query.Size size := query.Size
@ -182,7 +183,7 @@ func (m *YxCalculationMajorMapper) FindRecommendList(query dto.SchoolMajorQuery)
countErr = config.DB.Raw(countSQL, params...).Count(&total).Error countErr = config.DB.Raw(countSQL, params...).Count(&total).Error
// 计算该协程耗时,通过互斥锁安全写入共享变量 // 计算该协程耗时,通过互斥锁安全写入共享变量
mu.Lock() mu.Lock()
queryCost.CountCost = time.Now().Sub(start) queryCost.CountCost = time.Since(start)
mu.Unlock() mu.Unlock()
}() }()
@ -194,7 +195,7 @@ func (m *YxCalculationMajorMapper) FindRecommendList(query dto.SchoolMajorQuery)
probCountErr = config.DB.Raw(probCountSQL, params...).Scan(&probCount).Error probCountErr = config.DB.Raw(probCountSQL, params...).Scan(&probCount).Error
// 计算该协程耗时,通过互斥锁安全写入共享变量 // 计算该协程耗时,通过互斥锁安全写入共享变量
mu.Lock() mu.Lock()
queryCost.ProbCountCost = time.Now().Sub(start) queryCost.ProbCountCost = time.Since(start)
mu.Unlock() mu.Unlock()
}() }()
@ -206,14 +207,14 @@ func (m *YxCalculationMajorMapper) FindRecommendList(query dto.SchoolMajorQuery)
queryErr = config.DB.Raw(mainSQL, params...).Scan(&items).Error queryErr = config.DB.Raw(mainSQL, params...).Scan(&items).Error
// 计算该协程耗时,通过互斥锁安全写入共享变量 // 计算该协程耗时,通过互斥锁安全写入共享变量
mu.Lock() mu.Lock()
queryCost.QueryCost = time.Now().Sub(start) queryCost.QueryCost = time.Since(start)
mu.Unlock() mu.Unlock()
}() }()
wg.Wait() wg.Wait()
// 计算整体总耗时 // 计算整体总耗时
queryCost.TotalCost = time.Now().Sub(totalStartTime) queryCost.TotalCost = time.Since(totalStartTime)
// 打印各协程耗时和总耗时(按需输出,可注释或删除) // 打印各协程耗时和总耗时(按需输出,可注释或删除)
fmt.Printf("各查询耗时统计:\n") fmt.Printf("各查询耗时统计:\n")