Compare commits

..

9 Commits

@ -1,2 +0,0 @@
# eyescheck

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

@ -0,0 +1,25 @@
青少年视力健康管理系统
=======
## 平台简介
青少年视力健康管理系统是面向老师和学生管理视力信息的平台。
## 功能简介
注册功能:用户通过注册功能拥有自己的账号密码,之后可通过该账号密码进入系统<br>
登录功能:用户输入自己的账号密码,通过验证码成功验证后可登录进入系统。<br>
视力数据信息管理:班主任可以对学生的各类视力数据信息进行包括删除、修改、增加信息等的多种操作。学生用户可以输入自己的视力数据信息并进行管理。<br>
视力数据分析:某一对象输入若干次视力数据后,系统会自动根据数学公式或者其他科学依据判断用户视力变化趋势,生成视力数据关于时间分布的柱状图、批量学生视力变化分布的折线图等。用户班主任也可以通过输入某一时间,查看对应时间的左、右眼视力分析情况。<br>
视力预警:当分析数据后某些用户视力健康出现不良发展趋势,系统会标注对应用户,提醒管理员做出应对措施。建康资讯展示:该功能可为用户提供健康资讯有关的信息,包括相关医疗场所的详情以及预约方式、青少年视力防控等信息用户个人信息管理:班主任和学生可以在个人中心编辑自己的信息,包括年龄、头像、详细地址等。健康资讯管理:班主任可以对系统展示的健康资讯进行增添、删除、修改等操作<br>
项目首页:/青少年视力健康管理系统<br>
开发环境:<br>
内置tomcat <br>
mysql 5.7<br>
Chrome浏览器<br>
Java 1.8<br>
## 本地部署
- 创建数据库l2998数据库编码为UTF-8
- 修改application-dev.yml更新MySQL账号和密码
- 运行MrWangApplication.java则可启动项目
- 项目访问路径http://localhost:9090/jeefast
- 账号密码admin/123456

@ -0,0 +1,19 @@
package cn.jeefast;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class MrWangApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(MrWangApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MrWangApplication.class);
}
}

@ -0,0 +1,18 @@
package cn.jeefast.common.annotation;
import java.lang.annotation.*;
/**
*
*
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataFilter {
/** 表的别名 */
String tableAlias() default "";
/** true没有本部门数据权限也能查询本人数据 */
boolean user() default true;
}

@ -0,0 +1,19 @@
package cn.jeefast.common.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
*
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Log {
String value() default "";
}

@ -0,0 +1,80 @@
package cn.jeefast.common.aspect;
import org.apache.commons.lang.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.jeefast.common.annotation.DataFilter;
import cn.jeefast.common.exception.RRException;
import cn.jeefast.common.utils.Constant;
import cn.jeefast.common.utils.ShiroUtils;
import cn.jeefast.system.entity.SysUser;
import cn.jeefast.system.service.SysDeptService;
import java.util.Map;
/**
*
*/
@Aspect
@Component
public class DataFilterAspect {
@Autowired
private SysDeptService sysDeptService;
@Pointcut("@annotation(cn.jeefast.common.annotation.DataFilter)")
public void dataFilterCut() {
}
@Before("dataFilterCut()")
public void dataFilter(JoinPoint point) throws Throwable {
Object params = point.getArgs()[0];
if(params != null && params instanceof Map){
SysUser user = ShiroUtils.getUser();
//如果不是超级管理员,则只能查询本部门及子部门数据
if(user.getUserId() != Constant.SUPER_ADMIN){
Map map = (Map)params;
map.put("filterSql", getFilterSQL(user, point));
}
return ;
}
throw new RRException("要实现数据权限接口的参数只能是Map类型且不能为NULL");
}
/**
* SQL
*/
private String getFilterSQL(SysUser user, JoinPoint point){
MethodSignature signature = (MethodSignature) point.getSignature();
DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class);
//获取表的别名
String tableAlias = dataFilter.tableAlias();
if(StringUtils.isNotBlank(tableAlias)){
tableAlias += ".";
}
//获取子部门ID
String subDeptIds = sysDeptService.getSubDeptIdList(user.getDeptId());
StringBuilder filterSql = new StringBuilder();
filterSql.append("and (");
filterSql.append(tableAlias).append("dept_id in(").append(subDeptIds).append(")");
//没有本部门数据权限,也能查询本人数据
if(dataFilter.user()){
filterSql.append(" or ").append(tableAlias).append("user_id=").append(user.getUserId());
}
filterSql.append(")");
return filterSql.toString();
}
}

