package cn.dw.zh.dao;
import java.util.List;
import cn.dw.zh.model.Power;
public interface PowerDao {
public void add(Power power);
public void update(Power power);
public void del(Integer id);
public List<Power> query(Power power);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.dw.zh.dao.PowerDao">
<insert id="add" parameterType="cn.dw.zh.model.Power">
<!-- insert into power(name,age) values('zs',22) -->
insert into power
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="location != null and location !=''">
location,
</if>
<if test="elec != null">
elec,
</if>
<if test="etime != null ">
etime,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="location != null and location !=''">
#{location},
</if>
<if test="elec != null">
#{elec},
</if>
<if test="etime != null ">
#{etime},
</if>
</trim>
</insert>
<update id="update" parameterType="cn.dw.zh.model.Power">
update power <!-- location = '',elec ='' -->
<set>
<if test="location != null and location !=''">
location= #{location},
</if>
<if test="elec != null">
elec = #{elec},
</if>
<if test="etime != null ">
etime = #{etime},
</if>
</set>
where id = #{id}
</update>
<delete id="del" parameterType="int">
delete from power where id = #{id}
</delete>
<select id="query" parameterType="cn.dw.zh.model.Power" resultType="cn.dw.zh.model.Power">
select * from power <!-- where location = '' and elec = elec and etime = '' where id = '' -->
<where>
<if test="location != null and location !=''">
and location= #{location}
</if>
<if test="elec != null">
and elec = #{elec}
</if>
<if test="etime != null ">
and etime = #{etime}
</if>
</where>
</select>
</mapper>
/zhlph/src/cn/dw/zh/dao/PowerDao.java
猜你喜欢
转载自blog.csdn.net/linghuaming/article/details/82587544
今日推荐
周排行