后端多租户调整

This commit is contained in:
kerwincui
2022-06-03 17:21:51 +08:00
parent 168d987779
commit 4999c2abcb
28 changed files with 80 additions and 175 deletions

View File

@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.iot.model.IdAndName; import com.ruoyi.iot.model.IdAndName;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -49,15 +51,7 @@ public class CategoryController extends BaseController
public TableDataInfo list(Category category) public TableDataInfo list(Category category)
{ {
startPage(); startPage();
List<Category> list = new ArrayList<>(); return getDataTable(categoryService.selectCategoryList(category));
if(category.getTenantName()== null || category.getTenantName()=="")
{
list = categoryService.selectCategoryList(category);
}else {
list = categoryService.selectCategoryListAccurate(category);
}
return getDataTable(list);
} }
/** /**

View File

@@ -44,15 +44,7 @@ public class DeviceController extends BaseController
public TableDataInfo list(Device device) public TableDataInfo list(Device device)
{ {
startPage(); startPage();
List<Device> list = new ArrayList<>(); return getDataTable(deviceService.selectDeviceList(device));
if(device.getUserId() == null)
{
list = deviceService.selectDeviceList(device);
}else {
// 精确查询
list = deviceService.selectDeviceListAccurate(device);
}
return getDataTable(list);
} }
/** /**
@@ -64,15 +56,7 @@ public class DeviceController extends BaseController
public TableDataInfo shortList(Device device) public TableDataInfo shortList(Device device)
{ {
startPage(); startPage();
List<DeviceShortOutput> list = new ArrayList<>(); return getDataTable(deviceService.selectDeviceShortList(device));
if(device.getUserId() == null)
{
list = deviceService.selectDeviceShortList(device);
}else {
// 精确查询
list = deviceService.selectDeviceShortListAccurate(device);
}
return getDataTable(list);
} }
/** /**

View File

@@ -59,9 +59,7 @@ public class FirmwareController extends BaseController
public TableDataInfo list(Firmware firmware) public TableDataInfo list(Firmware firmware)
{ {
startPage(); startPage();
System.out.print("租户名称"+firmware.getTenantName()+"hs"); return getDataTable(firmwareService.selectFirmwareList(firmware));
List<Firmware> list = firmwareService.selectFirmwareList(firmware);
return getDataTable(list);
} }
/** /**

View File

@@ -50,17 +50,7 @@ public class GroupController extends BaseController
public TableDataInfo list(Group group) public TableDataInfo list(Group group)
{ {
startPage(); startPage();
List<Group> list = new ArrayList<>(); return getDataTable(groupService.selectGroupList(group));
if(group.getUserName() == null || group.getUserName().equals(""))
{
// 搜索查询 ,mapper使用的是模糊查询
list = groupService.selectGroupList(group);
}else {
// 精准查询
list = groupService.selectGroupListAccurate(group);
}
return getDataTable(list);
} }
/** /**

View File

@@ -43,14 +43,7 @@ public class ProductController extends BaseController
public TableDataInfo list(Product product) public TableDataInfo list(Product product)
{ {
startPage(); startPage();
List<Product> list = new ArrayList<>(); return getDataTable(productService.selectProductList(product));
if(product.getTenantName()=="" ||product.getTenantName()==null)
{
list = productService.selectProductList(product);
}else {
list = productService.selectProductListAccurate(product);
}
return getDataTable(list);
} }
/** /**

View File

@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -25,6 +27,8 @@ import com.ruoyi.iot.service.IThingsModelTemplateService;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
/** /**
* 通用物模型Controller * 通用物模型Controller
* *
@@ -48,14 +52,7 @@ public class ThingsModelTemplateController extends BaseController
public TableDataInfo list(ThingsModelTemplate thingsModelTemplate) public TableDataInfo list(ThingsModelTemplate thingsModelTemplate)
{ {
startPage(); startPage();
List<ThingsModelTemplate> list = new ArrayList<>(); return getDataTable(thingsModelTemplateService.selectThingsModelTemplateList(thingsModelTemplate));
if (thingsModelTemplate.getTenantName().equals("")|| thingsModelTemplate.getTenantName() == null){
list = thingsModelTemplateService.selectThingsModelTemplateList(thingsModelTemplate);
}else{
// 精准查询
list = thingsModelTemplateService.selectThingsModelTemplateListAccurate(thingsModelTemplate);
}
return getDataTable(list);
} }
/** /**

View File

@@ -77,8 +77,6 @@ public interface CategoryMapper
* @return 结果 * @return 结果
*/ */
public int productCountInCategorys(Long[] categoryIds); public int productCountInCategorys(Long[] categoryIds);
// 精准查询
List<Category> selectCategoryListAccurate(Category category);
List<IdAndName> selectCategoryShortListAccurate(Category category); List<IdAndName> selectCategoryShortListAccurate(Category category);
} }

