批量删除和单个删除
contoller
@RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ yonghuService.deleteyonghu(Arrays.asList(ids)); return R.ok(); }
dao层
// 批量删除用户 Long deleteLanguageBatch(List<Long> list);
service层
Long deleteyonghu(List<Long> id);
serviceimpl层
@Override public Long deleteyonghu(List<Long> id) { return yonghuDao.deleteLanguageBatch(id); }
xml文件 ```java <!-- 批量删除用户--> <!--批量删除--> <delete id="deleteLanguageBatch"> delete from yonghu where <foreach collection="list" item="key" separator="or"> id=#{key} </foreach> </delete>
多个条件是或者的关系,写法如下:
SELECT * FROM table_1 WHERE 条件1 OR 条件2;
或者关系查询,只要满足一个条件就会被查询出来。
如果多个条件都满足才查询出来,需要使用并且的关系:
SELECT * FROM table_1 WHERE 条件1 AND 条件2;
AND 的优先级高于 OR,使用的过程中请注意。
多条件模糊查询
<resultMap id="BaseResultMap" type="com.entity.Yonghu"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="yonghuming" jdbcType="VARCHAR" property="yonghuming" /> <result column="xingming" jdbcType="VARCHAR" property="xingming" /> <result column="mima" jdbcType="VARCHAR" property="mima" /> <result column="xingbie" jdbcType="VARCHAR" property="xingbie" /> <result column="dianhua" jdbcType="VARCHAR" property="dianhua" /> <result column="youxiang" jdbcType="VARCHAR" property="youxiang" /> <result column="addtime" jdbcType="VARCHAR" property="addtime" /> </resultMap> <select id="getyonghutiaojian" resultMap="BaseResultMap" parameterType="com.entity.Yonghu"> select * from yonghu <where> <if test="yonghuming !=null and yonghuming !=''"> and yonghuming like concat('%',#{yonghuming},'%') </if> <if test="xingming !=null and xingming !=''"> and xingming like concat('%',#{xingming},'%') </if> </where> </select>
今天就记录一下,没有写完