olga 发表于 2016-11-24 08:59:56

mybatis 存储过程

  CREATE DEFINER = `swc`@`%` PROCEDURE `NewProc`(i_begindate date,i_enddate date,i_channelid SMALLINT,i_platid TINYINT,i_page INT,i_rows INT,out o_rows_total INT)
    COMMENT '获取收入信息'
BEGIN
  DECLARE i_begin_row INT DEFAULT 0;
  SET i_begin_row = (i_page - 1) * i_rows;
  IF i_platid = 0 THEN
           
         SELECT postdate                
         , channelid
         , channelname
         , platid
         , platname  
         FROM tmp
         ORDER BY channelid
         LIMIT i_begin_row, i_rows;
  ELSE
          
        SELECT postdate                
         , channelid
         , channelname
         , platid
         , platname  
         FROM tmp
         ORDER BY postdate
         LIMIT i_begin_row, i_rows;
         END IF ;
  
  
    SELECT COUNT(1)
      INTO o_rows_total
      FROM tmp;
  END;
  <?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.gm.dao1.AnalyseDao">
  <select id="list" statementType="CALLABLE" parameterType="java.util.HashMap" resultType="com.gm.domain.Analyse">
   <![CDATA[
           {  call usp_g_channel_analyse_sum(
              #{begin,mode=IN,jdbcType=DATE},
              #{end,mode=IN,jdbcType=DATE},
              #{channel,mode=IN,jdbcType=INTEGER},
              #{platid,mode=IN,jdbcType=INTEGER},
              #{page,mode=IN,jdbcType=INTEGER},
              #{rows,mode=IN,jdbcType=INTEGER},
              #{total,mode=OUT,jdbcType=INTEGER}
           )}   
       ]]>
  </select>
 
</mapper>
  @RequestMapping(value = "/analyse", method = RequestMethod.POST)
 @AutoReturn
 public void list(Analyse s) throws ParseException {
  HashMap<String,Object> map=new HashMap<String, Object>();
  map.put("end", s.getDynamic().get("endDate"));
  map.put("begin",  s.getDynamic().get("startDate"));
  map.put("channel", 0);
  map.put("platid", 0);
  map.put("page", s.getPage()+1);
  map.put("rows", s.getRows());
  List analyse=analyseService.list(map);
  this.setResult(analyse);
  int total=Integer.parseInt(map.get("total").toString());
  this.setTotal(total);
  this.setSuccess(true);
 }
页: [1]
查看完整版本: mybatis 存储过程