2021-07-05 项目实训-研究生管理系统

教师端培养方案查询功能

1、.xml文件中的SQL语句

<!--  教师端:通过专业、学生类型、方案名、年度查询教学方案-->
  <select id="selective" parameterType="com.sdu.postgraduate.entity.StudyProject" resultMap="BaseResultMap">
    select * from study_project
    <trim prefix="where (" suffix=")" suffixOverrides=",">
      <if test="dname != null">
        dname = #{dname,jdbcType=VERCHAR},
      </if>
      <if test="studyProjectId != null">
        study_project_id = #{studyProjectId,jdbcType=INTEGER},
      </if>
      <if test="stuType != null">
        stu_type = #{stuType,jdbcType=VARCHAR},
      </if>
      <if test="major != null">
        major = #{major,jdbcType=VARCHAR},
      </if>
      <if test="proName != null">
        pro_name = #{proName,jdbcType=VARCHAR},
      </if>
      <if test="studyTime != null">
        study_time = #{studyTime,jdbcType=VARCHAR},
      </if>
    </trim>
  </select>

2、mapper接口中的方法定义

    /**
     * 教师端:培养方案查询
     * @param record
     * @return
     */
    List<StudyProject> selective(StudyProject record);

3、service层中的方法定义

	    /**
	     * 根据一个studyproj对象进行多条件查询
	     * @param sp
	     * @return
	     */
	    public List<StudyProject> searchStudyProj(StudyProject sp){
	        return studyProjectDao.selective(sp);
	    }

4、controller层业务逻辑

    /**
    * 培养方案查询:
    * 根据一个proj对象进行多条件查询
    * @param request
    * @return
    */
   @RequestMapping("/searchStuProj")
   public Result searchStuProj(@RequestBody Map<String, Object> request) {
       //专业
       String dname = (String) request.get("dname");
       //学生类型
       String stuType = (String) request.get("stu_type");
       //专业类型
       String major = (String) request.get("major");
       //方案名
       String proName = (String) request.get("pro_name");
       //年度
       String studyTime = (String) request.get("study_time");
       StudyProject a = new StudyProject();
       if(!dname.equals(""))
           a.setDname(dname);
       if(!stuType.equals(""))
           a.setStuType(stuType);
       System.out.println("stutype:"+a.getStuType());
       if(!major.equals(""))
           a.setMajor(major);
       System.out.println("majoy:"+a.getMajor());
       if(!proName.equals(""))
           a.setProName(proName);
       System.out.println("ProName:"+a.getProName());
       if(!studyTime.equals(""))
           a.setStudyTime(studyTime);
       System.out.println("StudyTime:"+a.getStudyTime());
       return Result.succ(teacherService.searchStudyProj(a));
   }

5、测试接口

post请求body部分

   {
      "dname":"",
      "stu_type": "",
      "major": "软件工程",
      "pro_name": "",
      "study_time": ""
   }

获得数据
查询结果

6、前后端连接

//前端保存查询条件
 collectData(){
				console.log("info"+this.info.pro_name);
				// console.log("cd"+this.dname[0]);
				console.log("info"+this.dname_index);
				
				if(this.dname_index==0)
					this.info.dname="";
				else
					this.info.dname=this.dname[this.dname_index];
					
				if(this.stuType_index==0)
					this.info.stu_type="";
				else
					this.info.stu_type=this.stutype[this.stuType_index];
					
				if(this.major_index==0)
					this.info.major="";
				else
					this.info.major=this.major[this.major_index];
					
				if(this.studyTime_index==0)
					this.info.study_time="";
				else
					this.info.study_time=this.year[this.studyTime_index];
				// this.info.pro_name=this.pro_name
				console.log("请求的数据为"+this.info.dname);
				console.log("dname:"+this.info.stu_type);
				console.log("stuType:"+this.info.major);
				console.log("major:"+this.info.study_time);
				console.log("pro_name:"+this.info.pro_name);
			}
//发起post请求
					this.collectData();
					uni.request({
						
						// header: {
						// 	'Content-Type': 'application/x-www-form-urlencoded'  
						// }, 
						url: 'http://localhost:8081/teacher/searchStuProj',
						method: 'POST',
						data: this.info,
						dataType:'json',
						
						success: (res) => {
							console.log(res.data);
							uni.setStorageSync('studyProjectList', res.data.data);
							uni.navigateTo({
								url:'/pages/teacher/studyProject/list'
							})
						}
					});

7、界面展示

选择查询条件
查询结果

详细信息

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值