Pass a list in the sql and return a list
-incoming array-returns list-String [] sendPersonIdArr = sendPersonId.split (","); List list = staffInfoService.ListPhonesByIds (sendPersonIdArr) SELECT h.telphone from hr_staff_info h left JOIN sys_user u on h.STAFFINFO_ID=u.STAFF_ID where u.id in # {item}-input List---- and return List- public List FindByUserIdList (List userlist) throws Exception {return (List) dao.findForList ("UserMapper.findByUserIdList") Userlist) } select * from sys_user where id in # {item}-input a map- batch modification data-controller: Map map = new HashMap (); map.put ("notifyNum", notifyNum) Map.put ("userIdArr", userIdArr); userService.sendNotify (map) In sql: update user set notify_codes=if (notify_codes is null or notify_codes='',# {notifyNum}, CONCAT (notify_codes,',',# {notifyNum})) where id in # {item} Summary: ① has passed a String notifyNum and a String [] userIdArr All we have to do is match the names in sql. ② batch modification can also be made with in ③. When modifying, we can append a string directly to the original field value. When the original value is a number, we can update user set notify_codes=notify_codes+'2' where id='24' like this, assuming that the original value is 5, so now it is 7. When the original value is of type String, we can append it with CONCAT (notify_codes,',',# {notifyNum}). For example, if you add a ", 13" to "12" now, then the result is "12 notify_codes is null or notify_codes='',' 13" when ④ determines whether a field is empty or not, use if (return this value if the notify_codes is null or notify_codes='',' is empty or an empty string', return this value if not empty)
The second way: the whole statement loop (unverified by yourself)
Update test test=$ {item.test} + 1 where id = ${item.id}
In sql, we can pass in a list or an array and return a list.
Here we use In in sql and traversal in sql.
When we want to pass the String parameter to mapper.xml, we need to set the
ParameterType= "String"
At the same time, make sure that the parameter names in impl are the same as those in sql.
As follows:
@ Override public User findByUE (String userId) throws Exception {return (User) dao.findForObject ("UserMapper.findById", userId);} sql: u.id = # {userId}