项目实训——第二周第二次日志

继续完善培养计划、培养方案、学生基本信息的学生功能。
1)学生查看培养方案
接口:localhost:8081//student//findProject
controller层:


    /**
     * 学生查询培养方案
     *
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/findProject")
    @ResponseBody
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public Map<String, Object> findProject(HttpServletRequest request) {


        int stu_id = Integer.parseInt(request.getParameter("stu_id"));
        List<StudyProject> list1 = StuService.selectStudyProject(stu_id);
        int pid = list1.get(0).getStudyProjectId();

        List<ProjectCourse> list2 = StuService.selectStudyProjectCourse(pid);
        Map<String, Object> allproperty = new HashMap<String, Object>();//存放总信息
        StudyProject project0 = list1.get(0);//取出培养计划
        //在总信息里存入取出的培养计划
        allproperty.put("stu_id", stu_id);
        allproperty.put("study_project_id", project0.getStudyProjectId());
        allproperty.put("stu_type", project0.getStuType());
        allproperty.put("major", project0.getMajor());
        allproperty.put("pro_name", project0.getProName());
        allproperty.put("start_time", project0.getStartTime());
        allproperty.put("necce_credit", project0.getNecceCredit());
        allproperty.put("total_credit", project0.getTotalCredit());
        allproperty.put("goal", project0.getGoal());
        allproperty.put("field", project0.getField());
        allproperty.put("method", project0.getMethod());
        allproperty.put("study_time", project0.getStudyTime());
        allproperty.put("courses_arrange", project0.getCoursesArrange());
        allproperty.put("segment", project0.getSegment());
        allproperty.put("mid_test", project0.getMidTest());
        allproperty.put("papers", project0.getPapers());
        allproperty.put("graduate", project0.getGraduate());
        allproperty.put("addition", project0.getAddition());
        allproperty.put("dname", project0.getDname());
        allproperty.put("study_year", project0.getStudyYear());
        allproperty.put("course_num", list2.size());


        List<Object> ness = new ArrayList<Object>();
        List<Object> opt = new ArrayList<Object>();
        List<Object> pub = new ArrayList<Object>();

        int ness_num = 1;
        int opt_num = 1;
        int pub_num = 1;
        //取出培养计划对应的课程信息
        for (int i = 0; i < list2.size(); i++) {

            ProjectCourse courseInfo = list2.get(i);

            if (courseInfo.getCourseType().equals("公共课")) {
                Map<String, Object> course = new HashMap<String, Object>();

                course.put("course_id", courseInfo.getCourseId());
                course.put("course_attr", courseInfo.getCourseAttr());
                course.put("course_name", courseInfo.getCourseName());
                course.put("began_time", courseInfo.getBeganTime());
                course.put("total_period", courseInfo.getTotalPeriod());
                course.put("credit", courseInfo.getCredit());
                course.put("exm_method", courseInfo.getExmMethod());
                pub.add(course);
                ++pub_num;
            } else {
                if (courseInfo.getCourseAttr().equals("选修课")) {
                    Map<String, Object> course = new HashMap<String, Object>();

                    course.put("course_id", courseInfo.getCourseId());
                    course.put("course_attr", courseInfo.getCourseAttr());
                    System.out.println(courseInfo.getCourseName());
                    course.put("course_name", courseInfo.getCourseName());
                    course.put("began_time", courseInfo.getBeganTime());
                    course.put("total_period", courseInfo.getTotalPeriod());
                    course.put("credit", courseInfo.getCredit());
                    course.put("exm_method", courseInfo.getExmMethod());
                    opt.add(course);
                    ++opt_num;
                } else {
                    Map<String, Object> course = new HashMap<String, Object>();

                    course.put("course_id", courseInfo.getCourseId());
                    course.put("course_attr", courseInfo.getCourseAttr());
                    course.put("course_name", courseInfo.getCourseName());
                    course.put("began_time", courseInfo.getBeganTime());
                    course.put("total_period", courseInfo.getTotalPeriod());
                    course.put("credit", courseInfo.getCredit());
                    course.put("exm_method", courseInfo.getExmMethod());
                    ness.add(course);
                    ++ness_num;
                }
            }
        }
        allproperty.put("ness_course", ness);
        allproperty.put("opt_course", opt);
        allproperty.put("pub_course", pub);

        return allproperty;
    }

service层:


    //学生查询培养方案
    public List<StudyProject> selectStudyProject(int stu_id) {
        return studyProjectDao.selectStudyProject(stu_id);
    }
    public List<ProjectCourse> selectStudyProjectCourse(int pid) {return projectCourseDao.selectStudyProjectCourse(pid); }

dao层:

 List<StudyProject> selectStudyProject(int stu_id);
List<ProjectCourse> selectStudyProjectCourse(int pid);

mapper:

  <select id="selectStudyPlan" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  select * from study_plan where study_plan.study_plan_id=(select study_plan_id from student where stu_id=#{stu_id});
  </select>
<select id="selectStudyProjectCourse" resultMap="BaseResultMap" parameterType="java.lang.Integer">

    select * from project_course where study_project_id=#{pid}

  </select>

postman测试:
在这里插入图片描述2)查询学生的基本信息:
接口:localhost:8081//student//findStuInfo
controller层:

/**
     * 学生基本信息查询
     *
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/findStuInfo")
    @ResponseBody
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public Result findStudentInfo(HttpServletRequest request) throws ParseException {
        int stu_id = Integer.parseInt(request.getParameter("stu_id"));
        Student stu = StuService.selectStudentInfo(stu_id);

        return Result.succ(200, "成功", stu);

    }

service层:


    //查询学生基本信息
    public  Student selectStudentInfo (int stu_id) {
        return studentDao.selectByPrimaryKey(stu_id);
    }

dao层:

   Student selectByPrimaryKey(Integer stuId);

mapper层:

  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from student
    where stu_id = #{stuId,jdbcType=INTEGER}
  </select>

postman测试:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值