123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?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.bz.smart_city.dao.SiteMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Site">
- <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
- <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
- <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
- <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
- <result column="id" property="id" jdbcType="INTEGER"/>
- <result column="name" property="name" jdbcType="VARCHAR"/>
- <result column="website" property="website" jdbcType="VARCHAR"/>
- <result column="logo_url" property="logoUrl" jdbcType="VARCHAR"/>
- <result column="status" property="status" jdbcType="INTEGER"/>
- <result column="type" property="type" jdbcType="INTEGER"/>
- <result column="customer_id" property="customerId" jdbcType="INTEGER"/>
- </resultMap>
- <!--auto generated Code-->
- <sql id="Base_Column_List">
- create_date,
- create_by,
- update_date,
- update_by,
- id,
- name,
- website,
- logo_url,
- status,
- type,
- customer_id
- </sql>
- <!--auto generated Code-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="site.id">
- INSERT INTO sc_site (
- create_date,
- create_by,
- update_date,
- update_by,
- id,
- name,
- website,
- logo_url,
- status,
- type,
- customer_id
- ) VALUES (
- #{site.createDate,jdbcType=TIMESTAMP},
- #{site.createBy,jdbcType=VARCHAR},
- #{site.updateDate,jdbcType=TIMESTAMP},
- #{site.updateBy,jdbcType=VARCHAR},
- #{site.id,jdbcType=INTEGER},
- #{site.name,jdbcType=VARCHAR},
- #{site.website,jdbcType=VARCHAR},
- #{site.logoUrl,jdbcType=VARCHAR},
- #{site.status,jdbcType=INTEGER},
- #{site.type,jdbcType=INTEGER},
- #{site.customerId,jdbcType=INTEGER}
- )
- </insert>
- <!--auto generated Code-->
- <insert id="insertSelective" useGeneratedKeys="true" keyProperty="site.id">
- INSERT INTO sc_site
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="site.createDate!=null"> create_date,</if>
- <if test="site.createBy!=null"> create_by,</if>
- <if test="site.updateDate!=null"> update_date,</if>
- <if test="site.updateBy!=null"> update_by,</if>
- <if test="site.id!=null"> id,</if>
- <if test="site.name!=null"> name,</if>
- <if test="site.website!=null"> website,</if>
- <if test="site.logoUrl!=null"> logo_url,</if>
- <if test="site.status!=null"> status,</if>
- <if test="site.type!=null"> type,</if>
- <if test="site.customerId!=null"> customer_id,</if>
- </trim>
- VALUES
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="site.createDate!=null">#{site.createDate,jdbcType=TIMESTAMP},
- </if>
- <if test="site.createBy!=null">#{site.createBy,jdbcType=VARCHAR},
- </if>
- <if test="site.updateDate!=null">#{site.updateDate,jdbcType=TIMESTAMP},
- </if>
- <if test="site.updateBy!=null">#{site.updateBy,jdbcType=VARCHAR},
- </if>
- <if test="site.id!=null">#{site.id,jdbcType=INTEGER},
- </if>
- <if test="site.name!=null">#{site.name,jdbcType=VARCHAR},
- </if>
- <if test="site.website!=null">#{site.website,jdbcType=VARCHAR},
- </if>
- <if test="site.logoUrl!=null">#{site.logoUrl,jdbcType=VARCHAR},
- </if>
- <if test="site.status!=null">#{site.status,jdbcType=INTEGER},
- </if>
- <if test="site.type!=null">#{site.type,jdbcType=INTEGER},
- </if>
- <if test="site.customerId!=null">#{site.customerId,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <!--auto generated Code-->
- <insert id="insertList">
- INSERT INTO sc_site (
- create_date,
- create_by,
- update_date,
- update_by,
- id,
- name,
- website,
- logo_url,
- status,
- type,
- customer_id
- )VALUES
- <foreach collection="sites" item="site" index="index" separator=",">
- (
- #{site.createDate,jdbcType=TIMESTAMP},
- #{site.createBy,jdbcType=VARCHAR},
- #{site.updateDate,jdbcType=TIMESTAMP},
- #{site.updateBy,jdbcType=VARCHAR},
- #{site.id,jdbcType=INTEGER},
- #{site.name,jdbcType=VARCHAR},
- #{site.website,jdbcType=VARCHAR},
- #{site.logoUrl,jdbcType=VARCHAR},
- #{site.status,jdbcType=INTEGER},
- #{site.type,jdbcType=INTEGER},
- #{site.customerId,jdbcType=INTEGER}
- )
- </foreach>
- </insert>
- <!--auto generated Code-->
- <update id="updateByPrimaryKeySelective">
- UPDATE sc_site
- <set>
- <if test="site.createDate != null"> create_date= #{site.createDate,jdbcType=TIMESTAMP},</if>
- <if test="site.createBy != null"> create_by= #{site.createBy,jdbcType=VARCHAR},</if>
- <if test="site.updateDate != null"> update_date= #{site.updateDate,jdbcType=TIMESTAMP},</if>
- <if test="site.updateBy != null"> update_by= #{site.updateBy,jdbcType=VARCHAR},</if>
- <if test="site.name != null"> name= #{site.name,jdbcType=VARCHAR},</if>
- <if test="site.website != null"> website= #{site.website,jdbcType=VARCHAR},</if>
- <if test="site.logoUrl != null"> logo_url= #{site.logoUrl,jdbcType=VARCHAR},</if>
- <if test="site.status != null"> status= #{site.status,jdbcType=INTEGER},</if>
- <if test="site.type != null"> type= #{site.type,jdbcType=INTEGER},</if>
- <if test="site.customerId != null"> customer_id= #{site.customerId,jdbcType=INTEGER}</if>
- </set>
- WHERE id = #{site.id,jdbcType=INTEGER}
- </update>
- <select id="getList" resultMap="lazyLoadChannelIds">
- select
- ss.*,
- (SELECT GROUP_CONCAT(su.username SEPARATOR '、') FROM sc_site_user ssu LEFT JOIN sc_user su on(su.id = ssu.user_id and su.`status`= 1) WHERE ssu.site_id = ss.id and ssu.`status` =1 and ssu.is_admin= 1) as username,
- (select count(1) from sc_building sb where sb.status = 1 and sb.site_id = ss.id) as building_count,
- (select count(1) from sc_device sd where sd.status = 1 and sd.site_id = ss.id) as device_count
- from sc_site ss
- where ss.status = 1
- <if test="siteIds != null and siteIds.size()>0">
- and ss.id in <foreach collection="siteIds" item="item" open="(" separator="," close=")">#{item}</foreach>
- </if>
- <if test="name != null and name != ''"> AND ss.name LIKE concat('%',#{name},'%')</if>
- order by ss.create_date desc
- </select>
- <resultMap id="lazyLoadChannelIds" type="com.bz.smart_city.dto.SiteDto" extends="BaseResultMap">
- <collection property="channelIds" ofType="java.lang.Integer" select="com.bz.smart_city.dao.ChannelMapper.getChannelBySiteId"
- column="id"></collection>
- </resultMap>
- <update id="delete">
- update sc_site set status = 0,update_date=NOW(),update_by=#{updateBy} where id = #{id}
- </update>
- <select id="findByNameUnique" resultType="int">
- select count(1) from sc_site where status = 1 and name = #{name}
- <if test="id != null"> and id != #{id}</if>
- </select>
- <select id="findById" resultMap="BaseResultMap">
- select ss.*,sc.customer_name
- from sc_site as ss
- left join sc_customer as sc on (sc.id = ss.customer_id)
- where ss.status = 1 and ss.id = #{siteId}
- </select>
- <select id="findByCustomerIdUnique" resultType="int">
- select count(1) from sc_site where status = 1 and customer_id = #{customerId}
- <if test="id != null"> and id != #{id}</if>
- </select>
- <select id="getSiteAndCustomerByCustomerNo" resultType="com.bz.smart_city.dto.pay.SiteinfoDto">
- select
- s.id,
- s.name as "siteName",
- s.customer_id,
- c.customer_no,
- c.customer_name as "customerName"
- from sc_site s
- left join sc_customer c on s.customer_id=c.id
- where c.customer_no=#{customerNo}
- </select>
- </mapper>
|