配置文件resultMap |
mybatits,配置文件resultmap,mapper,resultmap |
|
<resultMap id="RepliesMap" type="com.gcj.entity.ArtificialInquiryReply">
<id column="airId" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP" />
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP" />
<result column="note" property="note" jdbcType="VARCHAR" />
<result column="inquiry_user_id" property="inquiryUserId" jdbcType="BIGINT" />
<result column="answer_time" property="answerTime" jdbcType="TIMESTAMP" />
<result column="materials_type" property="materialsType" jdbcType="VARCHAR" />
<!-- 关联 -->
<association property="bill" javaType="com.gcj.entity.ArtificialInquiryBill" resultMap="BillsMap" />
</resultMap>
|
set与if标签嵌套 |
mybatits,set与if标签嵌套,mapper,set,if |
|
<update id="updateQuotedPrices" parameterType="com.gcj.entity.ArtificialInquiryQuotedPrices">
update artificial_inquiry_quoted_prices
<set>
<if test="companyId != null and companyId != ''">
company_id=#{companyId,jdbcType=INTEGER},
</if>
<if test="price != null and price != ''">
price=#{price,jdbcType=DOUBLE},
</if>
<if test="remarks != null and remarks != ''">
remarks=#{remarks,jdbcType=DOUBLE},
</if>
<if test="discount != null and discount != ''">
discount=#{discount,jdbcType=DOUBLE},
</if>
<if test="status != null and status != ''">
status=#{status,jdbcType=VARCHAR},
</if>
<if test="reply != null and reply != ''">
artificial_inquiry_reply_id=#{reply.id,jdbcType=VARCHAR},
</if>
<if test="createdAt != null and createdAt != ''">
created_at=#{createdAt,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null and updatedAt != ''">
updated_at=#{updatedAt,jdbcType=VARCHAR},
</if>
<if test="TrackTime != null and TrackTime != ''">
inquiry_track_time=#{TrackTime,jdbcType=VARCHAR},
</if>
<if test="content != null and content != ''">
content=#{content,jdbcType=VARCHAR},
</if>
<if test="userId != null and userId != ''">
user_id=#{userId,jdbcType=VARCHAR},
</if>
<if test="bill != null and bill != ''">
artificial_inquiry_bill_id=#{bill.id,jdbcType=VARCHAR},
</if>
<if test="materialsRemark != null and materialsRemark != ''">
materials_remark=#{materialsRemark,jdbcType=VARCHAR},
</if>
</set>
where id=#{id}
</update>
|
批量查询 |
mybatits,批量查询,mapper |
|
<select id="getRepliesBatch" resultMap="RepliesMap">
select aib.id as aidId,aib.bill_number,
air.id as airId,air.material_name,air.specification,air.amount,air.unit,air.other_note,air.brand
from artificial_inquiry_replies air, artificial_inquiry_bills aib
where air.artificial_inquiry_bill_id = aib.id and air.user_id = 1 and
air.status = 'DISPOSE' and air.id in
<foreach collection="list" item="id" index="index" open="("
close=")" separator=",">
#{id}
</foreach>
order by air.answer_time asc
</select>
|
批量增加 |
mybatits, 批量增加, mapper |
|
<insert id="addReplies" parameterType="list">
insert into
artificial_inquiry_replies(material_name,specification,amount,unit,artificial_inquiry_bill_id,user_id,status,created_at,updated_at,
note,inquiry_user_id,no_pass_reason,other_note,is_front,brand,answer_time,materials_type)
values
<foreach collection="list" item="reply" index="index" separator=",">
(
#{reply.materialName},#{reply.specification},#{reply.amount},
#{reply.unit},#{reply.bill.id},#{reply.userId},#{reply.status},
#{reply.createdAt},#{reply.updatedAt},#{reply.note},#{reply.inquiryUserId},
#{reply.noPassReason},#{reply.otherNote},#{reply.front},#{reply.brand},
#{reply.answerTime},#{reply.materialsType}
)
</foreach>
</insert>
|
批量删除 |
mybatits,批量删除,mapper |
|
<delete id="deleteRepliesBatch" parameterType="list">
delete from artificial_inquiry_replies where id in
<foreach collection="list" item="item" index="index" open="("
close=")" separator=",">
#{item}
</foreach>
</delete>
|
再for循环中使用Ajax |
ajax,for循环,for循环中使用ajax |
|
<script type="text/javascript">
$(function() {
//获取task的id长度
var len = $(".isTaskId").length;
//获取task的id集合
var $isTaskId = $(".isTaskId");
//循环遍历所有的taskId
for (var i = 0; i < len; i++) {
//发送ajax请求的url
var url = "teaAssess-saveValid";
//发送ajax请求的参数群
var params = {
"validStuId" : $("#stuId").val(),
"validTermId" : $("#termId").val(),
"validTaskId" : $isTaskId[i].value
};
/*
每隔一秒运行一次ajax
setInterval(callback, delay);
callback:回调函数,这儿是调用的ajax请求函数,
delay:延时长度(单位:毫秒),这儿设置每隔2秒请求一次ajax
*/
setInterval(ajax(url, params, i), 2000);
}
});
//ajax请求函数
function ajax(url, params, i) {
$.post(url, params, function(data) {
if (data == "isNotNull") {
$("#task" + i).remove();
//如果课题中没有可选项(全部被考核过了),追加一条,提示无数据
if ($(".dropdown-menu").children("li").length == 0) {
$(".dropdown-menu").append("<li>您已经对所有课程进行了考核!</li>");
}
}
});
}
</script>
|
Ajax批量删除 |
ajax,批量删除,checkbox,全选 |
|
//批量删除
$("#deleteUserBatch").click(function() {
var str = "";
$("input[name='idList']").each(function() {
if ($(this).attr("checked")) {
str += $(this).val();
}
});
if (str.trim(" ") == "") {
alert("尚未选择任何内容!");
return false;
} else if (confirm("确定批量删除[" + str + "]的信息?")) {
var url = "deleteUserBatch.do";
var params = $("#form1").serialize();
$.post(url, params, function(data) {
alert("data=" + data);
window.location.reload();
}, "html");
} else {
return false;
}
});
|