View File

@@ -180,5 +180,4 @@ public interface DeviceMapper
*/ */
List<Device> selectDeviceListAccurate(Device device); List<Device> selectDeviceListAccurate(Device device);
List<DeviceShortOutput> selectDeviceShortListAccurate(Device device);
} }

View File

@@ -84,6 +84,4 @@ public interface GroupMapper
*/ */
public int deleteDeviceGroupByGroupIds(Long[] groupIds); public int deleteDeviceGroupByGroupIds(Long[] groupIds);
// 精准查询所有
List<Group> selectGroupListAccurate(Group group);
} }

View File

@@ -116,6 +116,4 @@ public interface ProductMapper
* @return 结果 * @return 结果
*/ */
public int thingsCountInProduct(Long productId); public int thingsCountInProduct(Long productId);
// 精准查询
List<Product> selectProductListAccurate(Product product);
} }

View File

@@ -68,6 +68,5 @@ public interface ThingsModelTemplateMapper
* @return 结果 * @return 结果
*/ */
public int deleteThingsModelTemplateByTemplateIds(Long[] templateIds); public int deleteThingsModelTemplateByTemplateIds(Long[] templateIds);
// 精准查询
List<ThingsModelTemplate> selectThingsModelTemplateListAccurate(ThingsModelTemplate thingsModelTemplate);
} }

View File

@@ -69,8 +69,5 @@ public interface ICategoryService
*/ */
public int deleteCategoryByCategoryId(Long categoryId); public int deleteCategoryByCategoryId(Long categoryId);
// 精准查询
List<Category> selectCategoryListAccurate(Category category);
List<IdAndName> selectCategoryShortListAccurate(Category category); List<IdAndName> selectCategoryShortListAccurate(Category category);
} }

View File

@@ -172,10 +172,4 @@ public interface IDeviceService
*/ */
List<Device> selectDeviceListAccurate(Device device); List<Device> selectDeviceListAccurate(Device device);
/**
* 精准查询所有条件设备的简短信息
* @param device
* @return
*/
List<DeviceShortOutput> selectDeviceShortListAccurate(Device device);
} }

View File

@@ -73,7 +73,4 @@ public interface IGroupService
* @return 结果 * @return 结果
*/ */
public int deleteGroupByGroupId(Long groupId); public int deleteGroupByGroupId(Long groupId);
// 精准查询
List<Group> selectGroupListAccurate(Group group);
} }

View File

@@ -78,6 +78,4 @@ public interface IProductService
*/ */
public int deleteProductByProductId(Long productId); public int deleteProductByProductId(Long productId);
// 精准查询
List<Product> selectProductListAccurate(Product product);
} }

View File

@@ -59,6 +59,4 @@ public interface IThingsModelTemplateService
*/ */
public int deleteThingsModelTemplateByTemplateId(Long templateId); public int deleteThingsModelTemplateByTemplateId(Long templateId);
// 精准查询
List<ThingsModelTemplate> selectThingsModelTemplateListAccurate(ThingsModelTemplate thingsModelTemplate);
} }

