SSM框架crud(增删改查模糊查询加分页)之查询修改(二)
程序员文章站
2024-01-15 23:52:04
...
上一期主要时添加删除也没什么亮点,这期看看这个查询如何利用集合从后台查的数据,修改如何和bootstrap-validate验证文本狂不能为空,也可以正则验证。
第一:查询
先贴图吧
这个列表主要是通过foreach循环出来的非常简单,再这个页面先得写个标签<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 再根据c标签查询
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
药品管理
</title>
<script src="/resources/scripts/common/jquery.js">
</script>
<script src="/resources/scripts/common/layer/layer.js">
</script>
<script src="/resources/scripts/base/jquery.form.js">
</script>
<script src="/resources/scripts/common/bootstrap.js">
</script>
<script src="/resources/scripts/common/jquery.nanoscroller.min.js">
</script>
<script src="/resources/scripts/common/select2.min.js">
</script>
<script src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js">
</script>
<link href="/resources/css/common.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="/resources/css/compiled/layout.css">
<link href="/resources/css/bootstrap/bootstrap.min.css" rel="stylesheet"
/>
<link href="/resources/css/libs/font-awesome.min.css" type="text/css"
rel="stylesheet" />
<link rel="stylesheet" href="/resources/css/libs/nanoscroller.css" type="text/css"
/>
<link href="https://cdn.bootcss.com/bootstrap-validator/0.5.3/css/bootstrapValidator.min.css"
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/resources/css/compiled/layout.css">
<link rel="stylesheet" type="text/css" href="/resources/css/compiled/elements.css">
<link rel="stylesheet" href="/resources/css/libs/select2.css" type="text/css"
/>
<link rel="stylesheet" href="/resources/scripts/common/layer/layer.css"
type="text/css" />
<script type="text/javascript">
$(function() {
$('#ha_level').select2();
$('#drugs_type').select2();
</script>
</head>
<body style="background:#E8EBEE;overflow-x:hidden;">
<div class="row pt20 pb20">
<div class="col-lg-12">
<ol class="breadcrumb">
<li>
<a href="#">
药品管理
</a>
</li>
<li class="active">
<span>
药品列表
</span>
</li>
</ol>
</div>
</div>
<!--------------------------导航 end------------------------------->
<div class="row pl15 pr15">
<div class="col-lg-12">
<div class="main-box">
<div class="main-box-body clearfix">
<form class="mt10 mb15" role="form">
<div class="col-md-3">
<div class="form-group pl10">
<label>
危险级别
</label>
<select class="pt10" style="width: 200px" id="ha_level" name="ha_level"
value="${map.ha_level }">
<option value="">
全部
</option>
<option value="0">
A
</option>
<option value="1">
B
</option>
<option value="2">
C
</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group pl10">
<label>
药品种类
</label>
<select class="pt10" style="width: 200px" id="drugs_type" name="drugs_type"
value="${map.drugs_type }">
<option value="">
全部
</option>
<option value="0">
静脉用和口服化疗药
</option>
<option value="1">
抗血栓药物
</option>
<option value="2">
硬膜外或鞘内注射药
</option>
<option value="3">
口服降糖药
</option>
<option value="4">
静脉用改变心肌力药
</option>
<option value="5">
静脉用中度镇静药物
</option>
<option value="6">
神经肌肉阻断药
</option>
<option value="7">
静脉用造影剂
</option>
<option value="8">
肠外
</option>
<option value="9">
营养
</option>
<option value="10">
特殊高危药品
</option>
</select>
</div>
</div>
<div class="col-md-3" style="margin-top:-5px;">
<div class="form-group pl10">
<div class="width100 txtc fl mb15">
<input type="button" value="搜索" class="btn btn-primary mt15" style="width: 120px"
οnclick="search()">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!--------------------------列表 start----------------------------->
<div class="row pl15 pr15">
<div class="col-lg-12">
<div class="main-box clearfix">
<div class="tabs-wrapper">
<div class="tab-content">
<div class="tab-pane fade active in" id="tab-a">
<div class="row pl15 pr15">
<div class="col-lg-12">
<div class="main-box clearfix">
<div class="main-box-body clearfix">
<div class="table-responsive clearfix">
<table class="table table-hover">
<thead>
<tr>
<th>
<div>
<input type="checkbox" id="qx" style="width:16px; height:16px; border:1px solid: #aaa; background:#FFF;">
</div>
</th>
<th style="width:10%;">
药品编码
</th>
<th>
药品名称
</th>
<th>
生产批号
</th>
<th style="width:100px;">
生产厂家
</th>
<th>
危险级别
</th>
<th>
包装
</th>
<th>
药品种类
</th>
<th>
剂型
</th>
<th>
最大剂量(mg)
</th>
<th class="text-center">
操作
</th>
</tr>
</thead>
<tbody>
<c:forEach items="${dList }" var="product">
<tr>
<td>
<div>
<input type="checkbox" id="${product.drugs_id }" class="ids" value="${product.drugs_id }"
name="test" style="width:16px; height:16px; border:1px solid: #aaa; background:#FFF;">
</div>
</td>
<td>
${product.drugs_id }
</td>
<td>
<c:if test="${product.is_risk==1 }">
<span style="color:red;">
${product.drugs_name }
<span/>
</c:if>
<c:if test="${product.is_risk==0 }">
${product.drugs_name }
</c:if>
</td>
<td>
${product.pro_num }
</td>
<td>
${product.factory }
</td>
<td class="text-center">
<c:if test="${product.ha_level==0 }">
A
</c:if>
<c:if test="${product.ha_level==1 }">
B
</c:if>
<c:if test="${product.ha_level==2 }">
C
</c:if>
</td>
<td>
${product.pack }
</td>
<td>
<c:if test="${product.drugs_type==0 }">
静脉用和口服化疗药
</c:if>
<c:if test="${product.drugs_type==1 }">
抗血栓药物
</c:if>
<c:if test="${product.drugs_type==2 }">
硬膜外或鞘内注射药
</c:if>
<c:if test="${product.drugs_type==3 }">
口服降糖药
</c:if>
<c:if test="${product.drugs_type==4 }">
静脉用改变心肌力药
</c:if>
<c:if test="${product.drugs_type==5 }">
静脉用中度镇静药物
< </c:if>
<c:if test="${product.drugs_type==6 }">
神经肌肉阻断药
</c:if>
<c:if test="${product.drugs_type==7 }">
静脉用造影剂
</c:if>
<c:if test="${product.drugs_type==8 }">
肠外
</c:if>
<c:if test="${product.drugs_type==9 }">
营养
</c:if>
<c:if test="${product.drugs_type==10 }">
特殊高危药品
</c:if>
</td>
<td>
${product.ji_xi }
</td>
<td>
${product.max_dose }
</td>
<td class="text-center">
<a class="color6" href="#" οnclick="productDelete('${product.drugs_id }')">
<i class="icon-file-alt">
</i>
删除
</a>
<a class="color6" href="#" οnclick="productUpdate('${product.drugs_id }')">
<i class="icon-file-alt">
</i>
修改
</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--------------------------列表 end------------------------------->
</body>
</html>
2.后台控制层 DrugContorller
/**
* 药品查询
* @param request
* @param cpage
* @return
*/
@RequestMapping(value="queryDrugPage",method=RequestMethod.GET)
public String queryDrugPage(HttpServletRequest request){
return drugService.queryDrugPage(request);
}
3.接口类DrugService
String queryDrugPage(HttpServletRequest request)
4.业务逻辑层DrugServiceImpl
@Override
public String queryDrugPage(HttpServletRequest reques) {
List<Drug> dList = mapper.queryDrugPageList();
request.setAttribute("dList", dList);
return "drug/drugList";
}
5.连接mybatis接口层IDrugMapper
List<Drug> queryDrugPageList()
6.mybatis配置文件IDurgMapper.xml,写sql
<select id="queryDrugPageList" resultType="com.wandu.webmanagement.data.entity.drug.Drug">
SELECT d.* FROM drugs_info d
</select>
第二:修改,红框中就是bootstrap-voladate得效果
2.看看js,form表单内容
<script src="/resources/scripts/common/jquery.js">
</script>
<script src="/resources/scripts/common/layer/layer.js">
</script>
<script src="/resources/scripts/base/jquery.form.js">
</script>
<script src="/resources/scripts/common/bootstrap.js">
</script>
<script src="/resources/scripts/common/jquery.nanoscroller.min.js">
</script>
<script src="/resources/scripts/common/select2.min.js">
</script>
<script src="/resources/scripts/common/My97DatePicker/WdatePicker.js">
</script>
<script src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js">
</script>
<!-- 图片上传预览-结束 -->
<link href="/resources/css/common.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="/resources/css/compiled/layout.css">
<link href="/resources/css/bootstrap/bootstrap.min.css" rel="stylesheet"
/>
<link href="/resources/css/libs/font-awesome.min.css" type="text/css"
rel="stylesheet" />
<link rel="stylesheet" href="/resources/css/libs/nanoscroller.css" type="text/css"
/>
<link href="https://cdn.bootcss.com/bootstrap-validator/0.5.3/css/bootstrapValidator.min.css"
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/resources/css/compiled/layout.css">
<link rel="stylesheet" type="text/css" href="/resources/css/compiled/elements.css">
<link rel="stylesheet" href="/resources/css/libs/select2.css" type="text/css"
/>
<link rel="stylesheet" href="/resources/scripts/common/layer/layer.css"
type="text/css" />
<script type="text/javascript">
$(function() {
$('#producctForm').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
/*指定需要校验的元素 通过name数据去指定*/
drugs_id: {
/*配置校验规则 规则不止一个*/
validators: {
/*配置具体的规则*/
notEmpty: {
/*校验不成功的提示信息*/
message: '药品编码不能为空!!!'
}
}
},
drugs_name: {
validators: {
notEmpty: {
message: '商品名称不能为空!!!'
}
}
},
pro_num: {
validators: {
notEmpty: {
message: '生产批号不能为空!!!'
}
}
},
factory: {
validators: {
notEmpty: {
message: '生产厂家不能为空!!!'
}
}
},
gui_ge: {
validators: {
notEmpty: {
message: '规格不能为空!!!'
}
}
},
pack: {
validators: {
notEmpty: {
message: '包装不能为空!!!'
}
}
},
unit: {
validators: {
notEmpty: {
message: '单位不能为空!!!'
}
}
},
ji_xi: {
validators: {
notEmpty: {
message: '剂型不能为空!!!'
}
}
},
method: {
validators: {
notEmpty: {
message: '用药途径不能为空!!!'
}
}
},
max_dose: {
validators: {
notEmpty: {
message: '最大剂量不能为空!!!'
}
}
},
}
})
});
var id = "${param.id}";
$.ajax({
url: "/user/system/selectDrug",
dataType: "text",
type: "post",
cache: false,
data: {
id: id
},
success: function(json) {
var obj = JSON.parse(json) $("#drugs_id").val(obj.drugs_id);
$("#drugs_name").val(obj.drugs_name);
$("#pro_num").val(obj.pro_num);
$("#factory").val(obj.factory);
$("#gui_ge").val(obj.gui_ge);
$("#pack").val(obj.pack);
$("#unit").val(obj.unit);
$("#ji_xi").val(obj.ji_xi);
$("#method").val(obj.method);
$("#max_dose").val(obj.max_dose);
$("#pro_date").val(obj.pro_date);
$("#val_date").val(obj.val_date);
$("#who_price").val(obj.who_price);
$("#price").val(obj.price);
$("#med_insu").val(obj.med_insu);
$("#is_risk").val(obj.is_risk);
$("#ha_level").val(obj.ha_level);
$("#drugs_type").val(obj.inventory);
$("#inventory").val(obj.inventory);
$("#max_inv").val(obj.max_inv);
$("#least_inv").val(obj.least_inv);
// $("[name='input'][value=" + obj.input + "]").prop("checked", true);
}
})
$(function() {
$('#drugs_type').select2();
$('#ha_level').select2();
$('#is_risk').select2();
$('#med_insu').select2();
$('#input').select2();
//提交商品信息即商品详情图片
$("#upLoadProudct").click(function() {
var drugs_id = $("#drugs_id").val();
var drugs_name = $("#drugs_name").val();
var pro_num = $("#pro_num").val();
var factory = $("#factory").val();
var gui_ge = $("#gui_ge").val();
var pack = $("#pack").val();
var unit = $("#unit").val();
var ji_xi = $("#ji_xi").val();
var method = $("#method").val();
var max_dose = $("#max_dose").val();
var pro_date = $("#pro_date").val();
var val_date = $("#val_date").val();
var input = $("#input").val();
var who_price = $("#who_price").val();
var price = $("#price").val();
var med_insu = $("#med_insu").val();
var is_risk = $("#is_risk").val();
var ha_level = $("#ha_level").val();
var drugs_type = $("#drugs_type").val();
var inventory = $("#inventory").val();
var max_inv = $("#max_inv").val();
var least_inv = $("#least_inv").val();
$.ajax({
url: "/user/system/updateDrug",
dataType: "text",
type: "post",
cache: false,
data: {
drugs_id: drugs_id,
drugs_name: drugs_name,
pro_num: pro_num,
factory: factory,
gui_ge: gui_ge,
pack: pack,
unit: unit,
ji_xi: ji_xi,
method: method,
max_dose: max_dose,
pro_date: pro_date,
val_date: val_date,
input: input,
who_price: who_price,
price: price,
med_insu: med_insu,
is_risk: is_risk,
ha_level: ha_level,
drugs_type: drugs_type,
inventory: inventory,
max_inv: max_inv,
least_inv: least_inv
},
success: function(obj) {
if (obj == "success") {
layer.alert('商品修改成功!',
function(index) {
window.location.reload();
});
} else {
layer.alert("商品修改失败,请重新发布")
}
},
error: function(obj) {
layer.alert("网络出现异常,请稍后重新发布!!!!")
}
});
});
});
</script>
<body style="background: #E8EBEE;overflow-x:hidden;">
<div class="row pt20 pb20">
<div class="col-lg-12">
<ol class="breadcrumb">
<li>
<a href="#">
药品管理
</a>
</li>
<li class="active">
<span>
修改药品
</span>
</li>
</ol>
</div>
</div>
<!--------------------------详细信息 start-------------------------->
<div class="row pl15 pr15">
<div class="col-lg-12">
<div class="main-box">
<div class="main-box-body clearfix">
<form class="form-horizontal mt20" id="producctForm">
<table>
<tr>
<td>
<div class="label_css pt8 pr5 fl">
<label>
药品编码
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="drugs_id"
name="drugs_id" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
商品名称
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="drugs_name"
name="drugs_name" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
生产批号
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="pro_num"
name="pro_num" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
生产厂家
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="factory"
name="factory" />
</div>
</div>
</td>
</tr>
<tr style="height:80px;">
<td>
<div class="label_css pt8 pr5 fl">
<label>
规格
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="gui_ge" name="gui_ge"
/>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
包装
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="pack" name="pack"
/>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
单位
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="unit" name="unit"
/>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
剂型
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="ji_xi" name="ji_xi"
/>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
用药途径
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="method" name="method"
/>
</div>
</div>
</td>
</tr>
<tr style="height:50px;">
<td>
<div class="label_css pt8 pr5 fl">
<label>
最大剂量
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="max_dose"
name="max_dose" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
生产日期
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="pro_date"
name="pro_date" οnclick="WdatePicker()" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
有效期
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="val_date"
name="val_date" οnclick="WdatePicker()" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
是否进口
</label>
</div>
</td>
<td>
<div class="col-md-10">
<select class="fl" style="width:150px" id="input" name="input" placeholder="必填">
<option value="0">
是
</option>
<option value="1">
否
</option>
</select>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
批发价
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="who_price"
name="who_price" />
</div>
</div>
</td>
</tr>
<tr style="height:50px;">
<td>
<div class="label_css pt8 pr5 fl">
<label>
售价
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="price" name="price"
/>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
是否医保
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<select class="fl" style="width:150px" placeholder="必填" id="med_insu"
name="med_insu">
<option value="0">
是
</option>
<option value="1">
否
</option>
</select>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
是否高危
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<select class="fl" style="width:150px" placeholder="必填" id="is_risk" name="is_risk">
<option value="0">
是
</option>
<option value="1">
否
</option>
</select>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
危险级别
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<select class="fl" style="width:150px" placeholder="必填" id="ha_level"
name="ha_level">
<option value="0">
A
</option>
<option value="1">
B
</option>
<option value="2">
C
</option>
</select>
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
药品种类
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<select class="pt10" style="width: 150px" id="drugs_type" name="drugs_type">
<option value="">
全部
</option>
<option value="0">
静脉用和口服化疗药
</option>
<option value="1">
抗血栓药物
</option>
<option value="2">
硬膜外或鞘内注射药
</option>
<option value="3">
口服降糖药
</option>
<option value="4">
静脉用改变心肌力药
</option>
<option value="5">
静脉用中度镇静药物
</option>
<option value="6">
神经肌肉阻断药
</option>
<option value="7">
静脉用造影剂
</option>
<option value="8">
肠外
</option>
<option value="9">
营养
</option>
<option value="10">
特殊高危药品
</option>
</select>
</div>
</div>
</td>
</tr>
<tr style="height:50px;">
<td>
<div class="label_css pt8 pr5 fl">
<label>
库存
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="inventory"
name="inventory" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
高储标准
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="max_inv"
name="max_inv" />
</div>
</div>
</td>
<td>
<div class="label_css pt8 pr5 fl">
<label>
低储标准
</label>
</div>
</td>
<td>
<div class="col-md-10">
<div class="width100">
<input type="text" class="form-control" placeholder="必填" id="least_inv"
name="least_inv" />
</div>
</div>
</td>
</table>
<div class="form-group">
<div class="col-md-12 text-center" style="margin-top:20px;">
<input type="button" class="btn btn-primary" style="width: 120px" id="upLoadProudct"
value="立即修改" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
3.后台控制层 和添加差不多
首先是内容回显
/**
* 修改回显
* @param request
* @param cpage
* @return
*/
@RequestMapping(value="selectDrug",method=RequestMethod.POST)
@ResponseBody
public Drug selectDrug(String id,Model model){
return drugService.selectDrug(id,model);
}
其次修改提交
/**
* 修改药品
* @param request
* @param cpage
* @return
*/
@RequestMapping(value="updateDrug",method=RequestMethod.POST)
@ResponseBody
public String updateDrug(String drugs_id,String drugs_name,String pro_num,String factory,String gui_ge,String pack,String unit,String ji_xi,String method,
String max_dose,String pro_date,String input,String who_price,String price,String val_date,
String med_insu,String is_risk,String ha_level,String drugs_type,String inventory,String max_inv,String least_inv){
Map<String,Object> map = new HashMap<String,Object>();
map.put("drugs_id", drugs_id);map.put("drugs_name", drugs_name); map.put("pro_num",pro_num);map.put("factory", factory);
map.put("gui_ge", gui_ge);map.put("pack", pack); map.put("unit", unit);map.put("ji_xi", ji_xi);
map.put("method", method);map.put("max_dose", max_dose); map.put("pro_date", pro_date);map.put("input", input);
map.put("who_price", who_price);map.put("price", price); map.put("med_insu", med_insu);map.put("is_risk", is_risk);
map.put("ha_level", ha_level);map.put("drugs_type", drugs_type); map.put("inventory", inventory);map.put("max_inv", max_inv);
map.put("least_inv", least_inv); map.put("val_date", val_date);
return drugService.updateDrug(map);
}
4.接口
Drug selectDrug(String id, Model model);
String updateDrug(Map<String, Object> map);
5.业务逻辑层
@Override
public Drug selectDrug(String id, Model model) {
Drug drug = mapper.selectDrug(id);
return drug;
}
@Override
public String updateDrug(Map<String, Object> map) {
try {
boolean status = mapper.updateDrug(map);
if (status== true) {
return "success";
}
} catch (Exception e) {
e.printStackTrace();
}
return "fail";
}
6.映射xml接口层
Drug selectDrug(String id);
boolean updateDrug(Map<String, Object> map);
7.xml
<select id="selectDrug" resultType="com.wandu.webmanagement.data.entity.drug.Drug" parameterType="string">
SELECT * FROM drugs_info c where c.drugs_id=#{id}
</select>
<!--修改药品-->
<update id="updateDrug" parameterType="com.wandu.webmanagement.data.entity.drug.Drug" >
update drugs_info set drugs_id =#{drugs_id},drugs_name =
#{drugs_name},pro_num=#{pro_num},factory=#{factory},gui_ge=#{gui_ge},pack=#{pack},
unit=#{unit},ji_xi=#{ji_xi},method=#{method},
max_dose=#{max_dose},pro_date=#{pro_date},val_date=#{val_date},input=#{input},
who_price=#{who_price},price=#{price},med_insu=#{med_insu},is_risk=#{is_risk},
ha_level=#{ha_level},drugs_type=#{drugs_type},inventory=#{inventory},max_inv=#{max_inv},
least_inv=#{least_inv} where drugs_id = #{drugs_id }
</update>
crud 到此为止