@ -0,0 +1,99 @@
package cn.jeefast.common.aspect;
import com.google.gson.Gson;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.utils.HttpContextUtils;
import cn.jeefast.common.utils.IPUtils;
import cn.jeefast.system.entity.SysLog;
import cn.jeefast.system.entity.SysUser;
import cn.jeefast.system.service.SysLogService;
import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Date;
/**
*
*
*/
@Aspect
@Component
public class LogAspect {
@Autowired
private SysLogService sysLogService;
@Pointcut("@annotation(cn.jeefast.common.annotation.Log)")
public void logPointCut() {
}
@Around("logPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
long beginTime = System.currentTimeMillis();
//执行方法
Object result = point.proceed();
//执行时长(毫秒)
long time = System.currentTimeMillis() - beginTime;
//保存日志
saveSysLog(point, time);
return result;
}
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLog sysLog = new SysLog();
Log log = method.getAnnotation(Log.class);
if(log != null){
//注解上的描述
sysLog.setOperation(log.value());
}
//请求的方法名
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
sysLog.setMethod(className + "." + methodName + "()");
//请求的参数
Object[] args = joinPoint.getArgs();
try{
//只保存第一个参数
String params = new Gson().toJson(args[0]);
//保存全部参数
//String params = new Gson().toJson(args);
sysLog.setParams(params);
}catch (Exception e){
}
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
//用户名
String username = ((SysUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
sysLog.setUsername(username);
sysLog.setTime(time);
sysLog.setCreateDate(new Date());
//保存系统日志
sysLogService.insert(sysLog);
}
}

@ -0,0 +1,38 @@
package cn.jeefast.common.aspect;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import cn.jeefast.common.exception.RRException;
/**
* Redis
*
*/
@Aspect
@Configuration
public class RedisAspect {
private Logger logger = LoggerFactory.getLogger(getClass());
//是否开启redis缓存 true开启 false关闭
@Value("${renren.redis.open: false}")
private boolean open;
@Around("execution(* cn.jeefast.common.utils.RedisUtils.*(..))")
public Object around(ProceedingJoinPoint point) throws Throwable {
Object result = null;
if(open){
try{
result = point.proceed();
}catch (Exception e){
logger.error("redis error", e);
throw new RRException("Redis服务异常");
}
}
return result;
}
}

@ -0,0 +1,29 @@
package cn.jeefast.common.base;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.jeefast.system.entity.SysUser;
/**
* Controller
*
*/
public abstract class BaseController {
protected Logger logger = LoggerFactory.getLogger(getClass());
protected SysUser getUser() {
return (SysUser) SecurityUtils.getSubject().getPrincipal();
}
protected Long getUserId() {
return getUser().getUserId();
}
protected Long getDeptId() {
return getUser().getDeptId();
}
}

@ -0,0 +1,52 @@
package cn.jeefast.common.exception;
/**
*
*
*/
public class RRException extends RuntimeException {
private static final long serialVersionUID = 1L;
private String msg;
private int code = 500;
public RRException(String msg) {
super(msg);
this.msg = msg;
}
public RRException(String msg, Throwable e) {
super(msg, e);
this.msg = msg;
}
public RRException(String msg, int code) {
super(msg);
this.msg = msg;
this.code = code;
}
public RRException(String msg, int code, Throwable e) {
super(msg, e);
this.msg = msg;
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}

@ -0,0 +1,49 @@
package cn.jeefast.common.exception;
import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import cn.jeefast.common.utils.R;
/**
*
*
*/
@RestControllerAdvice
public class RRExceptionHandler {
private Logger logger = LoggerFactory.getLogger(getClass());
/**
*
*/
@ExceptionHandler(RRException.class)
public R handleRRException(RRException e){
R r = new R();
r.put("code", e.getCode());
r.put("msg", e.getMessage());
return r;
}
@ExceptionHandler(DuplicateKeyException.class)
public R handleDuplicateKeyException(DuplicateKeyException e){
logger.error(e.getMessage(), e);
return R.error("数据库中已存在该记录");
}
@ExceptionHandler(AuthorizationException.class)
public R handleAuthorizationException(AuthorizationException e){
logger.error(e.getMessage(), e);
return R.error("没有权限,请联系管理员授权");
}
@ExceptionHandler(Exception.class)
public R handleException(Exception e){
logger.error(e.getMessage(), e);
return R.error();
}
}

@ -0,0 +1,93 @@
package cn.jeefast.common.utils;
/**
*
*
*/
public class Constant {
/** 超级管理员ID */
public static final int SUPER_ADMIN = 1;
/**
*
*
*/
public enum MenuType {
/**
*
*/
CATALOG(0),
/**
*
*/
MENU(1),
/**
*
*/
BUTTON(2);
private int value;
private MenuType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
/**
*
*
*/
public enum ScheduleStatus {
/**
*
*/
NORMAL(0),
/**
*
*/
PAUSE(1);
private int value;
private ScheduleStatus(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
/**
*
*/
public enum CloudService {
/**
*
*/
QINIU(1),
/**
*
*/
ALIYUN(2),
/**
*
*/
QCLOUD(3);
private int value;
private CloudService(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
}

@ -0,0 +1,13 @@
package cn.jeefast.common.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
public class HttpContextUtils {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
}

@ -0,0 +1,55 @@
package cn.jeefast.common.utils;
import com.alibaba.druid.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
/**
* IP
*
*/
public class IPUtils {
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
/**
* IP
*
* 使Nginx request.getRemoteAddr()IP
* 使X-Forwarded-ForIPX-Forwarded-ForunknownIPIP
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = null;
try {
ip = request.getHeader("x-forwarded-for");
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} catch (Exception e) {
logger.error("IPUtils ERROR ", e);
}
// //使用代理则获取第一个IP地址
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
// if(ip.indexOf(",") > 0) {
// ip = ip.substring(0, ip.indexOf(","));
// }
// }
return ip;
}
}

@ -0,0 +1,59 @@
package cn.jeefast.common.utils;
import org.apache.commons.lang.StringUtils;
import cn.jeefast.common.xss.SQLFilter;
import java.util.LinkedHashMap;
import java.util.Map;
/**
*
*
*/
public class Query extends LinkedHashMap<String, Object> {
private static final long serialVersionUID = 1L;
//当前页码
private int page;
//每页条数
private int limit;
public Query(Map<String, Object> params){
this.putAll(params);
//分页参数
this.page = Integer.parseInt(params.get("page").toString());
this.limit = Integer.parseInt(params.get("limit").toString());
this.put("offset", (page - 1) * limit);
this.put("page", page);
this.put("limit", limit);
//防止SQL注入因为sidx、order是通过拼接SQL实现排序的会有SQL注入风险
String sidx = (String)params.get("sidx");
String order = (String)params.get("order");
if(StringUtils.isNotBlank(sidx)){
this.put("sidx", SQLFilter.sqlInject(sidx));
}
if(StringUtils.isNotBlank(order)){
this.put("order", SQLFilter.sqlInject(order));
}
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
}

@ -0,0 +1,54 @@
package cn.jeefast.common.utils;
import org.apache.http.HttpStatus;
import java.util.HashMap;
import java.util.Map;
/**
*
*
*/
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
public R() {
put("code", 0);
}
public static R error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
}
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
return r;
}
public static R ok(Map<String, Object> map) {
R r = new R();
r.putAll(map);
return r;
}
public static R ok() {
return new R();
}
public R put(String key, Object value) {
super.put(key, value);
return this;
}
}

@ -0,0 +1,12 @@
package cn.jeefast.common.utils;
/**
* RedisKeys
*
*/
public class RedisKeys {
public static String getSysConfigKey(String key){
return "sys:config:" + key;
}
}

@ -0,0 +1,90 @@
package cn.jeefast.common.utils;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* Redis
*
*/
@Component
public class RedisUtils {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private ValueOperations<String, String> valueOperations;
@Autowired
private HashOperations<String, String, Object> hashOperations;
@Autowired
private ListOperations<String, Object> listOperations;
@Autowired
private SetOperations<String, Object> setOperations;
@Autowired
private ZSetOperations<String, Object> zSetOperations;
/** 默认过期时长,单位:秒 */
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
/** 不设置过期时长 */
public final static long NOT_EXPIRE = -1;
private final static Gson gson = new Gson();
public void set(String key, Object value, long expire){
valueOperations.set(key, toJson(value));
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
}
public void set(String key, Object value){
set(key, value, DEFAULT_EXPIRE);
}
public <T> T get(String key, Class<T> clazz, long expire) {
String value = valueOperations.get(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value == null ? null : fromJson(value, clazz);
}
public <T> T get(String key, Class<T> clazz) {
return get(key, clazz, NOT_EXPIRE);
}
public String get(String key, long expire) {
String value = valueOperations.get(key);
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return value;
}
public String get(String key) {
return get(key, NOT_EXPIRE);
}
public void delete(String key) {
redisTemplate.delete(key);
}
/**
* ObjectJSON
*/
private String toJson(Object object){
if(object instanceof Integer || object instanceof Long || object instanceof Float ||
object instanceof Double || object instanceof Boolean || object instanceof String){
return String.valueOf(object);
}
return gson.toJson(object);
}
/**
* JSONObject
*/
private <T> T fromJson(String json, Class<T> clazz){
return gson.fromJson(json, clazz);
}
}

@ -0,0 +1,57 @@
package cn.jeefast.common.utils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import cn.jeefast.common.exception.RRException;
import cn.jeefast.system.entity.SysUser;
/**
* Shiro
*
*/
public class ShiroUtils {
public static Session getSession() {
return SecurityUtils.getSubject().getSession();
}
public static Subject getSubject() {
return SecurityUtils.getSubject();
}
public static SysUser getUser() {
return (SysUser) SecurityUtils.getSubject().getPrincipal();
}
public static Long getUserId() {
return getUser().getUserId();
}
public static void setSessionAttribute(Object key, Object value) {
getSession().setAttribute(key, value);
}
public static Object getSessionAttribute(Object key) {
return getSession().getAttribute(key);
}
public static boolean isLogin() {
return SecurityUtils.getSubject().getPrincipal() != null;
}
public static void logout() {
SecurityUtils.getSubject().logout();
}
public static String getKaptcha(String key) {
Object kaptcha = getSessionAttribute(key);
if(kaptcha == null){
throw new RRException("验证码已失效");
}
getSession().removeAttribute(key);
return kaptcha.toString();
}
}

@ -0,0 +1,42 @@
package cn.jeefast.common.utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* Spring Context
*
*/
@Component
public class SpringContextUtils implements ApplicationContextAware {
public static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
SpringContextUtils.applicationContext = applicationContext;
}
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static <T> T getBean(String name, Class<T> requiredType) {
return applicationContext.getBean(name, requiredType);
}
public static boolean containsBean(String name) {
return applicationContext.containsBean(name);
}
public static boolean isSingleton(String name) {
return applicationContext.isSingleton(name);
}
public static Class<? extends Object> getType(String name) {
return applicationContext.getType(name);
}
}

@ -0,0 +1,23 @@
package cn.jeefast.common.validator;
import org.apache.commons.lang.StringUtils;
import cn.jeefast.common.exception.RRException;
/**
*
*/
public abstract class Assert {
public static void isBlank(String str, String message) {
if (StringUtils.isBlank(str)) {
throw new RRException(message);
}
}
public static void isNull(Object object, String message) {
if (object == null) {
throw new RRException(message);
}
}
}

@ -0,0 +1,41 @@
package cn.jeefast.common.validator;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import cn.jeefast.common.exception.RRException;
import java.util.Set;
/**
* hibernate-validator
*
* http://docs.jboss.org/hibernate/validator/5.4/reference/en-US/html_single/
*
*/
public class ValidatorUtils {
private static Validator validator;
static {
validator = Validation.buildDefaultValidatorFactory().getValidator();
}
/**
*
* @param object
* @param groups
* @throws RRException RRException
*/
public static void validateEntity(Object object, Class<?>... groups)
throws RRException {
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
if (!constraintViolations.isEmpty()) {
StringBuilder msg = new StringBuilder();
for(ConstraintViolation<Object> constraint: constraintViolations){
msg.append(constraint.getMessage()).append("<br>");
}
throw new RRException(msg.toString());
}
}
}

@ -0,0 +1,7 @@
package cn.jeefast.common.validator.group;
/**
* Group
*/
public interface AddGroup {
}

@ -0,0 +1,11 @@
package cn.jeefast.common.validator.group;
import javax.validation.GroupSequence;
/**
* AddGroupUpdateGroup
*/
@GroupSequence({AddGroup.class, UpdateGroup.class})
public interface Group {
}

@ -0,0 +1,9 @@
package cn.jeefast.common.validator.group;
/**
* Group
*/
public interface UpdateGroup {
}

@ -0,0 +1,527 @@
package cn.jeefast.common.xss;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* HTML filtering utility for protecting against XSS (Cross Site Scripting).
*
* This code is licensed LGPLv3
*
* This code is a Java port of the original work in PHP by Cal Hendersen.
* http://code.iamcal.com/php/lib_filter/
*
* The trickiest part of the translation was handling the differences in regex handling
* between PHP and Java. These resources were helpful in the process:
*
* http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
* http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php
* http://www.regular-expressions.info/modifiers.html
*
* A note on naming conventions: instance variables are prefixed with a "v"; global
* constants are in all caps.
*
* Sample use:
* String input = ...
* String clean = new HTMLFilter().filter( input );
*
* The class is not thread safe. Create a new instance if in doubt.
*
* If you find bugs or have suggestions on improvement (especially regarding
* performance), please contact us. The latest version of this
* source, and our contact details, can be found at http://xss-html-filter.sf.net
*
*/
public final class HTMLFilter {
/** regex flag union representing /si modifiers in php **/
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
private static final Pattern P_END_ARROW = Pattern.compile("^>");
private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
private static final Pattern P_AMP = Pattern.compile("&");
private static final Pattern P_QUOTE = Pattern.compile("<");
private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
// @xxx could grow large... maybe use sesat's ReferenceMap
private static final ConcurrentMap<String,Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<String, Pattern>();
private static final ConcurrentMap<String,Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<String, Pattern>();
/** set of allowed html elements, along with allowed attributes for each element **/
private final Map<String, List<String>> vAllowed;
/** counts of open tags for each (allowable) html element **/
private final Map<String, Integer> vTagCounts = new HashMap<String, Integer>();
/** html elements which must always be self-closing (e.g. "<img />") **/
private final String[] vSelfClosingTags;
/** html elements which must always have separate opening and closing tags (e.g. "<b></b>") **/
private final String[] vNeedClosingTags;
/** set of disallowed html elements **/
private final String[] vDisallowed;
/** attributes which should be checked for valid protocols **/
private final String[] vProtocolAtts;
/** allowed protocols **/
private final String[] vAllowedProtocols;
/** tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") **/
private final String[] vRemoveBlanks;
/** entities allowed within html markup **/
private final String[] vAllowedEntities;
/** flag determining whether comments are allowed in input String. */
private final boolean stripComment;
private final boolean encodeQuotes;
private boolean vDebug = false;
/**
* flag determining whether to try to make tags when presented with "unbalanced"
* angle brackets (e.g. "<b text </b>" becomes "<b> text </b>"). If set to false,
* unbalanced angle brackets will be html escaped.
*/
private final boolean alwaysMakeTags;
/** Default constructor.
*
*/
public HTMLFilter() {
vAllowed = new HashMap<>();
final ArrayList<String> a_atts = new ArrayList<String>();
a_atts.add("href");
a_atts.add("target");
vAllowed.put("a", a_atts);
final ArrayList<String> img_atts = new ArrayList<String>();
img_atts.add("src");
img_atts.add("width");
img_atts.add("height");
img_atts.add("alt");
vAllowed.put("img", img_atts);
final ArrayList<String> no_atts = new ArrayList<String>();
vAllowed.put("b", no_atts);
vAllowed.put("strong", no_atts);
vAllowed.put("i", no_atts);
vAllowed.put("em", no_atts);
vSelfClosingTags = new String[]{"img"};
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
vDisallowed = new String[]{};
vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
vProtocolAtts = new String[]{"src", "href"};
vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
stripComment = true;
encodeQuotes = true;
alwaysMakeTags = true;
}
/** Set debug flag to true. Otherwise use default settings. See the default constructor.
*
* @param debug turn debug on with a true argument
*/
public HTMLFilter(final boolean debug) {
this();
vDebug = debug;
}
/** Map-parameter configurable constructor.
*
* @param conf map containing configuration. keys match field names.
*/
public HTMLFilter(final Map<String,Object> conf) {
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed"));
vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
vDisallowed = (String[]) conf.get("vDisallowed");
vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
vProtocolAtts = (String[]) conf.get("vProtocolAtts");
vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
vAllowedEntities = (String[]) conf.get("vAllowedEntities");
stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
}
private void reset() {
vTagCounts.clear();
}
private void debug(final String msg) {
if (vDebug) {
Logger.getAnonymousLogger().info(msg);
}
}
//---------------------------------------------------------------
// my versions of some PHP library functions
public static String chr(final int decimal) {
return String.valueOf((char) decimal);
}
public static String htmlSpecialChars(final String s) {
String result = s;
result = regexReplace(P_AMP, "&amp;", result);
result = regexReplace(P_QUOTE, "&quot;", result);
result = regexReplace(P_LEFT_ARROW, "&lt;", result);
result = regexReplace(P_RIGHT_ARROW, "&gt;", result);
return result;
}
//---------------------------------------------------------------
/**
* given a user submitted input String, filter out any invalid or restricted
* html.
*
* @param input text (i.e. submitted by a user) than may contain html
* @return "clean" version of input, with only valid, whitelisted html elements allowed
*/
public String filter(final String input) {
reset();
String s = input;
debug("************************************************");
debug(" INPUT: " + input);
s = escapeComments(s);
debug(" escapeComments: " + s);
s = balanceHTML(s);
debug(" balanceHTML: " + s);
s = checkTags(s);
debug(" checkTags: " + s);
s = processRemoveBlanks(s);
debug("processRemoveBlanks: " + s);
s = validateEntities(s);
debug(" validateEntites: " + s);
debug("************************************************\n\n");
return s;
}
public boolean isAlwaysMakeTags(){
return alwaysMakeTags;
}
public boolean isStripComments(){
return stripComment;
}
private String escapeComments(final String s) {
final Matcher m = P_COMMENTS.matcher(s);
final StringBuffer buf = new StringBuffer();
if (m.find()) {
final String match = m.group(1); //(.*?)
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
}
m.appendTail(buf);
return buf.toString();
}
private String balanceHTML(String s) {
if (alwaysMakeTags) {
//
// try and form html
//
s = regexReplace(P_END_ARROW, "", s);
s = regexReplace(P_BODY_TO_END, "<$1>", s);
s = regexReplace(P_XML_CONTENT, "$1<$2", s);
} else {
//
// escape stray brackets
//
s = regexReplace(P_STRAY_LEFT_ARROW, "&lt;$1", s);
s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2&gt;<", s);
//
// the last regexp causes '<>' entities to appear
// (we need to do a lookahead assertion so that the last bracket can
// be used in the next pass of the regexp)
//
s = regexReplace(P_BOTH_ARROWS, "", s);
}
return s;
}
private String checkTags(String s) {
Matcher m = P_TAGS.matcher(s);
final StringBuffer buf = new StringBuffer();
while (m.find()) {
String replaceStr = m.group(1);
replaceStr = processTag(replaceStr);
m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
}
m.appendTail(buf);
s = buf.toString();
// these get tallied in processTag
// (remember to reset before subsequent calls to filter method)
for (String key : vTagCounts.keySet()) {
for (int ii = 0; ii < vTagCounts.get(key); ii++) {
s += "</" + key + ">";
}
}
return s;
}
private String processRemoveBlanks(final String s) {
String result = s;
for (String tag : vRemoveBlanks) {
if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){
P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
}
result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){
P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
}
result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
}
return result;
}
private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) {
Matcher m = regex_pattern.matcher(s);
return m.replaceAll(replacement);
}
private String processTag(final String s) {
// ending tags
Matcher m = P_END_TAG.matcher(s);
if (m.find()) {
final String name = m.group(1).toLowerCase();
if (allowed(name)) {
if (!inArray(name, vSelfClosingTags)) {
if (vTagCounts.containsKey(name)) {
vTagCounts.put(name, vTagCounts.get(name) - 1);
return "</" + name + ">";
}
}
}
}
// starting tags
m = P_START_TAG.matcher(s);
if (m.find()) {
final String name = m.group(1).toLowerCase();
final String body = m.group(2);
String ending = m.group(3);
//debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
if (allowed(name)) {
String params = "";
final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
final List<String> paramNames = new ArrayList<String>();
final List<String> paramValues = new ArrayList<String>();
while (m2.find()) {
paramNames.add(m2.group(1)); //([a-z0-9]+)
paramValues.add(m2.group(3)); //(.*?)
}
while (m3.find()) {
paramNames.add(m3.group(1)); //([a-z0-9]+)
paramValues.add(m3.group(3)); //([^\"\\s']+)
}
String paramName, paramValue;
for (int ii = 0; ii < paramNames.size(); ii++) {
paramName = paramNames.get(ii).toLowerCase();
paramValue = paramValues.get(ii);
// debug( "paramName='" + paramName + "'" );
// debug( "paramValue='" + paramValue + "'" );
// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
if (allowedAttribute(name, paramName)) {
if (inArray(paramName, vProtocolAtts)) {
paramValue = processParamProtocol(paramValue);
}
params += " " + paramName + "=\"" + paramValue + "\"";
}
}
if (inArray(name, vSelfClosingTags)) {
ending = " /";
}
if (inArray(name, vNeedClosingTags)) {
ending = "";
}
if (ending == null || ending.length() < 1) {
if (vTagCounts.containsKey(name)) {
vTagCounts.put(name, vTagCounts.get(name) + 1);
} else {
vTagCounts.put(name, 1);
}
} else {
ending = " /";
}
return "<" + name + params + ending + ">";
} else {
return "";
}
}
// comments
m = P_COMMENT.matcher(s);
if (!stripComment && m.find()) {
return "<" + m.group() + ">";
}
return "";
}
private String processParamProtocol(String s) {
s = decodeEntities(s);
final Matcher m = P_PROTOCOL.matcher(s);
if (m.find()) {
final String protocol = m.group(1);
if (!inArray(protocol, vAllowedProtocols)) {
// bad protocol, turn into local anchor link instead
s = "#" + s.substring(protocol.length() + 1, s.length());
if (s.startsWith("#//")) {
s = "#" + s.substring(3, s.length());
}
}
}
return s;
}
private String decodeEntities(String s) {
StringBuffer buf = new StringBuffer();
Matcher m = P_ENTITY.matcher(s);
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.decode(match).intValue();
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
}
m.appendTail(buf);
s = buf.toString();
buf = new StringBuffer();
m = P_ENTITY_UNICODE.matcher(s);
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.valueOf(match, 16).intValue();
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
}
m.appendTail(buf);
s = buf.toString();
buf = new StringBuffer();
m = P_ENCODE.matcher(s);
while (m.find()) {
final String match = m.group(1);
final int decimal = Integer.valueOf(match, 16).intValue();
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
}
m.appendTail(buf);
s = buf.toString();
s = validateEntities(s);
return s;
}
private String validateEntities(final String s) {
StringBuffer buf = new StringBuffer();
// validate entities throughout the string
Matcher m = P_VALID_ENTITIES.matcher(s);
while (m.find()) {
final String one = m.group(1); //([^&;]*)
final String two = m.group(2); //(?=(;|&|$))
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
}
m.appendTail(buf);
return encodeQuotes(buf.toString());
}
private String encodeQuotes(final String s){
if(encodeQuotes){
StringBuffer buf = new StringBuffer();
Matcher m = P_VALID_QUOTES.matcher(s);
while (m.find()) {
final String one = m.group(1); //(>|^)
final String two = m.group(2); //([^<]+?)
final String three = m.group(3); //(<|$)
m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, "&quot;", two) + three));
}
m.appendTail(buf);
return buf.toString();
}else{
return s;
}
}
private String checkEntity(final String preamble, final String term) {
return ";".equals(term) && isValidEntity(preamble)
? '&' + preamble
: "&amp;" + preamble;
}
private boolean isValidEntity(final String entity) {
return inArray(entity, vAllowedEntities);
}
private static boolean inArray(final String s, final String[] array) {
for (String item : array) {
if (item != null && item.equals(s)) {
return true;
}
}
return false;
}
private boolean allowed(final String name) {
return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
}
private boolean allowedAttribute(final String name, final String paramName) {
return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
}
}

@ -0,0 +1,41 @@
package cn.jeefast.common.xss;
import org.apache.commons.lang.StringUtils;
import cn.jeefast.common.exception.RRException;
/**
* SQL
*/
public class SQLFilter {
/**
* SQL
* @param str
*/
public static String sqlInject(String str){
if(StringUtils.isBlank(str)){
return null;
}
//去掉'|"|;|\字符
str = StringUtils.replace(str, "'", "");
str = StringUtils.replace(str, "\"", "");
str = StringUtils.replace(str, ";", "");
str = StringUtils.replace(str, "\\", "");
//转换成小写
str = str.toLowerCase();
//非法字符
String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alert", "drop"};
//判断是否包含非法字符
for(String keyword : keywords){
if(str.indexOf(keyword) != -1){
throw new RRException("包含非法字符");
}
}
return str;
}
}

@ -0,0 +1,72 @@
package cn.jeefast.common.xss;
import org.apache.commons.lang.StringUtils;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* XSS
*/
public class XssFilter implements Filter {
//不拦截的地址
private List<String> excludedList = new ArrayList<String>();
@Override
public void init(FilterConfig config) throws ServletException {
/*
* url
* XssHttpServletRequestWrapper
*/
excludedList.add("/sysLswhfbj/update");
excludedList.add("/sysLswhfbj/save");
excludedList.add("/sysLswhwzgl/update");
excludedList.add("/sysLswhwzgl/save");
excludedList.add("/sysFood/update");
excludedList.add("/sysFood/save");
excludedList.add("/sysXinwen/update");
excludedList.add("/sysXinwen/save");
excludedList.add("/sysIndexQd/ydcp");
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
(HttpServletRequest) request);
String url = xssRequest.getServletPath();
if(isExcluded(url)){
chain.doFilter(request, response);
}else{
//使用XSS过滤
chain.doFilter(xssRequest, response);
}
}
@Override
public void destroy() {
}
/**
*
* @param url
* @return truefalse
*/
private boolean isExcluded(String url){
if(StringUtils.isBlank(url)){
return false;
}
for (String excluded : excludedList) {
if(url.contains(excluded)){
return true;
}
}
return false;
}
}

@ -0,0 +1,137 @@
package cn.jeefast.common.xss;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* XSS
*/
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
//没被包装过的HttpServletRequest特殊场景需要自己过滤
HttpServletRequest orgRequest;
//html过滤
private final static HTMLFilter htmlFilter = new HTMLFilter();
public XssHttpServletRequestWrapper(HttpServletRequest request) {
super(request);
orgRequest = request;
}
@Override
public ServletInputStream getInputStream() throws IOException {
//非json类型直接返回
if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){
return super.getInputStream();
}
//为空,直接返回
String json = IOUtils.toString(super.getInputStream(), "utf-8");
if (StringUtils.isBlank(json)) {
return super.getInputStream();
}
//xss过滤
json = xssEncode(json);
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
return new ServletInputStream() {
@Override
public boolean isFinished() {
return true;
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setReadListener(ReadListener readListener) {
}
@Override
public int read() throws IOException {
return bis.read();
}
};
}
@Override
public String getParameter(String name) {
String value = super.getParameter(xssEncode(name));
if (StringUtils.isNotBlank(value)) {
value = xssEncode(value);
}
return value;
}
@Override
public String[] getParameterValues(String name) {
String[] parameters = super.getParameterValues(name);
if (parameters == null || parameters.length == 0) {
return null;
}
for (int i = 0; i < parameters.length; i++) {
parameters[i] = xssEncode(parameters[i]);
}
return parameters;
}
@Override
public Map<String,String[]> getParameterMap() {
Map<String,String[]> map = new LinkedHashMap<>();
Map<String,String[]> parameters = super.getParameterMap();
for (String key : parameters.keySet()) {
String[] values = parameters.get(key);
for (int i = 0; i < values.length; i++) {
values[i] = xssEncode(values[i]);
}
map.put(key, values);
}
return map;
}
@Override
public String getHeader(String name) {
String value = super.getHeader(xssEncode(name));
if (StringUtils.isNotBlank(value)) {
value = xssEncode(value);
}
return value;
}
private String xssEncode(String input) {
return htmlFilter.filter(input);
}
/**
* request
*/
public HttpServletRequest getOrgRequest() {
return orgRequest;
}
/**
* request
*/
public static HttpServletRequest getOrgRequest(HttpServletRequest request) {
if (request instanceof XssHttpServletRequestWrapper) {
return ((XssHttpServletRequestWrapper) request).getOrgRequest();
}
return request;
}
}

