parent
0e8f4dc504
commit
f450f31300
@ -0,0 +1,14 @@ |
||||
package cn.toesbieya.jxc.api.service.system; |
||||
|
||||
import cn.toesbieya.jxc.common.model.entity.SysUser; |
||||
import cn.toesbieya.jxc.common.model.vo.DepartmentVo; |
||||
|
||||
import java.util.Set; |
||||
|
||||
public interface DepartmentApi { |
||||
//获取用户的数据范围(部门ID集合),返回null说明无需限制
|
||||
Set<Integer> getUserDataScope(SysUser user); |
||||
|
||||
//获取带有全名的部门
|
||||
DepartmentVo getById(int id); |
||||
} |
||||
@ -1,12 +1,12 @@ |
||||
package cn.toesbieya.jxc.common.constant; |
||||
|
||||
public class DocumentConstant { |
||||
public interface DocumentConstant { |
||||
//更新单据ID时的redis锁的键
|
||||
public static final String UPDATE_DOCUMENTS_LOCK_KEY = "UPDATE_DOCUMENTS"; |
||||
String UPDATE_DOCUMENTS_LOCK_KEY = "UPDATE_DOCUMENTS"; |
||||
|
||||
//单据ID的redis缓存的键
|
||||
public static final String DOCUMENT_TYPE_REDIS_KEY = "documentsID"; |
||||
String DOCUMENT_TYPE_REDIS_KEY = "documentsID"; |
||||
|
||||
//单据类型
|
||||
public static final String[] DOCUMENT_TYPE = {"CGDD", "CGRK", "CGTH", "XSDD", "XSCK", "XSTH"}; |
||||
String[] DOCUMENT_TYPE = {"CGDD", "CGRK", "CGTH", "XSDD", "XSCK", "XSTH"}; |
||||
} |
||||
|
||||
@ -1,18 +1,18 @@ |
||||
package cn.toesbieya.jxc.common.constant; |
||||
|
||||
public class SessionConstant { |
||||
public interface SessionConstant { |
||||
//session过期时间,单位秒
|
||||
public static long EXPIRE = 3600 * 8; |
||||
long EXPIRE = 3600 * 8; |
||||
|
||||
//存储用户信息的键的前缀
|
||||
public static String REDIS_NAMESPACE = "sessions:"; |
||||
String REDIS_NAMESPACE = "sessions:"; |
||||
|
||||
//key过期事件的前缀
|
||||
public static String REDIS_EXPIRE_TOPIC_PREFIX = "__keyspace@0__:"; |
||||
String REDIS_EXPIRE_TOPIC_PREFIX = "__keyspace@0__:"; |
||||
|
||||
//http headers中token的字段名
|
||||
public static String TOKEN_KEY = "X-Token"; |
||||
String TOKEN_KEY = "X-Token"; |
||||
|
||||
//区别无活动用户的时间间隔,单位秒
|
||||
public static long NO_ACTION_INTERVAL = 1800; |
||||
long NO_ACTION_INTERVAL = 1800; |
||||
} |
||||
|
||||
@ -1,23 +1,23 @@ |
||||
package cn.toesbieya.jxc.common.constant; |
||||
|
||||
public class SocketConstant { |
||||
public interface SocketConstant { |
||||
//web-socket服务端订阅的redis主题名称
|
||||
public static String REDIS_EVENT_TOPIC_SEND = "socket-event-send"; |
||||
String REDIS_EVENT_TOPIC_SEND = "socket-event-send"; |
||||
|
||||
//指定用户
|
||||
public static int REDIS_EVENT_SPECIFIC = 0; |
||||
int REDIS_EVENT_SPECIFIC = 0; |
||||
//广播
|
||||
public static int REDIS_EVENT_BROADCAST = 1; |
||||
int REDIS_EVENT_BROADCAST = 1; |
||||
//登出
|
||||
public static int REDIS_EVENT_LOGOUT = 2; |
||||
int REDIS_EVENT_LOGOUT = 2; |
||||
|
||||
//存放于redis中的在线用户的ID集合的键
|
||||
public static String REDIS_ONLINE_USER = "socket:online-user"; |
||||
String REDIS_ONLINE_USER = "socket:online-user"; |
||||
//存放于redis中的离线用户的离线时间的键
|
||||
public static String REDIS_OFFLINE_USER = "socket:offline-user"; |
||||
String REDIS_OFFLINE_USER = "socket:offline-user"; |
||||
|
||||
//登出事件
|
||||
public static final String EVENT_LOGOUT = "logout"; |
||||
String EVENT_LOGOUT = "logout"; |
||||
//新消息事件
|
||||
public static final String EVENT_NEW_MESSAGE = "new-message"; |
||||
String EVENT_NEW_MESSAGE = "new-message"; |
||||
} |
||||
|
||||
@ -0,0 +1,15 @@ |
||||
package cn.toesbieya.jxc.common.enumeration; |
||||
|
||||
public enum DataScopeEnum { |
||||
ALL(1), SELF(2), SPECIFIC(3); |
||||
|
||||
private final int code; |
||||
|
||||
DataScopeEnum(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
} |
||||
@ -0,0 +1,22 @@ |
||||
package cn.toesbieya.jxc.common.model.vo; |
||||
|
||||
import cn.toesbieya.jxc.common.model.entity.SysDepartment; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.ToString; |
||||
|
||||
@Data |
||||
@NoArgsConstructor |
||||
@ToString(callSuper = true) |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class DepartmentVo extends SysDepartment { |
||||
String fullname; |
||||
|
||||
public DepartmentVo(SysDepartment parent) { |
||||
this.setId(parent.getId()); |
||||
this.setPid(parent.getPid()); |
||||
this.setName(parent.getName()); |
||||
this.setStatus(parent.getStatus()); |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@ |
||||
package cn.toesbieya.jxc.web.common.interceptor; |
||||
|
||||
import cn.toesbieya.jxc.common.model.vo.Result; |
||||
import cn.toesbieya.jxc.common.model.vo.UserVo; |
||||
import cn.toesbieya.jxc.common.utils.SessionUtil; |
||||
import cn.toesbieya.jxc.web.common.utils.ThreadUtil; |
||||
import cn.toesbieya.jxc.web.common.utils.WebUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.web.servlet.HandlerInterceptor; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
@Slf4j |
||||
public class SecurityInterceptor implements HandlerInterceptor { |
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
||||
UserVo user = SessionUtil.get(request); |
||||
|
||||
if (user == null) { |
||||
WebUtil.responseJson(response, Result.requireLogin()); |
||||
ThreadUtil.clearAll(); |
||||
return false; |
||||
} |
||||
|
||||
ThreadUtil.setUser(user); |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
package cn.toesbieya.jxc.web.common.utils; |
||||
|
||||
import cn.toesbieya.jxc.common.model.vo.UserVo; |
||||
|
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
public class SecurityUtil { |
||||
//获取字符串形式的数据范围,sql中使用 in (${param}) 拼接
|
||||
public static String getScopeParam() { |
||||
UserVo user = ThreadUtil.getUser(); |
||||
if (user == null) return "''"; |
||||
Set<Integer> deptIds = user.getDepartmentIds(); |
||||
if (deptIds == null) return null; |
||||
return deptIds.isEmpty() ? "''" : deptIds.stream().map(String::valueOf).collect(Collectors.joining(",")); |
||||
} |
||||
} |
||||
@ -1,11 +1,11 @@ |
||||
package cn.toesbieya.jxc.message.constant; |
||||
|
||||
public class MsgConstant { |
||||
public static final Integer TYPE_NOTICE = 0; //通知提醒
|
||||
public static final Integer TYPE_ANNOUNCEMENT = 1; //系统公告
|
||||
public static final Integer STATUS_DRAFT = 0; //拟定
|
||||
public static final Integer STATUS_PUBLISHED = 1; //已发布
|
||||
public static final Integer STATUS_WITHDREW = 2; //已撤回
|
||||
public static final Integer TO_ALL = 1; //发送给全体用户
|
||||
public static final Integer TO_RANGE = 0; //已发送给指定用户
|
||||
public interface MsgConstant { |
||||
Integer TYPE_NOTICE = 0; //通知提醒
|
||||
Integer TYPE_ANNOUNCEMENT = 1; //系统公告
|
||||
Integer STATUS_DRAFT = 0; //拟定
|
||||
Integer STATUS_PUBLISHED = 1; //已发布
|
||||
Integer STATUS_WITHDREW = 2; //已撤回
|
||||
Integer TO_ALL = 1; //发送给全体用户
|
||||
Integer TO_RANGE = 0; //已发送给指定用户
|
||||
} |
||||
|
||||
@ -1,7 +1,14 @@ |
||||
package cn.toesbieya.jxc.system.mapper; |
||||
|
||||
import cn.toesbieya.jxc.common.model.entity.SysDepartment; |
||||
import cn.toesbieya.jxc.common.model.vo.DepartmentVo; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface SysDepartmentMapper extends BaseMapper<SysDepartment> { |
||||
List<DepartmentVo> selectChildrenById(@Param("id") int id); |
||||
|
||||
List<DepartmentVo> selectParentsById(@Param("id") int id); |
||||
} |
||||
|
||||
@ -0,0 +1,37 @@ |
||||
<?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="cn.toesbieya.jxc.system.mapper.SysDepartmentMapper"> |
||||
<select id="selectChildrenById" resultType="cn.toesbieya.jxc.common.model.vo.DepartmentVo"> |
||||
with recursive t as ( |
||||
select *, |
||||
name as fullname |
||||
from sys_department |
||||
where id = #{id} |
||||
union all |
||||
select c.*, |
||||
concat(t.fullname, ' > ', c.name) as fullname |
||||
from sys_department c, |
||||
t |
||||
where c.pid = t.id |
||||
) |
||||
select * |
||||
from t; |
||||
</select> |
||||
|
||||
<select id="selectParentsById" resultType="cn.toesbieya.jxc.common.model.vo.DepartmentVo"> |
||||
with recursive t as ( |
||||
select *, |
||||
name as fullname |
||||
from sys_department |
||||
where id = #{id} |
||||
union all |
||||
select c.*, |
||||
concat(c.name, ' > ', t.fullname) as fullname |
||||
from sys_department c, |
||||
t |
||||
where c.id = t.pid |
||||
) |
||||
select * |
||||
from t; |
||||
</select> |
||||
</mapper> |
||||
@ -1,7 +1,7 @@ |
||||
package cn.toesbieya.jxc.constant; |
||||
|
||||
public class DocumentConstant { |
||||
public static final String UPDATE_DOCUMENTS_LOCK_KEY = "UPDATE_DOCUMENTS"; |
||||
public static final String[] DOCUMENT_TYPE = {"CGDD", "CGRK", "CGTH", "XSDD", "XSCK", "XSTH"}; |
||||
public static final String DOCUMENT_TYPE_REDIS_KEY = "documentsID"; |
||||
public interface DocumentConstant { |
||||
String UPDATE_DOCUMENTS_LOCK_KEY = "UPDATE_DOCUMENTS"; |
||||
String[] DOCUMENT_TYPE = {"CGDD", "CGRK", "CGTH", "XSDD", "XSCK", "XSTH"}; |
||||
String DOCUMENT_TYPE_REDIS_KEY = "documentsID"; |
||||
} |
||||
|
||||
@ -1,11 +1,11 @@ |
||||
package cn.toesbieya.jxc.constant; |
||||
|
||||
public class MsgConstant { |
||||
public static final Integer TYPE_NOTICE = 0; //通知提醒
|
||||
public static final Integer TYPE_ANNOUNCEMENT = 1; //系统公告
|
||||
public static final Integer STATUS_DRAFT = 0; //拟定
|
||||
public static final Integer STATUS_PUBLISHED = 1; //已发布
|
||||
public static final Integer STATUS_WITHDREW = 2; //已撤回
|
||||
public static final Integer TO_ALL = 1; //发送给全体用户
|
||||
public static final Integer TO_RANGE = 0; //已发送给指定用户
|
||||
public interface MsgConstant { |
||||
Integer TYPE_NOTICE = 0; //通知提醒
|
||||
Integer TYPE_ANNOUNCEMENT = 1; //系统公告
|
||||
Integer STATUS_DRAFT = 0; //拟定
|
||||
Integer STATUS_PUBLISHED = 1; //已发布
|
||||
Integer STATUS_WITHDREW = 2; //已撤回
|
||||
Integer TO_ALL = 1; //发送给全体用户
|
||||
Integer TO_RANGE = 0; //已发送给指定用户
|
||||
} |
||||
|
||||
@ -1,18 +1,18 @@ |
||||
package cn.toesbieya.jxc.constant; |
||||
|
||||
public class SessionConstant { |
||||
public interface SessionConstant { |
||||
//session过期时间,单位秒
|
||||
public static long EXPIRE = 3600 * 8; |
||||
long EXPIRE = 3600 * 8; |
||||
|
||||
//存储用户信息的键的前缀
|
||||
public static String REDIS_NAMESPACE = "sessions:"; |
||||
String REDIS_NAMESPACE = "sessions:"; |
||||
|
||||
//key过期事件的前缀
|
||||
public static String REDIS_EXPIRE_TOPIC_PREFIX = "__keyspace@0__:"; |
||||
String REDIS_EXPIRE_TOPIC_PREFIX = "__keyspace@0__:"; |
||||
|
||||
//http headers中token的字段名
|
||||
public static String TOKEN_KEY = "X-Token"; |
||||
String TOKEN_KEY = "X-Token"; |
||||
|
||||
//区别无活动用户的时间间隔,单位秒
|
||||
public static long NO_ACTION_INTERVAL = 1800; |
||||
long NO_ACTION_INTERVAL = 1800; |
||||
} |
||||
|
||||
@ -1,23 +1,23 @@ |
||||
package cn.toesbieya.jxc.constant; |
||||
|
||||
public class SocketConstant { |
||||
public interface SocketConstant { |
||||
//web-socket服务端订阅的redis主题名称
|
||||
public static String REDIS_EVENT_TOPIC_SEND = "socket-event-send"; |
||||
String REDIS_EVENT_TOPIC_SEND = "socket-event-send"; |
||||
|
||||
//指定用户
|
||||
public static int REDIS_EVENT_SPECIFIC = 0; |
||||
int REDIS_EVENT_SPECIFIC = 0; |
||||
//广播
|
||||
public static int REDIS_EVENT_BROADCAST = 1; |
||||
int REDIS_EVENT_BROADCAST = 1; |
||||
//登出
|
||||
public static int REDIS_EVENT_LOGOUT = 2; |
||||
int REDIS_EVENT_LOGOUT = 2; |
||||
|
||||
//存放于redis中的在线用户的ID集合的键
|
||||
public static String REDIS_ONLINE_USER = "socket:online-user"; |
||||
String REDIS_ONLINE_USER = "socket:online-user"; |
||||
//存放于redis中的离线用户的离线时间的键
|
||||
public static String REDIS_OFFLINE_USER = "socket:offline-user"; |
||||
String REDIS_OFFLINE_USER = "socket:offline-user"; |
||||
|
||||
//登出事件
|
||||
public static final String EVENT_LOGOUT = "logout"; |
||||
String EVENT_LOGOUT = "logout"; |
||||
//新消息事件
|
||||
public static final String EVENT_NEW_MESSAGE = "new-message"; |
||||
String EVENT_NEW_MESSAGE = "new-message"; |
||||
} |
||||
|
||||
@ -0,0 +1,15 @@ |
||||
package cn.toesbieya.jxc.enumeration; |
||||
|
||||
public enum DataScopeEnum { |
||||
ALL(1), SELF(2), SPECIFIC(3); |
||||
|
||||
private final int code; |
||||
|
||||
DataScopeEnum(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue