課程
/后端開發(fā)
/Java
/JDBC之 “ 對岸的女孩看過來”
想要View層完整的可執(zhí)行代碼
2016-04-14
源自:JDBC之 “ 對岸的女孩看過來” 3-1
正在回答
你把新建的xml名字改成不是原來的那個,然后再MainActivity里面的R.layout.__也改成那個你定的名字就OK了像<a>,<span>這類都是非塊級元素,必要的時候要用display:block;屬性來轉(zhuǎn)成塊級元素,
感覺最上面的那個模塊化的代碼可讀性最強(qiáng),一目了然。牛逼
package?com.View; import?java.text.ParseException; import?java.text.SimpleDateFormat; import?java.util.ArrayList; import?java.util.Date; import?java.util.HashMap; import?java.util.List; import?java.util.Map; import?java.util.Scanner; import?com.Action.StudentAction; import?com.Entity.Student; public?class?View?{ private?static?final?String?CONTEXT="歡迎進(jìn)入學(xué)生管理系統(tǒng):\n"+ "功能列表如下:\n"+ "[MAIN/M]:主菜單\n"+ "[QUERY/Q]:查詢?nèi)繉W(xué)生信息\n"+ "[GET/G]:查看某位學(xué)生的詳細(xì)信息\n"+ "[ADD/A]:添加學(xué)生信息\n"+ "[UPDATE/U:]更新學(xué)生信息\n"+ "[DELETE/D]:刪除學(xué)生信息\n"+ "[FQUERY/F:]查詢學(xué)生信息(根據(jù)姓名、手機(jī)號...查詢)\n"+ "[EXIT/E]:退出學(xué)生管理系統(tǒng)。\n"+ "[BREAK/B]:結(jié)束當(dāng)前操作,返回主菜單。"; private?static?final?String?ACTION_MAIN?=?"MAIN"; private?static?final?String?ACTION_QUERY?=?"QUERY"; private?static?final?String?ACTION_GET?=?"GET"; private?static?final?String?ACTION_ADD?=?"ADD"; private?static?final?String?ACTION_UPDATE?=?"UPDATE"; private?static?final?String?ACTION_DELETE?=?"DELETE"; private?static?final?String?ACTION_FQUERY?=?"FQUERY"; private?static?final?String?ACTION_EXIT?=?"EXIT"; private?static?final?String?ACTION_BREAK?=?"BREAK"; private?static?Student?stu1; public?static?void?main(String[]?args)?{ System.out.println(CONTEXT); Scanner?input?=?new?Scanner(System.in); Student?stu?=?new?Student(); String?status?=?null;//狀態(tài) String?name?=?null; String?value?=?null; Integer?step?=?1; while?(input.hasNext())?{ String?in?=?input.next(); if?(ACTION_EXIT.equals(in.toUpperCase()) ||?ACTION_EXIT.substring(0,?1).equals(in.toUpperCase()))?{ System.out.println("退出學(xué)生管理系統(tǒng)。"); break; }else?if(ACTION_MAIN.equals(in.toUpperCase()) ||?ACTION_MAIN.substring(0,?1).equals(in.toUpperCase())){ System.out.println(CONTEXT); continue; } else?if(ACTION_BREAK.equals(in.toUpperCase()) ||?ACTION_BREAK.substring(0,?1).equals(in.toUpperCase())){ status?=?null; System.out.println("退出當(dāng)前功能。"); continue; } else?if(ACTION_DELETE.equals(in.toUpperCase()) ||?ACTION_DELETE.substring(0,?1).equals(in.toUpperCase()) ||?ACTION_DELETE.equals(status)){ //根據(jù)id刪除學(xué)生信息 System.out.println("請輸入要刪除的學(xué)生編號:"); in?=?input.next(); StudentAction.Delete(Integer.parseInt(in)); System.out.println("學(xué)生信息刪除成功!"); }else?if(ACTION_FQUERY.equals(in.toUpperCase()) ||?ACTION_FQUERY.substring(0,?1).equals(in.toUpperCase()) ||?ACTION_FQUERY.equals(status)){ //根據(jù)特定條件查詢學(xué)生信息 System.out.println("請選擇要查詢的字段:\n[name]姓名\n[mobile]手機(jī)號"); name?=?input.next(); if("name".equals(name)){ System.out.println("請輸入要查詢的姓名:"); value?=?input.next(); }else?if("mobile".equals(name)){ System.out.println("請輸入要查詢的手機(jī)號:"); value?=?input.next(); } List<Map<String,Object>>?params?=?new?ArrayList<Map<String,Object>>(); Map<String,Object>?map?=?new?HashMap<String,Object>(); map.put("name",?name); map.put("rela",?"="); map.put("value",?"'"+value+"'"); params.add(map); List<Student>?stulist1?=?StudentAction.FuzzyQuery(params); for?(Student?student?:?stulist1)?{ System.out.println(student.toString()); } if(stulist1.size()==0){ System.out.println("未查詢到相應(yīng)學(xué)生信息!"); } continue; }else?if(ACTION_GET.equals(in.toUpperCase()) ||?ACTION_GET.substring(0,?1).equals(in.toUpperCase()) ||?ACTION_GET.equals(status)){? //根據(jù)id查詢學(xué)生詳細(xì)信息 System.out.println("請輸入學(xué)生編號:"); in?=?input.next(); stu.setId(Integer.parseInt(in)); stu1?=?StudentAction.QueryById(stu.getId()); System.out.println(stu1.toString()); continue; }else?if?(ACTION_UPDATE.equals(in.toUpperCase()) ||?ACTION_UPDATE.substring(0,?1).equals(in.toUpperCase()) ||?ACTION_UPDATE.equals(status))?{ //更新學(xué)生信息 /* ?*?stu1?=?StudentAction.QueryById(stu.getId()); ?*?if("null".equals(in)){ stu.setName(stu1.getName()); }else{ stu.setName(in); } ?*?根據(jù)輸入的id查詢學(xué)生信息,當(dāng)輸入的值為null時,將該學(xué)生原信息賦值。 ?*?達(dá)到輸入null,不更新字段的效果。 ?*/ status?=?ACTION_UPDATE; if(1==step){ System.out.println("請輸入要更新的學(xué)生編號:"); System.out.println("編號:"); }else?if(2==step){ stu.setId(Integer.parseInt(in)); stu1?=?StudentAction.QueryById(stu.getId()); System.out.println("當(dāng)前id:"+stu.getId()+"-"+stu1.toString()); System.out.println("姓名(如果不更新該字段,則輸入null):"); }else?if(3==step){ if("null".equals(in)){ stu.setName(stu1.getName()); }else{ stu.setName(in); } System.out.println("性別:"); }else?if(4==step){ if("null".equals(in)){ stu.setSex(stu1.getSex()); }else{ stu.setSex(Integer.parseInt(in)); } System.out.println("年齡:"); }else?if(5==step){ if("null".equals(in)){ stu.setAge(stu1.getAge()); }else{ stu.setAge(Integer.parseInt(in)); } System.out.println("出生日期"); }else?if(6==step){ SimpleDateFormat?sdf?=?new?SimpleDateFormat("yyyy-MM-dd"); Date?birthday?=?null; try?{ if("null".equals(in)){ stu.setBirthday(stu1.getBirthday()); }else{ birthday?=?sdf.parse(in); stu.setBirthday(birthday); } System.out.println("手機(jī)號:"); }?catch?(ParseException?e)?{ e.printStackTrace(); System.out.println("您輸入的日期格式有誤,請重新輸入!"); step?=?5; } }else?if(7==step){ if("null".equals(in)){ stu.setMobile(stu1.getMobile()); }else{ stu.setMobile(in); } StudentAction.Update(stu); System.out.println("學(xué)生信息更新成功。"); status?=?null; } if?(ACTION_UPDATE.equals(status))?{ step++; } }?else?if?(ACTION_QUERY.equals(in.toUpperCase()) ||?ACTION_QUERY.substring(0,?1).equals(in.toUpperCase()) ||?ACTION_QUERY.equals(status))?{ //?查詢學(xué)生信息 List<Student>?stulist?=?StudentAction.Query(); for?(Student?student?:?stulist)?{ System.out.println(student.getId()?+?"-姓名:" +?student.getName()); } continue; }?else?if?(ACTION_ADD.equals(in.toUpperCase()) ||?ACTION_ADD.substring(0,?1).equals(in.toUpperCase()) ||?ACTION_ADD.equals(status))?{ //?添加學(xué)生信息 status?=?ACTION_ADD; if?(1?==?step)?{ System.out.println("請輸入學(xué)生姓名[name]:"); }?else?if?(2?==?step)?{ stu.setName(in); System.out.println("請輸入學(xué)生性別[sex]:"); }?else?if?(3?==?step)?{ stu.setSex(Integer.valueOf(in)); System.out.println("請輸入學(xué)生年齡[age]:"); }?else?if?(4?==?step)?{ stu.setAge(Integer.valueOf(in)); System.out.println("請輸入學(xué)生生日[birthday-格式y(tǒng)yyy-MM-dd]:"); }?else?if?(5?==?step)?{ SimpleDateFormat?sdf?=?new?SimpleDateFormat("yyyy-MM-dd"); Date?birthday?=?null; try?{ birthday?=?sdf.parse(in); stu.setBirthday(birthday); System.out.println("請輸入學(xué)生手機(jī)號碼[mobile]:"); }?catch?(ParseException?e)?{ e.printStackTrace(); System.out.println("您輸入的日期格式有誤,請重新輸入!"); step?=?4; } }?else?if?(6?==?step)?{ stu.setMobile(in); StudentAction.Add(stu); System.out.println("學(xué)生信息添加成功。"); status?=?null; } if?(ACTION_ADD.equals(status))?{ step++; } }? } } }
糖醋肉3984350
lsnFor 回復(fù) 糖醋肉3984350
糖醋肉3984350 回復(fù) lsnFor
package?view; import?java.sql.SQLException; import?java.util.List; import?java.util.Scanner; import?control.*;? import?model.*; public?class?Test?{ ???? ????public?static?Scanner?in?=?new?Scanner(System.in); ????private?static?Control?test?=?new?Control(); ????/** ?????*?1.循環(huán)執(zhí)行輸入exit才退出 ?????*?2.執(zhí)行內(nèi)容 ?????*?增刪改查數(shù)據(jù)表 ?????*?3.細(xì)節(jié)展示 ?????*?@param?args ?????*?@throws?SQLException? ?????*/ ????public?static?void?main(String[]?args)?throws?SQLException?{ ????????//外層循環(huán) ????????System.out.println("***********************************"); ????????System.out.println("歡迎來到禁區(qū)!"); ????????System.out.println("***********************************"); ????????System.out.println("【exit】\t退出"); ????????System.out.println("【query】\t查詢女神信息"); ????????System.out.println("【get】\t查詢女神詳細(xì)信息"); ????????System.out.println("【add】\t增加女神"); ????????System.out.println("【delete】\t刪除女神"); ????????System.out.println("【clear】\t刪除所有女神信息"); ????????System.out.println("【edit】\t修改女神信息"); ????????String?select?=?"null"; ????????//創(chuàng)建對象 ????????Test?it?=?new?Test(); ???????? ????????String[]?s?=?{"query",?"get",?"add",?"delete",?"clear",?"edit"}; ????????do?{ ????????????System.out.println("***********************************"); ???????????? ????????????if?(select.equals(s[0]))?{ ????????????????it.query(); ????????????}?else?if?(select.equals(s[1]))?{ ????????????????it.get(); ????????????}?else?if?(select.equals(s[2]))?{ ????????????????it.add(); ????????????}?else?if?(select.equals(s[3]))?{ ????????????????it.delete(); ????????????}?else?if?(select.equals(s[4]))?{ ????????????????it.clear(); ????????????}?else?if?(select.equals(s[5]))?{ ????????????????it.edit(); ????????????}?else?{ ???????????????? ????????????} ????????????System.out.println("***********************************"); ????????}?while?(!(select?=?in.next()).equals("exit")); ????????System.out.println("退出!"); ????} ???? ????public?void?delete()?throws?SQLException?{ ????????System.out.println("請輸入要刪除女神的ID:"); ????????int?id?=?in.nextInt(); ????????test.delete(id); ????????System.out.println("刪除成功!"); ????} ???? ????public?void?clear()?throws?SQLException?{ ????????test.deleteAll(); ????????System.out.println("所有女神信息已清除!"); ????} ???? ????public?void?get()?throws?SQLException?{ ????????System.out.println("請輸入要查詢女神的編號:"); ????????int?id?=?in.nextInt(); ????????Goddess?g?=?test.getQuery(id); ????????System.out.println("ID:"?+?g.getId()?+ ????????????????"\nName:"?+?g.getName()?+ ????????????????"\nAge:"?+?g.getAge()?+? ????????????????"\nPhone:"?+?g.getPhone()); ????} ???? ????public?void?query()?throws?SQLException?{ ????????List<Goddess>?gList?=?test.getQuery(); ????????for?(Goddess?goddess?:?gList)?{ ????????????System.out.println("ID:"?+?goddess.getId()?+ ????????????????????????"\tName:"?+?goddess.getName()?); ????????} ????} ???? ????public?void?add()?throws?SQLException?{ ????????System.out.println("請輸入要添加女神基本信息[ID][Name][Age][Phonenumber]:"); ????????int?id?=?in.nextInt(); ????????String?name?=?in.next(); ????????int?age?=?in.nextInt(); ????????String?number?=?in.next(); ????????Goddess?g?=?new?Goddess(id,?age,?name,?number); ????????test.add(g); ????} ???? ????public?void?edit()?throws?SQLException?{ ????????System.out.println("請輸入要修改女神的基本信息[ID][Name][Age][Phonenumber]:"); ????????int?id?=?in.nextInt(); ????????String?name?=?in.next(); ????????int?age?=?in.nextInt(); ????????String?number?=?in.next(); ????????Goddess?g?=?new?Goddess(id,?age,?name,?number); ???????? ????????test.undates(id,?g); ????????System.out.println("修改成功!"); ????} }
Raven1
染紅_街道
package com.imooc.view;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
/**
?* 測試界面
?*/
import com.imooc.action.GoddessAction;
import com.imooc.model.Goddess;
public class GoddessView {
private static final String CONTEXT="歡迎來到女神禁區(qū):\n"+
"下面是女神禁區(qū)的功能列表\n"
+"[MAIN/M]:主菜單\n"
+"[QUERY/Q]:查詢?nèi)颗竦男畔n"
+"[GET/G]:查詢某位女神的詳細(xì)信息\n"
+"[ADD/A]:添加女神信息\n"
+"[UPDATE/U]:更新女神信息\n"
+"[DELETE/D]:刪除女神信息\n"
+"[SEARCH/S]:查詢女神信息\n"
+"[EXIT/E]:退出女神禁區(qū)\n"
+"[BREAK/B]:退出當(dāng)前功能,返回主菜單\n";
private static final String OPERATION_MAIN="MAIN";
private static final String OPERATION_QUERY="QUERY";
private static final String OPERATION_GET="GET";
private static final String OPERATION_ADD="ADD";
private static final String OPERATION_UPDATE="UPDATE";
? ? private static final String OPERATION_DELETE="DELETE";
? ? private static final String OPERATION_SEARCH="SEARCH";
? ? private static final String OPERATION_EXIT="EXIT";
? ? private static final String OPERATION_BREAK="BREAK";
public static void main(String[] args) throws Exception {
System.out.println(CONTEXT);
Scanner s=new Scanner(System.in);
Goddess goddess=new Goddess();
GoddessAction action=new GoddessAction();
String prenious=null;
Integer step=1;
? ?while(s.hasNext()){
? ? String in=s.next().toString();
? ? if(OPERATION_EXIT.equals(in.toUpperCase())//退出功能
? ? ||OPERATION_EXIT.substring(0, 1).equals(in.toUpperCase())){
? ? System.out.println("您已成功退出女神禁區(qū),歡迎下次光臨!");
? ? break;
? ? }else if(OPERATION_BREAK.equals(in.toUpperCase())//退出當(dāng)前功能返回主菜單
? ? ||OPERATION_BREAK.substring(0, 1).equals(in.toUpperCase())){
? ? System.out.println(CONTEXT);
? ? continue;
? ? }else if(OPERATION_MAIN.equals(in.toUpperCase())//返回主菜單
? ? ||OPERATION_MAIN.substring(0, 1).equals(in.toUpperCase())){
? ? }else if(OPERATION_QUERY.equals(in.toUpperCase())//查詢?nèi)颗裥畔⒐δ?/p>
? ? ||OPERATION_QUERY.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_QUERY.equals(prenious)){
? ? prenious=OPERATION_QUERY;
? ? List<Goddess> list=action.queryAllGoddess();
? ? for(Goddess goddessList:list){
? ? System.out.println(goddessList.toString());
? ? }
? ? }else if(OPERATION_GET.equals(in.toUpperCase())//根據(jù)ID查詢女神的功能
? ? ||OPERATION_GET.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_GET.equals(prenious)){
? ? prenious=OPERATION_GET;
? ? if(1==step){
? ? System.out.println("請輸入女神的ID:"); ? ?
? ? }else if(2==step){
? ? Goddess goddess01=action.queryById(Integer.valueOf(in)); ? ?
? ? System.out.println(goddess01.toString());
? ? step++;
? ?
? ?}else if(OPERATION_UPDATE.equals(in.toUpperCase())//更新女神信息功能
? ? ||OPERATION_UPDATE.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_UPDATE.equals(prenious)){
? ? prenious=OPERATION_UPDATE;
? ? System.out.println("請輸入要更新女神的ID:");
? ? goddess.setId(Integer.valueOf(in));
? ? System.out.println("請輸入更新后女神的[年齡]:");
? ? }else if(3==step){
? ? goddess.setAge(Integer.valueOf(in));
? ? System.out.println("請輸入更新后女神的[生日]:(格式如:yyyy-MM-dd)");
? ? }else if(4==step){
? ? SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
? ? Date birthday=format.parse(in);
? ? goddess.setBirthday(birthday);
? ? System.out.println("請輸入更新后女神的[郵箱]:");
? ? }else if(5==step){
? ? goddess.setEmail(in);
? ? System.out.println("請輸入更新后女神的[電話]:");
? ? }else if(6==step){
? ? goddess.setMobile(in);
? ? System.out.println("請輸入更新后女神的[姓名]:");
? ? }else if(7==step){
? ? goddess.setUser_name(in);
? ? action.edit(goddess);
? ? System.out.println("信息更新成功");
? ?}else if(OPERATION_DELETE.equals(in.toUpperCase())//刪除女神信息功能
? ? ||OPERATION_DELETE.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_DELETE.equals(prenious)){
? ? prenious=OPERATION_DELETE;
? ? System.out.println("請輸入要刪除女神的ID:");
? ? action.del(Integer.valueOf(in));
? ? System.out.println("信息刪除成功!");
? ?}else if(OPERATION_SEARCH.equals(in.toUpperCase())//根據(jù)參數(shù)查詢女神信息功能
? ? ||OPERATION_SEARCH.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_SEARCH.equals(prenious)){
? ? prenious=OPERATION_SEARCH;
? ? List<Map<String,Object>> params=new ArrayList<Map<String,Object>>();
? ? Map<String,Object> map=new HashMap<String,Object>();
? ? System.out.println("輸入要查詢的參數(shù):");
? ? map.put("name", in); ? ?
? ? System.out.println("輸入查詢規(guī)則:");
? ? map.put("rela", in);
? ? System.out.println("輸入要查詢的參數(shù)名:");
? ? map.put("value", in);
? ? params.add(map);
? ? List<Goddess> list=action.queryByParams(params);
? ? for(Goddess g:list){
? ? System.out.println(g.toString());
? ?}else if(OPERATION_ADD.equals(in.toUpperCase())//添加女神信息功能
? ? ||OPERATION_ADD.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_ADD.equals(prenious)){
? ? prenious=OPERATION_ADD;
? ? System.out.println("請輸入女神的[姓名]:");
? ? System.out.println("請輸入女神的[年齡]:");
? ? System.out.println("請輸入女神的[生日]:(格式如:yyyy-MM-dd)");
? ? System.out.println("請輸入女神的[郵箱]:");
? ? System.out.println("請輸入女神的[電話]:");
? ? action.add(goddess);
? ? }else{
? ? System.out.println("你輸入的值為:"+in);
? ?}
? ?s.close();
}
我自己做完了視圖層的全部功能,你要的話,可以留下郵箱,這里上傳不了文件
舉報
一起領(lǐng)略JDBC的奧秘,為進(jìn)一步學(xué)習(xí)集成框架打下良好的基礎(chǔ)
4 回答完整版的View代碼塊有誰寫出來了嗎
2 回答有誰的全部寫出來的,功能 所有的 發(fā)一下視圖層代碼 謝謝
1 回答視圖層的搭建。
1 回答視圖層流程圖
2 回答求大牛分享一份視圖層全部功能的代碼?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2022-03-25
你把新建的xml名字改成不是原來的那個,然后再MainActivity里面的R.layout.__也改成那個你定的名字就OK了像<a>,<span>這類都是非塊級元素,必要的時候要用display:block;屬性來轉(zhuǎn)成塊級元素,
2016-10-06
感覺最上面的那個模塊化的代碼可讀性最強(qiáng),一目了然。牛逼
2016-08-09
2016-07-16
2016-04-18
package com.imooc.view;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
/**
?* 測試界面
?*/
import com.imooc.action.GoddessAction;
import com.imooc.model.Goddess;
public class GoddessView {
private static final String CONTEXT="歡迎來到女神禁區(qū):\n"+
"下面是女神禁區(qū)的功能列表\n"
+"[MAIN/M]:主菜單\n"
+"[QUERY/Q]:查詢?nèi)颗竦男畔n"
+"[GET/G]:查詢某位女神的詳細(xì)信息\n"
+"[ADD/A]:添加女神信息\n"
+"[UPDATE/U]:更新女神信息\n"
+"[DELETE/D]:刪除女神信息\n"
+"[SEARCH/S]:查詢女神信息\n"
+"[EXIT/E]:退出女神禁區(qū)\n"
+"[BREAK/B]:退出當(dāng)前功能,返回主菜單\n";
private static final String OPERATION_MAIN="MAIN";
private static final String OPERATION_QUERY="QUERY";
private static final String OPERATION_GET="GET";
private static final String OPERATION_ADD="ADD";
private static final String OPERATION_UPDATE="UPDATE";
? ? private static final String OPERATION_DELETE="DELETE";
? ? private static final String OPERATION_SEARCH="SEARCH";
? ? private static final String OPERATION_EXIT="EXIT";
? ? private static final String OPERATION_BREAK="BREAK";
public static void main(String[] args) throws Exception {
System.out.println(CONTEXT);
Scanner s=new Scanner(System.in);
Goddess goddess=new Goddess();
GoddessAction action=new GoddessAction();
String prenious=null;
Integer step=1;
? ?while(s.hasNext()){
? ? String in=s.next().toString();
? ? if(OPERATION_EXIT.equals(in.toUpperCase())//退出功能
? ? ||OPERATION_EXIT.substring(0, 1).equals(in.toUpperCase())){
? ? System.out.println("您已成功退出女神禁區(qū),歡迎下次光臨!");
? ? break;
? ? }else if(OPERATION_BREAK.equals(in.toUpperCase())//退出當(dāng)前功能返回主菜單
? ? ||OPERATION_BREAK.substring(0, 1).equals(in.toUpperCase())){
? ? System.out.println(CONTEXT);
? ? continue;
? ? }else if(OPERATION_MAIN.equals(in.toUpperCase())//返回主菜單
? ? ||OPERATION_MAIN.substring(0, 1).equals(in.toUpperCase())){
? ? System.out.println(CONTEXT);
? ? continue;
? ? }else if(OPERATION_QUERY.equals(in.toUpperCase())//查詢?nèi)颗裥畔⒐δ?/p>
? ? ||OPERATION_QUERY.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_QUERY.equals(prenious)){
? ? prenious=OPERATION_QUERY;
? ? List<Goddess> list=action.queryAllGoddess();
? ? for(Goddess goddessList:list){
? ? System.out.println(goddessList.toString());
? ? }
? ? }else if(OPERATION_GET.equals(in.toUpperCase())//根據(jù)ID查詢女神的功能
? ? ||OPERATION_GET.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_GET.equals(prenious)){
? ? prenious=OPERATION_GET;
? ? if(1==step){
? ? System.out.println("請輸入女神的ID:"); ? ?
? ? }else if(2==step){
? ? Goddess goddess01=action.queryById(Integer.valueOf(in)); ? ?
? ? System.out.println(goddess01.toString());
? ? }
? ? step++;
? ?
? ?}else if(OPERATION_UPDATE.equals(in.toUpperCase())//更新女神信息功能
? ? ||OPERATION_UPDATE.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_UPDATE.equals(prenious)){
? ? prenious=OPERATION_UPDATE;
? ? if(1==step){
? ? System.out.println("請輸入要更新女神的ID:");
? ? }else if(2==step){
? ? goddess.setId(Integer.valueOf(in));
? ? System.out.println("請輸入更新后女神的[年齡]:");
? ? }else if(3==step){
? ? goddess.setAge(Integer.valueOf(in));
? ? System.out.println("請輸入更新后女神的[生日]:(格式如:yyyy-MM-dd)");
? ? }else if(4==step){
? ? SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
? ? Date birthday=format.parse(in);
? ? goddess.setBirthday(birthday);
? ? System.out.println("請輸入更新后女神的[郵箱]:");
? ? }else if(5==step){
? ? goddess.setEmail(in);
? ? System.out.println("請輸入更新后女神的[電話]:");
? ? }else if(6==step){
? ? goddess.setMobile(in);
? ? System.out.println("請輸入更新后女神的[姓名]:");
? ? }else if(7==step){
? ? goddess.setUser_name(in);
? ? action.edit(goddess);
? ? System.out.println("信息更新成功");
? ? }
? ? step++;
? ?
? ?}else if(OPERATION_DELETE.equals(in.toUpperCase())//刪除女神信息功能
? ? ||OPERATION_DELETE.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_DELETE.equals(prenious)){
? ? prenious=OPERATION_DELETE;
? ? if(1==step){
? ? System.out.println("請輸入要刪除女神的ID:");
? ? }else if(2==step){
? ? action.del(Integer.valueOf(in));
? ? System.out.println("信息刪除成功!");
? ? }
? ? step++;
? ?}else if(OPERATION_SEARCH.equals(in.toUpperCase())//根據(jù)參數(shù)查詢女神信息功能
? ? ||OPERATION_SEARCH.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_SEARCH.equals(prenious)){
? ? prenious=OPERATION_SEARCH;
? ? List<Map<String,Object>> params=new ArrayList<Map<String,Object>>();
? ? Map<String,Object> map=new HashMap<String,Object>();
? ? if(1==step){
? ? System.out.println("輸入要查詢的參數(shù):");
? ? map.put("name", in); ? ?
? ? }else if(2==step){
? ? System.out.println("輸入查詢規(guī)則:");
? ? map.put("rela", in);
? ? }else if(3==step){
? ? System.out.println("輸入要查詢的參數(shù)名:");
? ? map.put("value", in);
? ? }else if(4==step){
? ? params.add(map);
? ? List<Goddess> list=action.queryByParams(params);
? ? for(Goddess g:list){
? ? System.out.println(g.toString());
? ? }
? ? }
? ? step++;
? ?}else if(OPERATION_ADD.equals(in.toUpperCase())//添加女神信息功能
? ? ||OPERATION_ADD.substring(0, 1).equals(in.toUpperCase())
? ? ||OPERATION_ADD.equals(prenious)){
? ? prenious=OPERATION_ADD;
? ? if(1==step){
? ? System.out.println("請輸入女神的[姓名]:");
? ? }else if(2==step){
? ? goddess.setUser_name(in);
? ? System.out.println("請輸入女神的[年齡]:");
? ? }else if(3==step){
? ? goddess.setAge(Integer.valueOf(in));
? ? System.out.println("請輸入女神的[生日]:(格式如:yyyy-MM-dd)");
? ? }else if(4==step){
? ? SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
? ? Date birthday=format.parse(in);
? ? goddess.setBirthday(birthday);
? ? System.out.println("請輸入女神的[郵箱]:");
? ? }else if(5==step){
? ? goddess.setEmail(in);
? ? System.out.println("請輸入女神的[電話]:");
? ? }else if(6==step){
? ? goddess.setMobile(in);
? ? action.add(goddess);
? ? }
? ? step++;
? ? }else{
? ? System.out.println("你輸入的值為:"+in);
? ? }
? ?}
? ?s.close();
? ?
}
}
2016-04-18
我自己做完了視圖層的全部功能,你要的話,可以留下郵箱,這里上傳不了文件