SpringBoot中mybatis多参数传递
使用Map封装
mybatis
<update id="testModify">
update testTable
<trim prefix="set (" suffix=")" sufiixOverrides=",">
<if test="name != null">name = #{name},</if>
</trim>
where id = #{id}
</update>
Mapper层
@Mapper
@Repository
public interface TestTableMapper {
void testModify(Map map);
}
Service层
public interface TestService {
void modifyName(String name, int id);
}
@Service
public class TestServiceImpl {
@Autowired
TestTableMapper testTableMapper;
@Override
public void modifyName(String name, int id) {
Map<String, String> map = new HashMap<String, String>();
map.put("name", name);
map.put("id", id + "");
testTableMapper.testModify(map);
}
}

浙公网安备 33010602011771号