Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the space-time field modified by MybatisPlus cannot be modified?

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to modify the space-time field of MybatisPlus. What is introduced in this article is very detailed and has certain reference value. Friends who are interested must finish reading it.

MybatisPlus empty field cannot be modified

Click to modify

When the data is empty, click OK, but the data in the list is still the original data.

Look at the printout in the background and find that these two fields are not updated.

At this point, add to the entity class

The comment on this line means

When the property is modified, a value is automatically populated (the default is null), which means that the field is changed to empty rather than left unmodified.

Mybatis-Plus modifies the core code of the specified field / * change the password (you can only change your own password) * * @ author zhangxuewei * @ param userID * @ param password * @ param session * @ return * / @ ResponseBody @ RequestMapping (value = "/ updateUserPWD" Method = RequestMethod.POST) public ResultCode updateUserPWD (@ RequestParam (value = "password_old") String password, @ RequestParam (value = "password_new") String newpassword, HttpSession session) {logger.info ("updateUserPWD.") User user1 = (User) session.getAttribute ("sessionUser"); ResultCode res = new ResultCode (); EntityWrapper ew = new EntityWrapper (); ew.eq ("user_name", user1.getUserName ()); User user2= userService.selectOne (ew) If (user2.getPassWord (). Equals (AIAppUtils.encrypt (password) {if (StringUtils.isNotBlank (password) & & StringUtils.isNotBlank (newpassword)) {String setSql = "pass_word =" + "" + AIAppUtils.encrypt (newpassword) + "'; EntityWrapper ew1 = new EntityWrapper () Ew1.eq ("user_id", user1.getUserID ()); try {userService.updateForSet (setSql, ew1); session.removeAttribute ("sessionUser") Res.setCode (0);} catch (Exception e) {/ / TODO: handle exception res.setCode (1) }} else {/ / parameter cannot be empty res.setCode (1); res.setMsg ("parameter cannot be empty") }} else {res.setCode (1); res.setMsg ("original password is incorrect!") ;} return res;} these are all the contents of the article "what to do if the spatio-temporal field cannot be modified by MybatisPlus". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report