Переглянути джерело

Merge branch 'henandk' of http://49.234.186.218:9000/root/ieplus into henandk

mingfu 1 тиждень тому
батько
коміт
f37eb1a530

+ 22 - 11
ie-admin/src/main/java/com/ruoyi/web/controller/front/UserController.java

@@ -63,8 +63,9 @@ public class UserController extends BaseController {
     private final IDzAgentService agentService;
     private final ISysDeptService deptService;
     private final IDzTeacherService dzTeacherService;
+    private final IDzSubjectService dzSubjectService;
 
-    public UserController(IDzControlService dzControlService, SysLoginService loginService, ISysUserService userService, SysPermissionService permissionService, TokenService tokenService, CommService commService, ISysConfigService configService, IDzCardsService dzCardsService, IDzSchoolService dzSchoolService, IDzClassesService dzClassesService, DzSchoolMapper dzSchoolMapper, DzClassesMapper dzClassesMapper, IDzAgentService agentService, ISysDeptService deptService, IDzTeacherService dzTeacherService) {
+    public UserController(IDzControlService dzControlService, SysLoginService loginService, ISysUserService userService, SysPermissionService permissionService, TokenService tokenService, CommService commService, ISysConfigService configService, IDzCardsService dzCardsService, IDzSchoolService dzSchoolService, IDzClassesService dzClassesService, DzSchoolMapper dzSchoolMapper, DzClassesMapper dzClassesMapper, IDzAgentService agentService, ISysDeptService deptService, IDzTeacherService dzTeacherService, IDzSubjectService dzSubjectService) {
         this.dzControlService = dzControlService;
         this.loginService = loginService;
         this.userService = userService;
@@ -80,6 +81,7 @@ public class UserController extends BaseController {
         this.agentService = agentService;
         this.deptService = deptService;
         this.dzTeacherService = dzTeacherService;
+        this.dzSubjectService = dzSubjectService;
     }
 
     @GetMapping(value = "provinces")
@@ -123,17 +125,26 @@ public class UserController extends BaseController {
     @ApiOperation("专业类别列表")
     public AjaxResult examMajor(@RequestParam String location, @RequestParam ExamType examType)
     {
-        List<JSONObject> list = new ArrayList<>();
-        if(ExamType.VHS.equals(examType)) {
-            JSONObject o = new JSONObject();
-            o.put("dictValue", 1);
-            o.put("dictLabel", "农林类");
-            list.add(o);
-            o = new JSONObject();
-            o.put("dictValue", 2);
-            o.put("dictLabel", "养殖类");
-            list.add(o);
+        if (StringUtils.isBlank(location) || null ==examType) {
+            examType = VistorContextHolder.getExamType();
+            location = VistorContextHolder.getLocation();
         }
+        // 构建查询条件
+        DzSubject cond = new DzSubject();
+        cond.setLocations(location);
+        cond.setExamTypes(examType.name());
+
+        // 查询科目列表
+        List<DzSubject> subjectList = dzSubjectService.selectDzSubjectList(cond);
+
+        // 转换为返回格式
+        List<JSONObject> list = subjectList.stream().map(subject -> {
+            JSONObject o = new JSONObject();
+            o.put("dictValue", subject.getSubjectId());
+            o.put("dictLabel", subject.getSubjectName());
+            return o;
+        }).collect(Collectors.toList());
+
         return AjaxResult.success(list);
     }