mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 08:55:53 +08:00
+f;新增授权码功能
1、产品表添加 is_authorize 是否启用授权码字段; 2、产品授权码功能:基础增删改查、批量生成授权码、绑定设备。
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?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.ruoyi.iot.mapper.ProductAuthorizeMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.iot.domain.ProductAuthorize" id="ProductAuthorizeResult">
|
||||
<result property="authorizeId" column="authorize_id" />
|
||||
<result property="authorizeCode" column="authorize_code" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProductAuthorizeVo">
|
||||
select authorize_id, authorize_code, product_id, device_id, serial_number, user_id, user_name, del_flag, create_by, create_time, update_by, update_time, remark from iot_product_authorize
|
||||
</sql>
|
||||
|
||||
<select id="selectProductAuthorizeList" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultMap="ProductAuthorizeResult">
|
||||
<include refid="selectProductAuthorizeVo"/>
|
||||
<where>
|
||||
<if test="authorizeCode != null and authorizeCode != ''"> and authorize_code = #{authorizeCode}</if>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
</where>
|
||||
order by
|
||||
device_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectProductAuthorizeByAuthorizeId" parameterType="Long" resultMap="ProductAuthorizeResult">
|
||||
<include refid="selectProductAuthorizeVo"/>
|
||||
where authorize_id = #{authorizeId}
|
||||
</select>
|
||||
<select id="selectOneUnboundAuthorizeByProductId" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||
<include refid="selectProductAuthorizeVo"/>
|
||||
where
|
||||
del_flag = 0
|
||||
and product_id = #{productId}
|
||||
and serial_number is null
|
||||
and device_id is null
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectOneUnboundAuthorizeByAuthorizeCode" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||
<include refid="selectProductAuthorizeVo"/>
|
||||
where
|
||||
del_flag = 0
|
||||
and authorize_code = #{authorizeCode}
|
||||
and serial_number is null
|
||||
and device_id is null
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertProductAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||
insert into iot_product_authorize
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="authorizeCode != null and authorizeCode != ''">authorize_code,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="serialNumber != null">serial_number,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="userName != null">user_name,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="authorizeCode != null and authorizeCode != ''">#{authorizeCode},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="serialNumber != null">#{serialNumber},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="userName != null">#{userName},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertBatchAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize" useGeneratedKeys="true" keyProperty="authorizeId">
|
||||
insert into iot_product_authorize (authorize_code,product_id,create_by,create_time)
|
||||
values
|
||||
<foreach item="item" collection="list" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{item.authorizeCode},#{item.productId},#{item.createBy},#{item.createTime}
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateProductAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||
update iot_product_authorize
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
user_id = #{userId},
|
||||
device_id = #{deviceId},
|
||||
<if test="authorizeCode != null and authorizeCode != ''">authorize_code = #{authorizeCode},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||
<if test="userName != null">user_name = #{userName},</if>
|
||||
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where authorize_id = #{authorizeId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteProductAuthorizeByAuthorizeId" parameterType="Long">
|
||||
delete from iot_product_authorize where authorize_id = #{authorizeId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProductAuthorizeByAuthorizeIds" parameterType="String">
|
||||
delete from iot_product_authorize where authorize_id in
|
||||
<foreach item="authorizeId" collection="array" open="(" separator="," close=")">
|
||||
#{authorizeId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
<result property="tenantName" column="tenant_name" />
|
||||
<result property="isSys" column="is_sys" />
|
||||
<result property="isAuthorize" column="is_authorize" />
|
||||
<result property="mqttAccount" column="mqtt_account" />
|
||||
<result property="mqttPassword" column="mqtt_password" />
|
||||
<result property="mqttSecret" column="mqtt_secret" />
|
||||
@@ -31,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProductVo">
|
||||
select product_id, product_name, category_id, category_name, tenant_id, tenant_name, is_sys,mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark from iot_product
|
||||
select product_id, product_name, category_id, category_name, tenant_id, tenant_name, is_sys, is_authorize, mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark from iot_product
|
||||
</sql>
|
||||
|
||||
<select id="selectProductList" parameterType="com.ruoyi.iot.domain.Product" resultMap="ProductResult">
|
||||
@@ -43,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
|
||||
<if test="isSys != null "> and is_sys = #{isSys}</if>
|
||||
<if test="isAuthorize != null "> and is_authorize = #{isAuthorize}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="deviceType != null "> and device_type = #{deviceType}</if>
|
||||
<if test="networkMethod != null "> and network_method = #{networkMethod}</if>
|
||||
@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="tenantId != null">tenant_id,</if>
|
||||
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
||||
<if test="isSys != null">is_sys,</if>
|
||||
<if test="isAuthorize != null">is_authorize,</if>
|
||||
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account,</if>
|
||||
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password,</if>
|
||||
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret,</if>
|
||||
@@ -92,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="tenantId != null">#{tenantId},</if>
|
||||
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
||||
<if test="isSys != null">#{isSys},</if>
|
||||
<if test="isAuthorize != null">#{isAuthorize},</if>
|
||||
<if test="mqttAccount != null and mqttAccount != ''">#{mqttAccount},</if>
|
||||
<if test="mqttPassword != null and mqttPassword != ''">#{mqttPassword},</if>
|
||||
<if test="mqttSecret != null and mqttSecret != ''">#{mqttSecret},</if>
|
||||
@@ -118,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
|
||||
<if test="isSys != null">is_sys = #{isSys},</if>
|
||||
<if test="isAuthorize != null">is_authorize = #{isAuthorize},</if>
|
||||
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account = #{mqttAccount},</if>
|
||||
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password = #{mqttPassword},</if>
|
||||
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret = #{mqttSecret},</if>
|
||||
|
||||
Reference in New Issue
Block a user