NewsInfo.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.enterprise.modules.base.dao.NewsInfoDAO">
  6. <resultMap id="NewsInfoMap" type="com.jpsoft.enterprise.modules.base.entity.NewsInfo">
  7. <id property="id" column="id_" />
  8. <result property="newsTypeId" column="news_type_id"/>
  9. <result property="companyId" column="company_id" />
  10. <result property="title" column="title_" />
  11. <result property="content" column="content_" />
  12. <result property="readerNum" column="reader_num" />
  13. <result property="picUrl" column="pic_url" />
  14. <result property="createBy" column="create_by" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateBy" column="update_by" />
  17. <result property="updateTime" column="update_time" />
  18. <result property="delFlag" column="del_flag" />
  19. </resultMap>
  20. <insert id="insert" parameterType="com.jpsoft.enterprise.modules.base.entity.NewsInfo">
  21. <!--
  22. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  23. select sys_guid() from dual
  24. </selectKey>
  25. -->
  26. <![CDATA[
  27. insert into base_news_info
  28. (id_,news_type_id,company_id,title_,content_,reader_num,pic_url,create_by,create_time,update_by,update_time,del_flag)
  29. values
  30. (
  31. #{id,jdbcType=VARCHAR}
  32. ,#{newsTypeId,jdbcType=VARCHAR}
  33. ,#{companyId,jdbcType=VARCHAR}
  34. ,#{title,jdbcType=VARCHAR}
  35. ,#{content,jdbcType=VARCHAR}
  36. ,#{readerNum,jdbcType= NUMERIC }
  37. ,#{picUrl,jdbcType=VARCHAR}
  38. ,#{createBy,jdbcType=VARCHAR}
  39. ,#{createTime,jdbcType= TIMESTAMP }
  40. ,#{updateBy,jdbcType=VARCHAR}
  41. ,#{updateTime,jdbcType= TIMESTAMP }
  42. ,#{delFlag,jdbcType= NUMERIC }
  43. )
  44. ]]>
  45. </insert>
  46. <delete id="delete" parameterType="string">
  47. delete from base_news_info where id_=#{id,jdbcType=VARCHAR}
  48. </delete>
  49. <update id="update" parameterType="com.jpsoft.enterprise.modules.base.entity.NewsInfo">
  50. update base_news_info
  51. <set>
  52. <if test="newsTypeId!=null">
  53. news_type_id=#{newsTypeId,jdbcType=VARCHAR},
  54. </if>
  55. <if test="companyId!=null">
  56. company_id=#{companyId,jdbcType=VARCHAR},
  57. </if>
  58. <if test="title!=null">
  59. title_=#{title,jdbcType=VARCHAR},
  60. </if>
  61. <if test="content!=null">
  62. content_=#{content,jdbcType=VARCHAR},
  63. </if>
  64. <if test="readerNum!=null">
  65. reader_num=#{readerNum,jdbcType= NUMERIC },
  66. </if>
  67. <if test="picUrl!=null">
  68. pic_url=#{picUrl,jdbcType=VARCHAR},
  69. </if>
  70. <if test="createBy!=null">
  71. create_by=#{createBy,jdbcType=VARCHAR},
  72. </if>
  73. <if test="createTime!=null">
  74. create_time=#{createTime,jdbcType= TIMESTAMP },
  75. </if>
  76. <if test="updateBy!=null">
  77. update_by=#{updateBy,jdbcType=VARCHAR},
  78. </if>
  79. <if test="updateTime!=null">
  80. update_time=#{updateTime,jdbcType= TIMESTAMP },
  81. </if>
  82. <if test="delFlag!=null">
  83. del_flag=#{delFlag,jdbcType= NUMERIC },
  84. </if>
  85. </set>
  86. where id_=#{id}
  87. </update>
  88. <select id="get" parameterType="string" resultMap="NewsInfoMap">
  89. select * from base_news_info where id_=#{0}
  90. </select>
  91. <select id="exist" parameterType="string" resultType="int">
  92. select count(*) from base_news_info where id_=#{0}
  93. </select>
  94. <select id="list" resultMap="NewsInfoMap">
  95. select * from base_news_info
  96. </select>
  97. <select id="search" parameterType="hashmap" resultMap="NewsInfoMap">
  98. <![CDATA[
  99. select * from base_news_info a left join base_news_type b
  100. on a.news_type_id = b.id_
  101. ]]>
  102. <where>
  103. a.del_flag = 0
  104. and b.del_flag = 0
  105. <if test="searchParams.id != null">
  106. and a.id_ like #{searchParams.id}
  107. </if>
  108. <if test="searchParams.newsTypeId != null">
  109. and a.news_type_id = #{searchParams.newsTypeId}
  110. </if>
  111. <if test="searchParams.newsTypeParentId != null">
  112. and b.parent_id = #{searchParams.newsTypeParentId}
  113. </if>
  114. <if test="searchParams.newsTypeName != null">
  115. and b.name_ = #{searchParams.newsTypeName}
  116. </if>
  117. <if test="searchParams.companyId != null">
  118. and a.company_id = #{searchParams.companyId}
  119. </if>
  120. </where>
  121. <foreach item="sort" collection="sortList" open="order by" separator=",">
  122. ${sort.name} ${sort.order}
  123. </foreach>
  124. </select>
  125. </mapper>