双向表-dao+sql

package com.lzl.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.lzl.pojo.Mingxi;
import com.lzl.pojo.Wuliao;

public interface MingxiDao {

List<Mingxi> select( @Param("ctime1")String ctime1, @Param("ctime2")String ctime2, @Param("cqid")String cqid,@Param("cname") String cname,@Param("ctel") String ctel);

void addWuliao(Wuliao wuliao);

void addMingxi(Mingxi mingxi);

}

----------------------------------sql

<?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="com.lzl.dao.MingxiDao">


<select id="select" resultType="Mingxi">

select * from mingxi

<where>
<if test="ctime1!=null and ctime1!=''"> and time &gt;= #{ctime1}</if>
<if test="ctime2!=null and ctime2!=''"> and time &gt;= #{ctime2}</if>
<if test="cname!=null and cname!=''"> no like '%${cname}%'</if>
<if test="ctel!=null and ctel!=''"> no like '%${ctel}%'</if>

</where>

</select>
<insert id="addMingxi">

INSERT INTO `zuoye524`.`mingxi` (`id`, `time`, `qid`, `name`, `tel`)
VALUES (null, #{time},#{qid}, #{name}, #{tel});


</insert>
<insert id="addWuliao">

INSERT INTO `zuoye524`.`wuliao` (`id`, `name`, `guige`, `danwei`, `price`, `beizhu`)
VALUES (null, #{name}, #{guige}, #{danwei}, #{price}, #{beizhu});


</insert>

</mapper>

原文地址:https://www.cnblogs.com/liuzhaolong/p/12971441.html