2021年9月2日10:07:12 1.增加微信小程序接口 2.4G开关功能接口

This commit is contained in:
xxmfl
2021-09-02 10:08:27 +08:00
parent 5c97293269
commit a8bc50f67c
337 changed files with 16032 additions and 12055 deletions

View File

@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.IotCategory;
/**
* 设备分类Service接口
*
*
* @author kerwincui
* @date 2021-05-07
*/
public interface IIotCategoryService
{
public interface IIotCategoryService {
/**
* 查询设备分类
*
*
* @param categoryId 设备分类ID
* @return 设备分类
*/
@@ -21,7 +21,7 @@ public interface IIotCategoryService
/**
* 查询设备分类列表
*
*
* @param iotCategory 设备分类
* @return 设备分类集合
*/
@@ -29,7 +29,7 @@ public interface IIotCategoryService
/**
* 新增设备分类
*
*
* @param iotCategory 设备分类
* @return 结果
*/
@@ -37,7 +37,7 @@ public interface IIotCategoryService
/**
* 修改设备分类
*
*
* @param iotCategory 设备分类
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface IIotCategoryService
/**
* 批量删除设备分类
*
*
* @param categoryIds 需要删除的设备分类ID
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface IIotCategoryService
/**
* 删除设备分类信息
*
*
* @param categoryId 设备分类ID
* @return 结果
*/

View File

@@ -1,20 +1,22 @@
package com.ruoyi.system.service;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.IotDevice;
import com.ruoyi.system.domain.vo.IotDeviceListDto;
import org.springframework.transaction.annotation.Transactional;
/**
* 设备Service接口
*
*
* @author kerwincui
* @date 2021-05-06
*/
public interface IIotDeviceService
{
public interface IIotDeviceService {
/**
* 查询设备
*
*
* @param deviceId 设备ID
* @return 设备
*/
@@ -27,7 +29,7 @@ public interface IIotDeviceService
/**
* 查询设备列表
*
*
* @param iotDevice 设备
* @return 设备集合
*/
@@ -35,7 +37,7 @@ public interface IIotDeviceService
/**
* 新增设备
*
*
* @param iotDevice 设备
* @return 结果
*/
@@ -43,7 +45,7 @@ public interface IIotDeviceService
/**
* 修改设备
*
*
* @param iotDevice 设备
* @return 结果
*/
@@ -51,7 +53,7 @@ public interface IIotDeviceService
/**
* 批量删除设备
*
*
* @param deviceIds 需要删除的设备ID
* @return 结果
*/
@@ -59,9 +61,27 @@ public interface IIotDeviceService
/**
* 删除设备信息
*
*
* @param deviceId 设备ID
* @return 结果
*/
public int deleteIotDeviceById(Long deviceId);
int controlDeviceByNum(String deviceNum, String cmd);
int bindDevice(Long userId,String nickname,String deviceNum,String name,Long categoryId,String remark);
List<IotDeviceListDto> selectMpIotDeviceList(IotDevice iotDevice);
@Transactional
int updateDeviceInfo(Long userId, String nickName, Long deviceId, String name, String remark);
IotDevice selectIotDeviceByUserAndNum(Long userId, String deviceNum);
int unBindDevice(Long userId,String username,Long deviceId);
JSONObject getDeviceInfoByDeviceNum(Long userId,String nickName,String deviceNum);
JSONObject getDeviceInfoByDeviceId(Long userId, String username, Long deviceId);
}

View File

@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.IotDeviceSet;
/**
* 设备配置Service接口
*
*
* @author kerwincui
* @date 2021-05-06
*/
public interface IIotDeviceSetService
{
public interface IIotDeviceSetService {
/**
* 查询设备配置
*
*
* @param deviceConfigId 设备配置ID
* @return 设备配置
*/
@@ -29,7 +29,7 @@ public interface IIotDeviceSetService
/**
* 查询设备配置列表
*
*
* @param iotDeviceSet 设备配置
* @return 设备配置集合
*/
@@ -37,7 +37,7 @@ public interface IIotDeviceSetService
/**
* 新增设备配置
*
*
* @param iotDeviceSet 设备配置
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface IIotDeviceSetService
/**
* 修改设备配置
*
*
* @param iotDeviceSet 设备配置
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface IIotDeviceSetService
/**
* 批量删除设备配置
*
*
* @param deviceConfigIds 需要删除的设备配置ID
* @return 结果
*/
@@ -61,7 +61,7 @@ public interface IIotDeviceSetService
/**
* 删除设备配置信息
*
*
* @param deviceConfigId 设备配置ID
* @return 结果
*/

View File

@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.IotDeviceStatus;
/**
* 设备状态Service接口
*
*
* @author kerwincui
* @date 2021-05-06
*/
public interface IIotDeviceStatusService
{
public interface IIotDeviceStatusService {
/**
* 查询设备状态
*
*
* @param deviceStatusId 设备状态ID
* @return 设备状态
*/
@@ -37,7 +37,7 @@ public interface IIotDeviceStatusService
/**
* 查询设备状态列表
*
*
* @param iotDeviceStatus 设备状态
* @return 设备状态集合
*/
@@ -45,7 +45,7 @@ public interface IIotDeviceStatusService
/**
* 新增设备状态
*
*
* @param iotDeviceStatus 设备状态
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface IIotDeviceStatusService
/**
* 修改设备状态
*
*
* @param iotDeviceStatus 设备状态
* @return 结果
*/
@@ -61,7 +61,7 @@ public interface IIotDeviceStatusService
/**
* 批量删除设备状态
*
*
* @param deviceStatusIds 需要删除的设备状态ID
* @return 结果
*/
@@ -69,7 +69,7 @@ public interface IIotDeviceStatusService
/**
* 删除设备状态信息
*
*
* @param deviceStatusId 设备状态ID
* @return 结果
*/

View File

@@ -0,0 +1,68 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.IotDeviceUserRelation;
/**
* 【请填写功能名称】Service接口
*
* @author wxy
* @date 2021-08-27
*/
public interface IIotDeviceUserRelationService {
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】ID
* @return 【请填写功能名称】
*/
public IotDeviceUserRelation selectIotDeviceUserRelationById(Long id);
/**
* 查询【请填写功能名称】列表
*
* @param iotDeviceUserRelation 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<IotDeviceUserRelation> selectIotDeviceUserRelationList(IotDeviceUserRelation iotDeviceUserRelation);
/**
* 新增【请填写功能名称】
*
* @param iotDeviceUserRelation 【请填写功能名称】
* @return 结果
*/
public int insertIotDeviceUserRelation(IotDeviceUserRelation iotDeviceUserRelation);
/**
* 修改【请填写功能名称】
*
* @param iotDeviceUserRelation 【请填写功能名称】
* @return 结果
*/
public int updateIotDeviceUserRelation(IotDeviceUserRelation iotDeviceUserRelation);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】ID
* @return 结果
*/
public int deleteIotDeviceUserRelationByIds(Long[] ids);
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】ID
* @return 结果
*/
public int deleteIotDeviceUserRelationById(Long id);
List<IotDeviceUserRelation> selectIotDeviceUserRelationByDeviceId(Long deviceId);
List<IotDeviceUserRelation> selectIotDeviceUserRelationByUserId(Long userId);
IotDeviceUserRelation selectIotDeviceUserRelationByDeviceIdAndUserId(Long deviceId,Long userId);
}

View File

@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.IotGroup;
/**
* 分组Service接口
*
*
* @author kerwincui
* @date 2021-05-18
*/
public interface IIotGroupService
{
public interface IIotGroupService {
/**
* 查询分组
*
*
* @param groupId 分组ID
* @return 分组
*/
@@ -21,7 +21,7 @@ public interface IIotGroupService
/**
* 查询分组列表
*
*
* @param iotGroup 分组
* @return 分组集合
*/
@@ -29,7 +29,7 @@ public interface IIotGroupService
/**
* 新增分组
*
*
* @param iotGroup 分组
* @return 结果
*/
@@ -37,7 +37,7 @@ public interface IIotGroupService
/**
* 修改分组
*
*
* @param iotGroup 分组
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface IIotGroupService
/**
* 批量删除分组
*
*
* @param groupIds 需要删除的分组ID
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface IIotGroupService
/**
* 删除分组信息
*
*
* @param groupId 分组ID
* @return 结果
*/

View File

@@ -1,18 +1,18 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysConfig;
/**
* 参数配置 服务层
*
*
* @author ruoyi
*/
public interface ISysConfigService
{
public interface ISysConfigService {
/**
* 查询参数配置信息
*
*
* @param configId 参数配置ID
* @return 参数配置信息
*/
@@ -20,7 +20,7 @@ public interface ISysConfigService
/**
* 根据键名查询参数配置信息
*
*
* @param configKey 参数键名
* @return 参数键值
*/
@@ -28,7 +28,7 @@ public interface ISysConfigService
/**
* 查询参数配置列表
*
*
* @param config 参数配置信息
* @return 参数配置集合
*/
@@ -36,7 +36,7 @@ public interface ISysConfigService
/**
* 新增参数配置
*
*
* @param config 参数配置信息
* @return 结果
*/
@@ -44,7 +44,7 @@ public interface ISysConfigService
/**
* 修改参数配置
*
*
* @param config 参数配置信息
* @return 结果
*/
@@ -52,7 +52,7 @@ public interface ISysConfigService
/**
* 批量删除参数信息
*
*
* @param configIds 需要删除的参数ID
* @return 结果
*/
@@ -65,7 +65,7 @@ public interface ISysConfigService
/**
* 校验参数键名是否唯一
*
*
* @param config 参数信息
* @return 结果
*/

View File

@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
/**
* 部门管理 服务层
*
*
* @author ruoyi
*/
public interface ISysDeptService
{
public interface ISysDeptService {
/**
* 查询部门管理数据
*
*
* @param dept 部门信息
* @return 部门信息集合
*/
@@ -21,7 +21,7 @@ public interface ISysDeptService
/**
* 构建前端所需要树结构
*
*
* @param depts 部门列表
* @return 树结构列表
*/
@@ -29,7 +29,7 @@ public interface ISysDeptService
/**
* 构建前端所需要下拉树结构
*
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
@@ -37,7 +37,7 @@ public interface ISysDeptService
/**
* 根据角色ID查询部门树信息
*
*
* @param roleId 角色ID
* @return 选中部门列表
*/
@@ -45,7 +45,7 @@ public interface ISysDeptService
/**
* 根据部门ID查询信息
*
*
* @param deptId 部门ID
* @return 部门信息
*/
@@ -53,7 +53,7 @@ public interface ISysDeptService
/**
* 根据ID查询所有子部门正常状态
*
*
* @param deptId 部门ID
* @return 子部门数
*/
@@ -61,7 +61,7 @@ public interface ISysDeptService
/**
* 是否存在部门子节点
*
*
* @param deptId 部门ID
* @return 结果
*/
@@ -69,7 +69,7 @@ public interface ISysDeptService
/**
* 查询部门是否存在用户
*
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@@ -77,7 +77,7 @@ public interface ISysDeptService
/**
* 校验部门名称是否唯一
*
*
* @param dept 部门信息
* @return 结果
*/
@@ -85,7 +85,7 @@ public interface ISysDeptService
/**
* 新增保存部门信息
*
*
* @param dept 部门信息
* @return 结果
*/
@@ -93,7 +93,7 @@ public interface ISysDeptService
/**
* 修改保存部门信息
*
*
* @param dept 部门信息
* @return 结果
*/
@@ -101,7 +101,7 @@ public interface ISysDeptService
/**
* 删除部门管理信息
*
*
* @param deptId 部门ID
* @return 结果
*/

View File

@@ -1,18 +1,18 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysDictData;
/**
* 字典 业务层
*
*
* @author ruoyi
*/
public interface ISysDictDataService
{
public interface ISysDictDataService {
/**
* 根据条件分页查询字典数据
*
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
@@ -20,8 +20,8 @@ public interface ISysDictDataService
/**
* 根据字典类型和字典键值查询字典数据信息
*
* @param dictType 字典类型
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典标签
*/
@@ -29,7 +29,7 @@ public interface ISysDictDataService
/**
* 根据字典数据ID查询信息
*
*
* @param dictCode 字典数据ID
* @return 字典数据
*/
@@ -37,7 +37,7 @@ public interface ISysDictDataService
/**
* 批量删除字典数据信息
*
*
* @param dictCodes 需要删除的字典数据ID
* @return 结果
*/
@@ -45,7 +45,7 @@ public interface ISysDictDataService
/**
* 新增保存字典数据信息
*
*
* @param dictData 字典数据信息
* @return 结果
*/
@@ -53,7 +53,7 @@ public interface ISysDictDataService
/**
* 修改保存字典数据信息
*
*
* @param dictData 字典数据信息
* @return 结果
*/

View File

@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysDictType;
/**
* 字典 业务层
*
*
* @author ruoyi
*/
public interface ISysDictTypeService
{
public interface ISysDictTypeService {
/**
* 根据条件分页查询字典类型
*
*
* @param dictType 字典类型信息
* @return 字典类型集合信息
*/
@@ -21,14 +21,14 @@ public interface ISysDictTypeService
/**
* 根据所有字典类型
*
*
* @return 字典类型集合信息
*/
public List<SysDictType> selectDictTypeAll();
/**
* 根据字典类型查询字典数据
*
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@@ -36,7 +36,7 @@ public interface ISysDictTypeService
/**
* 根据字典类型ID查询信息
*
*
* @param dictId 字典类型ID
* @return 字典类型
*/
@@ -44,7 +44,7 @@ public interface ISysDictTypeService
/**
* 根据字典类型查询信息
*
*
* @param dictType 字典类型
* @return 字典类型
*/
@@ -52,7 +52,7 @@ public interface ISysDictTypeService
/**
* 批量删除字典信息
*
*
* @param dictIds 需要删除的字典ID
* @return 结果
*/
@@ -65,7 +65,7 @@ public interface ISysDictTypeService
/**
* 新增保存字典类型信息
*
*
* @param dictType 字典类型信息
* @return 结果
*/
@@ -73,7 +73,7 @@ public interface ISysDictTypeService
/**
* 修改保存字典类型信息
*
*
* @param dictType 字典类型信息
* @return 结果
*/
@@ -81,7 +81,7 @@ public interface ISysDictTypeService
/**
* 校验字典类型称是否唯一
*
*
* @param dictType 字典类型
* @return 结果
*/

View File

@@ -1,25 +1,25 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysLogininfor;
/**
* 系统访问日志情况信息 服务层
*
*
* @author ruoyi
*/
public interface ISysLogininforService
{
public interface ISysLogininforService {
/**
* 新增系统登录日志
*
*
* @param logininfor 访问日志对象
*/
public void insertLogininfor(SysLogininfor logininfor);
/**
* 查询系统登录日志集合
*
*
* @param logininfor 访问日志对象
* @return 登录记录集合
*/
@@ -27,7 +27,7 @@ public interface ISysLogininforService
/**
* 批量删除系统登录日志
*
*
* @param infoIds 需要删除的登录日志ID
* @return
*/

View File

@@ -2,20 +2,20 @@ package com.ruoyi.system.service;
import java.util.List;
import java.util.Set;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.system.domain.vo.RouterVo;
/**
* 菜单 业务层
*
*
* @author ruoyi
*/
public interface ISysMenuService
{
public interface ISysMenuService {
/**
* 根据用户查询系统菜单列表
*
*
* @param userId 用户ID
* @return 菜单列表
*/
@@ -23,8 +23,8 @@ public interface ISysMenuService
/**
* 根据用户查询系统菜单列表
*
* @param menu 菜单信息
*
* @param menu 菜单信息
* @param userId 用户ID
* @return 菜单列表
*/
@@ -32,7 +32,7 @@ public interface ISysMenuService
/**
* 根据用户ID查询权限
*
*
* @param userId 用户ID
* @return 权限列表
*/
@@ -40,7 +40,7 @@ public interface ISysMenuService
/**
* 根据用户ID查询菜单树信息
*
*
* @param userId 用户ID
* @return 菜单列表
*/
@@ -48,7 +48,7 @@ public interface ISysMenuService
/**
* 根据角色ID查询菜单树信息
*
*
* @param roleId 角色ID
* @return 选中菜单列表
*/
@@ -56,7 +56,7 @@ public interface ISysMenuService
/**
* 构建前端路由所需要的菜单
*
*
* @param menus 菜单列表
* @return 路由列表
*/
@@ -64,7 +64,7 @@ public interface ISysMenuService
/**
* 构建前端所需要树结构
*
*
* @param menus 菜单列表
* @return 树结构列表
*/
@@ -72,7 +72,7 @@ public interface ISysMenuService
/**
* 构建前端所需要下拉树结构
*
*
* @param menus 菜单列表
* @return 下拉树结构列表
*/
@@ -80,7 +80,7 @@ public interface ISysMenuService
/**
* 根据菜单ID查询信息
*
*
* @param menuId 菜单ID
* @return 菜单信息
*/
@@ -88,7 +88,7 @@ public interface ISysMenuService
/**
* 是否存在菜单子节点
*
*
* @param menuId 菜单ID
* @return 结果 true 存在 false 不存在
*/
@@ -96,7 +96,7 @@ public interface ISysMenuService
/**
* 查询菜单是否存在角色
*
*
* @param menuId 菜单ID
* @return 结果 true 存在 false 不存在
*/
@@ -104,7 +104,7 @@ public interface ISysMenuService
/**
* 新增保存菜单信息
*
*
* @param menu 菜单信息
* @return 结果
*/
@@ -112,7 +112,7 @@ public interface ISysMenuService
/**
* 修改保存菜单信息
*
*
* @param menu 菜单信息
* @return 结果
*/
@@ -120,7 +120,7 @@ public interface ISysMenuService
/**
* 删除菜单管理信息
*
*
* @param menuId 菜单ID
* @return 结果
*/
@@ -128,7 +128,7 @@ public interface ISysMenuService
/**
* 校验菜单名称是否唯一
*
*
* @param menu 菜单信息
* @return 结果
*/

View File

@@ -1,18 +1,18 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysNotice;
/**
* 公告 服务层
*
*
* @author ruoyi
*/
public interface ISysNoticeService
{
public interface ISysNoticeService {
/**
* 查询公告信息
*
*
* @param noticeId 公告ID
* @return 公告信息
*/
@@ -20,7 +20,7 @@ public interface ISysNoticeService
/**
* 查询公告列表
*
*
* @param notice 公告信息
* @return 公告集合
*/
@@ -28,7 +28,7 @@ public interface ISysNoticeService
/**
* 新增公告
*
*
* @param notice 公告信息
* @return 结果
*/
@@ -36,7 +36,7 @@ public interface ISysNoticeService
/**
* 修改公告
*
*
* @param notice 公告信息
* @return 结果
*/
@@ -44,15 +44,15 @@ public interface ISysNoticeService
/**
* 删除公告信息
*
*
* @param noticeId 公告ID
* @return 结果
*/
public int deleteNoticeById(Long noticeId);
/**
* 批量删除公告信息
*
*
* @param noticeIds 需要删除的公告ID
* @return 结果
*/

View File

@@ -1,25 +1,25 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysOperLog;
/**
* 操作日志 服务层
*
*
* @author ruoyi
*/
public interface ISysOperLogService
{
public interface ISysOperLogService {
/**
* 新增操作日志
*
*
* @param operLog 操作日志对象
*/
public void insertOperlog(SysOperLog operLog);
/**
* 查询系统操作日志集合
*
*
* @param operLog 操作日志对象
* @return 操作日志集合
*/
@@ -27,7 +27,7 @@ public interface ISysOperLogService
/**
* 批量删除系统操作日志
*
*
* @param operIds 需要删除的操作日志ID
* @return 结果
*/
@@ -35,7 +35,7 @@ public interface ISysOperLogService
/**
* 查询操作日志详细
*
*
* @param operId 操作ID
* @return 操作日志对象
*/

View File

@@ -1,18 +1,18 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysPost;
/**
* 岗位信息 服务层
*
*
* @author ruoyi
*/
public interface ISysPostService
{
public interface ISysPostService {
/**
* 查询岗位信息集合
*
*
* @param post 岗位信息
* @return 岗位列表
*/
@@ -20,14 +20,14 @@ public interface ISysPostService
/**
* 查询所有岗位
*
*
* @return 岗位列表
*/
public List<SysPost> selectPostAll();
/**
* 通过岗位ID查询岗位信息
*
*
* @param postId 岗位ID
* @return 角色对象信息
*/
@@ -35,7 +35,7 @@ public interface ISysPostService
/**
* 根据用户ID获取岗位选择框列表
*
*
* @param userId 用户ID
* @return 选中岗位ID列表
*/
@@ -43,7 +43,7 @@ public interface ISysPostService
/**
* 校验岗位名称
*
*
* @param post 岗位信息
* @return 结果
*/
@@ -51,7 +51,7 @@ public interface ISysPostService
/**
* 校验岗位编码
*
*
* @param post 岗位信息
* @return 结果
*/
@@ -59,7 +59,7 @@ public interface ISysPostService
/**
* 通过岗位ID查询岗位使用数量
*
*
* @param postId 岗位ID
* @return 结果
*/
@@ -67,7 +67,7 @@ public interface ISysPostService
/**
* 删除岗位信息
*
*
* @param postId 岗位ID
* @return 结果
*/
@@ -75,7 +75,7 @@ public interface ISysPostService
/**
* 批量删除岗位信息
*
*
* @param postIds 需要删除的岗位ID
* @return 结果
* @throws Exception 异常
@@ -84,7 +84,7 @@ public interface ISysPostService
/**
* 新增保存岗位信息
*
*
* @param post 岗位信息
* @return 结果
*/
@@ -92,7 +92,7 @@ public interface ISysPostService
/**
* 修改保存岗位信息
*
*
* @param post 岗位信息
* @return 结果
*/

View File

@@ -2,18 +2,18 @@ package com.ruoyi.system.service;
import java.util.List;
import java.util.Set;
import com.ruoyi.common.core.domain.entity.SysRole;
/**
* 角色业务层
*
*
* @author ruoyi
*/
public interface ISysRoleService
{
public interface ISysRoleService {
/**
* 根据条件分页查询角色数据
*
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@@ -21,7 +21,7 @@ public interface ISysRoleService
/**
* 根据用户ID查询角色
*
*
* @param userId 用户ID
* @return 权限列表
*/
@@ -29,14 +29,14 @@ public interface ISysRoleService
/**
* 查询所有角色
*
*
* @return 角色列表
*/
public List<SysRole> selectRoleAll();
/**
* 根据用户ID获取角色选择框列表
*
*
* @param userId 用户ID
* @return 选中角色ID列表
*/
@@ -44,7 +44,7 @@ public interface ISysRoleService
/**
* 通过角色ID查询角色
*
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@@ -52,7 +52,7 @@ public interface ISysRoleService
/**
* 校验角色名称是否唯一
*
*
* @param role 角色信息
* @return 结果
*/
@@ -60,7 +60,7 @@ public interface ISysRoleService
/**
* 校验角色权限是否唯一
*
*
* @param role 角色信息
* @return 结果
*/
@@ -68,14 +68,14 @@ public interface ISysRoleService
/**
* 校验角色是否允许操作
*
*
* @param role 角色信息
*/
public void checkRoleAllowed(SysRole role);
/**
* 通过角色ID查询角色使用数量
*
*
* @param roleId 角色ID
* @return 结果
*/
@@ -83,7 +83,7 @@ public interface ISysRoleService
/**
* 新增保存角色信息
*
*
* @param role 角色信息
* @return 结果
*/
@@ -91,7 +91,7 @@ public interface ISysRoleService
/**
* 修改保存角色信息
*
*
* @param role 角色信息
* @return 结果
*/
@@ -99,7 +99,7 @@ public interface ISysRoleService
/**
* 修改角色状态
*
*
* @param role 角色信息
* @return 结果
*/
@@ -107,7 +107,7 @@ public interface ISysRoleService
/**
* 修改数据权限信息
*
*
* @param role 角色信息
* @return 结果
*/
@@ -115,7 +115,7 @@ public interface ISysRoleService
/**
* 通过角色ID删除角色
*
*
* @param roleId 角色ID
* @return 结果
*/
@@ -123,7 +123,7 @@ public interface ISysRoleService
/**
* 批量删除角色信息
*
*
* @param roleIds 需要删除的角色ID
* @return 结果
*/

View File

@@ -5,42 +5,41 @@ import com.ruoyi.system.domain.SysUserOnline;
/**
* 在线用户 服务层
*
*
* @author ruoyi
*/
public interface ISysUserOnlineService
{
public interface ISysUserOnlineService {
/**
* 通过登录地址查询信息
*
*
* @param ipaddr 登录地址
* @param user 用户信息
* @param user 用户信息
* @return 在线用户信息
*/
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user);
/**
* 通过用户名称查询信息
*
*
* @param userName 用户名称
* @param user 用户信息
* @param user 用户信息
* @return 在线用户信息
*/
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user);
/**
* 通过登录地址/用户名称查询信息
*
* @param ipaddr 登录地址
*
* @param ipaddr 登录地址
* @param userName 用户名称
* @param user 用户信息
* @param user 用户信息
* @return 在线用户信息
*/
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user);
/**
* 设置在线用户信息
*
*
* @param user 用户信息
* @return 在线用户
*/

View File

@@ -1,18 +1,18 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
* 用户 业务层
*
*
* @author ruoyi
*/
public interface ISysUserService
{
public interface ISysUserService {
/**
* 根据条件分页查询用户列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@@ -20,15 +20,17 @@ public interface ISysUserService
/**
* 通过用户名查询用户
*
*
* @param userName 用户名
* @return 用户对象信息
*/
public SysUser selectUserByUserName(String userName);
public SysUser selectUserByOpenId(String openId);
/**
* 通过用户ID查询用户
*
*
* @param userId 用户ID
* @return 用户对象信息
*/
@@ -36,7 +38,7 @@ public interface ISysUserService
/**
* 根据用户ID查询用户所属角色组
*
*
* @param userName 用户名
* @return 结果
*/
@@ -44,7 +46,7 @@ public interface ISysUserService
/**
* 根据用户ID查询用户所属岗位组
*
*
* @param userName 用户名
* @return 结果
*/
@@ -52,7 +54,7 @@ public interface ISysUserService
/**
* 校验用户名称是否唯一
*
*
* @param userName 用户名称
* @return 结果
*/
@@ -76,14 +78,14 @@ public interface ISysUserService
/**
* 校验用户是否允许操作
*
*
* @param user 用户信息
*/
public void checkUserAllowed(SysUser user);
/**
* 新增用户信息
*
*
* @param user 用户信息
* @return 结果
*/
@@ -91,7 +93,7 @@ public interface ISysUserService
/**
* 修改用户信息
*
*
* @param user 用户信息
* @return 结果
*/
@@ -99,7 +101,7 @@ public interface ISysUserService
/**
* 修改用户状态
*
*
* @param user 用户信息
* @return 结果
*/
@@ -107,7 +109,7 @@ public interface ISysUserService
/**
* 修改用户基本信息
*
*
* @param user 用户信息
* @return 结果
*/
@@ -115,16 +117,16 @@ public interface ISysUserService
/**
* 修改用户头像
*
*
* @param userName 用户名
* @param avatar 头像地址
* @param avatar 头像地址
* @return 结果
*/
public boolean updateUserAvatar(String userName, String avatar);
/**
* 重置用户密码
*
*
* @param user 用户信息
* @return 结果
*/
@@ -132,7 +134,7 @@ public interface ISysUserService
/**
* 重置用户密码
*
*
* @param userName 用户名
* @param password 密码
* @return 结果
@@ -141,7 +143,7 @@ public interface ISysUserService
/**
* 通过用户ID删除用户
*
*
* @param userId 用户ID
* @return 结果
*/
@@ -149,7 +151,7 @@ public interface ISysUserService
/**
* 批量删除用户信息
*
*
* @param userIds 需要删除的用户ID
* @return 结果
*/
@@ -157,10 +159,10 @@ public interface ISysUserService
/**
* 导入用户数据
*
* @param userList 用户数据列表
*
* @param userList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
* @param operName 操作用户
* @return 结果
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);

View File

@@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.TUserAccountInfo;
/**
* 小程序用户Service接口
*
* @author wxy
* @date 2021-08-26
*/
public interface ITUserAccountInfoService {
/**
* 查询小程序用户
*
* @param id 小程序用户ID
* @return 小程序用户
*/
public TUserAccountInfo selectTUserAccountInfoById(Long id);
/**
* 查询小程序用户列表
*
* @param tUserAccountInfo 小程序用户
* @return 小程序用户集合
*/
public List<TUserAccountInfo> selectTUserAccountInfoList(TUserAccountInfo tUserAccountInfo);
/**
* 新增小程序用户
*
* @param tUserAccountInfo 小程序用户
* @return 结果
*/
public int insertTUserAccountInfo(TUserAccountInfo tUserAccountInfo);
/**
* 修改小程序用户
*
* @param tUserAccountInfo 小程序用户
* @return 结果
*/
public int updateTUserAccountInfo(TUserAccountInfo tUserAccountInfo);
/**
* 批量删除小程序用户
*
* @param ids 需要删除的小程序用户ID
* @return 结果
*/
public int deleteTUserAccountInfoByIds(Long[] ids);
/**
* 删除小程序用户信息
*
* @param id 小程序用户ID
* @return 结果
*/
public int deleteTUserAccountInfoById(Long id);
}

View File

@@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.TUserLoginLog;
/**
* 【请填写功能名称】Service接口
*
* @author wxy
* @date 2021-08-26
*/
public interface ITUserLoginLogService {
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】ID
* @return 【请填写功能名称】
*/
public TUserLoginLog selectTUserLoginLogById(Long id);
/**
* 查询【请填写功能名称】列表
*
* @param tUserLoginLog 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<TUserLoginLog> selectTUserLoginLogList(TUserLoginLog tUserLoginLog);
/**
* 新增【请填写功能名称】
*
* @param tUserLoginLog 【请填写功能名称】
* @return 结果
*/
public int insertTUserLoginLog(TUserLoginLog tUserLoginLog);
/**
* 修改【请填写功能名称】
*
* @param tUserLoginLog 【请填写功能名称】
* @return 结果
*/
public int updateTUserLoginLog(TUserLoginLog tUserLoginLog);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】ID
* @return 结果
*/
public int deleteTUserLoginLogByIds(Long[] ids);
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】ID
* @return 结果
*/
public int deleteTUserLoginLogById(Long id);
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -10,87 +11,80 @@ import com.ruoyi.system.service.IIotCategoryService;
/**
* 设备分类Service业务层处理
*
*
* @author kerwincui
* @date 2021-05-07
*/
@Service
public class IotCategoryServiceImpl implements IIotCategoryService
{
public class IotCategoryServiceImpl implements IIotCategoryService {
@Autowired
private IotCategoryMapper iotCategoryMapper;
/**
* 查询设备分类
*
*
* @param categoryId 设备分类ID
* @return 设备分类
*/
@Override
public IotCategory selectIotCategoryById(Long categoryId)
{
public IotCategory selectIotCategoryById(Long categoryId) {
return iotCategoryMapper.selectIotCategoryById(categoryId);
}
/**
* 查询设备分类列表
*
*
* @param iotCategory 设备分类
* @return 设备分类
*/
@Override
public List<IotCategory> selectIotCategoryList(IotCategory iotCategory)
{
public List<IotCategory> selectIotCategoryList(IotCategory iotCategory) {
return iotCategoryMapper.selectIotCategoryList(iotCategory);
}
/**
* 新增设备分类
*
*
* @param iotCategory 设备分类
* @return 结果
*/
@Override
public int insertIotCategory(IotCategory iotCategory)
{
public int insertIotCategory(IotCategory iotCategory) {
iotCategory.setCreateTime(DateUtils.getNowDate());
return iotCategoryMapper.insertIotCategory(iotCategory);
}
/**
* 修改设备分类
*
*
* @param iotCategory 设备分类
* @return 结果
*/
@Override
public int updateIotCategory(IotCategory iotCategory)
{
public int updateIotCategory(IotCategory iotCategory) {
iotCategory.setUpdateTime(DateUtils.getNowDate());
return iotCategoryMapper.updateIotCategory(iotCategory);
}
/**
* 批量删除设备分类
*
*
* @param categoryIds 需要删除的设备分类ID
* @return 结果
*/
@Override
public int deleteIotCategoryByIds(Long[] categoryIds)
{
public int deleteIotCategoryByIds(Long[] categoryIds) {
return iotCategoryMapper.deleteIotCategoryByIds(categoryIds);
}
/**
* 删除设备分类信息
*
*
* @param categoryId 设备分类ID
* @return 结果
*/
@Override
public int deleteIotCategoryById(Long categoryId)
{
public int deleteIotCategoryById(Long categoryId) {
return iotCategoryMapper.deleteIotCategoryById(categoryId);
}
}

View File

@@ -1,35 +1,56 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.IotDeviceListDto;
import com.ruoyi.system.mqtt.config.MqttPushClient;
import com.ruoyi.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.IotDeviceMapper;
import com.ruoyi.system.domain.IotDevice;
import com.ruoyi.system.service.IIotDeviceService;
import org.springframework.transaction.annotation.Transactional;
/**
* 设备Service业务层处理
*
*
* @author kerwincui
* @date 2021-05-06
*/
@Service
public class IotDeviceServiceImpl implements IIotDeviceService
{
@Slf4j
public class IotDeviceServiceImpl implements IIotDeviceService {
@Autowired
private IotDeviceMapper iotDeviceMapper;
@Autowired
private MqttPushClient pushClient;
@Autowired
private ITUserAccountInfoService userAccountInfoService;
@Autowired
private IIotDeviceUserRelationService deviceUserRelationService;
@Autowired
private IIotDeviceSetService iotDeviceSetService;
@Autowired
private IIotDeviceStatusService iotDeviceStatusService;
/**
* 查询设备
*
*
* @param deviceId 设备ID
* @return 设备
*/
@Override
public IotDevice selectIotDeviceById(Long deviceId)
{
public IotDevice selectIotDeviceById(Long deviceId) {
return iotDeviceMapper.selectIotDeviceById(deviceId);
}
@@ -40,70 +61,276 @@ public class IotDeviceServiceImpl implements IIotDeviceService
* @return 设备
*/
@Override
public IotDevice selectIotDeviceByNum(String deviceNum)
{
public IotDevice selectIotDeviceByNum(String deviceNum) {
return iotDeviceMapper.selectIotDeviceByNum(deviceNum);
}
/**
* 查询设备列表
*
*
* @param iotDevice 设备
* @return 设备
*/
@Override
public List<IotDeviceListDto> selectIotDeviceList(IotDevice iotDevice)
{
public List<IotDeviceListDto> selectIotDeviceList(IotDevice iotDevice) {
return iotDeviceMapper.selectIotDeviceList(iotDevice);
}
/**
* 新增设备
*
*
* @param iotDevice 设备
* @return 结果
*/
@Override
public int insertIotDevice(IotDevice iotDevice)
{
public int insertIotDevice(IotDevice iotDevice) {
iotDevice.setCreateTime(DateUtils.getNowDate());
return iotDeviceMapper.insertIotDevice(iotDevice);
}
/**
* 修改设备
*
*
* @param iotDevice 设备
* @return 结果
*/
@Override
public int updateIotDevice(IotDevice iotDevice)
{
public int updateIotDevice(IotDevice iotDevice) {
iotDevice.setUpdateTime(DateUtils.getNowDate());
return iotDeviceMapper.updateIotDevice(iotDevice);
}
/**
* 批量删除设备
*
*
* @param deviceIds 需要删除的设备ID
* @return 结果
*/
@Override
public int deleteIotDeviceByIds(Long[] deviceIds)
{
public int deleteIotDeviceByIds(Long[] deviceIds) {
return iotDeviceMapper.deleteIotDeviceByIds(deviceIds);
}
/**
* 删除设备信息
*
*
* @param deviceId 设备ID
* @return 结果
*/
@Override
public int deleteIotDeviceById(Long deviceId)
{
public int deleteIotDeviceById(Long deviceId) {
return iotDeviceMapper.deleteIotDeviceById(deviceId);
}
@Override
public int controlDeviceByNum(String deviceNum, String cmd) {
IotDevice iotDevice = iotDeviceMapper.selectIotDeviceByNum(deviceNum);
if(iotDevice==null)
{
throw new CustomException("设备不存在");
}
Long deviceId = iotDevice.getDeviceId();
// IotDeviceStatus status = iotDeviceStatusService.selectIotDeviceStatusByDeviceId(iotDeviceSet.getDeviceId());
// if (status == null || status.getIsOnline() == 0) {
// return AjaxResult.error("设备已离线,不能更新状态。");
// }
// // 存储
// iotDeviceSetService.updateIotDeviceSet(iotDeviceSet);
//
// //mqtt发布
// IotDeviceSet set = iotDeviceSetService.selectIotDeviceSetByDeviceId(iotDeviceSet.getDeviceId());
// if (iotDeviceSet.getIsRadar() != null) {
// set.setIsRadar(iotDeviceSet.getIsRadar());
// }
// if (iotDeviceSet.getIsAlarm() != null) {
// set.setIsAlarm(iotDeviceSet.getIsAlarm());
// }
// if (iotDeviceSet.getRadarInterval() != null) {
// set.setRadarInterval(iotDeviceSet.getRadarInterval());
// }
// if (iotDeviceSet.getIsRfControl() != null) {
// set.setIsRfControl(iotDeviceSet.getIsRfControl());
// }
// if (iotDeviceSet.getRfOneFunc() != null) {
// set.setRfOneFunc(iotDeviceSet.getRfOneFunc());
// }
// if (iotDeviceSet.getRfTwoFunc() != null) {
// set.setRfTwoFunc(iotDeviceSet.getRfTwoFunc());
// }
// if (iotDeviceSet.getRfThreeFunc() != null) {
// set.setRfThreeFunc(iotDeviceSet.getRfThreeFunc());
// }
// if (iotDeviceSet.getRfFourFunc() != null) {
// set.setRfFourFunc(iotDeviceSet.getRfFourFunc());
// }
// if (iotDeviceSet.getIsRfLearn() != null) {
// set.setIsRfLearn(iotDeviceSet.getIsRfLearn());
// }
// if (iotDeviceSet.getIsRfClear() != null) {
// set.setIsRfClear(iotDeviceSet.getIsRfClear());
// }
// if (iotDeviceSet.getIsAp() != null) {
// set.setIsAp(iotDeviceSet.getIsAp());
// }
// if (iotDeviceSet.getIsReset() != null) {
// set.setIsReset(iotDeviceSet.getIsReset());
// }
// String content = JSON.toJSONString(set);
// String topic = "xiaoyi/swtich/devices/"+deviceNum;
IotDeviceStatus iotDeviceStatus = new IotDeviceStatus();
iotDeviceStatus.setDeviceId(deviceId);
if("on".equalsIgnoreCase(cmd))
{
iotDeviceStatus.setRelayStatus(1);
}else{
iotDeviceStatus.setRelayStatus(0);
}
String topic = "status/set/" + deviceNum;
String content = JSON.toJSONString(iotDeviceStatus);
// content="{\"deviceId\":\"4\",\"params\":{},\"relayStatus\":\"1\"}";
System.out.println("topic:"+topic);
System.out.println("content:"+content);
boolean publish = pushClient.publish(2, true, topic, content);
if(publish)
{
return 1;
}else{
throw new CustomException("指令发送失败");
}
}
/**
* @Method
* @Description 用户添加设备
* @Param null
* @return
* @date 2021-08-27,0027 11:33
* @author admin
*
*/
@Override
@Transactional
public int bindDevice(Long userId,String nickName, String deviceNum, String name, Long categoryId, String remark) {
IotDevice iotDevice = iotDeviceMapper.selectIotDeviceByNum(deviceNum);
if(iotDevice==null)
{
throw new CustomException("设备【"+deviceNum+"】不存在");
}
Long deviceId = iotDevice.getDeviceId();
IotDeviceUserRelation iotDeviceUserRelation = deviceUserRelationService.selectIotDeviceUserRelationByDeviceIdAndUserId(deviceId, userId);
if(iotDeviceUserRelation!=null)
{
throw new CustomException("该设备已被绑定!");
// throw new CustomException("设备【"+deviceNum+"】已经绑定,请换其他设备!");
}
log.info("用户: "+nickName+",添加设备【"+deviceNum+"】,名称为:"+name);
// iotDevice.setDeviceName(name);
iotDevice.setRemark(remark);
if("未激活".equals(iotDevice.getStatus()))
{
throw new CustomException("该设备未激活不能绑定!");
}
iotDeviceMapper.updateIotDevice(iotDevice);
//保存设备用户关联
IotDeviceUserRelation iotDeviceUserRelation1 = new IotDeviceUserRelation();
iotDeviceUserRelation1.setDeviceId(deviceId);
iotDeviceUserRelation1.setDeviceNum(deviceNum);
iotDeviceUserRelation1.setUserId(userId);
iotDeviceUserRelation1.setDeviceName(name);
return deviceUserRelationService.insertIotDeviceUserRelation(iotDeviceUserRelation1);
}
@Override
public List<IotDeviceListDto> selectMpIotDeviceList(IotDevice iotDevice) {
return iotDeviceMapper.selectMpIotDeviceList(iotDevice);
}
@Override
@Transactional
public int updateDeviceInfo(Long userId, String nickName, Long deviceId, String name, String remark) {
IotDevice iotDevice = iotDeviceMapper.selectIotDeviceById(deviceId);
if(iotDevice==null)
{
throw new CustomException("设备不存在");
}
IotDeviceUserRelation iotDeviceUserRelation = deviceUserRelationService.selectIotDeviceUserRelationByDeviceIdAndUserId(deviceId, userId);
if(iotDeviceUserRelation==null)
{
throw new CustomException("设备不存在!");
}
String deviceNum=iotDevice.getDeviceNum();
log.info("用户: "+nickName+",修改设备【"+deviceNum+"】名称为:"+name);
// iotDeviceMapper.updateIotDevice(iotDevice);
//保存设备用户关联
IotDeviceUserRelation iotDeviceUserRelation1 = new IotDeviceUserRelation();
iotDeviceUserRelation1.setId(iotDeviceUserRelation.getId());
iotDeviceUserRelation1.setDeviceId(deviceId);
iotDeviceUserRelation1.setDeviceNum(deviceNum);
iotDeviceUserRelation1.setUserId(userId);
iotDeviceUserRelation1.setDeviceName(name);
iotDeviceUserRelation1.setRemark(remark);
return deviceUserRelationService.updateIotDeviceUserRelation(iotDeviceUserRelation1);
}
@Override
public IotDevice selectIotDeviceByUserAndNum(Long userId, String deviceNum) {
IotDevice iotDevice = iotDeviceMapper.selectIotDeviceByNum(deviceNum);
if(iotDevice==null)
{
throw new CustomException("设备不存在");
}
Long deviceId = iotDevice.getDeviceId();
IotDeviceUserRelation iotDeviceUserRelation = deviceUserRelationService.selectIotDeviceUserRelationByDeviceIdAndUserId(deviceId, userId);
if(iotDeviceUserRelation==null)
{
throw new CustomException("设备不存在!");
}
iotDevice.setDeviceName(iotDeviceUserRelation.getDeviceName());
iotDevice.setRemark(iotDeviceUserRelation.getRemark());
return iotDevice;
}
@Override
public int unBindDevice(Long userId, String nickName, Long deviceId) {
IotDevice iotDevice = iotDeviceMapper.selectIotDeviceById(deviceId);
if(iotDevice==null)
{
throw new CustomException("设备不存在");
}
IotDeviceUserRelation iotDeviceUserRelation = deviceUserRelationService.selectIotDeviceUserRelationByDeviceIdAndUserId(deviceId, userId);
if(iotDeviceUserRelation==null)
{
throw new CustomException("设备不存在,或已解绑!");
}
String deviceNum = iotDevice.getDeviceNum();
log.info("用户: "+nickName+",解绑设备【"+deviceNum+"");
return deviceUserRelationService.deleteIotDeviceUserRelationById(iotDeviceUserRelation.getId());
}
@Override
public JSONObject getDeviceInfoByDeviceNum(Long userId, String nickname,String deviceNum) {
return iotDeviceMapper.getDeviceInfoByDeviceNum(userId,deviceNum);
}
@Override
public JSONObject getDeviceInfoByDeviceId(Long userId, String nickname,Long deviceId) {
return iotDeviceMapper.getDeviceInfoByDeviceId(userId,deviceId);
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -10,25 +11,23 @@ import com.ruoyi.system.service.IIotDeviceSetService;
/**
* 设备配置Service业务层处理
*
*
* @author kerwincui
* @date 2021-05-06
*/
@Service
public class IotDeviceSetServiceImpl implements IIotDeviceSetService
{
public class IotDeviceSetServiceImpl implements IIotDeviceSetService {
@Autowired
private IotDeviceSetMapper iotDeviceSetMapper;
/**
* 查询设备配置
*
*
* @param deviceConfigId 设备配置ID
* @return 设备配置
*/
@Override
public IotDeviceSet selectIotDeviceSetById(Long deviceSetId)
{
public IotDeviceSet selectIotDeviceSetById(Long deviceSetId) {
return iotDeviceSetMapper.selectIotDeviceSetById(deviceSetId);
}
@@ -39,70 +38,64 @@ public class IotDeviceSetServiceImpl implements IIotDeviceSetService
* @return 设备配置
*/
@Override
public IotDeviceSet selectIotDeviceSetByDeviceId(Long deviceId)
{
public IotDeviceSet selectIotDeviceSetByDeviceId(Long deviceId) {
return iotDeviceSetMapper.selectIotDeviceSetByDeviceId(deviceId);
}
/**
* 查询设备配置列表
*
*
* @param iotDeviceSet 设备配置
* @return 设备配置
*/
@Override
public List<IotDeviceSet> selectIotDeviceSetList(IotDeviceSet iotDeviceSet)
{
public List<IotDeviceSet> selectIotDeviceSetList(IotDeviceSet iotDeviceSet) {
return iotDeviceSetMapper.selectIotDeviceSetList(iotDeviceSet);
}
/**
* 新增设备配置
*
*
* @param iotDeviceSet 设备配置
* @return 结果
*/
@Override
public int insertIotDeviceSet(IotDeviceSet iotDeviceSet)
{
public int insertIotDeviceSet(IotDeviceSet iotDeviceSet) {
iotDeviceSet.setCreateTime(DateUtils.getNowDate());
return iotDeviceSetMapper.insertIotDeviceSet(iotDeviceSet);
}
/**
* 修改设备配置
*
*
* @param iotDeviceSet 设备配置
* @return 结果
*/
@Override
public int updateIotDeviceSet(IotDeviceSet iotDeviceSet)
{
public int updateIotDeviceSet(IotDeviceSet iotDeviceSet) {
iotDeviceSet.setUpdateTime(DateUtils.getNowDate());
return iotDeviceSetMapper.updateIotDeviceSet(iotDeviceSet);
}
/**
* 批量删除设备配置
*
*
* @param deviceConfigIds 需要删除的设备配置ID
* @return 结果
*/
@Override
public int deleteIotDeviceSetByIds(Long[] deviceConfigIds)
{
public int deleteIotDeviceSetByIds(Long[] deviceConfigIds) {
return iotDeviceSetMapper.deleteIotDeviceSetByIds(deviceConfigIds);
}
/**
* 删除设备配置信息
*
*
* @param deviceConfigId 设备配置ID
* @return 结果
*/
@Override
public int deleteIotDeviceSetById(Long deviceConfigId)
{
public int deleteIotDeviceSetById(Long deviceConfigId) {
return iotDeviceSetMapper.deleteIotDeviceSetById(deviceConfigId);
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -10,25 +11,23 @@ import com.ruoyi.system.service.IIotDeviceStatusService;
/**
* 设备状态Service业务层处理
*
*
* @author kerwincui
* @date 2021-05-06
*/
@Service
public class IotDeviceStatusServiceImpl implements IIotDeviceStatusService
{
public class IotDeviceStatusServiceImpl implements IIotDeviceStatusService {
@Autowired
private IotDeviceStatusMapper iotDeviceStatusMapper;
/**
* 查询设备状态
*
*
* @param deviceStatusId 设备状态ID
* @return 设备状态
*/
@Override
public IotDeviceStatus selectIotDeviceStatusById(Long deviceStatusId)
{
public IotDeviceStatus selectIotDeviceStatusById(Long deviceStatusId) {
return iotDeviceStatusMapper.selectIotDeviceStatusById(deviceStatusId);
}
@@ -39,8 +38,7 @@ public class IotDeviceStatusServiceImpl implements IIotDeviceStatusService
* @return 设备状态
*/
@Override
public IotDeviceStatus selectIotDeviceStatusByDeviceId(Long deviceId)
{
public IotDeviceStatus selectIotDeviceStatusByDeviceId(Long deviceId) {
return iotDeviceStatusMapper.selectIotDeviceStatusByDeviceId(deviceId);
}
@@ -51,70 +49,64 @@ public class IotDeviceStatusServiceImpl implements IIotDeviceStatusService
* @return 设备状态
*/
@Override
public IotDeviceStatus selectIotDeviceStatusByDeviceNum(String deviceNum)
{
public IotDeviceStatus selectIotDeviceStatusByDeviceNum(String deviceNum) {
return iotDeviceStatusMapper.selectIotDeviceStatusByDeviceNum(deviceNum);
}
/**
* 查询设备状态列表
*
*
* @param iotDeviceStatus 设备状态
* @return 设备状态
*/
@Override
public List<IotDeviceStatus> selectIotDeviceStatusList(IotDeviceStatus iotDeviceStatus)
{
public List<IotDeviceStatus> selectIotDeviceStatusList(IotDeviceStatus iotDeviceStatus) {
return iotDeviceStatusMapper.selectIotDeviceStatusList(iotDeviceStatus);
}
/**
* 新增设备状态
*
*
* @param iotDeviceStatus 设备状态
* @return 结果
*/
@Override
public int insertIotDeviceStatus(IotDeviceStatus iotDeviceStatus)
{
public int insertIotDeviceStatus(IotDeviceStatus iotDeviceStatus) {
iotDeviceStatus.setCreateTime(DateUtils.getNowDate());
return iotDeviceStatusMapper.insertIotDeviceStatus(iotDeviceStatus);
}
/**
* 修改设备状态
*
*
* @param iotDeviceStatus 设备状态
* @return 结果
*/
@Override
public int updateIotDeviceStatus(IotDeviceStatus iotDeviceStatus)
{
public int updateIotDeviceStatus(IotDeviceStatus iotDeviceStatus) {
iotDeviceStatus.setUpdateTime(DateUtils.getNowDate());
return iotDeviceStatusMapper.updateIotDeviceStatus(iotDeviceStatus);
}
/**
* 批量删除设备状态
*
*
* @param deviceStatusIds 需要删除的设备状态ID
* @return 结果
*/
@Override
public int deleteIotDeviceStatusByIds(Long[] deviceStatusIds)
{
public int deleteIotDeviceStatusByIds(Long[] deviceStatusIds) {
return iotDeviceStatusMapper.deleteIotDeviceStatusByIds(deviceStatusIds);
}
/**
* 删除设备状态信息
*
*
* @param deviceStatusId 设备状态ID
* @return 结果
*/
@Override
public int deleteIotDeviceStatusById(Long deviceStatusId)
{
public int deleteIotDeviceStatusById(Long deviceStatusId) {
return iotDeviceStatusMapper.deleteIotDeviceStatusById(deviceStatusId);
}
}

View File

@@ -0,0 +1,113 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.IotDeviceUserRelationMapper;
import com.ruoyi.system.domain.IotDeviceUserRelation;
import com.ruoyi.system.service.IIotDeviceUserRelationService;
/**
* 【请填写功能名称】Service业务层处理
*
* @author wxy
* @date 2021-08-27
*/
@Service
public class IotDeviceUserRelationServiceImpl implements IIotDeviceUserRelationService {
@Autowired
private IotDeviceUserRelationMapper iotDeviceUserRelationMapper;
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】ID
* @return 【请填写功能名称】
*/
@Override
public IotDeviceUserRelation selectIotDeviceUserRelationById(Long id) {
return iotDeviceUserRelationMapper.selectIotDeviceUserRelationById(id);
}
/**
* 查询【请填写功能名称】列表
*
* @param iotDeviceUserRelation 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<IotDeviceUserRelation> selectIotDeviceUserRelationList(IotDeviceUserRelation iotDeviceUserRelation) {
return iotDeviceUserRelationMapper.selectIotDeviceUserRelationList(iotDeviceUserRelation);
}
/**
* 新增【请填写功能名称】
*
* @param iotDeviceUserRelation 【请填写功能名称】
* @return 结果
*/
@Override
public int insertIotDeviceUserRelation(IotDeviceUserRelation iotDeviceUserRelation) {
return iotDeviceUserRelationMapper.insertIotDeviceUserRelation(iotDeviceUserRelation);
}
/**
* 修改【请填写功能名称】
*
* @param iotDeviceUserRelation 【请填写功能名称】
* @return 结果
*/
@Override
public int updateIotDeviceUserRelation(IotDeviceUserRelation iotDeviceUserRelation) {
return iotDeviceUserRelationMapper.updateIotDeviceUserRelation(iotDeviceUserRelation);
}
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】ID
* @return 结果
*/
@Override
public int deleteIotDeviceUserRelationByIds(Long[] ids) {
return iotDeviceUserRelationMapper.deleteIotDeviceUserRelationByIds(ids);
}
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】ID
* @return 结果
*/
@Override
public int deleteIotDeviceUserRelationById(Long id) {
return iotDeviceUserRelationMapper.deleteIotDeviceUserRelationById(id);
}
@Override
public List<IotDeviceUserRelation> selectIotDeviceUserRelationByDeviceId(Long deviceId) {
IotDeviceUserRelation iotDeviceUserRelation = new IotDeviceUserRelation();
iotDeviceUserRelation.setDeviceId(deviceId);
return iotDeviceUserRelationMapper.selectIotDeviceUserRelationList(iotDeviceUserRelation);
}
@Override
public List<IotDeviceUserRelation> selectIotDeviceUserRelationByUserId(Long userId) {
IotDeviceUserRelation iotDeviceUserRelation = new IotDeviceUserRelation();
iotDeviceUserRelation.setUserId(userId);
return iotDeviceUserRelationMapper.selectIotDeviceUserRelationList(iotDeviceUserRelation);
}
@Override
public IotDeviceUserRelation selectIotDeviceUserRelationByDeviceIdAndUserId(Long deviceId, Long userId) {
IotDeviceUserRelation iotDeviceUserRelation = new IotDeviceUserRelation();
iotDeviceUserRelation.setUserId(userId);
List<IotDeviceUserRelation> iotDeviceUserRelations = iotDeviceUserRelationMapper.selectIotDeviceUserRelationList(iotDeviceUserRelation);
if(iotDeviceUserRelations==null || iotDeviceUserRelations.size()==0)
{
return null;
}
return iotDeviceUserRelations.get(0);
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -10,87 +11,80 @@ import com.ruoyi.system.service.IIotGroupService;
/**
* 分组Service业务层处理
*
*
* @author kerwincui
* @date 2021-05-18
*/
@Service
public class IotGroupServiceImpl implements IIotGroupService
{
public class IotGroupServiceImpl implements IIotGroupService {
@Autowired
private IotGroupMapper iotGroupMapper;
/**
* 查询分组
*
*
* @param groupId 分组ID
* @return 分组
*/
@Override
public IotGroup selectIotGroupById(Long groupId)
{
public IotGroup selectIotGroupById(Long groupId) {
return iotGroupMapper.selectIotGroupById(groupId);
}
/**
* 查询分组列表
*
*
* @param iotGroup 分组
* @return 分组
*/
@Override
public List<IotGroup> selectIotGroupList(IotGroup iotGroup)
{
public List<IotGroup> selectIotGroupList(IotGroup iotGroup) {
return iotGroupMapper.selectIotGroupList(iotGroup);
}
/**
* 新增分组
*
*
* @param iotGroup 分组
* @return 结果
*/
@Override
public int insertIotGroup(IotGroup iotGroup)
{
public int insertIotGroup(IotGroup iotGroup) {
iotGroup.setCreateTime(DateUtils.getNowDate());
return iotGroupMapper.insertIotGroup(iotGroup);
}
/**
* 修改分组
*
*
* @param iotGroup 分组
* @return 结果
*/
@Override
public int updateIotGroup(IotGroup iotGroup)
{
public int updateIotGroup(IotGroup iotGroup) {
iotGroup.setUpdateTime(DateUtils.getNowDate());
return iotGroupMapper.updateIotGroup(iotGroup);
}
/**
* 批量删除分组
*
*
* @param groupIds 需要删除的分组ID
* @return 结果
*/
@Override
public int deleteIotGroupByIds(Long[] groupIds)
{
public int deleteIotGroupByIds(Long[] groupIds) {
return iotGroupMapper.deleteIotGroupByIds(groupIds);
}
/**
* 删除分组信息
*
*
* @param groupId 分组ID
* @return 结果
*/
@Override
public int deleteIotGroupById(Long groupId)
{
public int deleteIotGroupById(Long groupId) {
return iotGroupMapper.deleteIotGroupById(groupId);
}
}

View File

@@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataSource;
@@ -19,12 +20,11 @@ import com.ruoyi.system.service.ISysConfigService;
/**
* 参数配置 服务层实现
*
*
* @author ruoyi
*/
@Service
public class SysConfigServiceImpl implements ISysConfigService
{
public class SysConfigServiceImpl implements ISysConfigService {
@Autowired
private SysConfigMapper configMapper;
@@ -35,25 +35,22 @@ public class SysConfigServiceImpl implements ISysConfigService
* 项目启动时,初始化参数到缓存
*/
@PostConstruct
public void init()
{
public void init() {
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
for (SysConfig config : configsList)
{
for (SysConfig config : configsList) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
}
/**
* 查询参数配置信息
*
*
* @param configId 参数配置ID
* @return 参数配置信息
*/
@Override
@DataSource(DataSourceType.MASTER)
public SysConfig selectConfigById(Long configId)
{
public SysConfig selectConfigById(Long configId) {
SysConfig config = new SysConfig();
config.setConfigId(configId);
return configMapper.selectConfig(config);
@@ -61,23 +58,20 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 根据键名查询参数配置信息
*
*
* @param configKey 参数key
* @return 参数键值
*/
@Override
public String selectConfigByKey(String configKey)
{
public String selectConfigByKey(String configKey) {
String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
if (StringUtils.isNotEmpty(configValue))
{
if (StringUtils.isNotEmpty(configValue)) {
return configValue;
}
SysConfig config = new SysConfig();
config.setConfigKey(configKey);
SysConfig retConfig = configMapper.selectConfig(config);
if (StringUtils.isNotNull(retConfig))
{
if (StringUtils.isNotNull(retConfig)) {
redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
return retConfig.getConfigValue();
}
@@ -86,28 +80,25 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 查询参数配置列表
*
*
* @param config 参数配置信息
* @return 参数配置集合
*/
@Override
public List<SysConfig> selectConfigList(SysConfig config)
{
public List<SysConfig> selectConfigList(SysConfig config) {
return configMapper.selectConfigList(config);
}
/**
* 新增参数配置
*
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public int insertConfig(SysConfig config)
{
public int insertConfig(SysConfig config) {
int row = configMapper.insertConfig(config);
if (row > 0)
{
if (row > 0) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
return row;
@@ -115,16 +106,14 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 修改参数配置
*
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public int updateConfig(SysConfig config)
{
public int updateConfig(SysConfig config) {
int row = configMapper.updateConfig(config);
if (row > 0)
{
if (row > 0) {
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
}
return row;
@@ -132,24 +121,20 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 批量删除参数信息
*
*
* @param configIds 需要删除的参数ID
* @return 结果
*/
@Override
public int deleteConfigByIds(Long[] configIds)
{
for (Long configId : configIds)
{
public int deleteConfigByIds(Long[] configIds) {
for (Long configId : configIds) {
SysConfig config = selectConfigById(configId);
if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
{
if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
}
}
int count = configMapper.deleteConfigByIds(configIds);
if (count > 0)
{
if (count > 0) {
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
redisCache.deleteObject(keys);
}
@@ -160,25 +145,22 @@ public class SysConfigServiceImpl implements ISysConfigService
* 清空缓存数据
*/
@Override
public void clearCache()
{
public void clearCache() {
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
redisCache.deleteObject(keys);
}
/**
* 校验参数键名是否唯一
*
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public String checkConfigKeyUnique(SysConfig config)
{
public String checkConfigKeyUnique(SysConfig config) {
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
{
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -186,12 +168,11 @@ public class SysConfigServiceImpl implements ISysConfigService
/**
* 设置cache key
*
*
* @param configKey 参数键
* @return 缓存键key
*/
private String getCacheKey(String configKey)
{
private String getCacheKey(String configKey) {
return Constants.SYS_CONFIG_KEY + configKey;
}
}

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
@@ -19,12 +20,11 @@ import com.ruoyi.system.service.ISysDeptService;
/**
* 部门管理 服务实现
*
*
* @author ruoyi
*/
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
public class SysDeptServiceImpl implements ISysDeptService {
@Autowired
private SysDeptMapper deptMapper;
@@ -33,44 +33,38 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 查询部门管理数据
*
*
* @param dept 部门信息
* @return 部门信息集合
*/
@Override
@DataScope(deptAlias = "d")
public List<SysDept> selectDeptList(SysDept dept)
{
public List<SysDept> selectDeptList(SysDept dept) {
return deptMapper.selectDeptList(dept);
}
/**
* 构建前端所需要树结构
*
*
* @param depts 部门列表
* @return 树结构列表
*/
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
public List<SysDept> buildDeptTree(List<SysDept> depts) {
List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = new ArrayList<Long>();
for (SysDept dept : depts)
{
for (SysDept dept : depts) {
tempList.add(dept.getDeptId());
}
for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
{
for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext(); ) {
SysDept dept = (SysDept) iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(dept.getParentId()))
{
if (!tempList.contains(dept.getParentId())) {
recursionFn(depts, dept);
returnList.add(dept);
}
}
if (returnList.isEmpty())
{
if (returnList.isEmpty()) {
returnList = depts;
}
return returnList;
@@ -78,93 +72,85 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 构建前端所需要下拉树结构
*
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
{
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 根据角色ID查询部门树信息
*
*
* @param roleId 角色ID
* @return 选中部门列表
*/
@Override
public List<Integer> selectDeptListByRoleId(Long roleId)
{
public List<Integer> selectDeptListByRoleId(Long roleId) {
SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
}
/**
* 根据部门ID查询信息
*
*
* @param deptId 部门ID
* @return 部门信息
*/
@Override
public SysDept selectDeptById(Long deptId)
{
public SysDept selectDeptById(Long deptId) {
return deptMapper.selectDeptById(deptId);
}
/**
* 根据ID查询所有子部门正常状态
*
*
* @param deptId 部门ID
* @return 子部门数
*/
@Override
public int selectNormalChildrenDeptById(Long deptId)
{
public int selectNormalChildrenDeptById(Long deptId) {
return deptMapper.selectNormalChildrenDeptById(deptId);
}
/**
* 是否存在子节点
*
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public boolean hasChildByDeptId(Long deptId)
{
public boolean hasChildByDeptId(Long deptId) {
int result = deptMapper.hasChildByDeptId(deptId);
return result > 0 ? true : false;
}
/**
* 查询部门是否存在用户
*
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId)
{
public boolean checkDeptExistUser(Long deptId) {
int result = deptMapper.checkDeptExistUser(deptId);
return result > 0 ? true : false;
}
/**
* 校验部门名称是否唯一
*
*
* @param dept 部门信息
* @return 结果
*/
@Override
public String checkDeptNameUnique(SysDept dept)
{
public String checkDeptNameUnique(SysDept dept) {
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
{
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -172,17 +158,15 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 新增保存部门信息
*
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int insertDept(SysDept dept)
{
public int insertDept(SysDept dept) {
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
{
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new CustomException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
@@ -191,25 +175,22 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 修改保存部门信息
*
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int updateDept(SysDept dept)
{
public int updateDept(SysDept dept) {
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
{
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
{
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) {
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatus(dept);
}
@@ -218,11 +199,10 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 修改该部门的父级部门状态
*
*
* @param dept 当前部门
*/
private void updateParentDeptStatus(SysDept dept)
{
private void updateParentDeptStatus(SysDept dept) {
String updateBy = dept.getUpdateBy();
dept = deptMapper.selectDeptById(dept.getDeptId());
dept.setUpdateBy(updateBy);
@@ -231,48 +211,41 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 修改子元素关系
*
* @param deptId 被修改的部门ID
*
* @param deptId 被修改的部门ID
* @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
{
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children)
{
for (SysDept child : children) {
child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
}
if (children.size() > 0)
{
if (children.size() > 0) {
deptMapper.updateDeptChildren(children);
}
}
/**
* 删除部门管理信息
*
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public int deleteDeptById(Long deptId)
{
public int deleteDeptById(Long deptId) {
return deptMapper.deleteDeptById(deptId);
}
/**
* 递归列表
*/
private void recursionFn(List<SysDept> list, SysDept t)
{
private void recursionFn(List<SysDept> list, SysDept t) {
// 得到子节点列表
List<SysDept> childList = getChildList(list, t);
t.setChildren(childList);
for (SysDept tChild : childList)
{
if (hasChild(list, tChild))
{
for (SysDept tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
@@ -281,15 +254,12 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 得到子节点列表
*/
private List<SysDept> getChildList(List<SysDept> list, SysDept t)
{
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
List<SysDept> tlist = new ArrayList<SysDept>();
Iterator<SysDept> it = list.iterator();
while (it.hasNext())
{
while (it.hasNext()) {
SysDept n = (SysDept) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
tlist.add(n);
}
}
@@ -299,8 +269,7 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 判断是否有子节点
*/
private boolean hasChild(List<SysDept> list, SysDept t)
{
private boolean hasChild(List<SysDept> list, SysDept t) {
return getChildList(list, t).size() > 0 ? true : false;
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.domain.entity.SysDictData;
@@ -10,64 +11,58 @@ import com.ruoyi.system.service.ISysDictDataService;
/**
* 字典 业务层处理
*
*
* @author ruoyi
*/
@Service
public class SysDictDataServiceImpl implements ISysDictDataService
{
public class SysDictDataServiceImpl implements ISysDictDataService {
@Autowired
private SysDictDataMapper dictDataMapper;
/**
* 根据条件分页查询字典数据
*
*
* @param dictData 字典数据信息
* @return 字典数据集合信息
*/
@Override
public List<SysDictData> selectDictDataList(SysDictData dictData)
{
public List<SysDictData> selectDictDataList(SysDictData dictData) {
return dictDataMapper.selectDictDataList(dictData);
}
/**
* 根据字典类型和字典键值查询字典数据信息
*
* @param dictType 字典类型
*
* @param dictType 字典类型
* @param dictValue 字典键值
* @return 字典标签
*/
@Override
public String selectDictLabel(String dictType, String dictValue)
{
public String selectDictLabel(String dictType, String dictValue) {
return dictDataMapper.selectDictLabel(dictType, dictValue);
}
/**
* 根据字典数据ID查询信息
*
*
* @param dictCode 字典数据ID
* @return 字典数据
*/
@Override
public SysDictData selectDictDataById(Long dictCode)
{
public SysDictData selectDictDataById(Long dictCode) {
return dictDataMapper.selectDictDataById(dictCode);
}
/**
* 批量删除字典数据信息
*
*
* @param dictCodes 需要删除的字典数据ID
* @return 结果
*/
@Override
public int deleteDictDataByIds(Long[] dictCodes)
{
public int deleteDictDataByIds(Long[] dictCodes) {
int row = dictDataMapper.deleteDictDataByIds(dictCodes);
if (row > 0)
{
if (row > 0) {
DictUtils.clearDictCache();
}
return row;
@@ -75,16 +70,14 @@ public class SysDictDataServiceImpl implements ISysDictDataService
/**
* 新增保存字典数据信息
*
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public int insertDictData(SysDictData dictData)
{
public int insertDictData(SysDictData dictData) {
int row = dictDataMapper.insertDictData(dictData);
if (row > 0)
{
if (row > 0) {
DictUtils.clearDictCache();
}
return row;
@@ -92,16 +85,14 @@ public class SysDictDataServiceImpl implements ISysDictDataService
/**
* 修改保存字典数据信息
*
*
* @param dictData 字典数据信息
* @return 结果
*/
@Override
public int updateDictData(SysDictData dictData)
{
public int updateDictData(SysDictData dictData) {
int row = dictDataMapper.updateDictData(dictData);
if (row > 0)
{
if (row > 0) {
DictUtils.clearDictCache();
}
return row;

View File

@@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -17,12 +18,11 @@ import com.ruoyi.system.service.ISysDictTypeService;
/**
* 字典 业务层处理
*
*
* @author ruoyi
*/
@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService
{
public class SysDictTypeServiceImpl implements ISysDictTypeService {
@Autowired
private SysDictTypeMapper dictTypeMapper;
@@ -33,11 +33,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
* 项目启动时,初始化字典到缓存
*/
@PostConstruct
public void init()
{
public void init() {
List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
for (SysDictType dictType : dictTypeList)
{
for (SysDictType dictType : dictTypeList) {
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
DictUtils.setDictCache(dictType.getDictType(), dictDatas);
}
@@ -45,44 +43,39 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
/**
* 根据条件分页查询字典类型
*
*
* @param dictType 字典类型信息
* @return 字典类型集合信息
*/
@Override
public List<SysDictType> selectDictTypeList(SysDictType dictType)
{
public List<SysDictType> selectDictTypeList(SysDictType dictType) {
return dictTypeMapper.selectDictTypeList(dictType);
}
/**
* 根据所有字典类型
*
*
* @return 字典类型集合信息
*/
@Override
public List<SysDictType> selectDictTypeAll()
{
public List<SysDictType> selectDictTypeAll() {
return dictTypeMapper.selectDictTypeAll();
}
/**
* 根据字典类型查询字典数据
*
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public List<SysDictData> selectDictDataByType(String dictType)
{
public List<SysDictData> selectDictDataByType(String dictType) {
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
if (StringUtils.isNotEmpty(dictDatas))
{
if (StringUtils.isNotEmpty(dictDatas)) {
return dictDatas;
}
dictDatas = dictDataMapper.selectDictDataByType(dictType);
if (StringUtils.isNotEmpty(dictDatas))
{
if (StringUtils.isNotEmpty(dictDatas)) {
DictUtils.setDictCache(dictType, dictDatas);
return dictDatas;
}
@@ -91,48 +84,42 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
/**
* 根据字典类型ID查询信息
*
*
* @param dictId 字典类型ID
* @return 字典类型
*/
@Override
public SysDictType selectDictTypeById(Long dictId)
{
public SysDictType selectDictTypeById(Long dictId) {
return dictTypeMapper.selectDictTypeById(dictId);
}
/**
* 根据字典类型查询信息
*
*
* @param dictType 字典类型
* @return 字典类型
*/
@Override
public SysDictType selectDictTypeByType(String dictType)
{
public SysDictType selectDictTypeByType(String dictType) {
return dictTypeMapper.selectDictTypeByType(dictType);
}
/**
* 批量删除字典类型信息
*
*
* @param dictIds 需要删除的字典ID
* @return 结果
*/
@Override
public int deleteDictTypeByIds(Long[] dictIds)
{
for (Long dictId : dictIds)
{
public int deleteDictTypeByIds(Long[] dictIds) {
for (Long dictId : dictIds) {
SysDictType dictType = selectDictTypeById(dictId);
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
{
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) {
throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
}
int count = dictTypeMapper.deleteDictTypeByIds(dictIds);
if (count > 0)
{
if (count > 0) {
DictUtils.clearDictCache();
}
return count;
@@ -142,23 +129,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
* 清空缓存数据
*/
@Override
public void clearCache()
{
public void clearCache() {
DictUtils.clearDictCache();
}
/**
* 新增保存字典类型信息
*
*
* @param dictType 字典类型信息
* @return 结果
*/
@Override
public int insertDictType(SysDictType dictType)
{
public int insertDictType(SysDictType dictType) {
int row = dictTypeMapper.insertDictType(dictType);
if (row > 0)
{
if (row > 0) {
DictUtils.clearDictCache();
}
return row;
@@ -166,19 +150,17 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
/**
* 修改保存字典类型信息
*
*
* @param dictType 字典类型信息
* @return 结果
*/
@Override
@Transactional
public int updateDictType(SysDictType dictType)
{
public int updateDictType(SysDictType dictType) {
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
int row = dictTypeMapper.updateDictType(dictType);
if (row > 0)
{
if (row > 0) {
DictUtils.clearDictCache();
}
return row;
@@ -186,17 +168,15 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
/**
* 校验字典类型称是否唯一
*
*
* @param dict 字典类型
* @return 结果
*/
@Override
public String checkDictTypeUnique(SysDictType dict)
{
public String checkDictTypeUnique(SysDictType dict) {
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
{
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysLogininfor;
@@ -9,48 +10,44 @@ import com.ruoyi.system.service.ISysLogininforService;
/**
* 系统访问日志情况信息 服务层处理
*
*
* @author ruoyi
*/
@Service
public class SysLogininforServiceImpl implements ISysLogininforService
{
public class SysLogininforServiceImpl implements ISysLogininforService {
@Autowired
private SysLogininforMapper logininforMapper;
/**
* 新增系统登录日志
*
*
* @param logininfor 访问日志对象
*/
@Override
public void insertLogininfor(SysLogininfor logininfor)
{
public void insertLogininfor(SysLogininfor logininfor) {
logininforMapper.insertLogininfor(logininfor);
}
/**
* 查询系统登录日志集合
*
*
* @param logininfor 访问日志对象
* @return 登录记录集合
*/
@Override
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor)
{
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) {
return logininforMapper.selectLogininforList(logininfor);
}
/**
* 批量删除系统登录日志
*
*
* @param infoIds 需要删除的登录日志ID
* @return
*/
@Override
public int deleteLogininforByIds(Long[] infoIds)
{
public int deleteLogininforByIds(Long[] infoIds) {
return logininforMapper.deleteLogininforByIds(infoIds);
}
@@ -58,8 +55,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService
* 清空系统登录日志
*/
@Override
public void cleanLogininfor()
{
public void cleanLogininfor() {
logininforMapper.cleanLogininfor();
}
}

View File

@@ -8,6 +8,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
@@ -26,12 +27,11 @@ import com.ruoyi.system.service.ISysMenuService;
/**
* 菜单 业务层处理
*
*
* @author ruoyi
*/
@Service
public class SysMenuServiceImpl implements ISysMenuService
{
public class SysMenuServiceImpl implements ISysMenuService {
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
@Autowired
@@ -45,33 +45,28 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 根据用户查询系统菜单列表
*
*
* @param userId 用户ID
* @return 菜单列表
*/
@Override
public List<SysMenu> selectMenuList(Long userId)
{
public List<SysMenu> selectMenuList(Long userId) {
return selectMenuList(new SysMenu(), userId);
}
/**
* 查询系统菜单列表
*
*
* @param menu 菜单信息
* @return 菜单列表
*/
@Override
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
{
public List<SysMenu> selectMenuList(SysMenu menu, Long userId) {
List<SysMenu> menuList = null;
// 管理员显示所有菜单信息
if (SysUser.isAdmin(userId))
{
if (SysUser.isAdmin(userId)) {
menuList = menuMapper.selectMenuList(menu);
}
else
{
} else {
menu.getParams().put("userId", userId);
menuList = menuMapper.selectMenuListByUserId(menu);
}
@@ -80,19 +75,16 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 根据用户ID查询权限
*
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectMenuPermsByUserId(Long userId)
{
public Set<String> selectMenuPermsByUserId(Long userId) {
List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (String perm : perms)
{
if (StringUtils.isNotEmpty(perm))
{
for (String perm : perms) {
if (StringUtils.isNotEmpty(perm)) {
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
}
}
@@ -101,20 +93,16 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 根据用户ID查询菜单
*
*
* @param userId 用户名称
* @return 菜单列表
*/
@Override
public List<SysMenu> selectMenuTreeByUserId(Long userId)
{
public List<SysMenu> selectMenuTreeByUserId(Long userId) {
List<SysMenu> menus = null;
if (SecurityUtils.isAdmin(userId))
{
if (SecurityUtils.isAdmin(userId)) {
menus = menuMapper.selectMenuTreeAll();
}
else
{
} else {
menus = menuMapper.selectMenuTreeByUserId(userId);
}
return getChildPerms(menus, 0);
@@ -122,29 +110,26 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 根据角色ID查询菜单树信息
*
*
* @param roleId 角色ID
* @return 选中菜单列表
*/
@Override
public List<Integer> selectMenuListByRoleId(Long roleId)
{
public List<Integer> selectMenuListByRoleId(Long roleId) {
SysRole role = roleMapper.selectRoleById(roleId);
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
}
/**
* 构建前端路由所需要的菜单
*
*
* @param menus 菜单列表
* @return 路由列表
*/
@Override
public List<RouterVo> buildMenus(List<SysMenu> menus)
{
public List<RouterVo> buildMenus(List<SysMenu> menus) {
List<RouterVo> routers = new LinkedList<RouterVo>();
for (SysMenu menu : menus)
{
for (SysMenu menu : menus) {
RouterVo router = new RouterVo();
router.setHidden("1".equals(menu.getVisible()));
router.setName(getRouteName(menu));
@@ -152,14 +137,11 @@ public class SysMenuServiceImpl implements ISysMenuService
router.setComponent(getComponent(menu));
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache())));
List<SysMenu> cMenus = menu.getChildren();
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
{
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
router.setAlwaysShow(true);
router.setRedirect("noRedirect");
router.setChildren(buildMenus(cMenus));
}
else if (isMeunFrame(menu))
{
} else if (isMeunFrame(menu)) {
List<RouterVo> childrenList = new ArrayList<RouterVo>();
RouterVo children = new RouterVo();
children.setPath(menu.getPath());
@@ -176,31 +158,26 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 构建前端所需要树结构
*
*
* @param menus 菜单列表
* @return 树结构列表
*/
@Override
public List<SysMenu> buildMenuTree(List<SysMenu> menus)
{
public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
List<SysMenu> returnList = new ArrayList<SysMenu>();
List<Long> tempList = new ArrayList<Long>();
for (SysMenu dept : menus)
{
for (SysMenu dept : menus) {
tempList.add(dept.getMenuId());
}
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
{
for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
SysMenu menu = (SysMenu) iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(menu.getParentId()))
{
if (!tempList.contains(menu.getParentId())) {
recursionFn(menus, menu);
returnList.add(menu);
}
}
if (returnList.isEmpty())
{
if (returnList.isEmpty()) {
returnList = menus;
}
return returnList;
@@ -208,104 +185,95 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 构建前端所需要下拉树结构
*
*
* @param menus 菜单列表
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
{
public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) {
List<SysMenu> menuTrees = buildMenuTree(menus);
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 根据菜单ID查询信息
*
*
* @param menuId 菜单ID
* @return 菜单信息
*/
@Override
public SysMenu selectMenuById(Long menuId)
{
public SysMenu selectMenuById(Long menuId) {
return menuMapper.selectMenuById(menuId);
}
/**
* 是否存在菜单子节点
*
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public boolean hasChildByMenuId(Long menuId)
{
public boolean hasChildByMenuId(Long menuId) {
int result = menuMapper.hasChildByMenuId(menuId);
return result > 0 ? true : false;
}
/**
* 查询菜单使用数量
*
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public boolean checkMenuExistRole(Long menuId)
{
public boolean checkMenuExistRole(Long menuId) {
int result = roleMenuMapper.checkMenuExistRole(menuId);
return result > 0 ? true : false;
}
/**
* 新增保存菜单信息
*
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public int insertMenu(SysMenu menu)
{
public int insertMenu(SysMenu menu) {
return menuMapper.insertMenu(menu);
}
/**
* 修改保存菜单信息
*
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public int updateMenu(SysMenu menu)
{
public int updateMenu(SysMenu menu) {
return menuMapper.updateMenu(menu);
}
/**
* 删除菜单管理信息
*
*
* @param menuId 菜单ID
* @return 结果
*/
@Override
public int deleteMenuById(Long menuId)
{
public int deleteMenuById(Long menuId) {
return menuMapper.deleteMenuById(menuId);
}
/**
* 校验菜单名称是否唯一
*
*
* @param menu 菜单信息
* @return 结果
*/
@Override
public String checkMenuNameUnique(SysMenu menu)
{
public String checkMenuNameUnique(SysMenu menu) {
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
{
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -313,16 +281,14 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 获取路由名称
*
*
* @param menu 菜单信息
* @return 路由名称
*/
public String getRouteName(SysMenu menu)
{
public String getRouteName(SysMenu menu) {
String routerName = StringUtils.capitalize(menu.getPath());
// 非外链并且是一级目录(类型为目录)
if (isMeunFrame(menu))
{
if (isMeunFrame(menu)) {
routerName = StringUtils.EMPTY;
}
return routerName;
@@ -330,22 +296,19 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 获取路由地址
*
*
* @param menu 菜单信息
* @return 路由地址
*/
public String getRouterPath(SysMenu menu)
{
public String getRouterPath(SysMenu menu) {
String routerPath = menu.getPath();
// 非外链并且是一级目录(类型为目录)
if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
&& UserConstants.NO_FRAME.equals(menu.getIsFrame()))
{
&& UserConstants.NO_FRAME.equals(menu.getIsFrame())) {
routerPath = "/" + menu.getPath();
}
// 非外链并且是一级目录(类型为菜单)
else if (isMeunFrame(menu))
{
else if (isMeunFrame(menu)) {
routerPath = "/";
}
return routerPath;
@@ -353,19 +316,15 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 获取组件信息
*
*
* @param menu 菜单信息
* @return 组件信息
*/
public String getComponent(SysMenu menu)
{
public String getComponent(SysMenu menu) {
String component = UserConstants.LAYOUT;
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMeunFrame(menu))
{
if (StringUtils.isNotEmpty(menu.getComponent()) && !isMeunFrame(menu)) {
component = menu.getComponent();
}
else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
{
} else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) {
component = UserConstants.PARENT_VIEW;
}
return component;
@@ -373,43 +332,38 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 是否为菜单内部跳转
*
*
* @param menu 菜单信息
* @return 结果
*/
public boolean isMeunFrame(SysMenu menu)
{
public boolean isMeunFrame(SysMenu menu) {
return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
}
/**
* 是否为parent_view组件
*
*
* @param menu 菜单信息
* @return 结果
*/
public boolean isParentView(SysMenu menu)
{
public boolean isParentView(SysMenu menu) {
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
}
/**
* 根据父节点的ID获取所有子节点
*
* @param list 分类表
*
* @param list 分类表
* @param parentId 传入的父节点ID
* @return String
*/
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
{
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
List<SysMenu> returnList = new ArrayList<SysMenu>();
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
{
for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
SysMenu t = (SysMenu) iterator.next();
// 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
if (t.getParentId() == parentId)
{
if (t.getParentId() == parentId) {
recursionFn(list, t);
returnList.add(t);
}
@@ -419,19 +373,16 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 递归列表
*
*
* @param list
* @param t
*/
private void recursionFn(List<SysMenu> list, SysMenu t)
{
private void recursionFn(List<SysMenu> list, SysMenu t) {
// 得到子节点列表
List<SysMenu> childList = getChildList(list, t);
t.setChildren(childList);
for (SysMenu tChild : childList)
{
if (hasChild(list, tChild))
{
for (SysMenu tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
@@ -440,15 +391,12 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 得到子节点列表
*/
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
{
private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
List<SysMenu> tlist = new ArrayList<SysMenu>();
Iterator<SysMenu> it = list.iterator();
while (it.hasNext())
{
while (it.hasNext()) {
SysMenu n = (SysMenu) it.next();
if (n.getParentId().longValue() == t.getMenuId().longValue())
{
if (n.getParentId().longValue() == t.getMenuId().longValue()) {
tlist.add(n);
}
}
@@ -458,8 +406,7 @@ public class SysMenuServiceImpl implements ISysMenuService
/**
* 判断是否有子节点
*/
private boolean hasChild(List<SysMenu> list, SysMenu t)
{
private boolean hasChild(List<SysMenu> list, SysMenu t) {
return getChildList(list, t).size() > 0 ? true : false;
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysNotice;
@@ -9,84 +10,77 @@ import com.ruoyi.system.service.ISysNoticeService;
/**
* 公告 服务层实现
*
*
* @author ruoyi
*/
@Service
public class SysNoticeServiceImpl implements ISysNoticeService
{
public class SysNoticeServiceImpl implements ISysNoticeService {
@Autowired
private SysNoticeMapper noticeMapper;
/**
* 查询公告信息
*
*
* @param noticeId 公告ID
* @return 公告信息
*/
@Override
public SysNotice selectNoticeById(Long noticeId)
{
public SysNotice selectNoticeById(Long noticeId) {
return noticeMapper.selectNoticeById(noticeId);
}
/**
* 查询公告列表
*
*
* @param notice 公告信息
* @return 公告集合
*/
@Override
public List<SysNotice> selectNoticeList(SysNotice notice)
{
public List<SysNotice> selectNoticeList(SysNotice notice) {
return noticeMapper.selectNoticeList(notice);
}
/**
* 新增公告
*
*
* @param notice 公告信息
* @return 结果
*/
@Override
public int insertNotice(SysNotice notice)
{
public int insertNotice(SysNotice notice) {
return noticeMapper.insertNotice(notice);
}
/**
* 修改公告
*
*
* @param notice 公告信息
* @return 结果
*/
@Override
public int updateNotice(SysNotice notice)
{
public int updateNotice(SysNotice notice) {
return noticeMapper.updateNotice(notice);
}
/**
* 删除公告对象
*
*
* @param noticeId 公告ID
* @return 结果
*/
@Override
public int deleteNoticeById(Long noticeId)
{
public int deleteNoticeById(Long noticeId) {
return noticeMapper.deleteNoticeById(noticeId);
}
/**
* 批量删除公告信息
*
*
* @param noticeIds 需要删除的公告ID
* @return 结果
*/
@Override
public int deleteNoticeByIds(Long[] noticeIds)
{
public int deleteNoticeByIds(Long[] noticeIds) {
return noticeMapper.deleteNoticeByIds(noticeIds);
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysOperLog;
@@ -9,59 +10,54 @@ import com.ruoyi.system.service.ISysOperLogService;
/**
* 操作日志 服务层处理
*
*
* @author ruoyi
*/
@Service
public class SysOperLogServiceImpl implements ISysOperLogService
{
public class SysOperLogServiceImpl implements ISysOperLogService {
@Autowired
private SysOperLogMapper operLogMapper;
/**
* 新增操作日志
*
*
* @param operLog 操作日志对象
*/
@Override
public void insertOperlog(SysOperLog operLog)
{
public void insertOperlog(SysOperLog operLog) {
operLogMapper.insertOperlog(operLog);
}
/**
* 查询系统操作日志集合
*
*
* @param operLog 操作日志对象
* @return 操作日志集合
*/
@Override
public List<SysOperLog> selectOperLogList(SysOperLog operLog)
{
public List<SysOperLog> selectOperLogList(SysOperLog operLog) {
return operLogMapper.selectOperLogList(operLog);
}
/**
* 批量删除系统操作日志
*
*
* @param operIds 需要删除的操作日志ID
* @return 结果
*/
@Override
public int deleteOperLogByIds(Long[] operIds)
{
public int deleteOperLogByIds(Long[] operIds) {
return operLogMapper.deleteOperLogByIds(operIds);
}
/**
* 查询操作日志详细
*
*
* @param operId 操作ID
* @return 操作日志对象
*/
@Override
public SysOperLog selectOperLogById(Long operId)
{
public SysOperLog selectOperLogById(Long operId) {
return operLogMapper.selectOperLogById(operId);
}
@@ -69,8 +65,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
* 清空操作日志
*/
@Override
public void cleanOperLog()
{
public void cleanOperLog() {
operLogMapper.cleanOperLog();
}
}

View File

@@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
@@ -13,12 +14,11 @@ import com.ruoyi.system.service.ISysPostService;
/**
* 岗位信息 服务层处理
*
*
* @author ruoyi
*/
@Service
public class SysPostServiceImpl implements ISysPostService
{
public class SysPostServiceImpl implements ISysPostService {
@Autowired
private SysPostMapper postMapper;
@@ -27,64 +27,58 @@ public class SysPostServiceImpl implements ISysPostService
/**
* 查询岗位信息集合
*
*
* @param post 岗位信息
* @return 岗位信息集合
*/
@Override
public List<SysPost> selectPostList(SysPost post)
{
public List<SysPost> selectPostList(SysPost post) {
return postMapper.selectPostList(post);
}
/**
* 查询所有岗位
*
*
* @return 岗位列表
*/
@Override
public List<SysPost> selectPostAll()
{
public List<SysPost> selectPostAll() {
return postMapper.selectPostAll();
}
/**
* 通过岗位ID查询岗位信息
*
*
* @param postId 岗位ID
* @return 角色对象信息
*/
@Override
public SysPost selectPostById(Long postId)
{
public SysPost selectPostById(Long postId) {
return postMapper.selectPostById(postId);
}
/**
* 根据用户ID获取岗位选择框列表
*
*
* @param userId 用户ID
* @return 选中岗位ID列表
*/
@Override
public List<Integer> selectPostListByUserId(Long userId)
{
public List<Integer> selectPostListByUserId(Long userId) {
return postMapper.selectPostListByUserId(userId);
}
/**
* 校验岗位名称是否唯一
*
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostNameUnique(SysPost post)
{
public String checkPostNameUnique(SysPost post) {
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostNameUnique(post.getPostName());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -92,17 +86,15 @@ public class SysPostServiceImpl implements ISysPostService
/**
* 校验岗位编码是否唯一
*
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostCodeUnique(SysPost post)
{
public String checkPostCodeUnique(SysPost post) {
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
SysPost info = postMapper.checkPostCodeUnique(post.getPostCode());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -110,43 +102,38 @@ public class SysPostServiceImpl implements ISysPostService
/**
* 通过岗位ID查询岗位使用数量
*
*
* @param postId 岗位ID
* @return 结果
*/
@Override
public int countUserPostById(Long postId)
{
public int countUserPostById(Long postId) {
return userPostMapper.countUserPostById(postId);
}
/**
* 删除岗位信息
*
*
* @param postId 岗位ID
* @return 结果
*/
@Override
public int deletePostById(Long postId)
{
public int deletePostById(Long postId) {
return postMapper.deletePostById(postId);
}
/**
* 批量删除岗位信息
*
*
* @param postIds 需要删除的岗位ID
* @return 结果
* @throws Exception 异常
*/
@Override
public int deletePostByIds(Long[] postIds)
{
for (Long postId : postIds)
{
public int deletePostByIds(Long[] postIds) {
for (Long postId : postIds) {
SysPost post = selectPostById(postId);
if (countUserPostById(postId) > 0)
{
if (countUserPostById(postId) > 0) {
throw new CustomException(String.format("%1$s已分配,不能删除", post.getPostName()));
}
}
@@ -155,25 +142,23 @@ public class SysPostServiceImpl implements ISysPostService
/**
* 新增保存岗位信息
*
*
* @param post 岗位信息
* @return 结果
*/
@Override
public int insertPost(SysPost post)
{
public int insertPost(SysPost post) {
return postMapper.insertPost(post);
}
/**
* 修改保存岗位信息
*
*
* @param post 岗位信息
* @return 结果
*/
@Override
public int updatePost(SysPost post)
{
public int updatePost(SysPost post) {
return postMapper.updatePost(post);
}
}

View File

@@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -24,12 +25,11 @@ import com.ruoyi.system.service.ISysRoleService;
/**
* 角色 业务层处理
*
*
* @author ruoyi
*/
@Service
public class SysRoleServiceImpl implements ISysRoleService
{
public class SysRoleServiceImpl implements ISysRoleService {
@Autowired
private SysRoleMapper roleMapper;
@@ -44,32 +44,28 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 根据条件分页查询角色数据
*
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
@DataScope(deptAlias = "d")
public List<SysRole> selectRoleList(SysRole role)
{
public List<SysRole> selectRoleList(SysRole role) {
return roleMapper.selectRoleList(role);
}
/**
* 根据用户ID查询权限
*
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectRolePermissionByUserId(Long userId)
{
public Set<String> selectRolePermissionByUserId(Long userId) {
List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (SysRole perm : perms)
{
if (StringUtils.isNotNull(perm))
{
for (SysRole perm : perms) {
if (StringUtils.isNotNull(perm)) {
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
@@ -78,52 +74,47 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 查询所有角色
*
*
* @return 角色列表
*/
@Override
public List<SysRole> selectRoleAll()
{
public List<SysRole> selectRoleAll() {
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
}
/**
* 根据用户ID获取角色选择框列表
*
*
* @param userId 用户ID
* @return 选中角色ID列表
*/
@Override
public List<Integer> selectRoleListByUserId(Long userId)
{
public List<Integer> selectRoleListByUserId(Long userId) {
return roleMapper.selectRoleListByUserId(userId);
}
/**
* 通过角色ID查询角色
*
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public SysRole selectRoleById(Long roleId)
{
public SysRole selectRoleById(Long roleId) {
return roleMapper.selectRoleById(roleId);
}
/**
* 校验角色名称是否唯一
*
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleNameUnique(SysRole role)
{
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())
{
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -131,17 +122,15 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 校验角色权限是否唯一
*
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleKeyUnique(SysRole role)
{
public String checkRoleKeyUnique(SysRole role) {
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -149,40 +138,36 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 校验角色是否允许操作
*
*
* @param role 角色信息
*/
@Override
public void checkRoleAllowed(SysRole role)
{
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
{
public void checkRoleAllowed(SysRole role) {
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) {
throw new CustomException("不允许操作超级管理员角色");
}
}
/**
* 通过角色ID查询角色使用数量
*
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public int countUserRoleByRoleId(Long roleId)
{
public int countUserRoleByRoleId(Long roleId) {
return userRoleMapper.countUserRoleByRoleId(roleId);
}
/**
* 新增保存角色信息
*
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int insertRole(SysRole role)
{
public int insertRole(SysRole role) {
// 新增角色信息
roleMapper.insertRole(role);
return insertRoleMenu(role);
@@ -190,14 +175,13 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 修改保存角色信息
*
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int updateRole(SysRole role)
{
public int updateRole(SysRole role) {
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与菜单关联
@@ -207,26 +191,24 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 修改角色状态
*
*
* @param role 角色信息
* @return 结果
*/
@Override
public int updateRoleStatus(SysRole role)
{
public int updateRoleStatus(SysRole role) {
return roleMapper.updateRole(role);
}
/**
* 修改数据权限信息
*
*
* @param role 角色信息
* @return 结果
*/
@Override
@Transactional
public int authDataScope(SysRole role)
{
public int authDataScope(SysRole role) {
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与部门关联
@@ -237,23 +219,20 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 新增角色菜单信息
*
*
* @param role 角色对象
*/
public int insertRoleMenu(SysRole role)
{
public int insertRoleMenu(SysRole role) {
int rows = 1;
// 新增用户与角色管理
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
for (Long menuId : role.getMenuIds())
{
for (Long menuId : role.getMenuIds()) {
SysRoleMenu rm = new SysRoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0)
{
if (list.size() > 0) {
rows = roleMenuMapper.batchRoleMenu(list);
}
return rows;
@@ -264,20 +243,17 @@ public class SysRoleServiceImpl implements ISysRoleService
*
* @param role 角色对象
*/
public int insertRoleDept(SysRole role)
{
public int insertRoleDept(SysRole role) {
int rows = 1;
// 新增角色与部门(数据权限)管理
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
for (Long deptId : role.getDeptIds())
{
for (Long deptId : role.getDeptIds()) {
SysRoleDept rd = new SysRoleDept();
rd.setRoleId(role.getRoleId());
rd.setDeptId(deptId);
list.add(rd);
}
if (list.size() > 0)
{
if (list.size() > 0) {
rows = roleDeptMapper.batchRoleDept(list);
}
return rows;
@@ -285,14 +261,13 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 通过角色ID删除角色
*
*
* @param roleId 角色ID
* @return 结果
*/
@Override
@Transactional
public int deleteRoleById(Long roleId)
{
public int deleteRoleById(Long roleId) {
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
// 删除角色与部门关联
@@ -302,20 +277,17 @@ public class SysRoleServiceImpl implements ISysRoleService
/**
* 批量删除角色信息
*
*
* @param roleIds 需要删除的角色ID
* @return 结果
*/
@Override
@Transactional
public int deleteRoleByIds(Long[] roleIds)
{
for (Long roleId : roleIds)
{
public int deleteRoleByIds(Long[] roleIds) {
for (Long roleId : roleIds) {
checkRoleAllowed(new SysRole(roleId));
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0)
{
if (countUserRoleByRoleId(roleId) > 0) {
throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}

View File

@@ -8,24 +8,21 @@ import com.ruoyi.system.service.ISysUserOnlineService;
/**
* 在线用户 服务层处理
*
*
* @author ruoyi
*/
@Service
public class SysUserOnlineServiceImpl implements ISysUserOnlineService
{
public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
/**
* 通过登录地址查询信息
*
*
* @param ipaddr 登录地址
* @param user 用户信息
* @param user 用户信息
* @return 在线用户信息
*/
@Override
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user)
{
if (StringUtils.equals(ipaddr, user.getIpaddr()))
{
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) {
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
return loginUserToUserOnline(user);
}
return null;
@@ -33,16 +30,14 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
/**
* 通过用户名称查询信息
*
*
* @param userName 用户名称
* @param user 用户信息
* @param user 用户信息
* @return 在线用户信息
*/
@Override
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user)
{
if (StringUtils.equals(userName, user.getUsername()))
{
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) {
if (StringUtils.equals(userName, user.getUsername())) {
return loginUserToUserOnline(user);
}
return null;
@@ -50,17 +45,15 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
/**
* 通过登录地址/用户名称查询信息
*
* @param ipaddr 登录地址
*
* @param ipaddr 登录地址
* @param userName 用户名称
* @param user 用户信息
* @param user 用户信息
* @return 在线用户信息
*/
@Override
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user)
{
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
{
public SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user) {
if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) {
return loginUserToUserOnline(user);
}
return null;
@@ -68,15 +61,13 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
/**
* 设置在线用户信息
*
*
* @param user 用户信息
* @return 在线用户
*/
@Override
public SysUserOnline loginUserToUserOnline(LoginUser user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser()))
{
public SysUserOnline loginUserToUserOnline(LoginUser user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUser())) {
return null;
}
SysUserOnline sysUserOnline = new SysUserOnline();
@@ -87,8 +78,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
sysUserOnline.setBrowser(user.getBrowser());
sysUserOnline.setOs(user.getOs());
sysUserOnline.setLoginTime(user.getLoginTime());
if (StringUtils.isNotNull(user.getUser().getDept()))
{
if (StringUtils.isNotNull(user.getUser().getDept())) {
sysUserOnline.setDeptName(user.getUser().getDept().getDeptName());
}
return sysUserOnline;

View File

@@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,12 +28,11 @@ import com.ruoyi.system.service.ISysUserService;
/**
* 用户 业务层处理
*
*
* @author ruoyi
*/
@Service
public class SysUserServiceImpl implements ISysUserService
{
public class SysUserServiceImpl implements ISysUserService {
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
@Autowired
@@ -55,58 +55,57 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 根据条件分页查询用户列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectUserList(SysUser user)
{
public List<SysUser> selectUserList(SysUser user) {
return userMapper.selectUserList(user);
}
/**
* 通过用户名查询用户
*
*
* @param userName 用户名
* @return 用户对象信息
*/
@Override
public SysUser selectUserByUserName(String userName)
{
public SysUser selectUserByUserName(String userName) {
return userMapper.selectUserByUserName(userName);
}
@Override
public SysUser selectUserByOpenId(String openId) {
return userMapper.selectUserByOpenId(openId);
}
/**
* 通过用户ID查询用户
*
*
* @param userId 用户ID
* @return 用户对象信息
*/
@Override
public SysUser selectUserById(Long userId)
{
public SysUser selectUserById(Long userId) {
return userMapper.selectUserById(userId);
}
/**
* 查询用户所属角色组
*
*
* @param userName 用户名
* @return 结果
*/
@Override
public String selectUserRoleGroup(String userName)
{
public String selectUserRoleGroup(String userName) {
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
StringBuffer idsStr = new StringBuffer();
for (SysRole role : list)
{
for (SysRole role : list) {
idsStr.append(role.getRoleName()).append(",");
}
if (StringUtils.isNotEmpty(idsStr.toString()))
{
if (StringUtils.isNotEmpty(idsStr.toString())) {
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
@@ -114,21 +113,18 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 查询用户所属岗位组
*
*
* @param userName 用户名
* @return 结果
*/
@Override
public String selectUserPostGroup(String userName)
{
public String selectUserPostGroup(String userName) {
List<SysPost> list = postMapper.selectPostsByUserName(userName);
StringBuffer idsStr = new StringBuffer();
for (SysPost post : list)
{
for (SysPost post : list) {
idsStr.append(post.getPostName()).append(",");
}
if (StringUtils.isNotEmpty(idsStr.toString()))
{
if (StringUtils.isNotEmpty(idsStr.toString())) {
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
@@ -136,16 +132,14 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 校验用户名称是否唯一
*
*
* @param userName 用户名称
* @return 结果
*/
@Override
public String checkUserNameUnique(String userName)
{
public String checkUserNameUnique(String userName) {
int count = userMapper.checkUserNameUnique(userName);
if (count > 0)
{
if (count > 0) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -158,12 +152,10 @@ public class SysUserServiceImpl implements ISysUserService
* @return
*/
@Override
public String checkPhoneUnique(SysUser user)
{
public String checkPhoneUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -176,12 +168,10 @@ public class SysUserServiceImpl implements ISysUserService
* @return
*/
@Override
public String checkEmailUnique(SysUser user)
{
public String checkEmailUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
SysUser info = userMapper.checkEmailUnique(user.getEmail());
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
{
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -189,28 +179,25 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 校验用户是否允许操作
*
*
* @param user 用户信息
*/
@Override
public void checkUserAllowed(SysUser user)
{
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
{
public void checkUserAllowed(SysUser user) {
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
throw new CustomException("不允许操作超级管理员用户");
}
}
/**
* 新增保存用户信息
*
*
* @param user 用户信息
* @return 结果
*/
@Override
@Transactional
public int insertUser(SysUser user)
{
public int insertUser(SysUser user) {
// 新增用户信息
int rows = userMapper.insertUser(user);
// 新增用户岗位关联
@@ -222,14 +209,13 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改保存用户信息
*
*
* @param user 用户信息
* @return 结果
*/
@Override
@Transactional
public int updateUser(SysUser user)
{
public int updateUser(SysUser user) {
Long userId = user.getUserId();
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId(userId);
@@ -244,87 +230,78 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改用户状态
*
*
* @param user 用户信息
* @return 结果
*/
@Override
public int updateUserStatus(SysUser user)
{
public int updateUserStatus(SysUser user) {
return userMapper.updateUser(user);
}
/**
* 修改用户基本信息
*
*
* @param user 用户信息
* @return 结果
*/
@Override
public int updateUserProfile(SysUser user)
{
public int updateUserProfile(SysUser user) {
return userMapper.updateUser(user);
}
/**
* 修改用户头像
*
*
* @param userName 用户名
* @param avatar 头像地址
* @param avatar 头像地址
* @return 结果
*/
@Override
public boolean updateUserAvatar(String userName, String avatar)
{
public boolean updateUserAvatar(String userName, String avatar) {
return userMapper.updateUserAvatar(userName, avatar) > 0;
}
/**
* 重置用户密码
*
*
* @param user 用户信息
* @return 结果
*/
@Override
public int resetPwd(SysUser user)
{
public int resetPwd(SysUser user) {
return userMapper.updateUser(user);
}
/**
* 重置用户密码
*
*
* @param userName 用户名
* @param password 密码
* @return 结果
*/
@Override
public int resetUserPwd(String userName, String password)
{
public int resetUserPwd(String userName, String password) {
return userMapper.resetUserPwd(userName, password);
}
/**
* 新增用户角色信息
*
*
* @param user 用户对象
*/
public void insertUserRole(SysUser user)
{
public void insertUserRole(SysUser user) {
Long[] roles = user.getRoleIds();
if (StringUtils.isNotNull(roles))
{
if (StringUtils.isNotNull(roles)) {
// 新增用户与角色管理
List<SysUserRole> list = new ArrayList<SysUserRole>();
for (Long roleId : roles)
{
for (Long roleId : roles) {
SysUserRole ur = new SysUserRole();
ur.setUserId(user.getUserId());
ur.setRoleId(roleId);
list.add(ur);
}
if (list.size() > 0)
{
if (list.size() > 0) {
userRoleMapper.batchUserRole(list);
}
}
@@ -332,25 +309,21 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 新增用户岗位信息
*
*
* @param user 用户对象
*/
public void insertUserPost(SysUser user)
{
public void insertUserPost(SysUser user) {
Long[] posts = user.getPostIds();
if (StringUtils.isNotNull(posts))
{
if (StringUtils.isNotNull(posts)) {
// 新增用户与岗位管理
List<SysUserPost> list = new ArrayList<SysUserPost>();
for (Long postId : posts)
{
for (Long postId : posts) {
SysUserPost up = new SysUserPost();
up.setUserId(user.getUserId());
up.setPostId(postId);
list.add(up);
}
if (list.size() > 0)
{
if (list.size() > 0) {
userPostMapper.batchUserPost(list);
}
}
@@ -358,14 +331,13 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 通过用户ID删除用户
*
*
* @param userId 用户ID
* @return 结果
*/
@Override
@Transactional
public int deleteUserById(Long userId)
{
public int deleteUserById(Long userId) {
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId(userId);
// 删除用户与岗位表
@@ -375,16 +347,14 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 批量删除用户信息
*
*
* @param userIds 需要删除的用户ID
* @return 结果
*/
@Override
@Transactional
public int deleteUserByIds(Long[] userIds)
{
for (Long userId : userIds)
{
public int deleteUserByIds(Long[] userIds) {
for (Long userId : userIds) {
checkUserAllowed(new SysUser(userId));
}
// 删除用户与角色关联
@@ -396,17 +366,15 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 导入用户数据
*
* @param userList 用户数据列表
*
* @param userList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
* @param operName 操作用户
* @return 结果
*/
@Override
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
{
if (StringUtils.isNull(userList) || userList.size() == 0)
{
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
if (StringUtils.isNull(userList) || userList.size() == 0) {
throw new CustomException("导入用户数据不能为空!");
}
int successNum = 0;
@@ -414,48 +382,36 @@ public class SysUserServiceImpl implements ISysUserService
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
String password = configService.selectConfigByKey("sys.user.initPassword");
for (SysUser user : userList)
{
try
{
for (SysUser user : userList) {
try {
// 验证是否存在这个用户
SysUser u = userMapper.selectUserByUserName(user.getUserName());
if (StringUtils.isNull(u))
{
if (StringUtils.isNull(u)) {
user.setPassword(SecurityUtils.encryptPassword(password));
user.setCreateBy(operName);
this.insertUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
}
else if (isUpdateSupport)
{
} else if (isUpdateSupport) {
user.setUpdateBy(operName);
this.updateUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
}
else
{
} else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
}
}
catch (Exception e)
{
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0)
{
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new CustomException(failureMsg.toString());
}
else
{
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();

View File

@@ -0,0 +1,87 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TUserAccountInfoMapper;
import com.ruoyi.system.domain.TUserAccountInfo;
import com.ruoyi.system.service.ITUserAccountInfoService;
/**
* 小程序用户Service业务层处理
*
* @author wxy
* @date 2021-08-26
*/
@Service
public class TUserAccountInfoServiceImpl implements ITUserAccountInfoService {
@Autowired
private TUserAccountInfoMapper tUserAccountInfoMapper;
/**
* 查询小程序用户
*
* @param id 小程序用户ID
* @return 小程序用户
*/
@Override
public TUserAccountInfo selectTUserAccountInfoById(Long id) {
return tUserAccountInfoMapper.selectTUserAccountInfoById(id);
}
/**
* 查询小程序用户列表
*
* @param tUserAccountInfo 小程序用户
* @return 小程序用户
*/
@Override
public List<TUserAccountInfo> selectTUserAccountInfoList(TUserAccountInfo tUserAccountInfo) {
return tUserAccountInfoMapper.selectTUserAccountInfoList(tUserAccountInfo);
}
/**
* 新增小程序用户
*
* @param tUserAccountInfo 小程序用户
* @return 结果
*/
@Override
public int insertTUserAccountInfo(TUserAccountInfo tUserAccountInfo) {
return tUserAccountInfoMapper.insertTUserAccountInfo(tUserAccountInfo);
}
/**
* 修改小程序用户
*
* @param tUserAccountInfo 小程序用户
* @return 结果
*/
@Override
public int updateTUserAccountInfo(TUserAccountInfo tUserAccountInfo) {
return tUserAccountInfoMapper.updateTUserAccountInfo(tUserAccountInfo);
}
/**
* 批量删除小程序用户
*
* @param ids 需要删除的小程序用户ID
* @return 结果
*/
@Override
public int deleteTUserAccountInfoByIds(Long[] ids) {
return tUserAccountInfoMapper.deleteTUserAccountInfoByIds(ids);
}
/**
* 删除小程序用户信息
*
* @param id 小程序用户ID
* @return 结果
*/
@Override
public int deleteTUserAccountInfoById(Long id) {
return tUserAccountInfoMapper.deleteTUserAccountInfoById(id);
}
}

View File

@@ -0,0 +1,87 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TUserLoginLogMapper;
import com.ruoyi.system.domain.TUserLoginLog;
import com.ruoyi.system.service.ITUserLoginLogService;
/**
* 【请填写功能名称】Service业务层处理
*
* @author wxy
* @date 2021-08-26
*/
@Service
public class TUserLoginLogServiceImpl implements ITUserLoginLogService {
@Autowired
private TUserLoginLogMapper tUserLoginLogMapper;
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】ID
* @return 【请填写功能名称】
*/
@Override
public TUserLoginLog selectTUserLoginLogById(Long id) {
return tUserLoginLogMapper.selectTUserLoginLogById(id);
}
/**
* 查询【请填写功能名称】列表
*
* @param tUserLoginLog 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<TUserLoginLog> selectTUserLoginLogList(TUserLoginLog tUserLoginLog) {
return tUserLoginLogMapper.selectTUserLoginLogList(tUserLoginLog);
}
/**
* 新增【请填写功能名称】
*
* @param tUserLoginLog 【请填写功能名称】
* @return 结果
*/
@Override
public int insertTUserLoginLog(TUserLoginLog tUserLoginLog) {
return tUserLoginLogMapper.insertTUserLoginLog(tUserLoginLog);
}
/**
* 修改【请填写功能名称】
*
* @param tUserLoginLog 【请填写功能名称】
* @return 结果
*/
@Override
public int updateTUserLoginLog(TUserLoginLog tUserLoginLog) {
return tUserLoginLogMapper.updateTUserLoginLog(tUserLoginLog);
}
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】ID
* @return 结果
*/
@Override
public int deleteTUserLoginLogByIds(Long[] ids) {
return tUserLoginLogMapper.deleteTUserLoginLogByIds(ids);
}
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】ID
* @return 结果
*/
@Override
public int deleteTUserLoginLogById(Long id) {
return tUserLoginLogMapper.deleteTUserLoginLogById(id);
}
}