<?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">
|
<!--
|
* @title: 小鱼硬件设备表
|
* @description: 自定义sql,请自行实现业务逻辑
|
* @company: hugeinfo
|
* @author: liyj
|
* @time:2023-07-25 11:53:49
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.xylink.dao.mapper.XylinkNemoMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.xylink.domain.po.XylinkNemo">
|
<result property="id" column="id"/>
|
<result property="unitId" column="unit_id"/>
|
<result property="name" column="name"/>
|
<result property="nameCode" column="name_code"/>
|
<result property="number" column="number"/>
|
<result property="sn" column="sn"/>
|
<result property="adminName" column="admin_name"/>
|
<result property="avatar" column="avatar"/>
|
<result property="category" column="category"/>
|
<result property="isOnline" column="is_online"/>
|
<result property="clientVersion" column="client_version"/>
|
<result property="extendTime" column="extend_time"/>
|
<result property="portExpireTime" column="port_expire_time"/>
|
<result property="expireStatus" column="expire_status"/>
|
<result property="firstBindTime" column="first_bind_time"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
<!-- 表 -->
|
<sql id='table-name'>dyh_xylink_nemo</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
id,
|
unit_id,
|
name,
|
name_code,
|
number,
|
sn,
|
admin_name,
|
avatar,
|
category,
|
is_online,
|
client_version,
|
extend_time,
|
port_expire_time,
|
expire_status,
|
first_bind_time,
|
create_time,
|
update_time
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.unitId != null">unit_id = #{entity.unitId},</if>
|
<if test="entity.name != null">name = #{entity.name},</if>
|
<if test="entity.nameCode != null">name_code = #{entity.nameCode},</if>
|
<if test="entity.number != null">number = #{entity.number},</if>
|
<if test="entity.sn != null">sn = #{entity.sn},</if>
|
<if test="entity.adminName != null">admin_name = #{entity.adminName},</if>
|
<if test="entity.avatar != null">avatar = #{entity.avatar},</if>
|
<if test="entity.category != null">category = #{entity.category},</if>
|
<if test="entity.isOnline != null">is_online = #{entity.isOnline},</if>
|
<if test="entity.clientVersion != null">client_version = #{entity.clientVersion},</if>
|
<if test="entity.extendTime != null">extend_time = #{entity.extendTime},</if>
|
<if test="entity.portExpireTime != null">port_expire_time = #{entity.portExpireTime},</if>
|
<if test="entity.expireStatus != null">expire_status = #{entity.expireStatus},</if>
|
<if test="entity.firstBindTime != null">first_bind_time = #{entity.firstBindTime},</if>
|
<if test="entity.createTime != null">create_time = #{entity.createTime},</if>
|
<if test="entity.updateTime != null">update_time = #{entity.updateTime}</if>
|
</sql>
|
<!-- 条件 -->
|
<sql id="where-part">
|
<if test="terms != null">
|
<where>
|
<if test="terms.id != null and terms.id !=''">
|
and id = #{terms.id}
|
</if>
|
<if test="terms.unitId != null and terms.unitId !=''">
|
and unit_id = #{terms.unitId}
|
</if>
|
<if test="terms.name != null and terms.name !=''">
|
and name = #{terms.name}
|
</if>
|
<if test="terms.nameCode != null and terms.nameCode !=''">
|
and name_code = #{terms.nameCode}
|
</if>
|
<if test="terms.number != null and terms.number !=''">
|
and number = #{terms.number}
|
</if>
|
<if test="terms.sn != null and terms.sn !=''">
|
and sn = #{terms.sn}
|
</if>
|
<if test="terms.adminName != null and terms.adminName !=''">
|
and admin_name = #{terms.adminName}
|
</if>
|
<if test="terms.avatar != null and terms.avatar !=''">
|
and avatar = #{terms.avatar}
|
</if>
|
<if test="terms.category != null and terms.category !=''">
|
and category = #{terms.category}
|
</if>
|
<if test="terms.isOnline != null and terms.isOnline !=''">
|
and is_online = #{terms.isOnline}
|
</if>
|
<if test="terms.clientVersion != null and terms.clientVersion !=''">
|
and client_version = #{terms.clientVersion}
|
</if>
|
<if test="terms.extendTime != null and terms.extendTime !=''">
|
and extend_time = #{terms.extendTime}
|
</if>
|
<if test="terms.portExpireTime != null and terms.portExpireTime !=''">
|
and port_expire_time = #{terms.portExpireTime}
|
</if>
|
<if test="terms.expireStatus != null and terms.expireStatus !=''">
|
and expire_status = #{terms.expireStatus}
|
</if>
|
<if test="terms.firstBindTime != null and terms.firstBindTime !=''">
|
and first_bind_time = #{terms.firstBindTime}
|
</if>
|
<if test="terms.createTime != null and terms.createTime !=''">
|
and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
|
</if>
|
<if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
|
and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
|
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
|
</if>
|
<if test="terms.updateTime != null and terms.updateTime !=''">
|
and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
|
</if>
|
<if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
|
and (DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.updateStart}
|
and DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.updateEnd})
|
</if>
|
</where>
|
</if>
|
</sql>
|
<!-- 更新对象 -->
|
<update id="updateXylinkNemo">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
id = #{entity.id}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateXylinkNemoTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteXylinkNemo">
|
delete from
|
<include refid="table-name" />
|
where id = #{id}
|
</delete>
|
<!-- 根据条件查询 -->
|
<select id="listTerms" resultMap="dataResult">
|
select
|
<include refid="column-part"/>
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件统计 -->
|
<select id="countTerms" resultType="java.lang.Long">
|
select
|
COUNT(1)
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件分页查询 -->
|
<select id="pageTerms" resultMap="dataResult">
|
SELECT
|
<include refid="column-part"/>
|
FROM
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
<if test="page.sort != null">
|
<foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
|
${s.property} ${s.direction}
|
</foreach>
|
</if>
|
<if test="page.sort == null">
|
order by create_time desc
|
</if>
|
limit #{page.offset}, #{page.size}
|
</select>
|
|
</mapper>
|