首页 > 代码库 > 添加商品验证商品是否存在的两种实现方式

添加商品验证商品是否存在的两种实现方式

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:set var="ctx" value="${pageContext.request.contextPath}" /><jsp:include page="/jsp/common/header.jsp"></jsp:include><script src="${ctx }/js/hwg/saleLimit/hwgSaleLimit.js"></script><jsp:include page="/jsp/common/common_upload.jsp"></jsp:include><table class="queryTable">    <tr>        <td class="queryTitle" width="80px">商品名称</td>        <td class="queryContent" ><input class="inputText" type="text" id="goodsName" /></td>        <td class="queryTitle" width="80px">商品编码</td>        <td class="queryContent" ><input class="inputText" type="text" id="goodsNo" /></td>        <td class="queryTitle" width="80px">适应端</td>        <td class="queryContent" >            <select name="applyType"   id="applyType"  class="easyui-combobox" style="width: 80px" panelHeight="auto" editable="false">                <option value="" selected>请选择</option>                <option value="PC">PC</option>                <option value="WAP">WAP</option>                <option value="APP">APP</option>            </select>        </td>        <td class="queryTitle" width="80px">开始时间</td>        <td class="queryContent" ><input class="easyui-datetimebox"  type="text" id="beginTime" /></td>        <td class="queryTitle" width="80px">结束时间</td>        <td class="queryContent" ><input class="easyui-datetimebox"  type="text" id="endTime" /></td>        <td class="queryBtnTd">            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search"  onclick="doQuery()">查询</a>        </td>    </tr></table><table id="deliveryGrid"></table><div id="opreateHtml" class="easyui-window" title="" iconCls="icon-edit" style="width:320px; height:450px;text-align:center; background: #fafafa;margin:0 auto;">    <div class="easyui-layout" fit="true">        <div region="center" border="false" style="background:#fff;border:1px solid #ccc;">            <form>                <input type="hidden" id="idHidden" name="idHidden" value="" />                <table class="queryTable"  width="100%">                    <tr>                        <td class="queryTitle" width="100">商品编码</td>                        <td class="queryContent" ><input class="inputText" type="text" id="addGoodsNo" /><font color="red">添加时支持上传多个,并且用 | 分隔</font></td>                    </tr>                    <tr>                        <td class="queryTitle" width="100">开始时间</td>                        <td class="queryContent" ><input class="inputText" type="text" readonly="readonly" id="addBeginTime" />                        </td>                    </tr>                    <tr>                        <td class="queryTitle" width="100">结束时间</td>                        <td class="queryContent" ><input class="inputText" type="text" readonly="readonly" id="addEndTime" />                        </td>                    </tr>                    <tr>                        <td class="queryTitle" width="100">适应端</td>                        <td class="queryContent" >                            <select name="addApplyType" id="addApplyType"  class="easyui-combobox" style="width: 80px" panelHeight="auto" editable="false">                                <option value="" selected>请选择</option>                                <option value="PC">PC</option>                                <option value="WAP">WAP</option>                                <option value="APP">APP</option>                            </select>                        </td>                    </tr>                    <tr>                        <td class="queryTitle" width="100">排序</td>                        <td class="queryContent" ><input class="inputText" type="text" id="addOrderType" maxlength="8" /></td>                    </tr>                </table>            </form>        </div>        <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;">            <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="addOrUpdate();">保存</a>&nbsp;&nbsp;            <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="closeWin();">退出</a>        </div>    </div></div>
$(function(){    $(‘#addEndTime‘).datetimebox({        showSeconds:false,        editable:false    });    $(‘#addBeginTime‘).datetimebox({        showSeconds:false,        editable:false    });    $("#opreateHtml").window("close");    $("#deliveryGrid").datagrid({        url:appPath+"/page/hwgSaleLimit/getPage",        height:"full",        striped:true,        remoteSort:false,        pagination:true,        pageSize : 100,        pageList : [ 10, 20, 30, 40, 50, 100 ],        rownumbers:true,        singleSelect:false,        queryParams:getQueryParam(),        frozenColumns:[[{field:"limitId",checkbox:true},            {field:"opt",title:"操作",width:60,align:"center",                formatter:function(value,rowData,rowIndex){                    var dataStr = JSON.stringify(rowData);                    var html="<img class=‘op-enable‘ src=http://www.mamicode.com/‘"+appPath+"/js/lib/jquery-easyui/themes/icons/pencil.png‘ onClick=‘showWin("+rowData.limitId+")‘ title=‘编辑‘/>&nbsp;&nbsp;";                    html+="<img class=‘op-enable‘ src=http://www.mamicode.com/‘"+appPath+"/js/lib/jquery-easyui/themes/icons/cancel.png‘ onClick=‘cancel("+rowData.limitId+")‘ title=‘删除‘/>";                    return html;                }            }        ]],        columns:[[            {field:‘goodsName‘,title:‘商品名称‘,width:300,align:‘center‘,sortable:true},            {field:‘goodsNo‘,title:‘商品编码‘,width:150,align:‘center‘,sortable:true},            {field:‘beginTime‘,title:‘开始时间‘,width:150,align:‘center‘,sortable:true},            {field:‘endTime‘,title:‘结束时间‘,width:150,align:‘center‘,sortable:true},            {field:‘applyType‘,title:‘适应端‘,width:150,align:‘center‘,sortable:true},            {field:‘orderType‘,title:‘排序‘,width:150,align:‘center‘,sortable:true}        ]],        toolbar:[            {                id:‘btnAdd‘,                text:‘添加记录‘,                iconCls:‘icon-add‘,                handler:function(){                    showWin(null);                }            },"-",            {                id:‘btnPass‘,                text:‘批量删除‘,                iconCls:‘icon-cancel‘,                handler:function(){                    deletes(null);                }            }        ]    });});function getQueryParam(){    var info =new Object();    info.goodsName=$.trim($("#goodsName").val());    info.goodsNo=$.trim($("#goodsNo").val());    info.beginTime=$.trim($("#beginTime").datetimebox(‘getValue‘));    info.endTime=$.trim($("#endTime").datetimebox(‘getValue‘));    info.applyType=$.trim($("#applyType").combobox(‘getValue‘));    return info;}function doQuery(){    $("#deliveryGrid").datagrid(‘load‘,getQueryParam());}function cancel(limitId){    var info = new Object();    info.ids = limitId;    $.messager.defaults = { ok: "确定", cancel: "取消" };    $.messager.confirm(‘提示信息‘,‘您确定要删除?‘,function(r){        if(r){            doAjax({                url : appPath + ‘/page/hwgSaleLimit/deleteIdsLogic‘,                type : ‘post‘,                data : info,                success : function(data) {                    if (data =http://www.mamicode.com/="ok") {                        $.messager.alert(‘提示‘, "删除成功", ‘info‘);                        doQuery();                    } else {                        $.messager.alert(‘提示‘, data, ‘info‘);                    }                },                error : function(XMLHttpRequest, textStatus, errorThrown) {                    $.messager.alert(‘提示信息‘, ‘操作未能完成‘ + textStatus, ‘error‘);                }            });        }    });}function deletes(){    var selections = $("#deliveryGrid").datagrid(‘getSelections‘);    if(selections == null || selections == ‘‘){        $.messager.alert(‘提示信息‘,‘请选操作的记录‘,‘‘);        return;}    else{        var ids = ‘‘;        for(var i=0;i<selections.length;i++){            ids += selections[i].limitId+‘,‘;        }        var info = new Object();        info.ids = ids;        $.messager.confirm(‘提示信息‘,"您确定批量删除记录?",function(r){            if(r){                doAjax({                    url : appPath + ‘/page/hwgSaleLimit/deleteIdsLogic‘,                    type : ‘post‘,                    data : info,                    success : function(data) {                        if (data =http://www.mamicode.com/="ok") {                            $.messager.alert(‘提示‘, "批量删除成功", ‘info‘);                            doQuery();                        } else {                            $.messager.alert(‘提示‘, data, ‘info‘);                        }                    },                    error : function(XMLHttpRequest, textStatus, errorThrown) {                        $.messager.alert(‘提示信息‘, ‘操作未能完成‘ + textStatus, ‘error‘);                    }                });            }        });    }}function showWin(limitId){    $("#idHidden").val("");    $("#addGoodsNo").val("");    $("#addApplyType").combobox("setValue",‘‘);;    $("#addOrderType").val("");    $("#addBeginTime").datetimebox("setValue",‘‘);    $("#addEndTime").datetimebox("setValue",‘‘);    if (limitId == null || limitId == ‘‘) {        $(‘#opreateHtml‘).window({            title : ‘今日限时抢添加‘,            iconCls : ‘icon-add‘,            width : 500,            height : 250,            left : 200,            modal : true,            shadow : true,            collapsible : false,            minimizable : false,            maximizable : false        });        $(‘#opreateHtml‘).window(‘move‘, {            top : 50        });        $(‘#opreateHtml‘).window(‘open‘);    } else {        doAjax({            url : appPath + ‘/page/hwgSaleLimit/getBean/‘ + limitId,            type : ‘post‘,            dataType : "json",            success : function(data) {                $("#idHidden").val(data.limitId);                $("#addGoodsNo").val(data.goodsNo);                $("#addBeginTime").datetimebox("setValue", data.beginTime);                $("#addEndTime").datetimebox("setValue", data.endTime);                $("#addApplyType").combobox("setValue", data.applyType);                $("#addOrderType").val(data.orderType);                $(‘#opreateHtml‘).window({                    title : ‘今日限时抢修改‘,                    iconCls : ‘icon-edit‘,                    width : 500,                    height : 250,                    left : 200,                    modal : true,                    shadow : true,                    collapsible : false,                    minimizable : false,                    maximizable : false                });                $(‘#opreateHtml‘).window(‘move‘, {                    top : 50                });                $(‘#opreateHtml‘).window(‘open‘);            },            error : function(XMLHttpRequest, textStatus, errorThrown) {                $.messager.alert(‘提示信息‘, ‘抱歉,保存失败,‘ + textStatus, ‘error‘);            }        });    }}function closeWin(){    $(‘#opreateHtml‘).window(‘close‘);}function addOrUpdate() {    var info = new Object();    info.limitId = $("#idHidden").val();    info.goodsNo = $("#addGoodsNo").val();    info.endTime = $("#addEndTime").datetimebox("getValue");    info.beginTime = $("#addBeginTime").datetimebox("getValue");    info.applyType = $("#addApplyType").combobox("getValue");    info.orderType = $("#addOrderType").val();    if (info.goodsNo == null || info.goodsNo == ‘‘) {        $.messager.alert("提示信息", "商品编码不能为空!");        return;    }    if(info.beginTime == null || info.beginTime == ‘‘){        $.messager.alert("提示信息", "开始时间不能为空!");        return;    }    if(info.endTime == null || info.endTime == ‘‘){        $.messager.alert("提示信息", "结束时间不能为空!");        return;    }    if (info.beginTime > info.endTime) {        $.messager.alert(‘提示信息‘, ‘结束时间不能大于开始时间‘, ‘info‘);        return;    }    if(info.applyType == null || info.applyType == ‘‘){        $.messager.alert("提示信息", "适应端不能为空!");        return;    }    if(checkNumber(info.orderType)==false){        $.messager.alert(‘提示信息‘, ‘排序字段请填写数字‘, ‘info‘);        return;    }    doAjax({        url : appPath + ‘/page/hwgSaleLimit/saveOrUpdate‘,        type : ‘post‘,        data : info,        success : function(data) {            if (data =http://www.mamicode.com/="ok") {                $.messager.alert(‘提示‘, "保存成功", ‘info‘);                $(‘#opreateHtml‘).window(‘close‘);                doQuery();            } else {                $.messager.alert(‘提示‘, data, ‘info‘);            }        }    });}
package com.founder.ec.hwg.action;import com.founder.ec.base.action.BaseClassAction;import com.founder.ec.common.utils.StringUtil;import com.j1.base.dto.ServiceMessage;import com.j1.base.type.MsgStatus;import com.j1.hwg.model.HwgProductSaleLimit;import com.j1.soa.common.DateUtils;import com.j1.soa.resource.hwg.api.HwgProductSaleLimitService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.util.Date;import java.util.Map;/** * Created by zhangjun on 2017/4/5. */@Controller@RequestMapping(value = "/hwgSaleLimit")public class HwgSaleLimitAction extends BaseClassAction {    @Autowired    private HwgProductSaleLimitService productSaleLimitService;    /**     *@description 海外购热门评论分页查询(查询活动列表)     */    @RequestMapping(value="/getPage",method= RequestMethod.POST)    @ResponseBody    public Map<String,Object> getPage(HttpServletRequest request, HwgProductSaleLimit productSaleLimit)    {        int pageSize=10,pageNo=1;        if (null != request.getParameter("page")) {            pageNo = Integer.parseInt(request.getParameter("page"));        }        if (null != request.getParameter("rows")) {            pageSize = Integer.parseInt(request.getParameter("rows"));        }        Map<String, Object> resMap = productSaleLimitService.getInfo(productSaleLimit, pageNo, pageSize);        return resMap;    }    /**     *@description 海外购热门评论查询详细信息     */    @RequestMapping(value="/getBean/{getId}",method=RequestMethod.POST)    @ResponseBody    public HwgProductSaleLimit getDetail(HttpServletRequest request, @PathVariable Object getId)    {        HwgProductSaleLimit productSaleLimit = new HwgProductSaleLimit();        if(getId!=null && getId.toString().length()>0){            productSaleLimit = productSaleLimitService.getDetail(getId.toString());        }        return productSaleLimit;    }    /**     * 海外购热门评论的保存或者更新     * @param request     * @param productSaleLimit     * @return     */    @ResponseBody    @RequestMapping(value="/saveOrUpdate",method=RequestMethod.POST)    public String updateOrSave(HttpServletRequest request, HwgProductSaleLimit productSaleLimit)    {        try{            String userId =request.getSession().getAttribute("userId").toString();            String time = StringUtil.returnDateFormat(new Date(),"yyyy-MM-dd HH:mm:ss");            ServiceMessage<String> msg = null;            if(productSaleLimit.getLimitId() != null) {                productSaleLimit.setEditTime(time);                productSaleLimit.setEditUserId(Integer.parseInt(userId));                msg = productSaleLimitService.updateInfo(productSaleLimit);            } else {                productSaleLimit.setAddTime(time);                productSaleLimit.setAddUserId(new Integer(userId));                productSaleLimit.setIsDelete("N");                msg = productSaleLimitService.saveInfo(productSaleLimit);            }            if(msg != null){                if(!msg.getStatus().equals(MsgStatus.NORMAL)){                    logger.error(msg.getMessage());                    return msg.getMessage();                } else{                    return "ok";                }            }else{                logger.error("服务异常");                return "服务异常";            }        } catch (Exception e){            logger.error("服务异常");            return "服务异常";        }    }    /**     *海外购热门评论的删除     */    @RequestMapping(value="/deleteIdsLogic")    @ResponseBody    public String deleteIdsLogic(HttpServletRequest request,HttpServletResponse response)    {        try{            if (request.getParameter("ids") != null) {                Integer userId = Integer.parseInt(request.getSession().getAttribute("userId").toString());                String ids = request.getParameter("ids").trim();                String[] idArr = ids.split(",");                for (int i = 0; i < idArr.length; i++) {                    HwgProductSaleLimit productSaleLimit = new HwgProductSaleLimit();                    productSaleLimit.setLimitId(Long.parseLong(idArr[i]));                    productSaleLimit.setIsDelete("Y");                    productSaleLimit.setEditUserId(userId);                    productSaleLimit.setEditTime(DateUtils.getCurrentDateString());                    productSaleLimitService.deleteInfo(productSaleLimit);                }            }            return "ok";        }catch (Exception e){            logger.error("服务异常");            return "服务异常";        }    }}
package com.j1.soa.resource.hwg.service.oracle;import com.j1.base.dto.ServiceMessage;import com.j1.hwg.model.HwgProductSaleLimit;import com.j1.soa.common.service.BaseServiceImpl;import com.j1.soa.resource.hwg.api.HwgProductSaleLimitService;import com.j1.soa.resource.hwg.dao.oracle.HwgProductSaleLimitMapper;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.HashMap;import java.util.List;import java.util.Map;/** * Created by Administrator on 2017/4/5. */@Servicepublic class HwgProductSaleLimitServiceImpl extends BaseServiceImpl implements HwgProductSaleLimitService {    @Autowired    private HwgProductSaleLimitMapper productSaleLimitMapper;    @Override    public ServiceMessage<String> updateInfo(HwgProductSaleLimit productSaleLimit) throws Exception{        HwgProductSaleLimit product = productSaleLimitMapper.getProduct(productSaleLimit.getGoodsNo());        if(product == null){            return super.returnNoResult("商品不存在");        }        productSaleLimitMapper.update(productSaleLimit);        return super.returnCorrectResult("编辑成功");    }    @Override    public ServiceMessage<String> saveInfo(HwgProductSaleLimit productSaleLimit)  throws Exception{        String goodsNos = productSaleLimit.getGoodsNo();        String[] goodsNoArr = goodsNos.split(",");        for(int i = 0; i < goodsNoArr.length; i++ ){            HwgProductSaleLimit product = productSaleLimitMapper.getProduct(goodsNoArr[i].trim());            if(product == null){                return super.returnNoResult("商品编码" + goodsNoArr[i] + "不存在");            }        }        for(int i = 0; i < goodsNoArr.length; i++ ){            productSaleLimit.setGoodsNo(goodsNoArr[i]);            productSaleLimitMapper.save(productSaleLimit);        }        return super.returnCorrectResult("添加成功");    }    @Override    public Map<String, Object> getInfo(HwgProductSaleLimit productSaleLimit, int pageNo, int pageSize) {        productSaleLimit.setStartRow((pageNo - 1) * pageSize + 1);        productSaleLimit.setEndRow(productSaleLimit.getStartRow() + pageSize - 1);        List<HwgProductSaleLimit> result = productSaleLimitMapper.getInfoList(productSaleLimit);        int count = productSaleLimitMapper.getInfoCount();        Map<String,Object> resMap = new HashMap<String, Object>();        resMap.put("total", count);        resMap.put("rows",result);        return resMap;    }    @Override    public HwgProductSaleLimit getDetail(String id) {        HwgProductSaleLimit productSaleLimit = productSaleLimitMapper.getDetail(id);        return productSaleLimit;    }    @Override    public void deleteInfo(HwgProductSaleLimit productSaleLimit) {        productSaleLimitMapper.delete(productSaleLimit);    }}
package com.j1.soa.resource.hwg.dao.oracle;import com.j1.hwg.model.HwgProductSaleLimit;import com.j1.hwg.webmodel.AbroadLimitGoodsModel;import java.util.List;/** * Created by Administrator on 2017/4/5. */public interface HwgProductSaleLimitMapper {    int save(HwgProductSaleLimit productSaleLimit);    int update(HwgProductSaleLimit productSaleLimit);    List<HwgProductSaleLimit> getInfoList(HwgProductSaleLimit productSaleLimit);    int getInfoCount();    HwgProductSaleLimit getDetail(String id);    int delete(HwgProductSaleLimit productSaleLimit);    HwgProductSaleLimit getProduct(String productId);    /**     * 查询今日限购信息     * @Title: getAbroadLimitGoodsInfo      * @Description: 海外购-首页-今日限时抢     * @author pangxiejia@gmail.com     * @param applyType    适应端(PC/WAP)     * @return List<HwgProductSaleLimit>     */    public List<HwgProductSaleLimit> getAbroadLimitGoodsInfo(String applyType);    /**     * 查询今日限购所有商品     * @Title: getAbroadLimitGoodsList      * @Description: 海外购-首页-今日限时抢     * @author pangxiejia@gmail.com     * @param list    goodsNo List     * @return List<AbroadLimitGoodsModel>     */    public List<AbroadLimitGoodsModel> getAbroadLimitGoodsList(List<String> list);}
<?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.j1.soa.resource.hwg.dao.oracle.HwgProductSaleLimitMapper">    <!-- 用于分页查询的头部 -->    <sql id="be_fy">        select *        from (select row_.*, rownum rownum_        from (    </sql>    <!-- 用于分页的尾部 -->    <sql id="ed_fy">        ) row_        where 1=1        <if test="endRow != null">            <![CDATA[             and rownum <= #{endRow}             ]]>        </if>        )        where 1=1        <if test="startRow != null">            <![CDATA[             and rownum_ >= #{startRow}             ]]>        </if>    </sql>    <select id="getInfoList" resultType="HwgProductSaleLimit" parameterType="HwgProductSaleLimit">        <include refid="be_fy"/>        select           sl.limit_id    as limitId,           sl.goods_no    as goodsNo,           sl.order_type  as orderType,           sl.apply_type  as applyType,           to_char(sl.begin_time, ‘yyyy-mm-dd hh24:mi:ss‘)  as beginTime,           to_char(sl.end_time, ‘yyyy-mm-dd hh24:mi:ss‘)    as endTime,           g.goods_name   as goodsName        from hwg_product_sale_limit sl, goods g, product p        where sl.goods_no = g.goods_no        and g.product_id = p.product_id        and sl.IS_DELETE = ‘N‘        and g.is_delete = ‘N‘        and p.is_onsale = ‘Y‘        <if test="goodsName != null and goodsName != ‘‘ ">            and g.goods_name  like ‘%‘||#{goodsName}||‘%‘        </if>        <if test="goodsNo != null and goodsNo != ‘‘ ">            and sl.goods_no = #{goodsNo}        </if>        <if test="beginTime != null and beginTime != ‘‘ ">            and sl.begin_time >= to_date(#{beginTime}, ‘yyyy-mm-dd hh24:mi:ss‘)        </if>        <if test="endTime != null and endTime != ‘‘ ">        <![CDATA[ and sl.end_time <= to_date(#{endTime}, ‘yyyy-mm-dd hh24:mi:ss‘)]]>        </if>        <if test="applyType != null and applyType != ‘‘ ">            and sl.apply_type = #{applyType}        </if>        order by sl.ADD_TIME desc        <include refid="ed_fy"/>    </select>    <select id="getInfoCount" resultType="java.lang.Integer">        select count(1) from hwg_product_sale_limit sl, goods g, product p        where sl.goods_no = g.goods_no and g.product_id = p.product_id        and sl.IS_DELETE=‘N‘ and g.is_delete=‘N‘ and p.is_onsale = ‘Y‘    </select>    <select id="getDetail" resultType="HwgProductSaleLimit">        select          sl.limit_id   as limitId,          sl.goods_no   as goodsNo,          sl.order_type as orderType,          sl.apply_type as applyType,          to_char(sl.begin_time, ‘yyyy-mm-dd hh24:mi:ss‘) as beginTime,          to_char(sl.end_time, ‘yyyy-mm-dd hh24:mi:ss‘)   as endTime        from hwg_product_sale_limit sl        where sl.limit_id = #{limitId} and sl.IS_DELETE=‘N‘    </select>    <insert id="save" parameterType="HwgProductSaleLimit">        INSERT INTO hwg_product_sale_limit (limit_id, goods_no, order_type, apply_type, begin_time, end_time,        is_delete, ADD_USER_ID, ADD_TIME, EDIT_USER_ID, EDIT_TIME)        VALUES (HWG_PRODUCT_SALE_LIMIT_SEQ.nextval,#{goodsNo,jdbcType=VARCHAR},#{orderType,jdbcType=NUMERIC},#{applyType,jdbcType=VARCHAR},        to_date(#{beginTime},‘yyyy-mm-dd hh24:mi:ss‘),to_date(#{endTime},‘yyyy-mm-dd hh24:mi:ss‘),        #{isDelete,jdbcType=VARCHAR},#{addUserId,jdbcType=NUMERIC},#{addTime,jdbcType=VARCHAR},#{editUserId,jdbcType=NUMERIC},#{editTime,jdbcType=VARCHAR})    </insert>    <update id="update" parameterType="HwgProductSaleLimit">        update hwg_product_sale_limit        <set>            <if test="goodsNo != null">                goods_no = #{goodsNo},            </if>            <if test="orderType != null">                order_type = #{orderType},            </if>            <if test="applyType != null">                apply_type = #{applyType},            </if>            <if test="beginTime != null">                begin_time = to_date(#{beginTime},‘yyyy-mm-dd hh24:mi:ss‘),            </if>            <if test="endTime != null">                end_time = to_date(#{endTime},‘yyyy-mm-dd hh24:mi:ss‘),            </if>            <if test="isDelete != null">                IS_DELETE = #{isDelete},            </if>            <if test="addUserId != null">                ADD_USER_ID = #{addUserId},            </if>            <if test="addTime != null">                ADD_TIME = #{addTime},            </if>            <if test="editUserId != null">                EDIT_USER_ID = #{editUserId},            </if>            <if test="editTime != null">                EDIT_TIME = #{editTime}            </if>        </set>        where limit_id = #{limitId}    </update>    <delete id="delete"  parameterType="HwgProductSaleLimit" >        update hwg_product_sale_limit        set is_delete=#{isDelete},         EDIT_USER_ID = #{editUserId},         EDIT_TIME = #{editTime}        where limit_id = #{limitId}    </delete>    <select id="getProduct" resultType="HwgProductSaleLimit">        select          g.goods_no    as goodsNo,          g.goods_name  as productName,          g.goods_id    as goodsId,          g.product_id  as productId        from goods g, product p        where g.product_id = p.product_id        and g.goods_no = #{goodsNo}        and g.IS_DELETE = ‘N‘        and p.is_onsale = ‘Y‘        and rownum=1    </select>        <!-- 今日限时抢购 -->    <select id="getAbroadLimitGoodsInfo" resultType="HwgProductSaleLimit" parameterType="java.lang.String">        select           p.goods_no as goodsNo,             p.begin_time as beginTime,            p.end_time as endTime          from           hwg_product_sale_limit p         where           p.is_delete=‘N‘         and           p.apply_type= #{applyType}          and          trunc(p.begin_time) = trunc(sysdate)         and           trunc(p.end_time) = trunc(sysdate)         and           sysdate &lt; p.end_time     </select>        <!-- 查询今日限时抢购商品 -->    <select id="getAbroadLimitGoodsList" resultType="com.j1.hwg.webmodel.AbroadLimitGoodsModel" parameterType="java.util.List">        select           g.goods_id as goodsId, g.goods_no as goodsNo, g.product_id as productId,          g.goods_name as goodsName, g.ec_price as ecPrice, nvl(g.member_disacount, 0) as mDiscount        from goods g inner join product p on g.product_id=p.product_id         where           g.is_delete=‘N‘        and          p.is_onsale=‘Y‘        and           g.goods_no         in           <foreach item="item" index="index" collection="list" open="(" separator="," close=")">                #{item}            </foreach>      </select></mapper>

 

添加商品验证商品是否存在的两种实现方式