@ -0,0 +1,41 @@
package cn.jeefast.config;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;
import cn.jeefast.common.xss.XssFilter;
import javax.servlet.DispatcherType;
/**
* Filter
*
*/
@Configuration
public class FilterConfig {
@Bean
public FilterRegistrationBean shiroFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
//该值缺省为false表示生命周期由SpringApplicationContext管理设置为true则表示由ServletContainer管理
registration.addInitParameter("targetFilterLifecycle", "true");
registration.setEnabled(true);
registration.setOrder(Integer.MAX_VALUE - 1);
registration.addUrlPatterns("/*");
return registration;
}
@Bean
public FilterRegistrationBean xssFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter());
registration.addUrlPatterns("/*");
registration.setName("xssFilter");
registration.setOrder(Integer.MAX_VALUE);
return registration;
}
}

@ -0,0 +1,29 @@
package cn.jeefast.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
/**
*
*
*/
@Configuration
public class KaptchaConfig {
@Bean
public DefaultKaptcha producer() {
Properties properties = new Properties();
properties.put("kaptcha.border", "no");
properties.put("kaptcha.textproducer.font.color", "black");
properties.put("kaptcha.textproducer.char.space", "5");
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}

@ -0,0 +1,34 @@
package cn.jeefast.config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;
@Configuration
@MapperScan(basePackages = {"cn.jeefast.modules.*.dao", "cn.jeefast.system.dao"})
public class MybatisPlusConfig {
/**
* mybatis-plus SQL
*/
@Bean
public PerformanceInterceptor performanceInterceptor() {
return new PerformanceInterceptor();
}
/**
* mybatis-plus<br>
* http://mp.baomidou.com<br>
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setLocalPage(true);// 开启 PageHelper 的支持
return paginationInterceptor;
}
}

@ -0,0 +1,54 @@
package cn.jeefast.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* Redis
*
*/
@Configuration
public class RedisConfig {
@Autowired
private RedisConnectionFactory factory;
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
redisTemplate.setConnectionFactory(factory);
return redisTemplate;
}
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
@Bean
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
return redisTemplate.opsForValue();
}
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}

@ -0,0 +1,109 @@
package cn.jeefast.config;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.jeefast.system.oauth2.OAuth2Filter;
import cn.jeefast.system.oauth2.OAuth2Realm;
import javax.servlet.Filter;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Shiro
*
*/
@Configuration
public class ShiroConfig {
@Bean("sessionManager")
public SessionManager sessionManager(){
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionValidationSchedulerEnabled(true);
sessionManager.setSessionIdUrlRewritingEnabled(false);
//sessionManager.setSessionIdCookieEnabled(false);
return sessionManager;
}
@Bean("securityManager")
public SecurityManager securityManager(OAuth2Realm oAuth2Realm, SessionManager sessionManager) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(oAuth2Realm);
securityManager.setSessionManager(sessionManager);
return securityManager;
}
@Bean("shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
shiroFilter.setSecurityManager(securityManager);
//oauth过滤
Map<String, Filter> filters = new HashMap<>();
filters.put("oauth2", new OAuth2Filter());
shiroFilter.setFilters(filters);
Map<String, String> filterMap = new LinkedHashMap<>();
filterMap.put("/webjars/**", "anon");
filterMap.put("/druid/**", "anon");
filterMap.put("/api/**", "anon");
filterMap.put("/sys/login", "anon");
filterMap.put("/**/*.css", "anon");
filterMap.put("/**/*.js", "anon");
filterMap.put("/**/*.html", "anon");
filterMap.put("/img/**", "anon");
filterMap.put("/ueditor/**", "anon");
filterMap.put("/fonts/**", "anon");
filterMap.put("/plugins/**", "anon");
filterMap.put("/swagger/**", "anon");
filterMap.put("/favicon.ico", "anon");
filterMap.put("/captcha.jpg", "anon");
filterMap.put("/sys/regsave", "anon");
// 文本编辑器
filterMap.put("/**/*.eot", "anon");
filterMap.put("/**/*.ttf", "anon");
filterMap.put("/**/*.woff", "anon");
filterMap.put("/**/wx.jpg", "anon");
filterMap.put("/**/zfb.jpg", "anon");
filterMap.put("/", "anon");
filterMap.put("/**", "oauth2");
shiroFilter.setFilterChainDefinitionMap(filterMap);
return shiroFilter;
}
@Bean("lifecycleBeanPostProcessor")
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}
@Bean
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator();
proxyCreator.setProxyTargetClass(true);
return proxyCreator;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
advisor.setSecurityManager(securityManager);
return advisor;
}
}

@ -0,0 +1,27 @@
package cn.jeefast.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.io.File;
/**
* MVC
*
*/
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
public static final String separator= File.separator;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//和页面有关的静态目录都放在项目的static目录下
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
//上传的图片在D盘下的OTA目录下访问路径如http://localhost:8081/OTA/d3cf0281-bb7f-40e0-ab77-406db95ccf2c.jpg
//其中OTA表示访问的前缀。"file:D:/OTA/"是文件真实的存储路径
registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/upload/");
}
}

@ -0,0 +1,11 @@
package cn.jeefast.datasources;
/**
*
*
*/
public interface DataSourceNames {
String FIRST = "first";
String SECOND = "second";
}

@ -0,0 +1,21 @@
package cn.jeefast.datasources;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class DataSourceTestService {
// @Autowired
// private TbUserService userService;
//
// public TbUser queryObject(Long userId){
// return userService.selectById(userId);
// }
//
// @DataSource(name = DataSourceNames.SECOND)
// public TbUser queryObject2(Long userId){
// return userService.selectById(userId);
// }
}

@ -0,0 +1,38 @@
package cn.jeefast.datasources;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class DynamicDataSource extends AbstractRoutingDataSource {
private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();
public DynamicDataSource(DataSource defaultTargetDataSource, Map<String, DataSource> targetDataSources) {
super.setDefaultTargetDataSource(defaultTargetDataSource);
super.setTargetDataSources(new HashMap<>(targetDataSources));
super.afterPropertiesSet();
}
@Override
protected Object determineCurrentLookupKey() {
return getDataSource();
}
public static void setDataSource(String dataSource) {
contextHolder.set(dataSource);
}
public static String getDataSource() {
return contextHolder.get();
}
public static void clearDataSource() {
contextHolder.remove();
}
}

@ -0,0 +1,33 @@
package cn.jeefast.datasources;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
@Configuration
public class DynamicDataSourceConfig {
@Bean
@ConfigurationProperties("spring.datasource.druid.first")
public DataSource firstDataSource(){
return DruidDataSourceBuilder.create().build();
}
@Bean
@Primary
public DynamicDataSource dataSource(DataSource firstDataSource, DataSource secondDataSource) {
Map<String, DataSource> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceNames.FIRST, firstDataSource);
targetDataSources.put(DataSourceNames.SECOND, secondDataSource);
return new DynamicDataSource(firstDataSource, targetDataSources);
}
}

@ -0,0 +1,13 @@
package cn.jeefast.datasources.annotation;
import java.lang.annotation.*;
/**
*
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataSource {
String name() default "";
}

@ -0,0 +1,58 @@
package cn.jeefast.datasources.aspect;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import cn.jeefast.datasources.DataSourceNames;
import cn.jeefast.datasources.DynamicDataSource;
import cn.jeefast.datasources.annotation.DataSource;
import java.lang.reflect.Method;
/**
*
*/
@Aspect
@Component
public class DataSourceAspect implements Ordered {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Pointcut("@annotation(cn.jeefast.datasources.annotation.DataSource)")
public void dataSourcePointCut() {
}
@Around("dataSourcePointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
DataSource ds = method.getAnnotation(DataSource.class);
if(ds == null){
DynamicDataSource.setDataSource(DataSourceNames.FIRST);
logger.debug("set datasource is " + DataSourceNames.FIRST);
}else {
DynamicDataSource.setDataSource(ds.name());
logger.debug("set datasource is " + ds.name());
}
try {
return point.proceed();
} finally {
DynamicDataSource.clearDataSource();
logger.debug("clean datasource");
}
}
@Override
public int getOrder() {
return 1;
}
}

@ -0,0 +1,151 @@
package cn.jeefast.system.controller;
import cn.jeefast.system.entity.SysUser;
import cn.jeefast.system.service.SysUserService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.utils.Constant;
import cn.jeefast.common.utils.R;
import cn.jeefast.system.entity.SysDept;
import cn.jeefast.system.service.SysDeptService;
import java.util.HashMap;
import java.util.List;
/**
*
*
*/
@RestController
@RequestMapping("/sys/dept")
public class SysDeptController extends BaseController {
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysUserService sysUserService;
/**
*
*/
@RequestMapping("/list")
//@RequiresPermissions("sys:dept:list")
public List<SysDept> list(){
List<SysDept> deptList = sysDeptService.queryList(new HashMap<>());
System.out.println("deptListdeptListdeptList"+deptList);
return deptList;
}
/**
* ()
*/
@RequestMapping("/select")
//@RequiresPermissions("sys:dept:select")
public R select(){
List<SysDept> deptList = sysDeptService.queryList(new HashMap<>());
//添加一级部门
if(getUserId() == Constant.SUPER_ADMIN){
SysDept root = new SysDept();
root.setDeptId(0L);
root.setName("一级部门");
root.setParentId(-1L);
root.setOpen(true);
deptList.add(root);
}
return R.ok().put("deptList", deptList);
}
/**
* Id(0)
*/
@RequestMapping("/info")
//@RequiresPermissions("sys:dept:list")
public R info(){
long deptId = 0;
if(getUserId() != Constant.SUPER_ADMIN){
SysDept dept = sysDeptService.selectById(getDeptId());
deptId = dept.getParentId();
}
return R.ok().put("deptId", deptId);
}
/**
*
*/
@RequestMapping("/info/{deptId}")
//@RequiresPermissions("sys:dept:info")
public R info(@PathVariable("deptId") Long deptId){
SysDept dept = sysDeptService.selectById(deptId);
return R.ok().put("dept", dept);
}
/**
*
*/
@RequestMapping("/save")
//@RequiresPermissions("sys:dept:save")
public R save(@RequestBody SysDept dept){
System.out.println("deptdeptdept"+dept);
if(dept.getParentId() == 0){
dept.setUpstr(",0,");
}else{
SysDept sysDeptFj = sysDeptService.selectById(dept.getParentId());
dept.setUpstr(sysDeptFj.getUpstr()+sysDeptFj.getDeptId()+",");
}
sysDeptService.insert(dept);
return R.ok();
}
/**
*
*/
@RequestMapping("/update")
//@RequiresPermissions("sys:dept:update")
public R update(@RequestBody SysDept dept){
if(dept.getParentId() == 0){
dept.setUpstr(",0,");
}else{
SysDept sysDeptFj = sysDeptService.selectById(dept.getParentId());
dept.setUpstr(sysDeptFj.getUpstr()+sysDeptFj.getDeptId()+",");
}
sysDeptService.updateById(dept);
return R.ok();
}
/**
*
*/
@RequestMapping("/delete")
//@RequiresPermissions("sys:dept:delete")
public R delete(long deptId){
//判断是否有子部门
List<Long> deptList = sysDeptService.queryDetpIdList(deptId);
if(deptList.size() > 0){
return R.error("请先删除子部门");
}
//逻辑删除
SysDept dept = new SysDept();
dept.setDeptId(deptId);
dept.setDelFlag(-1);
sysDeptService.updateById(dept);
//物理删除
//sysDeptService.delete(deptId);
return R.ok();
}
}

