通过参数筛选学生学生信息

186 阅读1分钟
 /**
     * 获得学生信息
     * 通过班级id获得学生信息接口
     * @TODO 权限
     *getStudents
     */
    @AutoLog(value = "通过id 或者学号 获得学生")
    @ApiOperation(value="通过id 或者学号 获得学生", notes="通过id 或者学号 获得学生")
    @GetMapping(value = "/getStudentByStuIdOrId")
//    @RequiresPermissions("stStudent:getStStudent")
    public Result<?> getStudentByStuIdOrId(String keyword,String key,String fieldTwo,String nationality,String face,
                                           String punish,String graduation,String single,String difficult,String psychological,String academicWarning,String delayedGraduation,String departId,
                                    HttpServletRequest req) {
        if(keyword==null){
            keyword=key;
        }
        QueryWrapper<StStudent> stStudentWrapper=new QueryWrapper<>();
        if(StringUtils.isNotBlank(keyword)){
            stStudentWrapper.like("student_id",keyword).or().like("st_name",keyword).or().like("id",keyword);
        }
        stStudentWrapper.eq("deleted","0");
        stStudentWrapper.eq("field_one","0");
        if(StringUtils.isNotBlank(departId)){
            stStudentWrapper.eq("college",departId);
        }
        if(StringUtils.isNotBlank(fieldTwo)){
            //stStudentWrapper.eq("field_two",fieldTwo);
            stStudentWrapper.in("field_two", fieldTwo.split(","));
            //String[] split = college.split(",");
        }
        if(StringUtils.isNotBlank(nationality)){
            //stStudentWrapper.eq("nationality",nationality);
            stStudentWrapper.in("nationality", nationality.split(","));
        }
        if(StringUtils.isNotBlank(face)){
            //stStudentWrapper.eq("face",face);
            stStudentWrapper.in("face", face.split(","));
        }
        if(StringUtils.isNotBlank(punish)){
           // stStudentWrapper.eq("punish",punish);
            stStudentWrapper.in("punish", punish.split(","));
        }
        if(StringUtils.isNotBlank(graduation)){
            //stStudentWrapper.eq("graduation",graduation);
            stStudentWrapper.in("graduation", graduation.split(","));
        }
        if(StringUtils.isNotBlank(single)){
            //stStudentWrapper.eq("single",single);
            stStudentWrapper.in("single", single.split(","));
        }
        if(StringUtils.isNotBlank(difficult)){
           // stStudentWrapper.eq("difficult",difficult);
            stStudentWrapper.in("difficult", difficult.split(","));
        }
        if(StringUtils.isNotBlank(psychological)){
            //stStudentWrapper.eq("psychological",psychological);
            stStudentWrapper.in("psychological", psychological.split(","));
        }
        if(StringUtils.isNotBlank(academicWarning)){
            //stStudentWrapper.eq("academic_warning",academicWarning);
            stStudentWrapper.in("academic_warning", academicWarning.split(","));
        }
        if(StringUtils.isNotBlank(delayedGraduation)){
            //stStudentWrapper.eq("delayed_graduation",delayedGraduation);
            stStudentWrapper.in("delayed_graduation", delayedGraduation.split(","));
        }
        /*stStudentWrapper.eq("field_two","fieldTwo");
        stStudentWrapper.eq("nationality","nationality");*/
        /*List<FilterVo> filterVo= stStudentService.getfilterVos(fieldTwo,nationality);*/
        List<StStudent> stStudents = stStudentService.list(stStudentWrapper);
        Result result=new Result();
        List<DictModel> models=new ArrayList<>();
        for (StStudent stStudent : stStudents) {
            DictModel dictModel=new DictModel();
            dictModel.setValue(stStudent.getId());
            dictModel.setText(stStudent.getStName()+"("+stStudent.getStudentId()+")");
            dictModel.setPhone(stStudent.getStPhoto());
            dictModel.setStName(stStudent.getStName());
            dictModel.setStId(stStudent.getStudentId());
            models.add(dictModel);
        }
        result.setResult(models);
        return result;
    }