接口里抽象方法

public interface BrandMapper {
//单行查询
Brand FinId(Integer id);
//多条件查询
List FinAll(int[] ids);
//增加
void addTest(Brand brand);
//修改
void upTest(Brand brand);
//删除
void delete(Integer id);
//多行删除
void deletes(int[]idss);
//多行添加
// void adds(@Param(“brands”) ArrayList list);
//map集合多行添加
void adds(@Param(“map”) HashMap map);
}
image.png

映射文件,sql语句



insert into bg
values (null, #{brandName}, #{companyName}, #{ordered}, #{description}, #{status})



INSERT INTO bg VALUES

(null, #{brand.brandName}, #{brand.companyName}, #{brand.ordered}, #{brand.description}, #{brand.status})

  1. </insert><br /><!-- 修改--><br /> <update id="upTest"><br /> update bg<br /> <set><br /> <if test="brandName!=null and brandName!=''"><br /> brand_name=#{brandName},<br /> </if><br /> <if test="companyName!=null and companyName!=''"><br /> company_name =#{companyName},<br /> </if><br /> <if test="ordered!=null"><br /> ordered =#{ordered},<br /> </if><br /> <if test="description!=null and description!=''"><br /> description=#{description},<br /> </if><br /> <if test="status=null"><br /> status=#{status},<br /> </if><br /> </set><br /> where id=#{id}<br /> </update><br /><!-- 单行删除--><br /> <delete id="delete"><br /> delete from bg where id=#{id}<br /> </delete><br /><!-- 多行删除--><br /> <delete id="deletes"><br /> delete from bg where id in <foreach collection="array" open="(" close=")" separator="," item="id">#{id}</foreach><br /> </delete>






image.png

image.png

测试类的方法

image.png
image.png
image.png

控制台输出sql语句

多行添加
image.png
多行删除
image.png
单行删除
image.png
单行修改
image.png
//单行添加
image.png
多行查询
image.png
单行查询
image.png

懒人方法

接口方法

image.png

sql语句

image.png

测试方法

image.png