@ -0,0 +1,313 @@
package cn.jeefast.system.controller;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.Assert;
import cn.jeefast.system.entity.*;
import cn.jeefast.system.service.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.SimpleFormatter;
/**
* <p>
*
* </p>
*/
@RestController
@RequestMapping("/sysIndexQd")
public class SysIndexQdController extends BaseController {
@Value("${server.port}")
private String serverport;
@Value("${server.context-path}")
private String servercontextpath;
@Autowired
private SysUserTokenService sysUserTokenService;
@Autowired
private SysUserService sysUserService;
@Autowired
private TMaterialFileService tMaterialFileService;
@Autowired
private SysUserRoleService sysUserRoleService;
/**
*
*/
@RequestMapping("/getUser")
public R getUser(@RequestBody Map<String,Object> tjarray) throws UnknownHostException {
System.out.println("tjarraytjarray"+tjarray);
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("token",tjarray.get("token")+""));
SysUser user = sysUserService.selectById(sysUserToken.getUserId());
/**
*
*/
List<TMaterialFile> tMaterialFileList = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",user.getUserId()));
// SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("user_id", getUserId()));
System.out.println("tMaterialFileListtMaterialFileList"+tMaterialFileList);
InetAddress address = InetAddress.getLocalHost();
user.setPhotopath(tMaterialFileList != null && tMaterialFileList.size()>0?"http://"+address.getHostAddress() +":"+serverport+"/"+servercontextpath+"/upload/"+tMaterialFileList.get(0).getSfilename()+"?token="+sysUserToken.getToken():"img/usermm.jpg");
System.out.println("useruseruseruser"+user);
//获取用户所属的角色列表
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(user.getUserId());
user.setRoleIdList(roleIdList);
//获取附件列表
List<TMaterialFile> tMaterialFiles = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",user.getUserId()));
List<Map<String,Object>> mapList = new ArrayList<>();
if(!tMaterialFiles.isEmpty()){
for(TMaterialFile tMaterialFile:tMaterialFiles){
Map<String,Object> map =new HashMap<>();
map.put("id",tMaterialFile.getId());
map.put("filePath",tMaterialFile.getSfilename());
map.put("fileName",tMaterialFile.getSaccessoryname());
mapList.add(map);
}
}
JSONArray json = (JSONArray) JSONArray.toJSON(mapList);
user.setFiles(json);
return R.ok().put("sysuser",user);
}
/**
*
*/
@RequestMapping("/userSaveFile")
public R userSaveFile(@RequestBody JSONObject param){
System.out.println("paramparamparam"+JSON.toJSONString(param));
String userid = param.getString("userid");
JSONArray allFiles = param.getJSONArray("allFiles");
System.out.println("useriduseriduserid"+userid);
System.out.println("allFilesallFilesallFiles"+JSON.toJSONString(allFiles));
List<TMaterialFile> tMaterialFiles = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",userid));
if (tMaterialFiles.size()>0){
for (int i = 0; i < tMaterialFiles.size(); i++) {
tMaterialFileService.deleteById(tMaterialFiles.get(i).getId());
}
}
if(allFiles.size()>0){
for (int i = 0; i < allFiles.size(); i++) {
Map map = (Map) allFiles.get(i);
TMaterialFile tMaterialFile = tMaterialFileService.selectById(map.get("id").toString());
tMaterialFile.setParentid(userid);
tMaterialFileService.updateById(tMaterialFile);
}
}
return R.ok();
}
/**
*
*/
@RequestMapping("/updateuser")
public R updateuser(@RequestBody SysUser sysUser){
System.out.println("sysUsersysUser"+sysUser);
sysUserService.updateById(sysUser);
return R.ok();
}
/**
*
*/
@RequestMapping("/updatepassword")
public R updatepassword(@RequestBody JSONObject tjarray){
String token = tjarray.getString("token");
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("token",token));
SysUser user = sysUserService.selectById(sysUserToken.getUserId());
String oldpassword = tjarray.getString("oldpassword");
String newPassword = tjarray.getString("password");
Assert.isBlank(newPassword, "新密码不为能空");
//sha256加密
oldpassword = new Sha256Hash(oldpassword, user.getSalt()).toHex();
//sha256加密
newPassword = new Sha256Hash(newPassword, user.getSalt()).toHex();
if(!oldpassword.equals(user.getPassword())){
return R.error("原密码不正确无法修改密码");
}
// SysUser user = new SysUser();
user.setUserId(user.getUserId());
user.setPassword(newPassword);
//更新密码
sysUserService.updateById(user);
return R.ok();
}
@Autowired
private SysXinwenService sysXinwenService;
/**
*
*/
@RequestMapping("/getXinwenListAll")
public R getXinwenListAll(@RequestBody JSONObject tjarray){
String type = tjarray.getString("type");
String qname = tjarray.getString("qname");
Wrapper w =new EntityWrapper<SysXinwen>();
if(type != null){
w.eq("type",type);
}
if(qname != null){
w.like("title",qname);
}
List<SysXinwen> xinwenList = sysXinwenService.selectList(w.orderBy(true,"updatetime",false));
return R.ok().put("xinwenList",xinwenList);
}
/**
*
*/
@RequestMapping("/getXinwen")
public R getXinwen(@RequestBody Map<String,Object> tjarray) throws Exception {
System.out.println("tjarraytjarraytjarray"+tjarray);
if(tjarray.get("id") == null){
return R.error("请选择要查看的健康资讯");
}
String id = tjarray.get("id")+"";
SysXinwen xinwen =sysXinwenService.selectById(id);
System.out.println("xinwenxinwenxinwen"+xinwen);
//获取附件列表
List<TMaterialFile> tMaterialFiles = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",xinwen.getId()));
List<Map<String,Object>> mapList = new ArrayList<>();
if(!tMaterialFiles.isEmpty()){
for(TMaterialFile tMaterialFile:tMaterialFiles){
Map<String,Object> map =new HashMap<>();
map.put("id",tMaterialFile.getId());
map.put("filePath",tMaterialFile.getSfilename());
map.put("fileName",tMaterialFile.getSaccessoryname());
mapList.add(map);
}
}
JSONArray json = (JSONArray) JSONArray.toJSON(mapList);
xinwen.setFiles(json);
return R.ok().put("xinwen",xinwen);
}
@Autowired
private SysSlxxbService sysSlxxbService;
/**
*
*/
@RequestMapping("/getSlxxbListAll")
public R getSlxxbListAll(@RequestBody JSONObject param){
String token = param.getString("token");
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("token",token));
SysUser user = sysUserService.selectById(sysUserToken.getUserId());
Wrapper wrapper = new EntityWrapper<SysSlxxb>();
wrapper.orderBy(true,"updatetime",false);
List<SysSlxxb> slxxbList = sysSlxxbService.selectList(wrapper);
if(slxxbList.size()>0){
for (int i = 0; i < slxxbList.size(); i++) {
SysSlxxb sysSlxxb = slxxbList.get(i);
if(sysSlxxb.getType() != null){
if(sysSlxxb.getType().equals("1")){
sysSlxxb.setTypename("左眼");
}else {
sysSlxxb.setTypename("右眼");
}
}else{
sysSlxxb.setTypename("未知");
}
if(sysSlxxb.getSfzc() != null){
if(sysSlxxb.getSfzc().equals("1")){
sysSlxxb.setSfzcname("正常");
}else {
sysSlxxb.setSfzcname("异常");
}
}else{
sysSlxxb.setSfzcname("未知");
}
}
}
return R.ok().put("slxxbList",slxxbList);
}
/**
*
*/
@RequestMapping("/saveSlxxb")
public R saveSlxxb(@RequestBody JSONObject param) throws ParseException {
String token = param.getString("token");
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("token",token));
SysUser user = sysUserService.selectById(sysUserToken.getUserId());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String type = param.getString("type");
Double slj = param.getDouble("slj");
String username = param.getString("username");
String jcsj = param.getString("jcsj");
String sfzc = param.getString("sfzc");
SysSlxxb sysSlxxb = new SysSlxxb();
sysSlxxb.setType(type);
sysSlxxb.setSlj(slj);
sysSlxxb.setUsername(username);
sysSlxxb.setJcsj(format.parse(jcsj));
sysSlxxb.setSfzc(sfzc);
sysSlxxb.setUpdatetime(new Date());
sysSlxxb.setUpdateuser(user.getUsername());
sysSlxxb.setCreatetime(new Date());
sysSlxxb.setCreateuser(user.getUsername());
sysSlxxbService.insert(sysSlxxb);
return R.ok();
}
/**
*
*/
@RequestMapping("/slxxbshanchu")
public R slxxbshanchu(@RequestBody JSONObject param) throws ParseException {
String id = param.getString("id");
sysSlxxbService.delete(new EntityWrapper<SysSlxxb>().eq("id",id));
return R.ok();
}
}

@ -0,0 +1,47 @@
package cn.jeefast.system.controller;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.system.entity.SysLog;
import cn.jeefast.system.service.SysLogService;
import java.util.Map;
/**
*
*
*/
@RestController
@RequestMapping("/sys/log")
public class SysLogController extends BaseController {
@Autowired
private SysLogService sysLogService;
/**
*
*/
@ResponseBody
@RequestMapping("/list")
@RequiresPermissions("sys:log:list")
public R list(@RequestParam Map<String, Object> params){
//查询列表数据
Query query = new Query(params);
Page<SysLog> pageUtil = new Page<SysLog>(query.getPage(), query.getLimit());
Page<SysLog> page = sysLogService.selectPageList(pageUtil,query);
return R.ok().put("page", page);
}
}

@ -0,0 +1,129 @@
package cn.jeefast.system.controller;
import cn.jeefast.system.entity.SysUserRole;
import cn.jeefast.system.service.SysUserRoleService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.utils.ShiroUtils;
import cn.jeefast.system.entity.SysUser;
import cn.jeefast.system.service.SysUserService;
import cn.jeefast.system.service.SysUserTokenService;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
*
*/
@RestController
public class SysLoginController {
@Autowired
private Producer producer;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserTokenService sysUserTokenService;
@Autowired
private SysUserRoleService sysUserRoleService;
@RequestMapping("captcha.jpg")
public void captcha(HttpServletResponse response)throws ServletException, IOException {
response.setHeader("Cache-Control", "no-store, no-cache");
response.setContentType("image/jpeg");
//生成文字验证码
String text = producer.createText();
//生成图片验证码
BufferedImage image = producer.createImage(text);
//保存到shiro session
ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text);
ServletOutputStream out = response.getOutputStream();
ImageIO.write(image, "jpg", out);
IOUtils.closeQuietly(out);
}
/**
*
*/
@RequestMapping(value = "/sys/regsave", method = RequestMethod.POST)
public Map<String, Object> regsave(String sxh, String sname,
String xzraol, String susername, String spassword, String zcspassword
, String college, String major, String classinfo, String grade)throws IOException {
if(!spassword.equals(zcspassword)){
return R.error().put("msg","两次密码输入不一直");
}
SysUser sysUser = new SysUser();
sysUser.setUsername(susername);
sysUser.setPassword(spassword);
sysUser.setRealname(sname);
sysUser.setStadynum(sxh);
sysUser.setCollege(college);
sysUser.setMajor(major);
sysUser.setClassinfo(classinfo);
sysUser.setGrade(grade);
sysUser.setStatus(1);
List<Long> a = new ArrayList<>();
a.add((long)2);
sysUser.setRoleIdList(a);
sysUserService.save(sysUser);
return R.ok().put("msg","注册成功");
}
/**
*
*/
@RequestMapping(value = "/sys/login", method = RequestMethod.POST)
public Map<String, Object> login(String username, String password, String captcha)throws IOException {
System.out.println("usernameusernameusername"+username);
System.out.println("passwordpasswordpassword"+password);
System.out.println("captchacaptchacaptchacaptcha"+captcha);
String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY);
if(!captcha.equalsIgnoreCase(kaptcha)){
return R.error("验证码不正确");
}
//用户信息
SysUser user = sysUserService.queryByUserName(username);
System.out.println("useruseruseruser"+user);
//账号不存在、密码错误
if(user == null || !user.getPassword().equals(new Sha256Hash(password, user.getSalt()).toHex())) {
return R.error("账号或密码不正确");
}
//账号锁定
if(user.getStatus() == 0){
return R.error("账号已被锁定,请联系管理员");
}
//生成token并保存到数据库
System.out.println("getUserIdgetUserIdgetUserId"+user.getUserId());
R r = sysUserTokenService.createToken(user.getUserId());
System.out.println(user.getUserId()+"rrrrrrrrrrrrrr"+r);
return r;
}
}

@ -0,0 +1,182 @@
package cn.jeefast.system.controller;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.exception.RRException;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.utils.Constant.MenuType;
import cn.jeefast.system.entity.SysMenu;
import cn.jeefast.system.service.ShiroService;
import cn.jeefast.system.service.SysMenuService;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
/**
*
*
*/
@RestController
@RequestMapping("/sys/menu")
public class SysMenuController extends BaseController {
@Autowired
private SysMenuService sysMenuService;
@Autowired
private ShiroService shiroService;
/**
*
*/
@RequestMapping("/nav")
public R nav(){
List<SysMenu> menuList = sysMenuService.getUserMenuList(getUserId());
Set<String> permissions = shiroService.getUserPermissions(getUserId());
return R.ok().put("menuList", menuList).put("permissions", permissions);
}
/**
*
*/
@RequestMapping("/list")
@RequiresPermissions("sys:menu:list")
public List<SysMenu> list(){
List<SysMenu> menuList = sysMenuService.queryList(new HashMap<>());
return menuList;
}
/**
* ()
*/
@RequestMapping("/select")
@RequiresPermissions("sys:menu:select")
public R select(){
//查询列表数据
List<SysMenu> menuList = sysMenuService.queryNotButtonList();
//添加顶级菜单
SysMenu root = new SysMenu();
root.setMenuId(0L);
root.setName("一级菜单");
root.setParentId(-1L);
root.setOpen(true);
menuList.add(root);
return R.ok().put("menuList", menuList);
}
/**
*
*/
@RequestMapping("/info/{menuId}")
@RequiresPermissions("sys:menu:info")
public R info(@PathVariable("menuId") Long menuId){
SysMenu menu = sysMenuService.selectById(menuId);
return R.ok().put("menu", menu);
}
/**
*
*/
@Log("保存菜单")
@RequestMapping("/save")
@RequiresPermissions("sys:menu:save")
public R save(@RequestBody SysMenu menu){
//数据校验
verifyForm(menu);
sysMenuService.insert(menu);
return R.ok();
}
/**
*
*/
@Log("修改菜单")
@RequestMapping("/update")
@RequiresPermissions("sys:menu:update")
public R update(@RequestBody SysMenu menu){
//数据校验
verifyForm(menu);
sysMenuService.updateById(menu);
return R.ok();
}
/**
*
*/
@Log("删除菜单")
@RequestMapping("/delete")
@RequiresPermissions("sys:menu:delete")
public R delete(long menuId){
if(menuId <= 31){
return R.error("系统菜单,不能删除");
}
//判断是否有子菜单或按钮
List<SysMenu> menuList = sysMenuService.queryListParentId(menuId);
if(menuList.size() > 0){
return R.error("请先删除子菜单或按钮");
}
sysMenuService.deleteBatch(new Long[]{menuId});
return R.ok();
}
/**
*
*/
private void verifyForm(SysMenu menu){
if(StringUtils.isBlank(menu.getName())){
throw new RRException("菜单名称不能为空");
}
if(menu.getParentId() == null){
throw new RRException("上级菜单不能为空");
}
//菜单
if(menu.getType() == MenuType.MENU.getValue()){
if(StringUtils.isBlank(menu.getUrl())){
throw new RRException("菜单URL不能为空");
}
}
//上级菜单类型
int parentType = MenuType.CATALOG.getValue();
if(menu.getParentId() != 0){
SysMenu parentMenu = sysMenuService.selectById(menu.getParentId());
parentType = parentMenu.getType();
}
//目录、菜单
if(menu.getType() == MenuType.CATALOG.getValue() ||
menu.getType() == MenuType.MENU.getValue()){
if(parentType != MenuType.CATALOG.getValue()){
throw new RRException("上级菜单只能为目录类型");
}
return ;
}
//按钮
if(menu.getType() == MenuType.BUTTON.getValue()){
if(parentType != MenuType.MENU.getValue()){
throw new RRException("上级菜单只能为菜单类型");
}
return ;
}
}
}

@ -0,0 +1,148 @@
package cn.jeefast.system.controller;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.ValidatorUtils;
import cn.jeefast.system.entity.SysPjinfo;
import cn.jeefast.system.service.SysDeptService;
import cn.jeefast.system.service.SysPjinfoService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.jeefast.common.base.BaseController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
*/
@RestController
@RequestMapping("/sysPjinfo")
public class SysPjinfoController extends BaseController {
@Autowired
private SysPjinfoService sysPjinfoService;
@Autowired
private SysDeptService sysDeptService;
/**
*
*/
@RequestMapping("/list")
@RequiresPermissions("sys:pjinfo:list")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
Page<SysPjinfo> pageUtil = new Page<SysPjinfo>(query.getPage(), query.getLimit());
Page<SysPjinfo> page = sysPjinfoService.queryPageList(pageUtil, query);
if (page.getRecords().size() > 0) {
for (int i = 0; i < page.getRecords().size(); i++) {
SysPjinfo newSysPjinfo = page.getRecords().get(i);
newSysPjinfo.setDeptName(newSysPjinfo.getDeptid() != null && newSysPjinfo.getDeptid() != "" ? sysDeptService.selectById(newSysPjinfo.getDeptid()).getName() : null);
}
}
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/info/{pjinfoId}")
@RequiresPermissions("sys:pjinfo:info")
public R info(@PathVariable("pjinfoId") String pjinfoId) {
System.out.println("pjinfoIdpjinfoIdpjinfoId"+pjinfoId);
SysPjinfo pjinfo = sysPjinfoService.selectById(pjinfoId);
return R.ok().put("pjinfo", pjinfo);
}
/**
*
*/
@RequestMapping("/infoprent/{pjinfoId}")
@RequiresPermissions("sys:pjinfo:infoprent")
public R infoprent(@PathVariable("pjinfoId") String pjinfoId) {
System.out.println("pjinfoIdpjinfoIdpjinfoId"+pjinfoId);
SysPjinfo pjinfo = sysPjinfoService.selectById(pjinfoId);
List<SysPjinfo> sysPjinfoList = new ArrayList<>();
if(pjinfo.getPrentid() != null){
sysPjinfoList = sysPjinfoService.selectList(new EntityWrapper<SysPjinfo>().eq("prentid",pjinfo.getId()));
}
System.out.println("sysPjinfoListsysPjinfoListsysPjinfoList"+sysPjinfoList);
System.out.println("sizesizesizesizesizesizesize"+sysPjinfoList.size());
pjinfo.setSysPjinfoList(sysPjinfoList);
System.out.println("pjinfopjinfopjinfopjinfopjinfopjinfopjinfopjinfopjinfopjin"+pjinfo);
return R.ok().put("pjinfo", pjinfo).put("allFiles",sysPjinfoList);
}
/**
*
*/
@Log("保存系统评价")
@RequestMapping("/save")
@RequiresPermissions("sys:pjinfo:save")
public R save(@RequestBody SysPjinfo pjinfo) {
ValidatorUtils.validateEntity(pjinfo);
pjinfo.setUsername(getUser().getUsername());
sysPjinfoService.insert(pjinfo);
return R.ok();
}
/**
*
*/
@Log("修改系统评价")
@RequestMapping("/update")
@RequiresPermissions("sys:pjinfo:update")
public R update(@RequestBody SysPjinfo pjinfo) {
ValidatorUtils.validateEntity(pjinfo);
pjinfo.setUsername(getUser().getUsername());
pjinfo.setPrentid("0");
sysPjinfoService.updateById(pjinfo);
return R.ok();
}
/**
*
*/
@Log("保存评论")
@RequestMapping("/savePlxx")
@RequiresPermissions("sys:pjinfo:savePlxx")
public R savePlxx(@RequestBody SysPjinfo pjinfo) {
System.out.println("pjinfopjinfopjinfopjinfo"+pjinfo);
ValidatorUtils.validateEntity(pjinfo);
pjinfo.setUsername(getUser().getUsername());
pjinfo.setPrentid(pjinfo.getId()+"");
pjinfo.setId(null);
sysPjinfoService.insert(pjinfo);
return R.ok();
}
/**
*
*/
@Log("删除系统评价")
@RequestMapping("/delete")
@RequiresPermissions("sys:pjinfo:delete")
public R delete(@RequestBody String[] pjinfoIds) {
sysPjinfoService.deleteBatch(pjinfoIds);
return R.ok();
}
}

