<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.panzhihua.service_community.dao.ComFmsClassroomDAO">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComFmsClassroom" id="ComFmsClassroomMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="title" column="title" jdbcType="VARCHAR"/>
|
<result property="scholars" column="scholars" jdbcType="INTEGER"/>
|
<result property="cover" column="cover" jdbcType="VARCHAR"/>
|
<result property="content" column="content" jdbcType="VARCHAR"/>
|
<result property="viewNum" column="view_num" jdbcType="INTEGER"/>
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
<result property="createdBy" column="created_by" jdbcType="INTEGER"/>
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
<result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
|
<result property="communityId" column="community_id" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_fms_classroom(title, scholars, cover, content, view_num, created_at, created_by, updated_at, updated_by, community_id)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.title}, #{entity.scholars}, #{entity.cover}, #{entity.content}, #{entity.viewNum}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
|
</foreach>
|
</insert>
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_fms_classroom(title, scholars, cover, content, view_num, created_at, created_by, updated_at, updated_by, community_id)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.title}, #{entity.scholars}, #{entity.cover}, #{entity.content}, #{entity.viewNum}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
|
</foreach>
|
on duplicate key update
|
title = values(title) , scholars = values(scholars) , cover = values(cover) , content = values(content) , view_num = values(view_num) , created_at = values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by = values(updated_by) , community_id = values(community_id) </insert>
|
<select id="pageFmsClassroomAdmin"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsClassroomVO">
|
SELECT id, title, scholars, cover, view_num, created_at
|
FROM com_fms_classroom
|
WHERE community_id = #{adminDTO.communityId}
|
<if test='adminDTO.keyword != null and adminDTO.keyword != "" '>
|
AND title LIKE CONCAT('%',#{adminDTO.keyword},'%')
|
</if>
|
<if test='adminDTO.createdAtBegin != null '>
|
AND created_at >= #{adminDTO.createdAtBegin}
|
</if>
|
<if test='adminDTO.createdAtEnd != null '>
|
AND created_at <= #{adminDTO.createdAtEnd}
|
</if>
|
ORDER BY created_at DESC
|
</select>
|
<select id="statisticsFmsClassroom"
|
resultType="com.panzhihua.common.model.vos.community.fms.FmsClassroomTopStatisticsVO">
|
SELECT
|
(SELECT COUNT(id) FROM com_fms_classroom WHERE community_id = #{communityId}) AS classroomCount,
|
(SELECT IF(SUM(scholars) IS NULL,0,SUM(scholars)) FROM com_fms_classroom WHERE community_id = #{communityId}) AS learnCount
|
</select>
|
<select id="pageFmsEvent" resultType="com.panzhihua.common.model.vos.community.fms.FmsEventVO">
|
SELECT e.id, e.event_clazz, egd.grid_name, e.happent_lat_lng, e.happen_time, e.event_des,
|
e.danger_level, e.urgent, e.major, e.event_process_status
|
FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND egd.grid_community_id = #{adminDTO.communityId}
|
<if test="adminDTO.eventClazz != null and adminDTO.eventClazz != """>
|
AND e.event_clazz = #{adminDTO.eventClazz}
|
</if>
|
<if test="adminDTO.eventProcessStatus != null">
|
AND e.event_process_status = #{adminDTO.eventProcessStatus}
|
</if>
|
<if test="adminDTO.eventProcessStatus == null">
|
AND e.event_process_status IN(1,2)
|
</if>
|
<if test="adminDTO.type != null and adminDTO.type == 1">
|
AND e.event_type = 3
|
</if>
|
<if test="adminDTO.type != null and adminDTO.type == 2">
|
AND e.event_type = 1
|
</if>
|
<if test="adminDTO.keyword != null and adminDTO.keyword != """>
|
AND e.event_des LIKE CONCAT('%',#{adminDTO.keyword},'%')
|
</if>
|
ORDER BY e.happen_time DESC
|
</select>
|
<select id="statisticsFmsEvent"
|
resultType="com.panzhihua.common.model.vos.community.fms.FmsEventTopStatisticsVO">
|
SELECT
|
(SELECT COUNT(e.id) FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND e.event_process_status = 1 AND egd.grid_community_id = #{communityId}
|
<if test="type != null and type == 1">
|
AND e.event_type = 3
|
</if>
|
<if test="type != null and type == 2">
|
AND e.event_type = 1
|
</if>
|
) AS unHandledCount,
|
(SELECT COUNT(e.id) FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND e.event_process_status = 2 AND egd.grid_community_id = #{communityId}
|
<if test="type != null and type == 1">
|
AND e.event_type = 3
|
</if>
|
<if test="type != null and type == 2">
|
AND e.event_type = 1
|
</if>
|
) AS handledCount
|
</select>
|
<select id="pageFmsEventApplets" resultType="com.panzhihua.common.model.vos.grid.EventVO">
|
SELECT e.id, e.event_clazz, e.happen_time, e.event_des, e.grid_member_id
|
FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND egd.grid_community_id = #{adminDTO.communityId} AND e.event_process_status = 2
|
<if test="adminDTO.eventClazz != null and adminDTO.eventClazz != """>
|
AND e.event_clazz = #{adminDTO.eventClazz}
|
</if>
|
<if test="adminDTO.type != null and adminDTO.type == 1">
|
AND e.event_type = 3
|
</if>
|
<if test="adminDTO.type != null and adminDTO.type == 2">
|
AND e.event_type = 1
|
</if>
|
ORDER BY e.happen_time DESC
|
</select>
|
|
</mapper>
|