SysNewsInformationMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.cms.dal.dao.SysNewsInformationDao">
  8. <resultMap type="com.ym.mec.cms.dal.entity.SysNewsInformation" id="SysNewsInformation">
  9. <result column="id_" property="id" />
  10. <result column="title_" property="title" />
  11. <result column="content_" property="content" />
  12. <result column="cover_image_" property="coverImage" />
  13. <result column="video_cover_image_" property="videoCoverImage" />
  14. <result column="link_url_" property="linkUrl"/>
  15. <result column="type_" property="type"/>
  16. <result column="online_time_" property="onlineTime"/>
  17. <result column="offline_time_" property="offlineTime"/>
  18. <result column="sub_type_" property="subType"/>
  19. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. <result column="del_flag_" property="delFlag" />
  23. <result column="href_target_" property="hrefTarget" />
  24. <result column="order_" property="order" />
  25. <result column="memo_" property="memo" />
  26. <result column="tenant_id_" property="tenantId" />
  27. <result column="attribute1_" property="attribute1" />
  28. <result column="attribute2_" property="attribute2" />
  29. <result column="subject_id_list_" property="subjectIdList" />
  30. <result column="organ_id_list_" property="organIdList" />
  31. <result column="subject_name_" property="subjectName" />
  32. <result column="organ_name_list_" property="organNameList" />
  33. </resultMap>
  34. <resultMap type="com.ym.mec.cms.dto.SysNewsInformationDto" id="SysNewsInformationDto" extends="SysNewsInformation">
  35. <result column="typeName" property="typeName" />
  36. <result column="subTypeName" property="subTypeName" />
  37. </resultMap>
  38. <sql id="queryCondition">
  39. <where>
  40. sni.del_flag_=0 and sni.tenant_id_ = #{tenantId}
  41. <if test="type != null">
  42. and sni.type_ = #{type}
  43. </if>
  44. <if test="subType != null">
  45. and sni.sub_type_ = #{subType}
  46. </if>
  47. <if test="status != null">
  48. and sni.status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  49. </if>
  50. <if test="title != null">
  51. and sni.title_ like '%' #{title} '%'
  52. </if>
  53. <if test="search != null">
  54. and sni.title_ like '%' #{search} '%'
  55. </if>
  56. <if test="subjectId != null">
  57. and find_in_set(#{subjectId},sni.subject_id_list_)
  58. </if>
  59. <if test="organId != null">
  60. and (find_in_set(#{organId},sni.organ_id_list_) or sni.organ_id_list_ is null)
  61. </if>
  62. <if test="organIdList != null">
  63. and INTE_ARRAY(#{organIdList},sni.organ_id_list_)
  64. </if>
  65. <if test="excludeIds!=null and excludeIds.size()>0">
  66. AND sni.id_ NOT IN
  67. <foreach collection="excludeIds" item="excludeId" open="(" close=")" separator=",">
  68. #{excludeId}
  69. </foreach>
  70. </if>
  71. <if test="clientName != 'manage'">
  72. <choose>
  73. <when test="memo != null and memo != ''">
  74. and sni.memo_ = #{memo}
  75. </when>
  76. <otherwise>
  77. and (sni.memo_ is null or sni.memo_ = '')
  78. </otherwise>
  79. </choose>
  80. </if>
  81. </where>
  82. </sql>
  83. <!-- 根据主键查询一条记录 -->
  84. <select id="get" resultMap="SysNewsInformation" >
  85. SELECT * FROM sys_news_information WHERE id_ = #{id} AND del_flag_=0
  86. </select>
  87. <!-- 全查询 -->
  88. <select id="findAll" resultMap="SysNewsInformation">
  89. SELECT * FROM sys_news_information WHERE del_flag_=0 ORDER BY id_
  90. </select>
  91. <!-- 向数据库增加一条记录 -->
  92. <insert id="insert" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  93. INSERT INTO sys_news_information (id_,title_,content_,cover_image_,video_cover_image_,type_,online_time_,offline_time_,sub_type_,status_,create_time_,update_time_,link_url_,href_target_,order_,del_flag_,memo_,tenant_id_,attribute1_,attribute2_,subject_id_list_,organ_id_list_)
  94. VALUES(#{id},#{title},#{content},#{coverImage},#{videoCoverImage},#{type},#{onlineTime},#{offlineTime},#{subType},#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now(),now(),#{linkUrl},#{hrefTarget},#{order},0,#{memo},#{tenantId},#{attribute1},#{attribute2},#{subjectIdList},#{organIdList})
  95. </insert>
  96. <!-- 根据主键查询一条记录 -->
  97. <update id="update" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation">
  98. UPDATE sys_news_information
  99. <set>
  100. <if test="status != null">
  101. status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  102. </if>
  103. <if test="title != null">
  104. title_ = #{title},
  105. </if>
  106. <if test="tenantId != null">
  107. tenant_id_ = #{tenantId},
  108. </if>
  109. <if test="updateTime != null">
  110. update_time_ = NOW(),
  111. </if>
  112. <if test="content != null">
  113. content_ = #{content},
  114. </if>
  115. <if test="coverImage != null">
  116. cover_image_ = #{coverImage},
  117. </if>
  118. <if test="videoCoverImage != null">
  119. video_cover_image_ = #{videoCoverImage},
  120. </if>
  121. <if test="type != null">
  122. type_ = #{type},
  123. </if>
  124. online_time_ = #{onlineTime},
  125. offline_time_ = #{offlineTime},
  126. <if test="subType != null">
  127. sub_type_ = #{subType},
  128. </if>
  129. <if test="linkUrl != null">
  130. link_url_ = #{linkUrl},
  131. </if>
  132. <if test="hrefTarget != null">
  133. href_target_ = #{hrefTarget},
  134. </if>
  135. <if test="order != null">
  136. order_ = #{order},
  137. </if>
  138. <if test="memo != null">
  139. memo_ = #{memo},
  140. </if>
  141. <if test="delFlag != null">
  142. del_flag_ = #{delFlag},
  143. </if>
  144. <if test="attribute1 != null">
  145. attribute1_ = #{attribute1},
  146. </if>
  147. <if test="attribute2 != null">
  148. attribute2_ = #{attribute2},
  149. </if>
  150. <if test="subjectIdList != null">
  151. subject_id_list_ = #{subjectIdList},
  152. </if>
  153. <if test="organIdList != null">
  154. organ_id_list_ = #{organIdList},
  155. </if>
  156. </set>
  157. WHERE id_ = #{id}
  158. </update>
  159. <!-- 根据主键删除一条记录 -->
  160. <delete id="delete" >
  161. DELETE FROM sys_news_information WHERE id_ = #{id}
  162. </delete>
  163. <!-- 分页查询 -->
  164. <select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
  165. SELECT sni.*,GROUP_CONCAT(distinct s.name_) subject_name_,GROUP_CONCAT(distinct o.name_) organ_name_list_
  166. FROM sys_news_information sni left join subject s on find_in_set(s.id_,sni.subject_id_list_)
  167. left join organization o on find_in_set(o.id_,sni.organ_id_list_)
  168. <include refid="queryCondition" />
  169. group by sni.id_
  170. order by sni.status_ desc,sni.order_ desc,sni.update_time_ desc
  171. <include refid="global.limit"/>
  172. </select>
  173. <!-- 查询当前表的总记录数 -->
  174. <select id="queryCount" resultType="int">
  175. SELECT COUNT(sni.id_) FROM sys_news_information sni
  176. <include refid="queryCondition" />
  177. </select>
  178. <select id="queryBottomInfo" resultMap="SysNewsInformation" parameterType="java.lang.Integer">
  179. SELECT * FROM sys_news_information
  180. where del_flag_=0 and status_ = 1
  181. and sub_type_ = #{subType}
  182. </select>
  183. <update id="deleteWithLogical">
  184. UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  185. </update>
  186. <!-- 分页查询 -->
  187. <select id="queryHomePage" resultMap="SysNewsInformation"
  188. parameterType="map">
  189. SELECT sni.*,GROUP_CONCAT(s.name_) subject_name_ FROM sys_news_information sni left join subject s on find_in_set(s.id_,sni.subject_id_list_) where sni.del_flag_=0 and sni.tenant_id_ = #{tenantId}
  190. <if test="type != null">
  191. and sni.type_ = #{type}
  192. </if>
  193. <if test="subType != null">
  194. and sni.sub_type_ = #{subType}
  195. </if>
  196. <if test="status != null">
  197. and sni.status_ = #{status,
  198. typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  199. </if>
  200. <if test="title != null">
  201. and sni.title_ like '%' #{title} '%'
  202. </if>
  203. <if test="search != null">
  204. and sni.title_ like '%' #{search} '%'
  205. </if>
  206. <if test="excludeIds!=null and excludeIds.size()>0">
  207. AND sni.id_ NOT IN
  208. <foreach collection="excludeIds" item="excludeId" open="(" close=")" separator=",">
  209. #{excludeId}
  210. </foreach>
  211. </if>
  212. <if test="subjectId != null">
  213. and find_in_set(#{subjectId},sni.subject_id_list_)
  214. </if>
  215. <if test="organId != null">
  216. and (find_in_set(#{organId},sni.organ_id_list_) or sni.organ_id_list_ is null or sni.organ_id_list_ = '')
  217. </if>
  218. <if test="clientName != 'manage'">
  219. <choose>
  220. <when test="memo != null and memo != ''">
  221. and sni.memo_ = #{memo}
  222. </when>
  223. <otherwise>
  224. and (sni.memo_ is null or sni.memo_ = '')
  225. </otherwise>
  226. </choose>
  227. </if>
  228. group by sni.id_
  229. order by sni.status_ desc,sni.order_ desc,sni.update_time_ desc
  230. <include refid="global.limit" />
  231. </select>
  232. <!-- 查询当前表的总记录数 -->
  233. <select id="queryHomeCount" resultType="int">
  234. SELECT COUNT(sni.id_) FROM sys_news_information sni where sni.del_flag_=0 and sni.tenant_id_ = #{tenantId}
  235. <if test="type != null">
  236. and sni.type_ = #{type}
  237. </if>
  238. <if test="subType != null">
  239. and sni.sub_type_ = #{subType}
  240. </if>
  241. <if test="status != null">
  242. and sni.status_ = #{status,
  243. typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  244. </if>
  245. <if test="title != null">
  246. and sni.title_ like '%' #{title} '%'
  247. </if>
  248. <if test="search != null">
  249. and sni.title_ like '%' #{search} '%'
  250. </if>
  251. <if test="excludeIds!=null and excludeIds.size()>0">
  252. AND sni.id_ NOT IN
  253. <foreach collection="excludeIds" item="excludeId" open="(" close=")" separator=",">
  254. #{excludeId}
  255. </foreach>
  256. </if>
  257. <if test="subjectId != null">
  258. and find_in_set(#{subjectId},sni.subject_id_list_)
  259. </if>
  260. <if test="organId != null">
  261. and (find_in_set(#{organId},sni.organ_id_list_) or sni.organ_id_list_ is null or sni.organ_id_list_ = '')
  262. </if>
  263. <if test="clientName != 'manage'">
  264. <choose>
  265. <when test="memo != null and memo != ''">
  266. and sni.memo_ = #{memo}
  267. </when>
  268. <otherwise>
  269. and (sni.memo_ is null or sni.memo_ = '')
  270. </otherwise>
  271. </choose>
  272. </if>
  273. </select>
  274. <select id="queryNeedUpdateStatusList" resultMap="SysNewsInformation" >
  275. SELECT * FROM sys_news_information WHERE del_flag_ = 0 and (
  276. (online_time_ is not null and now() between online_time_ and offline_time_ and status_ = 0)
  277. or (offline_time_ is not null and offline_time_ &lt;= now() and status_ = 1)
  278. or (online_time_ is not null and online_time_ &gt;= now() and status_ = 1)
  279. )
  280. </select>
  281. <select id="queryById" resultMap="SysNewsInformationDto" >
  282. SELECT sni.*,sntp.name_ typeName,snts.name_ subTypeName FROM sys_news_information sni
  283. left join sys_news_type sntp on sni.type_ = sntp.id_
  284. left join sys_news_type snts on sni.sub_type_ = snts.id_
  285. where sni.id_ = #{id}
  286. </select>
  287. <select id="queryBySubType" resultMap="SysNewsInformation">
  288. SELECT * FROM sys_news_information
  289. WHERE del_flag_=0
  290. AND status_=1
  291. <if test="subType != null">
  292. AND sub_type_ = #{subType}
  293. </if>
  294. <if test="memo == null or memo == ''">
  295. AND (memo_ IS NULL OR memo_ = '')
  296. </if>
  297. <if test="memo != null and memo !=''">
  298. AND memo_ = #{memo}
  299. </if>
  300. <if test="organIds != null and organIds !=''">
  301. AND INTE_ARRAY(#{organIds},organ_id_list_) OR organ_id_list_ IS NULL OR organ_id_list_ = ''
  302. </if>
  303. ORDER BY order_ DESC
  304. </select>
  305. <select id="countStudentAttendanceError" resultType="java.lang.Boolean">
  306. SELECT COUNT(DISTINCT cs.id_) FROM course_schedule cs
  307. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  308. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_ AND cssp.user_id_ = sa.user_id_
  309. LEFT JOIN teacher_attendance ta on ta.course_schedule_id_ = cs.id_
  310. LEFT JOIN course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
  311. where cs.del_flag_ = '0' AND cs.pre_course_flag_ != 1 AND csts.user_id_ = #{userId} AND cs.status_ = 'OVER' AND cs.class_date_ BETWEEN #{startTime} AND DATE(NOW())
  312. AND (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0))
  313. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  314. AND cs.merge_flag_ IN (0,1) AND cssp.id_ IS NOT NULL
  315. AND (ta.sign_out_status_ IS NOT NULL OR ta.sign_in_status_ IS NOT NULL)
  316. </select>
  317. <select id="queryHomework" resultType="java.lang.Integer">
  318. SELECT count( csts.course_schedule_id_)
  319. FROM course_schedule_teacher_salary csts
  320. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  321. LEFT JOIN student_extracurricular_exercises_situation_ se ON se.teacher_id_ = csts.user_id_
  322. left join lesson_examination le on le.course_schedule_id_ = csts.course_schedule_id_
  323. left join teacher_attendance ta on ta.course_schedule_id_ = csts.course_schedule_id_
  324. WHERE csts.user_id_ = #{teacherId}
  325. AND cs.class_date_ = date_format(now(),'%Y-%m-%d')
  326. AND FIND_IN_SET(cs.id_, se.course_ids_) and le.id_ is null
  327. AND se.serve_type_ = 'HOMEWORK'
  328. and ta.sign_out_status_ is null and ta.sign_in_status_ is not null
  329. </select>
  330. <select id="queryPractice" resultType="int">
  331. SELECT
  332. count(distinct sees.music_group_id_)
  333. from
  334. student_extracurricular_exercises_situation_ sees
  335. LEFT JOIN
  336. music_group mg
  337. on mg.id_ = sees.music_group_id_
  338. WHERE
  339. sees.teacher_id_ = #{userId}
  340. and sees.serve_type_ = 'EXERCISE'
  341. and sees.actual_exercises_num_ = 0
  342. and sees.monday_ = #{date}
  343. </select>
  344. <select id="queryTeacherOrgan" resultType="java.lang.String">
  345. select organ_id_ from teacher where id_ = #{userId}
  346. </select>
  347. </mapper>