——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明





基于javaweb的SpringBoot家庭财务管理系统(java+springboot+ssm+mysql+maven+thymeleaf+html)
一、项目简述
功能: 家庭财务管理系统,具有收入统计,支出统计,汇总报 表,工资录入,其他收入等录入开支信息,echart图标插 件弓I入展示,分页查询,角色管理,用户管理,权限管理 等功能
二、项目运行
环境配置: jdk8+mysql+Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都主持)
项目技术: Thymeleaf+SpringBoot+Mybatis+html+css+JavaScript+Echart
——————————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
| try { List<Payway> payways = billService.getAllPayways(); if (payways!=null && payways.size()>0){ return ResultUtil.success(payways); }else { return ResultUtil.unSuccess(); } } catch (Exception e) { return ResultUtil.error(e); } }
} package com.example.cwgl.configs;
public class SessionInterceptor implements HandlerInterceptor {
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println(request.getRequestURL()); HttpSession session = request.getSession();
if(session.getAttribute(Config.CURRENT_USERNAME) == null && getCookieUser(request)!=null){
if(HandlerMethod.class.equals(handler.getClass())){ Object controller = ((HandlerMethod) handler).getBean(); if (controller instanceof UserInfoController){ UserInfoController userInfoController = (UserInfoController) controller; String userinfoStr = getCookieUser(request); UserInfo userInfo = new UserInfo();
|
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
| */ public class LoggerInterceptor implements HandlerInterceptor {
private static Logger logger = LoggerFactory.getLogger(LoggerInterceptor.class); private static HttpSession session; private static String userid; private static StringBuilder sb = new StringBuilder(); @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (session==null && (session = request.getSession()) != null){ UserInfo userInfo = (UserInfo)session.getAttribute(Config.CURRENT_USERNAME); userid = userInfo == null? request.getHeader("userid") : userInfo.getId().toString(); } sb.setLength(0);
sb.append("用户编号【") .append(userid) .append("】正在访问:") .append(request.getRequestURL().toString()); logger.info(sb.toString()); return true; }
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (!request.getRequestURI().contains("/static/")){ sb.setLength(0); sb.append("Method:").append(((HandlerMethod)handler).getShortLogMessage()); logger.info(sb.toString()); Map<String, String[]> parameters = request.getParameterMap(); if (parameters.size() > 0){ sb.setLength(0); sb.append("Parameters: {"); for (String key : parameters.keySet()){ String value = parameters.get(key)[0]; if (value != null && !value.isEmpty()){ sb.append(key +":"+parameters.get(key)[0]+","); } } if (sb.lastIndexOf(",")!=-1){ sb.deleteCharAt(sb.lastIndexOf(",")); }
|
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 49 50 51 52
| return ResultUtil.error(e); } }
@RequestMapping("/updateBill") public Result update(Bill bill, HttpSession session){ if (Config.getSessionUser(session)!=null){ bill.setUserid(Config.getSessionUser(session).getId()); } Utils.log(bill.toString()); try { int num = billService.update(bill); if(num>0){ return ResultUtil.success("修改成功!",null); }else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/delBill") public Result del(int id){ try { int num = billService.del(id); if(num>0){ return ResultUtil.success("删除成功!",null); }else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/getPayways") public Result<Payway> getAllPayways(){
try { List<Payway> payways = billService.getAllPayways(); if (payways!=null && payways.size()>0){ return ResultUtil.success(payways); }else { return ResultUtil.unSuccess(); } } catch (Exception e) { return ResultUtil.error(e); } }
}
|
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
| }
}
@Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
sb.setLength(0); sb.append("用户编号【") .append(userid) .append("】") .append(request.getRequestURL().toString()) .append(" 访问结束... ");
logger.info(sb.toString());
} } package com.example.cwgl.utils;
public class Config {
public static String CURRENT_USERNAME = "currentUser";
public static int SUCCESS=200; public static int UNSUCCESS=400; public static int ERROR=500;
public static boolean ENABLE_CUSTOMEIZE_LOG = true;
public static UserInfo getSessionUser(HttpSession session){ return (UserInfo)session.getAttribute(CURRENT_USERNAME);
|
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 49
| } Utils.log(bill.toString()); try { int num = billService.add(bill); if(num>0){ int billid = bill.getId(); bill = new Bill(); bill.setId(billid); return ResultUtil.success("记账成功!",billService.findByWhereNoPage(bill));
}else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/updateBill") public Result update(Bill bill, HttpSession session){ if (Config.getSessionUser(session)!=null){ bill.setUserid(Config.getSessionUser(session).getId()); } Utils.log(bill.toString()); try { int num = billService.update(bill); if(num>0){ return ResultUtil.success("修改成功!",null); }else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/delBill") public Result del(int id){ try { int num = billService.del(id); if(num>0){ return ResultUtil.success("删除成功!",null); }else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
|
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 49 50 51 52 53 54
| return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/updateBill") public Result update(Bill bill, HttpSession session){ if (Config.getSessionUser(session)!=null){ bill.setUserid(Config.getSessionUser(session).getId()); } Utils.log(bill.toString()); try { int num = billService.update(bill); if(num>0){ return ResultUtil.success("修改成功!",null); }else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/delBill") public Result del(int id){ try { int num = billService.del(id); if(num>0){ return ResultUtil.success("删除成功!",null); }else { return ResultUtil.unSuccess(); } }catch (Exception e){ return ResultUtil.error(e); } }
@RequestMapping("/getPayways") public Result<Payway> getAllPayways(){
try { List<Payway> payways = billService.getAllPayways(); if (payways!=null && payways.size()>0){ return ResultUtil.success(payways); }else { return ResultUtil.unSuccess(); } } catch (Exception e) { return ResultUtil.error(e); } }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=341422312105200im
https://javayms.pages.dev?id=341422312105200im