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

<%@ 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=‘"+appPath+"/js/lib/jquery-easyui/themes/icons/pencil.png‘ onClick=‘showWin("+rowData.limitId+")‘ title=‘编辑‘/>&nbsp;&nbsp;";
                    html+="<img class=‘op-enable‘ src=‘"+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 == "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 == "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 == "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.
 */
@Service
public 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 [email protected]
     * @param applyType    适应端(PC/WAP)
     * @return List<HwgProductSaleLimit>
     */
    public List<HwgProductSaleLimit> getAbroadLimitGoodsInfo(String applyType);
    /**
     * 查询今日限购所有商品
     * @Title: getAbroadLimitGoodsList
     * @Description: 海外购-首页-今日限时抢
     * @author [email protected]
     * @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>
时间: 2024-10-14 00:12:53

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

Web API之认证(Authentication)两种实现方式【二】(十三)

前言 上一节我们详细讲解了认证及其基本信息,这一节我们通过两种不同方式来实现认证,并且分析如何合理的利用这两种方式,文中涉及到的基础知识,请参看上一篇文中,就不再废叙述废话. 序言 对于所谓的认证说到底就是安全问题,在Web API中有多种方式来实现安全,[accepted]方式来处理基于IIS的安全(通过上节提到的WindowsIdentity依赖于HttpContext和IIS认证)或者在Web API里通过使用Web API中的消息处理机制,但是如果我们想应用程序运行在IIS之外此时Win

Android中BroadcastReceiver的两种注册方式(静态和动态)详解

今天我们一起来探讨下安卓中BroadcastReceiver组件以及详细分析下它的两种注册方式. BroadcastReceiver也就是"广播接收者"的意思,顾名思义,它就是用来接收来自系统和应用中的广播.在Android系统中,广播体现在方方面面,例如当开机完成后系统会产生一条广播,接收到这条广播就能实现开机启动服务的功能:当网络状态改变时系统会产生一条广播,接收到这条广播就能及时地做出提示和保存数据等操作:当电池电量改变时,系统会产生一条广播,接收到这条广播就能在电量低时告知用户

[转]Web APi之认证(Authentication)两种实现方式【二】(十三)

本文转自:http://www.cnblogs.com/CreateMyself/p/4857799.html 前言 上一节我们详细讲解了认证及其基本信息,这一节我们通过两种不同方式来实现认证,并且分析如何合理的利用这两种方式,文中涉及到的基础知识,请参看上一篇文中,就不再叙述废话. 序言 对于所谓的认证说到底就是安全问题,在Web API中有多种方式来实现安全,[accepted]方式来处理基于IIS的安全(通过上节提到的WindowsIdentity依赖于HttpContext和IIS认证)

PlaceHolder的两种实现方式

placeholder属性是HTML5 中为input添加的.在input上提供一个占位符,文字形式展示输入字段预期值的提示信息(hint),该字段会在输入为空时显示. 如 1 <input type="text" name="loginName" placeholder="邮箱/手机号/QQ号"> 目前浏览器的支持情况 浏览器 IE6/7/8/9 IE10+ Firefox Chrome Safari  是否支持 NO YES YE

Redis两种持久化方式(RDB&amp;AOF)

爬虫和转载请注明原文地址;博客园蜗牛:http://www.cnblogs.com/tdws/p/5754706.html Redis所需内存 超过可用内存怎么办 Redis修改数据多线程并发—Redis并发锁 windows下redis基础操作与主从复制 从而 数据备份和读写分离 Redis两种持久化方式(RDB&AOF) Redis的持久化过程中并不需要我们开发人员过多的参与,我们要做的是什么呢?除了深入了解RDB和AOF的作用原理,剩下的就是根据实际情况来制定合适的策略了,再复杂一点,也就

Android中两种序列化方式的比较Serializable和Parcelable

Serializable和Parcelable接口可以完成对象的序列化过程,当我们需要通过Intent和Binder传输数据时就需要使用者两种序列化方式.还有,我们需要对象持久化到存储设备或者通过网络传输给其他客户端,这个使用也需要使用Serializale来完成对象的序列化.在Android应用开发中,这两种方式都很常见,但两者方式并不相同. 1.Serializable接口 Serializable接口是Java提供的一个序列化接口,它是一个空接口,为对象提供标准的序列化和反序列化操作.使用

ItemsControl的两种数据绑定方式

最近在学习ItemsControl这个控件的时候,查看了MSDN上面的一个例子,并且自己做了一些修改,这里主要使用了两种方式来进行相应的数据绑定,一种是使用DataContext,另外一种是直接将一个类绑定到前台,其实这两种方式原理差不多都是将数据模型的对象添加到一个ObservableCollection集合中,然后再绑定到前台,下面分别介绍两种绑定方式: 第一种是将数据存储在一个ObservableCollection集合中,然后作为ItemsControl的DataContext对象,下面

Ajax中的get和post两种请求方式的异同

Ajax中我们经常用到get和post请求.那么什么时候用get请求,什么时候用post方式请求呢? 在做回答前我们首先要了解get和post的区别.   1. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到.post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML HEADER内一起传送到ACTION属性所指的URL地址.用户看不到这个过程.   2. 对于get方式,服务器端用Request.QueryS

关于popupwindow的两种实现方式

http://104zz.iteye.com/blog/1685389 android PopupWindow实现从底部弹出或滑出选择菜单或窗口 本实例弹出窗口主要是继承PopupWindow类来实现的弹出窗体,布局可以根据自己定义设计.弹出效果主要使用了translate和alpha样式实现,具体实习如下: 第一步:设计弹出窗口xml: Xml代码   <?xml version="1.0" encoding="utf-8"?> <Relativ

自制Javascript分页插件,支持AJAX加载和URL带参跳转两种初始化方式,可用于同一页面的多个分页和不同页面的调用

闲话部分 最近闲着实在无聊,就做了点小东西练练手,由于原来一直在用AspNetPager进行分页,而且也进行了深度的定制与原有系统整合的也不错,不过毕竟是用别人的,想着看自己能试着做出来不能,后台的分页插件已经有比较成熟的了,那就自己试着写一个前台分页吧. 话不多说,先上效果图: 优点与缺点 来说说优缺点吧,首先AspNetPager是后台分页控件,所以在向客户端回传HTML文档之前生成HTML阶段 就会把分页代码生成完毕,然后回传,而JS是前端代码,就是HTML文档在服务器组织完毕往客户端传送