A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

【郑州校区】传智健康项目讲义第十章 七

2.3.4 Dao接口
OrderDaoMemberDao中声明相关统计查询方法
[AppleScript] 纯文本查看 复制代码
package com.itheima.dao;
import com.itheima.pojo.Order;
import java.util.List;
import java.util.Map;
public interface OrderDao {
public void add(Order order);
public List<Order> findByCondition(Order order);
public Map findById4Detail(Integer id);
public Integer findOrderCountByDate(String date);
public Integer findOrderCountAfterDate(String date);
public Integer findVisitsCountByDate(String date);
public Integer findVisitsCountAfterDate(String date);
public List<Map> findHotSetmeal();
}

[AppleScript] 纯文本查看 复制代码
package com.itheima.dao;
import com.github.pagehelper.Page;
import com.itheima.pojo.Member;
import java.util.List;
public interface MemberDao {
public List<Member> findAll();
public Page<Member> selectByCondition(String queryString);
public void add(Member member);
public void deleteById(Integer id);
public Member findById(Integer id);
public Member findByTelephone(String telephone);
public void edit(Member member);
public Integer findMemberCountBeforeDate(String date);
public Integer findMemberCountByDate(String date);
public Integer findMemberCountAfterDate(String date);
public Integer findMemberTotalCount();
} 

2.3.5 Mapper映射文件
OrderDao.xmlMemberDao.xml中定义SQL语句
OrderDao.xml

[AppleScript] 纯文本查看 复制代码
<!‐‐根据日期统计预约数‐‐>
<select id="findOrderCountByDate" parameterType="string"
resultType="int">
select count(id) from t_order where orderDate = #{value}
</select>
<!‐‐根据日期统计预约数,统计指定日期之后的预约数‐‐>
<select id="findOrderCountAfterDate" parameterType="string"
resultType="int">
select count(id) from t_order where orderDate >= #{value}
</select>
<!‐‐根据日期统计到诊数‐‐>
<select id="findVisitsCountByDate" parameterType="string"
resultType="int">
select count(id) from t_order where orderDate = #{value} and
orderStatus = '已到诊'
</select>
<!‐‐根据日期统计到诊数,统计指定日期之后的到诊数‐‐>
<select id="findVisitsCountAfterDate" parameterType="string"
resultType="int">
select count(id) from t_order where orderDate >= #{value} and
orderStatus = '已到诊'
</select>
<!‐‐热门套餐,查询前4条‐‐>
<select id="findHotSetmeal" resultType="map">
select
s.name,
count(o.id) setmeal_count ,
count(o.id)/(select count(id) from t_order) proportion
from t_order o inner join t_setmeal s on s.id = o.setmeal_id
group by o.setmeal_id
order by setmeal_count desc
limit 0,4
</select> 

MemberDao.xml

[AppleScript] 纯文本查看 复制代码
<!‐‐根据日期统计会员数,统计指定日期之前的会员数‐‐>
<select id="findMemberCountBeforeDate" parameterType="string"
resultType="int">
select count(id) from t_member where regTime <= #{value}
</select>
<!‐‐根据日期统计会员数‐‐>
<select id="findMemberCountByDate" parameterType="string"
resultType="int">
select count(id) from t_member where regTime = #{value}
</select>
<!‐‐根据日期统计会员数,统计指定日期之后的会员数‐‐>
<select id="findMemberCountAfterDate" parameterType="string"
resultType="int">
select count(id) from t_member where regTime >= #{value}
</select>
<!‐‐总会员数‐‐>
<select id="findMemberTotalCount" resultType="int">
select count(id) from t_member
</select> 


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马