基于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等等
* 删除
* @param id
* @return
*/
@DeleteMapping("/admin/deletePayMoneyById/{id}")
@ResponseBody
public Msg deletePayMoneyById(@PathVariable("id") Integer id){
Integer result = payMoneyService.deletePayMoneyById(id);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
}
@Controller
public class MyFinanceController {
@Autowired
UserChangeMoneyService userChangeMoneyService;
@Autowired
UserPayMoneyService userPayMoneyService;
@Autowired
UserFundProductService userFundProductService;
@Autowired
UserTermFinancialService userTermFinancialService;
@GetMapping("/user/personal/toMyFinance.html")
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";
}
/**
* 新增工资理财产品
* @param payMoney
* @return
*/
@PostMapping("/admin/addPayMoney")
@ResponseBody
public Msg addPayMoney(PayMoney payMoney){
Integer result = payMoneyService.insertPayMoney(payMoney);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
/**
public String toUserIndex(Model model){
List<News> list = newsService.selectAllNews();
model.addAttribute("newsList",list);
model.addAttribute("pageTopBarInfo","系统首页");
model.addAttribute("activeUrl","indexActive");
return "user/main";
}
/**
* 注销(只有正常退出的用户可以注销)
* @param session
* @return
*/
@GetMapping("/logout")
public String logout(@RequestParam("logout")String logout, HttpSession session) {
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";
}
}
model.addAttribute("userList",list);
model.addAttribute("pageTopBarInfo","系统首页");
model.addAttribute("activeUrl","indexActive");
return "admin/main";
}
/**
* 用户首页
* @param model
* @return
*/
@GetMapping("/user/index.html")
public String toUserIndex(Model model){
List<News> list = newsService.selectAllNews();
model.addAttribute("newsList",list);
model.addAttribute("pageTopBarInfo","系统首页");
model.addAttribute("activeUrl","indexActive");
return "user/main";
}
/**
* 注销(只有正常退出的用户可以注销)
* @param session
* @return
*/
@GetMapping("/logout")
public String logout(@RequestParam("logout")String logout, HttpSession session) {
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";
}
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";
}
}
@Controller
public class BankController {
@Autowired
BankService bankService;
/**
* 跳转用户银行推荐界面
* @param model
* @return
*/
@RequestMapping("/user/finance/toBank.html")
public String toBank(Model model){
List<Bank> list = bankService.selectAllBank();
model.addAttribute("bankList",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) {
bankcard.setId(id);
Integer result = bankCardService.updateBankCard(bankcard);
ufp.setStatus(1);
Integer result = userFundProductService.insertUserFundProduct(ufp);
if (result==1){
FlowOfFunds fof = new FlowOfFunds();
fof.setUserid(userId);
fof.setFlowmoney(fp.getLeastmoney());
fof.setType(1);
fof.setSource(fp.getFunddesc());
fof.setCreatetime(new Date());
fof.setFunddesc("无");
flowOfFundsService.insertFlowOfFunds(fof);
return Msg.success();
}else {
return Msg.fail();
}
}
/**
* 跳转到基金理财管理界面(管理员)
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@GetMapping("/admin/finance/toFundProduct.html")
public String toFundProduct(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<FundProduct> list = fundProductService.selectAllFundProduct();
PageInfo<FundProduct> pageInfo = new PageInfo<FundProduct>(list, 5);
model.addAttribute("finacnePageInfo",pageInfo);
model.addAttribute("financeList",list);
model.addAttribute("activeUrl1", "financeActive");
model.addAttribute("activeUrl2", "fundproductActive");
model.addAttribute("pageTopBarInfo", "基金理财管理界面");
return "/admin/finance/fundproduct";
}
/**
@PutMapping("/loan/notPassApplyStatus/{id}")
@ResponseBody
public Msg notPassApplyStatus(@PathVariable("id") Integer id, HttpSession session) {
Admin admin = (Admin) session.getAttribute("loginAdmin");
Loan loan = loanService.selectLoanById(id);
loan.setExamineid(admin.getId());
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");
public Msg updateAdminPermissions(@RequestParam("adminPermissions")String adminPermissions){
String[] strings = adminPermissions.split(";");
//System.out.println(strings.length+":"+ Arrays.toString(strings));
adminPermissionsService.deleteAllAdminPermissionsByAdminId(1);
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")
return Msg.success();
}
return Msg.fail();
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/admin/deleteChangeMoneyById/{id}")
@ResponseBody
public Msg deleteChangeMoneyById(@PathVariable("id") Integer id){
Integer result = changeMoneyService.deleteChangeMoneyById(id);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
}
@Controller
public class PayMoneyController {
@Autowired
return Msg.success().add("url", "/");
}
}
/**
* 对所有乱码进行拦截及纠正,包括get提交方式,解决get提交方式乱码,方式是重写了request的getParameter方法,
* 让其在返回值的时候检查提交方式,如果为“get”就进行解码。 使用过滤器的@WebFilter注解进行配置和值的初始化
*/
@WebFilter(filterName = "encodingFilter", urlPatterns = "/*", initParams = {
@WebInitParam(name = "code", value = "utf-8") })
public class EncodingFilter implements Filter {
private String code = null;
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
// 设置码表
request.setCharacterEncoding(code);
response.setCharacterEncoding(code);
response.setContentType("text/html;charset=" + code);
// 将现在的reuqest对象换成我自己的request对象
MyHttpServletRequest myRequest = new MyHttpServletRequest((HttpServletRequest) request);
//System.out.println("Filter");
// 跳转到请求的资源,并传入自己定义的myRequest对象
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());
info.setCreatetime(new Date());
*/
@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";
}
}
@Controller
public class BankController {
@Autowired
BankService bankService;
/**
* 跳转用户银行推荐界面
* @param model
* @return
*/
@RequestMapping("/user/finance/toBank.html")
public String toBank(Model model){
List<Bank> list = bankService.selectAllBank();
model.addAttribute("bankList",list);
model.addAttribute("pageTopBarInfo","银行推荐界面");
model.addAttribute("activeUrl1","financeActive");
model.addAttribute("activeUrl2","bankActive");
return "user/finance/bank";
}
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";
}
/**
* 新增工资理财产品
* @param payMoney
* @return
*/
@PostMapping("/admin/addPayMoney")
@ResponseBody
public Msg addPayMoney(PayMoney payMoney){
Integer result = payMoneyService.insertPayMoney(payMoney);
if (result==1){
return Msg.success();
String[] strings = adminPermissions.split(";");
//System.out.println(strings.length+":"+ Arrays.toString(strings));
adminPermissionsService.deleteAllAdminPermissionsByAdminId(1);
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");
* @param id
* @return
*/
@DeleteMapping("/admin/deleteChangeMoneyById/{id}")
@ResponseBody
public Msg deleteChangeMoneyById(@PathVariable("id") Integer id){
Integer result = changeMoneyService.deleteChangeMoneyById(id);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
}
@Controller
public class PayMoneyController {
@Autowired
PayMoneyService payMoneyService;
@Autowired
UserPayMoneyService userPayMoneyService;
@Autowired
FlowOfFundsService flowOfFundsService;
/**
* 跳转到工资理财界面
* @param model
* @return
* @param user
* @return
*/
@PostMapping("/user/addUser")
@ResponseBody
public Msg addUser(User user){
user.setStatus(0);
user.setReputation("良好");
Integer result = userService.insertUser(user);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
/**
* 更新用户信息时回显用户信息(管理员)
* @param id
* @return
*/
@GetMapping("/user/getUserById/{id}")
@ResponseBody
public Msg getUserInfoById(@PathVariable("id")Integer id){
User user = userService.selectUserById(id);
return Msg.success().add("user",user);
}
/**
* 删除用户(管理员)
* @param id
* @param session
* @return
*/
@DeleteMapping("/user/deleteUserById/{id}")
@ResponseBody
public Msg deleteUserById(@PathVariable("id")Integer id,HttpSession session){
Integer result = userService.deleteUserById(id);
if (result==1){
// 删除用户时应先判断这个用户是否在线
User loginUser = (User) session.getAttribute("loginUser");
if (loginUser!=null){
if (id == (loginUser.getId())) {
session.removeAttribute("loginUser");
}
}