use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.
the class ThingsModelTemplateServiceImpl method insertThingsModelTemplate.
/**
* 新增通用物模型
*
* @param thingsModelTemplate 通用物模型
* @return 结果
*/
@Override
public int insertThingsModelTemplate(ThingsModelTemplate thingsModelTemplate) {
SysUser user = getLoginUser().getUser();
List<SysRole> roles = user.getRoles();
if (roles == null || roles.size() == 0) {
return 0;
}
// 系统管理员
if (roles.stream().anyMatch(a -> a.getRoleKey().equals("admin"))) {
thingsModelTemplate.setIsSys(1);
}
thingsModelTemplate.setTenantId(user.getUserId());
thingsModelTemplate.setTenantName(user.getUserName());
thingsModelTemplate.setCreateTime(DateUtils.getNowDate());
return thingsModelTemplateMapper.insertThingsModelTemplate(thingsModelTemplate);
}
use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.
the class ProductServiceImpl method insertProduct.
/**
* 新增产品
*
* @param product 产品
* @return 结果
*/
@Override
public Product insertProduct(Product product) {
SysUser user = getLoginUser().getUser();
List<SysRole> roles = user.getRoles();
if (roles == null || roles.size() == 0) {
return null;
}
// 系统管理员
if (roles.stream().anyMatch(a -> a.getRoleKey().equals("admin"))) {
product.setIsSys(1);
}
// mqtt账号密码
product.setMqttAccount("wumei-smart");
product.setMqttPassword("P" + toolService.getStringRandom(15));
product.setMqttSecret("K" + toolService.getStringRandom(15));
product.setStatus(product.getStatus() == null ? 1 : product.getStatus());
product.setTenantId(user.getUserId());
product.setTenantName(user.getUserName());
product.setCreateTime(DateUtils.getNowDate());
productMapper.insertProduct(product);
return product;
}
use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.
the class SysRoleServiceImpl method deleteRoleByIds.
/**
* 批量删除角色信息
*
* @param roleIds 需要删除的角色ID
* @return 结果
*/
@Override
@Transactional
public int deleteRoleByIds(Long[] roleIds) {
for (Long roleId : roleIds) {
checkRoleAllowed(new SysRole(roleId));
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0) {
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenu(roleIds);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDept(roleIds);
return roleMapper.deleteRoleByIds(roleIds);
}
use of com.ruoyi.common.core.domain.entity.SysRole in project wumei-smart by kerwincui.
the class SysRoleServiceImpl method checkRoleDataScope.
/**
* 校验角色是否有数据权限
*
* @param roleId 角色id
*/
@Override
public void checkRoleDataScope(Long roleId) {
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
SysRole role = new SysRole();
role.setRoleId(roleId);
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
if (StringUtils.isEmpty(roles)) {
throw new ServiceException("没有权限访问角色数据!");
}
}
}
use of com.ruoyi.common.core.domain.entity.SysRole in project RuoYi-Vue by yangzongzhuan.
the class SysRoleServiceImpl method checkRoleNameUnique.
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleNameUnique(SysRole role) {
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
Aggregations