IContentDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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="net.mingsoft.cms.dao.IContentDao">
  4. <resultMap id="resultMap" type="net.mingsoft.cms.entity.ContentEntity">
  5. <id column="id" property="id" /><!--编号 -->
  6. <result column="content_title" property="contentTitle" /><!--文章标题 -->
  7. <result column="content_category_id" property="contentCategoryId" /><!--所属栏目 -->
  8. <result column="content_type" property="contentType" /><!--文章类型 -->
  9. <result column="content_display" property="contentDisplay" /><!--是否显示 -->
  10. <result column="content_author" property="contentAuthor" /><!--文章作者 -->
  11. <result column="content_source" property="contentSource" /><!--文章来源 -->
  12. <result column="content_datetime" property="contentDatetime" /><!--发布时间 -->
  13. <result column="content_sort" property="contentSort" /><!--自定义顺序 -->
  14. <result column="content_img" property="contentImg" /><!--文章缩略图 -->
  15. <result column="content_description" property="contentDescription" /><!--描述 -->
  16. <result column="content_keyword" property="contentKeyword" /><!--关键字 -->
  17. <result column="content_details" property="contentDetails" /><!--文章内容 -->
  18. <result column="content_url" property="contentUrl" /><!--文章跳转链接地址 -->
  19. <result column="content_hit" property="contentHit" /><!--点击次数 -->
  20. <result column="app_id" property="appId" /><!--文章管理的应用id -->
  21. <result column="create_by" property="createBy" /><!--创建人 -->
  22. <result column="create_date" property="createDate" /><!--创建时间 -->
  23. <result column="update_by" property="updateBy" /><!--修改人 -->
  24. <result column="update_date" property="updateDate" /><!--修改时间 -->
  25. <result column="del" property="del" /><!--删除标记 -->
  26. </resultMap>
  27. <!--保存-->
  28. <insert id="saveEntity" useGeneratedKeys="true" keyProperty="id"
  29. parameterType="net.mingsoft.cms.entity.ContentEntity" >
  30. insert into cms_content
  31. <trim prefix="(" suffix=")" suffixOverrides=",">
  32. <if test="contentTitle != null and contentTitle != ''">content_title,</if>
  33. <if test="contentCategoryId != null and contentCategoryId != ''">content_category_id,</if>
  34. <if test="contentType != null and contentType != ''">content_type,</if>
  35. <if test="contentDisplay != null and contentDisplay != ''">content_display,</if>
  36. <if test="contentAuthor != null and contentAuthor != ''">content_author,</if>
  37. <if test="contentSource != null and contentSource != ''">content_source,</if>
  38. <if test="contentDatetime != null">content_datetime,</if>
  39. <if test="contentSort != null">content_sort,</if>
  40. <if test="contentImg != null and contentImg != ''">content_img,</if>
  41. <if test="contentDescription != null and contentDescription != ''">content_description,</if>
  42. <if test="contentKeyword != null and contentKeyword != ''">content_keyword,</if>
  43. <if test="contentDetails != null and contentDetails != ''">content_details,</if>
  44. <if test="contentUrl != null and contentUrl != ''">content_url,</if>
  45. <if test="contentHit != null">content_hit,</if>
  46. <if test="appId != null">app_id,</if>
  47. <if test="createBy &gt; 0">create_by,</if>
  48. <if test="createDate != null">create_date,</if>
  49. <if test="updateBy &gt; 0">update_by,</if>
  50. <if test="updateDate != null">update_date,</if>
  51. <if test="del != null">del,</if>
  52. </trim>
  53. <trim prefix="values (" suffix=")" suffixOverrides=",">
  54. <if test="contentTitle != null and contentTitle != ''">#{contentTitle},</if>
  55. <if test="contentCategoryId != null and contentCategoryId != ''">#{contentCategoryId},</if>
  56. <if test="contentType != null and contentType != ''">#{contentType},</if>
  57. <if test="contentDisplay != null and contentDisplay != ''">#{contentDisplay},</if>
  58. <if test="contentAuthor != null and contentAuthor != ''">#{contentAuthor},</if>
  59. <if test="contentSource != null and contentSource != ''">#{contentSource},</if>
  60. <if test="contentDatetime != null">#{contentDatetime},</if>
  61. <if test="contentSort != null">#{contentSort},</if>
  62. <if test="contentImg != null and contentImg != ''">#{contentImg},</if>
  63. <if test="contentDescription != null and contentDescription != ''">#{contentDescription},</if>
  64. <if test="contentKeyword != null and contentKeyword != ''">#{contentKeyword},</if>
  65. <if test="contentDetails != null and contentDetails != ''">#{contentDetails},</if>
  66. <if test="contentUrl != null and contentUrl != ''">#{contentUrl},</if>
  67. <if test="contentHit != null">#{contentHit},</if>
  68. <if test="appId != null">#{appId},</if>
  69. <if test="createBy &gt; 0">#{createBy},</if>
  70. <if test="createDate != null">#{createDate},</if>
  71. <if test="updateBy &gt; 0">#{updateBy},</if>
  72. <if test="updateDate != null">#{updateDate},</if>
  73. <if test="del != null">#{del},</if>
  74. </trim>
  75. </insert>
  76. <!--更新-->
  77. <update id="updateEntity" parameterType="net.mingsoft.cms.entity.ContentEntity">
  78. update cms_content
  79. <set>
  80. <if test="contentTitle != null and contentTitle != ''">content_title=#{contentTitle},</if>
  81. <if test="contentCategoryId != null and contentCategoryId != ''">content_category_id=#{contentCategoryId},</if>
  82. <if test="contentType != null and contentType != ''">content_type=#{contentType},</if>
  83. <if test="contentDisplay != null and contentDisplay != ''">content_display=#{contentDisplay},</if>
  84. <if test="contentAuthor != null and contentAuthor != ''">content_author=#{contentAuthor},</if>
  85. <if test="contentSource != null and contentSource != ''">content_source=#{contentSource},</if>
  86. <if test="contentDatetime != null">content_datetime=#{contentDatetime},</if>
  87. <if test="contentSort != null">content_sort=#{contentSort},</if>
  88. <if test="contentImg != null and contentImg != ''">content_img=#{contentImg},</if>
  89. <if test="contentDescription != null and contentDescription != ''">content_description=#{contentDescription},</if>
  90. <if test="contentKeyword != null and contentKeyword != ''">content_keyword=#{contentKeyword},</if>
  91. <if test="contentDetails != null and contentDetails != ''">content_details=#{contentDetails},</if>
  92. <if test="contentUrl != null and contentUrl != ''">content_url=#{contentUrl},</if>
  93. <if test="contentHit != null">content_hit=#{contentHit},</if>
  94. <if test="appId != null">app_id=#{appId},</if>
  95. <if test="createBy &gt; 0">create_by=#{createBy},</if>
  96. <if test="createDate != null">create_date=#{createDate},</if>
  97. <if test="updateBy &gt; 0">update_by=#{updateBy},</if>
  98. <if test="updateDate != null">update_date=#{updateDate},</if>
  99. <if test="del != null">del=#{del},</if>
  100. </set>
  101. where id = #{id}
  102. </update>
  103. <!--根据id获取-->
  104. <select id="getEntity" resultMap="resultMap" parameterType="int">
  105. select * from cms_content where id=#{id}
  106. </select>
  107. <!--根据实体获取-->
  108. <select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.cms.entity.ContentEntity">
  109. select * from cms_content
  110. <where>
  111. <if test="contentTitle != null and contentTitle != ''">and content_title like CONCAT('%',#{contentTitle},'%')</if>
  112. <if test="contentCategoryId != null and contentCategoryId != ''">and content_category_id=#{contentCategoryId}</if>
  113. <if test="contentType != null and contentType != ''">and content_type=#{contentType}</if>
  114. <if test="contentDisplay != null and contentDisplay != ''">and content_display=#{contentDisplay}</if>
  115. <if test="contentAuthor != null and contentAuthor != ''">and content_author=#{contentAuthor}</if>
  116. <if test="contentSource != null and contentSource != ''">and content_source=#{contentSource}</if>
  117. <if test="contentDatetime != null"> and content_datetime=#{contentDatetime} </if>
  118. <if test="contentSort != null"> and content_sort=#{contentSort} </if>
  119. <if test="contentImg != null and contentImg != ''">and content_img=#{contentImg}</if>
  120. <if test="contentDescription != null and contentDescription != ''">and content_description=#{contentDescription}</if>
  121. <if test="contentKeyword != null and contentKeyword != ''">and content_keyword=#{contentKeyword}</if>
  122. <if test="contentDetails != null and contentDetails != ''">and content_details=#{contentDetails}</if>
  123. <if test="contentUrl != null and contentUrl != ''">and content_url=#{contentUrl}</if>
  124. <if test="contentHit != null">and content_hit=#{contentHit}</if>
  125. <if test="appId != null"> and app_id=#{appId} </if>
  126. <if test="createBy &gt; 0"> and create_by=#{createBy} </if>
  127. <if test="createDate != null"> and create_date=#{createDate} </if>
  128. <if test="updateBy &gt; 0"> and update_by=#{updateBy} </if>
  129. <if test="updateDate != null"> and update_date=#{updateDate} </if>
  130. <if test="del != null"> and del=#{del} </if>
  131. </where>
  132. limit 0,1
  133. </select>
  134. <!--删除-->
  135. <delete id="deleteEntity" parameterType="int">
  136. delete from cms_content where id=#{id}
  137. </delete>
  138. <!--批量删除-->
  139. <delete id="delete" >
  140. delete from cms_content
  141. <where>
  142. id in <foreach collection="ids" item="item" index="index"
  143. open="(" separator="," close=")">#{item}</foreach>
  144. </where>
  145. </delete>
  146. <!--查询全部-->
  147. <select id="queryAll" resultMap="resultMap">
  148. select * from cms_content order by id desc
  149. </select>
  150. <!--条件查询-->
  151. <select id="query" resultMap="resultMap">
  152. select * from cms_content
  153. <where>
  154. <if test="contentTitle != null and contentTitle != ''"> and content_title like CONCAT('%',#{contentTitle},'%')</if>
  155. <if test="contentCategoryId != null and contentCategoryId != ''"> and content_category_id=#{contentCategoryId}</if>
  156. <if test="contentType != null and contentType != ''"> and content_type LIKE CONCAT('%',#{contentType},'%')</if>
  157. <if test="contentDisplay != null and contentDisplay != ''"> and content_display=#{contentDisplay}</if>
  158. <if test="contentAuthor != null and contentAuthor != ''"> and content_author=#{contentAuthor}</if>
  159. <if test="contentSource != null and contentSource != ''"> and content_source=#{contentSource}</if>
  160. <if test="contentDatetime != null"> and content_datetime=#{contentDatetime} </if>
  161. <if test="contentSort != null"> and content_sort=#{contentSort} </if>
  162. <if test="contentImg != null and contentImg != ''"> and content_img=#{contentImg}</if>
  163. <if test="contentDescription != null and contentDescription != ''"> and content_description=#{contentDescription}</if>
  164. <if test="contentKeyword != null and contentKeyword != ''"> and content_keyword=#{contentKeyword}</if>
  165. <if test="contentDetails != null and contentDetails != ''"> and content_details=#{contentDetails}</if>
  166. <if test="contentUrl != null and contentUrl != ''"> and content_url=#{contentUrl}</if>
  167. <if test="contentHit != null"> and content_hit=#{contentHit}</if>
  168. <if test="appId != null"> and app_id=#{appId} </if>
  169. <if test="createBy &gt; 0"> and create_by=#{createBy} </if>
  170. <if test="createDate != null"> and create_date=#{createDate} </if>
  171. <if test="updateBy &gt; 0"> and update_by=#{updateBy} </if>
  172. <if test="updateDate != null"> and update_date=#{updateDate} </if>
  173. <if test="del != null"> and del=#{del} </if>
  174. <include refid="net.mingsoft.base.dao.IBaseDao.sqlWhere"></include>
  175. </where>
  176. order by id desc
  177. </select>
  178. </mapper>