@ -0,0 +1,133 @@
package cn.jeefast.system.controller;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.plugins.Page;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.utils.Constant;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.ValidatorUtils;
import cn.jeefast.system.entity.SysRole;
import cn.jeefast.system.service.SysRoleDeptService;
import cn.jeefast.system.service.SysRoleMenuService;
import cn.jeefast.system.service.SysRoleService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
*/
@RestController
@RequestMapping("/sys/role")
public class SysRoleController extends BaseController {
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysRoleMenuService sysRoleMenuService;
@Autowired
private SysRoleDeptService sysRoleDeptService;
/**
*
*/
@RequestMapping("/list")
@RequiresPermissions("sys:role:list")
public R list(@RequestParam Map<String, Object> params){
//如果不是超级管理员,则只查询自己创建的角色列表
if(getUserId() != Constant.SUPER_ADMIN){
params.put("createUserId", getUserId());
}
//查询列表数据
Query query = new Query(params);
Page<SysRole> pageUtil = new Page<SysRole>(query.getPage(), query.getLimit());
Page<SysRole> page = sysRoleService.queryPageList(pageUtil,query);
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/select")
@RequiresPermissions("sys:role:select")
public R select(){
Map<String, Object> map = new HashMap<>();
//如果不是超级管理员,则只查询自己所拥有的角色列表
if(getUserId() != Constant.SUPER_ADMIN){
map.put("createUserId", getUserId());
}
List<SysRole> list = sysRoleService.queryList(map);
return R.ok().put("list", list);
}
/**
*
*/
@RequestMapping("/info/{roleId}")
@RequiresPermissions("sys:role:info")
public R info(@PathVariable("roleId") Long roleId){
SysRole role = sysRoleService.selectById(roleId);
//查询角色对应的菜单
List<Long> menuIdList = sysRoleMenuService.queryMenuIdList(roleId);
role.setMenuIdList(menuIdList);
//查询角色对应的部门
List<Long> deptIdList = sysRoleDeptService.queryDeptIdList(roleId);
role.setDeptIdList(deptIdList);
return R.ok().put("role", role);
}
/**
*
*/
@Log("保存角色")
@RequestMapping("/save")
@RequiresPermissions("sys:role:save")
public R save(@RequestBody SysRole role){
ValidatorUtils.validateEntity(role);
sysRoleService.save(role);
return R.ok();
}
/**
*
*/
@Log("修改角色")
@RequestMapping("/update")
@RequiresPermissions("sys:role:update")
public R update(@RequestBody SysRole role){
ValidatorUtils.validateEntity(role);
sysRoleService.update(role);
return R.ok();
}
/**
*
*/
@Log("删除角色")
@RequestMapping("/delete")
@RequiresPermissions("sys:role:delete")
public R delete(@RequestBody Long[] roleIds){
sysRoleService.deleteBatch(roleIds);
return R.ok();
}
}

@ -0,0 +1,166 @@
package cn.jeefast.system.controller;
import java.util.*;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.ValidatorUtils;
import cn.jeefast.system.entity.SysSlxxb;
import cn.jeefast.system.entity.TMaterialFile;
import cn.jeefast.system.service.TMaterialFileService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.jeefast.system.service.SysSlxxbService;
import org.springframework.web.bind.annotation.RestController;
import cn.jeefast.common.base.BaseController;
/**
* <p>
*
* </p>
*/
@RestController
@RequestMapping("/sysSlxxb")
public class SysSlxxbController extends BaseController {
@Autowired
private SysSlxxbService sysSlxxbService;
@Autowired
private TMaterialFileService tMaterialFileService;
/**
*
*/
@RequestMapping("/list")
@RequiresPermissions("sys:slxxb:list")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
Page<SysSlxxb> pageUtil = new Page<SysSlxxb>(query.getPage(), query.getLimit());
Page<SysSlxxb> page = sysSlxxbService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/info/{slxxbId}")
@RequiresPermissions("sys:slxxb:info")
public R info(@PathVariable("slxxbId") String slxxbId) {
SysSlxxb slxxb = sysSlxxbService.selectById(slxxbId);
//获取附件列表
List<TMaterialFile> tMaterialFiles = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid", slxxb.getId()));
List<Map<String, Object>> mapList = new ArrayList<>();
if (!tMaterialFiles.isEmpty()) {
for (TMaterialFile tMaterialFile : tMaterialFiles) {
Map<String, Object> map = new HashMap<>();
map.put("id", tMaterialFile.getId());
map.put("filePath", tMaterialFile.getSfilename());
map.put("fileName", tMaterialFile.getSaccessoryname());
mapList.add(map);
}
}
JSONArray json = (JSONArray) JSONArray.toJSON(mapList);
slxxb.setFiles(json);
return R.ok().put("slxxb", slxxb);
}
/**
*
*/
@RequestMapping("/getSlxxbs")
public R getSlxxbs() {
List<SysSlxxb> slxxbs = sysSlxxbService.selectList(new EntityWrapper<SysSlxxb>().orderBy(true, "updatetime", false));
return R.ok().put("slxxbs", slxxbs);
}
/**
*
*/
@Log("保存视力数据信息管理")
@RequestMapping("/save")
@RequiresPermissions("sys:slxxb:save")
public R save(@RequestBody SysSlxxb slxxb) {
ValidatorUtils.validateEntity(slxxb);
slxxb.setCreatetime(new Date());
slxxb.setCreateuser(getUser().getUsername());
slxxb.setUpdatetime(new Date());
slxxb.setUpdateuser(getUser().getUsername());
sysSlxxbService.insert(slxxb);
if (slxxb.getFiles() != null) {
tMaterialFileService.setTMaterialFilePrintId(slxxb.getFiles(), slxxb.getId());
}
return R.ok();
}
/**
*
*/
@Log("修改视力数据信息管理")
@RequestMapping("/update")
@RequiresPermissions("sys:slxxb:update")
public R update(@RequestBody SysSlxxb slxxb) {
ValidatorUtils.validateEntity(slxxb);
slxxb.setUpdatetime(new Date());
slxxb.setUpdateuser(getUser().getUsername());
sysSlxxbService.updateById(slxxb);
if (slxxb.getFiles() != null) {
tMaterialFileService.setTMaterialFilePrintId(slxxb.getFiles(), slxxb.getId());
}
return R.ok();
}
/**
*
*/
@Log("删除视力数据信息管理")
@RequestMapping("/delete")
@RequiresPermissions("sys:slxxb:delete")
public R delete(@RequestBody String[] slxxbIds) {
sysSlxxbService.deleteBatch(slxxbIds);
return R.ok();
}
/**
*
*/
@RequestMapping("/tjlist")
@RequiresPermissions("sys:slxxb:tjlist")
public R tjlist(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
Page<SysSlxxb> pageUtil = new Page<SysSlxxb>(query.getPage(), query.getLimit());
Page<SysSlxxb> page = sysSlxxbService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
@Log("统计图表")
@RequestMapping("/getData")
public R getData(@RequestBody JSONObject param) {
System.out.println("paramparamparam"+param);
String id = param.getString("id");
SysSlxxb sysSlxxb = sysSlxxbService.selectById(id);
String username = sysSlxxb.getUsername();
List<SysSlxxb> sysSlxxbs = sysSlxxbService.selectList(new EntityWrapper<SysSlxxb>().eq("username",username).eq("type","1").orderBy(true,"jcsj",true));
List<SysSlxxb> sysyySlxxbs = sysSlxxbService.selectList(new EntityWrapper<SysSlxxb>().eq("username",username).eq("type","2").orderBy(true,"jcsj",true));
return R.ok().put("zy",sysSlxxbs).put("yy",sysyySlxxbs);
}
}

@ -0,0 +1,385 @@
package cn.jeefast.system.controller;
import cn.jeefast.system.entity.*;
import cn.jeefast.system.service.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.plugins.Page;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.Assert;
import cn.jeefast.common.validator.ValidatorUtils;
import cn.jeefast.common.validator.group.AddGroup;
import cn.jeefast.common.validator.group.UpdateGroup;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
/**
*
*
*/
@RestController
@RequestMapping("/sys/user")
public class SysUserController extends BaseController {
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserRoleService sysUserRoleService;
@Autowired
private SysUserTokenService sysUserTokenService;
@Autowired
private TMaterialFileService tMaterialFileService;
@Autowired
private SysRoleService sysRoleService;
@Value("${server.port}")
private String serverport;
@Value("${server.context-path}")
private String servercontextpath;
/**
*
*/
@RequestMapping("/list")
@RequiresPermissions("sys:user:list")
public R list(@RequestParam Map<String, Object> params) throws UnknownHostException {
//查询列表数据
SysUser dluser = getUser();
//管理远看全部
List<SysUserRole> sysUserRolesone = sysUserRoleService.selectList(new EntityWrapper<SysUserRole>().eq("user_id",dluser.getUserId()));
String usernameParam = dluser.getUsername();
if(sysUserRolesone.size()>0){
for(int i=0;i<sysUserRolesone.size();i++){
SysUserRole sysUserRole = sysUserRolesone.get(i);
if((sysUserRole.getRoleId()+"").equals("1")){
usernameParam = null;
}
}
}
params.put("usernameParam",usernameParam);
Query query = new Query(params);
Page<SysUser> pageUtil = new Page<SysUser>(query.getPage(), query.getLimit());
Page<SysUser> page = sysUserService.queryPageList(pageUtil,query);
if(page.getRecords().size()>0){
for(int i=0;i<page.getRecords().size();i++){
SysUser sysUser = page.getRecords().get(i);
List<SysUserRole> sysUserRoles = sysUserRoleService.selectList(new EntityWrapper<SysUserRole>().eq("user_id",sysUser.getUserId()));
String roalArraystr = "";
if(sysUserRoles != null && sysUserRoles.size()>0){
for(int j=0;j<sysUserRoles.size();j++){
SysRole sysRole = sysRoleService.selectById(sysUserRoles.get(j).getRoleId());
if(sysRole != null){
roalArraystr = sysRole.getRoleName()+","+roalArraystr;
}
}
}
sysUser.setRoalArraystr(roalArraystr);//显示角色信息
/**
*
*/
List<TMaterialFile> tMaterialFileList = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",sysUser.getUserId()));
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("user_id", getUserId()));
InetAddress address = InetAddress.getLocalHost();
sysUser.setPhotopath(tMaterialFileList != null && tMaterialFileList.size()>0?"http://"+address.getHostAddress() +":"+serverport+"/"+servercontextpath+"/upload/"+tMaterialFileList.get(0).getSfilename()+"?token="+sysUserToken.getToken():"img/usermm.jpg");
}
}
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/info")
public R info() throws UnknownHostException {
SysUser user = getUser();
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("user_id", user.getUserId()));
List<TMaterialFile> tMaterialFileList = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",user.getUserId()));
InetAddress address = InetAddress.getLocalHost();
return R.ok().put("user", getUser()).put("lj",tMaterialFileList != null && tMaterialFileList.size()>0?"http://"+address.getHostAddress() +":"+serverport+"/"+servercontextpath+"/upload/"+tMaterialFileList.get(0).getSfilename()+"?token="+sysUserToken.getToken():"img/usermm.jpg");
}
/**
*
*/
@Log("修改密码")
@RequestMapping("/password")
public R password(String password, String newPassword){
Assert.isBlank(newPassword, "新密码不为能空");
//sha256加密
password = new Sha256Hash(password, getUser().getSalt()).toHex();
SysUser sysUser = sysUserService.selectById(getUser().getUserId());
String passwordOld = new Sha256Hash(sysUser.getPassword(), getUser().getSalt()).toHex();
if(!password.equals(sysUser.getPassword())){
return R.error("原密码输入不正确无法重置密码,请联系管理员谢谢!");
}
//sha256加密
newPassword = new Sha256Hash(newPassword, getUser().getSalt()).toHex();
SysUser user = new SysUser();
user.setUserId(getUserId());
user.setPassword(newPassword);
//更新密码
boolean bFlag = sysUserService.updateById(user);
if(!bFlag){
return R.error("原密码不正确");
}
return R.ok();
}
/**
*
*/
@RequestMapping("/info/{userId}")
@RequiresPermissions("sys:user:info")
public R info(@PathVariable("userId") Long userId){
SysUser user = sysUserService.selectById(userId);
//获取用户所属的角色列表
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(userId);
user.setRoleIdList(roleIdList);
//获取附件列表
List<TMaterialFile> tMaterialFiles = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",userId));
List<Map<String,Object>> mapList = new ArrayList<>();
if(!tMaterialFiles.isEmpty()){
for(TMaterialFile tMaterialFile:tMaterialFiles){
Map<String,Object> map =new HashMap<>();
map.put("id",tMaterialFile.getId());
map.put("filePath",tMaterialFile.getSfilename());
map.put("fileName",tMaterialFile.getSaccessoryname());
mapList.add(map);
}
}
JSONArray json = (JSONArray) JSONArray.toJSON(mapList);
user.setFiles(json);
return R.ok().put("user", user);
}
/**
*
*/
@Log("保存用户")
@RequestMapping("/save")
@RequiresPermissions("sys:user:save")
public R save(@RequestBody SysUser user){
ValidatorUtils.validateEntity(user, AddGroup.class);
user.setCreateTime(new Date());
user.setCreateUserId(getUserId());
sysUserService.save(user);
tMaterialFileService.setTMaterialFilePrintId(user.getFiles(),user.getUserId()+"");
return R.ok();
}
/**
*
*/
@Log("修改用户")
@RequestMapping("/update")
@RequiresPermissions("sys:user:update")
public R update(@RequestBody SysUser user){
ValidatorUtils.validateEntity(user, UpdateGroup.class);
user.setCreateUserId(getUserId());
sysUserService.update(user);
tMaterialFileService.setTMaterialFilePrintId(user.getFiles(),user.getUserId()+"");
return R.ok();
}
/**
*
*/
@Log("删除用户")
@RequestMapping("/delete")
@RequiresPermissions("sys:user:delete")
public R delete(@RequestBody Long[] userIds){
if(ArrayUtils.contains(userIds, 1L)){
return R.error("系统管理员不能删除");
}
if(ArrayUtils.contains(userIds, getUserId())){
return R.error("当前用户不能删除");
}
sysUserService.deleteBatch(userIds);
return R.ok();
}
/**
*
*/
@Log("获取用户")
@RequestMapping("/getUsers")
public R getUsers(){
List<SysUser> users = sysUserService.selectList(new EntityWrapper<SysUser>().orderBy(true,"create_time",false));
return R.ok().put("users",users);
}
@Autowired
private SysSlxxbService sysSlxxbService;
/**
*
*/
@RequestMapping("/yjlist")
@RequiresPermissions("sys:user:yjlist")
public R yjlist(@RequestParam Map<String, Object> params) throws UnknownHostException {
//查询列表数据
SysUser dluser = getUser();
//管理远看全部
List<SysUserRole> sysUserRolesone = sysUserRoleService.selectList(new EntityWrapper<SysUserRole>().eq("user_id",dluser.getUserId()));
String usernameParam = dluser.getUsername();
if(sysUserRolesone.size()>0){
for(int i=0;i<sysUserRolesone.size();i++){
SysUserRole sysUserRole = sysUserRolesone.get(i);
if((sysUserRole.getRoleId()+"").equals("1")){
usernameParam = null;
}
}
}
params.put("usernameParam",usernameParam);
Query query = new Query(params);
Page<SysUser> pageUtil = new Page<SysUser>(query.getPage(), query.getLimit());
Page<SysUser> page = sysUserService.queryPageList(pageUtil,query);
if(page.getRecords().size()>0){
for(int i=0;i<page.getRecords().size();i++){
SysUser sysUser = page.getRecords().get(i);
List<SysUserRole> sysUserRoles = sysUserRoleService.selectList(new EntityWrapper<SysUserRole>().eq("user_id",sysUser.getUserId()));
String roalArraystr = "";
if(sysUserRoles != null && sysUserRoles.size()>0){
for(int j=0;j<sysUserRoles.size();j++){
SysRole sysRole = sysRoleService.selectById(sysUserRoles.get(j).getRoleId());
if(sysRole != null){
roalArraystr = sysRole.getRoleName()+","+roalArraystr;
}
}
}
sysUser.setRoalArraystr(roalArraystr);//显示角色信息
/**
*
*/
List<TMaterialFile> tMaterialFileList = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",sysUser.getUserId()));
SysUserToken sysUserToken = sysUserTokenService.selectOne(new EntityWrapper<SysUserToken>().eq("user_id", getUserId()));
InetAddress address = InetAddress.getLocalHost();
sysUser.setPhotopath(tMaterialFileList != null && tMaterialFileList.size()>0?"http://"+address.getHostAddress() +":"+serverport+"/"+servercontextpath+"/upload/"+tMaterialFileList.get(0).getSfilename()+"?token="+sysUserToken.getToken():"img/usermm.jpg");
//预警走势算法计算
List<SysSlxxb> sysZySlxxbs = sysSlxxbService.selectList(new EntityWrapper<SysSlxxb>().eq("username",sysUser.getUsername()).eq("type","1").orderBy(true,"jcsj",false));
List<SysSlxxb> sysYySlxxbs = sysSlxxbService.selectList(new EntityWrapper<SysSlxxb>().eq("username",sysUser.getUsername()).eq("type","2").orderBy(true,"jcsj",false));
Map zyMap = getYcjg(sysZySlxxbs);
Map yyMap = getYcjg(sysYySlxxbs);
sysUser.setZyycjg(zyMap.get("ycjg")+"");
sysUser.setYyycjg(yyMap.get("ycjg")+"");
sysUser.setZysfbj(zyMap.get("sfbj")+"");
sysUser.setYysfbj(yyMap.get("sfbj")+"");
}
}
return R.ok().put("page", page);
}
//获取预测结果
private Map getYcjg(List<SysSlxxb> sysSlxxbs){
String ycjg = "";
String sfbj = "";
List<Double> x = new ArrayList<>();
List<Double> y = new ArrayList<>();
// x.add(2019.0); y.add(10.0);
// x.add(2020.0); y.add(20.0);
// x.add(2021.0); y.add(22.0);
// x.add(2022.0); y.add(30.0);
// x.add(2023.0); y.add(33.0);
if(sysSlxxbs.size()>=5){
for (int i = 1; i <= sysSlxxbs.size(); i++) {
x.add(i+2019.0); y.add(sysSlxxbs.size()+0.0);
}
// 训练模型
double[] coefficients = train(x, y);
// 预测j结果值
double jgz = predict(coefficients, sysSlxxbs.size()+1+2019.0);
System.out.println("预测j结果值" + jgz);
System.out.println("最后数量:" + sysSlxxbs.get(sysSlxxbs.size()-1).getSlj());
if(jgz < sysSlxxbs.get(sysSlxxbs.size()-1).getSlj()){
ycjg = "目前态势是你的视力越来越差";
sfbj = "1";
System.out.println(ycjg);
}else {
ycjg = "目前态势是你的视力越来越好";
System.out.println(ycjg);
sfbj = "2";
}
}else {
ycjg = "检测数量不足五条无法进行预测评估";
System.out.println(ycjg);
sfbj = "2";
}
Map map = new HashMap();
map.put("ycjg",ycjg);
map.put("sfbj",sfbj);
return map;
}
// 训练模型
public static double[] train(List<Double> x, List<Double> y) {
int n = x.size();
double xSum = 0.0, ySum = 0.0, xySum = 0.0, xxSum = 0.0;
for (int i = 0; i < n; i++) {
xSum += x.get(i);
ySum += y.get(i);
xySum += x.get(i) * y.get(i);
xxSum += x.get(i) * x.get(i);
}
double xMean = xSum / n;
double yMean = ySum / n;
double beta1 = (xySum - n * xMean * yMean) / (xxSum - n * xMean * xMean);
double beta0 = yMean - beta1 * xMean;
double[] coefficients = new double[2];
coefficients[0] = beta0;
coefficients[1] = beta1;
return coefficients;
}
// 预测
public static double predict(double[] coefficients, double x) {
double beta0 = coefficients[0];
double beta1 = coefficients[1];
return beta0 + beta1 * x;
}
}

@ -0,0 +1,173 @@
package cn.jeefast.system.controller;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.ValidatorUtils;
import cn.jeefast.system.entity.SysXinwen;
import cn.jeefast.system.entity.TMaterialFile;
import cn.jeefast.system.service.SysXinwenService;
import cn.jeefast.system.service.TMaterialFileService;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.jeefast.common.base.BaseController;
import java.util.*;
/**
* <p>
*
* </p>
*
* @author theodo
* @since 2022-03-30
*/
@RestController
@RequestMapping("/sysXinwen")
public class SysXinwenController extends BaseController {
@Autowired
private SysXinwenService sysXinwenService;
@Autowired
private TMaterialFileService tMaterialFileService;
/**
*
*/
@RequestMapping("/list")
@RequiresPermissions("sys:xinwen:list")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
params.put("type","1");
Query query = new Query(params);
Page<SysXinwen> pageUtil = new Page<SysXinwen>(query.getPage(), query.getLimit());
Page<SysXinwen> page = sysXinwenService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/gsjj")
@RequiresPermissions("sys:xinwen:gsjj")
public R gsjj(@RequestParam Map<String, Object> params) {
//查询列表数据
params.put("type","2");
Query query = new Query(params);
Page<SysXinwen> pageUtil = new Page<SysXinwen>(query.getPage(), query.getLimit());
Page<SysXinwen> page = sysXinwenService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/zysxlist")
@RequiresPermissions("sys:xinwen:zysxlist")
public R zysxlist(@RequestParam Map<String, Object> params) {
//查询列表数据
params.put("type","3");
Query query = new Query(params);
Page<SysXinwen> pageUtil = new Page<SysXinwen>(query.getPage(), query.getLimit());
Page<SysXinwen> page = sysXinwenService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/xlgllist")
@RequiresPermissions("sys:xinwen:xlgllist")
public R xlgllist(@RequestParam Map<String, Object> params) {
//查询列表数据
params.put("type","4");
Query query = new Query(params);
Page<SysXinwen> pageUtil = new Page<SysXinwen>(query.getPage(), query.getLimit());
Page<SysXinwen> page = sysXinwenService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
/**
*
*/
@RequestMapping("/info/{xinwenId}")
@RequiresPermissions("sys:xinwen:info")
public R info(@PathVariable("xinwenId") String xinwenId) {
SysXinwen xinwen = sysXinwenService.selectById(xinwenId);
//获取附件列表
List<TMaterialFile> tMaterialFiles = tMaterialFileService.selectList(new EntityWrapper<TMaterialFile>().eq("parentid",xinwen.getId()));
List<Map<String,Object>> mapList = new ArrayList<>();
if(!tMaterialFiles.isEmpty()){
for(TMaterialFile tMaterialFile:tMaterialFiles){
Map<String,Object> map =new HashMap<>();
map.put("id",tMaterialFile.getId());
map.put("filePath",tMaterialFile.getSfilename());
map.put("fileName",tMaterialFile.getSaccessoryname());
mapList.add(map);
}
}
JSONArray json = (JSONArray) JSONArray.toJSON(mapList);
xinwen.setFiles(json);
return R.ok().put("xinwen", xinwen);
}
/**
*
*/
//@Log("保存健康资讯")
@RequestMapping("/save")
@RequiresPermissions("sys:xinwen:save")
public R save(@RequestBody SysXinwen xinwen) {
ValidatorUtils.validateEntity(xinwen);
xinwen.setCreateuser(getUser().getUsername());
xinwen.setCreatetime(new Date());
xinwen.setUpdateuser(getUser().getUsername());
xinwen.setUpdatetime(new Date());
sysXinwenService.insert(xinwen);
if(xinwen.getFiles() != null){
tMaterialFileService.setTMaterialFilePrintId(xinwen.getFiles(),xinwen.getId());
}
return R.ok();
}
/**
*
*/
//@Log("修改健康资讯")
@RequestMapping("/update")
@RequiresPermissions("sys:xinwen:update")
public R update(@RequestBody SysXinwen xinwen) {
ValidatorUtils.validateEntity(xinwen);
xinwen.setUpdateuser(getUser().getUsername());
xinwen.setUpdatetime(new Date());
sysXinwenService.updateById(xinwen);
if(xinwen.getFiles() != null){
tMaterialFileService.setTMaterialFilePrintId(xinwen.getFiles(),xinwen.getId());
}
return R.ok();
}
/**
*
*/
//@Log("删除健康资讯")
@RequestMapping("/delete")
@RequiresPermissions("sys:xinwen:delete")
public R delete(@RequestBody String[] xinwenIds) {
sysXinwenService.deleteBatch(xinwenIds);
return R.ok();
}
}

@ -0,0 +1,320 @@
package cn.jeefast.system.controller;
import cn.jeefast.common.annotation.Log;
import cn.jeefast.common.base.BaseController;
import cn.jeefast.common.utils.Query;
import cn.jeefast.common.utils.R;
import cn.jeefast.common.validator.ValidatorUtils;
import cn.jeefast.common.validator.group.AddGroup;
import cn.jeefast.common.validator.group.UpdateGroup;
import cn.jeefast.system.entity.TMaterialFile;
import cn.jeefast.system.service.TMaterialFileService;
import cn.jeefast.system.util.FileUpLoadUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
/**
* <p>
*
* </p>
*
* @author theodo
* @since 2019-05-21
*/
@RestController
@RequestMapping("/tMaterialFile")
public class TMaterialFileController extends BaseController {
@Autowired
private TMaterialFileService tMaterialFileService;
@Value("${server.port}")
private String serverport;
@Value("${server.context-path}")
private String servercontextpath;
@RequestMapping("/ajaxUploadFile")
public R ajaxUploadFile(@RequestParam("files") MultipartFile myfiles, HttpServletRequest request, HttpServletResponse response) throws IOException {
System.out.println("myfilesmyfilesmyfiles"+myfiles);
System.out.println("getBytesgetBytesgetBytes"+myfiles.getBytes());
System.out.println("toJSONStringtoJSONString"+ JSON.toJSONString(myfiles));
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(myfiles));
String s = new String(myfiles.getBytes());
String dataPath = "D:\\upload";
Map<String, String> map = null;
boolean ff = false;
// 得到上传文件的保存目录将上传文件存放在WEB-INF目录下不允许外界直接访问保证上传文件的安全
String prefix = new SimpleDateFormat("yyyyMMdd").format(new Date());
File dir = new File(dataPath + "/" + prefix);
File saveFileDir = new File(dataPath);
if (!saveFileDir.exists()) {
// 创建目录
saveFileDir.mkdirs();
if (!dir.exists()) {
dir.mkdirs();
}
} else {
if (!dir.exists()) {
dir.mkdirs();
}
}
dataPath = dataPath + "/" + prefix;
String uuid = UUID.randomUUID().toString();
String fileName = uuid+myfiles.getOriginalFilename();
System.out.println("完整文件名 = " + fileName);
InputStream inputStream = null;
FileOutputStream fileOut = null;
InetAddress address = InetAddress.getLocalHost();
String qdfwlj = "http://"+address.getHostAddress() +":"+serverport+"/"+servercontextpath+"/upload/"+prefix+"/"+fileName;
try {
inputStream = myfiles.getInputStream();
fileOut = new FileOutputStream(dataPath+"/"+fileName);//这里可以改路径
IOUtils.copy(inputStream, fileOut);
fileOut.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if (inputStream != null) {
inputStream.close();
}
if (fileOut != null) {
fileOut.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return R.ok()
// .put("path","http://localhost:9090/jeefast/upload/20220424/372e641f-9be8-4ad7-b0be-a3b938f9f767.jpg")
.put("path",qdfwlj)
;
}
//@Log("所有附件列表")
@RequestMapping("/list")
// @RequiresPermissions("basic")
public R list(@RequestParam Map<String, Object> params) {
Query query = new Query(params);
Page<TMaterialFile> pageUtil = new Page<TMaterialFile>(query.getPage(), query.getLimit());
Page<TMaterialFile> page = tMaterialFileService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
//@Log("展示附件show")
@RequestMapping("/show")
// @RequiresPermissions("basic")
public R show(@RequestParam Map<String, Object> params) {
Query query = new Query(params);
Page<TMaterialFile> pageUtil = new Page<TMaterialFile>(query.getPage(), query.getLimit());
Page<TMaterialFile> page = tMaterialFileService.queryPageList(pageUtil, query);
return R.ok().put("page", page);
}
//@Log("删除文件上传")
@RequestMapping("/deleteByFileId")
public R deleteByFileId(@RequestBody Map<String,Object> deleteFles) {
System.out.println("aaaaaaaaididididididid"+deleteFles);
String id = deleteFles.get("id")+"";
tMaterialFileService.deletePreachFile(id);
tMaterialFileService.deleteFileByid(id);
// tMaterialFileService.deleteBatch(id);
return R.ok();
}
//@Log("获取附件信息")
@RequestMapping("/info/{id}")
@RequiresPermissions("basic")
public R info(@PathVariable("id") String id) {
TMaterialFile tMaterialFile = tMaterialFileService.selectById(id);
return R.ok().put("tMaterialFile", tMaterialFile);
}
//@Log("保存文件上传")
@RequestMapping("/save")
// @RequiresPermissions("basic")
public R save(@RequestBody TMaterialFile tMaterialFile) {
ValidatorUtils.validateEntity(tMaterialFile, AddGroup.class);
tMaterialFileService.insert(tMaterialFile);
return R.ok();
}
//@Log("修改文件上传")
@RequestMapping("/update")
// @RequiresPermissions("platform:programme:update")
public R update(@RequestBody TMaterialFile tMaterialFile) {
ValidatorUtils.validateEntity(tMaterialFile, UpdateGroup.class);
tMaterialFileService.updateById(tMaterialFile);
return R.ok();
}
//@Log("删除文件上传")
@RequestMapping("/delete")
// @RequiresPermissions("basic")
public R delete(@RequestBody String[] ids) {
tMaterialFileService.deleteBatch(ids);
return R.ok();
}
/**
*
*/
//@Log("上传文件")
@RequestMapping("uploadFile")
// @RequiresPermissions("basic")
public R uploadFile(MultipartFile file) {
String path = tMaterialFileService.uploadFile(file);
return R.ok().put("fileName", file.getOriginalFilename()).put("path", path);
}
/**
*
* @throws Exception
*/
//@Log("上传文件")
@RequestMapping("importPsot")
// @RequiresPermissions("sys:tMaterialFile:importPsot")
public R importPsot(HttpServletRequest request) throws Exception {
System.out.println("requestrequestrequestrequest"+request);
// Boolean result=tMaterialFileService.verification(request.getParameter("fileList111"), getUser());
// System.out.println("resultresultresult"+result);
// if (result==false) {
// return R.error("false");
// }
// String dataPath = sysSwitchService.selectOne(new EntityWrapper<SysSwitch>()).getFileuplpadurl();
String dataPath = "D:\\upload";
Map<String, String> map = tMaterialFileService.importPsot(request);
// if (map.get("mibiaotest")!=null) {
// return R.error("false1");
// }
return R.ok().put("fileName", map.get("fileName")).put("path", map.get("path")).put("id", map.get("id")).put("dataPath", dataPath).put("mbfklj", map.get("mbfklj"));
}
/**
*
* @throws Exception
*/
//@Log("上传文件")
@RequestMapping("importPsotfiles")
// @RequiresPermissions("basic")
public R importPsotfiles(HttpServletRequest request) throws Exception {
// String dataPath = sysSwitchService.selectOne(new EntityWrapper<SysSwitch>()).getFileuplpadurl();
// Map<String, String> map = tMaterialFileService.importPsotfiles(request);
// return R.ok().put("fileName", map.get("fileName")).put("path", map.get("path")).put("id", map.get("id")).put("dataPath", dataPath);
return null;
}
//@Log("文件是否存在")
@RequestMapping("ishSingleFile/{preachDataId}")
//@RequiresPermissions("basic")
public R ishSingleFile(@PathVariable("preachDataId") String preachDataId) {
// String dataPath = sysSwitchService.selectOne(new EntityWrapper<SysSwitch>()).getFileuplpadurl();
String dataPath = "D:\\upload";
TMaterialFile tMaterialFile = tMaterialFileService.selectById(preachDataId);
System.out.println("dataPathdataPathdataPath"+dataPath +"/"+ tMaterialFile.getSfilename());
String fileName="";
if(tMaterialFile!=null) {
File file = new File(dataPath +"/"+ tMaterialFile.getSfilename());
if (!file.exists()) {
fileName = "文件不存在";
return R.ok().put("fileName", fileName);
}
}else {
fileName = "无下载文件";
}
System.out.println("fileNamefileNamefileNamefileNamefileName"+fileName);
return R.ok().put("fileName", fileName);
// return null;
}
//@Log("下载文件")
@RequestMapping("/downFile")
public void downFile(HttpServletRequest request, HttpServletResponse response, String id) throws Exception {
TMaterialFile tMaterialFile = tMaterialFileService.selectById(id);
try {
FileUpLoadUtil.downloadAttachments("","D:\\upload", tMaterialFile.getSfilename(), tMaterialFile.getSfilelength(),tMaterialFile, response);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//删除文件
//@Log("删除文件")
@RequestMapping("deleteFile")
// @RequiresPermissions("basic")
public R deleteFile(@RequestBody String filePath) {
// System.out.println("filePathfilePath"+filePath);
tMaterialFileService.deleteFile(filePath);
return R.ok();
}
//删除文件
//@Log("删除文件")
@RequestMapping("/deleteFileByid/{id}")
// @RequiresPermissions("basic")
public R deleteFileByid(@PathVariable("id") String id) {
tMaterialFileService.deleteFileByid(id);
return R.ok();
}
//@Log("下载文件")
@RequestMapping("/ishFile/{id}")
// @RequiresPermissions("basic")
public R ishFile(@PathVariable("id") String id) {
// String dataPath = sysSwitchService.selectOne(new EntityWrapper<SysSwitch>()).getFileuplpadurl();
String dataPath = "D://uoload";
TMaterialFile tMaterialFile = tMaterialFileService.selectById(id);
String fileName="";
if(tMaterialFile!=null&& tMaterialFile.getSfilename()!=null) {
File file = new File(dataPath +"/"+ tMaterialFile.getSfilename());
if (!file.exists()) {
fileName = "文件不存在";
return R.ok().put("fileName", fileName);
}
}else {
fileName = "无下载文件";
}
return R.ok().put("fileName", fileName);
}
}

@ -0,0 +1,26 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import cn.jeefast.system.entity.SysDept;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysDeptDao extends BaseMapper<SysDept> {
List<SysDept> queryList(Map<String, Object> map);
/**
* ID
* @param parentId ID
*/
List<Long> queryDetpIdList(Long parentId);
}

@ -0,0 +1,32 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import cn.jeefast.system.entity.SysLog;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysLogDao extends BaseMapper<SysLog> {
/**
* <p>
* : state
* </p>
*
* @param page
* xml 使 Page
* @param state
*
* @return
*/
List<SysLog> selectPageList(Pagination page, Map<String, Object> map);
}

@ -0,0 +1,38 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import cn.jeefast.system.entity.SysMenu;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysMenuDao extends BaseMapper<SysMenu> {
List<SysMenu> queryList(Map<String, Object> map);
/**
*
* @param parentId ID
*/
List<SysMenu> queryListParentId(Long parentId);
/**
*
*/
List<SysMenu> queryNotButtonList();
/**
*
*/
List<SysMenu> queryUserList(Long userId);
int deleteBatch(Object[] id);
}

@ -0,0 +1,21 @@
package cn.jeefast.system.dao;
import cn.jeefast.system.entity.SysPjinfo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysPjinfoDao extends BaseMapper<SysPjinfo> {
List<SysPjinfo> queryPageList(Page<SysPjinfo> page, Map<String, Object> map);
int deleteBatch(Object[] id);
}

@ -0,0 +1,25 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.jeefast.system.entity.SysRole;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysRoleDao extends BaseMapper<SysRole> {
List<SysRole> queryPageList(Page<SysRole> page, Map<String, Object> map);
List<SysRole> queryList(Map<String, Object> map);
int deleteBatch(Object[] id);
}

@ -0,0 +1,26 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import cn.jeefast.system.entity.SysRoleDept;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysRoleDeptDao extends BaseMapper<SysRoleDept> {
/**
* IDID
*/
List<Long> queryDeptIdList(Long roleId);
void save(Map<String, Object> map);
void deleteByRoleId(Object roleId);
}

@ -0,0 +1,27 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import cn.jeefast.system.entity.SysRoleMenu;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysRoleMenuDao extends BaseMapper<SysRoleMenu> {
/**
* IDID
*/
List<Long> queryMenuIdList(Long roleId);
void save(Map<String, Object> map);
void deleteByRoleId(Long roleId);
}

@ -0,0 +1,21 @@
package cn.jeefast.system.dao;
import cn.jeefast.system.entity.SysSlxxb;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysSlxxbDao extends BaseMapper<SysSlxxb> {
List<SysSlxxb> queryPageList(Page<SysSlxxb> page, Map<String, Object> map);
int deleteBatch(Object[] id);
}

@ -0,0 +1,43 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.jeefast.system.entity.SysUser;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysUserDao extends BaseMapper<SysUser> {
List<SysUser> queryPageList(Page<SysUser> page, Map<String, Object> map);
List<SysUser> queryList(Map<String, Object> map);
/**
*
* @param userId ID
*/
List<String> queryAllPerms(Long userId);
/**
* ID
*/
List<Long> queryAllMenuId(Long userId);
/**
*
*/
SysUser queryByUserName(String username);
int deleteBatch(Object[] id);
}

@ -0,0 +1,28 @@
package cn.jeefast.system.dao;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import cn.jeefast.system.entity.SysUserRole;
/**
* <p>
* Mapper
* </p>
*
*/
public interface SysUserRoleDao extends BaseMapper<SysUserRole> {
List<SysUserRole> queryList(Map<String, Object> map);
/**
* IDID
*/
List<Long> queryRoleIdList(Long userId);
void save(Map<String, Object> map);
int deleteByUserId(Long userId);
}

@ -0,0 +1,17 @@
package cn.jeefast.system.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import cn.jeefast.system.entity.SysUserToken;
/**
* <p>
* Token Mapper
* </p>
*
*/
public interface SysUserTokenDao extends BaseMapper<SysUserToken> {
SysUserToken queryByToken(String token);
}

@ -0,0 +1,22 @@
package cn.jeefast.system.dao;
import cn.jeefast.system.entity.SysXinwen;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper
* </p>
*
* @author theodo
* @since 2022-03-30
*/
public interface SysXinwenDao extends BaseMapper<SysXinwen> {
List<SysXinwen> queryPageList(Page<SysXinwen> page, Map<String, Object> map);
int deleteBatch(Object[] id);
}

@ -0,0 +1,22 @@
package cn.jeefast.system.dao;
import cn.jeefast.system.entity.TMaterialFile;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper
* </p>
*
*/
public interface TMaterialFileDao extends BaseMapper<TMaterialFile> {
List<TMaterialFile> queryPageList(Page<TMaterialFile> page, Map<String, Object> map);
void deleteBatch(String[] ids);
}

@ -0,0 +1,178 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import java.util.List;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_dept")
public class SysDept extends Model<SysDept> {
private static final long serialVersionUID = 1L;
@TableId(value="dept_id", type= IdType.AUTO)
private Long deptId;
/**
* ID0
*/
@TableField("parent_id")
private Long parentId;
/**
*
*/
private String name;
/**
*
*/
@TableField("order_num")
private Integer orderNum;
/**
* -1 0
*/
@TableField("del_flag")
private Integer delFlag;
/**
*
*/
@TableField(exist=false)
private String parentName;
/**
* ztree
*/
@TableField(exist=false)
private Boolean open;
@TableField(exist=false)
private List<?> list;
/**
*
*/
@TableField(exist=false)
private Integer rs;
private String upstr;
private String downstr;
public Integer getRs() {
return rs;
}
public void setRs(Integer rs) {
this.rs = rs;
}
public String getUpstr() {
return upstr;
}
public void setUpstr(String upstr) {
this.upstr = upstr;
}
public String getDownstr() {
return downstr;
}
public void setDownstr(String downstr) {
this.downstr = downstr;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public Boolean getOpen() {
return open;
}
public void setOpen(Boolean open) {
this.open = open;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
@Override
protected Serializable pkVal() {
return this.deptId;
}
@Override
public String toString() {
return "SysDept{" +
"deptId=" + deptId +
", parentId=" + parentId +
", name='" + name + '\'' +
", orderNum=" + orderNum +
", delFlag=" + delFlag +
", parentName='" + parentName + '\'' +
", open=" + open +
", list=" + list +
", rs=" + rs +
", upstr='" + upstr + '\'' +
", downstr='" + downstr + '\'' +
'}';
}
}

@ -0,0 +1,138 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_log")
public class SysLog extends Model<SysLog> {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Long id;
/**
*
*/
private String username;
/**
*
*/
private String operation;
/**
*
*/
private String method;
/**
*
*/
private String params;
/**
* ()
*/
private Long time;
/**
* IP
*/
private String ip;
/**
*
*/
@TableField("create_date")
private Date createDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysLog{" +
", id=" + id +
", username=" + username +
", operation=" + operation +
", method=" + method +
", params=" + params +
", time=" + time +
", ip=" + ip +
", createDate=" + createDate +
"}";
}
}

@ -0,0 +1,163 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import java.util.List;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_menu")
public class SysMenu extends Model<SysMenu> {
private static final long serialVersionUID = 1L;
@TableId(value="menu_id", type= IdType.AUTO)
private Long menuId;
/**
* ID0
*/
@TableField("parent_id")
private Long parentId;
/**
*
*/
private String name;
/**
* URL
*/
private String url;
/**
* (user:list,user:create)
*/
private String perms;
/**
* 0 1 2
*/
private Integer type;
/**
*
*/
private String icon;
/**
*
*/
@TableField("order_num")
private Integer orderNum;
/**
* ztree
*/
@TableField(exist=false)
private Boolean open;
@TableField(exist=false)
private List<?> list;
public Long getMenuId() {
return menuId;
}
public void setMenuId(Long menuId) {
this.menuId = menuId;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getPerms() {
return perms;
}
public void setPerms(String perms) {
this.perms = perms;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public Boolean getOpen() {
return open;
}
public void setOpen(Boolean open) {
this.open = open;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
@Override
protected Serializable pkVal() {
return this.menuId;
}
@Override
public String toString() {
return "SysMenu{" +
", menuId=" + menuId +
", parentId=" + parentId +
", name=" + name +
", url=" + url +
", perms=" + perms +
", type=" + type +
", icon=" + icon +
", orderNum=" + orderNum +
"}";
}
}

@ -0,0 +1,150 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable;
import java.util.List;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_pjinfo")
public class SysPjinfo extends Model<SysPjinfo> {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Long id;
/**
*
*/
private String title;
/**
*
*/
private String content;
/**
*
*/
private String author;
private String pjtype;
private String deptid;
private String username;
private String prentid;
@TableField(exist=false)
private List<SysPjinfo> sysPjinfoList;
public List<SysPjinfo> getSysPjinfoList() {
return sysPjinfoList;
}
public void setSysPjinfoList(List<SysPjinfo> sysPjinfoList) {
sysPjinfoList = sysPjinfoList;
}
public String getPrentid() {
return prentid;
}
public void setPrentid(String prentid) {
this.prentid = prentid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@TableField(exist = false)
private String deptName;
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getPjtype() {
return pjtype;
}
public void setPjtype(String pjtype) {
this.pjtype = pjtype;
}
public String getDeptid() {
return deptid;
}
public void setDeptid(String deptid) {
this.deptid = deptid;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysPjinfo{" +
"id=" + id +
", title='" + title + '\'' +
", content='" + content + '\'' +
", author='" + author + '\'' +
", pjtype='" + pjtype + '\'' +
", deptid='" + deptid + '\'' +
", username='" + username + '\'' +
", prentid='" + prentid + '\'' +
", SysPjinfoList=" + sysPjinfoList +
", deptName='" + deptName + '\'' +
'}';
}
}

@ -0,0 +1,143 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_role")
public class SysRole extends Model<SysRole> {
private static final long serialVersionUID = 1L;
@TableId(value="role_id", type= IdType.AUTO)
private Long roleId;
/**
*
*/
@TableField("role_name")
@NotBlank(message="角色名称不能为空")
private String roleName;
/**
*
*/
private String remark;
/**
* ID
*/
@TableField("dept_id")
// @NotNull(message="部门不能为空")
private Long deptId;
/**
*
*/
@TableField("create_time")
private Date createTime;
/**
*
*/
@TableField(exist=false)
private String deptName;
@TableField(exist=false)
private List<Long> menuIdList;
@TableField(exist=false)
private List<Long> deptIdList;
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public List<Long> getDeptIdList() {
return deptIdList;
}
public void setDeptIdList(List<Long> deptIdList) {
this.deptIdList = deptIdList;
}
public List<Long> getMenuIdList() {
return menuIdList;
}
public void setMenuIdList(List<Long> menuIdList) {
this.menuIdList = menuIdList;
}
@Override
protected Serializable pkVal() {
return this.roleId;
}
@Override
public String toString() {
return "SysRole{" +
", roleId=" + roleId +
", roleName=" + roleName +
", remark=" + remark +
", deptId=" + deptId +
", createTime=" + createTime +
"}";
}
}

@ -0,0 +1,73 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_role_dept")
public class SysRoleDept extends Model<SysRoleDept> {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Long id;
/**
* ID
*/
@TableField("role_id")
private Long roleId;
/**
* ID
*/
@TableField("dept_id")
private Long deptId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysRoleDept{" +
", id=" + id +
", roleId=" + roleId +
", deptId=" + deptId +
"}";
}
}

@ -0,0 +1,73 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_role_menu")
public class SysRoleMenu extends Model<SysRoleMenu> {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Long id;
/**
* ID
*/
@TableField("role_id")
private Long roleId;
/**
* ID
*/
@TableField("menu_id")
private Long menuId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Long getMenuId() {
return menuId;
}
public void setMenuId(Long menuId) {
this.menuId = menuId;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysRoleMenu{" +
", id=" + id +
", roleId=" + roleId +
", menuId=" + menuId +
"}";
}
}

@ -0,0 +1,219 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import java.util.Date;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_slxxb")
public class SysSlxxb extends Model<SysSlxxb> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.UUID)
private String id;
/**
* ,1:,2:
*/
private String type;
/**
*
*/
private Double slj;
/**
*
*/
private String username;
/**
*
*/
private Date jcsj;
/**
* ,1:,2:
*/
private String sfzc;
/**
*
*/
private Date updatetime;
/**
*
*/
private String updateuser;
/**
*
*/
private Date createtime;
/**
*
*/
private String createuser;
@TableField(exist = false)
private String typename;
@TableField(exist = false)
private String sfzcname;
public String getTypename() {
return typename;
}
public void setTypename(String typename) {
this.typename = typename;
}
public String getSfzcname() {
return sfzcname;
}
public void setSfzcname(String sfzcname) {
this.sfzcname = sfzcname;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Double getSlj() {
return slj;
}
public void setSlj(Double slj) {
this.slj = slj;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Date getJcsj() {
return jcsj;
}
public void setJcsj(Date jcsj) {
this.jcsj = jcsj;
}
public String getSfzc() {
return sfzc;
}
public void setSfzc(String sfzc) {
this.sfzc = sfzc;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getUpdateuser() {
return updateuser;
}
public void setUpdateuser(String updateuser) {
this.updateuser = updateuser;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getCreateuser() {
return createuser;
}
public void setCreateuser(String createuser) {
this.createuser = createuser;
}
/**
*
*/
@TableField(exist = false)
private JSONArray files;
public JSONArray getFiles() {
return files;
}
public void setFiles(JSONArray files) {
this.files = files;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysSlxxb{" +
"id='" + id + '\'' +
", type='" + type + '\'' +
", slj=" + slj +
", username='" + username + '\'' +
", jcsj=" + jcsj +
", sfzc='" + sfzc + '\'' +
", updatetime=" + updatetime +
", updateuser='" + updateuser + '\'' +
", createtime=" + createtime +
", createuser='" + createuser + '\'' +
", typename='" + typename + '\'' +
", sfzcname='" + sfzcname + '\'' +
", files=" + files +
'}';
}
}

@ -0,0 +1,513 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.enums.IdType;
import cn.jeefast.common.validator.group.AddGroup;
import cn.jeefast.common.validator.group.UpdateGroup;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_user")
public class SysUser extends Model<SysUser> {
private static final long serialVersionUID = 1L;
@TableId(value="user_id", type= IdType.AUTO)
private Long userId;
/**
*
*/
@NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String username;
/**
*
*/
@NotBlank(message="密码不能为空", groups = AddGroup.class)
private String password;
/**
*
*/
private String salt;
/**
*
*/
// @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
// @Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
private String email;
/**
*
*/
private String mobile;
/**
* 0 1
*/
private Integer status;
/**
* ID
*/
@TableField("dept_id")
// @NotNull(message="部门不能为空", groups = {AddGroup.class, UpdateGroup.class})
private Long deptId;
/**
*
*/
@TableField(exist=false)
private String deptName;
/**
* ID
*/
@TableField(exist=false)
private List<Long> roleIdList;
/**
*
*/
@TableField("create_time")
private Date createTime;
/**
* ID
*/
@TableField(exist=false)
private Long createUserId;
/**
*
*/
@TableField(exist=false)
private String roalArraystr;
/**
*
*/
@TableField(exist=false)
private String photopath;
/**
* qq
*/
private String qq;
/**
*
*/
private String idnumb;
/**
*
*/
private String wxnub;
/**
*
*/
private String birthday;
/**
*
*/
private String political;
/**
*
*/
private String ramark;
/**
*
*/
private BigDecimal membership;
private String stadynum;//学号/工号
private String realname;//真名
private String college;//学院
private String major;//专业
private String classinfo;//班级
private String grade;//年级
private String photo;//个人照片
private String type;//人员类型
private String address;
private String xb;
@TableField(exist=false)
private String zyycjg;
@TableField(exist=false)
private String yyycjg;
@TableField(exist=false)
private String zysfbj;
@TableField(exist=false)
private String yysfbj;
public String getZyycjg() {
return zyycjg;
}
public void setZyycjg(String zyycjg) {
this.zyycjg = zyycjg;
}
public String getYyycjg() {
return yyycjg;
}
public void setYyycjg(String yyycjg) {
this.yyycjg = yyycjg;
}
public String getZysfbj() {
return zysfbj;
}
public void setZysfbj(String zysfbj) {
this.zysfbj = zysfbj;
}
public String getYysfbj() {
return yysfbj;
}
public void setYysfbj(String yysfbj) {
this.yysfbj = yysfbj;
}
public String getXb() {
return xb;
}
public void setXb(String xb) {
this.xb = xb;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhotopath() {
return photopath;
}
public void setPhotopath(String photopath) {
this.photopath = photopath;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
/**
*
*/
@TableField(exist = false)
private JSONArray files;
public JSONArray getFiles() {
return files;
}
public void setFiles(JSONArray files) {
this.files = files;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getStadynum() {
return stadynum;
}
public void setStadynum(String stadynum) {
this.stadynum = stadynum;
}
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public String getCollege() {
return college;
}
public void setCollege(String college) {
this.college = college;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getClassinfo() {
return classinfo;
}
public void setClassinfo(String classinfo) {
this.classinfo = classinfo;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public BigDecimal getMembership() {
return membership;
}
public void setMembership(BigDecimal membership) {
this.membership = membership;
}
public String getRamark() {
return ramark;
}
public void setRamark(String ramark) {
this.ramark = ramark;
}
public String getPolitical() {
return political;
}
public void setPolitical(String political) {
this.political = political;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getWxnub() {
return wxnub;
}
public void setWxnub(String wxnub) {
this.wxnub = wxnub;
}
public String getIdnumb() {
return idnumb;
}
public void setIdnumb(String idnumb) {
this.idnumb = idnumb;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public List<Long> getRoleIdList() {
return roleIdList;
}
public void setRoleIdList(List<Long> roleIdList) {
this.roleIdList = roleIdList;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public String getRoalArraystr() {
return roalArraystr;
}
public void setRoalArraystr(String roalArraystr) {
this.roalArraystr = roalArraystr;
}
@Override
protected Serializable pkVal() {
return this.userId;
}
@Override
public String toString() {
return "SysUser{" +
"userId=" + userId +
", username='" + username + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", email='" + email + '\'' +
", mobile='" + mobile + '\'' +
", status=" + status +
", deptId=" + deptId +
", deptName='" + deptName + '\'' +
", roleIdList=" + roleIdList +
", createTime=" + createTime +
", createUserId=" + createUserId +
", roalArraystr='" + roalArraystr + '\'' +
", photopath='" + photopath + '\'' +
", qq='" + qq + '\'' +
", idnumb='" + idnumb + '\'' +
", wxnub='" + wxnub + '\'' +
", birthday='" + birthday + '\'' +
", political='" + political + '\'' +
", ramark='" + ramark + '\'' +
", membership=" + membership +
", stadynum='" + stadynum + '\'' +
", realname='" + realname + '\'' +
", college='" + college + '\'' +
", major='" + major + '\'' +
", classinfo='" + classinfo + '\'' +
", grade='" + grade + '\'' +
", photo='" + photo + '\'' +
", type='" + type + '\'' +
", address='" + address + '\'' +
", xb='" + xb + '\'' +
", zyycjg='" + zyycjg + '\'' +
", yyycjg='" + yyycjg + '\'' +
", zysfbj='" + zysfbj + '\'' +
", yysfbj='" + yysfbj + '\'' +
", files=" + files +
'}';
}
}

@ -0,0 +1,73 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
*
* </p>
*
*/
@TableName("sys_user_role")
public class SysUserRole extends Model<SysUserRole> {
private static final long serialVersionUID = 1L;
@TableId(value="id", type= IdType.AUTO)
private Long id;
/**
* ID
*/
@TableField("user_id")
private Long userId;
/**
* ID
*/
@TableField("role_id")
private Long roleId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysUserRole{" +
", id=" + id +
", userId=" + userId +
", roleId=" + roleId +
"}";
}
}

@ -0,0 +1,97 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
/**
* <p>
* Token
* </p>
*
*/
@TableName("sys_user_token")
public class SysUserToken extends Model<SysUserToken> {
private static final long serialVersionUID = 1L;
@TableId("id")
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private Long userId;
/**
* token
*/
private String token;
/**
*
*/
@TableField("expire_time")
private Date expireTime;
/**
*
*/
@TableField("update_time")
private Date updateTime;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Date getExpireTime() {
return expireTime;
}
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
protected Serializable pkVal() {
return this.userId;
}
@Override
public String toString() {
return "SysUserToken{" +
"id=" + id +
", userId=" + userId +
", token='" + token + '\'' +
", expireTime=" + expireTime +
", updateTime=" + updateTime +
'}';
}
}

@ -0,0 +1,218 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import java.util.Date;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author theodo
* @since 2022-03-30
*/
@TableName("sys_xinwen")
public class SysXinwen extends Model<SysXinwen> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.UUID)
private String id;
/**
*
*/
private String title;
/**
*
*/
private String content;
/**
*
*/
private String zuozhe;
/**
*
*/
private String createuser;
/**
*
*/
private String updateuser;
/**
*
*/
private Date updatetime;
/**
*
*/
private Date createtime;
private String type;//分类1健康资讯2公司简介
private String zbx;
private String zby;
@TableField(exist = false)
private String qzbx;
@TableField(exist = false)
private String qzby;
@TableField(exist = false)
private JSONArray files;
public JSONArray getFiles() {
return files;
}
public void setFiles(JSONArray files) {
this.files = files;
}
public String getQzbx() {
return qzbx;
}
public void setQzbx(String qzbx) {
this.qzbx = qzbx;
}
public String getQzby() {
return qzby;
}
public void setQzby(String qzby) {
qzby = qzby;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getZbx() {
return zbx;
}
public void setZbx(String zbx) {
this.zbx = zbx;
}
public String getZby() {
return zby;
}
public void setZby(String zby) {
this.zby = zby;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getZuozhe() {
return zuozhe;
}
public void setZuozhe(String zuozhe) {
this.zuozhe = zuozhe;
}
public String getCreateuser() {
return createuser;
}
public void setCreateuser(String createuser) {
this.createuser = createuser;
}
public String getUpdateuser() {
return updateuser;
}
public void setUpdateuser(String updateuser) {
this.updateuser = updateuser;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "SysXinwen{" +
"id='" + id + '\'' +
", title='" + title + '\'' +
", content='" + content + '\'' +
", zuozhe='" + zuozhe + '\'' +
", createuser='" + createuser + '\'' +
", updateuser='" + updateuser + '\'' +
", updatetime=" + updatetime +
", createtime=" + createtime +
", type='" + type + '\'' +
", zbx='" + zbx + '\'' +
", zby='" + zby + '\'' +
", qzbx='" + qzbx + '\'' +
", qzby='" + qzby + '\'' +
", files='" + files + '\'' +
'}';
}
}

@ -0,0 +1,108 @@
package cn.jeefast.system.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
*/
@TableName("tb_scms_file")
public class TMaterialFile extends Model<TMaterialFile> {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.UUID)
private String id;
//存储状态
private Integer smodelidstate;
//附件名
private String sfilename;
//附件路径
private String sfilelength;
//存储源文件名
private String saccessoryname;
//新表父id
private String parentid;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getSmodelidstate() {
return smodelidstate;
}
public void setSmodelidstate(Integer smodelidstate) {
this.smodelidstate = smodelidstate;
}
public String getSfilename() {
return sfilename;
}
public void setSfilename(String sfilename) {
this.sfilename = sfilename;
}
public String getSfilelength() {
return sfilelength;
}
public void setSfilelength(String sfilelength) {
this.sfilelength = sfilelength;
}
public String getSaccessoryname() {
return saccessoryname;
}
public void setSaccessoryname(String saccessoryname) {
this.saccessoryname = saccessoryname;
}
public String getParentid() {
return parentid;
}
public void setParentid(String parentid) {
this.parentid = parentid;
}
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "TMaterialFile{" +
"id='" + id + '\'' +
", smodelidstate=" + smodelidstate +
", sfilename='" + sfilename + '\'' +
", sfilelength='" + sfilelength + '\'' +
", saccessoryname='" + saccessoryname + '\'' +
", parentid='" + parentid + '\'' +
'}';
}
}

@ -0,0 +1,91 @@
package cn.jeefast.system.oauth2;
import com.google.gson.Gson;
import cn.jeefast.common.utils.R;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.web.filter.authc.AuthenticatingFilter;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* oauth2
*
*/
public class OAuth2Filter extends AuthenticatingFilter {
@Override
protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception {
//获取请求token
String token = getRequestToken((HttpServletRequest) request);
if(StringUtils.isBlank(token)){
return null;
}
return new OAuth2Token(token);
}
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
return false;
}
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
//获取请求token如果token不存在直接返回401
String token = getRequestToken((HttpServletRequest) request);
if(StringUtils.isBlank(token)){
HttpServletResponse httpResponse = (HttpServletResponse) response;
String json = new Gson().toJson(R.error(HttpStatus.SC_UNAUTHORIZED, "invalid token"));
httpResponse.getWriter().print(json);
return false;
}
return executeLogin(request, response);
}
@Override
protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response) {
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setContentType("application/json;charset=utf-8");
try {
//处理登录失败的异常
Throwable throwable = e.getCause() == null ? e : e.getCause();
R r = R.error(HttpStatus.SC_UNAUTHORIZED, throwable.getMessage());
String json = new Gson().toJson(r);
httpResponse.getWriter().print(json);
} catch (IOException e1) {
}
return false;
}
/**
* token
*/
private String getRequestToken(HttpServletRequest httpRequest){
//从header中获取token
String token = httpRequest.getHeader("token");
//如果header中不存在token则从参数中获取token
if(StringUtils.isBlank(token)){
token = httpRequest.getParameter("token");
}
return token;
}
}

@ -0,0 +1,71 @@
package cn.jeefast.system.oauth2;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.jeefast.system.entity.SysUser;
import cn.jeefast.system.entity.SysUserToken;
import cn.jeefast.system.service.ShiroService;
import java.util.Set;
/**
*
*
*/
@Component
public class OAuth2Realm extends AuthorizingRealm {
@Autowired
private ShiroService shiroService;
@Override
public boolean supports(AuthenticationToken token) {
return token instanceof OAuth2Token;
}
/**
* ()
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SysUser user = (SysUser)principals.getPrimaryPrincipal();
Long userId = user.getUserId();
//用户权限列表
Set<String> permsSet = shiroService.getUserPermissions(userId);
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
info.setStringPermissions(permsSet);
return info;
}
/**
* ()
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
String accessToken = (String) token.getPrincipal();
//根据accessToken查询用户信息
SysUserToken tokenEntity = shiroService.queryByToken(accessToken);
//token失效
if(tokenEntity == null || tokenEntity.getExpireTime().getTime() < System.currentTimeMillis()){
throw new IncorrectCredentialsException("token失效请重新登录");
}
//查询用户信息
SysUser user = shiroService.queryUser(tokenEntity.getUserId());
//账号锁定
if(user.getStatus() == 0){
throw new LockedAccountException("账号已被锁定,请联系管理员");
}
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, accessToken, getName());
return info;
}
}

@ -0,0 +1,28 @@
package cn.jeefast.system.oauth2;
import org.apache.shiro.authc.AuthenticationToken;
/**
* token
*
*/
public class OAuth2Token implements AuthenticationToken {
private static final long serialVersionUID = 1L;
private String token;
public OAuth2Token(String token){
this.token = token;
}
@Override
public String getPrincipal() {
return token;
}
@Override
public Object getCredentials() {
return token;
}
}

@ -0,0 +1,43 @@
package cn.jeefast.system.oauth2;
import java.security.MessageDigest;
import java.util.UUID;
import cn.jeefast.common.exception.RRException;
/**
* token
*
*/
public class TokenGenerator {
public static String generateValue() {
return generateValue(UUID.randomUUID().toString());
}
private static final char[] hexCode = "0123456789abcdef".toCharArray();
public static String toHexString(byte[] data) {
if(data == null) {
return null;
}
StringBuilder r = new StringBuilder(data.length*2);
for ( byte b : data) {
r.append(hexCode[(b >> 4) & 0xF]);
r.append(hexCode[(b & 0xF)]);
}
return r.toString();
}
public static String generateValue(String param) {
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(param.getBytes());
byte[] messageDigest = algorithm.digest();
return toHexString(messageDigest);
} catch (Exception e) {
throw new RRException("生成Token失败", e);
}
}
}

@ -0,0 +1,23 @@
package cn.jeefast.system.redis;
import cn.jeefast.common.utils.RedisKeys;
import cn.jeefast.common.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Redis
*
*/
@Component
public class SysConfigRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(String configKey) {
String key = RedisKeys.getSysConfigKey(configKey);
redisUtils.delete(key);
}
}

@ -0,0 +1,24 @@
package cn.jeefast.system.service;
import java.util.Set;
import cn.jeefast.system.entity.SysUser;
import cn.jeefast.system.entity.SysUserToken;
/**
* shiro
*/
public interface ShiroService {
/**
*
*/
Set<String> getUserPermissions(long userId);
SysUserToken queryByToken(String token);
/**
* ID
* @param userId
*/
SysUser queryUser(Long userId);
}

@ -0,0 +1,29 @@
package cn.jeefast.system.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.service.IService;
import cn.jeefast.system.entity.SysDept;
/**
* <p>
*
* </p>
*
*/
public interface SysDeptService extends IService<SysDept> {
List<SysDept> queryList(Map<String, Object> map);
/**
* ID
* @param parentId ID
*/
public List<Long> queryDetpIdList(Long parentId);
/**
* ID(ID)
*/
String getSubDeptIdList(Long deptId);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save