租户只能查看自己的产品、固件、分组和产品下设备以及系统定义的物模型和分类

This commit is contained in:
kerwincui
2022-06-04 13:19:15 +08:00
parent dad1d22d69
commit f8eb314bd0
9 changed files with 19 additions and 28 deletions

View File

@@ -247,9 +247,11 @@ public class DeviceServiceImpl implements IDeviceService {
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;
}
}
return deviceMapper.selectAllDeviceShortList(device);

View File

@@ -67,8 +67,8 @@ public class GroupServiceImpl implements IGroupService
SysUser user = getLoginUser().getUser();
List<SysRole> roles=user.getRoles();
for(int i=0;i<roles.size();i++){
if (roles.get(i).getRoleKey().equals("general")){
// 用户查看自己设备
// 租户和用户,只查看自己分组
if(roles.get(i).getRoleKey().equals("tenant") || roles.get(i).getRoleKey().equals("general")){
group.setUserId(user.getUserId());
break;
}

View File

@@ -114,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</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="tenantId != null "> and (tenant_id = #{tenantId} or is_sys = 1)</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="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
<if test="status != null "> and status = #{status}</if>

View File

@@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<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="tenantId != null and tenantId != ''"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
</where>
order by create_time desc
</select>

View File

@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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>
<if test="tenantId != null and tenantId != 0"> and (tenant_id = #{tenantId} or is_sys = 1)</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
</where>
order by create_time desc
</select>

View File

@@ -32,8 +32,8 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
<template slot-scope="scope">
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:category:edit']">修改</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']" v-if=" canEdit ? true : (scope.row.isSys == '1' ? false : true)">删除</el-button>
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:category:edit']" v-if="scope.row.isSys == '1' && isTenant!=true">修改</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:category:remove']" v-if="scope.row.isSys == '1' && isTenant!=true">删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -54,7 +54,7 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled=" canEdit ? false : (form.isSys == '1' ? true : false)"> </el-button>
<el-button type="primary" @click="submitForm" > </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@@ -77,8 +77,8 @@ export default {
dicts: ["iot_yes_no"],
data() {
return {
// 判断是否获取到修改权限
canEdit: false,
// 是否为租户
isTenant: false,
// 遮罩层
loading: true,
// 选中数组
@@ -127,8 +127,8 @@ export default {
},
methods: {
init() {
if (this.$store.state.user.roles.indexOf("admin") !== -1) {
this.canEdit = true
if (this.$store.state.user.roles.indexOf("tenant") !== -1) {
this.isTenant = true
}
},
/** 查询产品分类列表 */

View File

@@ -137,6 +137,7 @@
</el-col>
</el-row>
<el-empty description="暂无数据,请添加设备" v-if="total==0"></el-empty>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 查看监测数据 -->

View File

@@ -19,15 +19,10 @@
</el-card>
<el-card style="padding-bottom:100px;">
<el-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange" border>
<el-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange">
<el-table-column label="固件名称" align="center" prop="firmwareName" />
<el-table-column label="产品名称" align="center" prop="productName" />
<el-table-column label="租户名称" align="center" prop="tenantName" />
<el-table-column label="系统定义" align="center" prop="isSys">
<template slot-scope="scope">
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.isSys" />
</template>
</el-table-column>
<el-table-column label="固件版本" align="center" prop="version">
<template slot-scope="scope">
<span>Version </span> {{scope.row.version}}
@@ -44,7 +39,7 @@
<template slot-scope="scope">
<el-button size="small" type="info" style="padding:5px;" icon="el-icon-download" @click="handleDownload(scope.row)">下载</el-button>
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:firmware:edit']">修改</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:firmware:remove']" v-if=" canEdit ? true : (scope.row.isSys == '1' ? false : true)">删除</el-button>
<el-button size="small" type="danger" style="padding:5px;" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['iot:firmware:remove']" >删除</el-button>
</template>
</el-table-column>
</el-table>
@@ -73,7 +68,7 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled=" canEdit ? false : (form.isSys == '1' ? true : false)"> </el-button>
<el-button type="primary" @click="submitForm" > </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@@ -109,8 +104,6 @@ export default {
},
data() {
return {
// 判断是否有修改权限
canEdit: false,
// 遮罩层
loading: true,
// 选中数组
@@ -189,14 +182,8 @@ export default {
created() {
this.getList();
this.getProductShortList();
this.init();
},
methods: {
init() {
if (this.$store.state.user.roles.indexOf("admin") !== -1) {
this.canEdit = true
}
},
/** 查询产品固件列表 */
getList() {
this.loading = true;

View File

@@ -76,6 +76,7 @@
</el-col>
</el-row>
<el-empty description="暂无数据,请添加产品" v-if="total==0"></el-empty>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 下载SDK -->