mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 17:05:55 +08:00
多租户测试调整
This commit is contained in:
@@ -37,7 +37,7 @@ public class AlertController extends BaseController
|
||||
/**
|
||||
* 查询设备告警列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:list')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Alert alert)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ public class AlertController extends BaseController
|
||||
/**
|
||||
* 导出设备告警列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:export')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:export')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Alert alert)
|
||||
@@ -62,7 +62,7 @@ public class AlertController extends BaseController
|
||||
/**
|
||||
* 获取设备告警详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:query')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:query')")
|
||||
@GetMapping(value = "/{alertId}")
|
||||
public AjaxResult getInfo(@PathVariable("alertId") Long alertId)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ public class AlertController extends BaseController
|
||||
/**
|
||||
* 新增设备告警
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:add')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:add')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Alert alert)
|
||||
@@ -83,7 +83,7 @@ public class AlertController extends BaseController
|
||||
/**
|
||||
* 修改设备告警
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:edit')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:edit')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Alert alert)
|
||||
@@ -94,7 +94,7 @@ public class AlertController extends BaseController
|
||||
/**
|
||||
* 删除设备告警
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:remove')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:remove')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{alertIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] alertIds)
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AlertLogController extends BaseController
|
||||
/**
|
||||
* 查询设备告警列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:alertLog:list')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(AlertLog alertLog)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ public class AlertLogController extends BaseController
|
||||
/**
|
||||
* 导出设备告警列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:alertLog:export')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:export')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, AlertLog alertLog)
|
||||
@@ -62,7 +62,7 @@ public class AlertLogController extends BaseController
|
||||
/**
|
||||
* 获取设备告警详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:alertLog:query')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:query')")
|
||||
@GetMapping(value = "/{alertLogId}")
|
||||
public AjaxResult getInfo(@PathVariable("alertLogId") Long alertLogId)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ public class AlertLogController extends BaseController
|
||||
/**
|
||||
* 新增设备告警
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:alertLog:add')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:add')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody AlertLog alertLog)
|
||||
@@ -83,7 +83,7 @@ public class AlertLogController extends BaseController
|
||||
/**
|
||||
* 修改设备告警
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:alertLog:edit')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:edit')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody AlertLog alertLog)
|
||||
@@ -94,7 +94,7 @@ public class AlertLogController extends BaseController
|
||||
/**
|
||||
* 删除设备告警
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:alertLog:remove')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:alert:remove')")
|
||||
@Log(title = "设备告警", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{alertLogIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] alertLogIds)
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
|
||||
@@ -27,6 +29,7 @@ import com.ruoyi.iot.service.impl.ThingsModelServiceImpl;
|
||||
import com.ruoyi.iot.util.AESUtils;
|
||||
import com.ruoyi.iot.util.VelocityInitializer;
|
||||
import com.ruoyi.iot.util.VelocityUtils;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -42,6 +45,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -101,6 +105,17 @@ public class ToolController extends BaseController {
|
||||
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@GetMapping("/userList")
|
||||
public TableDataInfo list(SysUser user)
|
||||
{
|
||||
startPage();
|
||||
List<SysUser> list = toolService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation("mqtt认证")
|
||||
@PostMapping("/mqtt/auth")
|
||||
public ResponseEntity mqttAuth(@RequestParam String clientid, @RequestParam String username, @RequestParam String password) throws Exception {
|
||||
|
||||
@@ -105,6 +105,25 @@ public class Device extends BaseEntity
|
||||
/** 分组ID,用于分组查询 **/
|
||||
private Long groupId;
|
||||
|
||||
/** 是否设备所有者,用于查询 **/
|
||||
private Integer isOwner;
|
||||
|
||||
public Integer getLocationWay() {
|
||||
return locationWay;
|
||||
}
|
||||
|
||||
public void setLocationWay(Integer locationWay) {
|
||||
this.locationWay = locationWay;
|
||||
}
|
||||
|
||||
public Integer getIsOwner() {
|
||||
return isOwner;
|
||||
}
|
||||
|
||||
public void setIsOwner(Integer isOwner) {
|
||||
this.isOwner = isOwner;
|
||||
}
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
@@ -124,14 +143,6 @@ public class Device extends BaseEntity
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public Integer getlocationWay() {
|
||||
return locationWay;
|
||||
}
|
||||
|
||||
public void setlocationWay(Integer locationWay) {
|
||||
this.locationWay = locationWay;
|
||||
}
|
||||
|
||||
public String getImgUrl() {
|
||||
return imgUrl;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,25 @@ public class DeviceAllShortOutput
|
||||
/** 纬度 */
|
||||
private BigDecimal latitude;
|
||||
|
||||
/** 是否设备所有者,用于查询 **/
|
||||
private Integer isOwner;
|
||||
|
||||
public Integer getLocationWay() {
|
||||
return locationWay;
|
||||
}
|
||||
|
||||
public void setLocationWay(Integer locationWay) {
|
||||
this.locationWay = locationWay;
|
||||
}
|
||||
|
||||
public Integer getIsOwner() {
|
||||
return isOwner;
|
||||
}
|
||||
|
||||
public void setIsOwner(Integer isOwner) {
|
||||
this.isOwner = isOwner;
|
||||
}
|
||||
|
||||
public String getNetworkAddress() {
|
||||
return networkAddress;
|
||||
}
|
||||
@@ -82,14 +101,6 @@ public class DeviceAllShortOutput
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public Integer getlocationWay() {
|
||||
return locationWay;
|
||||
}
|
||||
|
||||
public void setlocationWay(Integer locationWay) {
|
||||
this.locationWay = locationWay;
|
||||
}
|
||||
|
||||
public Integer getIsShadow() {
|
||||
return isShadow;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,9 @@ public class DeviceShortOutput
|
||||
/** 图片地址 */
|
||||
private String imgUrl;
|
||||
|
||||
/** 是否设备所有者,用于查询 **/
|
||||
private Integer isOwner;
|
||||
|
||||
private List<StringModelOutput> stringList;
|
||||
private List<IntegerModelOutput> integerList;
|
||||
private List<DecimalModelOutput> decimalList;
|
||||
@@ -101,14 +104,22 @@ public class DeviceShortOutput
|
||||
private List<BoolModelOutput> boolList;
|
||||
private List<ReadOnlyModelOutput> readOnlyList;
|
||||
|
||||
public Integer getlocationWay() {
|
||||
public Integer getLocationWay() {
|
||||
return locationWay;
|
||||
}
|
||||
|
||||
public void setlocationWay(Integer locationWay) {
|
||||
public void setLocationWay(Integer locationWay) {
|
||||
this.locationWay = locationWay;
|
||||
}
|
||||
|
||||
public Integer getIsOwner() {
|
||||
return isOwner;
|
||||
}
|
||||
|
||||
public void setIsOwner(Integer isOwner) {
|
||||
this.isOwner = isOwner;
|
||||
}
|
||||
|
||||
public String getImgUrl() {
|
||||
return imgUrl;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class EmqxService {
|
||||
device.setProductId(productId);
|
||||
device.setSerialNumber(deviceNum);
|
||||
// 未采用设备定位则清空定位,定位方式(1=ip自动定位,2=设备定位,3=自定义)
|
||||
if(device.getlocationWay()!=2){
|
||||
if(device.getLocationWay()!=2){
|
||||
device.setLatitude(null);
|
||||
device.setLongitude(null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||
import com.ruoyi.iot.model.MqttAuthenticationModel;
|
||||
@@ -8,6 +9,8 @@ import com.ruoyi.iot.model.RegisterUserInput;
|
||||
import com.ruoyi.iot.util.AESUtils;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kerwincui
|
||||
@@ -20,6 +23,14 @@ public interface IToolService
|
||||
*/
|
||||
public String register(RegisterUserInput registerBody);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser user);
|
||||
|
||||
/**
|
||||
* 生成随机数字和字母
|
||||
*/
|
||||
|
||||
@@ -304,8 +304,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
*/
|
||||
@Override
|
||||
public List<Device> selectDeviceListByGroup(Device device) {
|
||||
if(device.getUserId()==null || device.getUserId()==0){
|
||||
return new ArrayList<>();
|
||||
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.selectDeviceListByGroup(device);
|
||||
}
|
||||
@@ -564,7 +572,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
device.setActiveTime(DateUtils.getNowDate());
|
||||
device.setIsShadow(0);
|
||||
device.setRssi(0);
|
||||
device.setlocationWay(1); // 1-自动定位,2-设备定位,3-自定义位置
|
||||
device.setLocationWay(1); // 1-自动定位,2-设备定位,3-自定义位置
|
||||
device.setCreateTime(DateUtils.getNowDate());
|
||||
device.setThingsModelValue(JSONObject.toJSONString(getThingsModelDefaultValue(device.getProductId())));
|
||||
// 随机位置
|
||||
@@ -713,7 +721,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
device.setActiveTime(DateUtils.getNowDate());
|
||||
}
|
||||
// 定位方式(1=ip自动定位,2=设备定位,3=自定义)
|
||||
if (device.getlocationWay() == 1) {
|
||||
if (device.getLocationWay() == 1) {
|
||||
device.setNetworkIp(ipAddress);
|
||||
setLocation(ipAddress, device);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.service.impl;
|
||||
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
@@ -32,6 +33,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.iot.mqtt.MqttConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
@@ -156,6 +158,18 @@ public class ToolServiceImpl implements IToolService
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user