LiuyanMapper.xml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.mapper.LiuyanMapper">
  5. <resultMap type="Liuyan" id="queryMap">
  6. <id property="id" column="id" />
  7. <result property="uid" column="uid" />
  8. <result property="lynr" column="lynr" />
  9. <result property="lysj" column="lysj" />
  10. <result property="lyhf" column="lyhf" />
  11. <association property="user" javaType="Userinfo">
  12. <id property="id" column="id" />
  13. <result property="name" column="name" />
  14. <result property="tel" column="tel" />
  15. </association>
  16. </resultMap>
  17. <sql id="Where_Clause">
  18. <where>
  19. <if test="id!=null and id!=0">and a.id= #{id}</if>
  20. <if test="uid!=null and uid!=''">and a.uid= #{uid}</if>
  21. </where>
  22. </sql>
  23. <select id="query" parameterType="java.util.Map"
  24. resultMap="queryMap">
  25. select a.*,b.name,b.tel from liuyan a left join
  26. userinfo b on a.uid=b.id
  27. <include refid="Where_Clause" />
  28. order by id desc
  29. </select>
  30. <select id="getCount" parameterType="java.util.Map"
  31. resultType="Int">
  32. select count(*) nums from liuyan a left join userinfo b on
  33. a.uid=b.id
  34. <include refid="Where_Clause" />
  35. </select>
  36. <select id="queryLiuyanById" parameterType="int"
  37. resultType="Liuyan">
  38. select * from liuyan where id=${value}
  39. </select>
  40. <insert id="insertLiuyan" useGeneratedKeys="true" keyProperty="id"
  41. parameterType="Liuyan">
  42. insert into liuyan (uid,lynr,lysj,lyhf) values
  43. (#{uid},#{lynr},#{lysj},#{lyhf});
  44. </insert>
  45. <update id="updateLiuyan" parameterType="Liuyan">
  46. update liuyan set
  47. uid=#{uid},lynr=#{lynr},lysj=#{lysj},lyhf=#{lyhf} where id=#{id}
  48. </update>
  49. <delete id="deleteLiuyan" parameterType="int">
  50. delete from liuyan where id=${value}
  51. </delete>
  52. </mapper>