JtKnowledgeBaseMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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.goafanti.common.dao.JtKnowledgeBaseMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.JtKnowledgeBase">
  5. <!--
  6. WARNING - @mbggenerated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  9. -->
  10. <result column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="category" jdbcType="INTEGER" property="category" />
  12. <result column="title" jdbcType="VARCHAR" property="title" />
  13. <result column="summary" jdbcType="VARCHAR" property="summary" />
  14. <result column="source" jdbcType="VARCHAR" property="source" />
  15. <result column="status" jdbcType="INTEGER" property="status" />
  16. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  17. <result column="owner" jdbcType="VARCHAR" property="owner" />
  18. <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" />
  19. <result column="read_number" jdbcType="INTEGER" property="readNumber" />
  20. <result column="comment_number" jdbcType="INTEGER" property="commentNumber" />
  21. <result column="star_number" jdbcType="INTEGER" property="starNumber" />
  22. <result column="keyword" jdbcType="VARCHAR" property="keyword" />
  23. <result column="pic_url" jdbcType="VARCHAR" property="picUrl" />
  24. <result column="top" jdbcType="INTEGER" property="top" />
  25. <result column="recommend" jdbcType="INTEGER" property="recommend" />
  26. </resultMap>
  27. <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.goafanti.common.model.JtKnowledgeBase">
  28. <!--
  29. WARNING - @mbggenerated
  30. This element is automatically generated by MyBatis Generator, do not modify.
  31. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  32. -->
  33. <result column="content" jdbcType="LONGVARCHAR" property="content" />
  34. </resultMap>
  35. <sql id="Example_Where_Clause">
  36. <!--
  37. WARNING - @mbggenerated
  38. This element is automatically generated by MyBatis Generator, do not modify.
  39. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  40. -->
  41. <where>
  42. <foreach collection="oredCriteria" item="criteria" separator="or">
  43. <if test="criteria.valid">
  44. <trim prefix="(" prefixOverrides="and" suffix=")">
  45. <foreach collection="criteria.criteria" item="criterion">
  46. <choose>
  47. <when test="criterion.noValue">
  48. and ${criterion.condition}
  49. </when>
  50. <when test="criterion.singleValue">
  51. and ${criterion.condition} #{criterion.value}
  52. </when>
  53. <when test="criterion.betweenValue">
  54. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  55. </when>
  56. <when test="criterion.listValue">
  57. and ${criterion.condition}
  58. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  59. #{listItem}
  60. </foreach>
  61. </when>
  62. </choose>
  63. </foreach>
  64. </trim>
  65. </if>
  66. </foreach>
  67. </where>
  68. </sql>
  69. <sql id="Update_By_Example_Where_Clause">
  70. <!--
  71. WARNING - @mbggenerated
  72. This element is automatically generated by MyBatis Generator, do not modify.
  73. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  74. -->
  75. <where>
  76. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  77. <if test="criteria.valid">
  78. <trim prefix="(" prefixOverrides="and" suffix=")">
  79. <foreach collection="criteria.criteria" item="criterion">
  80. <choose>
  81. <when test="criterion.noValue">
  82. and ${criterion.condition}
  83. </when>
  84. <when test="criterion.singleValue">
  85. and ${criterion.condition} #{criterion.value}
  86. </when>
  87. <when test="criterion.betweenValue">
  88. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  89. </when>
  90. <when test="criterion.listValue">
  91. and ${criterion.condition}
  92. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  93. #{listItem}
  94. </foreach>
  95. </when>
  96. </choose>
  97. </foreach>
  98. </trim>
  99. </if>
  100. </foreach>
  101. </where>
  102. </sql>
  103. <sql id="Base_Column_List">
  104. <!--
  105. WARNING - @mbggenerated
  106. This element is automatically generated by MyBatis Generator, do not modify.
  107. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  108. -->
  109. id, category, title, summary, source, status, create_time, owner, release_time, read_number,
  110. comment_number, star_number, keyword, pic_url, top, recommend
  111. </sql>
  112. <sql id="Blob_Column_List">
  113. <!--
  114. WARNING - @mbggenerated
  115. This element is automatically generated by MyBatis Generator, do not modify.
  116. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  117. -->
  118. content
  119. </sql>
  120. <select id="selectByExampleWithBLOBs" parameterType="com.goafanti.common.model.JtKnowledgeBaseExample" resultMap="ResultMapWithBLOBs">
  121. <!--
  122. WARNING - @mbggenerated
  123. This element is automatically generated by MyBatis Generator, do not modify.
  124. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  125. -->
  126. select
  127. <if test="distinct">
  128. distinct
  129. </if>
  130. <include refid="Base_Column_List" />
  131. ,
  132. <include refid="Blob_Column_List" />
  133. from jt_knowledge_base
  134. <if test="_parameter != null">
  135. <include refid="Example_Where_Clause" />
  136. </if>
  137. <if test="orderByClause != null">
  138. order by ${orderByClause}
  139. </if>
  140. </select>
  141. <select id="selectByExample" parameterType="com.goafanti.common.model.JtKnowledgeBaseExample" resultMap="BaseResultMap">
  142. <!--
  143. WARNING - @mbggenerated
  144. This element is automatically generated by MyBatis Generator, do not modify.
  145. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  146. -->
  147. select
  148. <if test="distinct">
  149. distinct
  150. </if>
  151. <include refid="Base_Column_List" />
  152. from jt_knowledge_base
  153. <if test="_parameter != null">
  154. <include refid="Example_Where_Clause" />
  155. </if>
  156. <if test="orderByClause != null">
  157. order by ${orderByClause}
  158. </if>
  159. </select>
  160. <delete id="deleteByExample" parameterType="com.goafanti.common.model.JtKnowledgeBaseExample">
  161. <!--
  162. WARNING - @mbggenerated
  163. This element is automatically generated by MyBatis Generator, do not modify.
  164. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  165. -->
  166. delete from jt_knowledge_base
  167. <if test="_parameter != null">
  168. <include refid="Example_Where_Clause" />
  169. </if>
  170. </delete>
  171. <insert id="insert" parameterType="com.goafanti.common.model.JtKnowledgeBase">
  172. <!--
  173. WARNING - @mbggenerated
  174. This element is automatically generated by MyBatis Generator, do not modify.
  175. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  176. -->
  177. insert into jt_knowledge_base (id, category, title,
  178. summary, source, status,
  179. create_time, owner, release_time,
  180. read_number, comment_number, star_number,
  181. keyword, pic_url, top,
  182. recommend, content)
  183. values (#{id,jdbcType=VARCHAR}, #{category,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR},
  184. #{summary,jdbcType=VARCHAR}, #{source,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
  185. #{createTime,jdbcType=TIMESTAMP}, #{owner,jdbcType=VARCHAR}, #{releaseTime,jdbcType=TIMESTAMP},
  186. #{readNumber,jdbcType=INTEGER}, #{commentNumber,jdbcType=INTEGER}, #{starNumber,jdbcType=INTEGER},
  187. #{keyword,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR}, #{top,jdbcType=INTEGER},
  188. #{recommend,jdbcType=INTEGER}, #{content,jdbcType=LONGVARCHAR})
  189. </insert>
  190. <insert id="insertSelective" parameterType="com.goafanti.common.model.JtKnowledgeBase">
  191. <!--
  192. WARNING - @mbggenerated
  193. This element is automatically generated by MyBatis Generator, do not modify.
  194. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  195. -->
  196. insert into jt_knowledge_base
  197. <trim prefix="(" suffix=")" suffixOverrides=",">
  198. <if test="id != null">
  199. id,
  200. </if>
  201. <if test="category != null">
  202. category,
  203. </if>
  204. <if test="title != null">
  205. title,
  206. </if>
  207. <if test="summary != null">
  208. summary,
  209. </if>
  210. <if test="source != null">
  211. source,
  212. </if>
  213. <if test="status != null">
  214. status,
  215. </if>
  216. <if test="createTime != null">
  217. create_time,
  218. </if>
  219. <if test="owner != null">
  220. owner,
  221. </if>
  222. <if test="releaseTime != null">
  223. release_time,
  224. </if>
  225. <if test="readNumber != null">
  226. read_number,
  227. </if>
  228. <if test="commentNumber != null">
  229. comment_number,
  230. </if>
  231. <if test="starNumber != null">
  232. star_number,
  233. </if>
  234. <if test="keyword != null">
  235. keyword,
  236. </if>
  237. <if test="picUrl != null">
  238. pic_url,
  239. </if>
  240. <if test="top != null">
  241. top,
  242. </if>
  243. <if test="recommend != null">
  244. recommend,
  245. </if>
  246. <if test="content != null">
  247. content,
  248. </if>
  249. </trim>
  250. <trim prefix="values (" suffix=")" suffixOverrides=",">
  251. <if test="id != null">
  252. #{id,jdbcType=VARCHAR},
  253. </if>
  254. <if test="category != null">
  255. #{category,jdbcType=INTEGER},
  256. </if>
  257. <if test="title != null">
  258. #{title,jdbcType=VARCHAR},
  259. </if>
  260. <if test="summary != null">
  261. #{summary,jdbcType=VARCHAR},
  262. </if>
  263. <if test="source != null">
  264. #{source,jdbcType=VARCHAR},
  265. </if>
  266. <if test="status != null">
  267. #{status,jdbcType=INTEGER},
  268. </if>
  269. <if test="createTime != null">
  270. #{createTime,jdbcType=TIMESTAMP},
  271. </if>
  272. <if test="owner != null">
  273. #{owner,jdbcType=VARCHAR},
  274. </if>
  275. <if test="releaseTime != null">
  276. #{releaseTime,jdbcType=TIMESTAMP},
  277. </if>
  278. <if test="readNumber != null">
  279. #{readNumber,jdbcType=INTEGER},
  280. </if>
  281. <if test="commentNumber != null">
  282. #{commentNumber,jdbcType=INTEGER},
  283. </if>
  284. <if test="starNumber != null">
  285. #{starNumber,jdbcType=INTEGER},
  286. </if>
  287. <if test="keyword != null">
  288. #{keyword,jdbcType=VARCHAR},
  289. </if>
  290. <if test="picUrl != null">
  291. #{picUrl,jdbcType=VARCHAR},
  292. </if>
  293. <if test="top != null">
  294. #{top,jdbcType=INTEGER},
  295. </if>
  296. <if test="recommend != null">
  297. #{recommend,jdbcType=INTEGER},
  298. </if>
  299. <if test="content != null">
  300. #{content,jdbcType=LONGVARCHAR},
  301. </if>
  302. </trim>
  303. </insert>
  304. <select id="countByExample" parameterType="com.goafanti.common.model.JtKnowledgeBaseExample" resultType="java.lang.Integer">
  305. <!--
  306. WARNING - @mbggenerated
  307. This element is automatically generated by MyBatis Generator, do not modify.
  308. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  309. -->
  310. select count(*) from jt_knowledge_base
  311. <if test="_parameter != null">
  312. <include refid="Example_Where_Clause" />
  313. </if>
  314. </select>
  315. <update id="updateByExampleSelective" parameterType="map">
  316. <!--
  317. WARNING - @mbggenerated
  318. This element is automatically generated by MyBatis Generator, do not modify.
  319. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  320. -->
  321. update jt_knowledge_base
  322. <set>
  323. <if test="record.id != null">
  324. id = #{record.id,jdbcType=VARCHAR},
  325. </if>
  326. <if test="record.category != null">
  327. category = #{record.category,jdbcType=INTEGER},
  328. </if>
  329. <if test="record.title != null">
  330. title = #{record.title,jdbcType=VARCHAR},
  331. </if>
  332. <if test="record.summary != null">
  333. summary = #{record.summary,jdbcType=VARCHAR},
  334. </if>
  335. <if test="record.source != null">
  336. source = #{record.source,jdbcType=VARCHAR},
  337. </if>
  338. <if test="record.status != null">
  339. status = #{record.status,jdbcType=INTEGER},
  340. </if>
  341. <if test="record.createTime != null">
  342. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  343. </if>
  344. <if test="record.owner != null">
  345. owner = #{record.owner,jdbcType=VARCHAR},
  346. </if>
  347. <if test="record.releaseTime != null">
  348. release_time = #{record.releaseTime,jdbcType=TIMESTAMP},
  349. </if>
  350. <if test="record.readNumber != null">
  351. read_number = #{record.readNumber,jdbcType=INTEGER},
  352. </if>
  353. <if test="record.commentNumber != null">
  354. comment_number = #{record.commentNumber,jdbcType=INTEGER},
  355. </if>
  356. <if test="record.starNumber != null">
  357. star_number = #{record.starNumber,jdbcType=INTEGER},
  358. </if>
  359. <if test="record.keyword != null">
  360. keyword = #{record.keyword,jdbcType=VARCHAR},
  361. </if>
  362. <if test="record.picUrl != null">
  363. pic_url = #{record.picUrl,jdbcType=VARCHAR},
  364. </if>
  365. <if test="record.top != null">
  366. top = #{record.top,jdbcType=INTEGER},
  367. </if>
  368. <if test="record.recommend != null">
  369. recommend = #{record.recommend,jdbcType=INTEGER},
  370. </if>
  371. <if test="record.content != null">
  372. content = #{record.content,jdbcType=LONGVARCHAR},
  373. </if>
  374. </set>
  375. <if test="_parameter != null">
  376. <include refid="Update_By_Example_Where_Clause" />
  377. </if>
  378. </update>
  379. <update id="updateByExampleWithBLOBs" parameterType="map">
  380. <!--
  381. WARNING - @mbggenerated
  382. This element is automatically generated by MyBatis Generator, do not modify.
  383. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  384. -->
  385. update jt_knowledge_base
  386. set id = #{record.id,jdbcType=VARCHAR},
  387. category = #{record.category,jdbcType=INTEGER},
  388. title = #{record.title,jdbcType=VARCHAR},
  389. summary = #{record.summary,jdbcType=VARCHAR},
  390. source = #{record.source,jdbcType=VARCHAR},
  391. status = #{record.status,jdbcType=INTEGER},
  392. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  393. owner = #{record.owner,jdbcType=VARCHAR},
  394. release_time = #{record.releaseTime,jdbcType=TIMESTAMP},
  395. read_number = #{record.readNumber,jdbcType=INTEGER},
  396. comment_number = #{record.commentNumber,jdbcType=INTEGER},
  397. star_number = #{record.starNumber,jdbcType=INTEGER},
  398. keyword = #{record.keyword,jdbcType=VARCHAR},
  399. pic_url = #{record.picUrl,jdbcType=VARCHAR},
  400. top = #{record.top,jdbcType=INTEGER},
  401. recommend = #{record.recommend,jdbcType=INTEGER},
  402. content = #{record.content,jdbcType=LONGVARCHAR}
  403. <if test="_parameter != null">
  404. <include refid="Update_By_Example_Where_Clause" />
  405. </if>
  406. </update>
  407. <update id="updateByExample" parameterType="map">
  408. <!--
  409. WARNING - @mbggenerated
  410. This element is automatically generated by MyBatis Generator, do not modify.
  411. This element was generated on Wed Nov 07 10:11:18 CST 2018.
  412. -->
  413. update jt_knowledge_base
  414. set id = #{record.id,jdbcType=VARCHAR},
  415. category = #{record.category,jdbcType=INTEGER},
  416. title = #{record.title,jdbcType=VARCHAR},
  417. summary = #{record.summary,jdbcType=VARCHAR},
  418. source = #{record.source,jdbcType=VARCHAR},
  419. status = #{record.status,jdbcType=INTEGER},
  420. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  421. owner = #{record.owner,jdbcType=VARCHAR},
  422. release_time = #{record.releaseTime,jdbcType=TIMESTAMP},
  423. read_number = #{record.readNumber,jdbcType=INTEGER},
  424. comment_number = #{record.commentNumber,jdbcType=INTEGER},
  425. star_number = #{record.starNumber,jdbcType=INTEGER},
  426. keyword = #{record.keyword,jdbcType=VARCHAR},
  427. pic_url = #{record.picUrl,jdbcType=VARCHAR},
  428. top = #{record.top,jdbcType=INTEGER},
  429. recommend = #{record.recommend,jdbcType=INTEGER}
  430. <if test="_parameter != null">
  431. <include refid="Update_By_Example_Where_Clause" />
  432. </if>
  433. </update>
  434. <!-- 获得列表 -->
  435. <select id="getKnowledgeBaseListBySome" parameterType="java.util.Map" resultType="com.goafanti.admin.bo.KnowledgeBaseBo">
  436. select
  437. v.id, v.category, v.title, v.summary, v.source, v.status, v.create_time as createTime, v.owner, v.release_time as releaseTime,
  438. v.read_number as readNumber,
  439. v.comment_number as commentNumber, v.star_number as starNumber, v.keyword, v.pic_url as picUrl, v.top, v.recommend, a.name as ownerName
  440. from jt_knowledge_base v
  441. left join admin a on v.owner = a.id
  442. where 1=1
  443. <if test='v.title != null and v.title != ""'>
  444. <bind name="n" value="'%' + v.title + '%' " />
  445. and v.title like #{n,jdbcType=VARCHAR}
  446. </if>
  447. <if test="v.category != null">
  448. and v.category = #{v.category,jdbcType=INTEGER}
  449. </if>
  450. <if test="v.status != null">
  451. and v.status = #{v.status,jdbcType=INTEGER}
  452. </if>
  453. <if test="v.status == null">
  454. and v.status &lt;&gt; 2
  455. </if>
  456. <if test="v.owner != null">
  457. and v.owner = #{v.owner,jdbcType=VARCHAR}
  458. </if>
  459. <if test='v.keyword != null and v.keyword != ""'>
  460. <bind name="kw" value="'%' + v.keyword + '%' "/>
  461. and v.keyword like #{kw,jdbcType=VARCHAR}
  462. </if>
  463. <if test="v.startTime != null and v.endTime != null">
  464. <bind name="st" value=" v.startTime + ' 00:00:00' "/>
  465. <bind name="et" value=" v.endTime + ' 23:59:59' "/>
  466. and v.release_time between #{st,jdbcType=VARCHAR} and #{et,jdbcType=VARCHAR}
  467. </if>
  468. <if test="v.top != null">
  469. and v.top = #{v.top,jdbcType=INTEGER}
  470. </if>
  471. <if test="v.recommend != null">
  472. and v.recommend = #{v.recommend,jdbcType=INTEGER}
  473. </if>
  474. <if test="ob == 1">
  475. order by v.create_time desc
  476. </if>
  477. <if test="ob == 2">
  478. order by v.release_time desc
  479. </if>
  480. <if test="page_sql!=null">
  481. ${page_sql}
  482. </if>
  483. </select>
  484. <!-- 获得总数 -->
  485. <select id="getKnowledgeBaseCountBySome" parameterType="java.util.Map" resultType="java.lang.Integer">
  486. select count(*)
  487. from jt_knowledge_base v
  488. left join admin a on v.owner = a.id
  489. where 1=1
  490. <if test='v.title != null and v.title != ""'>
  491. <bind name="n" value="'%' + v.title + '%' " />
  492. and v.title like #{n,jdbcType=VARCHAR}
  493. </if>
  494. <if test="v.category != null">
  495. and v.category = #{v.category,jdbcType=INTEGER}
  496. </if>
  497. <if test="v.status != null">
  498. and v.status = #{v.status,jdbcType=INTEGER}
  499. </if>
  500. <if test="v.status == null">
  501. and v.status &lt;&gt; 2
  502. </if>
  503. <if test="v.owner != null">
  504. and v.owner = #{v.owner,jdbcType=VARCHAR}
  505. </if>
  506. <if test='v.keyword != null and v.keyword != ""'>
  507. <bind name="kw" value="'%' + v.keyword + '%' "/>
  508. and v.keyword like #{kw,jdbcType=VARCHAR}
  509. </if>
  510. <if test="v.startTime != null and v.endTime != null">
  511. <bind name="st" value=" v.startTime + ' 00:00:00' "/>
  512. <bind name="et" value=" v.endTime + ' 23:59:59' "/>
  513. and v.release_time between #{st,jdbcType=VARCHAR} and #{et,jdbcType=VARCHAR}
  514. </if>
  515. <if test="v.top != null">
  516. and v.top = #{v.top,jdbcType=INTEGER}
  517. </if>
  518. <if test="v.recommend != null">
  519. and v.recommend = #{v.recommend,jdbcType=INTEGER}
  520. </if>
  521. <if test="ob == 1">
  522. order by v.create_time desc
  523. </if>
  524. <if test="ob == 2">
  525. order by v.release_time desc
  526. </if>
  527. </select>
  528. <!-- 获得一个知识详情数据 -->
  529. <select id="getKnowledgeBaseById" parameterType="com.goafanti.common.model.JtKnowledgeBase" resultType="com.goafanti.admin.bo.KnowledgeBaseBo">
  530. select
  531. v.id, v.category, v.title, v.summary, v.source, v.status, v.create_time as createTime, v.owner, v.release_time as releaseTime, v.read_number as readNumber,
  532. v.comment_number as commentNumber, v.star_number as starNumber, v.keyword, v.pic_url as picUrl, v.top, v.recommend, v.content, a.name as ownerName
  533. from jt_knowledge_base v
  534. left join admin a on v.owner = a.id
  535. where 1=1
  536. <if test="id != null">
  537. and v.id = #{id,jdbcType=VARCHAR}
  538. </if>
  539. <if test="category != null">
  540. and v.category = #{category,jdbcType=INTEGER}
  541. </if>
  542. <if test='title != null and title != ""'>
  543. <bind name="n" value="'%' + title + '%' " />
  544. and v.title like #{n,jdbcType=VARCHAR}
  545. </if>
  546. <if test="summary != null">
  547. <bind name="s" value="'%' + summary + '%' " />
  548. and v.summary like #{s,jdbcType=VARCHAR}
  549. </if>
  550. <if test="source != null">
  551. and v.source = #{source,jdbcType=VARCHAR}
  552. </if>
  553. <if test="status != null">
  554. and v.status = #{status,jdbcType=INTEGER}
  555. </if>
  556. <if test="owner != null">
  557. and v.owner #{owner,jdbcType=VARCHAR}
  558. </if>
  559. <if test="readNumber != null">
  560. and v.read_number = #{readNumber,jdbcType=INTEGER}
  561. </if>
  562. <if test="commentNumber != null">
  563. and v.comment_number = #{commentNumber,jdbcType=INTEGER}
  564. </if>
  565. <if test="starNumber != null">
  566. and v.star_Number = #{starNumber,jdbcType=INTEGER}
  567. </if>
  568. <if test="keyword != null">
  569. <bind name="kw" value="'%' + keyword + '%' "/>
  570. and v.keyword like #{kw,jdbcType=VARCHAR}
  571. </if>
  572. <if test="picUrl != null">
  573. and v.pic_url = #{picUrl,jdbcType=VARCHAR}
  574. </if>
  575. <if test="top != null">
  576. and v.top = #{top,jdbcType=INTEGER}
  577. </if>
  578. <if test="recommend != null">
  579. and v.recommend = #{recommend,jdbcType=INTEGER}
  580. </if>
  581. </select>
  582. <!-- 修改 -->
  583. <update id="updateBySome" parameterType="com.goafanti.common.model.JtKnowledgeBase">
  584. update jt_knowledge_base
  585. <set>
  586. <if test="category != null">
  587. category = #{category,jdbcType=INTEGER},
  588. </if>
  589. <if test="title != null">
  590. title = #{title,jdbcType=VARCHAR},
  591. </if>
  592. <if test="summary != null">
  593. summary = #{summary,jdbcType=VARCHAR},
  594. </if>
  595. <if test="source != null">
  596. source = #{source,jdbcType=VARCHAR},
  597. </if>
  598. <if test="status != null">
  599. status = #{status,jdbcType=INTEGER},
  600. </if>
  601. <if test="createTime != null">
  602. create_time = #{createTime,jdbcType=TIMESTAMP},
  603. </if>
  604. <if test="owner != null">
  605. owner = #{owner,jdbcType=VARCHAR},
  606. </if>
  607. <if test="releaseTime != null">
  608. release_time = #{releaseTime,jdbcType=TIMESTAMP},
  609. </if>
  610. <if test="picUrl != null">
  611. pic_url = #{picUrl,jdbcType=VARCHAR},
  612. </if>
  613. <if test="top != null">
  614. top = #{top,jdbcType=INTEGER},
  615. </if>
  616. <if test="recommend != null">
  617. recommend = #{recommend,jdbcType=INTEGER},
  618. </if>
  619. <if test="keyword != null">
  620. keyword = #{keyword,jdbcType=VARCHAR},
  621. </if>
  622. <if test="content != null">
  623. content = #{content,jdbcType=LONGVARCHAR},
  624. </if>
  625. </set>
  626. where id = #{id,jdbcType=VARCHAR}
  627. </update>
  628. <!-- 新增一个阅读量 -->
  629. <update id="addOneRead" parameterType="java.lang.String">
  630. update jt_knowledge_base set read_number = read_number +1
  631. where
  632. id = #{_parameter,jdbcType=VARCHAR}
  633. </update>
  634. <!-- 新增一个评论量 -->
  635. <update id="addOneComment" parameterType="java.lang.String">
  636. update jt_knowledge_base set comment_number = comment_number +1
  637. where
  638. id = #{_parameter,jdbcType=VARCHAR}
  639. </update>
  640. <!-- 新增一个点赞量 -->
  641. <update id="addOneStar" parameterType="java.lang.String">
  642. update jt_knowledge_base set star_number = star_number +1
  643. where
  644. id = #{_parameter,jdbcType=VARCHAR}
  645. </update>
  646. <!-- 标题检查 -->
  647. <select id="nameCheck" parameterType="java.lang.String" resultType="java.lang.Integer">
  648. select count(*) from jt_knowledge_base where title = #{_parameter,jdbcType=VARCHAR}
  649. </select>
  650. </mapper>