采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
更新用户信息的时候为什么需要新建updateUser 而不直接采用传过来的更新信息user
同学你好
hi同学,我们调用的 是updateByPrimaryKeySelective这个方法
<update
id
=
"updateByPrimaryKeySelective"
parameterType=
"com.mmall.pojo.User"
>
update mmall_user
<
set
if
test
"username != null"
username =
#{username,jdbcType=VARCHAR},
/if
"password != null"
password =
#{password,jdbcType=VARCHAR},
"email != null"
email =
#{email,jdbcType=VARCHAR},
"phone != null"
phone =
#{phone,jdbcType=VARCHAR},
"question != null"
question =
#{question,jdbcType=VARCHAR},
"answer != null"
answer =
#{answer,jdbcType=VARCHAR},
"role != null"
role =
#{role,jdbcType=INTEGER},
"createTime != null"
create_time =
#{createTime,jdbcType=TIMESTAMP},
"updateTime != null"
update_time = now(),
/set
where
#{id,jdbcType=INTEGER}
/update
注意看他的实现,自己new之后只更新想更新的。不必要的重复更新就不更新了。
在updateUserInfomation中,要把更新的updateUser放入data中返回给Controller: return ServerResponse.createBySuccess("更新个人信息成功",updateUser); 在controller中要把返回的值放入session中。这样session中存放的值就不全。。。后面取session值的时候,里面没有自己想要的字段怎么办? session.setAttribute(Const.CURRENT_USER,response.getData());
目前session里通过update之后的确有这个问题,赞同学。可以修改一下,session里一期主要是判断是否登录所用。里面的字段也不都全部使用。
登录后可查看更多问答,登录/注册
前后端分离,数据库接口设计,架构设计,功能开发,上线运维
10.6k 10
2.0k 22
1.6k 21
2.4k 21
2.2k 18
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号