@ResponseBody
@RequestMapping("/test5")
public List<Student> findByCondition(StudentCondition condition){
//用来根据名字模糊匹配
condition.setName("%"+condition.getName()+"%");
return studentService.findByContidion(condition);
}
@ResponseBody
@RequestMapping("/test6/{ids}")
public int deleteByIds(@PathVariable Integer[]ids){
return studentService.deleteByIds(ids);
}
数组请求方式
请求条件类
import lombok.Data;
@Data
public class StudentCondition {
private String name;
private Integer max;
private Integer min;
}
mapper.xml
<delete id="deleteByIds">
delete from student
where id in
<foreach collection="array" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<select id="findByCondition" resultType="com.lanou.pojo.Student">
select id,name,age
from student
<where>
<if test="name!=null and name!='%%' and name!='%null%'">
name like #{name}
</if>
<if test="min!=null">
and age <=#{max}
</if>
<if test="max!=null">
and age >=#{min}
</if>
</where>
</select>