|
@@ -0,0 +1,144 @@
|
|
|
+<?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.huaxu.dao.SceneMapper">
|
|
|
+ <resultMap type="SceneEntity" id="SceneResult">
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="tenantId" column="tenant_id"/>
|
|
|
+ <result property="parentSceneId" column="parent_scene_id"/>
|
|
|
+ <result property="sceneName" column="scene_name"/>
|
|
|
+ <result property="companyOrgId" column="company_org_id"/>
|
|
|
+ <result property="deptOrgId" column="dept_org_id"/>
|
|
|
+ <result property="sceneTypeId" column="scene_type_id"/>
|
|
|
+ <result property="enableState" column="enable_state"/>
|
|
|
+ <result property="runTime" column="run_time"/>
|
|
|
+ <result property="address" column="address"/>
|
|
|
+ <result property="pointX" column="point_x"/>
|
|
|
+ <result property="pointY" column="point_y"/>
|
|
|
+ <result property="remark" column="remark"/>
|
|
|
+ <result property="status" column="status"/>
|
|
|
+ <result property="dateCreate" column="date_create"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="dateUpdate" column="date_update"/>
|
|
|
+ <result property="updateBy" column="update_by"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 实体栏位 -->
|
|
|
+ <sql id="sceneColumns">
|
|
|
+ a.id as "id" ,
|
|
|
+ a.tenant_id as "tenantId" ,
|
|
|
+ a.parent_scene_id as "parentSceneId" ,
|
|
|
+ a.scene_name as "sceneName" ,
|
|
|
+ a.company_org_id as "companyOrgId" ,
|
|
|
+ a.dept_org_id as "deptOrgId" ,
|
|
|
+ a.scene_type_id as "sceneTypeId" ,
|
|
|
+ a.enable_state as "enableState" ,
|
|
|
+ a.run_time as "runTime" ,
|
|
|
+ a.address as "address" ,
|
|
|
+ a.point_x as "pointX" ,
|
|
|
+ a.point_y as "pointY" ,
|
|
|
+ a.remark as "remark" ,
|
|
|
+ a.status as "status" ,
|
|
|
+ a.date_create as "dateCreate" ,
|
|
|
+ a.create_by as "createBy" ,
|
|
|
+ a.date_update as "dateUpdate" ,
|
|
|
+ a.update_by as "updateBy"
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 根据主键获取实体 -->
|
|
|
+ <select id="findSceneById" resultType="com.huaxu.entity.SceneEntity">
|
|
|
+ SELECT
|
|
|
+ <include refid="sceneColumns"/>
|
|
|
+ FROM sms_scene a
|
|
|
+ WHERE a.id = #{id} and a.status=1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据获取实体List -->
|
|
|
+ <select id="findList" resultType="com.huaxu.entity.SceneEntity">
|
|
|
+ SELECT
|
|
|
+ <include refid="sceneColumns"/>
|
|
|
+ FROM sms_scene a
|
|
|
+ <where>
|
|
|
+ a.status=1
|
|
|
+ <if test="scene.tenantId != null and scene.tenantId != ''">and a.tenant_id = #{scene.tenantId}</if>
|
|
|
+ <if test="scene.parentSceneId != null ">and a.parent_scene_id = #{scene.parentSceneId}</if>
|
|
|
+ <if test="scene.sceneName != null and scene.sceneName != ''">
|
|
|
+ and a.scene_name LIKE concat('%',#{scene.sceneName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="scene.sceneTypeId != null ">and a.scene_type_id = #{scene.sceneTypeId}</if>
|
|
|
+ <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
+ <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 1">
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ order by a.date_create
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据获取实体 page -->
|
|
|
+ <select id="findPage" resultType="com.huaxu.entity.SceneEntity">
|
|
|
+ SELECT
|
|
|
+ <include refid="sceneColumns"/>
|
|
|
+ FROM sms_scene a
|
|
|
+ <where>
|
|
|
+ a.status=1 and a.parent_scene_id=0
|
|
|
+ <if test="scene.tenantId != null and scene.tenantId != ''">and a.tenant_id = #{scene.tenantId}</if>
|
|
|
+ <if test="scene.parentSceneId != null ">and a.parent_scene_id = #{scene.parentSceneId}</if>
|
|
|
+ <if test="scene.sceneName != null and scene.sceneName != ''">
|
|
|
+ and a.scene_name LIKE concat('%',#{scene.sceneName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="scene.sceneTypeId != null ">and a.scene_type_id = #{scene.sceneTypeId}</if>
|
|
|
+ <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
+ <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 1">
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ order by a.date_create
|
|
|
+ </select>
|
|
|
+</mapper>
|