添加权限控制
This commit is contained in:
1 parent
f91140ea33
commit
db12a62698
2 files changed
+43
-2
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.luqj.util.HttpHelper;
|
||||||
import com.ruoyi.common.select.SelectItem;
|
import com.ruoyi.common.select.SelectItem;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.DmPlayerConfig;
|
import com.ruoyi.system.domain.DmPlayerConfig;
|
||||||
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
import com.ruoyi.system.domain.DmPlayerConfigPlus;
|
||||||
|
|||||||
+42
-2
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.luqj.util.HttpHelper;
|
import com.luqj.util.HttpHelper;
|
||||||
import com.ruoyi.common.select.SelectItem;
|
import com.ruoyi.common.select.SelectItem;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.TokenUtil;
|
import com.ruoyi.common.utils.TokenUtil;
|
||||||
import com.ruoyi.system.domain.DmOperateVo;
|
import com.ruoyi.system.domain.DmOperateVo;
|
||||||
@@ -156,10 +157,18 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
|||||||
@Override
|
@Override
|
||||||
public DmPlayerent selectDmPlayerentById(Long id) {
|
public DmPlayerent selectDmPlayerentById(Long id) {
|
||||||
DmPlayerent dmPlayerent = dmPlayerentMapper.selectDmPlayerentById(id);
|
DmPlayerent dmPlayerent = dmPlayerentMapper.selectDmPlayerentById(id);
|
||||||
dmPlayerent.setMjpegUrl("http://" + dmPlayerent.getIp()+":8888/stream?token="
|
dmPlayerent.setMjpegUrl("http://" + dmPlayerent.getIp() + ":8888/stream?token="
|
||||||
+ TokenUtil.generateToken(dmPlayerent.getId()+"",dmPlayerent.getSecret()));
|
+ TokenUtil.generateToken(dmPlayerent.getId() + "", dmPlayerent.getSecret()));
|
||||||
dmPlayerent.setSecret(null);
|
dmPlayerent.setSecret(null);
|
||||||
|
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||||
return dmPlayerent;
|
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
|
@Override
|
||||||
public List<DmPlayerent> selectDmPlayerentList(DmPlayerent dmPlayerent) {
|
public List<DmPlayerent> selectDmPlayerentList(DmPlayerent dmPlayerent) {
|
||||||
|
if (SecurityUtils.getUserId() != 1L) {
|
||||||
|
dmPlayerent.setAccountid(SecurityUtils.getUserId());
|
||||||
|
}
|
||||||
List<DmPlayerent> list = dmPlayerentMapper.selectDmPlayerentList(dmPlayerent);
|
List<DmPlayerent> list = dmPlayerentMapper.selectDmPlayerentList(dmPlayerent);
|
||||||
List<Long> ids = new ArrayList<>();
|
List<Long> ids = new ArrayList<>();
|
||||||
for (DmPlayerent playerent : list) {
|
for (DmPlayerent playerent : list) {
|
||||||
@@ -212,6 +224,7 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertDmPlayerent(DmPlayerent dmPlayerent) {
|
public int insertDmPlayerent(DmPlayerent dmPlayerent) {
|
||||||
|
dmPlayerent.setAccountid(SecurityUtils.getUserId());
|
||||||
dmPlayerent.setCreateTime(DateUtils.getNowDate());
|
dmPlayerent.setCreateTime(DateUtils.getNowDate());
|
||||||
return dmPlayerentMapper.insertDmPlayerent(dmPlayerent);
|
return dmPlayerentMapper.insertDmPlayerent(dmPlayerent);
|
||||||
}
|
}
|
||||||
@@ -219,6 +232,14 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
|||||||
@Override
|
@Override
|
||||||
public boolean operate(DmOperateVo vo) {
|
public boolean operate(DmOperateVo vo) {
|
||||||
DmPlayerent dmPlayerent = this.dmPlayerentMapper.selectDmPlayerentById(Long.parseLong(vo.getPlayerId()));
|
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) {
|
if (dmPlayerent == null) {
|
||||||
throw new RuntimeException("找不到对象");
|
throw new RuntimeException("找不到对象");
|
||||||
}
|
}
|
||||||
@@ -276,7 +297,15 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
|
|||||||
@Override
|
@Override
|
||||||
public int updateDmPlayerent(DmPlayerent dmPlayerent) {
|
public int updateDmPlayerent(DmPlayerent dmPlayerent) {
|
||||||
dmPlayerent.setUpdateTime(DateUtils.getNowDate());
|
dmPlayerent.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||||
return dmPlayerentMapper.updateDmPlayerent(dmPlayerent);
|
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
|
@Override
|
||||||
public int deleteDmPlayerentByIds(Long[] ids) {
|
public int deleteDmPlayerentByIds(Long[] ids) {
|
||||||
|
if (null != SecurityUtils.getUserId() && SecurityUtils.getUserId() == 1L) {
|
||||||
return dmPlayerentMapper.deleteDmPlayerentByIds(ids);
|
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