forked from dyf/fys-Multi-tenant
Merge remote-tracking branch 'upstream/dyf-device'
This commit is contained in:
@ -1,9 +1,6 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -32,6 +29,13 @@ public class Device extends TenantEntity {
|
||||
@TableField(exist = false)
|
||||
private Long assignId;
|
||||
|
||||
/**
|
||||
* 设备分组
|
||||
* group_id
|
||||
*/
|
||||
@Schema(name = "设备分组")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* device_type
|
||||
*/
|
||||
@ -143,4 +147,11 @@ public class Device extends TenantEntity {
|
||||
*/
|
||||
private String subTopic;
|
||||
|
||||
/**
|
||||
* 出厂日期
|
||||
* production_date
|
||||
*/
|
||||
@Schema(name = "出厂日期")
|
||||
private Date productionDate;
|
||||
|
||||
}
|
||||
|
@ -30,18 +30,21 @@ public class DeviceGroupBo extends BaseEntity {
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
@Schema(name = "分组名称")
|
||||
@NotBlank(message = "分组名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 状态:0-禁用,1-正常
|
||||
*/
|
||||
@Schema(name = "状态:0-禁用,1-正常")
|
||||
// @NotNull(message = "状态:0-禁用,1-正常不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long status;
|
||||
|
||||
/**
|
||||
* 父分组ID
|
||||
*/
|
||||
@Schema(name = "父分组ID")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
|
@ -65,4 +65,23 @@ public class DeviceQueryCriteria extends BaseEntity {
|
||||
|
||||
/* app绑定用户id */
|
||||
private Long bindingUserId;
|
||||
|
||||
/**
|
||||
* 是否为管理员
|
||||
*/
|
||||
@Schema(name = "是否为管理员")
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
/**
|
||||
* 设备所属分组
|
||||
*/
|
||||
@Schema(name = "设备所属分组")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 设备地区
|
||||
*/
|
||||
@Schema(name = "设备地区")
|
||||
private String area;
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,10 @@ public class DeviceTypeQueryCriteria extends BaseEntity implements Serializable
|
||||
|
||||
@Schema(name = "每页数据量", example = "10")
|
||||
private Integer pageSize = 10;
|
||||
|
||||
|
||||
/* 是否为管理员 */
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
|
||||
}
|
||||
|
@ -106,6 +106,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
criteria.setDeviceType(deviceTypeGrant.getDeviceTypeId());
|
||||
}
|
||||
}
|
||||
|
||||
// 管理员
|
||||
String username = LoginHelper.getUsername();
|
||||
if (username.equals("admin")) {
|
||||
criteria.setIsAdmin(true);
|
||||
}
|
||||
|
||||
IPage<Device> devices = deviceMapper.findAll(criteria, page);
|
||||
|
||||
List<Device> records = devices.getRecords();
|
||||
|
@ -53,8 +53,12 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<DeviceType> queryAll(DeviceTypeQueryCriteria criteria, Page<DeviceType> page) {
|
||||
criteria.setCustomerId(LoginHelper.getUserId());
|
||||
// return
|
||||
// 管理员
|
||||
String username = LoginHelper.getUsername();
|
||||
if (!username.equals("admin")) {
|
||||
criteria.setCustomerId(LoginHelper.getUserId());
|
||||
}
|
||||
|
||||
IPage<DeviceType> deviceTypeIPage = deviceTypeMapper.findAll(criteria, page);
|
||||
return new TableDataInfo<DeviceType>(deviceTypeIPage.getRecords(), deviceTypeIPage.getTotal());
|
||||
}
|
||||
@ -74,8 +78,16 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
@Override
|
||||
public List<DeviceType> queryDeviceTypes() {
|
||||
DeviceTypeQueryCriteria criteria = new DeviceTypeQueryCriteria();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
criteria.setCustomerId(userId);
|
||||
|
||||
// 管理员
|
||||
String username = LoginHelper.getUsername();
|
||||
if (!username.equals("admin")) {
|
||||
criteria.setCustomerId(LoginHelper.getUserId());
|
||||
|
||||
Long userId = LoginHelper.getUserId();
|
||||
criteria.setCustomerId(userId);
|
||||
}
|
||||
|
||||
return deviceTypeMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
@ -157,8 +169,12 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
throw new RuntimeException("设备类型名称已存在,无法修改!!!");
|
||||
}
|
||||
|
||||
if (!Objects.equals(deviceType.getCustomerId(), LoginHelper.getUserId())) {
|
||||
throw new RuntimeException("无权修改该设备类型");
|
||||
// 管理员
|
||||
String username = LoginHelper.getUsername();
|
||||
if (!username.equals("admin")) {
|
||||
if (!Objects.equals(deviceType.getCustomerId(), LoginHelper.getUserId())) {
|
||||
throw new RuntimeException("无权修改该设备类型");
|
||||
}
|
||||
}
|
||||
|
||||
BeanUtil.copyProperties(resources, deviceType);
|
||||
|
@ -74,8 +74,11 @@
|
||||
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||
and da.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||
</if>
|
||||
AND da.assignee_id = #{criteria.currentOwnerId}
|
||||
AND dg.customer_id = #{criteria.currentOwnerId}
|
||||
<!-- 管理员可以查看所有设备,普通用户只能查看自己的设备 -->
|
||||
<if test="criteria.isAdmin != true">
|
||||
AND da.assignee_id = #{criteria.currentOwnerId}
|
||||
AND dg.customer_id = #{criteria.currentOwnerId}
|
||||
</if>
|
||||
</where>
|
||||
) AS ranked
|
||||
WHERE rn = 1
|
||||
@ -213,18 +216,20 @@
|
||||
WHERE original_device_id = #{originalDeviceId}
|
||||
</select>
|
||||
<select id="getDeviceInfo" resultType="com.fuyuanshen.equipment.domain.vo.AppDeviceVo">
|
||||
select d.id, d.device_name, d.device_name,
|
||||
d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
dt.model_dictionary detailPageUrl
|
||||
select d.id,
|
||||
d.device_name,
|
||||
d.device_name,
|
||||
d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
dt.model_dictionary detailPageUrl
|
||||
from device d
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
where d.device_mac = #{deviceMac}
|
||||
</select>
|
||||
|
||||
|
Reference in New Issue
Block a user