博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码
理财管理系统基于SpringBoot+Mybatis开发,功能完整,页面简洁,系统分为管理员和普通用户两种角色。
管理员功能如下:
普通用户功能如下:
BankCardController
package com.bjpowernode.finance.controller;
import com.bjpowernode.finance.common.Msg;
import com.bjpowernode.finance.entity.Bankcard;
import com.bjpowernode.finance.entity.User;
import com.bjpowernode.finance.service.BankCardService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.util.List;
@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
* @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);
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");
model.addAttribute("activeUrl2", "bankcardActive");
return "/admin/userinfo/bankcard";
}
}
PayMoneyController
package com.bjpowernode.finance.controller;
import com.bjpowernode.finance.common.Msg;
import com.bjpowernode.finance.entity.FlowOfFunds;
import com.bjpowernode.finance.entity.PayMoney;
import com.bjpowernode.finance.entity.UserPayMoney;
import com.bjpowernode.finance.service.FlowOfFundsService;
import com.bjpowernode.finance.service.PayMoneyService;
import com.bjpowernode.finance.service.UserPayMoneyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Controller
public class PayMoneyController {
@Autowired
PayMoneyService payMoneyService;
@Autowired
UserPayMoneyService userPayMoneyService;
@Autowired
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();
}
}
/**
* 跳转到工资理财管理界面(管理员)
* @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();
}
/**
* 更新时回显信息
* @param id
* @return
*/
@GetMapping("/admin/getPayMoneyInfoById/{id}")
@ResponseBody
public Msg getPayMoneyInfoById(@PathVariable("id") Integer id){
PayMoney payMoney = payMoneyService.selectPayMoneyById(id);
return Msg.success().add("payMoney",payMoney);
}
/**
* 更新
* @param id
* @param payMoney
* @return
*/
@PutMapping("/admin/updatePayMoney/{id}")
@ResponseBody
public Msg updatePayMoney(@PathVariable("id") Integer id,PayMoney payMoney){
payMoney.setId(id);
Integer result = payMoneyService.updatePayMoney(payMoney);
if (result==1){
return Msg.success();
}
return Msg.fail();
}
/**
* 删除
* @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();
}
}
大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 101