SSH_06

作者: 编程_书恨少 | 来源:发表于2018-09-05 20:09 被阅读0次

    1. 如何进行查询的sql书写

    select dd.dict_item_name, count(*) totalCount from t_customer c, data_dict dd 
    where c.cust_industry = dd.dict_id group by cust_industry;
    
    Snip20180905_5.png Snip20180905_6.png Snip20180905_7.png

    2. 按行业查询客户数的需求实现

    CustomerDao

    public interface CustomerDao extends BaseDao<Customer> {
    
        List<Object[]> getIndustryCount();
    }
    

    CustomerDaoImpl

    public class CustomerDaoImpl extends BaseDaoImpl<Customer> implements CustomerDao {
    
        @Override
        @SuppressWarnings("all")
        public List<Object[]> getIndustryCount() {
    
            // 原生sql查询
            List<Object[]> list = getHibernateTemplate().execute(new HibernateCallback<List>() {
    
                @Override
                public List doInHibernate(Session session) throws HibernateException {
    
                    String sql = "select dd.dict_item_name, count(*) total_count from t_customer c, data_dict dd \n" +
                                "where c.cust_industry = dd.dict_id group by cust_industry";
    
                    Query query = session.createQuery(sql);
    
                    return query.list();
                }
            });
    
            return list;
        }
    }
    
    

    CustomerService

    
    public interface CustomerService {
    
        // 分页方法
        PageBean getPageBean(DetachedCriteria dc, Integer currentPage, Integer pageSize);
    
        void save(Customer customer);
    
        List<Object[]> getIndustryCount();
    }
    
    

    CustomerServiceImpl

    // 按照行业查询客户数
        @Override
        public List<Object[]> getIndustryCount() {
    
            return customerDao.getIndustryCount();
        }
    

    CustomerAction

     public String industryCount() throws Exception {
    
            List<Object[]> list = customerService.getIndustryCount();
    
            ActionContext.getContext().put("list", list);
    
            return "industryCount";
        }
    

    3. 将项目转换为使用spring注解来实现

    个人比较喜欢用xml来管理,这里就不上代码了

    4.easyUI过时了,直接写html和js就好了

    相关文章

      网友评论

          本文标题:SSH_06

          本文链接:https://www.haomeiwen.com/subject/wypawftx.html