基于javaweb+mysql的springboot理财管理系统设计和实现(java+springboot+ssm+thymeleaf+html)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot理财管理系统设计和实现(java+springboot+ssm+thymeleaf+html)
spring boot,spring,spring mvc,mybatis,shiro框架分页处理使用了pagehelper进行操作,前台使用了模板语言thymeleaf,界面较为炫酷,适合年轻朋友。开发工具采用的是IDEA。该系统主要解决了理财中的一些问题,包含功能:权限管理,用户信息管理,理财产品管理等内容。
主要分为管理员和普通用户两种用户;
1.管理员模块主要包括:
用户信息管理:用户信息、银行卡、个人征信;
理财产品管理:零钱理财、工资理财、期限理财、基金理财、精选银行;
权限管理:用户权限、管理员权限
网贷管理:网贷审核、网贷信息;
2.普通用户模块主要包括
个人理财:零钱理财、工资理财、期限理财、基金理财、银行推荐;
金融工具:资金记录、安全网贷;
个人中心:我的理财、我的借贷、银行卡管理、账户安全;
@ResponseBody
public Msg updateBankCard(@PathVariable("update-id") Integer id, Bankcard bankcard) {
bankcard.setId(id);
Integer result = bankCardService.updateBankCard(bankcard);
if (result == 1) {
return Msg.success();
}
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");
* @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());
info.setTitle("还款通知");
info.setInfodesc("用户" + loan.getUser().getUsername() + "申请的" + loan.getAmount() + "元网贷该还款了!该提醒发送人为:" + admin.getUsername());
info.setStatus(0);
Integer result = infoService.insertInfo(info);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
}
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";
}
*/
@PutMapping("/user/updateInfo/{infoId}")
@ResponseBody
public Msg updateInfo(@PathVariable("infoId") Integer id) {
Info info = infoService.selectInfoById(id);
info.setStatus(1);
Integer result = infoService.updateInfo(info);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
/**
* 删除消息
* @param id
* @return
*/
@DeleteMapping("/user/deleteInfo/{infoId}")
@ResponseBody
public Msg deleteInfo(@PathVariable("infoId") Integer id) {
Integer result = infoService.deleteInfobyId(id);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
}
@Controller
}
/**
* 修改银行卡时回显银行卡信息
*
* @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);
if (result == 1) {
return Msg.success();
}
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
Info info = infoService.selectInfoById(id);
info.setStatus(1);
Integer result = infoService.updateInfo(info);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
/**
* 删除消息
* @param id
* @return
*/
@DeleteMapping("/user/deleteInfo/{infoId}")
@ResponseBody
public Msg deleteInfo(@PathVariable("infoId") Integer id) {
Integer result = infoService.deleteInfobyId(id);
if (result == 1) {
return Msg.success();
}
return Msg.fail();
}
}
@Controller
public class RecoderController {
public String toAdminIndex(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model){
// 引入PageHelper插件,在查询之前调用startPage方法,传入页码以及每页大小
PageHelper.startPage(pageNum, pageSize);
List<User> list = userService.selectUserByStatusDesc();
// 使用PageInfo包装查询后的结果,并交给页面处理
// PageInfo封装了详细的分页信息,包括我们查询出来的数据,还可以传入连续显示的页数(5)
PageInfo<User> pageInfo = new PageInfo<User>(list, 5);
model.addAttribute("userPageInfo",pageInfo);
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());
return "/admin/userinfo/userinfo";
}
/**
* 添加用户(管理员)
* @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){
// 删除用户时应先判断这个用户是否在线
UserChangeMoney ucm = new UserChangeMoney();
ucm.setUserid(userId);
ucm.setChangeid(changeMoneyId);
ucm.setStarttime(new Date());
ucm.setAveryield(cm.getAnnualincome());
ucm.setProfit(cm.getAnnualincome().multiply(cm.getInvesmoney()));
ucm.setStatus(1);
Integer result = userChangeMoneyService.insertUserChangeMoney(ucm);
if (result==1){
FlowOfFunds fof = new FlowOfFunds();
fof.setUserid(userId);
fof.setFlowmoney(cm.getInvesmoney());
fof.setType(1);
fof.setSource(cm.getName());
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/toChangeMoney.html")
public String toUserInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<ChangeMoney> list = changeMoneyService.selectAllChangeMoney();
PageInfo<ChangeMoney> pageInfo = new PageInfo<ChangeMoney>(list, 5);
model.addAttribute("finacnePageInfo",pageInfo);
model.addAttribute("financeList",list);
}
}
@Controller
public class ChangeMoneyController {
@Autowired
ChangeMoneyService changeMoneyService;
@Autowired
UserChangeMoneyService userChangeMoneyService;
@Autowired
FlowOfFundsService flowOfFundsService;
/**
* 跳转到零钱理财界面(用户)
* @param model
* @return
*/
@RequestMapping("/user/finance/toChangeMoney.html")
public String toChangemoney(Model model){
List<ChangeMoney> list = changeMoneyService.selectAllChangeMoney();
model.addAttribute("changeMoneyList",list);
model.addAttribute("pageTopBarInfo","零钱理财界面");
@Controller
@RequestMapping("/login")
public class LoginController {
@Autowired
UserService userService;
@Autowired
AdminService adminService;
//public static final Map<String, HttpSession> USR_SESSION = new HashMap<>();
public static String last_login = "";
@GetMapping("/loginVerifyUsername/{username}")
@ResponseBody
public Msg loginVerifyUsername(@PathVariable("username") String username) {
User user = userService.selectUserByTerms(username, null);
if (user != null) {
return Msg.success();
}
Admin admin = adminService.selectAdminByTerms(username, null);
if (admin != null) {
return Msg.success();
}
return Msg.fail();
}
@GetMapping("/verifyLogin")
@ResponseBody
public Msg verifyLogin(@RequestParam("username") String username, @RequestParam("password") String password,
HttpSession session) {
User loginUser = userService.selectUserByTerms(username, password);
if (loginUser != null) {
//获取当前用户
Subject subject = SecurityUtils.getSubject();
//封装用户登录数据
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
try {
subject.login(token);
return Msg.success().add("url", "/user/index.html");
} catch (UnknownAccountException | IncorrectCredentialsException e) {
return Msg.fail();
}
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/admin/deleteFundProductById/{id}")
@ResponseBody
public Msg deleteFundProductById(@PathVariable("id") Integer id){
Integer result = fundProductService.deleteFundProductById(id);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
}
@Controller
public class ChangeMoneyController {
@Autowired
ChangeMoneyService changeMoneyService;
@Autowired
UserChangeMoneyService userChangeMoneyService;
@Autowired
FlowOfFundsService flowOfFundsService;
/**
* 跳转到零钱理财界面(用户)
/**
* 添加用户(管理员)
* @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);
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);
@Controller
@RequestMapping("/login")
public class LoginController {
@Autowired
UserService userService;
@Autowired
AdminService adminService;
//public static final Map<String, HttpSession> USR_SESSION = new HashMap<>();
public static String last_login = "";
@GetMapping("/loginVerifyUsername/{username}")
@ResponseBody
public Msg loginVerifyUsername(@PathVariable("username") String username) {
User user = userService.selectUserByTerms(username, null);
if (user != null) {
return Msg.success();
}
Admin admin = adminService.selectAdminByTerms(username, null);
if (admin != null) {
return Msg.success();
}
return Msg.fail();
}
@GetMapping("/verifyLogin")
@ResponseBody
public Msg verifyLogin(@RequestParam("username") String username, @RequestParam("password") String password,
HttpSession session) {
User loginUser = userService.selectUserByTerms(username, password);
if (loginUser != null) {
//获取当前用户
Subject subject = SecurityUtils.getSubject();
//封装用户登录数据
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
try {
subject.login(token);
return Msg.success().add("url", "/user/index.html");
} catch (UnknownAccountException | IncorrectCredentialsException e) {
return Msg.fail();
Integer result = userChangeMoneyService.insertUserChangeMoney(ucm);
if (result==1){
FlowOfFunds fof = new FlowOfFunds();
fof.setUserid(userId);
fof.setFlowmoney(cm.getInvesmoney());
fof.setType(1);
fof.setSource(cm.getName());
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/toChangeMoney.html")
public String toUserInfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
PageHelper.startPage(pageNum, pageSize);
List<ChangeMoney> list = changeMoneyService.selectAllChangeMoney();
PageInfo<ChangeMoney> pageInfo = new PageInfo<ChangeMoney>(list, 5);
model.addAttribute("finacnePageInfo",pageInfo);
model.addAttribute("financeList",list);
model.addAttribute("activeUrl1", "financeActive");
model.addAttribute("activeUrl2", "changemoneyActive");
model.addAttribute("pageTopBarInfo", "零钱理财管理界面");
return "/admin/finance/changemoney";
}
/**
* 新增零钱理财产品
* @param changeMoney
* @return
*/
@PostMapping("/admin/addChangeMoney")
@ResponseBody
public Msg addChangeMoney(ChangeMoney changeMoney){
Integer result = changeMoneyService.insertChangeMoney(changeMoney);
if (result==1){
* @return
*/
@PostMapping("/admin/addBank")
@ResponseBody
public Msg addBank(Bank bank){
Integer result = bankService.insertBank(bank);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
/**
* 更新时回显信息
* @param id
* @return
*/
@GetMapping("/admin/getBankInfoById/{id}")
@ResponseBody
public Msg getBankInfoById(@PathVariable("id") Integer id){
Bank bank = bankService.selectBankById(id);
return Msg.success().add("bank",bank);
}
/**
* 更新
* @param id
*
* @return
*/
@PutMapping("/admin/updateBank/{id}")
@ResponseBody
public Msg updateBank(@PathVariable("id") Integer id,Bank bank){
bank.setId(id);
Integer result = bankService.updateBank(bank);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/admin/deleteBankById/{id}")
@ResponseBody
public Msg deleteBankById(@PathVariable("id") Integer id){
Integer result = bankService.deleteBankById(id);
if (result==1){
return Msg.success();
/**
* 更新用户信息(用户更改自己信息)
*
* @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