管理日常支出
@RequestMapping(value = "/recordselectBydate") public String selectByRecorddate(String userId, String time, @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(defaultValue = "1") Integer pageNo, Model model) { Integer uId = Integer.parseInt(userId);DateFormatfmt = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = null; try { date1 = fmt.parse(time);} catch (ParseException e) {e.printStackTrace(); } List<Record> list = recordservice.selectbyRecorddate(uId, date1, pageSize, ((pageNo - 1) * pageSize));model.addAttribute("recordlist", list);//收入总金额model.addAttribute("income", recordservice.selectincome(uId, date1));//支出总金额model.addAttribute("pay", recordservice.selectpay(uId, date1)); return "record/datarecord";Mapper.xml<select id="queryRecordbydate" resultMap="BaseResultMap"> select * from records where user_id=#{userId}<![CDATA[ and DATE_FORMAT(time, '%Y-%m-%d') = DATE_FORMAT(#{time}, '%Y-%m-%d') ]]> limit #{pageNo},#{pageSize}</select><select id="income" resultType="DOUBLE"> select sum(value) FROM records where user_id=#{userId}<![CDATA[ and DATE_FORMAT(time, '%Y-%m-%d') = DATE_FORMAT(#{time}, '%Y-%m-%d') ]]> AND value>0</select><select id="pay" resultType="DOUBLE"> select sum(value) FROM records where user_id=#{userId}<![CDATA[ and DATE_FORMAT(time, '%Y-%m-%d') = DATE_FORMAT(#{time}, '%Y-%m-%d') ]]> AND value <=0</select>
评论