mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-28 02:11:29 +08:00
租户只能查看自己的产品、固件、分组和产品下设备以及系统定义的物模型和分类
This commit is contained in:
@@ -247,9 +247,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
if(roles.get(i).getRoleKey().equals("tenant")){
|
if(roles.get(i).getRoleKey().equals("tenant")){
|
||||||
// 租户查看产品下所有设备
|
// 租户查看产品下所有设备
|
||||||
device.setTenantId(user.getUserId());
|
device.setTenantId(user.getUserId());
|
||||||
|
break;
|
||||||
}else if (roles.get(i).getRoleKey().equals("general")){
|
}else if (roles.get(i).getRoleKey().equals("general")){
|
||||||
// 用户查看自己设备
|
// 用户查看自己设备
|
||||||
device.setUserId(user.getUserId());
|
device.setUserId(user.getUserId());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deviceMapper.selectAllDeviceShortList(device);
|
return deviceMapper.selectAllDeviceShortList(device);
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ public class GroupServiceImpl implements IGroupService
|
|||||||
SysUser user = getLoginUser().getUser();
|
SysUser user = getLoginUser().getUser();
|
||||||
List<SysRole> roles=user.getRoles();
|
List<SysRole> roles=user.getRoles();
|
||||||
for(int i=0;i<roles.size();i++){
|
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());
|
group.setUserId(user.getUserId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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="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} 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="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>
|
||||||
|
|||||||
@@ -28,7 +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="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>
|
</where>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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>
|
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
||||||
<template slot-scope="scope">
|
<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="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=" 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:category:remove']" v-if="scope.row.isSys == '1' && isTenant!=true">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<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>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -77,8 +77,8 @@ export default {
|
|||||||
dicts: ["iot_yes_no"],
|
dicts: ["iot_yes_no"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 判断是否获取到修改权限
|
// 是否为租户
|
||||||
canEdit: false,
|
isTenant: false,
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 选中数组
|
// 选中数组
|
||||||
@@ -127,8 +127,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
if (this.$store.state.user.roles.indexOf("admin") !== -1) {
|
if (this.$store.state.user.roles.indexOf("tenant") !== -1) {
|
||||||
this.canEdit = true
|
this.isTenant = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 查询产品分类列表 */
|
/** 查询产品分类列表 */
|
||||||
|
|||||||
@@ -137,6 +137,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</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" />
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||||
|
|
||||||
<!-- 查看监测数据 -->
|
<!-- 查看监测数据 -->
|
||||||
|
|||||||
@@ -19,15 +19,10 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card style="padding-bottom:100px;">
|
<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="firmwareName" />
|
||||||
<el-table-column label="产品名称" align="center" prop="productName" />
|
<el-table-column label="产品名称" align="center" prop="productName" />
|
||||||
<el-table-column label="租户名称" align="center" prop="tenantName" />
|
<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">
|
<el-table-column label="固件版本" align="center" prop="version">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>Version </span> {{scope.row.version}}
|
<span>Version </span> {{scope.row.version}}
|
||||||
@@ -44,7 +39,7 @@
|
|||||||
<template slot-scope="scope">
|
<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="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="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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -73,7 +68,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<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>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -109,8 +104,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 判断是否有修改权限
|
|
||||||
canEdit: false,
|
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 选中数组
|
// 选中数组
|
||||||
@@ -189,14 +182,8 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.getProductShortList();
|
this.getProductShortList();
|
||||||
this.init();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
|
||||||
if (this.$store.state.user.roles.indexOf("admin") !== -1) {
|
|
||||||
this.canEdit = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/** 查询产品固件列表 */
|
/** 查询产品固件列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</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" />
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||||
|
|
||||||
<!-- 下载SDK -->
|
<!-- 下载SDK -->
|
||||||
|
|||||||
Reference in New Issue
Block a user