From 9b72804e7bb3ee6fe6e97d25e24ea9d7e098287b Mon Sep 17 00:00:00 2001 From: zhouwentao Date: Thu, 1 Jan 2026 22:52:16 +0800 Subject: [PATCH] updates --- server/docs/docs.go | 78 +++++++++++-------- server/docs/swagger.json | 78 +++++++++++-------- server/docs/swagger.yaml | 52 ++++++++----- .../user/controller/user_major_controller.go | 5 ++ .../user/service/user_score_service.go | 8 +- server/modules/yx/dto/yx_school_major_dto.go | 6 +- 6 files changed, 138 insertions(+), 89 deletions(-) diff --git a/server/docs/docs.go b/server/docs/docs.go index b88b4c4..7f524c6 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -282,38 +282,6 @@ const docTemplate = `{ } } }, - "/user//major/list": { - "get": { - "tags": [ - "用户专业" - ], - "summary": "获取当前用户可检索列表", - "parameters": [ - { - "type": "integer", - "default": 1, - "description": "页码", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "每页数量", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/common.Response" - } - } - } - } - }, "/user/auth/info": { "get": { "tags": [ @@ -379,6 +347,52 @@ const docTemplate = `{ } } }, + "/user/major/list": { + "get": { + "tags": [ + "用户专业" + ], + "summary": "获取当前用户可检索列表", + "parameters": [ + { + "type": "integer", + "default": 1, + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "每页数量", + "name": "size", + "in": "query" + }, + { + "type": "string", + "default": "\"\"", + "description": "批次(本科提前批/本科A段/本科B段/本科/高职高专)", + "name": "batch", + "in": "query" + }, + { + "type": "string", + "default": "\"\"", + "description": "录取概率类型(难录取/可冲击/较稳妥/可保底)", + "name": "probability", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/common.Response" + } + } + } + } + }, "/user/score": { "get": { "tags": [ diff --git a/server/docs/swagger.json b/server/docs/swagger.json index 98fe964..fd6031b 100644 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -276,38 +276,6 @@ } } }, - "/user//major/list": { - "get": { - "tags": [ - "用户专业" - ], - "summary": "获取当前用户可检索列表", - "parameters": [ - { - "type": "integer", - "default": 1, - "description": "页码", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "每页数量", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/common.Response" - } - } - } - } - }, "/user/auth/info": { "get": { "tags": [ @@ -373,6 +341,52 @@ } } }, + "/user/major/list": { + "get": { + "tags": [ + "用户专业" + ], + "summary": "获取当前用户可检索列表", + "parameters": [ + { + "type": "integer", + "default": 1, + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "default": 10, + "description": "每页数量", + "name": "size", + "in": "query" + }, + { + "type": "string", + "default": "\"\"", + "description": "批次(本科提前批/本科A段/本科B段/本科/高职高专)", + "name": "batch", + "in": "query" + }, + { + "type": "string", + "default": "\"\"", + "description": "录取概率类型(难录取/可冲击/较稳妥/可保底)", + "name": "probability", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/common.Response" + } + } + } + } + }, "/user/score": { "get": { "tags": [ diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index dceae95..ac94e1a 100644 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -710,27 +710,6 @@ paths: summary: Sys用户登出 tags: - 认证 - /user//major/list: - get: - parameters: - - default: 1 - description: 页码 - in: query - name: page - type: integer - - default: 10 - description: 每页数量 - in: query - name: size - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/common.Response' - summary: 获取当前用户可检索列表 - tags: - - 用户专业 /user/auth/info: get: responses: @@ -772,6 +751,37 @@ paths: summary: 用户登出 tags: - 认证 + /user/major/list: + get: + parameters: + - default: 1 + description: 页码 + in: query + name: page + type: integer + - default: 10 + description: 每页数量 + in: query + name: size + type: integer + - default: '""' + description: 批次(本科提前批/本科A段/本科B段/本科/高职高专) + in: query + name: batch + type: string + - default: '""' + description: 录取概率类型(难录取/可冲击/较稳妥/可保底) + in: query + name: probability + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/common.Response' + summary: 获取当前用户可检索列表 + tags: + - 用户专业 /user/score: get: responses: diff --git a/server/modules/user/controller/user_major_controller.go b/server/modules/user/controller/user_major_controller.go index ddcfcb9..40db3ba 100644 --- a/server/modules/user/controller/user_major_controller.go +++ b/server/modules/user/controller/user_major_controller.go @@ -39,14 +39,19 @@ func (ctrl *UserMajorController) RegisterRoutes(rg *gin.RouterGroup) { // @Tags 用户专业 // @Param page query int false "页码" default(1) // @Param size query int false "每页数量" default(10) +// @Param batch query string false "批次(本科提前批/本科A段/本科B段/本科/高职高专)" default("") +// @Param probability query string false "录取概率类型(难录取/可冲击/较稳妥/可保底)" default("") // @Success 200 {object} common.Response // @Router /user/major/list [get] func (ctrl *UserMajorController) List(c *gin.Context) { page, _ := strconv.Atoi(c.DefaultQuery("page", "1")) size, _ := strconv.Atoi(c.DefaultQuery("size", "10")) schoolMajorQuery := yxDto.SchoolMajorQuery{ + Keyword: c.DefaultQuery("keyword", ""), Page: page, Size: size, + Batch: c.DefaultQuery("batch", ""), + Probability: c.DefaultQuery("probability", ""), LoginUserId: common.GetLoginUser(c).ID, } userScoreVO, err := ctrl.userScoreService.GetActiveByID(schoolMajorQuery.LoginUserId) diff --git a/server/modules/user/service/user_score_service.go b/server/modules/user/service/user_score_service.go index 4cbf417..76eb378 100644 --- a/server/modules/user/service/user_score_service.go +++ b/server/modules/user/service/user_score_service.go @@ -32,7 +32,7 @@ func (s *UserScoreService) GetUserScoreByUserId(id string) { // GetActiveByID 获取当前激活的成绩 func (s *UserScoreService) GetActiveByID(userID string) (vo.UserScoreVO, error) { var score entity.YxUserScore - + // 先从Redis获取是否存在 scoreRedisData, err := config.RDB.Get(context.Background(), common.RedisUserScorePrefix+userID).Result() if err != nil { // 明确指定字段,提高可读性 @@ -217,7 +217,6 @@ func (s *UserScoreService) convertEntityToVo(item entity.YxUserScore) vo.UserSco Type: item.Type, EducationalLevel: item.EducationalLevel, CognitioPolyclinic: item.CognitioPolyclinic, - SubjectList: strings.Split(item.Subjects, ","), ProfessionalCategory: item.ProfessionalCategory, ProfessionalCategoryChildren: []string{}, ProfessionalCategoryChildrenScore: make(map[string]float64), @@ -228,6 +227,11 @@ func (s *UserScoreService) convertEntityToVo(item entity.YxUserScore) vo.UserSco Province: item.Province, State: item.State, } + if item.Subjects == "" { + voItem.SubjectList = []string{} + } else { + voItem.SubjectList = strings.Split(item.Subjects, ",") + } if item.ProfessionalCategoryChildren == "" { voItem.ProfessionalCategoryChildren = []string{} diff --git a/server/modules/yx/dto/yx_school_major_dto.go b/server/modules/yx/dto/yx_school_major_dto.go index 98b2fea..4aacfc0 100644 --- a/server/modules/yx/dto/yx_school_major_dto.go +++ b/server/modules/yx/dto/yx_school_major_dto.go @@ -57,17 +57,19 @@ type YxHistoryMajorEnrollDTO struct { type SchoolMajorQuery struct { Page int `json:"page"` Size int `json:"size"` + Keyword string `json:"keyword"` // 对应 keyword MajorType string `json:"majorType"` // 对应 major_type Category string `json:"category"` // 对应 category - Batch string `json:"batch"` // 对应 batch + Batch string `json:"batch"` // 对应 批次 MajorTypeChildren []string `json:"majorTypeChildren"` // 对应 major_type_child in (...) MainSubjects string `json:"mainSubjects"` // 对应 main_subjects + Probability string `json:"probability"` // 对应 录取概率类型 ScoreId string `json:"scoreId"` // 对应 score_id TagList []string `json:"tagList"` // 对应 tags in (...) SchoolNatureList []string `json:"schoolNatureList"` // 对应 school_nature in (...) AddressList []string `json:"addressList"` // 对应 address in (...) KyjxList []string `json:"kyjxList"` // 对应 kyjx in (...) - RulesEnrollProbabilityList []string `json:"rulesEnrollProbabilityList"` // 对应 rules_enroll_probability in (...) + RulesEnrollProbabilityList []string `json:"rulesEnrollProbabilityList"` // 录取方式,对应 rules_enroll_probability in (...) LoginUserId string `json:"loginUserId"` // 登录用户 ID UserScoreVO userVO.UserScoreVO `json:"userScoreVO"` // 用户成绩 VO CalculationTableName string `json:"calculationTableName"` // 对应 calculation_table_name