一、项目介绍
1.目的
2.意义
二、功能模块
1.使用的技术
2.项目结构
3.项目的功能模块
一级菜单
二级菜单
三、常见错误
四、总结与收获
移动大厅业务系统的设计目的是提供一个便捷、高效和个性化的移动服务平台,以满足用户在移动大厅办理业务的需求。该系统旨在简化用户在移动大厅的办理流程,提供办理业务、查询信息等功能,以提升用户体验和效率。通过该系统,用户可以通过移动设备随时随地办理各类业务,包括充值、缴费、办理手机号码业务、查询账单、办理套餐变更等。
随着信息时代的发展,电子支付已经成为常态,而常规的线下移动业务大厅费时费力,因此一个移动业务大厅系统是非常有意义的。
移动大厅业务系统的设计意义在于提升用户的移动服务体验,并提高运营商的效率和服务质量。通过该系统,用户可以通过移动设备随时随地办理各类业务,无需亲自前往实体大厅,从而节省时间和精力。系统的功能可以减少用户等待时间,提高办理效率。此外,系统还提供了查询信息、办理业务、缴费等功能,使用户可以方便地获取所需的移动服务。
同时,对于运营商来说,移动大厅业务系统可以减轻实体大厅的压力,降低人力成本,并提高业务处理的效率和准确性。系统可以自动化处理一部分常规业务,减少人工干预,从而减少出错的可能性。
lib文件夹:用于存放项目依赖的jar包
src文件夹用于存放项目的源文件
在src文件夹中又可以细分几个不同作用的文件
constant:常量层,用于存放项目中使用的各种常量,或者各个数字表示的具体含义。
dao:DAO层(数据访问层),封装对于实体类的数据库的访问,即增、删、改、查操作。
DAO层内部拥有关于各个表的方法接口,以及impl文件夹中相对应的实现类。
entity:实体层,里面存放实体类,而实体类通常用于存储和操作数据
service:业务逻辑层,主要负责实现具体的业务功能,例如:用户登录注册、使用嗖嗖等。
util:工具层,存放用于本项目的工具类,例如本次项目的数据库连接,修改时间。
test文件夹用于存放测试类的源文件
登录功能
public MoboleCard login(){
System.out.print("请输入手机号:");
String cardNo = input.next();
System.out.print("请输入密码:");
String password = input.next();
//调用到dao层类方法
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
MoboleCard moboleCard = moboleCardDao.queryByCardNo(cardNo);
if (moboleCard ==null){ //没有手机号
System.out.println("卡号或者密码错误!!!");
}else {//有手机号
if (!moboleCard.getPassword().equals(password)){
System.out.println("卡号或者密码错误!!!");
}else if (moboleCard.getStatus().longValue()== SystemConstant.MOBOLE_STATUS_FREEZE){ //冻结状态
System.out.println("该手机号已冻结,请联系工作人员!");
}else {
return moboleCard;
}
}
return null;
}
注册功能
public void register(){
System.out.println("*****可选择的卡号*****");
//显示可用的卡
CardDao cardDao = new CardDaoImpl();
List cards = cardDao.queryBysTatus(SystemConstant.CARD_STATUS_NORMAL);
for (int i = 0; i < cards.size(); i++) {
System.out.print((i+1)+"."+cards.get(i).getCardNumber()+"\t");
if ((i+1)%3 == 0){
System.out.println();
}
}
System.out.println();
//选择卡
System.out.print("请选择你的卡号:");
int cardIndex = input.nextInt();
Card card = cards.get(cardIndex-1);
//显示所有套餐
SerpackageTypeDao serpackageTypeDao = new SerpackageTypeDaoImpl();
List serpackageTypes = serpackageTypeDao.queryAll();
for (int i = 0; i < serpackageTypes.size(); i++) {
System.out.print((i+1)+"."+serpackageTypes.get(i).getName()+"\t");
}
//选择套餐
System.out.print("\n请选择套餐:");
int serpackageTypeIndex = input.nextInt();
SerpackageType serpackageType = serpackageTypes.get(serpackageTypeIndex-1);
//根据套餐类型查询套餐明细
SerpackageDao serpackageDao = new SerpackageDaoImpl();
Serpackage serpackage = serpackageDao.querByType(serpackageType.getId());
System.out.print("请输入姓名:");
String name = input.next();
System.out.print("请输入密码:");
String pwd = input.next();
double money = 0;
do {
System.out.print("请输入预存话费金额:");
money = input.nextDouble();
if (money < serpackage.getPrice()){
System.out.println("您预存的话费不足以支付本月套餐资费,请重新输入!");
}
}while (money < serpackage.getPrice());
//往用户卡添加一条记录
MoboleCard moboleCard = new MoboleCard();
moboleCard.setCardNumber(card.getCardNumber());
moboleCard.setPassword(pwd);
moboleCard.setUsername(name);
moboleCard.setSerPackage(serpackageType.getId());
moboleCard.setStatus(SystemConstant.MOBOLE_STATUS_NORMAL);
moboleCard.setMoney(money-serpackage.getPrice());
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
moboleCardDao.insert(moboleCard);
//修改卡的状态
card.setStatus(SystemConstant.CARD_STATUS_FREEZE);
cardDao.update(card);
//往充值记录表里面添加一条充值记录
RechargeRecord rechargeRecord = new RechargeRecord();
rechargeRecord.setAmount(money);
rechargeRecord.setRechargeDate(new Date());
rechargeRecord.setCardNumber(card.getCardNumber());
//往号码流量表里面添加记录
Flow flow = new Flow();
flow.setFlow(serpackage.getFlow());
flow.setCardNumber(card.getCardNumber());
FlowDao flowDao = new FlowDaoImpl();
flowDao.insert(flow);
RechargeRecordDao rechargeRecordDao = new RechargeRecordDaoImpl();
rechargeRecordDao.insert(rechargeRecord);
System.out.print("注册成功!");
System.out.println("卡号:"+moboleCard.getCardNumber()+",用户名:"+moboleCard.getUsername()+",当前余额:"+moboleCard.getMoney());
System.out.println(serpackageType.getName()+"通话时长:"+serpackage.getTime()+"分钟/月");
}
使用嗖嗖功能
public void useSoSo(){
System.out.print("请输入手机卡号:");
String cardNo = input.next();
//根据手机卡号查询用户卡信息
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
MoboleCard moboleCard = moboleCardDao.queryByCardNo(cardNo);
if (moboleCard == null){ //卡号存在
System.out.println("[错误提示:]卡号不存在!!!请重新输入");
}else if (moboleCard.getStatus().intValue()==SystemConstant.MOBOLE_STATUS_FREEZE){//冻结状态
System.out.println("[错误提示:]该卡已被冻结,请联系工作人员!!!");
}else {
//查询该卡的套餐
SerpackageDao serpackageDao = new SerpackageDaoImpl();
Serpackage serpackage = serpackageDao.queryById(moboleCard.getSerPackage());
//查询所有的场景
SceneDao sceneDao = new SceneDaoImpl();
List scenes = sceneDao.queryAll();
//随机一个场景
Random random = new Random();
int index = random.nextInt(scenes.size());
Scene scene = scenes.get(index);
//查询卡当月月消费情况, 根据换手机号与日期
MCRecordsDao mcRecordsDao = new MCRecordsDaoImpl();
Date firstDayDate = DateUtil.getFirstDayDate(new Date());
MCRecords mcRecords = mcRecordsDao.queryCurrentMonthRecprByCardNo(cardNo,firstDayDate);
if (mcRecords == null){ //没有消费记录
// 初始化当月消费记
mcRecords = new MCRecords();
mcRecords.setCardNumber(cardNo);
mcRecords.setConsumAmount(0.0);
mcRecords.setConsumeDate(firstDayDate);
mcRecords.setRealFlow(0);
mcRecords.setRealSMSCount(0);
mcRecords.setRealTalkTime(0);
//保存数据
mcRecordsDao.insert(mcRecords);
//查询一次,确保得到新添加的月消费记录有id
mcRecords = mcRecordsDao.queryCurrentMonthRecprByCardNo(cardNo,firstDayDate);
}
String type = ""; //场景类型
int free = 0; //余量
Flow flow = null;
FlowDao flowDao = new FlowDaoImpl();
flow = flowDao.queryByCardNo(cardNo);
if (scene.getType().equals("通话")){
type = "通话";
free = serpackage.getTime() -mcRecords.getRealTalkTime();
mcRecords.setRealTalkTime(mcRecords.getRealTalkTime()+scene.getData());
}else if (scene.getType().equals("短信")){
type = "短信";
free = serpackage.getCount()-mcRecords.getRealSMSCount();
mcRecords.setRealSMSCount(mcRecords.getRealSMSCount()+scene.getData());
}else if (scene.getType().equals("上网")){
type = "上网";
free = flow.getFlow()-mcRecords.getRealFlow();
mcRecords.setRealFlow(mcRecords.getRealFlow()+scene.getData());
}
//计算本次消费金额
Double cost = 0.0;
if (free <= 0){ //没有余量
cost = calcCost(type,scene.getData());
}else { //有余量
if (free - scene.getData() <0 ){
cost = calcCost(type,scene.getData()-free);
}
}
//修改月消费记录
mcRecords.setConsumAmount(mcRecords.getConsumAmount()+cost);
//保存到数据库
mcRecordsDao.update(mcRecords);
MCRecords mcRecords1 = mcRecordsDao.queryCurrentMonthRecprByCardNo(cardNo,firstDayDate);
//修改剩余流量
Flow flow1 = new Flow();
flow1.setFlow(flow.getFlow()-mcRecords1.getRealFlow());
flow1.setCardNumber(cardNo);
flowDao.update(flow1);
//修改用户卡余额
if (cost > 0){
moboleCard.setMoney(moboleCard.getMoney()-cost);
moboleCardDao.update(moboleCard);
}
//新添加一条消费记录
Consuminfo consuminfo = new Consuminfo();
consuminfo.setCardNumber(cardNo);
consuminfo.setType(type);
consuminfo.setConsumeDate(new Date());
consuminfo.setConsumData(scene.getData());
//保存到数据库
ConsuminfoDao consuminfoDao = new ConsuminfoDaoImpl();
consuminfoDao.insert(consuminfo);
//打印消费信息
System.out.println(scene.getDescription());
}
System.out.println();
}
//计算消费金额(用于使用嗖嗖)
private double calcCost(String type,int number){
double cost = 0.0;
if (type.equals("通话")){
cost = 0.2 * number;
}else if (type.equals("短信")){
cost = 0.1 * number;
}else if (type.equals("上网")){
cost = 0.1 * number;
}
return cost;
}
话费充值功能
public void recharge(){
System.out.println("********话费充值********");
System.out.print("请输入要充值的卡号:");
String cardNo = input.next();
System.out.print("请输入充值金额:");
Double money = input.nextDouble();
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
MoboleCard moboleCard = moboleCardDao.queryByCardNo(cardNo);
if (moboleCard == null){
System.out.println("[错误提示]:该卡号不存在!!!");
recharge();
}else if (moboleCard.getStatus().intValue() == 1){
System.out.println("[错误提示]:该手机已经被冻结,请联系工作人员!!!");
} else {
//充值记录
RechargeRecord rechargeRecord = new RechargeRecord();
rechargeRecord.setAmount(money);
rechargeRecord.setRechargeDate(new Date());
rechargeRecord.setCardNumber(cardNo);
RechargeRecordDao rechargeRecordDao = new RechargeRecordDaoImpl();
rechargeRecordDao.insert(rechargeRecord);
//修改金额
Double sumMoney = money+ moboleCard.getMoney();
moboleCard.setMoney(sumMoney);
moboleCard.setCardNumber(cardNo);
moboleCardDao.update(moboleCard);
System.out.print("[友情提示] : 充值成功,卡上余额:"+sumMoney+"元");
}
System.out.println();
}
资费说明功能
public void explain(){
System.out.println("********套餐说明********");
System.out.println("序号\t套餐名称\t通话时长(分/月)\t短信条数(条/月)\t上网流量(GB/月)");
SerpackageDao sd = new SerpackageDaoImpl();
SerpackageTypeDao std = new SerpackageTypeDaoImpl();
for (int i = 0; i
申请解冻功能
public void thaw(){
System.out.print("请输入您要解冻的号码:");
String cardNo = input.next();
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
MoboleCard moboleCard = moboleCardDao.queryByCardNo(cardNo);
if (moboleCard == null){
System.out.println("[错误提示]:您输入的号码不存在!!!");
thaw();
}else if (moboleCard.getStatus() == SystemConstant.MOBOLE_STATUS_NORMAL){
System.out.println("[友情提示]:该号码是正常状态,无需解冻!!!");
}else {
MoboleCard moboleCard1 = new MoboleCard();
moboleCard1.setStatus(SystemConstant.MOBOLE_STATUS_NORMAL);
moboleCard1.setCardNumber(cardNo);
moboleCardDao.updateStatusByCardNo(moboleCard1);
System.out.println("[友情提示]:"+cardNo+"成功解冻!");
}
}
本月账单查询功能
public void billInquiry(){
System.out.println("********本月账单查询********");
System.out.println("本月账单:");
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
//账户余额
Double money = moboleCardDao.queryByCardNo(SosoApp.loginCardNumber).getMoney();
Integer type = moboleCardDao.queryByCardNo(SosoApp.loginCardNumber).getSerPackage();
SerpackageDao serpackageDao = new SerpackageDaoImpl();
//拿到所属套餐的月资费
Double price = serpackageDao.querByType(type).getPrice();
MCRecordsDao mcRecordsDao = new MCRecordsDaoImpl();
MCRecords mcRecords = new MCRecords();
Date firstDayDate = DateUtil.getFirstDayDate(new Date());
mcRecords = mcRecordsDao.queryCurrentMonthRecprByCardNo(SosoApp.loginCardNumber,firstDayDate);
//获取当月消费金额
double consumAmount;
if (mcRecordsDao.queryByCardNo(SosoApp.loginCardNumber)==null){
consumAmount = 0.0;
}else {
consumAmount = mcRecords.getConsumAmount();
}
Double sumMoney = price+consumAmount;
System.out.println("套餐资费:"+price+"元");
System.out.println("合计:"+sumMoney+"元");
System.out.println("账户余额:"+money+"元");
System.out.println();
}
套餐余量查询功能
public void margin(){
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
MoboleCard moboleCard = moboleCardDao.queryByCardNo(SosoApp.loginCardNumber);
SerpackageDao serpackageDao = new SerpackageDaoImpl();
Serpackage serpackage = serpackageDao.queryById(moboleCard.getSerPackage());
MCRecordsDao mcRecordsDao = new MCRecordsDaoImpl();
MCRecords mcRecords = mcRecordsDao.queryCurrentMonthRecprByCardNo(SosoApp.loginCardNumber, new Date());
//计算余量
int talkTime = serpackage.getTime();
int smsCount = serpackage.getCount();
FlowDao flowDao = new FlowDaoImpl();
Flow flow = flowDao.queryByCardNo(SosoApp.loginCardNumber);
Integer flow1 = flow.getFlow();
if (mcRecords != null){
talkTime = talkTime - mcRecords.getRealTalkTime() >0? talkTime-mcRecords.getRealTalkTime():0;
smsCount = smsCount - mcRecords.getRealSMSCount() >0 ? smsCount-mcRecords.getRealSMSCount():0;
}
System.out.println("******套餐余量查询********");
System.out.println("您的卡号是"+SosoApp.loginCardNumber+"套餐内剩余:");
System.out.println("通话时长:"+talkTime+"分钟");
System.out.println("短信条数:"+smsCount+"条");
System.out.println("上网流量:"+(flow1/1024)+"GB");
System.out.println();
}
打印消费详单功能
public void consumerBill(){
System.out.println("********消费详情查询********");
System.out.print("请输入本年需要查询的月份(1-12):");
int month = input.nextInt();
int year = DateUtil.getYear(new Date());
ConsuminfoDao consuminfoDao = new ConsuminfoDaoImpl();
List consuminfos = consuminfoDao.queryBycardNo(SosoApp.loginCardNumber, year, month);
if (consuminfos.size() != 0){
System.out.println("序号\t类型\t数据\t日期");
for (int i = 0; i < consuminfos.size(); i++) {
System.out.println((i+1)+"\t\t"+consuminfos.get(i).getType()+"\t"
+consuminfos.get(i).getConsumData()+"\t\t"+consuminfos.get(i).getConsumeDate());
}
}else {
System.out.println("[友情提示]:对不起,不存在本卡"+month+"月消费记录");
}
System.out.println();
}
套餐变更功能
public void packageChanges(){
System.out.println("********套餐变更********");
//显示所有套餐
SerpackageTypeDao serpackageTypeDao = new SerpackageTypeDaoImpl();
List serpackageTypes = serpackageTypeDao.queryAll();
MCRecords mcRecords = null;
MCRecordsDao mcRecordsDao = new MCRecordsDaoImpl();
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
SerpackageDao serpackageDao = new SerpackageDaoImpl();
//当前号码所属套餐
Integer serPackage = moboleCardDao.queryByCardNo(SosoApp.loginCardNumber).getSerPackage();
System.out.println("您现在的套餐:"+serpackageTypeDao.queryById(serPackage).getName());
for (int i = 0; i < serpackageTypes.size(); i++) {
System.out.print((i+1)+"."+serpackageTypes.get(i).getName()+"\t");
}
System.out.print("\t请选择(序号):");
int type = input.nextInt();
//当前号码余额
Double money = moboleCardDao.queryByCardNo(SosoApp.loginCardNumber).getMoney();
if (serPackage == type ){
System.out.println("[友情提示]:您已经是该套餐的用户,无需更换!");
}else {
if (type == 1){ //1.话痨套餐
if (money >= serpackageDao.queryById(1).getPrice()){
Serpackage serpackage1 = serpackageDao.queryById(1);
System.out.println("[友情提示]:更换套餐成功!话痨套餐:通话时长: "+serpackage1.getTime()
+"分钟/月,短信条数:" +serpackage1.getCount()+"条/月,上网流量:"
+serpackage1.getFlow() +"GB/月,月租:"
+ serpackage1.getPrice()+"元/月");
//更改套餐类型
MoboleCard moboleCard = new MoboleCard();
moboleCard.setSerPackage(1);
moboleCard.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.updateByCardNo(moboleCard);
MoboleCard moboleCard1 = new MoboleCard();
moboleCard1.setMoney(money-serpackageDao.queryById(1).getPrice());
moboleCard1.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.update(moboleCard1);
mcRecordsDao.deleteByCardNo(SosoApp.loginCardNumber);
Date firstDayDate = DateUtil.getFirstDayDate(new Date());
mcRecords = new MCRecords();
mcRecords.setCardNumber(SosoApp.loginCardNumber);
mcRecords.setConsumAmount(0.0);
mcRecords.setConsumeDate(firstDayDate);
mcRecords.setRealFlow(0);
mcRecords.setRealSMSCount(0);
mcRecords.setRealTalkTime(0);
mcRecordsDao.insert(mcRecords);
}else {
System.out.println("[友情提示]:对不起您的余额不足以支付新套餐本月资费,请充值后办理变更套餐业务!");
}
}else if (type == 2){ //2.网虫套餐
if (money >= serpackageDao.queryById(2).getPrice()){
Serpackage serpackage2 = serpackageDao.queryById(2);
System.out.println("[友情提示]:更换套餐成功!网虫套餐:通话时长: "+serpackage2.getTime()
+"分钟/月,短信条数:" +serpackage2.getCount()+"条/月,上网流量:"
+serpackage2.getFlow()/1024 +"GB/月,月租:"
+serpackage2.getPrice()+"元/月");
MoboleCard moboleCard = new MoboleCard();
moboleCard.setSerPackage(2);
moboleCard.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.updateByCardNo(moboleCard);
MoboleCard moboleCard1 = new MoboleCard();
moboleCard1.setMoney(money-serpackageDao.queryById(2).getPrice());
moboleCard1.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.update(moboleCard1);
mcRecordsDao.deleteByCardNo(SosoApp.loginCardNumber);
Date firstDayDate = DateUtil.getFirstDayDate(new Date());
mcRecords = new MCRecords();
mcRecords.setCardNumber(SosoApp.loginCardNumber);
mcRecords.setConsumAmount(0.0);
mcRecords.setConsumeDate(firstDayDate);
mcRecords.setRealFlow(0);
mcRecords.setRealSMSCount(0);
mcRecords.setRealTalkTime(0);
mcRecordsDao.insert(mcRecords);
}else {
System.out.println("[友情提示]:对不起您的余额不足以支付新套餐本月资费,请充值后办理变更套餐业务!");
}
}else if (type == 3){ //超人套餐
if (money >= serpackageDao.queryById(3).getPrice()){
Serpackage serpackage3 = serpackageDao.queryById(3);
System.out.println("[友情提示]:更换套餐成功!超人套餐:通话时长: "+serpackage3.getTime()
+"分钟/月,短信条数:" +serpackage3.getCount()+"条/月,上网流量:"
+serpackage3.getFlow()/1024 +"GB/月,月租:"
+serpackage3.getPrice()+"元/月");
MoboleCard moboleCard = new MoboleCard();
moboleCard.setSerPackage(3);
moboleCard.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.updateByCardNo(moboleCard);
MoboleCard moboleCard1 = new MoboleCard();
moboleCard1.setMoney(money-serpackageDao.queryById(3).getPrice());
moboleCard1.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.update(moboleCard1);
mcRecordsDao.deleteByCardNo(SosoApp.loginCardNumber);
Date firstDayDate = DateUtil.getFirstDayDate(new Date());
mcRecords = new MCRecords();
mcRecords.setCardNumber(SosoApp.loginCardNumber);
mcRecords.setConsumAmount(0.0);
mcRecords.setConsumeDate(firstDayDate);
mcRecords.setRealFlow(0);
mcRecords.setRealSMSCount(0);
mcRecords.setRealTalkTime(0);
mcRecordsDao.insert(mcRecords);
}else {
System.out.println("[友情提示]:对不起您的余额不足以支付新套餐本月资费,请充值后办理变更套餐业务!");
}
}
}
System.out.println();
}
购买流量功能
//购买流量
public void buyFlow(){
FlowDao flowDao = new FlowDaoImpl();
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
Flow realFlow = flowDao.queryByCardNo(SosoApp.loginCardNumber);
System.out.println("您当前的流量为:"+(realFlow.getFlow()/1024)+"GB");
System.out.print("请输入你要购买的流量(GB):");
int flow = input.nextInt();
if (moboleCardDao.queryByCardNo(SosoApp.loginCardNumber).getMoney() < flow*100){
System.out.println("[错误提示]:您的余额不足,请充值!!!");
}else {
//修改流量
Flow flow1 = new Flow();
flow1.setFlow(realFlow.getFlow()+flow*1024);
flow1.setCardNumber(SosoApp.loginCardNumber);
flowDao.update(flow1);
//修改账户余额
MoboleCard moboleCard = null;
Double money = moboleCardDao.queryByCardNo(SosoApp.loginCardNumber).getMoney();
moboleCard = new MoboleCard();
moboleCard.setMoney(money-flow*50);
moboleCard.setCardNumber(SosoApp.loginCardNumber);
moboleCardDao.update(moboleCard);
System.out.println("购买成功!!!");
System.out.println("当前流量:"+flowDao.queryByCardNo(SosoApp.loginCardNumber).getFlow()/1024+"GB");
}
}
办理退网功能
public void logout(){
System.out.println("********办理退网*********");
int status = 0;
MoboleCardDao moboleCardDao = new MoboleCardDaoImpl();
ConsuminfoDao consuminfoDao = new ConsuminfoDaoImpl();
MCRecordsDao mcRecordsDao = new MCRecordsDaoImpl();
RechargeRecordDao rechargeRecordDao = new RechargeRecordDaoImpl();
FlowDao flowDao = new FlowDaoImpl();
moboleCardDao.deleteByCardNo(SosoApp.loginCardNumber);
consuminfoDao.deleteByCardNo(SosoApp.loginCardNumber);
mcRecordsDao.deleteByCardNo(SosoApp.loginCardNumber);
rechargeRecordDao.deleteByCardNo(SosoApp.loginCardNumber);
flowDao.deleteByCardNo(SosoApp.loginCardNumber);
Card card = new Card();
card.setStatus(status);
card.setCardNumber(SosoApp.loginCardNumber);
CardDao cardDao = new CardDaoImpl();
cardDao.update(card);
System.out.println("[友情提示:] 卡号"+SosoApp.loginCardNumber+"办理退网成功!");
System.out.println();
}
空指针异常
产生原因:
这一次项目,主要是关于数据库的连接,此前我对数据库的连接仅仅停留在之前的简单题目上,而这个项目让我对数据库连接有了更实操的认识。
项目中也运用到了前面关于面向对象的知识和思想。在老师的带领下,我们创建了entity(实体层)、DAO层(数据访问层)、util层(工具层)等,这体现了面向对象当中的封装思想,而DAO层中更是运用到了继承和多态,可以让我们的代码总量变少,让整体项目看起来更加的清晰明了。
通过这一次的项目,我掌握了数据库的连接方式,也学到了怎样去封装一个项目,在之前也学习了sql语言,但是在项目中用到的sql语句,与以往直接在Navicat运行不一样,项目中的sql语言更多的是建立在我要用这里sql语言去对数据库当中的表格做出增、删、改,因为是与用户进行的一个交互。
在项目中,我也发现我对以前的知识掌握的不太牢固,老师在项目过程中提出的一些问题我无法回答出来,也许知识点我会运用,但是无法说出它的底层原理,这是我意识的我的不足,也需要去改进。