From 8efcdef1c99e4f01d39767de12f5119121d7925b Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Wed, 19 Jun 2024 10:13:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E5=8F=B0=E5=AD=A6=E7=A7=91=E4=B8=93?= =?UTF-8?q?=E4=B8=9A=E7=AD=9B=E9=80=89=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/DisciplineController.java | 22 +++++++++-- .../com/huoran/iasf/entity/Discipline.java | 4 ++ .../huoran/iasf/entity/ProfessionalClass.java | 5 ++- .../mapper/xml/SysProductDetailsMapper.xml | 20 ++++++++-- .../iasf/service/DisciplineService.java | 3 ++ .../service/impl/DisciplineServiceImpl.java | 39 +++++++++++++++++++ .../iasf/vo/req/PageCourseProductReq.java | 10 +++++ 7 files changed, 95 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/huoran/iasf/controller/DisciplineController.java b/src/main/java/com/huoran/iasf/controller/DisciplineController.java index db522cf..e25fbbc 100644 --- a/src/main/java/com/huoran/iasf/controller/DisciplineController.java +++ b/src/main/java/com/huoran/iasf/controller/DisciplineController.java @@ -37,6 +37,8 @@ public class DisciplineController { @Autowired public ProfessionalClassService classService; + + @GetMapping("/courseDiscipline") @ApiOperation(value = "课程学科类别", response = Discipline.class) public R courseDiscipline() { @@ -46,19 +48,31 @@ public class DisciplineController { @GetMapping("/courseProfessionalClass") @ApiOperation(value = "课程专业类", response = ProfessionalClass.class) - public R disciplineList(@ApiParam(value = "disciplineId", required = true) @RequestParam("disciplineId") Integer disciplineId) { + public R disciplineList(@ApiParam(value = "disciplineId") @RequestParam("disciplineId") Integer disciplineId) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("discipline_id", disciplineId); + if (disciplineId != null){ + queryWrapper.eq("discipline_id", disciplineId); + } List list = classService.list(queryWrapper); return R.success(list); } + @GetMapping("/threeLevelJointInvestigation") + @ApiOperation(value = "三级联查", response = ProfessionalClass.class) + public R threeLevelJointInvestigation(@ApiParam(value = "disciplineId") @RequestParam("disciplineId") Integer disciplineId) { + + return R.success(disciplineService.getCourseDisciplineWithDetails(disciplineId)); + } + + @GetMapping("/courseProfessional") @ApiOperation(value = "课程专业", response = Professional.class) - public R courseProfessional(@ApiParam(value = "professionalClassId", required = true) @RequestParam("professionalClassId") Integer professionalClassId) { + public R courseProfessional(@ApiParam(value = "professionalClassId") @RequestParam("professionalClassId") Integer professionalClassId) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("professional_class_id", professionalClassId); + if (professionalClassId != null){ + queryWrapper.eq("professional_class_id", professionalClassId); + } List list = professionalService.list(queryWrapper); return R.success(list); } diff --git a/src/main/java/com/huoran/iasf/entity/Discipline.java b/src/main/java/com/huoran/iasf/entity/Discipline.java index 7c80786..d3c8163 100644 --- a/src/main/java/com/huoran/iasf/entity/Discipline.java +++ b/src/main/java/com/huoran/iasf/entity/Discipline.java @@ -1,6 +1,7 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -9,6 +10,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.util.List; /** *

@@ -34,4 +36,6 @@ public class Discipline implements Serializable { private String disciplineName; + @TableField(exist = false) + List professionalClasses; } diff --git a/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java b/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java index e10b0be..f39a925 100644 --- a/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java +++ b/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java @@ -1,6 +1,7 @@ package com.huoran.iasf.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -9,6 +10,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.util.List; /** *

@@ -36,5 +38,6 @@ public class ProfessionalClass implements Serializable { @ApiModelProperty(value = "学科层次id") private Integer disciplineId; - + @TableField(exist = false) + List professionals; } diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml index d035168..be29df2 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml @@ -188,9 +188,23 @@ AND is_top = 1 - - and d.NAME LIKE CONCAT('%',#{req.keyWord},'%') - + + AND FIND_IN_SET(#{req.subjectCategoryId},( SELECT GROUP_CONCAT( subject_category_id ) FROM sys_subject_specialty WHERE template_details_id = d.id ) ) + + + + AND FIND_IN_SET(#{req.professionalCategoryId},( SELECT GROUP_CONCAT( professional_category_id ) FROM sys_subject_specialty WHERE template_details_id = d.id ) ) + + + + + AND FIND_IN_SET(#{req.majorId},( SELECT GROUP_CONCAT( major_id ) FROM sys_subject_specialty WHERE template_details_id = d.id ) ) + + + + + and d.NAME LIKE CONCAT('%',#{req.keyWord},'%') + AND FIND_IN_SET(#{req.categoryId}, d.category_id) diff --git a/src/main/java/com/huoran/iasf/service/DisciplineService.java b/src/main/java/com/huoran/iasf/service/DisciplineService.java index e7536e3..f48f647 100644 --- a/src/main/java/com/huoran/iasf/service/DisciplineService.java +++ b/src/main/java/com/huoran/iasf/service/DisciplineService.java @@ -1,5 +1,6 @@ package com.huoran.iasf.service; +import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.Discipline; import com.baomidou.mybatisplus.extension.service.IService; @@ -16,4 +17,6 @@ import java.util.List; public interface DisciplineService extends IService { List subjectCategory(); + + R getCourseDisciplineWithDetails(Integer disciplineId); } diff --git a/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java index 0cc9a51..4182901 100644 --- a/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java @@ -1,9 +1,16 @@ package com.huoran.iasf.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.Discipline; +import com.huoran.iasf.entity.Professional; +import com.huoran.iasf.entity.ProfessionalClass; import com.huoran.iasf.mapper.DisciplineMapper; +import com.huoran.iasf.mapper.ProfessionalClassMapper; +import com.huoran.iasf.mapper.ProfessionalMapper; import com.huoran.iasf.service.DisciplineService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @@ -18,9 +25,41 @@ import java.util.List; */ @Service public class DisciplineServiceImpl extends ServiceImpl implements DisciplineService { + @Autowired + private DisciplineMapper disciplineMapper; + @Autowired + private ProfessionalClassMapper professionalClassMapper; + @Autowired + private ProfessionalMapper professionalMapper; @Override public List subjectCategory() { return baseMapper.selectList(null); } + + @Override + public R getCourseDisciplineWithDetails(Integer disciplineId) { + if (disciplineId == null) { + // 如果没有disciplineId,只查询第一级(学科类别) + List disciplines = disciplineMapper.selectList(new LambdaQueryWrapper<>()); + return R.success(disciplines); + } else { + // 进行完整的三级联查 + List disciplines = disciplineMapper.selectList(new LambdaQueryWrapper().eq(Discipline::getDisciplineId, disciplineId)); + + disciplines.forEach(discipline -> { + // 获取该学科类别下的所有专业类别 + List professionalClasses = professionalClassMapper.selectList(new LambdaQueryWrapper().eq(ProfessionalClass::getDisciplineId, discipline.getDisciplineId())); + discipline.setProfessionalClasses(professionalClasses); + + // 为每个专业类别填充其下的专业 + professionalClasses.forEach(professionalClass -> { + List professionals = professionalMapper.selectList(new LambdaQueryWrapper().eq(Professional::getProfessionalClassId, professionalClass.getProfessionalClassId())); + professionalClass.setProfessionals(professionals); + }); + }); + + return R.success(disciplines); + } + } } diff --git a/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java b/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java index 35a7696..b3947b9 100644 --- a/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java +++ b/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java @@ -35,4 +35,14 @@ public class PageCourseProductReq extends PageReqVO { private Integer selection; + @ApiModelProperty(value = "学科类别id,仅产品使用,可为空") + private Integer subjectCategoryId; + + @ApiModelProperty(value = "专业类别id,仅产品使用,可为空") + private Integer professionalCategoryId; + + @ApiModelProperty(value = "专业id,仅产品使用,可为空") + private Integer majorId; + + } \ No newline at end of file