目录
Mapper代理
增删改查
查
<select id="selectByCondition" resultMap="brandResultMap">
select * from tb_brand /*where true*/
<where>
<if test="status != null">
and status = #{status}
</if>
<if test="companyName != null and companyName != ''">
and company_name like #{companyName}
</if>
<if test="brandName != null and brandName != ''">
and brand_name like #{brandName}
</if>
</where>
</select>
List<Brand> selectByCondition(@Param("status") int status,@Param("companyName")
String companyName,@Param("brandName") String brandName);
添加
<insert id="add" useGeneratedKeys="true" keyProperty="id">
insert into tb_brand (status, description, ordered, company_name, brand_name)
values (#{status},#{description},#{ordered},#{companyName},#{brandName} )
</insert>
更新
删
mapper:
void deleteByIds (@Param("ids") int[] ids);
xml:
<delete id="deleteByIds">
delete from tb_brand where id
in(
<foreach collection="ids" item="id" separator=","> /(
<foreach collection="array" item="id" separator="," open="(" close=")">)
#{id}
</foreach>
)
</delete>