修改了ddl并导入了数据,已经可以进行增删改查功能

有模糊搜索,但无编辑删除功能的代码
F_X_Zhe 6 months ago
parent 8d4970ed2b
commit b5257720e0

@ -0,0 +1,32 @@
delete from T_Drugs;
insert into T_Drugs values('10001','0.9%쪘뺏컷鬧<ECBBB7>',800);
insert into T_Drugs values('10002','10%팥境鎌鬧<E98E8C>',1600);
insert into T_Drugs values('10003','25%팥境鎌鬧<E98E8C>',500);
insert into T_Drugs values('10004','50%팥境鎌鬧<E98E8C>',1250);
insert into T_Drugs values('10005','갚솖굵擧鬧<EFBFBD>',323);
insert into T_Drugs values('10006','뜩郭屆왯륩휫捻',155);
insert into T_Drugs values('10007','로제옴북셉(북셉)',697);
insert into T_Drugs values('10008','맘옰求빱뤽죕(括꼼)',52);
insert into T_Drugs values('10009','맘있튬(튬셉)',168);
insert into T_Drugs values('10010','릿렘抉擧맥텟更옮젓',985);
insert into T_Drugs values('10011','뼝竟計鬧<EFBFBD>捻(鬧<>셉)',211);
insert into T_Drugs values('10012','솖机郭꽝綾돛堈(綾돛堈)',129);
insert into T_Drugs values('10013','솖南쪘팹갬鬧<EFBFBD>',681);
insert into T_Drugs values('10014','영맘퀸스(퀸스셉)',52);
insert into T_Drugs values('10015','영맘懦스켠',36);
insert into T_Drugs values('10016','웸揭스켠(스켠)',89);
insert into T_Drugs values('10017','윳갚팥極옮젓',67);
insert into T_Drugs values('10018','적뜩엥凜鬧<EFBFBD>',225);
insert into T_Drugs values('10019','쪘뺏솜鬧<EFBFBD>',569);
insert into T_Drugs values('10020','쵠렷鱇計',44);
insert into T_Drugs values('10021','형쭁計황늠뉼튬',49);
insert into T_Drugs values('10022','흗擧컷주목鬧<EFBFBD>',113);
insert into T_Drugs values('10023','흗擧弩<EFBFBD>衫西鬧<EFBFBD>',253);
insert into T_Drugs values('10024','崗펠맷었愷젬삶었튬(튬셉)',55);
insert into T_Drugs values('10025','<EFBFBD>羹AD두셉',169);
insert into T_Drugs values('10026','<EFBFBD>羹B1',32);
insert into T_Drugs values('10027','<EFBFBD>羹B6',87);
insert into T_Drugs values('10028','俱흙痰吉擧갚鴨乞휫捻',12);
insert into T_Drugs values('10029','机澁格랑-齡첫었羹堈',31);
insert into T_Drugs values('10030','懦旿퀼<EFBFBD>',462);

@ -1,7 +1,7 @@
create table T_Drugs(
ID varchar(5),
name varchar(20),
num numeric(3,0),
name varchar(64),
num numeric(5,0),
primary key (ID));
@ -13,7 +13,7 @@ create table T_Norms(
create table T_Vendor(
ID varchar(5),
name varchar(20),
name varchar(64),
address varchar(64),
phonenumber varchar(11),
monitor varchar(5),

@ -1,8 +1,11 @@
package com.keafmd.dao;
import com.keafmd.domain.Drugs;
import com.keafmd.domain.User;
import java.util.List;
public interface IDrugDao {
public interface IDataDao {
List<User> find_User();
List<Drugs> find_drugs();
}

@ -1,8 +0,0 @@
package com.keafmd.dao;
import com.keafmd.domain.User;
import java.util.List;
public interface IUserDao {
List<User> find_User();
}

@ -1,4 +1,33 @@
package com.keafmd.domain;
public class Drugs {
private Integer ID;
private String name;
private Integer num;
public Integer getID() {
return ID;
}
public void setID(Integer ID) {
this.ID = ID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
@Override
public String toString() {
return "Drugs:{ID=" + ID + ", name=" + name + ", num=" + num + "}";
}
}

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.keafmd.dao.IUserDao">
<mapper namespace="com.keafmd.dao.IDataDao">
<select id="find_User" resultType="com.keafmd.domain.User">
select * from T_User
@ -13,4 +13,14 @@
AND name like #{name}
</if>
</select>
<select id="find_drugs" resultType="com.keafmd.domain.Drugs">
select * from T_Drugs
<if test = "ID != null">
AND ID like #{ID}
</if>
<if test = "name != null">
AND name like #{name}
</if>
</select>
</mapper>

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.keafmd.dao.IUserDao">
<select id="findAll" resultType="com.keafmd.domain.User">
select * from instructor
<if test = "ID != null">
AND ID like #{ID}
</if>
<if test = "name != null">
AND name like #{name}
</if>
</select>
</mapper>

@ -1,7 +1,7 @@
package com.keafmd.test;
import com.keafmd.dao.IUserDao;
import com.keafmd.domain.User;
import com.keafmd.dao.IDataDao;
import com.keafmd.domain.Drugs;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
@ -22,11 +22,16 @@ public class MybatisTest {
//3.使用工厂生产SqlSession对象
SqlSession session = factory.openSession();
//4.使用SqlSession创建Dao接口的代理对象
IUserDao userDao = session.getMapper(IUserDao.class);
/*IUserDao userDao = session.getMapper(IUserDao.class);
//5.使用代理对象执行方法
List<User> users = Collections.unmodifiableList(userDao.find_User());
for (User user : users) {
List<User> users = Collections.unmodifiableList(userDao.find_User());*/
IDataDao drugDao = session.getMapper(IDataDao.class);
List<Drugs> drugs = Collections.unmodifiableList(drugDao.find_drugs());
/*for (User user : users) {
System.out.println(user);
}*/
for (Drugs d : drugs) {
System.out.println(d);
}
//6.释放资源
session.close();

Loading…
Cancel
Save