后端完整代码,包括各接口和一些基本方法

有模糊搜索,但无编辑删除功能的代码
F_X_Zhe 6 months ago
parent 9409d76a6c
commit 67bdb359d0

@ -1,11 +1,22 @@
package com.keafmd.dao;
import com.keafmd.domain.Drugs;
import com.keafmd.domain.User;
import com.keafmd.domain.*;
import java.util.List;
public interface IDataDao {
List<User> find_User();
List<Drugs> find_drugs();
List<Drugs> insert_drugs();
List<Norms> find_Norms();
List<Vendor> find_Vendor();
List<Department> find_Department();
List<Request> find_request();
List<Request> find_sum_commits();
List<Request> insert_requests();
}

@ -0,0 +1,40 @@
package com.keafmd.domain;
public class Department {
private Integer ID;
private String name;
private Integer member;
private String floor;
public void setID(Integer ID) {
this.ID = ID;
}
public Integer getID() {
return ID;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setMember(Integer member) {
this.member = member;
}
public Integer getMember() {
return member;
}
public void setFloor(String floor) {
this.floor = floor;
}
public String getFloor() {
return floor;
}
public String toString() {
return "ID: {" + ID + ", Name: " + name + ", Member: " + member + ", Floor: " + floor + "}";
}
}

@ -4,6 +4,9 @@ public class Drugs {
private Integer ID;
private String name;
private Integer num;
private String type;
private String productor;
private String address;
public Integer getID() {
return ID;
@ -26,8 +29,29 @@ public class Drugs {
this.num = num;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getProductor() {
return productor;
}
public void setProductor(String productor) {
this.productor = productor;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "Drugs:{ID=" + ID + ", name=" + name + ", num=" + num + "}";
return "Drugs:{" + ID + ", " + name + ", " + num + ", " + type + ", " + productor + ", " + address + "}";
}
}

@ -0,0 +1,25 @@
package com.keafmd.domain;
public class Norms {
private Integer ID;
private String feather;
public Integer getID() {
return ID;
}
public void setID(Integer ID) {
this.ID = ID;
}
public String getFeather() {
return feather;
}
public void setFeather(String feather) {
this.feather = feather;
}
@Override
public String toString() {
return "Norms:{ID=" + ID + ", feather=" + feather + "}";
}
}

@ -0,0 +1,74 @@
package com.keafmd.domain;
public class Request {
private Integer ID;
private Integer drug_ID;
private String drug_name;
private String feather;
private Integer num;
private String user_name;
private String department_name;
private String date;
public Integer getID() {
return ID;
}
public void setID(Integer ID) {
this.ID = ID;
}
public Integer getDrug_ID() {
return drug_ID;
}
public void setDrug_ID(Integer drug_ID){
this.drug_ID = drug_ID;
}
public String getDrug_name(){
return drug_name;
}
public void setDrug_name(String drug_name) {
this.drug_name = drug_name;
}
public String getFeather() {
return feather;
}
public void setFeather(String feather) {
this.feather = feather;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getDepartment_name() {
return department_name;
}
public void setDepartment_name(String department_name) {
this.department_name = department_name;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
@Override
public String toString(){
return "Request:{ID:" + ID + ",drug_ID:" + drug_ID + ",drug_name:" + drug_name
+ ",feather:" + feather + ",num:" + num + ",user_name:" + user_name + "}";
}
}

@ -1,7 +1,5 @@
package com.keafmd.domain;
import java.util.Date;
public class User {
private Integer user_id;
private String user_name;
@ -10,6 +8,7 @@ public class User {
private Integer age;
private String phonenumber;
private String role;
private String department;
public Integer getUser_id() {
return user_id;
@ -60,6 +59,13 @@ public class User {
this.role = role;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Override
public String toString() {
return "User:{" +
@ -70,6 +76,7 @@ public class User {
",age=" + age + '\'' +
",phonenumber=" + phonenumber + '\'' +
",role=" + role + '\'' +
",department=" + department + '\'' +
"}";
}
}

@ -0,0 +1,58 @@
package com.keafmd.domain;
public class Vendor {
private Integer ID;
private String name;
private String address;
private String phonenumber;
private String monitor;
private String zipcode;
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 String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getMonitor() {
return monitor;
}
public void setMonitor(String monitor) {
this.monitor = monitor;
}
public String getZipcode() {
return zipcode;
}
public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}
@Override
public String toString() {
return "Vendor:{ID=" + ID + ", name=" + name + ", address=" + address + ", phonenumber=" + phonenumber +
", monitor=" + monitor + ", zipcode=" + zipcode + "}";
}
}

@ -5,7 +5,7 @@
<mapper namespace="com.keafmd.dao.IDataDao">
<select id="find_User" resultType="com.keafmd.domain.User">
select * from T_User
select T_User.ID,T_User.name,T_User.sex,T_User.age,T_User.phonenumber,T_User.role,T_Department.name from (T_User natural join T_Belong) left join on T_Department on T_Belong.d_id = T_Department.ID
<if test = "ID != null">
AND ID like #{ID}
</if>
@ -15,7 +15,9 @@
</select>
<select id="find_drugs" resultType="com.keafmd.domain.Drugs">
select * from T_Drugs
select T_Drugs.ID,T_Drugs.name,T_Drugs.num,T_Norms.feather,T_Vendor.name,T_Vendor.address from ((T_Drugs left join T_Type on T_Drugs.ID = T_Type.d_id)
left join T_Norms on T_Type.n_id = T_Norms.ID)
left join T_Vendor on T_Type.producer = T_Vendor.ID
<if test = "ID != null">
AND ID like #{ID}
</if>
@ -23,4 +25,79 @@
AND name like #{name}
</if>
</select>
<select id="find_Vendor" resultType="com.keafmd.domain.Vendor">
select * from T_Vendor
<if test="ID != null">
AND ID like #{ID}
</if>
<if test="name != null">
AND name like #{name}
</if>
</select>
<select id="find_Department" resultType="com.keafmd.domain.Department">
select * from T_Department
<if test="ID != null">
AND ID like #{ID}
</if>
<if test="name != null">
AND name like #{name}
</if>
</select>
<select id="find_request" resultType="com.keafmd.domain.Request">
select T_Request.ID,T_Drugs.ID,T_Drugs.name,T_Norms.feather,T_Request.num,T_User.name,T_Department.name,T_Request.date
from ((((((T_Request natural join T_Require) left join T_Drugs on T_Require.d_id = T_Drugs.ID)
left join T_Type on T_Drugs.ID = T_Type.d_id)
left join T_Norms on T_Type.n_id = T_Norms.ID)
left join T_Commit on T_Request.ID = T_Commit.r_id)
left join T_User on T_User.ID = T_Commit.u_id)
left join T_Belong on T_Belong.u_id = T_User.ID)
left join T_Department on T_Department.ID = T_Belong.d_id
<if test="T_Request.ID != null">
AND T_Request.ID like #{T_Request.ID}
</if>
<if test="T_Drugs.ID != null">
AND T_Drugs.ID like #{T_Drugs.ID}
</if>
<if test="T_Drugs.name != null">
AND T_Drugs.name like #{T_Drugs.name}
</if>
<if test="T_Norms.feather != null">
AND T_Norms.feather like #{T_Norms.feather}
</if>
<if test="T_User.name != null">
AND T_User.name like #{T_User.name}
</if>>
<if test="T_Department.name != null">
AND T_Department.name like #{T_Department.name}
</if>
<if test="T_Request.date != null">
AND T_Request.date like #{T_Request.date}
</if>
</select>
<select id="find_sum_commits" resultType="com.keafmd.domain.Request">
select count(T_Request),T_Department.name
from (((T_Request natural join T_Commit) left join T_User on T_User.ID = T_Commit.u_id)
left join T_Belong on T_Belong.u_id = T_User.ID)
left join T_Department on T_Department.ID = T_Belong.u_id
<if test="T_Department.name != null">
AND T_Department.name like #{T_Department.name}
</if>
</select>
<insert id="insert_drugs" parameterType="com.keafmd.domain.Drugs">
insert into T_Drugs values (ID,name,num)
insert into T_Type values (ID,t_id,price,producer)
insert into T_Norm values (t_id,feather)
insert into T_Vendor values (producer,p_name,address,phonenumber,monitor,zipcode)
</insert>
<insert id="insert_request" parameterType="com.keafmd.domain.Request">
insert into T_Request values (ID,num,date)
insert into T_Require values (d_id,ID)
insert into T_Commit values (ID,u_id)
</insert>
</mapper>

@ -1,7 +1,7 @@
package com.keafmd.test;
import com.keafmd.dao.IDataDao;
import com.keafmd.domain.Drugs;
import com.keafmd.domain.*;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

Loading…
Cancel
Save