添加权限控制
This commit is contained in:
1 parent
f91140ea33
commit
db12a62698
2 files changed
+41
No files matched your search
+1
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.luqj.util.HttpHelper;
|
||||
import com.ruoyi.common.select.SelectItem;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.DmPlayerConfig;
|
||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.luqj.util.HttpHelper;
|
||||
import com.ruoyi.common.select.SelectItem;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.TokenUtil;
|
||||
import com.ruoyi.system.domain.DmOperateVo;
|
||||
@@ -159,7 +160,15 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
dmPlayerent.setMjpegUrl("http://" + dmPlayerent.getIp() + ":8888/stream?token="
|
||||
+ TokenUtil.generateToken(dmPlayerent.getId() + "", dmPlayerent.getSecret()));
|
||||
dmPlayerent.setSecret(null);
|
||||
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||
return dmPlayerent;
|
||||
} else {
|
||||
if (dmPlayerent.getAccountid().longValue() == SecurityUtils.getUserId()) {
|
||||
return dmPlayerent;
|
||||
} else {
|
||||
throw new RuntimeException("没有权限");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,6 +179,9 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
*/
|
||||
@Override
|
||||
public List<DmPlayerent> selectDmPlayerentList(DmPlayerent dmPlayerent) {
|
||||
if (SecurityUtils.getUserId() != 1L) {
|
||||
dmPlayerent.setAccountid(SecurityUtils.getUserId());
|
||||
}
|
||||
List<DmPlayerent> list = dmPlayerentMapper.selectDmPlayerentList(dmPlayerent);
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (DmPlayerent playerent : list) {
|
||||
@@ -212,6 +224,7 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
*/
|
||||
@Override
|
||||
public int insertDmPlayerent(DmPlayerent dmPlayerent) {
|
||||
dmPlayerent.setAccountid(SecurityUtils.getUserId());
|
||||
dmPlayerent.setCreateTime(DateUtils.getNowDate());
|
||||
return dmPlayerentMapper.insertDmPlayerent(dmPlayerent);
|
||||
}
|
||||
@@ -219,6 +232,14 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
@Override
|
||||
public boolean operate(DmOperateVo vo) {
|
||||
DmPlayerent dmPlayerent = this.dmPlayerentMapper.selectDmPlayerentById(Long.parseLong(vo.getPlayerId()));
|
||||
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||
|
||||
} else {
|
||||
if (dmPlayerent.getAccountid().longValue() == SecurityUtils.getUserId()) {
|
||||
} else {
|
||||
throw new RuntimeException("没有权限");
|
||||
}
|
||||
}
|
||||
if (dmPlayerent == null) {
|
||||
throw new RuntimeException("找不到对象");
|
||||
}
|
||||
@@ -276,7 +297,15 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
@Override
|
||||
public int updateDmPlayerent(DmPlayerent dmPlayerent) {
|
||||
dmPlayerent.setUpdateTime(DateUtils.getNowDate());
|
||||
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||
return dmPlayerentMapper.updateDmPlayerent(dmPlayerent);
|
||||
} else {
|
||||
if (dmPlayerent.getAccountid().longValue() == SecurityUtils.getUserId()) {
|
||||
return dmPlayerentMapper.updateDmPlayerent(dmPlayerent);
|
||||
} else {
|
||||
throw new RuntimeException("没有权限");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,7 +316,18 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
||||
*/
|
||||
@Override
|
||||
public int deleteDmPlayerentByIds(Long[] ids) {
|
||||
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||
return dmPlayerentMapper.deleteDmPlayerentByIds(ids);
|
||||
} else {
|
||||
List<DmPlayerentPlus> list = dmPlayerentMapper.selectBatchIds(Arrays.asList(ids));
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).getAccountid().longValue() == SecurityUtils.getUserId()) {
|
||||
} else {
|
||||
throw new RuntimeException("没有权限");
|
||||
}
|
||||
}
|
||||
return dmPlayerentMapper.deleteDmPlayerentByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user