源码地址:java_ssm_tb_vaccine对照编码【登记系统】-Java文档类资源-CSDN下载
效果:
模糊查询
添加
删除
配置文件与创建项目参考:【当年的Java考试:JAVA&移动应用&大数据-大三-社区疫苗接种管理系统(全部源码·保姆式呵护)_红目香薰的博客-CSDN博客】
目录
mapper/TbVaccineMapper.xml
TbVaccine
TbVaccineMapper
TbVaccineService
TbVaccineServiceImpl
TbVaccineController
GetInfo.jsp
INSERT into tb_vaccine VALUES(0,"${name}","${sex}","${id_no}","${address}",#{company},NOW());
delete from tb_vaccine where id=#{id}
package com.item.model;
public class TbVaccine {
private int id;
private String name;
private String sex;
private String id_no;
private String address;
private int company;
private String inoculation_time;
@Override
public String toString() {
return "TbVaccine{" +
"id=" + id +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", id_no='" + id_no + '\'' +
", address='" + address + '\'' +
", company=" + company +
", inoculation_time='" + inoculation_time + '\'' +
'}';
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getId_no() {
return id_no;
}
public void setId_no(String id_no) {
this.id_no = id_no;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getCompany() {
return company;
}
public void setCompany(int company) {
this.company = company;
}
public String getInoculation_time() {
return inoculation_time;
}
public void setInoculation_time(String inoculation_time) {
this.inoculation_time = inoculation_time;
}
}
package com.item.dao;
import com.item.model.TbVaccine;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TbVaccineMapper {
List GetInfo();
List SelectByNameAndIdNo(@Param("name") String name,@Param("id_no") String id_no);
int AddInfo(
@Param("name") String name,
@Param("sex") String sex,
@Param("id_no") String id_no,
@Param("address") String address,
@Param("company") int company
);
int DeleteById(@Param("id") int id);
}
package com.item.service;
import com.item.model.TbVaccine;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TbVaccineService {
/**
* 查询所有
*
* @return
*/
List GetInfo();
/**
* 模糊查询
*
* @return
*/
List SelectByNameAndIdNo(String name, String id_no);
/**
* 添加
* @param name
* @param sex
* @param id_no
* @param address
* @param company
* @return
*/
int AddInfo(
String name,
String sex,
String id_no,
String address,
int company
);
/**
* 删除
* @param id
* @return
*/
int DeleteById(int id);
}
package com.item.serviceimpl;
import com.item.dao.TbVaccineMapper;
import com.item.model.TbVaccine;
import com.item.service.TbVaccineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TbVaccineServiceImpl implements TbVaccineService {
@Autowired
private TbVaccineMapper tbVaccineMapper;
@Override
public List GetInfo() {
return tbVaccineMapper.GetInfo();
}
@Override
public List SelectByNameAndIdNo(String name, String id_no) {
return tbVaccineMapper.SelectByNameAndIdNo(name,id_no);
}
@Override
public int AddInfo(String name, String sex, String id_no, String address, int company) {
return tbVaccineMapper.AddInfo(name,sex,id_no,address,company);
}
@Override
public int DeleteById(int id) {
return tbVaccineMapper.DeleteById(id);
}
}
package com.item.controller;
import com.item.model.TbVaccine;
import com.item.service.TbVaccineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
public class TbVaccineController {
@Autowired
private TbVaccineService db;
@GetMapping("/GetInfo")
public String GetInfo(HttpServletRequest request, Model model){
List list = db.GetInfo();
model.addAttribute("lists",list);
return "GetInfo";
}
@GetMapping("/SelectByNameAndIdNo")
public String SelectByNameAndIdNo(HttpServletRequest request, Model model){
String name = request.getParameter("name");
String id_no = request.getParameter("id_no");
List list = db.SelectByNameAndIdNo(name==""?null:name,id_no==""?null:id_no);
model.addAttribute("lists",list);
return "GetInfo";
}
@GetMapping("/AddInfoPage")
public String AddInfoPage(){
return "AddInfoPage";
}
@PostMapping("/AddInfo")
public String AddInfo(HttpServletRequest request, Model model){
String name = request.getParameter("name");
String sex = request.getParameter("sex");
String id_no = request.getParameter("id_no");
String address = request.getParameter("address");
String company = request.getParameter("company");
db.AddInfo(name,sex,id_no,address,Integer.parseInt(company));
return "redirect:/GetInfo";
}
@GetMapping("/DeleteById")
public String DeleteById(HttpServletRequest request, Model model){
String id = request.getParameter("id");
db.DeleteById(Integer.parseInt(id));
return "redirect:/GetInfo";
}
}
<%@ page import="java.util.List" %>
<%@ page import="com.item.model.TbVaccine" %><%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2022/6/1 0001
Time: 10:34
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
视图页面
新冠疫苗接种登记系统
<% List list = (List) request.getAttribute("lists");%>
序号
姓名
性别
身份证号码
地址
疫苗企业
接种时间
操作
<%
for (TbVaccine t : list) {
%>
<%=t.getId()%>
<%=t.getName()%>
<%=t.getSex()%>
<%=t.getId_no()%>
<%=t.getAddress()%>
<%=t.getCompany()%>
<%=t.getInoculation_time()%>
删除
<%
}
%>
AddInfoPage.jsp
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2022/6/1 0001
Time: 10:36
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
添加页面