@@ -70,7 +70,7 @@ public class SysConfig extends BaseEntity {
|
||||
*/
|
||||
@ApiModelProperty(value = "系统内置(Y是 N否)")
|
||||
@ExcelProperty(value = "系统内置", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_yes_no")
|
||||
@ExcelDictFormat(dictType = "sys_yes_no")
|
||||
private String configType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SysOperLog implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty(value = "业务类型(0其它 1新增 2修改 3删除)")
|
||||
@ExcelProperty(value = "业务类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_oper_type")
|
||||
@ExcelDictFormat(dictType = "sys_oper_type")
|
||||
private Integer businessType;
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class SysOperLog implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty(value = "操作类别(0其它 1后台用户 2手机端用户)")
|
||||
@ExcelProperty(value = "操作类别", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户")
|
||||
@ExcelDictFormat(readConverterExp = "0=其它,1=后台用户,2=手机端用户")
|
||||
private Integer operatorType;
|
||||
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ public class SysOperLog implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty(value = "操作状态(0正常 1异常)")
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_common_status")
|
||||
@ExcelDictFormat(dictType = "sys_common_status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,35 +19,35 @@ import lombok.experimental.Accessors;
|
||||
@TableName("sys_oss")
|
||||
public class SysOss extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 对象存储主键
|
||||
*/
|
||||
@TableId(value = "oss_id", type = IdType.AUTO)
|
||||
private Long ossId;
|
||||
/**
|
||||
* 对象存储主键
|
||||
*/
|
||||
@TableId(value = "oss_id", type = IdType.AUTO)
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 原名
|
||||
*/
|
||||
private String originalName;
|
||||
/**
|
||||
* 原名
|
||||
*/
|
||||
private String originalName;
|
||||
|
||||
/**
|
||||
* 文件后缀名
|
||||
*/
|
||||
private String fileSuffix;
|
||||
/**
|
||||
* 文件后缀名
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* URL地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* URL地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 服务商
|
||||
*/
|
||||
private String service;
|
||||
/**
|
||||
* 服务商
|
||||
*/
|
||||
private String service;
|
||||
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class SysPost extends BaseEntity {
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_common_status")
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_common_status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -21,6 +23,7 @@ public class SysRoleDept {
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -21,6 +23,7 @@ public class SysRoleMenu {
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -21,6 +23,7 @@ public class SysUserPost {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -21,6 +23,7 @@ public class SysUserRole {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.excel.ExcelListener;
|
||||
import com.ruoyi.common.excel.ExcelResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.ValidatorUtils;
|
||||
@@ -44,7 +45,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
||||
this.userService = SpringUtils.getBean(ISysUserService.class);
|
||||
this.password = SecurityUtils.encryptPassword(initPassword);
|
||||
this.isUpdateSupport = isUpdateSupport;
|
||||
this.operName = SecurityUtils.getUsername();
|
||||
this.operName = LoginUtils.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysConfig;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysConfigMapper extends BaseMapperPlus<SysConfig> {
|
||||
public interface SysConfigMapper extends BaseMapperPlus<SysConfigMapper, SysConfig, SysConfig> {
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.ruoyi.system.mapper;
|
||||
import com.ruoyi.common.annotation.DataColumn;
|
||||
import com.ruoyi.common.annotation.DataPermission;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysDeptMapper extends BaseMapperPlus<SysDept> {
|
||||
public interface SysDeptMapper extends BaseMapperPlus<SysDeptMapper, SysDept, SysDept> {
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.ruoyi.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysDictDataMapper extends BaseMapperPlus<SysDictData> {
|
||||
public interface SysDictDataMapper extends BaseMapperPlus<SysDictDataMapper, SysDictData, SysDictData> {
|
||||
|
||||
default List<SysDictData> selectDictDataByType(String dictType) {
|
||||
return selectList(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 字典表 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysDictTypeMapper extends BaseMapperPlus<SysDictType> {
|
||||
public interface SysDictTypeMapper extends BaseMapperPlus<SysDictTypeMapper, SysDictType, SysDictType> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
* @author XuanXuan Xuan
|
||||
* @date 2021-03-30
|
||||
*/
|
||||
public interface SysFormMapper extends BaseMapperPlus<SysForm> {
|
||||
public interface SysFormMapper extends BaseMapperPlus<SysFormMapper, SysForm, SysForm> {
|
||||
/**
|
||||
* 查询流程表单
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysLogininfor;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysLogininfor;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysLogininforMapper extends BaseMapperPlus<SysLogininfor> {
|
||||
public interface SysLogininforMapper extends BaseMapperPlus<SysLogininforMapper, SysLogininfor, SysLogininfor> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysMenuMapper extends BaseMapperPlus<SysMenu> {
|
||||
public interface SysMenuMapper extends BaseMapperPlus<SysMenuMapper, SysMenu, SysMenu> {
|
||||
|
||||
/**
|
||||
* 根据用户所有权限
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysNotice;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysNotice;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysNoticeMapper extends BaseMapperPlus<SysNotice> {
|
||||
public interface SysNoticeMapper extends BaseMapperPlus<SysNoticeMapper, SysNotice, SysNotice> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysOperLog;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysOperLog;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysOperLogMapper extends BaseMapperPlus<SysOperLog> {
|
||||
public interface SysOperLogMapper extends BaseMapperPlus<SysOperLogMapper, SysOperLog, SysOperLog> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysOssConfig;
|
||||
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
||||
|
||||
/**
|
||||
* 对象存储配置Mapper接口
|
||||
@@ -10,6 +11,6 @@ import com.ruoyi.system.domain.SysOssConfig;
|
||||
* @author 孤舟烟雨
|
||||
* @date 2021-08-13
|
||||
*/
|
||||
public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfig> {
|
||||
public interface SysOssConfigMapper extends BaseMapperPlus<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysOss;
|
||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
|
||||
/**
|
||||
* 文件上传 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysOssMapper extends BaseMapperPlus<SysOss> {
|
||||
public interface SysOssMapper extends BaseMapperPlus<SysOssMapper, SysOss, SysOssVo> {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysPostMapper extends BaseMapperPlus<SysPost> {
|
||||
public interface SysPostMapper extends BaseMapperPlus<SysPostMapper, SysPost, SysPost> {
|
||||
|
||||
/**
|
||||
* 根据用户ID获取岗位选择框列表
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysRoleDept;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysRoleDept;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDept> {
|
||||
public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDeptMapper, SysRoleDept, SysRoleDept> {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.DataColumn;
|
||||
import com.ruoyi.common.annotation.DataPermission;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapperPlus<SysRole> {
|
||||
public interface SysRoleMapper extends BaseMapperPlus<SysRoleMapper, SysRole, SysRole> {
|
||||
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysRoleMenu;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysRoleMenu;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu> {
|
||||
public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenuMapper, SysRoleMenu, SysRoleMenu> {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.annotation.DataColumn;
|
||||
import com.ruoyi.common.annotation.DataPermission;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapperPlus<SysUser> {
|
||||
public interface SysUserMapper extends BaseMapperPlus<SysUserMapper, SysUser, SysUser> {
|
||||
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysUserPost;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysUserPost;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysUserPostMapper extends BaseMapperPlus<SysUserPost> {
|
||||
public interface SysUserPostMapper extends BaseMapperPlus<SysUserPostMapper, SysUserPost, SysUserPost> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
|
||||
/**
|
||||
@@ -8,6 +8,6 @@ import com.ruoyi.system.domain.SysUserRole;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole> {
|
||||
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRoleMapper, SysUserRole, SysUserRole> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysConfigService extends IService<SysConfig> {
|
||||
public interface ISysConfigService {
|
||||
|
||||
|
||||
TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery);
|
||||
@@ -94,4 +93,7 @@ public interface ISysConfigService extends IService<SysConfig> {
|
||||
* @return 结果
|
||||
*/
|
||||
String checkConfigKeyUnique(SysConfig config);
|
||||
|
||||
SysConfig getOne(SysConfig config);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,7 +10,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysDeptService extends IService<SysDept> {
|
||||
public interface ISysDeptService {
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysDictDataService extends IService<SysDictData> {
|
||||
public interface ISysDictDataService {
|
||||
|
||||
|
||||
TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||
@@ -13,7 +12,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysDictTypeService extends IService<SysDictType> {
|
||||
public interface ISysDictTypeService {
|
||||
|
||||
|
||||
TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysLogininfor;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysLogininforService extends IService<SysLogininfor> {
|
||||
public interface ISysLogininforService {
|
||||
|
||||
|
||||
TableDataInfo<SysLogininfor> selectPageLogininforList(SysLogininfor logininfor, PageQuery pageQuery);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
|
||||
@@ -13,7 +12,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysMenuService extends IService<SysMenu> {
|
||||
public interface ISysMenuService {
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysNotice;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysNoticeService extends IService<SysNotice> {
|
||||
public interface ISysNoticeService {
|
||||
|
||||
|
||||
TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysOperLog;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysOperLogService extends IService<SysOperLog> {
|
||||
public interface ISysOperLogService {
|
||||
|
||||
TableDataInfo<SysOperLog> selectPageOperLogList(SysOperLog operLog, PageQuery pageQuery);
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysOssConfig;
|
||||
import com.ruoyi.system.domain.bo.SysOssConfigBo;
|
||||
import com.ruoyi.system.domain.vo.SysOssConfigVo;
|
||||
|
||||
@@ -16,7 +14,7 @@ import java.util.Collection;
|
||||
* @author 孤舟烟雨
|
||||
* @date 2021-08-13
|
||||
*/
|
||||
public interface ISysOssConfigService extends IServicePlus<SysOssConfig, SysOssConfigVo> {
|
||||
public interface ISysOssConfigService {
|
||||
|
||||
/**
|
||||
* 初始化OSS配置
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysOss;
|
||||
import com.ruoyi.system.domain.bo.SysOssBo;
|
||||
@@ -15,11 +14,14 @@ import java.util.Collection;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysOssService extends IServicePlus<SysOss, SysOssVo> {
|
||||
public interface ISysOssService {
|
||||
|
||||
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery);
|
||||
|
||||
SysOss getById(Long ossId);
|
||||
|
||||
SysOss upload(MultipartFile file);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysPostService extends IService<SysPost> {
|
||||
public interface ISysPostService {
|
||||
|
||||
|
||||
TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -14,7 +13,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysRoleService extends IService<SysRole> {
|
||||
public interface ISysRoleService {
|
||||
|
||||
|
||||
TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery);
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.system.domain.SysUserOnline;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysUserOnlineService {
|
||||
/**
|
||||
* 通过登录地址查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名称查询信息
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
SysUserOnline selectOnlineByUserName(String userName, LoginUser user);
|
||||
|
||||
/**
|
||||
* 通过登录地址/用户名称查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
SysUserOnline selectOnlineByInfo(String ipaddr, String userName, LoginUser user);
|
||||
|
||||
/**
|
||||
* 设置在线用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 在线用户
|
||||
*/
|
||||
SysUserOnline loginUserToUserOnline(LoginUser user);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -13,7 +12,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface ISysUserService extends IService<SysUser>, UserService {
|
||||
public interface ISysUserService extends UserService {
|
||||
|
||||
|
||||
TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery);
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.service.LogininforService;
|
||||
import com.ruoyi.common.core.service.TokenService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.enums.DeviceType;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.enums.UserType;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.exception.user.UserException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.RedisUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -30,23 +26,15 @@ import java.util.concurrent.TimeUnit;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysLoginService {
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Resource
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private LogininforService asyncService;
|
||||
private final ISysUserService userService;
|
||||
private final ISysConfigService configService;
|
||||
private final LogininforService asyncService;
|
||||
private final SysPermissionService permissionService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
@@ -71,39 +59,49 @@ public class SysLoginService {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME), request);
|
||||
throw new UserException("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME);
|
||||
}
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try {
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||
} catch (Exception e) {
|
||||
if (e instanceof BadCredentialsException) {
|
||||
// 是否第一次
|
||||
errorNumber = ObjectUtil.isNull(errorNumber) ? 1 : errorNumber + 1;
|
||||
// 达到规定错误次数 则锁定登录
|
||||
if (errorNumber.equals(Constants.LOGIN_ERROR_NUMBER)) {
|
||||
RedisUtils.setCacheObject(Constants.LOGIN_ERROR + username, errorNumber, Constants.LOGIN_ERROR_LIMIT_TIME, TimeUnit.MINUTES);
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME), request);
|
||||
throw new UserException("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME);
|
||||
} else {
|
||||
// 未达到规定错误次数 则递增
|
||||
RedisUtils.setCacheObject(Constants.LOGIN_ERROR + username, errorNumber);
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", errorNumber), request);
|
||||
throw new UserException("user.password.retry.limit.count", errorNumber);
|
||||
}
|
||||
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
log.info("登录用户:{} 已被删除.", username);
|
||||
throw new UserException("user.password.delete", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
if (!SecurityUtils.matchesPassword(password, user.getPassword())) {
|
||||
// 是否第一次
|
||||
errorNumber = ObjectUtil.isNull(errorNumber) ? 1 : errorNumber + 1;
|
||||
// 达到规定错误次数 则锁定登录
|
||||
if (errorNumber.equals(Constants.LOGIN_ERROR_NUMBER)) {
|
||||
RedisUtils.setCacheObject(Constants.LOGIN_ERROR + username, errorNumber, Constants.LOGIN_ERROR_LIMIT_TIME, TimeUnit.MINUTES);
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME), request);
|
||||
throw new UserException("user.password.retry.limit.exceed", Constants.LOGIN_ERROR_LIMIT_TIME);
|
||||
} else {
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage(), request);
|
||||
throw new ServiceException(e.getMessage());
|
||||
// 未达到规定错误次数 则递增
|
||||
RedisUtils.setCacheObject(Constants.LOGIN_ERROR + username, errorNumber);
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.retry.limit.count", errorNumber), request);
|
||||
throw new UserException("user.password.retry.limit.count", errorNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// 登录成功 清空错误次数
|
||||
RedisUtils.deleteObject(Constants.LOGIN_ERROR + username);
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
recordLoginInfo(loginUser.getUserId(), username);
|
||||
recordLoginInfo(user.getUserId(), username);
|
||||
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setDeptId(user.getDeptId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
loginUser.setMenuPermission(permissionService.getMenuPermission(user));
|
||||
loginUser.setRolePermission(permissionService.getRolePermission(user));
|
||||
|
||||
// 生成token
|
||||
return tokenService.createToken(loginUser);
|
||||
LoginUtils.loginByDevice(loginUser, UserType.SYS_USER, DeviceType.PC);
|
||||
return StpUtil.getTokenValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +110,6 @@ public class SysLoginService {
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
* @return 结果
|
||||
*/
|
||||
public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) {
|
||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -12,14 +12,12 @@ import java.util.Set;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysPermissionService {
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private ISysMenuService menuService;
|
||||
private final ISysRoleService roleService;
|
||||
private final ISysMenuService menuService;
|
||||
|
||||
/**
|
||||
* 获取角色数据权限
|
||||
|
||||
@@ -7,8 +7,12 @@ import com.ruoyi.common.core.domain.model.RegisterBody;
|
||||
import com.ruoyi.common.core.service.LogininforService;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -16,17 +20,13 @@ import org.springframework.stereotype.Service;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysRegisterService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private LogininforService asyncService;
|
||||
private final ISysUserService userService;
|
||||
private final ISysConfigService configService;
|
||||
private final LogininforService asyncService;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
|
||||
@@ -7,15 +7,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.ConfigService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.RedisUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
import com.ruoyi.system.mapper.SysConfigMapper;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -28,8 +28,11 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysConfig, SysConfig> implements ISysConfigService, ConfigService {
|
||||
public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
|
||||
private final SysConfigMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config, PageQuery pageQuery) {
|
||||
@@ -40,7 +43,7 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
|
||||
.like(StringUtils.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
Page<SysConfig> page = page(pageQuery.build(), lqw);
|
||||
Page<SysConfig> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -202,6 +205,11 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysConfig getOne(SysConfig config) {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<>(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数 key 获取参数值
|
||||
*
|
||||
|
||||
@@ -8,19 +8,18 @@ import com.ruoyi.system.domain.SysRoleDept;
|
||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleDeptMapper;
|
||||
import com.ruoyi.system.service.SysDataScopeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service("sdss")
|
||||
public class SysDataScopeServiceImpl implements SysDataScopeService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleDeptMapper roleDeptMapper;
|
||||
@Autowired
|
||||
private SysDeptMapper deptMapper;
|
||||
private final SysRoleDeptMapper roleDeptMapper;
|
||||
private final SysDeptMapper deptMapper;
|
||||
|
||||
@Override
|
||||
public String getRoleCustom(Long roleId) {
|
||||
|
||||
@@ -9,9 +9,8 @@ import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.TreeBuildUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@@ -19,7 +18,7 @@ import com.ruoyi.system.mapper.SysDeptMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -30,14 +29,13 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept, SysDept> implements ISysDeptService {
|
||||
public class SysDeptServiceImpl implements ISysDeptService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
private final SysDeptMapper baseMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
@@ -91,7 +89,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public SysDept selectDeptById(Long deptId) {
|
||||
return getById(deptId);
|
||||
return baseMapper.selectById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +100,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public long selectNormalChildrenDeptById(Long deptId) {
|
||||
return count(new LambdaQueryWrapper<SysDept>()
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getStatus, 0)
|
||||
.apply("find_in_set({0}, ancestors)", deptId));
|
||||
}
|
||||
@@ -115,9 +113,8 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByDeptId(Long deptId) {
|
||||
long result = count(new LambdaQueryWrapper<SysDept>()
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getParentId, deptId));
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,9 +125,8 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDeptExistUser(Long deptId) {
|
||||
long result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
|
||||
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getDeptId, deptId));
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,11 +138,11 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
@Override
|
||||
public String checkDeptNameUnique(SysDept dept) {
|
||||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||
long count = count(new LambdaQueryWrapper<SysDept>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(SysDept::getDeptName, dept.getDeptName())
|
||||
.eq(SysDept::getParentId, dept.getParentId())
|
||||
.ne(SysDept::getDeptId, deptId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -159,7 +155,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public void checkDeptDataScope(Long deptId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
SysDept dept = new SysDept();
|
||||
dept.setDeptId(deptId);
|
||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
@@ -177,7 +173,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public int insertDept(SysDept dept) {
|
||||
SysDept info = getById(dept.getParentId());
|
||||
SysDept info = baseMapper.selectById(dept.getParentId());
|
||||
// 如果父节点不为正常状态,则不允许新增子节点
|
||||
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
|
||||
throw new ServiceException("部门停用,不允许新增");
|
||||
@@ -194,8 +190,8 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
*/
|
||||
@Override
|
||||
public int updateDept(SysDept dept) {
|
||||
SysDept newParentDept = getById(dept.getParentId());
|
||||
SysDept oldDept = getById(dept.getDeptId());
|
||||
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
|
||||
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
@@ -219,7 +215,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
private void updateParentDeptStatusNormal(SysDept dept) {
|
||||
String ancestors = dept.getAncestors();
|
||||
Long[] deptIds = Convert.toLongArray(ancestors);
|
||||
update(null, new LambdaUpdateWrapper<SysDept>()
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
|
||||
.set(SysDept::getStatus, "0")
|
||||
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
|
||||
}
|
||||
@@ -232,7 +228,7 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
||||
* @param oldAncestors 旧的父ID集合
|
||||
*/
|
||||
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
|
||||
List<SysDept> children = list(new LambdaQueryWrapper<SysDept>()
|
||||
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
||||
.apply("find_in_set({0},ancestors)", deptId));
|
||||
for (SysDept child : children) {
|
||||
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
|
||||
|
||||
@@ -5,12 +5,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.RedisUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -20,8 +20,11 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, SysDictData, SysDictData> implements ISysDictDataService {
|
||||
public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
|
||||
private final SysDictDataMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) {
|
||||
@@ -30,7 +33,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||
.orderByAsc(SysDictData::getDictSort);
|
||||
Page<SysDictData> page = page(pageQuery.build(), lqw);
|
||||
Page<SysDictData> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -42,7 +45,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataList(SysDictData dictData) {
|
||||
return list(new LambdaQueryWrapper<SysDictData>()
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
|
||||
.like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
|
||||
.eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
|
||||
@@ -58,7 +61,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
||||
*/
|
||||
@Override
|
||||
public String selectDictLabel(String dictType, String dictValue) {
|
||||
return getOne(new LambdaQueryWrapper<SysDictData>()
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
|
||||
.select(SysDictData::getDictLabel)
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.eq(SysDictData::getDictValue, dictValue))
|
||||
@@ -73,7 +76,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
||||
*/
|
||||
@Override
|
||||
public SysDictData selectDictDataById(Long dictCode) {
|
||||
return getById(dictCode);
|
||||
return baseMapper.selectById(dictCode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +89,7 @@ public class SysDictDataServiceImpl extends ServicePlusImpl<SysDictDataMapper, S
|
||||
public void deleteDictDataByIds(Long[] dictCodes) {
|
||||
for (Long dictCode : dictCodes) {
|
||||
SysDictData data = selectDictDataById(dictCode);
|
||||
removeById(dictCode);
|
||||
baseMapper.deleteById(dictCode);
|
||||
List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType());
|
||||
RedisUtils.setCacheObject(getCacheKey(data.getDictType()), dictDatas);
|
||||
}
|
||||
|
||||
@@ -9,16 +9,15 @@ import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.DictService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.RedisUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -32,11 +31,12 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, SysDictType, SysDictType> implements ISysDictTypeService, DictService {
|
||||
public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService {
|
||||
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
private final SysDictTypeMapper baseMapper;
|
||||
private final SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery) {
|
||||
@@ -47,7 +47,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
.like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
Page<SysDictType> page = page(pageQuery.build(), lqw);
|
||||
Page<SysDictType> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeList(SysDictType dictType) {
|
||||
Map<String, Object> params = dictType.getParams();
|
||||
return list(new LambdaQueryWrapper<SysDictType>()
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysDictType>()
|
||||
.like(StringUtils.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName())
|
||||
.eq(StringUtils.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus())
|
||||
.like(StringUtils.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType())
|
||||
@@ -75,7 +75,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeAll() {
|
||||
return list();
|
||||
return baseMapper.selectList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeById(Long dictId) {
|
||||
return getById(dictId);
|
||||
return baseMapper.selectById(dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeByType(String dictType) {
|
||||
return getOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
||||
return baseMapper.selectById(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
*/
|
||||
@Override
|
||||
public void loadingDictCache() {
|
||||
List<SysDictType> dictTypeList = list();
|
||||
List<SysDictType> dictTypeList = baseMapper.selectList();
|
||||
for (SysDictType dictType : dictTypeList) {
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
|
||||
RedisUtils.setCacheObject(getCacheKey(dictType.getDictType()), dictDatas);
|
||||
@@ -193,7 +193,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateDictType(SysDictType dict) {
|
||||
SysDictType oldDict = getById(dict.getDictId());
|
||||
SysDictType oldDict = baseMapper.selectById(dict.getDictId());
|
||||
dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
|
||||
.set(SysDictData::getDictType, dict.getDictType())
|
||||
.eq(SysDictData::getDictType, oldDict.getDictType()));
|
||||
@@ -214,7 +214,7 @@ public class SysDictTypeServiceImpl extends ServicePlusImpl<SysDictTypeMapper, S
|
||||
@Override
|
||||
public String checkDictTypeUnique(SysDictType dict) {
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
long count = count(new LambdaQueryWrapper<SysDictType>()
|
||||
long count = baseMapper.selectCount(new LambdaQueryWrapper<SysDictType>()
|
||||
.eq(SysDictType::getDictType, dict.getDictType())
|
||||
.ne(SysDictType::getDictId, dictId));
|
||||
if (count > 0) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.LogininforService;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
@@ -15,6 +14,7 @@ import com.ruoyi.common.utils.ip.AddressUtils;
|
||||
import com.ruoyi.system.domain.SysLogininfor;
|
||||
import com.ruoyi.system.mapper.SysLogininforMapper;
|
||||
import com.ruoyi.system.service.ISysLogininforService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -30,9 +30,12 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMapper, SysLogininfor, SysLogininfor> implements ISysLogininforService, LogininforService {
|
||||
public class SysLogininforServiceImpl implements ISysLogininforService, LogininforService {
|
||||
|
||||
private final SysLogininforMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
@@ -99,7 +102,7 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
||||
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("info_id").setIsAsc("desc");
|
||||
}
|
||||
Page<SysLogininfor> page = page(pageQuery.build(), lqw);
|
||||
Page<SysLogininfor> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -111,7 +114,7 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
||||
@Override
|
||||
public void insertLogininfor(SysLogininfor logininfor) {
|
||||
logininfor.setLoginTime(new Date());
|
||||
save(logininfor);
|
||||
baseMapper.insert(logininfor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +126,7 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
||||
@Override
|
||||
public List<SysLogininfor> selectLogininforList(SysLogininfor logininfor) {
|
||||
Map<String, Object> params = logininfor.getParams();
|
||||
return list(new LambdaQueryWrapper<SysLogininfor>()
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysLogininfor>()
|
||||
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
|
||||
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
|
||||
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
|
||||
@@ -148,6 +151,6 @@ public class SysLogininforServiceImpl extends ServicePlusImpl<SysLogininforMappe
|
||||
*/
|
||||
@Override
|
||||
public void cleanLogininfor() {
|
||||
remove(new LambdaQueryWrapper<>());
|
||||
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.TreeBuildUtils;
|
||||
@@ -19,7 +18,7 @@ import com.ruoyi.system.mapper.SysMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
@@ -29,14 +28,13 @@ import java.util.*;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu, SysMenu> implements ISysMenuService {
|
||||
public class SysMenuServiceImpl implements ISysMenuService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMenuMapper roleMenuMapper;
|
||||
private final SysMenuMapper baseMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysRoleMenuMapper roleMenuMapper;
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
@@ -60,7 +58,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (SysUser.isAdmin(userId)) {
|
||||
menuList = list(new LambdaQueryWrapper<SysMenu>()
|
||||
menuList = baseMapper.selectList(new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
@@ -198,7 +196,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
*/
|
||||
@Override
|
||||
public SysMenu selectMenuById(Long menuId) {
|
||||
return getById(menuId);
|
||||
return baseMapper.selectById(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,8 +207,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
long result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
|
||||
return result > 0;
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,8 +218,7 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
*/
|
||||
@Override
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
long result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
|
||||
return result > 0;
|
||||
return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,11 +263,11 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
@Override
|
||||
public String checkMenuNameUnique(SysMenu menu) {
|
||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||
long count = count(new LambdaQueryWrapper<SysMenu>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenu::getParentId, menu.getParentId())
|
||||
.ne(SysMenu::getMenuId, menuId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -426,9 +422,8 @@ public class SysMenuServiceImpl extends ServicePlusImpl<SysMenuMapper, SysMenu,
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String innerLinkReplaceEach(String path)
|
||||
{
|
||||
return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS },
|
||||
new String[] { "", "" });
|
||||
public String innerLinkReplaceEach(String path) {
|
||||
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS},
|
||||
new String[]{"", ""});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.ruoyi.system.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysNotice;
|
||||
import com.ruoyi.system.mapper.SysNoticeMapper;
|
||||
import com.ruoyi.system.service.ISysNoticeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -19,8 +19,11 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNotice, SysNotice> implements ISysNoticeService {
|
||||
public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
|
||||
private final SysNoticeMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) {
|
||||
@@ -28,7 +31,7 @@ public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNo
|
||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
|
||||
Page<SysNotice> page = page(pageQuery.build(), lqw);
|
||||
Page<SysNotice> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -40,7 +43,7 @@ public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNo
|
||||
*/
|
||||
@Override
|
||||
public SysNotice selectNoticeById(Long noticeId) {
|
||||
return getById(noticeId);
|
||||
return baseMapper.selectById(noticeId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +54,7 @@ public class SysNoticeServiceImpl extends ServicePlusImpl<SysNoticeMapper, SysNo
|
||||
*/
|
||||
@Override
|
||||
public List<SysNotice> selectNoticeList(SysNotice notice) {
|
||||
return list(new LambdaQueryWrapper<SysNotice>()
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysNotice>()
|
||||
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
|
||||
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
|
||||
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.dto.OperLogDTO;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.OperLogService;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@@ -14,6 +13,7 @@ import com.ruoyi.common.utils.ip.AddressUtils;
|
||||
import com.ruoyi.system.domain.SysOperLog;
|
||||
import com.ruoyi.system.mapper.SysOperLogMapper;
|
||||
import com.ruoyi.system.service.ISysOperLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -27,8 +27,11 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, SysOperLog, SysOperLog> implements ISysOperLogService, OperLogService {
|
||||
public class SysOperLogServiceImpl implements ISysOperLogService, OperLogService {
|
||||
|
||||
private final SysOperLogMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
@@ -64,7 +67,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
||||
if(StringUtils.isBlank(pageQuery.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("oper_id").setIsAsc("desc");
|
||||
}
|
||||
Page<SysOperLog> page = page(pageQuery.build(), lqw);
|
||||
Page<SysOperLog> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -76,7 +79,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
||||
@Override
|
||||
public void insertOperlog(SysOperLog operLog) {
|
||||
operLog.setOperTime(new Date());
|
||||
save(operLog);
|
||||
baseMapper.insert(operLog);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +91,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
||||
@Override
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog) {
|
||||
Map<String, Object> params = operLog.getParams();
|
||||
return list(new LambdaQueryWrapper<SysOperLog>()
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysOperLog>()
|
||||
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
|
||||
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
|
||||
SysOperLog::getBusinessType, operLog.getBusinessType())
|
||||
@@ -124,7 +127,7 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
||||
*/
|
||||
@Override
|
||||
public SysOperLog selectOperLogById(Long operId) {
|
||||
return getById(operId);
|
||||
return baseMapper.selectById(operId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +135,6 @@ public class SysOperLogServiceImpl extends ServicePlusImpl<SysOperLogMapper, Sys
|
||||
*/
|
||||
@Override
|
||||
public void cleanOperLog() {
|
||||
remove(new LambdaQueryWrapper<>());
|
||||
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.RedisUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.redis.RedisUtils;
|
||||
import com.ruoyi.oss.constant.OssConstant;
|
||||
import com.ruoyi.oss.factory.OssFactory;
|
||||
import com.ruoyi.system.domain.SysOssConfig;
|
||||
@@ -24,7 +23,6 @@ import com.ruoyi.system.mapper.SysOssConfigMapper;
|
||||
import com.ruoyi.system.service.ISysOssConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -39,16 +37,18 @@ import java.util.List;
|
||||
* @date 2021-08-13
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper, SysOssConfig, SysOssConfigVo> implements ISysOssConfigService {
|
||||
public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
|
||||
private final SysOssConfigMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化参数到缓存,加载配置类
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
List<SysOssConfig> list = list();
|
||||
List<SysOssConfig> list = baseMapper.selectList();
|
||||
// 加载OSS初始化配置
|
||||
for (SysOssConfig config : list) {
|
||||
String configKey = config.getConfigKey();
|
||||
@@ -63,13 +63,13 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
||||
|
||||
@Override
|
||||
public SysOssConfigVo queryById(Integer ossConfigId) {
|
||||
return getVoById(ossConfigId);
|
||||
return baseMapper.selectVoById(ossConfigId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysOssConfig> lqw = buildQueryWrapper(bo);
|
||||
Page<SysOssConfigVo> result = pageVo(pageQuery.build(), lqw);
|
||||
Page<SysOssConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
||||
public Boolean insertByBo(SysOssConfigBo bo) {
|
||||
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
|
||||
validEntityBeforeSave(config);
|
||||
return setConfigCache(save(config), config);
|
||||
return setConfigCache(baseMapper.insert(config) > 0, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +98,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
||||
luw.set(StringUtils.isBlank(config.getRegion()), SysOssConfig::getRegion, "");
|
||||
luw.set(StringUtils.isBlank(config.getExt1()), SysOssConfig::getExt1, "");
|
||||
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
|
||||
return setConfigCache(update(config, luw), config);
|
||||
return setConfigCache(baseMapper.update(config, luw) > 0, config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,10 +120,10 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
||||
}
|
||||
List<SysOssConfig> list = Lists.newArrayList();
|
||||
for (Long configId : ids) {
|
||||
SysOssConfig config = getById(configId);
|
||||
SysOssConfig config = baseMapper.selectById(configId);
|
||||
list.add(config);
|
||||
}
|
||||
boolean flag = removeByIds(ids);
|
||||
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
|
||||
if (flag) {
|
||||
list.stream().forEach(sysOssConfig -> {
|
||||
RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey()));
|
||||
@@ -137,7 +137,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
|
||||
*/
|
||||
private String checkConfigKeyUnique(SysOssConfig sysOssConfig) {
|
||||
long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
|
||||
SysOssConfig info = getOne(new LambdaQueryWrapper<SysOssConfig>()
|
||||
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
|
||||
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
|
||||
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
|
||||
if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@@ -16,6 +15,7 @@ import com.ruoyi.system.domain.bo.SysOssBo;
|
||||
import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
import com.ruoyi.system.mapper.SysOssMapper;
|
||||
import com.ruoyi.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -29,13 +29,16 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, SysOssVo> implements ISysOssService {
|
||||
public class SysOssServiceImpl implements ISysOssService {
|
||||
|
||||
private final SysOssMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
|
||||
Page<SysOssVo> result = pageVo(pageQuery.build(), lqw);
|
||||
Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@@ -53,6 +56,11 @@ public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, Sys
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysOss getById(Long ossId) {
|
||||
return baseMapper.selectById(ossId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysOss upload(MultipartFile file) {
|
||||
String originalfileName = file.getOriginalFilename();
|
||||
@@ -71,7 +79,7 @@ public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, Sys
|
||||
.setFileName(uploadResult.getFilename())
|
||||
.setOriginalName(originalfileName)
|
||||
.setService(storage.getServiceType());
|
||||
save(oss);
|
||||
baseMapper.insert(oss);
|
||||
return oss;
|
||||
}
|
||||
|
||||
@@ -80,12 +88,12 @@ public class SysOssServiceImpl extends ServicePlusImpl<SysOssMapper, SysOss, Sys
|
||||
if (isValid) {
|
||||
// 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
List<SysOss> list = listByIds(ids);
|
||||
List<SysOss> list = baseMapper.selectBatchIds(ids);
|
||||
for (SysOss sysOss : list) {
|
||||
IOssStrategy storage = OssFactory.instance(sysOss.getService());
|
||||
storage.delete(sysOss.getUrl());
|
||||
}
|
||||
return removeByIds(ids);
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@@ -13,7 +12,7 @@ import com.ruoyi.system.domain.SysUserPost;
|
||||
import com.ruoyi.system.mapper.SysPostMapper;
|
||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -24,11 +23,12 @@ import java.util.List;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost, SysPost> implements ISysPostService {
|
||||
public class SysPostServiceImpl implements ISysPostService {
|
||||
|
||||
@Autowired
|
||||
private SysUserPostMapper userPostMapper;
|
||||
private final SysPostMapper baseMapper;
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) {
|
||||
@@ -36,7 +36,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName());
|
||||
Page<SysPost> page = page(pageQuery.build(), lqw);
|
||||
Page<SysPost> page = baseMapper.selectPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
*/
|
||||
@Override
|
||||
public List<SysPost> selectPostList(SysPost post) {
|
||||
return list(new LambdaQueryWrapper<SysPost>()
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<SysPost>()
|
||||
.like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode())
|
||||
.eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus())
|
||||
.like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()));
|
||||
@@ -61,7 +61,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
*/
|
||||
@Override
|
||||
public List<SysPost> selectPostAll() {
|
||||
return list();
|
||||
return baseMapper.selectList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
*/
|
||||
@Override
|
||||
public SysPost selectPostById(Long postId) {
|
||||
return getById(postId);
|
||||
return baseMapper.selectById(postId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +95,10 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
@Override
|
||||
public String checkPostNameUnique(SysPost post) {
|
||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||
long count = count(new LambdaQueryWrapper<SysPost>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostName, post.getPostName())
|
||||
.ne(SysPost::getPostId, postId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -113,10 +113,10 @@ public class SysPostServiceImpl extends ServicePlusImpl<SysPostMapper, SysPost,
|
||||
@Override
|
||||
public String checkPostCodeUnique(SysPost post) {
|
||||
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
|
||||
long count = count(new LambdaQueryWrapper<SysPost>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostCode, post.getPostCode())
|
||||
.ne(SysPost::getPostId, postId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
|
||||
@@ -6,10 +6,9 @@ import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.system.domain.SysRoleDept;
|
||||
@@ -20,7 +19,7 @@ import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -31,17 +30,14 @@ import java.util.*;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole, SysRole> implements ISysRoleService {
|
||||
public class SysRoleServiceImpl implements ISysRoleService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMenuMapper roleMenuMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleDeptMapper roleDeptMapper;
|
||||
private final SysRoleMapper baseMapper;
|
||||
private final SysRoleMenuMapper roleMenuMapper;
|
||||
private final SysUserRoleMapper userRoleMapper;
|
||||
private final SysRoleDeptMapper roleDeptMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery) {
|
||||
@@ -128,7 +124,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
*/
|
||||
@Override
|
||||
public SysRole selectRoleById(Long roleId) {
|
||||
return getById(roleId);
|
||||
return baseMapper.selectById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,10 +136,10 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
@Override
|
||||
public String checkRoleNameUnique(SysRole role) {
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
long count = count(new LambdaQueryWrapper<SysRole>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleName, role.getRoleName())
|
||||
.ne(SysRole::getRoleId, roleId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -158,10 +154,10 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
@Override
|
||||
public String checkRoleKeyUnique(SysRole role) {
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
long count = count(new LambdaQueryWrapper<SysRole>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleKey, role.getRoleKey())
|
||||
.ne(SysRole::getRoleId, roleId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -186,7 +182,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(Long roleId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
@@ -281,7 +277,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
rows = roleMenuMapper.insertAll(list);
|
||||
rows = roleMenuMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@@ -302,7 +298,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
rows = roleDeptMapper.insertAll(list);
|
||||
rows = roleDeptMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
@@ -393,7 +389,7 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
rows = userRoleMapper.insertAll(list);
|
||||
rows = userRoleMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.SensitiveService;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 脱敏服务
|
||||
* 默认管理员不过滤
|
||||
* 需自行根据业务重写实现
|
||||
*
|
||||
* @author Lion Li
|
||||
* @version 3.6.0
|
||||
*/
|
||||
@Service
|
||||
public class SysSensitiveServiceImpl implements SensitiveService {
|
||||
|
||||
/**
|
||||
* 是否脱敏
|
||||
*/
|
||||
@Override
|
||||
public boolean isSensitive() {
|
||||
return SecurityUtils.isAdmin(LoginUtils.getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysUserOnline;
|
||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 在线用户 服务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Service
|
||||
public class SysUserOnlineServiceImpl implements ISysUserOnlineService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 通过登录地址查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline selectOnlineByIpaddr(String ipaddr, LoginUser user) {
|
||||
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
|
||||
return loginUserToUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名称查询信息
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline selectOnlineByUserName(String userName, LoginUser user) {
|
||||
if (StringUtils.equals(userName, user.getUsername())) {
|
||||
return loginUserToUserOnline(user);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过登录地址/用户名称查询信息
|
||||
*
|
||||
* @param ipaddr 登录地址
|
||||
* @param userName 用户名称
|
||||
* @param user 用户信息
|
||||
* @return 在线用户信息
|
||||
*/
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置在线用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 在线用户
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline loginUserToUserOnline(LoginUser user) {
|
||||
if (StringUtils.isNull(user)) {
|
||||
return null;
|
||||
}
|
||||
SysUser sysUser = userService.selectUserById(user.getUserId());
|
||||
SysUserOnline sysUserOnline = new SysUserOnline();
|
||||
sysUserOnline.setTokenId(user.getToken());
|
||||
sysUserOnline.setUserName(user.getUsername());
|
||||
sysUserOnline.setIpaddr(user.getIpaddr());
|
||||
sysUserOnline.setLoginLocation(user.getLoginLocation());
|
||||
sysUserOnline.setBrowser(user.getBrowser());
|
||||
sysUserOnline.setOs(user.getOs());
|
||||
sysUserOnline.setLoginTime(user.getLoginTime());
|
||||
if (StringUtils.isNotNull(sysUser.getDept())) {
|
||||
sysUserOnline.setDeptName(sysUser.getDept().getDeptName());
|
||||
}
|
||||
return sysUserOnline;
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.service.UserService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@@ -20,8 +20,8 @@ import com.ruoyi.system.domain.SysUserPost;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -36,20 +36,15 @@ import java.util.stream.Collectors;
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser, SysUser> implements ISysUserService, UserService {
|
||||
public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysPostMapper postMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserPostMapper userPostMapper;
|
||||
private final SysUserMapper baseMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysPostMapper postMapper;
|
||||
private final SysUserRoleMapper userRoleMapper;
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysUser> selectPageUserList(SysUser user, PageQuery pageQuery) {
|
||||
@@ -152,7 +147,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
*/
|
||||
@Override
|
||||
public String checkUserNameUnique(String userName) {
|
||||
long count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
||||
long count = baseMapper.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
|
||||
if (count > 0) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
@@ -168,10 +163,10 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
@Override
|
||||
public String checkPhoneUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
long count = count(new LambdaQueryWrapper<SysUser>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getPhonenumber, user.getPhonenumber())
|
||||
.ne(SysUser::getUserId, userId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -186,10 +181,10 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
@Override
|
||||
public String checkEmailUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
long count = count(new LambdaQueryWrapper<SysUser>()
|
||||
boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getEmail, user.getEmail())
|
||||
.ne(SysUser::getUserId, userId));
|
||||
if (count > 0) {
|
||||
if (count) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@@ -214,7 +209,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
if (!SysUser.isAdmin(LoginUtils.getUserId())) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
@@ -368,7 +363,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
userRoleMapper.insertAll(list);
|
||||
userRoleMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,7 +385,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
list.add(up);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
userPostMapper.insertAll(list);
|
||||
userPostMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,7 +407,7 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
userRoleMapper.insertAll(list);
|
||||
userRoleMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.jwt.JWTUtil;
|
||||
import cn.hutool.jwt.signers.JWTSigner;
|
||||
import cn.hutool.jwt.signers.JWTSignerUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.service.TokenService;
|
||||
import com.ruoyi.common.properties.TokenProperties;
|
||||
import com.ruoyi.common.utils.RedisUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.ip.AddressUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* token验证处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Service
|
||||
public class TokenServiceImpl implements TokenService {
|
||||
|
||||
protected static final long MILLIS_SECOND = 1000;
|
||||
|
||||
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
|
||||
|
||||
private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
|
||||
|
||||
@Autowired
|
||||
private TokenProperties tokenProperties;
|
||||
|
||||
/**
|
||||
* 获取用户身份信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@Override
|
||||
public LoginUser getLoginUser(HttpServletRequest request) {
|
||||
// 获取请求携带的令牌
|
||||
String token = getToken(request);
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
try {
|
||||
JSONObject claims = parseToken(token);
|
||||
// 解析对应的权限以及用户信息
|
||||
String uuid = claims.getStr(Constants.LOGIN_USER_KEY);
|
||||
String userKey = getTokenKey(uuid);
|
||||
LoginUser user = RedisUtils.getCacheObject(userKey);
|
||||
return user;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户身份信息
|
||||
*/
|
||||
@Override
|
||||
public void setLoginUser(LoginUser loginUser) {
|
||||
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) {
|
||||
refreshToken(loginUser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户身份信息
|
||||
*/
|
||||
@Override
|
||||
public void delLoginUser(String token) {
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
String userKey = getTokenKey(token);
|
||||
RedisUtils.deleteObject(userKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建令牌
|
||||
*
|
||||
* @param loginUser 用户信息
|
||||
* @return 令牌
|
||||
*/
|
||||
@Override
|
||||
public String createToken(LoginUser loginUser) {
|
||||
String token = IdUtil.fastUUID();
|
||||
loginUser.setToken(token);
|
||||
setUserAgent(loginUser);
|
||||
refreshToken(loginUser);
|
||||
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(Constants.LOGIN_USER_KEY, token);
|
||||
return createToken(claims);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证令牌有效期,相差不足20分钟,自动刷新缓存
|
||||
*
|
||||
* @param loginUser
|
||||
* @return 令牌
|
||||
*/
|
||||
@Override
|
||||
public void verifyToken(LoginUser loginUser) {
|
||||
long expireTime = loginUser.getExpireTime();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (expireTime - currentTime <= MILLIS_MINUTE_TEN) {
|
||||
refreshToken(loginUser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新令牌有效期
|
||||
*
|
||||
* @param loginUser 登录信息
|
||||
*/
|
||||
@Override
|
||||
public void refreshToken(LoginUser loginUser) {
|
||||
loginUser.setLoginTime(System.currentTimeMillis());
|
||||
loginUser.setExpireTime(loginUser.getLoginTime() + tokenProperties.getExpireTime() * MILLIS_MINUTE);
|
||||
// 根据uuid将loginUser缓存
|
||||
String userKey = getTokenKey(loginUser.getToken());
|
||||
RedisUtils.setCacheObject(userKey, loginUser, tokenProperties.getExpireTime(), TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户代理信息
|
||||
*
|
||||
* @param loginUser 登录信息
|
||||
*/
|
||||
@Override
|
||||
public void setUserAgent(LoginUser loginUser) {
|
||||
UserAgent userAgent = UserAgentUtil.parse(ServletUtils.getRequest().getHeader("User-Agent"));
|
||||
String ip = ServletUtils.getClientIP();
|
||||
loginUser.setIpaddr(ip);
|
||||
loginUser.setLoginLocation(AddressUtils.getRealAddressByIP(ip));
|
||||
loginUser.setBrowser(userAgent.getBrowser().getName());
|
||||
loginUser.setOs(userAgent.getOs().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 从数据声明生成令牌
|
||||
*
|
||||
* @param claims 数据声明
|
||||
* @return 令牌
|
||||
*/
|
||||
private String createToken(Map<String, Object> claims) {
|
||||
JWTSigner signer = JWTSignerUtil.hs512(tokenProperties.getSecret().getBytes());
|
||||
String token = JWTUtil.createToken(claims, signer);
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从令牌中获取数据声明
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 数据声明
|
||||
*/
|
||||
private JSONObject parseToken(String token) {
|
||||
JWTSigner signer = JWTSignerUtil.hs512(tokenProperties.getSecret().getBytes());
|
||||
return JWTUtil.parseToken(token).setSigner(signer).getPayload().getClaimsJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从令牌中获取用户名
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 用户名
|
||||
*/
|
||||
@Override
|
||||
public String getUsernameFromToken(String token) {
|
||||
JSONObject claims = parseToken(token);
|
||||
return claims.getStr("sub");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求token
|
||||
*
|
||||
* @param request
|
||||
* @return token
|
||||
*/
|
||||
private String getToken(HttpServletRequest request) {
|
||||
String token = request.getHeader(tokenProperties.getHeader());
|
||||
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) {
|
||||
token = token.replace(Constants.TOKEN_PREFIX, "");
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
private String getTokenKey(String uuid) {
|
||||
return Constants.LOGIN_TOKEN_KEY + uuid;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.exception.user.UserException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.system.service.SysPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 用户验证处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysPermissionService permissionService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||
log.info("登录用户:{} 已被删除.", username);
|
||||
throw new UserException("user.password.delete", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
|
||||
return createLoginUser(user);
|
||||
}
|
||||
|
||||
public UserDetails createLoginUser(SysUser user) {
|
||||
return new LoginUser()
|
||||
.setUserId(user.getUserId())
|
||||
.setDeptId(user.getDeptId())
|
||||
.setNickName(user.getNickName())
|
||||
.setUsername(user.getUserName())
|
||||
.setPassword(user.getPassword())
|
||||
.setMenuPermissions(permissionService.getMenuPermission(user))
|
||||
.setRolePermissions(permissionService.getRolePermission(user));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.workflow.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 流程分类对象 workflow_category
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("workflow_category")
|
||||
public class FlowCategory extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
@TableId(value = "category_id")
|
||||
private Long categoryId;
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
/**
|
||||
* 分类编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.workflow.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 流程分类业务对象 flow_category
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("流程分类业务对象")
|
||||
public class FlowCategoryBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
@ApiModelProperty(value = "分类ID", required = true)
|
||||
@NotNull(message = "分类ID不能为空", groups = { EditGroup.class })
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@ApiModelProperty(value = "分类名称", required = true)
|
||||
@NotBlank(message = "分类名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String categoryName;
|
||||
|
||||
/**
|
||||
* 分类编码
|
||||
*/
|
||||
@ApiModelProperty(value = "分类编码", required = true)
|
||||
@NotBlank(message = "分类编码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注", required = true)
|
||||
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021/3/28 15:50
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class FlowCommentDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 意见类别 0 正常意见 1 退回意见 2 驳回意见
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 意见内容
|
||||
*/
|
||||
private String comment;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021/3/31 23:20
|
||||
*/
|
||||
@Data
|
||||
public class FlowFromFieldDTO implements Serializable {
|
||||
|
||||
private Object fields;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动态人员、组
|
||||
* @author Xuan xuan
|
||||
* @date 2021/4/17 22:59
|
||||
*/
|
||||
@Data
|
||||
public class FlowNextDto implements Serializable {
|
||||
|
||||
private String type;
|
||||
|
||||
private String vars;
|
||||
|
||||
private List<SysUser> userList;
|
||||
|
||||
private List<SysRole> roleList;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>流程定义<p>
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel("流程定义")
|
||||
public class FlowProcDefDto implements Serializable {
|
||||
|
||||
@ApiModelProperty("流程id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("流程名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("流程key")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty("流程分类")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("配置表单名称")
|
||||
private String formName;
|
||||
|
||||
@ApiModelProperty("配置表单id")
|
||||
private Long formId;
|
||||
|
||||
@ApiModelProperty("版本")
|
||||
private int version;
|
||||
|
||||
@ApiModelProperty("部署ID")
|
||||
private String deploymentId;
|
||||
|
||||
@ApiModelProperty("流程定义状态: 1:激活 , 2:中止")
|
||||
private int suspensionState;
|
||||
|
||||
@ApiModelProperty("部署时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date deploymentTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021/3/28 19:48
|
||||
*/
|
||||
@Data
|
||||
public class FlowSaveXmlVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 流程名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 流程分类
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* xml 文件
|
||||
*/
|
||||
private String xml;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>工作流任务<p>
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ApiModel("工作流任务相关-返回参数")
|
||||
public class FlowTaskDto implements Serializable {
|
||||
|
||||
@ApiModelProperty("任务编号")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty("任务名称")
|
||||
private String taskName;
|
||||
|
||||
@ApiModelProperty("任务Key")
|
||||
private String taskDefKey;
|
||||
|
||||
@ApiModelProperty("任务执行人Id")
|
||||
private Long assigneeId;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty("流程发起人部门名称")
|
||||
private String startDeptName;
|
||||
|
||||
@ApiModelProperty("任务执行人名称")
|
||||
private String assigneeName;
|
||||
|
||||
@ApiModelProperty("流程发起人Id")
|
||||
private String startUserId;
|
||||
|
||||
@ApiModelProperty("流程发起人名称")
|
||||
private String startUserName;
|
||||
|
||||
@ApiModelProperty("流程类型")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("流程变量信息")
|
||||
private Object procVars;
|
||||
|
||||
@ApiModelProperty("局部变量信息")
|
||||
private Object taskLocalVars;
|
||||
|
||||
@ApiModelProperty("流程部署编号")
|
||||
private String deployId;
|
||||
|
||||
@ApiModelProperty("流程ID")
|
||||
private String procDefId;
|
||||
|
||||
@ApiModelProperty("流程key")
|
||||
private String procDefKey;
|
||||
|
||||
@ApiModelProperty("流程定义名称")
|
||||
private String procDefName;
|
||||
|
||||
@ApiModelProperty("流程定义内置使用版本")
|
||||
private int procDefVersion;
|
||||
|
||||
@ApiModelProperty("流程实例ID")
|
||||
private String procInsId;
|
||||
|
||||
@ApiModelProperty("历史流程实例ID")
|
||||
private String hisProcInsId;
|
||||
|
||||
@ApiModelProperty("任务耗时")
|
||||
private String duration;
|
||||
|
||||
@ApiModelProperty("任务意见")
|
||||
private FlowCommentDto comment;
|
||||
|
||||
@ApiModelProperty("候选执行人")
|
||||
private String candidate;
|
||||
|
||||
@ApiModelProperty("任务创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("任务完成时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date finishTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.workflow.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Xuan xuan
|
||||
* @date 2021/4/21 20:55
|
||||
*/
|
||||
@Data
|
||||
public class FlowViewerDto implements Serializable {
|
||||
|
||||
private String key;
|
||||
private boolean completed;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.workflow.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 流程分类视图对象 flow_category
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("流程分类视图对象")
|
||||
@ExcelIgnoreUnannotated
|
||||
public class FlowCategoryVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
@ExcelProperty(value = "分类ID")
|
||||
@ApiModelProperty("分类ID")
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@ExcelProperty(value = "分类名称")
|
||||
@ApiModelProperty("分类名称")
|
||||
private String categoryName;
|
||||
|
||||
/**
|
||||
* 分类编码
|
||||
*/
|
||||
@ExcelProperty(value = "分类编码")
|
||||
@ApiModelProperty("分类编码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.workflow.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>流程任务<p>
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("工作流任务相关--请求参数")
|
||||
public class FlowTaskVo {
|
||||
|
||||
@ApiModelProperty("任务Id")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty("用户Id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("任务意见")
|
||||
private String comment;
|
||||
|
||||
@ApiModelProperty("流程实例Id")
|
||||
private String instanceId;
|
||||
|
||||
@ApiModelProperty("节点")
|
||||
private String targetKey;
|
||||
|
||||
@ApiModelProperty("流程变量信息")
|
||||
private Map<String, Object> values;
|
||||
|
||||
@ApiModelProperty("审批人")
|
||||
private String assignee;
|
||||
|
||||
@ApiModelProperty("候选人")
|
||||
private List<String> candidateUsers;
|
||||
|
||||
@ApiModelProperty("审批组")
|
||||
private List<String> candidateGroups;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.workflow.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 任务追踪视图类
|
||||
*
|
||||
* @author konbai
|
||||
* @createTime 2022/1/8 19:42
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FlowViewerVo {
|
||||
|
||||
/**
|
||||
* 获取流程实例的历史节点(去重)
|
||||
*/
|
||||
private List<String> finishedTaskList;
|
||||
|
||||
/**
|
||||
* 获取流程实例当前正在待办的节点(去重)
|
||||
*/
|
||||
private List<String> unfinishedTaskList;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.workflow.mapper;
|
||||
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.workflow.domain.FlowCategory;
|
||||
import com.ruoyi.workflow.domain.vo.FlowCategoryVo;
|
||||
|
||||
/**
|
||||
* 流程分类Mapper接口
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
public interface FlowCategoryMapper extends BaseMapperPlus<FlowCategoryMapper, FlowCategory, FlowCategoryVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.workflow.domain.bo.FlowCategoryBo;
|
||||
import com.ruoyi.workflow.domain.vo.FlowCategoryVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程分类Service接口
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
public interface IFlowCategoryService {
|
||||
/**
|
||||
* 查询单个
|
||||
* @return
|
||||
*/
|
||||
FlowCategoryVo queryById(Long categoryId);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
TableDataInfo<FlowCategoryVo> queryPageList(FlowCategoryBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<FlowCategoryVo> queryList(FlowCategoryBo bo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入【请填写功能名称】
|
||||
* @param bo 【请填写功能名称】新增业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean insertByBo(FlowCategoryBo bo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改【请填写功能名称】
|
||||
* @param bo 【请填写功能名称】编辑业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean updateByBo(FlowCategoryBo bo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.workflow.domain.dto.FlowProcDefDto;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03 14:41
|
||||
*/
|
||||
public interface IFlowDefinitionService {
|
||||
|
||||
boolean exist(String processDefinitionKey);
|
||||
|
||||
|
||||
/**
|
||||
* 流程定义列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @return 流程定义分页列表数据
|
||||
*/
|
||||
Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 导入流程文件
|
||||
*
|
||||
* @param name
|
||||
* @param category
|
||||
* @param in
|
||||
*/
|
||||
void importFile(String name, String category, InputStream in);
|
||||
|
||||
/**
|
||||
* 读取xml
|
||||
* @param deployId
|
||||
* @return
|
||||
*/
|
||||
R readXml(String deployId) throws IOException;
|
||||
|
||||
/**
|
||||
* 根据流程定义ID启动流程实例
|
||||
*
|
||||
* @param procDefId
|
||||
* @param variables
|
||||
* @return
|
||||
*/
|
||||
|
||||
R startProcessInstanceById(String procDefId, Map<String, Object> variables);
|
||||
|
||||
|
||||
/**
|
||||
* 激活或挂起流程定义
|
||||
*
|
||||
* @param state 状态
|
||||
* @param deployId 流程部署ID
|
||||
*/
|
||||
void updateState(Integer state, String deployId);
|
||||
|
||||
|
||||
/**
|
||||
* 删除流程定义
|
||||
*
|
||||
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
|
||||
*/
|
||||
void delete(String deployId);
|
||||
|
||||
|
||||
/**
|
||||
* 读取图片文件
|
||||
* @param deployId
|
||||
* @return
|
||||
*/
|
||||
InputStream readImage(String deployId);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03 14:40
|
||||
*/
|
||||
public interface IFlowInstanceService {
|
||||
|
||||
List<Task> queryListByInstanceId(String instanceId);
|
||||
|
||||
/**
|
||||
* 结束流程实例
|
||||
*
|
||||
* @param vo
|
||||
*/
|
||||
void stopProcessInstance(FlowTaskVo vo);
|
||||
|
||||
/**
|
||||
* 激活或挂起流程实例
|
||||
*
|
||||
* @param state 状态
|
||||
* @param instanceId 流程实例ID
|
||||
*/
|
||||
void updateState(Integer state, String instanceId);
|
||||
|
||||
/**
|
||||
* 删除流程实例ID
|
||||
*
|
||||
* @param instanceId 流程实例ID
|
||||
* @param deleteReason 删除原因
|
||||
*/
|
||||
void delete(String instanceId, String deleteReason);
|
||||
|
||||
/**
|
||||
* 根据实例ID查询历史实例数据
|
||||
*
|
||||
* @param processInstanceId
|
||||
* @return
|
||||
*/
|
||||
HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId);
|
||||
|
||||
/**
|
||||
* 根据流程定义ID启动流程实例
|
||||
*
|
||||
* @param procDefId 流程定义Id
|
||||
* @param variables 流程变量
|
||||
* @return
|
||||
*/
|
||||
R startProcessInstanceById(String procDefId, Map<String, Object> variables);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03 14:42
|
||||
*/
|
||||
public interface IFlowTaskService {
|
||||
|
||||
/**
|
||||
* 审批任务
|
||||
*
|
||||
* @param task 请求实体参数
|
||||
*/
|
||||
R complete(FlowTaskVo task);
|
||||
|
||||
/**
|
||||
* 驳回任务
|
||||
*
|
||||
* @param flowTaskVo
|
||||
*/
|
||||
void taskReject(FlowTaskVo flowTaskVo);
|
||||
|
||||
|
||||
/**
|
||||
* 退回任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
void taskReturn(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 获取所有可回退的节点
|
||||
*
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
R findReturnTaskList(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
void deleteTask(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 认领/签收任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
void claim(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 取消认领/签收任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
void unClaim(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 委派任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
void delegateTask(FlowTaskVo flowTaskVo);
|
||||
|
||||
|
||||
/**
|
||||
* 转办任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
void assignTask(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 我发起的流程
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
R myProcess(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 取消申请
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
R stopProcess(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 撤回流程
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
R revokeProcess(FlowTaskVo flowTaskVo);
|
||||
|
||||
|
||||
/**
|
||||
* 代办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
R todoList(Integer pageNum, Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 已办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
R finishedList(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 流程历史流转记录
|
||||
*
|
||||
* @param procInsId 流程实例Id
|
||||
* @return
|
||||
*/
|
||||
R flowRecord(String procInsId,String deployId);
|
||||
|
||||
/**
|
||||
* 根据任务ID查询挂载的表单信息
|
||||
*
|
||||
* @param taskId 任务Id
|
||||
* @return
|
||||
*/
|
||||
Task getTaskForm(String taskId);
|
||||
|
||||
/**
|
||||
* 获取流程过程图
|
||||
* @param processId
|
||||
* @return
|
||||
*/
|
||||
InputStream diagram(String processId);
|
||||
|
||||
/**
|
||||
* 获取流程执行过程
|
||||
* @param procInsId
|
||||
* @return
|
||||
*/
|
||||
R getFlowViewer(String procInsId);
|
||||
|
||||
/**
|
||||
* 获取流程变量
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
R processVariables(String taskId);
|
||||
|
||||
/**
|
||||
* 获取下一节点
|
||||
* @param flowTaskVo 任务
|
||||
* @return
|
||||
*/
|
||||
R getNextFlowNode(FlowTaskVo flowTaskVo);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.system.domain.SysDeployForm;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程实例关联表单Service接口
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
public interface ISysDeployFormService {
|
||||
/**
|
||||
* 查询流程实例关联表单
|
||||
*
|
||||
* @param id 流程实例关联表单ID
|
||||
* @return 流程实例关联表单
|
||||
*/
|
||||
SysDeployForm selectSysDeployFormById(Long id);
|
||||
|
||||
/**
|
||||
* 查询流程实例关联表单列表
|
||||
*
|
||||
* @param sysDeployForm 流程实例关联表单
|
||||
* @return 流程实例关联表单集合
|
||||
*/
|
||||
List<SysDeployForm> selectSysDeployFormList(SysDeployForm sysDeployForm);
|
||||
|
||||
/**
|
||||
* 新增流程实例关联表单
|
||||
*
|
||||
* @param sysDeployForm 流程实例关联表单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSysDeployForm(SysDeployForm sysDeployForm);
|
||||
|
||||
/**
|
||||
* 修改流程实例关联表单
|
||||
*
|
||||
* @param sysDeployForm 流程实例关联表单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSysDeployForm(SysDeployForm sysDeployForm);
|
||||
|
||||
/**
|
||||
* 批量删除流程实例关联表单
|
||||
*
|
||||
* @param ids 需要删除的流程实例关联表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysDeployFormByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除流程实例关联表单信息
|
||||
*
|
||||
* @param id 流程实例关联表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysDeployFormById(Long id);
|
||||
|
||||
/**
|
||||
* 查询流程挂着的表单
|
||||
*
|
||||
* @param deployId
|
||||
* @return
|
||||
*/
|
||||
SysForm selectSysDeployFormByDeployId(String deployId);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表单
|
||||
*
|
||||
* @author XuanXuan Xuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
public interface ISysFormService {
|
||||
/**
|
||||
* 查询流程表单
|
||||
*
|
||||
* @param formId 流程表单ID
|
||||
* @return 流程表单
|
||||
*/
|
||||
SysForm selectSysFormById(Long formId);
|
||||
|
||||
/**
|
||||
* 查询流程表单列表
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 流程表单集合
|
||||
*/
|
||||
TableDataInfo<SysForm> selectSysFormPage(SysForm sysForm, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询流程表单列表
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 流程表单集合
|
||||
*/
|
||||
List<SysForm> selectSysFormList(SysForm sysForm);
|
||||
|
||||
/**
|
||||
* 新增流程表单
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSysForm(SysForm sysForm);
|
||||
|
||||
/**
|
||||
* 修改流程表单
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSysForm(SysForm sysForm);
|
||||
|
||||
/**
|
||||
* 批量删除流程表单
|
||||
*
|
||||
* @param formIds 需要删除的流程表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysFormByIds(Long[] formIds);
|
||||
|
||||
/**
|
||||
* 删除流程表单信息
|
||||
*
|
||||
* @param formId 流程表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysFormById(Long formId);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.system.domain.SysTaskForm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程任务关联单Service接口
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ISysTaskFormService {
|
||||
/**
|
||||
* 查询流程任务关联单
|
||||
*
|
||||
* @param id 流程任务关联单ID
|
||||
* @return 流程任务关联单
|
||||
*/
|
||||
SysTaskForm selectSysTaskFormById(Long id);
|
||||
|
||||
/**
|
||||
* 查询流程任务关联单列表
|
||||
*
|
||||
* @param sysTaskForm 流程任务关联单
|
||||
* @return 流程任务关联单集合
|
||||
*/
|
||||
List<SysTaskForm> selectSysTaskFormList(SysTaskForm sysTaskForm);
|
||||
|
||||
/**
|
||||
* 新增流程任务关联单
|
||||
*
|
||||
* @param sysTaskForm 流程任务关联单
|
||||
* @return 结果
|
||||
*/
|
||||
int insertSysTaskForm(SysTaskForm sysTaskForm);
|
||||
|
||||
/**
|
||||
* 修改流程任务关联单
|
||||
*
|
||||
* @param sysTaskForm 流程任务关联单
|
||||
* @return 结果
|
||||
*/
|
||||
int updateSysTaskForm(SysTaskForm sysTaskForm);
|
||||
|
||||
/**
|
||||
* 批量删除流程任务关联单
|
||||
*
|
||||
* @param ids 需要删除的流程任务关联单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysTaskFormByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除流程任务关联单信息
|
||||
*
|
||||
* @param id 流程任务关联单ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteSysTaskFormById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.workflow.domain.FlowCategory;
|
||||
import com.ruoyi.workflow.domain.bo.FlowCategoryBo;
|
||||
import com.ruoyi.workflow.domain.vo.FlowCategoryVo;
|
||||
import com.ruoyi.workflow.mapper.FlowCategoryMapper;
|
||||
import com.ruoyi.workflow.service.IFlowCategoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程分类Service业务层处理
|
||||
*
|
||||
* @author KonBAI
|
||||
* @date 2022-01-15
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class FlowCategoryServiceImpl implements IFlowCategoryService {
|
||||
|
||||
private final FlowCategoryMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public FlowCategoryVo queryById(Long categoryId){
|
||||
return baseMapper.selectVoById(categoryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<FlowCategoryVo> queryPageList(FlowCategoryBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<FlowCategory> lqw = buildQueryWrapper(bo);
|
||||
Page<FlowCategoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FlowCategoryVo> queryList(FlowCategoryBo bo) {
|
||||
LambdaQueryWrapper<FlowCategory> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<FlowCategory> buildQueryWrapper(FlowCategoryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<FlowCategory> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getCategoryName()), FlowCategory::getCategoryName, bo.getCategoryName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), FlowCategory::getCode, bo.getCode());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(FlowCategoryBo bo) {
|
||||
FlowCategory add = BeanUtil.toBean(bo, FlowCategory.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setCategoryId(add.getCategoryId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(FlowCategoryBo bo) {
|
||||
FlowCategory update = BeanUtil.toBean(bo, FlowCategory.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(FlowCategory entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
||||
import com.ruoyi.flowable.common.enums.FlowComment;
|
||||
import com.ruoyi.workflow.domain.dto.FlowProcDefDto;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
import com.ruoyi.workflow.service.IFlowDefinitionService;
|
||||
import com.ruoyi.workflow.service.ISysDeployFormService;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.image.impl.DefaultProcessDiagramGenerator;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 流程定义
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService {
|
||||
|
||||
@Resource
|
||||
private ISysDeployFormService sysDeployFormService;
|
||||
|
||||
private static final String BPMN_FILE_SUFFIX = ".bpmn";
|
||||
|
||||
@Override
|
||||
public boolean exist(String processDefinitionKey) {
|
||||
ProcessDefinitionQuery processDefinitionQuery
|
||||
= repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey);
|
||||
long count = processDefinitionQuery.count();
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 流程定义列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @return 流程定义分页列表数据
|
||||
*/
|
||||
@Override
|
||||
public Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowProcDefDto> page = new Page<>();
|
||||
// 流程定义列表数据查询
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
|
||||
// .latestVersion()
|
||||
.orderByProcessDefinitionKey().asc();
|
||||
page.setTotal(processDefinitionQuery.count());
|
||||
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageNum - 1, pageSize);
|
||||
|
||||
List<FlowProcDefDto> dataList = new ArrayList<>();
|
||||
for (ProcessDefinition processDefinition : processDefinitionList) {
|
||||
String deploymentId = processDefinition.getDeploymentId();
|
||||
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
||||
FlowProcDefDto reProcDef = new FlowProcDefDto();
|
||||
BeanUtils.copyProperties(processDefinition, reProcDef);
|
||||
SysForm sysForm = sysDeployFormService.selectSysDeployFormByDeployId(deploymentId);
|
||||
if (Objects.nonNull(sysForm)) {
|
||||
reProcDef.setFormName(sysForm.getFormName());
|
||||
reProcDef.setFormId(sysForm.getFormId());
|
||||
}
|
||||
// 流程定义时间
|
||||
reProcDef.setDeploymentTime(deployment.getDeploymentTime());
|
||||
dataList.add(reProcDef);
|
||||
}
|
||||
page.setRecords(dataList);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入流程文件
|
||||
*
|
||||
* @param name
|
||||
* @param category
|
||||
* @param in
|
||||
*/
|
||||
@Override
|
||||
public void importFile(String name, String category, InputStream in) {
|
||||
Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy();
|
||||
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();
|
||||
repositoryService.setProcessDefinitionCategory(definition.getId(), category);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取xml
|
||||
*
|
||||
* @param deployId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R readXml(String deployId) throws IOException {
|
||||
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
|
||||
InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName());
|
||||
String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
|
||||
return R.success("", result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取xml
|
||||
*
|
||||
* @param deployId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public InputStream readImage(String deployId) {
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
|
||||
//获得图片流
|
||||
DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
||||
//输出为图片
|
||||
return diagramGenerator.generateDiagram(
|
||||
bpmnModel,
|
||||
"png",
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
"宋体",
|
||||
"宋体",
|
||||
"宋体",
|
||||
null,
|
||||
1.0,
|
||||
false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程定义ID启动流程实例
|
||||
*
|
||||
* @param procDefId 流程定义Id
|
||||
* @param variables 流程变量
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R startProcessInstanceById(String procDefId, Map<String, Object> variables) {
|
||||
try {
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
|
||||
.latestVersion().singleResult();
|
||||
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
|
||||
return R.error("流程已被挂起,请先激活流程");
|
||||
}
|
||||
// variables.put("skip", true);
|
||||
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
|
||||
// 设置流程发起人Id到流程中
|
||||
String UserIdStr = LoginUtils.getUserId().toString();
|
||||
identityService.setAuthenticatedUserId(UserIdStr);
|
||||
variables.put(ProcessConstants.PROCESS_INITIATOR, UserIdStr);
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
|
||||
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
|
||||
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
|
||||
if (Objects.nonNull(task)) {
|
||||
if (!StrUtil.equalsAny(task.getAssignee(), UserIdStr)) {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return R.error("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!");
|
||||
}
|
||||
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginUtils.getNickName() + "发起流程申请");
|
||||
// taskService.setAssignee(task.getId(), UserIdStr);
|
||||
taskService.complete(task.getId(), variables);
|
||||
}
|
||||
return R.success("流程启动成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.error("流程启动错误");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 激活或挂起流程定义
|
||||
*
|
||||
* @param state 状态
|
||||
* @param deployId 流程部署ID
|
||||
*/
|
||||
@Override
|
||||
public void updateState(Integer state, String deployId) {
|
||||
ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult();
|
||||
// 激活
|
||||
if (state == 1) {
|
||||
repositoryService.activateProcessDefinitionById(procDef.getId(), true, null);
|
||||
}
|
||||
// 挂起
|
||||
if (state == 2) {
|
||||
repositoryService.suspendProcessDefinitionById(procDef.getId(), true, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除流程定义
|
||||
*
|
||||
* @param deployId 流程部署ID act_ge_bytearray 表中 deployment_id值
|
||||
*/
|
||||
@Override
|
||||
public void delete(String deployId) {
|
||||
// true 允许级联删除 ,不设置会导致数据库外键关联异常
|
||||
repositoryService.deleteDeployment(deployId, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
import com.ruoyi.workflow.service.IFlowInstanceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>工作流流程实例管理<p>
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FlowInstanceServiceImpl extends FlowServiceFactory implements IFlowInstanceService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Task> queryListByInstanceId(String instanceId) {
|
||||
return taskService.createTaskQuery().processInstanceId(instanceId).active().list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束流程实例
|
||||
*
|
||||
* @param vo
|
||||
*/
|
||||
@Override
|
||||
public void stopProcessInstance(FlowTaskVo vo) {
|
||||
String taskId = vo.getTaskId();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 激活或挂起流程实例
|
||||
*
|
||||
* @param state 状态
|
||||
* @param instanceId 流程实例ID
|
||||
*/
|
||||
@Override
|
||||
public void updateState(Integer state, String instanceId) {
|
||||
|
||||
// 激活
|
||||
if (state == 1) {
|
||||
runtimeService.activateProcessInstanceById(instanceId);
|
||||
}
|
||||
// 挂起
|
||||
if (state == 2) {
|
||||
runtimeService.suspendProcessInstanceById(instanceId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程实例ID
|
||||
*
|
||||
* @param instanceId 流程实例ID
|
||||
* @param deleteReason 删除原因
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(String instanceId, String deleteReason) {
|
||||
|
||||
// 查询历史数据
|
||||
HistoricProcessInstance historicProcessInstance = getHistoricProcessInstanceById(instanceId);
|
||||
if (historicProcessInstance.getEndTime() != null) {
|
||||
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
|
||||
return;
|
||||
}
|
||||
// 删除流程实例
|
||||
runtimeService.deleteProcessInstance(instanceId, deleteReason);
|
||||
// 删除历史流程实例
|
||||
historyService.deleteHistoricProcessInstance(instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实例ID查询历史实例数据
|
||||
*
|
||||
* @param processInstanceId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public HistoricProcessInstance getHistoricProcessInstanceById(String processInstanceId) {
|
||||
HistoricProcessInstance historicProcessInstance =
|
||||
historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
if (Objects.isNull(historicProcessInstance)) {
|
||||
throw new FlowableObjectNotFoundException("流程实例不存在: " + processInstanceId);
|
||||
}
|
||||
return historicProcessInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程定义ID启动流程实例
|
||||
*
|
||||
* @param procDefId 流程定义Id
|
||||
* @param variables 流程变量
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R startProcessInstanceById(String procDefId, Map<String, Object> variables) {
|
||||
|
||||
try {
|
||||
// 设置流程发起人Id到流程中
|
||||
Long userId = LoginUtils.getUserId();
|
||||
// identityService.setAuthenticatedUserId(userId.toString());
|
||||
variables.put("initiator", userId);
|
||||
variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true);
|
||||
runtimeService.startProcessInstanceById(procDefId, variables);
|
||||
return R.success("流程启动成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.error("流程启动错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,948 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
||||
import com.ruoyi.flowable.common.enums.FlowComment;
|
||||
import com.ruoyi.workflow.domain.dto.FlowCommentDto;
|
||||
import com.ruoyi.workflow.domain.dto.FlowNextDto;
|
||||
import com.ruoyi.workflow.domain.dto.FlowTaskDto;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import com.ruoyi.workflow.domain.vo.FlowViewerVo;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
import com.ruoyi.flowable.flow.CustomProcessDiagramGenerator;
|
||||
import com.ruoyi.flowable.flow.FindNextNodeUtil;
|
||||
import com.ruoyi.flowable.flow.FlowableUtils;
|
||||
import com.ruoyi.workflow.service.IFlowTaskService;
|
||||
import com.ruoyi.workflow.service.ISysDeployFormService;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.common.engine.api.FlowableException;
|
||||
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.engine.ProcessEngineConfiguration;
|
||||
import org.flowable.engine.history.HistoricActivityInstance;
|
||||
import org.flowable.engine.history.HistoricActivityInstanceQuery;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.engine.task.Comment;
|
||||
import org.flowable.identitylink.api.history.HistoricIdentityLink;
|
||||
import org.flowable.image.ProcessDiagramGenerator;
|
||||
import org.flowable.task.api.DelegationState;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
**/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTaskService {
|
||||
|
||||
@Resource
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
|
||||
@Resource
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
|
||||
@Resource
|
||||
private ISysDeployFormService sysInstanceFormService;
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param taskVo 请求实体参数
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public R complete(FlowTaskVo taskVo) {
|
||||
Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult();
|
||||
if (Objects.isNull(task)){
|
||||
return R.error("任务不存在");
|
||||
}
|
||||
if (DelegationState.PENDING.equals(task.getDelegationState())) {
|
||||
taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
|
||||
taskService.resolveTask(taskVo.getTaskId(), taskVo.getValues());
|
||||
} else {
|
||||
taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment());
|
||||
Long userId = LoginUtils.getUserId();
|
||||
taskService.setAssignee(taskVo.getTaskId(), userId.toString());
|
||||
if (ObjectUtil.isNotEmpty(taskVo.getValues())) {
|
||||
taskService.complete(taskVo.getTaskId(), taskVo.getValues());
|
||||
} else {
|
||||
taskService.complete(taskVo.getTaskId());
|
||||
}
|
||||
}
|
||||
return R.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回任务
|
||||
*
|
||||
* @param flowTaskVo
|
||||
*/
|
||||
@Override
|
||||
public void taskReject(FlowTaskVo flowTaskVo) {
|
||||
if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
|
||||
throw new RuntimeException("任务处于挂起状态");
|
||||
}
|
||||
// 当前任务 task
|
||||
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
||||
// 获取流程定义信息
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
|
||||
// 获取所有节点信息
|
||||
Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
|
||||
// 获取全部节点列表,包含子节点
|
||||
Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
|
||||
// 获取当前任务节点元素
|
||||
FlowElement source = null;
|
||||
if (allElements != null) {
|
||||
for (FlowElement flowElement : allElements) {
|
||||
// 类型为用户节点
|
||||
if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
|
||||
// 获取节点信息
|
||||
source = flowElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 目的获取所有跳转到的节点 targetIds
|
||||
// 获取当前节点的所有父级用户任务节点
|
||||
// 深度优先算法思想:延边迭代深入
|
||||
List<UserTask> parentUserTaskList = FlowableUtils.iteratorFindParentUserTasks(source, null, null);
|
||||
if (parentUserTaskList == null || parentUserTaskList.size() == 0) {
|
||||
throw new RuntimeException("当前节点为初始任务节点,不能驳回");
|
||||
}
|
||||
// 获取活动 ID 即节点 Key
|
||||
List<String> parentUserTaskKeyList = new ArrayList<>();
|
||||
parentUserTaskList.forEach(item -> parentUserTaskKeyList.add(item.getId()));
|
||||
// 获取全部历史节点活动实例,即已经走过的节点历史,数据采用开始时间升序
|
||||
List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
|
||||
// 数据清洗,将回滚导致的脏数据清洗掉
|
||||
List<String> lastHistoricTaskInstanceList = FlowableUtils.historicTaskInstanceClean(allElements, historicTaskInstanceList);
|
||||
// 此时历史任务实例为倒序,获取最后走的节点
|
||||
List<String> targetIds = new ArrayList<>();
|
||||
// 循环结束标识,遇到当前目标节点的次数
|
||||
int number = 0;
|
||||
StringBuilder parentHistoricTaskKey = new StringBuilder();
|
||||
for (String historicTaskInstanceKey : lastHistoricTaskInstanceList) {
|
||||
// 当会签时候会出现特殊的,连续都是同一个节点历史数据的情况,这种时候跳过
|
||||
if (parentHistoricTaskKey.toString().equals(historicTaskInstanceKey)) {
|
||||
continue;
|
||||
}
|
||||
parentHistoricTaskKey = new StringBuilder(historicTaskInstanceKey);
|
||||
if (historicTaskInstanceKey.equals(task.getTaskDefinitionKey())) {
|
||||
number++;
|
||||
}
|
||||
// 在数据清洗后,历史节点就是唯一一条从起始到当前节点的历史记录,理论上每个点只会出现一次
|
||||
// 在流程中如果出现循环,那么每次循环中间的点也只会出现一次,再出现就是下次循环
|
||||
// number == 1,第一次遇到当前节点
|
||||
// number == 2,第二次遇到,代表最后一次的循环范围
|
||||
if (number == 2) {
|
||||
break;
|
||||
}
|
||||
// 如果当前历史节点,属于父级的节点,说明最后一次经过了这个点,需要退回这个点
|
||||
if (parentUserTaskKeyList.contains(historicTaskInstanceKey)) {
|
||||
targetIds.add(historicTaskInstanceKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 目的获取所有需要被跳转的节点 currentIds
|
||||
// 取其中一个父级任务,因为后续要么存在公共网关,要么就是串行公共线路
|
||||
UserTask oneUserTask = parentUserTaskList.get(0);
|
||||
// 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
|
||||
List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
|
||||
List<String> runTaskKeyList = new ArrayList<>();
|
||||
runTaskList.forEach(item -> runTaskKeyList.add(item.getTaskDefinitionKey()));
|
||||
// 需驳回任务列表
|
||||
List<String> currentIds = new ArrayList<>();
|
||||
// 通过父级网关的出口连线,结合 runTaskList 比对,获取需要撤回的任务
|
||||
List<UserTask> currentUserTaskList = FlowableUtils.iteratorFindChildUserTasks(oneUserTask, runTaskKeyList, null, null);
|
||||
currentUserTaskList.forEach(item -> currentIds.add(item.getId()));
|
||||
|
||||
|
||||
// 规定:并行网关之前节点必须需存在唯一用户任务节点,如果出现多个任务节点,则并行网关节点默认为结束节点,原因为不考虑多对多情况
|
||||
if (targetIds.size() > 1 && currentIds.size() > 1) {
|
||||
throw new RuntimeException("任务出现多对多情况,无法撤回");
|
||||
}
|
||||
|
||||
// 循环获取那些需要被撤回的节点的ID,用来设置驳回原因
|
||||
List<String> currentTaskIds = new ArrayList<>();
|
||||
currentIds.forEach(currentId -> runTaskList.forEach(runTask -> {
|
||||
if (currentId.equals(runTask.getTaskDefinitionKey())) {
|
||||
currentTaskIds.add(runTask.getId());
|
||||
}
|
||||
}));
|
||||
// 设置驳回意见
|
||||
currentTaskIds.forEach(item -> taskService.addComment(item, task.getProcessInstanceId(), FlowComment.REJECT.getType(), flowTaskVo.getComment()));
|
||||
|
||||
try {
|
||||
// 如果父级任务多于 1 个,说明当前节点不是并行节点,原因为不考虑多对多情况
|
||||
if (targetIds.size() > 1) {
|
||||
// 1 对 多任务跳转,currentIds 当前节点(1),targetIds 跳转到的节点(多)
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(task.getProcessInstanceId()).
|
||||
moveSingleActivityIdToActivityIds(currentIds.get(0), targetIds).changeState();
|
||||
}
|
||||
// 如果父级任务只有一个,因此当前任务可能为网关中的任务
|
||||
if (targetIds.size() == 1) {
|
||||
// 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetIds.get(0) 跳转到的节点(1)
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(task.getProcessInstanceId())
|
||||
.moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)).changeState();
|
||||
}
|
||||
} catch (FlowableObjectNotFoundException e) {
|
||||
throw new RuntimeException("未找到流程实例,流程可能已发生变化");
|
||||
} catch (FlowableException e) {
|
||||
throw new RuntimeException("无法取消或开始活动");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void taskReturn(FlowTaskVo flowTaskVo) {
|
||||
if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
|
||||
throw new RuntimeException("任务处于挂起状态");
|
||||
}
|
||||
// 当前任务 task
|
||||
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
||||
// 获取流程定义信息
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
|
||||
// 获取所有节点信息
|
||||
Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
|
||||
// 获取全部节点列表,包含子节点
|
||||
Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
|
||||
// 获取当前任务节点元素
|
||||
FlowElement source = null;
|
||||
// 获取跳转的节点元素
|
||||
FlowElement target = null;
|
||||
if (allElements != null) {
|
||||
for (FlowElement flowElement : allElements) {
|
||||
// 当前任务节点元素
|
||||
if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
|
||||
source = flowElement;
|
||||
}
|
||||
// 跳转的节点元素
|
||||
if (flowElement.getId().equals(flowTaskVo.getTargetKey())) {
|
||||
target = flowElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 从当前节点向前扫描
|
||||
// 如果存在路线上不存在目标节点,说明目标节点是在网关上或非同一路线上,不可跳转
|
||||
// 否则目标节点相对于当前节点,属于串行
|
||||
Boolean isSequential = FlowableUtils.iteratorCheckSequentialReferTarget(source, flowTaskVo.getTargetKey(), null, null);
|
||||
if (!isSequential) {
|
||||
throw new RuntimeException("当前节点相对于目标节点,不属于串行关系,无法回退");
|
||||
}
|
||||
|
||||
|
||||
// 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
|
||||
List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
|
||||
List<String> runTaskKeyList = new ArrayList<>();
|
||||
runTaskList.forEach(item -> runTaskKeyList.add(item.getTaskDefinitionKey()));
|
||||
// 需退回任务列表
|
||||
List<String> currentIds = new ArrayList<>();
|
||||
// 通过父级网关的出口连线,结合 runTaskList 比对,获取需要撤回的任务
|
||||
List<UserTask> currentUserTaskList = FlowableUtils.iteratorFindChildUserTasks(target, runTaskKeyList, null, null);
|
||||
currentUserTaskList.forEach(item -> currentIds.add(item.getId()));
|
||||
|
||||
// 循环获取那些需要被撤回的节点的ID,用来设置驳回原因
|
||||
List<String> currentTaskIds = new ArrayList<>();
|
||||
currentIds.forEach(currentId -> runTaskList.forEach(runTask -> {
|
||||
if (currentId.equals(runTask.getTaskDefinitionKey())) {
|
||||
currentTaskIds.add(runTask.getId());
|
||||
}
|
||||
}));
|
||||
// 设置回退意见
|
||||
for (String currentTaskId : currentTaskIds) {
|
||||
taskService.addComment(currentTaskId, task.getProcessInstanceId(), FlowComment.REBACK.getType(), flowTaskVo.getComment());
|
||||
}
|
||||
|
||||
try {
|
||||
// 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(task.getProcessInstanceId())
|
||||
.moveActivityIdsToSingleActivityId(currentIds, flowTaskVo.getTargetKey()).changeState();
|
||||
} catch (FlowableObjectNotFoundException e) {
|
||||
throw new RuntimeException("未找到流程实例,流程可能已发生变化");
|
||||
} catch (FlowableException e) {
|
||||
throw new RuntimeException("无法取消或开始活动");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有可回退的节点
|
||||
*
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R findReturnTaskList(FlowTaskVo flowTaskVo) {
|
||||
// 当前任务 task
|
||||
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
||||
// 获取流程定义信息
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
|
||||
// 获取所有节点信息,暂不考虑子流程情况
|
||||
Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
|
||||
Collection<FlowElement> flowElements = process.getFlowElements();
|
||||
// 获取当前任务节点元素
|
||||
UserTask source = null;
|
||||
if (flowElements != null) {
|
||||
for (FlowElement flowElement : flowElements) {
|
||||
// 类型为用户节点
|
||||
if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
|
||||
source = (UserTask) flowElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取节点的所有路线
|
||||
List<List<UserTask>> roads = FlowableUtils.findRoad(source, null, null, null);
|
||||
// 可回退的节点列表
|
||||
List<UserTask> userTaskList = new ArrayList<>();
|
||||
for (List<UserTask> road : roads) {
|
||||
if (userTaskList.size() == 0) {
|
||||
// 还没有可回退节点直接添加
|
||||
userTaskList = road;
|
||||
} else {
|
||||
// 如果已有回退节点,则比对取交集部分
|
||||
userTaskList.retainAll(road);
|
||||
}
|
||||
}
|
||||
return R.success(userTaskList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
@Override
|
||||
public void deleteTask(FlowTaskVo flowTaskVo) {
|
||||
// todo 待确认删除任务是物理删除任务 还是逻辑删除,让这个任务直接通过?
|
||||
taskService.deleteTask(flowTaskVo.getTaskId(),flowTaskVo.getComment());
|
||||
}
|
||||
|
||||
/**
|
||||
* 认领/签收任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void claim(FlowTaskVo flowTaskVo) {
|
||||
taskService.claim(flowTaskVo.getTaskId(), flowTaskVo.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消认领/签收任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void unClaim(FlowTaskVo flowTaskVo) {
|
||||
taskService.unclaim(flowTaskVo.getTaskId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 委派任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delegateTask(FlowTaskVo flowTaskVo) {
|
||||
taskService.delegateTask(flowTaskVo.getTaskId(), flowTaskVo.getAssignee());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转办任务
|
||||
*
|
||||
* @param flowTaskVo 请求实体参数
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void assignTask(FlowTaskVo flowTaskVo) {
|
||||
taskService.setAssignee(flowTaskVo.getTaskId(),flowTaskVo.getComment());
|
||||
}
|
||||
|
||||
/**
|
||||
* 我发起的流程
|
||||
*
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R myProcess(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
||||
.startedBy(userId.toString())
|
||||
.orderByProcessInstanceStartTime()
|
||||
.desc();
|
||||
List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage(pageNum - 1, pageSize);
|
||||
page.setTotal(historicProcessInstanceQuery.count());
|
||||
List<FlowTaskDto> flowList = new ArrayList<>();
|
||||
for (HistoricProcessInstance hisIns : historicProcessInstances) {
|
||||
FlowTaskDto flowTask = new FlowTaskDto();
|
||||
flowTask.setCreateTime(hisIns.getStartTime());
|
||||
flowTask.setFinishTime(hisIns.getEndTime());
|
||||
flowTask.setProcInsId(hisIns.getId());
|
||||
|
||||
// 计算耗时
|
||||
if (Objects.nonNull(hisIns.getEndTime())) {
|
||||
long time = hisIns.getEndTime().getTime() - hisIns.getStartTime().getTime();
|
||||
flowTask.setDuration(getDate(time));
|
||||
} else {
|
||||
long time = System.currentTimeMillis() - hisIns.getStartTime().getTime();
|
||||
flowTask.setDuration(getDate(time));
|
||||
}
|
||||
// 流程定义信息
|
||||
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionId(hisIns.getProcessDefinitionId())
|
||||
.singleResult();
|
||||
flowTask.setDeployId(pd.getDeploymentId());
|
||||
flowTask.setProcDefName(pd.getName());
|
||||
flowTask.setProcDefVersion(pd.getVersion());
|
||||
flowTask.setCategory(pd.getCategory());
|
||||
flowTask.setProcDefVersion(pd.getVersion());
|
||||
// 当前所处流程 todo: 本地启动放开以下注释
|
||||
// List<Task> taskList = taskService.createTaskQuery().processInstanceId(hisIns.getId()).list();
|
||||
// if (CollectionUtils.isNotEmpty(taskList)) {
|
||||
// flowTask.setTaskId(taskList.get(0).getId());
|
||||
// } else {
|
||||
// List<HistoricTaskInstance> historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisIns.getId()).orderByHistoricTaskInstanceEndTime().desc().list();
|
||||
// flowTask.setTaskId(historicTaskInstance.get(0).getId());
|
||||
// }
|
||||
flowList.add(flowTask);
|
||||
}
|
||||
page.setRecords(flowList);
|
||||
return R.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消申请
|
||||
*
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R stopProcess(FlowTaskVo flowTaskVo) {
|
||||
List<Task> task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).list();
|
||||
if (CollectionUtils.isEmpty(task)) {
|
||||
throw new RuntimeException("流程未启动或已执行完成,取消申请失败");
|
||||
}
|
||||
|
||||
ProcessInstance processInstance =
|
||||
runtimeService.createProcessInstanceQuery().processInstanceId(flowTaskVo.getInstanceId()).singleResult();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
|
||||
if (Objects.nonNull(bpmnModel)) {
|
||||
Process process = bpmnModel.getMainProcess();
|
||||
List<EndEvent> endNodes = process.findFlowElementsOfType(EndEvent.class, false);
|
||||
if (CollectionUtils.isNotEmpty(endNodes)) {
|
||||
Authentication.setAuthenticatedUserId(LoginUtils.getUserId().toString());
|
||||
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
|
||||
// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
|
||||
String endId = endNodes.get(0).getId();
|
||||
List<Execution> executions =
|
||||
runtimeService.createExecutionQuery().parentId(processInstance.getProcessInstanceId()).list();
|
||||
List<String> executionIds = new ArrayList<>();
|
||||
executions.forEach(execution -> executionIds.add(execution.getId()));
|
||||
runtimeService.createChangeActivityStateBuilder().moveExecutionsToSingleActivityId(executionIds,
|
||||
endId).changeState();
|
||||
}
|
||||
}
|
||||
|
||||
return R.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回流程 目前存在错误
|
||||
*
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R revokeProcess(FlowTaskVo flowTaskVo) {
|
||||
Task task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).singleResult();
|
||||
if (task == null) {
|
||||
throw new RuntimeException("流程未启动或已执行完成,无法撤回");
|
||||
}
|
||||
|
||||
List<HistoricTaskInstance> htiList = historyService.createHistoricTaskInstanceQuery()
|
||||
.processInstanceId(task.getProcessInstanceId())
|
||||
.orderByTaskCreateTime()
|
||||
.asc()
|
||||
.list();
|
||||
String myTaskId = null;
|
||||
HistoricTaskInstance myTask = null;
|
||||
for (HistoricTaskInstance hti : htiList) {
|
||||
if (LoginUtils.getUserId().toString().equals(hti.getAssignee())) {
|
||||
myTaskId = hti.getId();
|
||||
myTask = hti;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (null == myTaskId) {
|
||||
throw new RuntimeException("该任务非当前用户提交,无法撤回");
|
||||
}
|
||||
|
||||
String processDefinitionId = myTask.getProcessDefinitionId();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
|
||||
//变量
|
||||
// Map<String, VariableInstance> variables = runtimeService.getVariableInstances(currentTask.getExecutionId());
|
||||
String myActivityId = null;
|
||||
List<HistoricActivityInstance> haiList = historyService.createHistoricActivityInstanceQuery()
|
||||
.executionId(myTask.getExecutionId()).finished().list();
|
||||
for (HistoricActivityInstance hai : haiList) {
|
||||
if (myTaskId.equals(hai.getTaskId())) {
|
||||
myActivityId = hai.getActivityId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
FlowNode myFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(myActivityId);
|
||||
|
||||
Execution execution = runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();
|
||||
String activityId = execution.getActivityId();
|
||||
FlowNode flowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(activityId);
|
||||
|
||||
//记录原活动方向
|
||||
List<SequenceFlow> oriSequenceFlows = new ArrayList<>(flowNode.getOutgoingFlows());
|
||||
|
||||
|
||||
return R.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 代办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R todoList(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||
.active()
|
||||
.includeProcessVariables()
|
||||
.taskAssignee(userId.toString())
|
||||
.orderByTaskCreateTime().desc();
|
||||
page.setTotal(taskQuery.count());
|
||||
List<Task> taskList = taskQuery.listPage(pageNum - 1, pageSize);
|
||||
List<FlowTaskDto> flowList = new ArrayList<>();
|
||||
for (Task task : taskList) {
|
||||
FlowTaskDto flowTask = new FlowTaskDto();
|
||||
// 当前流程信息
|
||||
flowTask.setTaskId(task.getId());
|
||||
flowTask.setTaskDefKey(task.getTaskDefinitionKey());
|
||||
flowTask.setCreateTime(task.getCreateTime());
|
||||
flowTask.setProcDefId(task.getProcessDefinitionId());
|
||||
flowTask.setTaskName(task.getName());
|
||||
// 流程定义信息
|
||||
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionId(task.getProcessDefinitionId())
|
||||
.singleResult();
|
||||
flowTask.setDeployId(pd.getDeploymentId());
|
||||
flowTask.setProcDefName(pd.getName());
|
||||
flowTask.setProcDefVersion(pd.getVersion());
|
||||
flowTask.setProcInsId(task.getProcessInstanceId());
|
||||
|
||||
// 流程发起人信息
|
||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(task.getProcessInstanceId())
|
||||
.singleResult();
|
||||
SysUser startUser = sysUserService.selectUserById(Long.parseLong(historicProcessInstance.getStartUserId()));
|
||||
// SysUser startUser = sysUserService.selectUserById(Long.parseLong(task.getAssignee()));
|
||||
flowTask.setStartUserId(startUser.getNickName());
|
||||
flowTask.setStartUserName(startUser.getNickName());
|
||||
flowTask.setStartDeptName(startUser.getDept().getDeptName());
|
||||
flowList.add(flowTask);
|
||||
}
|
||||
|
||||
page.setRecords(flowList);
|
||||
return R.success(page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 已办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R finishedList(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
.includeProcessVariables()
|
||||
.finished()
|
||||
.taskAssignee(userId.toString())
|
||||
.orderByHistoricTaskInstanceEndTime()
|
||||
.desc();
|
||||
List<HistoricTaskInstance> historicTaskInstanceList = taskInstanceQuery.listPage(pageNum - 1, pageSize);
|
||||
List<FlowTaskDto> hisTaskList = Lists.newArrayList();
|
||||
for (HistoricTaskInstance histTask : historicTaskInstanceList) {
|
||||
FlowTaskDto flowTask = new FlowTaskDto();
|
||||
// 当前流程信息
|
||||
flowTask.setTaskId(histTask.getId());
|
||||
// 审批人员信息
|
||||
flowTask.setCreateTime(histTask.getCreateTime());
|
||||
flowTask.setFinishTime(histTask.getEndTime());
|
||||
flowTask.setDuration(getDate(histTask.getDurationInMillis()));
|
||||
flowTask.setProcDefId(histTask.getProcessDefinitionId());
|
||||
flowTask.setTaskDefKey(histTask.getTaskDefinitionKey());
|
||||
flowTask.setTaskName(histTask.getName());
|
||||
|
||||
// 流程定义信息
|
||||
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionId(histTask.getProcessDefinitionId())
|
||||
.singleResult();
|
||||
flowTask.setDeployId(pd.getDeploymentId());
|
||||
flowTask.setProcDefName(pd.getName());
|
||||
flowTask.setProcDefVersion(pd.getVersion());
|
||||
flowTask.setProcInsId(histTask.getProcessInstanceId());
|
||||
flowTask.setHisProcInsId(histTask.getProcessInstanceId());
|
||||
|
||||
// 流程发起人信息
|
||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(histTask.getProcessInstanceId())
|
||||
.singleResult();
|
||||
SysUser startUser = sysUserService.selectUserById(Long.parseLong(historicProcessInstance.getStartUserId()));
|
||||
flowTask.setStartUserId(startUser.getNickName());
|
||||
flowTask.setStartUserName(startUser.getNickName());
|
||||
flowTask.setStartDeptName(startUser.getDept().getDeptName());
|
||||
hisTaskList.add(flowTask);
|
||||
}
|
||||
page.setTotal(hisTaskList.size());
|
||||
page.setRecords(hisTaskList);
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// result.put("result",page);
|
||||
// result.put("finished",true);
|
||||
return R.success(page);
|
||||
}
|
||||
|
||||
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
||||
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
||||
return t -> seen.add(keyExtractor.apply(t));
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程历史流转记录
|
||||
*
|
||||
* @param procInsId 流程实例Id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R flowRecord(String procInsId, String deployId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (StringUtils.isNotBlank(procInsId)) {
|
||||
List<HistoricActivityInstance> list = historyService
|
||||
.createHistoricActivityInstanceQuery()
|
||||
.processInstanceId(procInsId)
|
||||
.orderByHistoricActivityInstanceStartTime()
|
||||
.desc().list();
|
||||
List<FlowTaskDto> hisFlowList = new ArrayList<>();
|
||||
for (HistoricActivityInstance histIns : list) {
|
||||
if (StringUtils.isNotBlank(histIns.getTaskId())) {
|
||||
FlowTaskDto flowTask = new FlowTaskDto();
|
||||
flowTask.setTaskId(histIns.getTaskId());
|
||||
flowTask.setTaskName(histIns.getActivityName());
|
||||
flowTask.setCreateTime(histIns.getStartTime());
|
||||
flowTask.setFinishTime(histIns.getEndTime());
|
||||
if (StringUtils.isNotBlank(histIns.getAssignee())) {
|
||||
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(histIns.getAssignee()));
|
||||
flowTask.setAssigneeId(sysUser.getUserId());
|
||||
flowTask.setAssigneeName(sysUser.getNickName());
|
||||
flowTask.setDeptName(sysUser.getDept().getDeptName());
|
||||
}
|
||||
// 展示审批人员
|
||||
List<HistoricIdentityLink> linksForTask = historyService.getHistoricIdentityLinksForTask(histIns.getTaskId());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (HistoricIdentityLink identityLink : linksForTask) {
|
||||
if ("candidate".equals(identityLink.getType())) {
|
||||
if (StringUtils.isNotBlank(identityLink.getUserId())) {
|
||||
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
|
||||
stringBuilder.append(sysUser.getNickName()).append(",");
|
||||
}
|
||||
if (StringUtils.isNotBlank(identityLink.getGroupId())) {
|
||||
SysRole sysRole = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
|
||||
stringBuilder.append(sysRole.getRoleName()).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(stringBuilder)) {
|
||||
flowTask.setCandidate(stringBuilder.substring(0, stringBuilder.length() - 1));
|
||||
}
|
||||
|
||||
flowTask.setDuration(histIns.getDurationInMillis() == null || histIns.getDurationInMillis() == 0 ? null : getDate(histIns.getDurationInMillis()));
|
||||
// 获取意见评论内容
|
||||
List<Comment> commentList = taskService.getProcessInstanceComments(histIns.getProcessInstanceId());
|
||||
commentList.forEach(comment -> {
|
||||
if (histIns.getTaskId().equals(comment.getTaskId())) {
|
||||
flowTask.setComment(FlowCommentDto.builder().type(comment.getType()).comment(comment.getFullMessage()).build());
|
||||
}
|
||||
});
|
||||
hisFlowList.add(flowTask);
|
||||
}
|
||||
}
|
||||
map.put("flowList", hisFlowList);
|
||||
// // 查询当前任务是否完成
|
||||
// List<Task> taskList = taskService.createTaskQuery().processInstanceId(procInsId).list();
|
||||
// if (CollectionUtils.isNotEmpty(taskList)) {
|
||||
// map.put("finished", true);
|
||||
// } else {
|
||||
// map.put("finished", false);
|
||||
// }
|
||||
}
|
||||
// 第一次申请获取初始化表单
|
||||
if (StringUtils.isNotBlank(deployId)) {
|
||||
SysForm sysForm = sysInstanceFormService.selectSysDeployFormByDeployId(deployId);
|
||||
if (Objects.isNull(sysForm)) {
|
||||
return R.error("请先配置流程表单");
|
||||
}
|
||||
map.put("formData", JSONObject.parseObject(sysForm.getFormContent()));
|
||||
}
|
||||
return R.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务ID查询挂载的表单信息
|
||||
*
|
||||
* @param taskId 任务Id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Task getTaskForm(String taskId) {
|
||||
return taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程过程图
|
||||
*
|
||||
* @param processId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public InputStream diagram(String processId) {
|
||||
String processDefinitionId;
|
||||
// 获取当前的流程实例
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
|
||||
// 如果流程已经结束,则得到结束节点
|
||||
if (Objects.isNull(processInstance)) {
|
||||
HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processId).singleResult();
|
||||
|
||||
processDefinitionId = pi.getProcessDefinitionId();
|
||||
} else {// 如果流程没有结束,则取当前活动节点
|
||||
// 根据流程实例ID获得当前处于活动状态的ActivityId合集
|
||||
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
|
||||
processDefinitionId = pi.getProcessDefinitionId();
|
||||
}
|
||||
|
||||
// 获得活动的节点
|
||||
List<HistoricActivityInstance> highLightedFlowList = historyService.createHistoricActivityInstanceQuery().processInstanceId(processId).orderByHistoricActivityInstanceStartTime().asc().list();
|
||||
|
||||
List<String> highLightedFlows = new ArrayList<>();
|
||||
List<String> highLightedNodes = new ArrayList<>();
|
||||
//高亮线
|
||||
for (HistoricActivityInstance tempActivity : highLightedFlowList) {
|
||||
if ("sequenceFlow".equals(tempActivity.getActivityType())) {
|
||||
//高亮线
|
||||
highLightedFlows.add(tempActivity.getActivityId());
|
||||
} else {
|
||||
//高亮节点
|
||||
highLightedNodes.add(tempActivity.getActivityId());
|
||||
}
|
||||
}
|
||||
|
||||
//获取流程图
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration();
|
||||
//获取自定义图片生成器
|
||||
ProcessDiagramGenerator diagramGenerator = new CustomProcessDiagramGenerator();
|
||||
InputStream in = diagramGenerator.generateDiagram(bpmnModel, "png", highLightedNodes, highLightedFlows, configuration.getActivityFontName(),
|
||||
configuration.getLabelFontName(), configuration.getAnnotationFontName(), configuration.getClassLoader(), 1.0, true);
|
||||
return in;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程执行过程
|
||||
*
|
||||
* @param procInsId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R getFlowViewer(String procInsId) {
|
||||
// 构建查询条件
|
||||
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
|
||||
.processInstanceId(procInsId);
|
||||
// 获取流程实例已完成的节点
|
||||
List<String> finishedTaskList = query.finished().list()
|
||||
.stream().distinct().map(HistoricActivityInstance::getActivityId)
|
||||
.collect(Collectors.toList());
|
||||
// 获取流程实例正在待办的节点
|
||||
List<String> unfinishedTaskList = query.unfinished().list()
|
||||
.stream().distinct().map(HistoricActivityInstance::getActivityId)
|
||||
.collect(Collectors.toList());
|
||||
// 构建视图类
|
||||
return R.success(new FlowViewerVo(finishedTaskList, unfinishedTaskList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程变量
|
||||
*
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R processVariables(String taskId) {
|
||||
// 流程变量
|
||||
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().finished().taskId(taskId).singleResult();
|
||||
if (Objects.nonNull(historicTaskInstance)) {
|
||||
return R.success(historicTaskInstance.getProcessVariables());
|
||||
} else {
|
||||
Map<String, Object> variables = taskService.getVariables(taskId);
|
||||
return R.success(variables);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一节点
|
||||
*
|
||||
* @param flowTaskVo 任务
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R getNextFlowNode(FlowTaskVo flowTaskVo) {
|
||||
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
||||
FlowNextDto flowNextDto = new FlowNextDto();
|
||||
if (Objects.nonNull(task)) {
|
||||
List<UserTask> nextUserTask = FindNextNodeUtil.getNextUserTasks(repositoryService, task, new HashMap<>());
|
||||
if (CollectionUtils.isNotEmpty(nextUserTask)) {
|
||||
for (UserTask userTask : nextUserTask) {
|
||||
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
|
||||
// 会签节点
|
||||
if (Objects.nonNull(multiInstance)) {
|
||||
List<SysUser> list = sysUserService.selectUserList(new SysUser());
|
||||
|
||||
flowNextDto.setVars(ProcessConstants.PROCESS_MULTI_INSTANCE_USER);
|
||||
flowNextDto.setType(ProcessConstants.PROCESS_MULTI_INSTANCE);
|
||||
flowNextDto.setUserList(list);
|
||||
} else {
|
||||
|
||||
// 读取自定义节点属性 判断是否是否需要动态指定任务接收人员、组
|
||||
String dataType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE);
|
||||
String userType = userTask.getAttributeValue(ProcessConstants.NAMASPASE, ProcessConstants.PROCESS_CUSTOM_USER_TYPE);
|
||||
|
||||
if (ProcessConstants.DATA_TYPE.equals(dataType)) {
|
||||
// 指定单个人员
|
||||
if (ProcessConstants.USER_TYPE_ASSIGNEE.equals(userType)) {
|
||||
List<SysUser> list = sysUserService.selectUserList(new SysUser());
|
||||
|
||||
flowNextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
|
||||
flowNextDto.setType(ProcessConstants.USER_TYPE_ASSIGNEE);
|
||||
flowNextDto.setUserList(list);
|
||||
}
|
||||
// 候选人员(多个)
|
||||
if (ProcessConstants.USER_TYPE_USERS.equals(userType)) {
|
||||
List<SysUser> list = sysUserService.selectUserList(new SysUser());
|
||||
|
||||
flowNextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
|
||||
flowNextDto.setType(ProcessConstants.USER_TYPE_USERS);
|
||||
flowNextDto.setUserList(list);
|
||||
}
|
||||
// 候选组
|
||||
if (ProcessConstants.USER_TYPE_ROUPS.equals(userType)) {
|
||||
List<SysRole> sysRoles = sysRoleService.selectRoleAll();
|
||||
|
||||
flowNextDto.setVars(ProcessConstants.PROCESS_APPROVAL);
|
||||
flowNextDto.setType(ProcessConstants.USER_TYPE_ROUPS);
|
||||
flowNextDto.setRoleList(sysRoles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return R.success("流程已完结", null);
|
||||
}
|
||||
}
|
||||
return R.success(flowNextDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程完成时间处理
|
||||
*
|
||||
* @param ms
|
||||
* @return
|
||||
*/
|
||||
private String getDate(long ms) {
|
||||
|
||||
long day = ms / (24 * 60 * 60 * 1000);
|
||||
long hour = (ms / (60 * 60 * 1000) - day * 24);
|
||||
long minute = ((ms / (60 * 1000)) - day * 24 * 60 - hour * 60);
|
||||
long second = (ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60);
|
||||
|
||||
if (day > 0) {
|
||||
return day + "天" + hour + "小时" + minute + "分钟";
|
||||
}
|
||||
if (hour > 0) {
|
||||
return hour + "小时" + minute + "分钟";
|
||||
}
|
||||
if (minute > 0) {
|
||||
return minute + "分钟";
|
||||
}
|
||||
if (second > 0) {
|
||||
return second + "秒";
|
||||
} else {
|
||||
return 0 + "秒";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import com.ruoyi.workflow.service.ISysDeployFormService;
|
||||
import com.ruoyi.system.domain.SysDeployForm;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
import com.ruoyi.system.mapper.SysDeployFormMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 流程实例关联表单Service业务层处理
|
||||
*
|
||||
* @author XuanXuan Xuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Service
|
||||
public class SysDeployFormServiceImpl implements ISysDeployFormService {
|
||||
|
||||
@Autowired
|
||||
private SysDeployFormMapper sysDeployFormMapper;
|
||||
|
||||
/**
|
||||
* 查询流程实例关联表单
|
||||
*
|
||||
* @param id 流程实例关联表单ID
|
||||
* @return 流程实例关联表单
|
||||
*/
|
||||
@Override
|
||||
public SysDeployForm selectSysDeployFormById(Long id) {
|
||||
return sysDeployFormMapper.selectSysDeployFormById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程实例关联表单列表
|
||||
*
|
||||
* @param sysDeployForm 流程实例关联表单
|
||||
* @return 流程实例关联表单
|
||||
*/
|
||||
@Override
|
||||
public List<SysDeployForm> selectSysDeployFormList(SysDeployForm sysDeployForm) {
|
||||
return sysDeployFormMapper.selectSysDeployFormList(sysDeployForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流程实例关联表单
|
||||
*
|
||||
* @param sysDeployForm 流程实例关联表单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysDeployForm(SysDeployForm sysDeployForm) {
|
||||
SysForm sysForm = sysDeployFormMapper.selectSysDeployFormByDeployId(sysDeployForm.getDeployId());
|
||||
if (Objects.isNull(sysForm)) {
|
||||
return sysDeployFormMapper.insertSysDeployForm(sysDeployForm);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程实例关联表单
|
||||
*
|
||||
* @param sysDeployForm 流程实例关联表单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysDeployForm(SysDeployForm sysDeployForm) {
|
||||
return sysDeployFormMapper.updateSysDeployForm(sysDeployForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除流程实例关联表单
|
||||
*
|
||||
* @param ids 需要删除的流程实例关联表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDeployFormByIds(Long[] ids) {
|
||||
return sysDeployFormMapper.deleteSysDeployFormByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程实例关联表单信息
|
||||
*
|
||||
* @param id 流程实例关联表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDeployFormById(Long id) {
|
||||
return sysDeployFormMapper.deleteSysDeployFormById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程挂着的表单
|
||||
*
|
||||
* @param deployId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SysForm selectSysDeployFormByDeployId(String deployId) {
|
||||
return sysDeployFormMapper.selectSysDeployFormByDeployId(deployId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.workflow.service.ISysFormService;
|
||||
import com.ruoyi.system.domain.SysForm;
|
||||
import com.ruoyi.system.mapper.SysFormMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程表单Service业务层处理
|
||||
*
|
||||
* @author XuanXuan Xuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Service
|
||||
public class SysFormServiceImpl implements ISysFormService {
|
||||
|
||||
@Autowired
|
||||
private SysFormMapper sysFormMapper;
|
||||
|
||||
/**
|
||||
* 查询流程表单
|
||||
*
|
||||
* @param formId 流程表单ID
|
||||
* @return 流程表单
|
||||
*/
|
||||
@Override
|
||||
public SysForm selectSysFormById(Long formId) {
|
||||
return sysFormMapper.selectSysFormById(formId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程表单列表
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 流程表单
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysForm> selectSysFormPage(SysForm sysForm, PageQuery pageQuery) {
|
||||
return TableDataInfo.build(sysFormMapper.selectSysFormPage(pageQuery.build(), sysForm));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程表单列表
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 流程表单
|
||||
*/
|
||||
@Override
|
||||
public List<SysForm> selectSysFormList(SysForm sysForm) {
|
||||
return sysFormMapper.selectSysFormList(sysForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流程表单
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysForm(SysForm sysForm) {
|
||||
sysForm.setCreateTime(DateUtils.getNowDate());
|
||||
return sysFormMapper.insertSysForm(sysForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程表单
|
||||
*
|
||||
* @param sysForm 流程表单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysForm(SysForm sysForm) {
|
||||
sysForm.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysFormMapper.updateSysForm(sysForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除流程表单
|
||||
*
|
||||
* @param formIds 需要删除的流程表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysFormByIds(Long[] formIds) {
|
||||
return sysFormMapper.deleteSysFormByIds(formIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程表单信息
|
||||
*
|
||||
* @param formId 流程表单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysFormById(Long formId) {
|
||||
return sysFormMapper.deleteSysFormById(formId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
import com.ruoyi.workflow.service.ISysTaskFormService;
|
||||
import com.ruoyi.system.domain.SysTaskForm;
|
||||
import com.ruoyi.system.mapper.SysTaskFormMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程任务关联单Service业务层处理
|
||||
*
|
||||
* @author XuanXuan Xuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Service
|
||||
public class SysTaskFormServiceImpl implements ISysTaskFormService {
|
||||
|
||||
@Autowired
|
||||
private SysTaskFormMapper sysTaskFormMapper;
|
||||
|
||||
/**
|
||||
* 查询流程任务关联单
|
||||
*
|
||||
* @param id 流程任务关联单ID
|
||||
* @return 流程任务关联单
|
||||
*/
|
||||
@Override
|
||||
public SysTaskForm selectSysTaskFormById(Long id) {
|
||||
return sysTaskFormMapper.selectSysTaskFormById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程任务关联单列表
|
||||
*
|
||||
* @param sysTaskForm 流程任务关联单
|
||||
* @return 流程任务关联单
|
||||
*/
|
||||
@Override
|
||||
public List<SysTaskForm> selectSysTaskFormList(SysTaskForm sysTaskForm) {
|
||||
return sysTaskFormMapper.selectSysTaskFormList(sysTaskForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流程任务关联单
|
||||
*
|
||||
* @param sysTaskForm 流程任务关联单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysTaskForm(SysTaskForm sysTaskForm) {
|
||||
return sysTaskFormMapper.insertSysTaskForm(sysTaskForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程任务关联单
|
||||
*
|
||||
* @param sysTaskForm 流程任务关联单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysTaskForm(SysTaskForm sysTaskForm) {
|
||||
return sysTaskFormMapper.updateSysTaskForm(sysTaskForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除流程任务关联单
|
||||
*
|
||||
* @param ids 需要删除的流程任务关联单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysTaskFormByIds(Long[] ids) {
|
||||
return sysTaskFormMapper.deleteSysTaskFormByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程任务关联单信息
|
||||
*
|
||||
* @param id 流程任务关联单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysTaskFormById(Long id) {
|
||||
return sysTaskFormMapper.deleteSysTaskFormById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.workflow.mapper.FlowCategoryMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.workflow.domain.FlowCategory" id="FlowCategoryResult">
|
||||
<result property="categoryId" column="category_id"/>
|
||||
<result property="categoryName" column="category_name"/>
|
||||
<result property="code" column="code"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -30,9 +30,9 @@
|
||||
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where d.del_flag = '0'
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND dept_id = #{deptId}
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND dept_id = #{deptId}
|
||||
</if>
|
||||
<if test="parentId != null and parentId != 0">
|
||||
AND parent_id = #{parentId}
|
||||
</if>
|
||||
@@ -42,10 +42,6 @@
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="params.dataScope != null and params.dataScope != ''">-->
|
||||
<!-- AND ( ${params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
from sys_form
|
||||
</sql>
|
||||
|
||||
<select id="selectSysFormPage" parameterType="SysForm" resultMap="SysFormResult">
|
||||
<select id="selectSysFormPage" resultMap="SysFormResult">
|
||||
<include refid="selectSysFormVo"/>
|
||||
<where>
|
||||
<if test="from.formName != null and from.formName != ''">
|
||||
@@ -39,7 +39,7 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysFormList" parameterType="SysForm" resultMap="SysFormResult">
|
||||
<select id="selectSysFormList" resultMap="SysFormResult">
|
||||
<include refid="selectSysFormVo"/>
|
||||
<where>
|
||||
<if test="formName != null and formName != ''">and form_name like concat('%', #{formName}, '%')</if>
|
||||
@@ -52,7 +52,7 @@
|
||||
where form_id = #{formId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysForm" parameterType="SysForm" useGeneratedKeys="true" keyProperty="formId">
|
||||
<insert id="insertSysForm" useGeneratedKeys="true" keyProperty="formId">
|
||||
insert into sys_form
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="formName != null">form_name,</if>
|
||||
@@ -74,7 +74,7 @@
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysForm" parameterType="SysForm">
|
||||
<update id="updateSysForm">
|
||||
update sys_form
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="formName != null">form_name = #{formName},</if>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="path" column="path"/>
|
||||
<result property="component" column="component"/>
|
||||
<result property="query" column="query"/>
|
||||
<result property="isFrame" column="is_frame"/>
|
||||
<result property="query" column="query"/>
|
||||
<result property="isFrame" column="is_frame"/>
|
||||
<result property="isCache" column="is_cache"/>
|
||||
<result property="menuType" column="menu_type"/>
|
||||
<result property="visible" column="visible"/>
|
||||
@@ -33,8 +33,8 @@
|
||||
m.menu_name,
|
||||
m.path,
|
||||
m.component,
|
||||
m.`query`,
|
||||
m.visible,
|
||||
m.`query`,
|
||||
m.visible,
|
||||
m.status,
|
||||
ifnull(m.perms, '') as perms,
|
||||
m.is_frame,
|
||||
@@ -75,7 +75,7 @@
|
||||
m.menu_name,
|
||||
m.path,
|
||||
m.component,
|
||||
m.`query`,
|
||||
m.`query`,
|
||||
m.visible,
|
||||
m.status,
|
||||
ifnull(m.perms, '') as perms,
|
||||
|
||||
@@ -60,10 +60,6 @@
|
||||
<if test="role.params.endTime != null and role.params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{role.params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="role.params.dataScope != null and role.params.dataScope != ''">-->
|
||||
<!-- AND ( ${role.params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
@@ -88,10 +84,6 @@
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="params.dataScope != null and params.dataScope != ''">-->
|
||||
<!-- AND ( ${params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
|
||||
@@ -75,9 +75,9 @@
|
||||
r.data_scope,
|
||||
r.status as role_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
</sql>
|
||||
|
||||
<select id="selectPageUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
@@ -108,10 +108,6 @@
|
||||
AND (u.dept_id = #{user.deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{user.deptId},
|
||||
ancestors) ))
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">-->
|
||||
<!-- AND ( ${user.params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
</select>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
@@ -142,10 +138,6 @@
|
||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
ancestors) ))
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="params.dataScope != null and params.dataScope != ''">-->
|
||||
<!-- AND ( ${params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
</select>
|
||||
|
||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
@@ -161,10 +153,6 @@
|
||||
<if test="user.phonenumber != null and user.phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{user.phonenumber}, '%')
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">-->
|
||||
<!-- AND ( ${user.params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
</select>
|
||||
|
||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
@@ -181,10 +169,6 @@
|
||||
<if test="user.phonenumber != null and user.phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{user.phonenumber}, '%')
|
||||
</if>
|
||||
<!-- <!– 数据范围过滤 –>-->
|
||||
<!-- <if test="user.params.dataScope != null and user.params.dataScope != ''">-->
|
||||
<!-- AND ( ${user.params.dataScope} )-->
|
||||
<!-- </if>-->
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
|
||||
Reference in New Issue
Block a user