——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Node.js≥14
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
❗没学过node.js的不要搞前后端分离项目
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SpringBoot物资管理系统(java+springboot+vue+maven+mysql+redis)
1 2 3 4 5 6 7 8 9
| 登录: user1 123456 应急事件管理员 user2 123456 应急物资管理员 user3 123456 运输管理员 user4 123456 审批人员
前端启动命令: npm run serve
|
一、项目运行 环境配置:
Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
@Override @SneakyThrows protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) { HttpServletRequest request = (HttpServletRequest) servletRequest;
log.warn("onAccessDenied 方法被调用:::"+ request.getRequestURI());
String jwt = request.getHeader("Authorization"); log.info("从Request-Header中获取Authorization: {}", jwt); JwtToken jwtToken = new JwtToken(jwt); jwtToken.setServletRequest(servletRequest);
try { getSubject(servletRequest, servletResponse).login(jwtToken); } catch (Exception e) { final HttpServletResponse response = (HttpServletResponse) servletResponse; response.setContentType("application/json; charset=utf-8"); response.setCharacterEncoding("UTF-8");
final String s = Tips.getAndRemove();
String jsonString = JSONObject.toJSONString(RWrapper.failure((HttpServletRequest) servletRequest, ResultCode.UN_AUTHORIZATION , s));
final PrintWriter writer = response.getWriter(); writer.write(jsonString); writer.flush(); writer.close();
return false; }
return true; } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| if (regex(IE11, userAgent)) { return IE11; } if (regex(IE10, userAgent)) { return IE10; } if (regex(IE9, userAgent)) { return IE9; } if (regex(IE8, userAgent)) { return IE8; } if (regex(IE7, userAgent)) { return IE7; } if (regex(IE6, userAgent)) { return IE6; } return OTHER; }
private static boolean regex(String regex, String str) { Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Matcher m = p.matcher(str); return m.find(); }
public static String getBrowserLanguage(HttpServletRequest request) { String browserLang = request.getLocale().getLanguage(); String browserLangCode = langMap.get(browserLang); if(browserLangCode == null) { browserLangCode = EN_US; } return browserLangCode; }
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
@Slf4j @ControllerAdvice @RestControllerAdvice public class GlobalExceptionHandler extends BaseGlobalExceptionHandler {
@Override @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(ConstraintViolationException.class) public RWrapper handleConstraintViolationException(ConstraintViolationException e, HttpServletRequest request) { return super.handleConstraintViolationException(e, request); }
@Override @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(HttpMessageNotReadableException.class) public RWrapper handleConstraintViolationException(HttpMessageNotReadableException e, HttpServletRequest request) { return super.handleConstraintViolationException(e, request); }
@Override
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| private <T> void idsCheck(List<T> ids) { if (Objects.isNull(ids) || ids.size() == 0) { throw new BusinessException("未指定对象ID"); } int dbCount = eventService.count(new QueryWrapper<EventPO>().lambda().in(EventPO::getId, ids)); if (dbCount != ids.size()) { throw new BusinessException("请求操作的ID数量:" + ids.size() + ",系统得到的实际可操作ID数量:" + dbCount + ", 数量不对等,部分ID可能不存在,请确认!"); } }
private <T> void idsCheck(T[] ids) { if (Objects.isNull(ids) || ids.length == 0) { throw new BusinessException("未指定对象ID"); } idsCheck(Arrays.asList(ids)); }
private <T> List<T> parseJson2Obj(String jsonString, Class<T> clazz) { List<T> list; try { list = JSON.parseArray(jsonString, clazz); } catch (Exception e) { throw new BusinessException("Json解析失败:" + e.getMessage()); } if (list.size() > OPERATE_MAX_BATCH) { throw new BusinessException("超出限制,批量插入最多允许:1000个对象/次"); } return list; }
}
public class BrowserUtils {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
@Slf4j @ControllerAdvice @RestControllerAdvice public class GlobalExceptionHandler extends BaseGlobalExceptionHandler {
@Override @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(ConstraintViolationException.class) public RWrapper handleConstraintViolationException(ConstraintViolationException e, HttpServletRequest request) { return super.handleConstraintViolationException(e, request); }
@Override @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(HttpMessageNotReadableException.class) public RWrapper handleConstraintViolationException(HttpMessageNotReadableException e, HttpServletRequest request) { return super.handleConstraintViolationException(e, request); }
@Override @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(BindException.class) public RWrapper handleBindException(BindException e, HttpServletRequest request) { final List<ObjectError> allErrors = e.getAllErrors(); LinkedList<Map<String, String>> res = new LinkedList<>(); allErrors.forEach(error->{ final Object[] arguments = error.getArguments(); DefaultMessageSourceResolvable defaultMessageSourceResolvable = (DefaultMessageSourceResolvable) arguments[0]; final String paramName = defaultMessageSourceResolvable.getDefaultMessage(); final String defaultMessage = error.getDefaultMessage(); res.add(Collections.singletonMap(paramName, defaultMessage)); });
return RWrapper.failure(ResultCode.BAD_REQUEST, res); }
@Override @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(MethodArgumentNotValidException.class) public RWrapper handleMethodArgumentNotValidException(MethodArgumentNotValidException e, HttpServletRequest request) { return super.handleMethodArgumentNotValidException(e, request); }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=031023501103200zk
https://javayms.pages.dev?id=031023501103200zk