|
- <?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.iformall.mapper.KwMerchantMeterMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.KwMerchantMeter">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="meter_id" jdbcType="BIGINT" property="meterId"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
-
-
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`meter_id`,`merchant_id`,`status`,`create_time`,`update_time`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId ">
- and `tenant_id` = #{tenantId}
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != meterId ">
- and `meter_id` = #{meterId}
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.KwMerchantMeter" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from kw_merchant_meter
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <resultMap id="MeterBaseResultMap" type="com.iformall.domain.po.KwMeter">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="address" jdbcType="BIGINT" property="address"/>
- <result column="brand" jdbcType="VARCHAR" property="brand"/>
- <result column="place" jdbcType="VARCHAR" property="place"/>
- <result column="model" jdbcType="VARCHAR" property="model"/>
- <result column="protocol" jdbcType="INTEGER" property="protocol"/>
- <result column="bandrate" jdbcType="INTEGER" property="bandrate"/>
- <result column="last_online_time" jdbcType="TIMESTAMP" property="lastOnlineTime"/>
- <result column="online_status" jdbcType="INTEGER" property="onlineStatus"/>
- <result column="config" jdbcType="VARCHAR" property="config"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="box_id" jdbcType="BIGINT" property="boxId"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="bind_status" jdbcType="INTEGER" property="bindStatus"/>
- </resultMap>
-
- <select id="findMeterList" parameterType="java.util.Map" resultMap="MeterBaseResultMap">
- select m.* from kw_merchant_meter mm
- left join kw_meter m on mm.`meter_id` = m.id
- where mm.`status` = 0 and m.`bind_status` = 0
- <if test=" null != merchantId ">
- and mm.`merchant_id` = #{merchantId}
- </if>
- </select>
-
-
- <resultMap id="BaseResultMapVo" type="com.iformall.domain.vo.KwMerchantMeterVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
-
- <result column="name" jdbcType="VARCHAR" property="merchantName"/>
- <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
-
- <collection column="{merchantId=id}" property="shopVoList"
- ofType="com.iformall.domain.vo.WxShopVo"
- javaType="java.util.List"
- select="com.iformall.mapper.WxShopMapper.findShopVoList">
- </collection>
-
- <collection column="{merchantId=id}" property="meterList"
- ofType="com.iformall.domain.po.kwMeter"
- javaType="java.util.List"
- select="com.iformall.mapper.KwMerchantMeterMapper.findMeterList">
- </collection>
-
- </resultMap>
-
- <sql id="allColumnsVo">
- `id`, `tenant_id`, `merchant_id`, `status`, `name`, `link_phone`
- </sql>
-
- <select id="findListVo" parameterType="com.iformall.domain.dto.KwMerchantMeterDto" resultMap="BaseResultMapVo">
- select <include refid="allColumnsVo"/>
- from (
- select merchant_id from kw_merchant_meter
- where `status` = 0
-
- <if test=" null != tenantId ">
- and `tenant_id` = #{tenantId}
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- group by merchant_id
- ) temp
- , wx_merchant
- where temp.merchant_id = id
-
- </select>
-
- <select id="getById" parameterType="java.lang.Long" resultMap="BaseResultMapVo">
- select <include refid="allColumnsVo"/>
- from (
- select merchant_id from kw_merchant_meter
- where `status` = 0
- and `merchant_id` = #{merchantId}
- group by merchant_id
- ) temp
- , wx_merchant
- where temp.merchant_id = id
- </select>
-
- <update id="unbindBatch" parameterType="com.iformall.domain.po.KwMerchantMeter">
- update kw_merchant_meter set status = 1
- where status = 0
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != meterId ">
- and `meter_id` = #{meterId}
- </if>
-
- </update>
-
- </mapper>
|