ElectricFenceMapper.xml 5.52 KB
<?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="cn.com.glsx.admin.modules.mapper.ElectricFenceMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.ElectricFence">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="fence_name" jdbcType="VARCHAR" property="fenceName"/>
        <result column="biz_fence_type" jdbcType="TINYINT" property="bizFenceType"/>
        <result column="location_type" jdbcType="TINYINT" property="locationType"/>
        <result column="shape_type" jdbcType="TINYINT" property="shapeType"/>
        <result column="radius" jdbcType="INTEGER" property="radius"/>
        <result column="trigger_type" jdbcType="TINYINT" property="triggerType"/>
        <result column="time_type" jdbcType="TINYINT" property="timeType"/>
        <result column="start_time" jdbcType="DATE" property="startTime"/>
        <result column="end_time" jdbcType="DATE" property="endTime"/>
        <result column="enable_status" jdbcType="TINYINT" property="enableStatus"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="area_code" jdbcType="VARCHAR" property="areaCode"/>
        <result column="area_text" jdbcType="VARCHAR" property="areaText"/>
        <result column="analysis_address" jdbcType="VARCHAR" property="analysisAddress"/>
        <result column="tel_numbers" jdbcType="VARCHAR" property="telNumbers"/>
        <result column="record" jdbcType="VARCHAR" property="record"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
    </resultMap>
    <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.glsx.admin.modules.entity.ElectricFence">
        <!--
          WARNING - @mbg.generated
        -->
        <result column="lnglat" jdbcType="LONGVARCHAR" property="lnglat"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, fence_name, biz_fence_type, location_type, shape_type, radius,
        trigger_type, time_type, start_time, end_time, `enable_status`, remark, area_code, area_text,
        record, analysis_address, tel_numbers, del_flag, created_date, created_by,
        updated_date, updated_by
    </sql>
    <sql id="Blob_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        lnglat
    </sql>

    <select id="selectById" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>,
        <include refid="Blob_Column_List"/>
        from t_electric_fence
        where del_flag = 0
        and id = #{id}
    </select>

    <select id="selectByFenceNameAndBizType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from t_electric_fence
        where del_flag = 0
        and fence_name = #{fenceName}
        and biz_fence_type = #{bizFenceType}
        limit 1
    </select>

    <select id="selectAllNotDel" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>,
        <include refid="Blob_Column_List"/>
        from t_electric_fence
        where del_flag = 0
    </select>

    <select id="search" resultType="cn.com.glsx.admin.modules.model.ElectricFenceDTO">
        select tef.id fenceId,
        tef.fence_name fenceName,
        tu.username shopName,
        tu.account shopCode,
        ttds.shop_level shopLevel,
        tef.created_date createdDate,
        tef.created_by createdBy,
        biz_fence_type as bizFenceType
        from t_electric_fence tef
        left join t_user tu on tu.id = tef.created_by
        left join t_trial_drive_shop ttds on ttds.fence_id = tef.id
        where tef.del_flag = 0
        and tef.biz_fence_type = 12
        <if test="term != null and term !=''">
            and (
            ttds.shop_name like CONCAT('%',#{term},'%')
            or
            ttds.shop_code like CONCAT('%',#{term},'%')
            or
            tef.fence_name like CONCAT('%',#{term},'%')
            )
        </if>
        order by tef.id desc
    </select>

    <select id="export" resultType="cn.com.glsx.admin.modules.model.export.ElectricFenceExport">
        select tef.id fenceId,
        tef.fence_name fenceName,
        tu.username shopName,
        tu.account shopCode,
        ttds.shop_level shopLevel,
        tef.created_date createdDate,
        tef.created_by createdBy,
        tef.biz_fence_type bizFenceType
        from t_electric_fence tef
        left join t_user tu on tu.id = tef.created_by
        left join t_trial_drive_shop ttds on ttds.fence_id = tef.id
        where tef.del_flag = 0
        and tef.biz_fence_type = 12
        <if test="term != null and term !=''">
            and (
            ttds.shop_name like CONCAT('%',#{term},'%')
            or
            ttds.shop_code like CONCAT('%',#{term},'%')
            or
            tef.fence_name like CONCAT('%',#{term},'%')
            )
        </if>
        order by tef.id desc
    </select>

    <update id="logicDeleteById">
        update t_electric_fence
        set del_flag = -1
        where id = #{id}
    </update>
</mapper>