基于javaweb+mysql的springboot个人投资理财系统(java+springboot+layui+html+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot个人投资理财系统(java+springboot+layui+html+mysql)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
return Msg.fail();
}
/**
* 删除银行卡
*
* @param id
* @return
*/
@DeleteMapping("/user/deleteBankCard/{id}")
@ResponseBody
public Msg deleteBankCard(@PathVariable("id") Integer id) {
Integer result = bankCardService.deleteBankCardById(id);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
/**
* 跳转到银行卡管理界面(管理员)
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@GetMapping("/admin/userinfo/toBankCard.html")
public String toBankCard1(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<Bankcard> list = bankCardService.selectAllBankCard();
PageInfo<Bankcard> pageInfo = new PageInfo<Bankcard>(list, 5);
model.addAttribute("bankcardPageInfo",pageInfo);
model.addAttribute("bankcardList",list);
model.addAttribute("pageTopBarInfo", "银行卡管理界面");
model.addAttribute("activeUrl1", "userInfoActive");
model.addAttribute("activeUrl2", "bankcardActive");
return "/admin/userinfo/bankcard";
}
}
e.printStackTrace();
}
return value;
}
}
}
@Controller
public class InfoController {
@Autowired
InfoService infoService;
/**
* 跳转到我的消息界面
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@RequestMapping("/user/personal/toMyInfo.html")
public String toMyInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
User loginUser = (User) session.getAttribute("loginUser");
PageHelper.startPage(pageNum, pageSize);
List<Info> list = infoService.selectInfoOrderByUserIdDesc(loginUser.getId());
PageInfo<Info> pageInfo = new PageInfo<Info>(list, 5);
model.addAttribute("infoPageInfo", pageInfo);
model.addAttribute("infoList", list);
model.addAttribute("pageTopBarInfo", "我的消息界面");
/**
* 更新用户信息(用户更改自己信息)
*
* @param id
* @param user
* @param session
* @return
*/
@PutMapping("/user/updateUserProfile/{userId}")
@ResponseBody
public Msg updateUserProfile(@PathVariable("userId") Integer id, User user, HttpSession session) {
user.setId(id);
Integer result = userService.updateUser(user);
if (result == 1) {
// 当前登录用户信息改变时session里面存储的用户信息也应该同时改变
User loginUser = (User) session.getAttribute("loginUser");
if (loginUser!=null){
if (id == (loginUser.getId())) {
session.setAttribute("loginUser", userService.selectUserById(id));
}
}
return Msg.success();
}
return Msg.fail();
}
/**
* 用户强制下线(管理员更改用户信息)
*
* @param id
* @param session
* @return
*/
@PutMapping("/user/updateUserStatus/{id}")
@ResponseBody
public Msg updateUserStatus(@PathVariable("id") Integer id, HttpSession session) {
User user = userService.selectUserById(id);
user.setStatus(0);
Integer result = userService.updateUser(user);
if (result == 1) {
// 当前登录用户强制下线
session.removeAttribute("loginUser");
return Msg.success();
}
return Msg.fail();
}
/**
* 跳转到用户信息界面(管理员)
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
model.addAttribute("bankCardList", list);
model.addAttribute("pageTopBarInfo", "银行卡管理界面");
model.addAttribute("activeUrl1", "personalActive");
model.addAttribute("activeUrl2", "bankCardActive");
return "/user/personal/bankcard";
}
/**
* 新增银行卡
*
* @param bankcard
* @param session
* @return
*/
@PostMapping("/user/addBankCard")
@ResponseBody
public Msg addBankCard(Bankcard bankcard, HttpSession session) {
//System.out.println(bankcard.getCardbank());
User loginUser = (User) session.getAttribute("loginUser");
bankcard.setUserid(loginUser.getId());
Integer result = bankCardService.insertBankCard(bankcard);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
/**
* 修改银行卡时回显银行卡信息
*
* @param id
* @return
*/
@GetMapping("/user/getBankCardById/{id}")
@ResponseBody
public Msg getBankCardById(@PathVariable("id") Integer id) {
Bankcard bankcard = bankCardService.selectBankCardById(id);
return Msg.success().add("bankcard", bankcard);
}
/**
* 修改银行卡信息
*
* @param id
* @param bankcard
* @return
*/
@PutMapping("/user/updateBankCard/{update-id}")
@ResponseBody
public Msg updateBankCard(@PathVariable("update-id") Integer id, Bankcard bankcard) {
@PostMapping("/user/buyPayMoney")
@ResponseBody
public Msg buyPayMoney(@RequestParam("payMoneyId")Integer payMoneyId,
@RequestParam("userId") Integer userId ){
PayMoney pm = payMoneyService.selectPayMoneyById(payMoneyId);
UserPayMoney upm = new UserPayMoney();
upm.setUserid(userId);
upm.setPayid(payMoneyId);
upm.setStarttime(new Date());
upm.setAveryield(new BigDecimal("0.03123"));
upm.setProfit(new BigDecimal("0.03123").multiply(pm.getMonthmoney()));
upm.setStatus(1);
Integer result = userPayMoneyService.insertUserPayMoney(upm);
if (result==1){
FlowOfFunds fof = new FlowOfFunds();
fof.setUserid(userId);
fof.setFlowmoney(pm.getMonthmoney());
fof.setType(1);
fof.setSource("工资理财");
fof.setCreatetime(new Date());
if (pm.getType()==1){
fof.setFunddesc("国债");
}else if(pm.getType()==2){
fof.setFunddesc("期货");
}
flowOfFundsService.insertFlowOfFunds(fof);
return Msg.success();
}else {
return Msg.fail();
}
}
/**
* 跳转到工资理财管理界面(管理员)
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@GetMapping("/admin/finance/toPayMoney.html")
public String toPayMoneyInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<PayMoney> list = payMoneyService.selectAllPayMoney();
PageInfo<PayMoney> pageInfo = new PageInfo<PayMoney>(list, 5);
model.addAttribute("finacnePageInfo",pageInfo);
model.addAttribute("financeList",list);
model.addAttribute("activeUrl1", "financeActive");
model.addAttribute("activeUrl2", "paymoneyActive");
model.addAttribute("pageTopBarInfo", "工资理财管理界面");
return "/admin/finance/paymoney";
model.addAttribute("flowOfFundsPageInfo",pageInfo);
model.addAttribute("pageTopBarInfo", "资金记录界面");
model.addAttribute("activeUrl1", "toolsActive");
model.addAttribute("activeUrl2", "recordActive");
return "/user/tools/record";
}
}
/**
* 登陆拦截器:未登录用户不能访问系统界面
*/
public class LoginHandlerInterceptor implements HandlerInterceptor {
//目标方法执行之前
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Object user = request.getSession().getAttribute("loginUser");
Object admin = request.getSession().getAttribute("loginAdmin");
if(user == null&&admin==null){
//未登陆,返回登陆页面
request.setAttribute("msg","没有权限请先登陆");
System.out.println("LoginHandlerInterceptor.preHandle" + "----------------未登入------拦截请求--------------->");
response.sendRedirect("/");
return false;
}else{
//已登陆,放行请求
return true;
}
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}
if ("userLogout".equals(logout)){
User loginUser = (User) session.getAttribute("loginUser");
User user = userService.selectUserById(loginUser.getId());
user.setStatus(0);
userService.updateUser(user);
session.removeAttribute("loginUser");
System.out.println("logout==>"+user.getUsername()+"已退出系统");
return "login";
}
if ("adminLogout".equals(logout)){
Admin loginAdmin = (Admin) session.getAttribute("loginAdmin");
Admin admin =adminService.selectAdminById(loginAdmin.getId());
admin.setStatus(0);
adminService.updateAdmin(admin);
session.removeAttribute("loginAdmin");
System.out.println("logout==>"+admin.getUsername()+"已退出系统");
return "login";
}
return "login";
}
}
@Controller
public class PermissionsController {
@Autowired
UserPermissionsService userPermissionsService;
@Autowired
PermissionsService permissionsService;
@Autowired
AdminPermissionsService adminPermissionsService;
/**
* 跳转到用户权限管理界面(管理员)
* @param model
if (result==1){
// 删除用户时应先判断这个用户是否在线
User loginUser = (User) session.getAttribute("loginUser");
if (loginUser!=null){
if (id == (loginUser.getId())) {
session.removeAttribute("loginUser");
}
}
return Msg.success();
}
return Msg.fail();
}
/**
* 跳转到用户信誉管理界面(管理员)
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@GetMapping("/admin/userinfo/toReputation.html")
public String toUserReputation(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<User> list = userService.selectAllUser();
PageInfo<User> pageInfo = new PageInfo<User>(list, 5);
model.addAttribute("userPageInfo",pageInfo);
model.addAttribute("userList",list);
model.addAttribute("activeUrl1", "userInfoActive");
model.addAttribute("activeUrl2", "reputationActive");
model.addAttribute("pageTopBarInfo", "用户信誉界面");
return "/admin/userinfo/reputation";
}
}
FlowOfFundsService flowOfFundsService;
/**
* 跳转到工资理财界面
* @param model
* @return
*/
@RequestMapping("/user/finance/toPayMoney.html")
public String toPaymoney(Model model){
List<PayMoney> list = payMoneyService.selectAllPayMoney();
model.addAttribute("payMoneyList",list);
model.addAttribute("pageTopBarInfo","工资理财界面");
model.addAttribute("activeUrl1","financeActive");
model.addAttribute("activeUrl2","payMoneyActive");
return "/user/finance/paymoney";
}
/**
* 购买工资理财产品
* @param payMoneyId
* @param userId
* @return
*/
@PostMapping("/user/buyPayMoney")
@ResponseBody
public Msg buyPayMoney(@RequestParam("payMoneyId")Integer payMoneyId,
@RequestParam("userId") Integer userId ){
PayMoney pm = payMoneyService.selectPayMoneyById(payMoneyId);
UserPayMoney upm = new UserPayMoney();
upm.setUserid(userId);
upm.setPayid(payMoneyId);
upm.setStarttime(new Date());
upm.setAveryield(new BigDecimal("0.03123"));
upm.setProfit(new BigDecimal("0.03123").multiply(pm.getMonthmoney()));
upm.setStatus(1);
Integer result = userPayMoneyService.insertUserPayMoney(upm);
if (result==1){
FlowOfFunds fof = new FlowOfFunds();
fof.setUserid(userId);
fof.setFlowmoney(pm.getMonthmoney());
fof.setType(1);
fof.setSource("工资理财");
fof.setCreatetime(new Date());
if (pm.getType()==1){
fof.setFunddesc("国债");
}else if(pm.getType()==2){
fof.setFunddesc("期货");
}
flowOfFundsService.insertFlowOfFunds(fof);
return Msg.success();
}else {
return Msg.fail();
}
}
return Msg.fail();
}
/**
* 更新时回显信息
* @param id
* @return
*/
@GetMapping("/admin/getTermFinancialInfoById/{id}")
@ResponseBody
public Msg getTermFinancialInfoById(@PathVariable("id") Integer id){
TermFinancial termFinancial = termFinancialService.selectTermFinancialById(id);
return Msg.success().add("termFinancial",termFinancial);
}
/**
* 更新
* @param id
*
* @return
*/
@PutMapping("/admin/updateTermFinancial/{id}")
@ResponseBody
public Msg updateTermFinancial(@PathVariable("id") Integer id,TermFinancial termFinancial){
termFinancial.setId(id);
Integer result = termFinancialService.updateTermFinancial(termFinancial);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/admin/deleteTermFinancialById/{id}")
@ResponseBody
public Msg deleteTermFinancialById(@PathVariable("id") Integer id){
Integer result = termFinancialService.deleteTermFinancialById(id);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
}
loan.setApplystatus(1);
Integer result = loanService.updateLoan(loan);
if (result == 1) {
Info info = new Info();
info.setSendid(admin.getId());
info.setReceiveid(loan.getUser().getId());
info.setCreatetime(new Date());
info.setTitle("网贷审核未通过");
info.setInfodesc("用户" + loan.getUser().getUsername() + "的" + loan.getAmount() + "元网贷申请审核未通过!审核人为:" + admin.getUsername());
info.setStatus(0);
infoService.insertInfo(info);
return Msg.success();
}
return Msg.fail();
}
/**
* 跳转到网贷信息界面(管理员)
*
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@GetMapping("/admin/loan/toLoaninfo.html")
public String toLoaninfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
// 引入PageHelper插件,在查询之前调用startPage方法,传入页码以及每页大小
PageHelper.startPage(pageNum, pageSize);
List<Loan> list = loanService.selectAllExamedLoan();
// 使用PageInfo包装查询后的结果,并交给页面处理
// PageInfo封装了详细的分页信息,包括我们查询出来的数据,还可以传入连续显示的页数(5)
PageInfo<Loan> pageInfo = new PageInfo<Loan>(list, 5);
model.addAttribute("loanPageInfo", pageInfo);
model.addAttribute("loanList", list);
model.addAttribute("activeUrl1", "loanActive");
model.addAttribute("activeUrl2", "loaninfoActive");
model.addAttribute("pageTopBarInfo", "网贷信息界面");
return "admin/loan/loaninfo";
}
@PutMapping("/loan/remindPay/{id}")
@ResponseBody
public Msg remindPay(@PathVariable("id") Integer id, HttpSession session) {
Admin admin = (Admin) session.getAttribute("loginAdmin");
Loan loan = loanService.selectLoanById(id);
Info info = new Info();
info.setSendid(admin.getId());
info.setReceiveid(loan.getUser().getId());
for (String string : strings) {
AdminPermissions ap = new AdminPermissions();
ap.setAdminid(1);
ap.setPermissionid(permissionsService.selectPermissionsByPermission(string).get(0).getId());
adminPermissionsService.insertAdminPermissions(ap);
}
return Msg.success();
}
}
@Controller
public class BankCardController {
@Autowired
BankCardService bankCardService;
/**
* 跳转到银行卡管理界面(用户)
*
* @param model
* @param session
* @return
*/
@GetMapping("/user/personal/toBankCard.html")
public String toBankCard(Model model, HttpSession session) {
User loginUser = (User) session.getAttribute("loginUser");
List<Bankcard> list = bankCardService.selectBankCardByUserId(loginUser.getId());
model.addAttribute("bankCardList", list);
model.addAttribute("pageTopBarInfo", "银行卡管理界面");
model.addAttribute("activeUrl1", "personalActive");
model.addAttribute("activeUrl2", "bankCardActive");
return "/user/personal/bankcard";
}
/**
* 新增银行卡
*
* @param bankcard
@Controller
public class MainController {
@Autowired
UserService userService;
@Autowired
AdminService adminService;
@Autowired
NewsService newsService;
/**
* 404页面
*/
@GetMapping(value = "/error/404")
public String error_404() {
return "error/404";
}
/**
* 500页面
*/
@GetMapping(value = "/error/500")
public String error_500() {
return "error/500";
}
/**
* 错误界面返回
* @param session
* @return
*/
@GetMapping("/toindex.html")
public String toIndex(HttpSession session){
//TODO (用户和管理员同时登陆)
if (session.getAttribute("loginUser")!=null&&session.getAttribute("loginAdmin")!=null){
return "redirect:/index.html";
}
*
* @param id
* @return
*/
@DeleteMapping("/user/deleteBankCard/{id}")
@ResponseBody
public Msg deleteBankCard(@PathVariable("id") Integer id) {
Integer result = bankCardService.deleteBankCardById(id);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
/**
* 跳转到银行卡管理界面(管理员)
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@GetMapping("/admin/userinfo/toBankCard.html")
public String toBankCard1(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<Bankcard> list = bankCardService.selectAllBankCard();
PageInfo<Bankcard> pageInfo = new PageInfo<Bankcard>(list, 5);
model.addAttribute("bankcardPageInfo",pageInfo);
model.addAttribute("bankcardList",list);
model.addAttribute("pageTopBarInfo", "银行卡管理界面");
model.addAttribute("activeUrl1", "userInfoActive");
model.addAttribute("activeUrl2", "bankcardActive");
return "/admin/userinfo/bankcard";
}
}
/**
* 404页面
*/
@GetMapping(value = "/error/404")
public String error_404() {
return "error/404";
}
/**
* 500页面
*/
@GetMapping(value = "/error/500")
public String error_500() {
return "error/500";
}
/**
* 错误界面返回
* @param session
* @return
*/
@GetMapping("/toindex.html")
public String toIndex(HttpSession session){
//TODO (用户和管理员同时登陆)
if (session.getAttribute("loginUser")!=null&&session.getAttribute("loginAdmin")!=null){
return "redirect:/index.html";
}
if (session.getAttribute("loginUser")!=null){
return "redirect:/user/index.html";
}
if (session.getAttribute("loginAdmin")!=null){
return "redirect:/admin/index.html";
}
return "redirect:/index.html";
}
/**
* 管理员首页
@Controller
public class MainController {
@Autowired
UserService userService;
@Autowired
AdminService adminService;
@Autowired
NewsService newsService;
/**
* 404页面
*/
@GetMapping(value = "/error/404")
public String error_404() {
return "error/404";
}
/**
* 500页面
*/
@GetMapping(value = "/error/500")
public String error_500() {
return "error/500";
}
/**
* 错误界面返回
* @param session
* @return
*/
@GetMapping("/toindex.html")
public String toIndex(HttpSession session){
//TODO (用户和管理员同时登陆)
if (session.getAttribute("loginUser")!=null&&session.getAttribute("loginAdmin")!=null){