Java-SSM-新冠疫苗接种登记系统

举报
红目香薰 发表于 2022/06/26 20:02:48 2022/06/26
【摘要】 ​ 源码地址:java_ssm_tb_vaccine对照编码【登记系统】-Java文档类资源-CSDN下载效果:​编辑模糊查询​编辑​编辑添加​编辑​编辑删除​编辑​编辑 配置文件与创建项目参考:【当年的Java考试:JAVA&移动应用&大数据-大三-社区疫苗接种管理系统(全部源码·保姆式呵护)_红目香薰的博客-CSDN博客】目录mapper/TbVaccineMapper.xmlTbVac...

 源码地址:java_ssm_tb_vaccine对照编码【登记系统】-Java文档类资源-CSDN下载

效果:

编辑

模糊查询

编辑

编辑

添加

编辑

编辑

删除

编辑编辑

 配置文件与创建项目参考:【当年的Java考试:JAVA&移动应用&大数据-大三-社区疫苗接种管理系统(全部源码·保姆式呵护)_红目香薰的博客-CSDN博客

目录

mapper/TbVaccineMapper.xml

TbVaccine

TbVaccineMapper

TbVaccineService

TbVaccineServiceImpl

TbVaccineController

GetInfo.jsp



mapper/TbVaccineMapper.xml

<?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.item.dao.TbVaccineMapper">
    <select id="GetInfo" resultType="TbVaccine">
        select * from tb_vaccine;
    </select>
    <!-- name的模糊查询以及id_no的精准查询 -->
    <select id="SelectByNameAndIdNo" resultType="TbVaccine">
        select * from tb_vaccine
        <if test="name!=null or id_no!=null">
            where 1=1
        </if>
        <if test="name!=null">
            and name like "%${name}%"
        </if>
        <if test="id_no!=null">
            and id_no="${id_no}"
        </if>
    </select>
    <insert id="AddInfo">
        INSERT into tb_vaccine VALUES(0,"${name}","${sex}","${id_no}","${address}",#{company},NOW());
    </insert>
    <delete id="DeleteById">
        delete from tb_vaccine where id=#{id}
    </delete>
</mapper>


TbVaccine

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;
    }
}

TbVaccineMapper

package com.item.dao;

import com.item.model.TbVaccine;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface TbVaccineMapper {
    List<TbVaccine> GetInfo();

    List<TbVaccine> 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);
}

TbVaccineService

package com.item.service;

import com.item.model.TbVaccine;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface TbVaccineService {
    /**
     * 查询所有
     *
     * @return
     */
    List<TbVaccine> GetInfo();

    /**
     * 模糊查询
     *
     * @return
     */
    List<TbVaccine> 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);
}

TbVaccineServiceImpl

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<TbVaccine> GetInfo() {
        return tbVaccineMapper.GetInfo();
    }

    @Override
    public List<TbVaccine> 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);
    }
}

TbVaccineController

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<TbVaccine> 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<TbVaccine> 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";
    }
}

GetInfo.jsp

<%@ 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" %>
<html>
<head>
    <title>视图页面</title>
</head>
<body>
<h1>新冠疫苗接种登记系统</h1>
<form action="/SelectByNameAndIdNo">
    姓名:<input type="text" name="name"/>
    身份证:<input type="text" name="id_no"/>
    <input type="submit" value="查询"/>
    <a href="/AddInfoPage">登记</a>
</form>
<% List<TbVaccine> list = (List<TbVaccine>) request.getAttribute("lists");%>
<table style="width: 100%" cellpadding="1" cellspacing="1" border="1">
    <tr>
        <th>序号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>身份证号码</th>
        <th>地址</th>
        <th>疫苗企业</th>
        <th>接种时间</th>
        <th>操作</th>
    </tr>
    <%
        for (TbVaccine t : list) {
    %>
        <tr>
            <td><%=t.getId()%></td>
            <td><%=t.getName()%></td>
            <td><%=t.getSex()%></td>
            <td><%=t.getId_no()%></td>
            <td><%=t.getAddress()%></td>
            <td><%=t.getCompany()%></td>
            <td><%=t.getInoculation_time()%></td>
            <td>
                <a href="/DeleteById?id=<%=t.getId()%>" onclick="return confirm('是否删除此行')">删除</a>
            </td>
        </tr>
    <%
    }
%>
</table>
</body>
</html>

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" %>
<html>
<head>
    <title>添加页面</title>
</head>
<body>
    <form action="/AddInfo" method="post">
        <p>
            姓名<input type="text" name="name"/>
        </p>
        <p>
            性别<input type="text" name="sex"/>
        </p>
        <p>
            身份证<input type="text" name="id_no"/>
        </p>
        <p>
            地址<input type="text" name="address"/>
        </p>
        <p>
            型号<input type="text" name="company"/>
        </p>
        <p>
            <input type="submit" value="添加"/>
            <input type="reset" value="重置"/>
        </p>
    </form>
</body>
</html>


【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。