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

教师端出国申请-归国申请&归国变更申请

1、.xml文件中的SQL语句

<update id="updateByPrimaryKeySelective" parameterType="com.sdu.postgraduate.entity.Teacher" >
    update teacher
    <set >
      <if test="teaName != null" >
        tea_name = #{teaName,jdbcType=CHAR},
      </if>
      <if test="teaGender != null" >
        tea_gender = #{teaGender,jdbcType=CHAR},
      </if>
      <if test="teaBirthday != null" >
        tea_birthday = #{teaBirthday,jdbcType=DATE},
      </if>
      <if test="teaTelNum != null" >
        tea_tel_num = #{teaTelNum,jdbcType=INTEGER},
      </if>
      <if test="mailAddress != null" >
        mail_address = #{mailAddress,jdbcType=CHAR},
      </if>
      <if test="position != null" >
        position = #{position,jdbcType=CHAR},
      </if>
      <if test="highestEdu != null" >
        highest_edu = #{highestEdu,jdbcType=CHAR},
      </if>
      <if test="finalEdu != null" >
        final_edu = #{finalEdu,jdbcType=CHAR},
      </if>
      <if test="teaDocTime != null" >
        tea_doc_time = #{teaDocTime,jdbcType=DATE},
      </if>
      <if test="teaMasterTime != null" >
        tea_master_time = #{teaMasterTime,jdbcType=DATE},
      </if>
      <if test="teaDname != null" >
        tea_dname = #{teaDname,jdbcType=CHAR},
      </if>
      <if test="personIntro != null" >
        person_intro = #{personIntro,jdbcType=CHAR},
      </if>
      <if test="searchDirection != null" >
        search_direction = #{searchDirection,jdbcType=CHAR},
      </if>
      <if test="workAddress != null" >
        work_address = #{workAddress,jdbcType=CHAR},
      </if>
      <if test="teaPhoto != null" >
        tea_photo = #{teaPhoto,jdbcType=LONGVARBINARY},
      </if>
    </set>
    where tea_id = #{teaId,jdbcType=INTEGER}
  </update>

2、mapper接口中的方法定义

    int updateByPrimaryKey(Teacher record);

3、service层中的方法定义

	/**
     * 更新教师个人信息
     * @param t
     * @return
     */
    public int updateTeacherInfo(Teacher t){
        return teacherMapper.updateByPrimaryKeySelective(t);
    }

4、controller层业务逻辑

     /**
     * 个人信息维护:
     * 教师的个人信息更改
     * TODO:图片上传和显示
     * @param request
     * @return
     */
    @RequestMapping("/UpdateTeacherInfo")
    public com.sdu.postgraduate.entity.Result UpdateTeacherInfo(@RequestBody Map<String, Object> request) {
        Integer teaId = (Integer) request.get("teaId");
        String finalEdu = (String) request.get("finalEdu");
        String highestEdu = (String) request.get("highestEdu");
        String mailAddress = (String) request.get("mailAddress");
        String personIntro = (String) request.get("personIntro");
        String position = (String) request.get("position");
        String searchDirection = (String) request.get("searchDirection");
        String teaDname = (String) request.get("teaDname");
        String workAddress = (String) request.get("workAddress");

        Teacher a = new Teacher();

        //前端的teaTelNum格式为String,对其进行类型转换
        System.out.println(request.get("teaTelNum").getClass().toString());
        int tel = Integer.parseInt(request.get("teaTelNum").toString());
        a.setTeaTelNum(tel);

        String teaDocTime = (String) request.get("teaDocTime");
        String teaMasterTime = (String) request.get("teaMasterTime");

        if(teaId!=null)
            a.setTeaId(teaId);
        if(!finalEdu.equals(""))
            a.setFinalEdu(finalEdu);
        if(!highestEdu.equals(""))
            a.setHighestEdu(highestEdu);
        if(!mailAddress.equals(""))
            a.setMailAddress(mailAddress);
        if(!personIntro.equals(""))
            a.setPersonIntro(personIntro);
        if(!position.equals(""))
            a.setPosition(position);
        if(!searchDirection.equals(""))
            a.setSearchDirection(searchDirection);
        if(!teaDname.equals(""))
            a.setTeaDname(teaDname);
        if(!workAddress.equals(""))
            a.setWorkAddress(workAddress);
        if(!teaMasterTime.equals("")){
            java.sql.Date MasterTime = java.sql.Date.valueOf(teaMasterTime);
            a.setTeaMasterTime(MasterTime);
        }
        if(!teaDocTime.equals("")){
            java.sql.Date DocTime = java.sql.Date.valueOf(teaDocTime);
            a.setTeaDocTime(DocTime);
        }
//        return Result.succ(teacherService.updateTeacherInfo(a));
//        teacherService.updateTeacherInfo(a);
        return com.sdu.postgraduate.entity.Result.succ(teacherService.updateTeacherInfo(a));
    }

5、前后端连接

//载入原有信息
 
uni.request({
					url:'http://localhost:8081/teacher/loadTeacher',
					data:this.person,
					method :'POST',
					dataType:'json',
					success:(res)=>{
						console.log(res.data);
						uni.setStorageSync('basicInfoList', res.data.data[0]);
						this.info=uni.getStorageSync('basicInfoList');
						this.info.teaBirthday = this.formatDate(this.info.teaBirthday);
						this.date1=this.formatDate(this.info.teaDocTime);
						this.info.teaDocTime = this.formatDate(this.info.teaDocTime);
						this.date2=this.formatDate(this.info.teaMasterTime);
						this.info.teaMasterTime = this.formatDate(this.info.teaMasterTime);
					},
				});
//收集更新后的数据
uni.request({
			        url:'http://localhost:8081/teacher/UpdateTeacherInfo',
					data:this.info,
			        method:'POST',
			    	success: (res) => {
			    	        console.log("basic_info_sucess->",res.data);
							uni.showModal({
								showCancel: false,
								title: '提示',
								content: "修改成功!",
								success: function (res) {
									if (res.confirm) {
										console.log('用户点击确定');
										uni.navigateTo({
											url: '/pages/index/mine',
										});
									} 
								}
							});		
			    	    }
			    });
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值