View File

@@ -48,6 +48,12 @@ public class CategoryServiceImpl implements ICategoryService
@Override @Override
public List<Category> selectCategoryList(Category category) public List<Category> selectCategoryList(Category category)
{ {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
// 租户
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
category.setTenantId(user.getUserId());
}
return categoryMapper.selectCategoryList(category); return categoryMapper.selectCategoryList(category);
} }
@@ -132,9 +138,4 @@ public class CategoryServiceImpl implements ICategoryService
{ {
return categoryMapper.deleteCategoryByCategoryId(categoryId); return categoryMapper.deleteCategoryByCategoryId(categoryId);
} }
@Override
public List<Category> selectCategoryListAccurate(Category category) {
return categoryMapper.selectCategoryListAccurate(category);
}
} }

View File

@@ -3,6 +3,7 @@ package com.ruoyi.iot.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
@@ -218,6 +219,17 @@ public class DeviceServiceImpl implements IDeviceService {
*/ */
@Override @Override
public List<Device> selectDeviceList(Device device) { public List<Device> selectDeviceList(Device device) {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
for(int i=0;i<roles.size();i++){
if(roles.get(i).getRoleKey().equals("tenant")){
// 租户查看产品下所有设备
device.setTenantId(user.getUserId());
}else if (roles.get(i).getRoleKey().equals("general")){
// 用户查看自己设备
device.setUserId(user.getUserId());
}
}
return deviceMapper.selectDeviceList(device); return deviceMapper.selectDeviceList(device);
} }
@@ -241,6 +253,20 @@ public class DeviceServiceImpl implements IDeviceService {
@Override @Override
public List<DeviceShortOutput> selectDeviceShortList(Device device) { public List<DeviceShortOutput> selectDeviceShortList(Device device) {
// TODO 关联设备用户表 // TODO 关联设备用户表
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
for(int i=0;i<roles.size();i++){
if(roles.get(i).getRoleKey().equals("tenant")){
// 租户查看产品下所有设备
device.setTenantId(user.getUserId());
break;
}else if (roles.get(i).getRoleKey().equals("general")){
// 用户查看自己设备
device.setUserId(user.getUserId());
break;
}
}
List<DeviceShortOutput> deviceList = deviceMapper.selectDeviceShortList(device); List<DeviceShortOutput> deviceList = deviceMapper.selectDeviceShortList(device);
for (int i = 0; i < deviceList.size(); i++) { for (int i = 0; i < deviceList.size(); i++) {
JSONObject thingsModelObject = JSONObject.parseObject(thingsModelService.getCacheThingsModelByProductId(deviceList.get(i).getProductId())); JSONObject thingsModelObject = JSONObject.parseObject(thingsModelService.getCacheThingsModelByProductId(deviceList.get(i).getProductId()));
@@ -254,11 +280,6 @@ public class DeviceServiceImpl implements IDeviceService {
return deviceList; return deviceList;
} }
// 精准查询所有条件的设备
@Override
public List<DeviceShortOutput> selectDeviceShortListAccurate(Device device) {
return deviceMapper.selectDeviceShortListAccurate(device);
}
/** /**
* Json物模型集合转换为对象中的分类集合 * Json物模型集合转换为对象中的分类集合

View File

@@ -46,6 +46,12 @@ public class FirmwareServiceImpl implements IFirmwareService
@Override @Override
public List<Firmware> selectFirmwareList(Firmware firmware) public List<Firmware> selectFirmwareList(Firmware firmware)
{ {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
// 租户
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
firmware.setTenantId(user.getUserId());
}
return firmwareMapper.selectFirmwareList(firmware); return firmwareMapper.selectFirmwareList(firmware);
} }

View File

@@ -1,5 +1,6 @@
package com.ruoyi.iot.service.impl; package com.ruoyi.iot.service.impl;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.iot.domain.Group; import com.ruoyi.iot.domain.Group;
@@ -63,6 +64,15 @@ public class GroupServiceImpl implements IGroupService
@Override @Override
public List<Group> selectGroupList(Group group) public List<Group> selectGroupList(Group group)
{ {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
for(int i=0;i<roles.size();i++){
if (roles.get(i).getRoleKey().equals("general")){
// 用户查看自己设备
group.setUserId(user.getUserId());
break;
}
}
return groupMapper.selectGroupList(group); return groupMapper.selectGroupList(group);
} }
@@ -140,9 +150,4 @@ public class GroupServiceImpl implements IGroupService
return groupMapper.deleteGroupByGroupId(groupId); return groupMapper.deleteGroupByGroupId(groupId);
} }
// 精准查询所有
@Override
public List<Group> selectGroupListAccurate(Group group) {
return groupMapper.selectGroupListAccurate(group);
}
} }

View File

@@ -59,6 +59,12 @@ public class ProductServiceImpl implements IProductService
@Override @Override
public List<Product> selectProductList(Product product) public List<Product> selectProductList(Product product)
{ {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
// 租户
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
product.setTenantId(user.getUserId());
}
return productMapper.selectProductList(product); return productMapper.selectProductList(product);
} }
@@ -194,9 +200,4 @@ public class ProductServiceImpl implements IProductService
redisCache.deleteObject(tslPreKey+productId); redisCache.deleteObject(tslPreKey+productId);
return productMapper.deleteProductByProductId(productId); return productMapper.deleteProductByProductId(productId);
} }
// 精准查询
@Override
public List<Product> selectProductListAccurate(Product product) {
return productMapper.selectProductListAccurate(product);
}
} }

View File

@@ -47,6 +47,12 @@ public class ThingsModelTemplateServiceImpl implements IThingsModelTemplateServi
@Override @Override
public List<ThingsModelTemplate> selectThingsModelTemplateList(ThingsModelTemplate thingsModelTemplate) public List<ThingsModelTemplate> selectThingsModelTemplateList(ThingsModelTemplate thingsModelTemplate)
{ {
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
// 租户
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
thingsModelTemplate.setTenantId(user.getUserId());
}
return thingsModelTemplateMapper.selectThingsModelTemplateList(thingsModelTemplate); return thingsModelTemplateMapper.selectThingsModelTemplateList(thingsModelTemplate);
} }
@@ -108,9 +114,4 @@ public class ThingsModelTemplateServiceImpl implements IThingsModelTemplateServi
{ {
return thingsModelTemplateMapper.deleteThingsModelTemplateByTemplateId(templateId); return thingsModelTemplateMapper.deleteThingsModelTemplateByTemplateId(templateId);
} }
// 精准查询
@Override
public List<ThingsModelTemplate> selectThingsModelTemplateListAccurate(ThingsModelTemplate thingsModelTemplate) {
return thingsModelTemplateMapper.selectThingsModelTemplateListAccurate(thingsModelTemplate);
}
} }

View File

@@ -29,17 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectCategoryVo"/> <include refid="selectCategoryVo"/>
<where> <where>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if> <if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if> <if test="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
<if test="isSys != null "> and is_sys = #{isSys}</if>
</where>
order by order_num
</select>
<select id="selectCategoryListAccurate" parameterType="com.ruoyi.iot.domain.Category" resultMap="CategoryResult">
<include refid="selectCategoryVo"/>
<where>
<if test="categoryName != null and categoryName != ''"> and category_name = #{categoryName}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name = #{tenantName} or is_sys = 1</if>
<if test="isSys != null "> and is_sys = #{isSys}</if>
</where> </where>
order by order_num order by order_num
</select> </select>

View File

@@ -121,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if> <if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if> <if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if> <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if> <if test="tenantId != null "> and (tenant_id = #{tenantId} or is_sys = 1)</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if> <if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if> <if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
@@ -131,24 +131,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time desc order by create_time desc
</select> </select>
<select id="selectDeviceListAccurate" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
<where>
<if test="deviceName != null and deviceName != ''"> and device_name = #{deviceName} </if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name = #{productName}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name= #{userName}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name= #{tenantName}</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="status != null "> and status = #{status}</if>
<if test="networkAddress != null and networkAddress != ''"> and network_address = #{networkAddress} </if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
order by create_time desc
</select>
<select id="selectAllDeviceShortList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceAllShortResult"> <select id="selectAllDeviceShortList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceAllShortResult">
select device_id, device_name, product_name, user_name, serial_number, firmware_version, status,rssi,is_shadow , select device_id, device_name, product_name, user_name, serial_number, firmware_version, status,rssi,is_shadow ,
is_custom_location, active_time,network_address,longitude,latitude from iot_device is_custom_location, active_time,network_address,longitude,latitude from iot_device

View File

@@ -28,8 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="firmwareName != null and firmwareName != ''"> and firmware_name like concat('%', #{firmwareName}, '%')</if> <if test="firmwareName != null and firmwareName != ''"> and firmware_name like concat('%', #{firmwareName}, '%')</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if> <if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%') or is_sys = 1</if> <if test="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
<if test="isSys != null "> and is_sys = #{isSys}</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>

View File

@@ -28,14 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if> <if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if> <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
</where> <if test="userId != null "> and user_id = #{userId}</if>
order by group_order
</select>
<select id="selectGroupListAccurate" parameterType="com.ruoyi.iot.domain.Group" resultMap="GroupResult">
<include refid="selectGroupVo"/>
<where>
<if test="groupName != null and groupName != ''"> and group_name = #{groupName}</if>
<if test="userName != null and userName != ''"> and user_name = #{userName}</if>
</where> </where>
order by group_order order by group_order
</select> </select>

View File

@@ -41,29 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if> <if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if> <if test="categoryId != null "> and category_id = #{categoryId}</if>
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if> <if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</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>
</where>
order by create_time desc
</select>
<select id="selectProductListAccurate" parameterType="com.ruoyi.iot.domain.Product" resultMap="ProductResult">
<include refid="selectProductVo"/>
<where>
<if test="productName != null and productName != ''"> and product_name=#{productName}</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if>
<if test="categoryName != null and categoryName != ''"> and category_name = #{categoryName}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name = #{tenantName} or is_sys = 1</if>
<if test="isSys != null "> and is_sys = #{isSys}</if>
<if test="isAuthorize != null "> and is_authorize = #{isAuthorize}</if> <if test="isAuthorize != null "> and is_authorize = #{isAuthorize}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if> <if test="deviceType != null "> and device_type = #{deviceType}</if>
<if test="networkMethod != null "> and network_method = #{networkMethod}</if> <if test="networkMethod != null "> and network_method = #{networkMethod}</if>
<if test="tenantId != null and tenantId != 0"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>

View File

@@ -31,16 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if> <if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
<if test="type != null "> and type = #{type}</if> <if test="type != null "> and type = #{type}</if>
<if test="specs != null and specs != ''"> and specs = #{specs}</if> <if test="specs != null and specs != ''"> and specs = #{specs}</if>
</where> <if test="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
order by create_time desc
</select>
<select id="selectThingsModelTemplateListAccurate" parameterType="com.ruoyi.iot.domain.ThingsModelTemplate" resultMap="ThingsModelTemplateResult">
<include refid="selectThingsModelTemplateVo"/>
<where>
<if test="templateName != null and templateName != ''"> and template_name = #{templateName}</if>
<if test="type != null "> and type = #{type}</if>
<if test="specs != null and specs != ''"> and specs = #{specs}</if>
<if test="tenantName != null and tenantName != ''"> and create_by = #{tenantName} or is_sys = 1</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>