TCmsLiveMapper.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.sooka.mybatis.mapper.TCmsLiveMapper">
  4. <resultMap id="BaseResultMap" type="com.sooka.mybatis.model.TCmsLive">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="content_id" jdbcType="INTEGER" property="content_id" />
  7. <result column="speakName" jdbcType="VARCHAR" property="speakName" />
  8. <result column="speakContent" jdbcType="LONGVARCHAR" property="speakContent" />
  9. <result column="speakDate" jdbcType="TIMESTAMP" property="speakDate" />
  10. <result column="sort" jdbcType="INTEGER" property="sort" />
  11. <result column="userType" jdbcType="INTEGER" property="userType" />
  12. </resultMap>
  13. <select id="selectByCondition" parameterType="com.sooka.mybatis.model.TCmsLive" resultMap="BaseResultMap">
  14. SELECT
  15. *
  16. FROM
  17. t_cms_content_live
  18. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  19. <if test="content_id!=null and content_id!=''">
  20. content_id = #{content_id,jdbcType=VARCHAR}
  21. </if>
  22. <if test="speakName!=null and speakName!=''">
  23. and speakName like CONCAT('%',#{speakName,jdbcType=VARCHAR},'%')
  24. </if>
  25. </trim>
  26. <choose>
  27. <when test="orderField!=null and orderField!='' and orderDirection!=null and orderDirection!='' ">
  28. order by ${orderField} ${orderDirection}
  29. </when>
  30. <otherwise>
  31. order by sort desc
  32. </otherwise>
  33. </choose>
  34. </select>
  35. <select id="selectForTag" parameterType="com.sooka.mybatis.model.TCmsLive" resultMap="BaseResultMap">
  36. SELECT
  37. *
  38. FROM
  39. t_cms_content_live
  40. <trim prefix="WHERE (" suffix=")" prefixOverrides="AND|OR">
  41. <if test="content_id!=null and content_id!=''">
  42. content_id = #{content_id,jdbcType=VARCHAR}
  43. </if>
  44. <if test="speakName!=null and speakName!=''">
  45. and speakName like CONCAT('%',#{speakName,jdbcType=VARCHAR},'%')
  46. </if>
  47. </trim>
  48. order by sort desc
  49. </select>
  50. <select id="selectMaxSort" parameterType="com.sooka.mybatis.model.TCmsLive" resultType="Integer">
  51. select max(sort)+1 maxSort from t_cms_content_live where content_id=#{content_id,jdbcType=VARCHAR}
  52. </select>
  53. </mapper>