SSH与SSM学习之SSH实现CRM练习04——客户列表04_CustomerService

来源:互联网 发布:工商局可以投诉淘宝吗 编辑:程序博客网 时间:2024/06/07 03:07

  • SSH与SSM学习之SSH实现CRM练习04客户列表04_CustomerService
    • 一说明
    • 二CustomerService
      • 1 CustomerService
      • 3 CustomerServiceImpl
    • 三Spring中配置 CustomerService
    • 四源码下载

SSH与SSM学习之SSH实现CRM练习04——客户列表04_CustomerService

一、说明

由之前的分析,我们知道 CustomerService 应该保护以下的方法

    public PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize) ;

CustomerService中应该保护一个 CustomerDao 的实例,通过 Spring配置。


二、CustomerService

2.1 CustomerService

package com.qwm.ssh_crm.service;import com.qwm.ssh_crm.utils.PageBean;import org.hibernate.criterion.DetachedCriteria;/** * @author:qiwenming * @date:2017/11/5 0005   0:45 * @description: * 客户 */public interface CustomerService {    public PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize) ;}

2.3 CustomerServiceImpl

package com.qwm.ssh_crm.service.impl;import com.qwm.ssh_crm.dao.CustomerDao;import com.qwm.ssh_crm.domain.Customer;import com.qwm.ssh_crm.service.CustomerService;import com.qwm.ssh_crm.utils.PageBean;import org.hibernate.criterion.DetachedCriteria;import java.util.List;/** * @author:qiwenming * @date:2017/11/5 0005   0:47 * @description: */public class CustomerServiceImpl implements CustomerService {    private CustomerDao cd;    @Override    public PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize) {        //1 调用Dao查询总记录数        //2 创建PageBean对象        //3 调用Dao查询分页数        //4 列表数据放入到PageBean中,并返回        Integer totalCount = cd.getTotalCount(dc);        PageBean pb = new PageBean(currentPage,totalCount,pageSize);        List<Customer> list = cd.getPageList(dc,pb.getStart(),pb.getPageSize());        pb.setList(list);        return pb;    }    public CustomerDao getCd() { return cd; }    public void setCd(CustomerDao cd) { this.cd = cd; }}

三、Spring中配置 CustomerService

在Spring的配置文件中,添加一下的配置

    <bean name="customerService" class="com.qwm.ssh_crm.service.impl.CustomerServiceImpl">        <property name="cd" ref="customerDao"/>    </bean>

四、源码下载

https://github.com/wimingxxx/ssh_crm

阅读全文
0 0
原创粉丝点击