银行用户管理系统
Posted 汤米先生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了银行用户管理系统相关的知识,希望对你有一定的参考价值。
文章目录
- 前言
- 一. 功能
- 二. 代码
- 银行卡数据
- 转账流水数据
- 用户数据
- BanksController
- UserController
- BanksDao
- RecordDao
- UserDao
- Banks
- Record
- User
- BanksService 接口
- UserService接口
- BanksServiceImpl
- UsersServiceImpl
- AppStar 测试类
- ConnectMsql (JDBC连接Mysql数据库)
- AddBanksMoneyView
- AddBanksView
- AddUsersMoneyView
- AddUserView
- MainView
- MoveMoneyView
- ShowBanksView
- ShowMoveMoney
- ShowUserView
- UpdatePwdView
- UserLoginView
- UsersView
前言
银行用户管理系统是由我的另一篇博客项目 Java实训项目——网银管理系统改编而来。 与之不同的是,这个小项目新增了 转账流水功能, 并且运用了 集合,JavaSpring,mysql数据库和JDBC。 虽然大同小异,但亦有可取之处。一. 功能
-
登陆
-
注册
-
首页
-
个人信息显示
-
修改密码
-
添加银行卡
-
银行卡查看
-
充值
-
提现
-
转账
-
用户管理
-
转账流水
把用户信息,银行卡信息和转账流水(包括充值,提现和转账)都存入数据库之中,在根据功能合理的使用这些数据。
详细的功能介绍在上一篇项目博客中已经介绍过了 ——网银管理系统。
二. 代码
银行卡数据
转账流水数据
用户数据
BanksController
package com.vector.controller;
import com.vector.entity.Banks;
import com.vector.service.BanksService;
import com.vector.service.impl.BanksServiceImpl;
import java.util.List;
public class BanksController {
private BanksServiceImpl service =new BanksServiceImpl();
public boolean addBanks(Banks banks){
return service.addBanks(banks);
}
public List<Banks> showBanksByTel(String tel){
return service.showBanksByTel(tel);
}
public boolean deleteMoney(String banksNum,double money){
return service.deleteMoney(banksNum,money);
}
public boolean addMoney(String banksNum,double money){
return service.addMoney(banksNum,money);
}
public boolean moveMoney(String banksNum1,String banksNum2,double money){
return service.moveMoney(banksNum1,banksNum2,money);
}
public boolean chickNUm( String num) {
return service.chickNUm(num);
}
}
UserController
package com.vector.controller;
import com.vector.entity.Banks;
import com.vector.entity.User;
import com.vector.service.UserService;
import com.vector.service.impl.UsersServiceImpl;
import java.sql.SQLException;
import java.util.List;
// 用户管理
public class UserController {
private UserService userService =new UsersServiceImpl();
public User userLog(String tel,String pwd) {
return userService.findUSerByTelAdnpwd(tel,pwd);
}
// 注册
//String name, String cardNum, String tel, String pwd, String email, double money, String relName
public boolean addUser(String name, String cardNum, String tel, String pwd, String email, String relName){
User u =new User(name,cardNum,tel,pwd,email,0,relName);
return userService.addUsers(u);
}
public boolean isExistTel(String tel) {
return userService.isExistTel(tel);
}
public boolean isExistEmail(String email){
return userService.isExistEmail(email);
}
public boolean updatePwd(String tel,String odlPwd,String pwd){
return userService.updatePwd(tel,pwd);
}
public boolean addMoney(String tel,double money){
return userService.addMoney(tel,money);
}
public boolean deleteMoney(String tel,double money){
return userService.deleteMoney(tel,money);
}
public List<User> showUserTel(String tel){
return userService.showUserTel(tel);
}
public List<User> showUser(){
return userService.showUser();
}
public boolean chickNUm(String num) {
return userService.chickNUm(num);}
}
BanksDao
package com.vector.dao;
import com.vector.entity.Banks;
import com.vector.entity.User;
import com.vector.units.ConnectMsql;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
public class BanksDao {
public boolean write(List<Banks> list){
try {
String delsql = "delete from banks where bankNum = ?";
String sql = "insert into banks(bankNum,money,bankName,tel) values(?,?,?,?)";
Connection connection = ConnectMsql.getConnectMsql();
PreparedStatement ad = connection.prepareStatement(sql);
PreparedStatement del = connection.prepareStatement(delsql);
int f=0;
for(Banks user:list) {
del.setString(1, user.getBankNumber());
del.executeUpdate();
ad.setString(1, user.getBankNumber());
ad.setDouble(2, user.getMoney());
ad.setString(3, user.getBankName());
ad.setString(4, user.getTel());
int i = ad.executeUpdate();
if(i<0) {
System.out.println("添加失败!");
f++;
return false;
}
}
if (f==0) {
System.out.println("添加成功");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
ConnectMsql.closeConnection();
}
return true;
}
public List<Banks> read(){
List<Banks> list=new ArrayList<>();
Connection connection = ConnectMsql.getConnectMsql();
Statement stmt;
try {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select * from banks");
while (rs.next()) {
Banks bank =new Banks(rs.getString("bankNum"), rs.getDouble("money"), rs.getString("bankName"), rs.getString("tel"));
list.add(bank);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
ConnectMsql.closeConnection();
}
return list;
}
}
RecordDao
package com.vector.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import com.vector.entity.Banks;
import com.vector.entity.Record;
import com.vector.units.ConnectMsql;
public class RecordDao {
public boolean write(List<Record> list) {
LocalDateTime dateTime = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String dataString=new String(dateTime.format(formatter));
try {
String delsql = "delete from movemoney where id = ?";
String sql = "insert into movemoney(outuser,inuser,money,date,id) values(?,?,?,?,?)";
Connection connection = ConnectMsql.getConnectMsql();
PreparedStatement ad = connection.prepareStatement(sql);
PreparedStatement del = connection.prepareStatement(delsql);
int f=0,k=1;
for(Record record:list) {
del.setInt(1, record.getId());
del.executeUpdate();
ad.setString(1, record.getOutuser());
ad.setString(2, record.getInuser());
ad.setDouble(3, record.getMoney());
ad.setString(4,dataString);
ad.setInt(5,k);
int i = ad.executeUpdate();
k++;
if(i<0) {
System.out.println("添加失败!");
f++;
return false;
}
}
if (f==0) {
System.out.println("添加成功");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
ConnectMsql.closeConnection();
}
return true;
}
public List<Record> read(){
List<Record> list=new ArrayList<>();
Connection connection = ConnectMsql.getConnectMsql();
Statement stmt;
try {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select * from movemoney");
while (rs.next()) {
Record record =new Record(rs.getString("outuser"), rs.getString("inuser"),rs.getDouble("money"), rs.getString("date"),rs.getInt("id"));
list.add(record);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
ConnectMsql.closeConnection();
}
return list;
}
}
UserDao
package com.vector.dao;
import java.util.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.sound.midi.Soundbank;
import com.vector.entity.User;
import com.vector.units.ConnectMsql;
public class UserDao {
public boolean write(List<User> list) {
try {
String delsql = "delete from user where tel = ?";
String sql = "insert into user(name,cardNum,tel,pwd,email,money,relName) values(?,?,?,?,?,?,?)";
Connection connection = ConnectMsql.getConnectMsql();
PreparedStatement ad = connection.prepareStatement(sql);
PreparedStatement del = connection.prepareStatement(delsql);
int f=0;
for(User user:list) {
del.setString(1, user.getTel());
del.executeUpdate();
//System.out.println("这是密码"+user.getPwd());
ad.setString(1, user.getName());
ad.setString(2, user.getCardNum());
ad.setString(3, user.getTel());
ad.setString(4, user.getPwd());
ad.setString(5, user.getEmail());
ad.setDouble(6, user.getMoney());
ad.setString(7, user.getRelName());
int i = ad.executeUpdate();
if(i<0) {
System.out.println("添加失败!");
f++;
return false;
}
}
if (f==0) {
System.out.println("添加成功");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
ConnectMsql.closeConnection();
}
return true;
}
public List<User> read() {
List<User> list=new ArrayList<>();
Connection connection = ConnectMsql.getConnectMsql();
Statement stmt;
try {
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select * from user");
while (rs.next()Android 逆向Linux 文件权限 ( Linux 权限简介 | 系统权限 | 用户权限 | 匿名用户权限 | 读 | 写 | 执行 | 更改组 | 更改用户 | 粘滞 )(代码片段