|
<
资本下载:https://download.csdn.net/download/weixin_44893902/21727306
1、言语战情况
1.完成言语: JAVA言语。
2.情况请求: MyEclipse/Eclipse + Tomcat + MySQL。
3.利用妙技: Spring MVC + Spring + MyBatis 或 JSP + Servlet + JavaBean + JDBC。
2、完成结果
完成可以对患者姓名,医师种别、科室的恍惚查询,用户面击核销当前形态变成已救治。
面击登记完成根本疑息的增加
3、完成代码
数据库:
- SET FOREIGN_KEY_CHECKS=0;
- -- ----------------------------
- -- Table structure for tb_patient
- -- ----------------------------
- DROP TABLE IF EXISTS `tb_patient`;
- CREATE TABLE `tb_patient` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `name` varchar(50) DEFAULT NULL,
- `sex` varchar(10) DEFAULT NULL,
- `age` int(11) DEFAULT NULL,
- `phone` varchar(20) DEFAULT NULL,
- `department` varchar(50) DEFAULT NULL,
- `type` varchar(50) DEFAULT NULL,
- `price` decimal(9,2) DEFAULT NULL,
- `state` int(11) DEFAULT NULL,
- `register_time` datetime DEFAULT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
- -- ----------------------------
- -- Records of tb_patient
- -- ----------------------------
- INSERT INTO `tb_patient` VALUES ('1', '张蕾', '女', '12', '13895463212', '女科', '专家医师', '25.00', '1', '2021-07-18 12:23:00');
- INSERT INTO `tb_patient` VALUES ('2', '刘德明', '男', '28', '13345623215', '骨科', '一般医师', '8.00', '0', '2021-07-18 12:23:00');
- INSERT INTO `tb_patient` VALUES ('3', '李将军', '男', '38', '13578064788', '外科', '专家医师', '25.00', '1', '2021-07-17 12:23:00');
- INSERT INTO `tb_patient` VALUES ('4', '张佩佩', '女', '44', '18214217246', '中科', '副主任医师', '17.00', '0', '2021-07-16 12:23:00');
- INSERT INTO `tb_patient` VALUES ('5', '程智慧', '男', '29', '13652645964', '骨科', '副主任医师', '17.00', '0', '2021-08-08 16:21:52');
复造代码 项目Java代码:
目次构造
JAR包:
代码:
=src
> com.mhys.crm.controller
HospitalContrller.java
- package com.mhys.crm.controller;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.mhys.crm.dao.TbPatientMapper;
- import com.mhys.crm.entity.TbPatient;
- @Controller
- public class HospitalContrller {
- @Resource
- private TbPatientMapper tbPatientMapper;
- @RequestMapping("/select")
- public String getList(Model model) {
- List<TbPatient> selctAll = tbPatientMapper.selectAlls();
- System.out.println(selctAll);
- model.addAttribute("selctAll", selctAll);
- return "info";
- }
- @RequestMapping("/list")
- public String getAll(Model model, String name, String type, String dep) {
- List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep);
- System.out.println(name+"==="+type+"==="+dep);
- model.addAttribute("selctAll", selctAll);
- return "info";
- }
- @RequestMapping("/upd")
- public String upDev(Model model,int id) {
- int update = tbPatientMapper.update(id);
- return "redirect:/select.do";
- }
-
- @RequestMapping("/adds")
- public String adds(Model model) {
- return "addInfo";
- }
-
- @RequestMapping("/insert")
- public String toaddDev(Model model,TbPatient tb) {
- tbPatientMapper.insert(tb);
- return "redirect:/select.do";
- }
- }
复造代码 > com.mhys.crm.dao
TbPatientMapper.java
- package com.mhys.crm.dao;
- import com.mhys.crm.entity.TbPatient;
- import java.util.List;
- import org.apache.ibatis.annotations.Param;
- public interface TbPatientMapper {
- int deleteByPrimaryKey(Integer id);
- int insert(TbPatient record);
- TbPatient selectByPrimaryKey(Integer id);
- List<TbPatient> selectAlls();
- int updateByPrimaryKey(TbPatient record);
-
- int update(Integer id);
-
- List<TbPatient> selectAll(@Param("name")String name,@Param("type")String type,@Param("dep")String dap);
- }
复造代码 TbPatientMapper.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.mhys.crm.dao.TbPatientMapper" >
- <resultMap id="BaseResultMap" type="com.mhys.crm.entity.TbPatient" >
- <id column="id" property="id" jdbcType="INTEGER" />
- <result column="name" property="name" jdbcType="VARCHAR" />
- <result column="sex" property="sex" jdbcType="VARCHAR" />
- <result column="age" property="age" jdbcType="INTEGER" />
- <result column="phone" property="phone" jdbcType="VARCHAR" />
- <result column="department" property="department" jdbcType="VARCHAR" />
- <result column="type" property="type" jdbcType="VARCHAR" />
- <result column="price" property="price" jdbcType="DECIMAL" />
- <result column="state" property="state" jdbcType="INTEGER" />
- <result column="register_time" property="registerTime" jdbcType="TIMESTAMP" />
- </resultMap>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
- delete from tb_patient
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" parameterType="com.mhys.crm.entity.TbPatient" >
- insert into tb_patient (id, name, sex,
- age, phone, department,
- type, price, state,
- register_time)
- values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR},
- #{age,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR},
- #{type,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{state,jdbcType=INTEGER},
- #{registerTime,jdbcType=TIMESTAMP})
- </insert>
- <update id="updateByPrimaryKey" parameterType="com.mhys.crm.entity.TbPatient" >
- update tb_patient
- set name = #{name,jdbcType=VARCHAR},
- sex = #{sex,jdbcType=VARCHAR},
- age = #{age,jdbcType=INTEGER},
- phone = #{phone,jdbcType=VARCHAR},
- department = #{department,jdbcType=VARCHAR},
- type = #{type,jdbcType=VARCHAR},
- price = #{price,jdbcType=DECIMAL},
- state = #{state,jdbcType=INTEGER},
- register_time = #{registerTime,jdbcType=TIMESTAMP}
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="selectAlls" resultMap="BaseResultMap" >
- select id, name, sex, age, phone, department, type, price, state, register_time
- from tb_patient
- </select>
-
- <select id="selectAll" resultMap="BaseResultMap" >
- select id, name, sex, age, phone, department, type, price, state, register_time
- from tb_patient
- <where>
- <if test="name!=null and name!=''">
- and name = #{name}
- </if>
- <if test="type!=null and type!=''">
- and type = #{type}
- </if>
- <if test="dep!=null and dep!=''">
- and department = #{dep}
- </if>
- </where>
- </select>
-
- <update id="update" parameterType="com.mhys.crm.entity.TbPatient" >
- update tb_patient set state=1 where id = #{id,jdbcType=INTEGER}
- </update>
-
- </mapper>
复造代码 > com.mhys.crm.entity
TbPatient.java
> com.mhys.crm.service.impl
HospitalService.java
- package com.mhys.crm.service.impl;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.mhys.crm.dao.TbPatientMapper;
- import com.mhys.crm.entity.TbPatient;
- public class HospitalService {
- @Resource
- private TbPatientMapper tbPatientMapper;
- @RequestMapping("/select")
- public String getList(Model model) {
- List<TbPatient> selctAll = tbPatientMapper.selectAlls();
- System.out.println(selctAll);
- model.addAttribute("selctAll", selctAll);
- return "info";
- }
- @RequestMapping("/list")
- public String getAll(Model model, String name, String type, String dep) {
- List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep);
- System.out.println(name+"==="+type+"==="+dep);
- model.addAttribute("selctAll", selctAll);
- return "info";
- }
- @RequestMapping("/upd")
- public String upDev(Model model,int id) {
- int update = tbPatientMapper.update(id);
- return "redirect:/select.do";
- }
-
- @RequestMapping("/adds")
- public String adds(Model model) {
- return "addInfo";
- }
-
- @RequestMapping("/insert")
- public String toaddDev(Model model,TbPatient tb) {
- tbPatientMapper.insert(tb);
- return "redirect:/select.do";
- }
- }
复造代码 =resource
> mybatis
SqlMapConfig.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-config.dtd">
- <configuration>
- <typeAliases>
- <package name="com.mhys.crm.entity"/>
- </typeAliases>
- </configuration>
复造代码 > spring
applicationContext-dao.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
-
- <context:property-placeholder location="classpath:database.properties"></context:property-placeholder>
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="driverClassName" value="${jdbc.driver}"></property>
- <property name="Url" value="${jdbc.url}"></property>
- <property name="username" value="${jdbc.username}"></property>
- <property name="password" value="${jdbc.password}"></property>
- </bean>
- <!-- 设置SqlSessionFactory -->
- <bean class="org.mybatis.spring.SqlSessionFactoryBean">
- <!-- 设置MyBatis中心设置文件 -->
- <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
- <!-- 设置数据源 -->
- <property name="dataSource" ref="dataSource" />
- </bean>
- <!-- 设置Mapper扫描 -->
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <!-- 设置Mapper扫描包 -->
- <property name="basePackage" value="com.mhys.crm.dao" />
- </bean>
- <!-- 设置事件办理器 -->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <!-- 开启注解方法办理AOP事件 -->
- <tx:annotation-driven transaction-manager="transactionManager" />
-
- </beans>
复造代码 applicationContext-service.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
- <!-- 设置Service扫描 -->
- <context:component-scan base-package="com" />
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager" />
- </beans>
复造代码 spring-mvc.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
- <!-- 设置Controller扫描 -->
- <context:component-scan base-package="com.mhys.crm.controller" />
- <mvc:annotation-driven />
- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="prefix" value="/WEB-INF/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
- </beans>
复造代码 > database.properties
- jdbc.url=jdbc:mysql://localhost:3306/hospital_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false
- jdbc.username=root
- jdbc.password=123456
- jdbc.driver=com.mysql.jdbc.Driver
复造代码 =JSP页里
> /WEB-INF/jsp/
addInfo.jsp
- <%@ page language="java" contentType="text/html; charset=utf-8"
- pageEncoding="utf-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>登记</title>
- </head>
- <body>
- <form action="insert.do" method="post">
- <table border="" cellspacing="" cellpadding="">
-
- <tr>
- <td>姓名</td>
- <td><input type="text" name="name" value="" /></td>
- </tr>
- <tr>
- <td>性别</td>
- <td><input type="text" name="sex" value=""/></td>
- </tr>
- <tr>
- <td>年齿</td>
- <td><input type="text" name="age" value=""/></td>
- </tr>
- <tr>
- <td>德律风</td>
- <td><input type="text" name="phone" value=""/></td>
- </tr>
- <tr>
- <td>医师种别</td>
- <td><input type="text" name="department" value=""/></td>
- </tr>
- <tr>
- <td>价钱</td>
- <td><input type="text" name="price" value=""/></td>
- </tr>
- <tr>
- <td>登记工夫</td>
- <td><input type="text" name="registerTime" value=""/></td>
- </tr>
-
- </table>
- <input type="submit" value="肯定" />
- </form>
- </body>
- </html>
复造代码 info.jsp
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
- <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>病院救治登记体系</title>
- <style type="text/css">
- form{
- padding: 20px;
- }
- #warp{
- margin:0 auto;
- width: 60%
- }
- </style>
- </head>
- <body>
- <h1 align="center">病院救治登记体系</h1>
- <div id="warp">
- <form action="list.do">
- 患者姓名:<input type="text" name="name">
- 医师种别:
- <select name="type">
- <option value="" >=没有限=</option>
- <option value="专家医师" >专家医师</option>
- <option value="一般医师" >一般医师</option>
- <option value="副主任医师" >副主任医师</option>
- </select>
- 科室:<input type="text" name="dep">
- <input type="submit" value="查询">
- <input type="button" value="登记" onclick="add()">
- </form>
- <table style="margin-bottom: 30px;" width="100%" border="1px" cellpadding="11" cellspacing="0">
- <tr>
- <th>编号</th>
- <th>姓名</th>
- <th>性别</th>
- <th>年齿</th>
- <th>德律风</th>
- <th>科室</th>
- <th>医师种别</th>
- <th>价钱</th>
- <th>登记工夫</th>
- <th>形态</th>
- <th>操纵</th>
- </tr>
- <c:forEach var="list" items="${selctAll }">
- <tr>
- <td>${list.id }</td>
- <td>${list.name }</td>
- <td>${list.sex }</td>
- <td>${list.age }</td>
- <td>${list.phone }</td>
- <td>${list.department }</td>
- <td>${list.type }</td>
- <td>${list.price }</td>
- <td><fmt:formatDate value="${list.registerTime }" pattern="yyyy-MM-dd"/></td>
- <td>
- <c:if test="${list.state==0}">
- 已救治
- </c:if>
- <c:if test="${list.state==1}">
- 已救治
- </c:if>
- </td>
- <td>
- <c:if test="${list.state==0}">
- <a href="javascript:if(confirm('的确要核销该登记疑息吗?'))location='upd.do?id=${list.id }'">核销</a>
- </c:if>
- <%-- <c:if test="${list.state==1}">
- 已救治
- </c:if> --%>
- </td>
- </tr>
- </c:forEach>
- </table>
- </div>
- <script type="text/javascript">
- function add() {
- location.href="adds.do";
- }
- </script>
- </body>
- </html>
复造代码 index.jsp
- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
- %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>XXX体系</title>
- </head>
- <body>
- <script>
- window.location.href="<%=basePath%>/select.do";
- </script>
- </body>
- </html>
复造代码 免责声明:假如进犯了您的权益,请联络站少,我们会实时删除侵权内乱容,感谢协作! |
1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,按照目前互联网开放的原则,我们将在不通知作者的情况下,转载文章;如果原文明确注明“禁止转载”,我们一定不会转载。如果我们转载的文章不符合作者的版权声明或者作者不想让我们转载您的文章的话,请您发送邮箱:Cdnjson@163.com提供相关证明,我们将积极配合您!
2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并自负版权等法律责任。
|