1namespace是命名空间,此路径是映射路径,是到层的实现 a.id AS 'id', a.phone AS 'phone', a.name AS 'name', a.awards AS 'awards'
2标签可以写数据库 中的字段名,这样在多次操作时可以直接在次标签修改,相当于封装,在方法比较多的时候建议这么写 insert into awards(phone,name,awards) values(#{phone,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{awards,jdbcType=VARCHAR})
3 from awards a where 1=1 and phone=#{phone} if标签判断传入参数是否为空,当不为空时可以进行sql语句的拼接
4在之后的操作可以进行条件的搜索,即条件搜索和显示全部可以都是用这一个方法;查询所有Listawards = awardsDao.findByPhone(null);根据条件查询所有,可以都是用这个方法,非常实用Listawards = awardsDao.findByPhone(phone);
5抽奖逻辑String newLottery =''; String [] lottery = c.getLotteryArray().split(','); Integer i =(int)(Math.random()*lottery.length); for(int j=0;j
6@RequestMapping(value='/findLettory.do',method=RequestMethod.POST) @ResponseBody public List findLettory(String phone){ Listawards = awardsDao.findByPhone(phone); return awards; }ajax,请求
7public String sum(String price,String number){ List numbers = StringUtil.splitInteger(number); List prices = StringUtil.splitDouble(price); Double total = 0.0; Double temp = 0.0; // 用户购买种子的总金额 for (int i = 0; i < numbers.size(); i++) { temp = numbers.get(i) * prices.get(i); total += temp; } return total.toString(); }