commit 76703669893fa3cfc324142e4b8ec7388cc7761e
Author: markma <750975972@qq.com>
Date: Mon Aug 2 11:08:27 2021 +0800
0.0.1
Signed-off-by: markma <750975972@qq.com>
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..37efc6e
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/.project b/.project
new file mode 100644
index 0000000..e02732f
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ Markma-Hero-Select
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..5723a0f
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e8ab647
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+该程序是用来筛选数据库上的武将信息。
+
+有关该项目资料的查询:https://www.wolai.com/81653LDk4k71WzqBnokQ5r?theme=light
+
+我的其他项目资料:https://www.wolai.com/k3a8LkCjN8xnEKTvKYPqum?theme=light
+
+ https://www.wolai.com/tqqpCNJ3U7jUHCPx13Qorx?theme=light
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..27f566b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,24 @@
+
+ 4.0.0
+ com.markma
+ Markma-Hero-Select
+ 0.0.1-SNAPSHOT
+
+
+ org.mybatis
+ mybatis
+ 3.4.4
+
+
+ org.mybatis
+ mybatis-spring
+ 1.3.0
+
+
+ mysql
+ mysql-connector-java
+ 8.0.26
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
new file mode 100644
index 0000000..b96a847
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,11 @@
+
+import tools.ArgsHandler;
+
+public class Main {
+
+ public static void main(String[] args)
+ {
+ ArgsHandler argsHandler = new ArgsHandler(args);
+ argsHandler.switchModel();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/hero/Hero.java b/src/main/java/hero/Hero.java
new file mode 100644
index 0000000..55069b0
--- /dev/null
+++ b/src/main/java/hero/Hero.java
@@ -0,0 +1,188 @@
+package hero;
+
+public class Hero {
+
+ final String COLORCODE = "31";
+ private int ID = 0,
+ bloodValue = 0,
+ attackValue = 0;
+ private String name = "",
+ weaponName = "",
+ birthday = "",
+ deathday = "",
+ introduction = "";
+
+ // create table books(id int primary key auto_increment,title varchar(40),author varchar(40),price int);
+
+ public Hero()
+ {
+ }
+
+ public Hero(int ID,
+ int bloodValue,
+ int attackValue,
+ String name,
+ String weaponName,
+ String birthday,
+ String deathday,
+ String introduction)
+ {
+ super();
+ this.ID = ID;
+ this.bloodValue = bloodValue;
+ this.attackValue = attackValue;
+ this.name = name;
+ this.weaponName = weaponName;
+ this.birthday = birthday;
+ this.deathday = deathday;
+ this.introduction = introduction;
+ }
+
+ public int getID()
+ {
+ return ID;
+ }
+
+ public void setID(int iD)
+ {
+ ID = iD;
+ }
+
+ public int getBloodValue()
+ {
+ return bloodValue;
+ }
+
+ public void setBloodValue(int bloodValue)
+ {
+ this.bloodValue = bloodValue;
+ }
+
+ public int getAttackValue()
+ {
+ return attackValue;
+ }
+
+ public void setAttackValue(int attackValue)
+ {
+ this.attackValue = attackValue;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getWeaponName()
+ {
+ return weaponName;
+ }
+
+ public void setWeaponName(String weaponName)
+ {
+ this.weaponName = weaponName;
+ }
+
+ public String getBirthday()
+ {
+ return birthday;
+ }
+
+ public void setBirthday(String birthday)
+ {
+ this.birthday = birthday;
+ }
+
+ public String getDeathday()
+ {
+ return deathday;
+ }
+
+ public void setDeathday(String deathday)
+ {
+ this.deathday = deathday;
+ }
+
+ public String getIntroduction()
+ {
+ return introduction;
+ }
+
+ public void setIntroduction(String introduction)
+ {
+ this.introduction = introduction;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hero [ID=" + ID
+ + ", bloodValue=" + bloodValue
+ + ", attackValue=" + attackValue
+ + ", name=" + name
+ + ", weaponName=" + weaponName
+ + ", birthday=" + birthday
+ + ", deathday=" + deathday
+ + ", introduction=" + introduction
+ + "]";
+ }
+ public String partToString(String dividedPro[])
+ {
+ String printString = "Hero [";
+ printString += "name=";
+ printString += name;
+ printString += ",";
+ //String pro:dividedPro
+ for(int i = 0;i find(@Param("name") String name);
+ @Select("SELECT * FROM heros")
+ List findAll();
+ @Delete("")
+ void remove(String title);
+ @Update("")
+ void update(Hero b);
+}
\ No newline at end of file
diff --git a/src/main/java/tools/ArgsDivider.java b/src/main/java/tools/ArgsDivider.java
new file mode 100644
index 0000000..5f5a16c
--- /dev/null
+++ b/src/main/java/tools/ArgsDivider.java
@@ -0,0 +1,27 @@
+package tools;
+public class ArgsDivider
+{
+ final int MAX_NAME = 1000,MAX_PRO = 1000;
+ String undividedName,undividedProperties;
+ String dividedName[],dividedProperties[];
+ public ArgsDivider()
+ {
+
+ }
+ public ArgsDivider(String mainUndName,String mainUndProperties)
+ {
+ undividedName = mainUndName;
+ undividedProperties = mainUndProperties;
+ }
+ public void divideName()
+ {
+ dividedName = new String[MAX_NAME];
+ dividedName = undividedName.split(",");
+ }
+ public void dividePro()
+ {
+ dividedProperties = new String[MAX_PRO];
+ dividedProperties = undividedProperties.split(",");
+ }
+
+}
diff --git a/src/main/java/tools/ArgsHandler.java b/src/main/java/tools/ArgsHandler.java
new file mode 100644
index 0000000..d6f0aa6
--- /dev/null
+++ b/src/main/java/tools/ArgsHandler.java
@@ -0,0 +1,78 @@
+package tools;
+
+public class ArgsHandler
+{
+ String args[];
+ final String VERSION = "0.0.1";
+ public ArgsHandler()
+ {
+
+ }
+ public ArgsHandler(String mainArgs[])
+ {
+ args = new String[mainArgs.length];
+ System.arraycopy(mainArgs, 0, args, 0, mainArgs.length);
+ }
+ public void printHelp()
+ {
+ System.out.println("-s name properties 搜索模式");
+ System.out.println("多个name和properties用,连接 查询全部为-a");
+ System.out.println("properties名称:姓名name,武器weaponName,生日birthday,卒日deathday,"
+ + "介绍introduction,ID ID,血量bloodValue,攻击力attackValue");
+ System.out.println("例: -s 刘备,曹操 ID,bloodValue");
+ System.out.println("例: -s -a ID");
+ System.out.println("-v 显示版本");
+ return;
+ }
+ public void switchModel()
+ {
+ switch(args.length)
+ {
+ case 0:
+ {
+ System.out.println("三国人物查找系统");
+ System.out.println("命令后缀名:");
+ printHelp();
+ return;
+ }
+ case 1:
+ {
+ if(args[0].equals("-v"))
+ {
+ System.out.println("version:"+VERSION);
+ return;
+ }
+ else
+ {
+ System.out.println("后缀名输入错误");
+ printHelp();
+ return;
+ }
+ }
+ case 3:
+ {
+ if(args[0].equals("-s"))
+ {
+ ArgsDivider argsDivider = new ArgsDivider(args[1],args[2]);
+ argsDivider.divideName();
+ argsDivider.dividePro();
+ SQLReader sqlReader = new SQLReader();
+ sqlReader.read(argsDivider.dividedName, argsDivider.dividedProperties);
+ return;
+ }
+ else
+ {
+ System.out.println("后缀名输入错误");
+ printHelp();
+ return;
+ }
+ }
+ default:
+ {
+ System.out.println("后缀名数目输入错误");
+ printHelp();
+ return;
+ }
+ }
+ }
+}
diff --git a/src/main/java/tools/SQLReader.java b/src/main/java/tools/SQLReader.java
new file mode 100644
index 0000000..bc8f337
--- /dev/null
+++ b/src/main/java/tools/SQLReader.java
@@ -0,0 +1,77 @@
+package tools;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ibatis.io.Resources;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+
+import hero.Hero;
+import hero.HeroMapper;
+
+public class SQLReader
+{
+ public SQLReader()
+ {
+
+ }
+ public void read(String [] dividedName,String [] dividedPro)
+ {
+ try
+ {
+ SqlSessionFactory factory = new SqlSessionFactoryBuilder()
+ .build(Resources.getResourceAsReader("tools/config.xml"));
+
+ // 一次会话
+ // Connection
+ SqlSession session = factory.openSession();
+
+ // 获得了接口的一个具体实现(实例)
+ // mybatis 根据注解创建了接口的实力
+ HeroMapper mapper = session.getMapper(HeroMapper.class);
+ List heroList = new ArrayList();
+ for(String name:dividedName)
+ {
+ if(name.equals("-a"))
+ {
+ heroList = mapper.findAll();
+ break;
+ }
+ else
+ {
+ if(mapper.find(name) != null)
+ {
+ heroList.addAll(mapper.find(name));
+ }
+ }
+ }
+ String pro = dividedPro[0];
+ if(pro.equals("-a"))
+ {
+ for (Hero i : heroList)
+ {
+ System.out.println(i);
+ }
+ }
+ else
+ {
+ for (Hero i : heroList)
+ {
+ System.out.println(i.partToString(dividedPro));
+ }
+ }
+
+ // 会话提交
+ session.commit();
+ System.out.println("查询完毕,共找到"+heroList.size()+"条结果");
+
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/tools/config.xml b/src/main/java/tools/config.xml
new file mode 100644
index 0000000..3b430ae
--- /dev/null
+++ b/src/main/java/tools/config.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+