• service的开发实现


    1.分析页面

    2.因为taotao-common被其他子工程共享依赖,所以在这里新建展示数据的POJO类EasyUIDataGridResult如下:

    3.POJO类序列化

    4.创建接口ItemService 

    ItemService.java 

    package com.taotao.service;
    
    import com.taotao.common.pojo.EasyUIDataGridResult;
    
    /**
     * 商品相关的处理的service
     * @title ItemService.java
     * <p>description</p>
     * @author
     * @version 1.0
     */
    public interface ItemService {
    	
    	/**
    	 *  根据当前的页码和每页 的行数进行分页查询
    	 * @param page
    	 * @param rows
    	 * @return
    	 */
    	public EasyUIDataGridResult getItemList(Integer page,Integer rows);
    }
    

      

    5.新建实现类ItemServiceImpl

    ItemServiceImpl.java

    package com.taotao.service.impl;
    
    import java.util.List;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import com.github.pagehelper.PageHelper;
    import com.github.pagehelper.PageInfo;
    import com.taotao.common.pojo.EasyUIDataGridResult;
    import com.taotao.mapper.TbItemMapper;
    import com.taotao.pojo.TbItem;
    import com.taotao.pojo.TbItemExample;
    import com.taotao.service.ItemService;
    
    @Service
    public class ItemServiceImpl implements ItemService {
    
    	@Autowired
    	private TbItemMapper mapper;
    
    	@Override
    	public EasyUIDataGridResult getItemList(Integer page, Integer rows) {
    		// 1.设置分页的信息 使用pagehelper
    		if (page == null)
    			page = 1;
    		if (rows == null)
    			rows = 30;
    		PageHelper.startPage(page, rows);
    		// 2.注入mapper
    		// 3.创建example 对象 不需要设置查询条件
    		TbItemExample example = new TbItemExample();
    		// 4.根据mapper调用查询所有数据的方法
    		List<TbItem> list = mapper.selectByExample(example);
    		// 5.获取分页的信息
    		PageInfo<TbItem> info = new PageInfo<>(list);
    		// 6.封装到EasyUIDataGridResult
    		EasyUIDataGridResult result = new EasyUIDataGridResult();
    		result.setTotal((int) info.getTotal());
    		result.setRows(info.getList());
    		// 7.返回
    		return result;
    	}
    
    }
    

      

    6. 修改applicationContext-service.xml

  • 相关阅读:
    关于Unity中调试C#的方法
    关于Unity的C#基础学习(二)
    关于代码命名规范
    关于Unity的C#基础学习(一)
    关于Unity的游戏的运行模式
    关于Unity的组件和作用
    关于Unity的开发模式
    关于Unity的坐标系
    关于Unity中场景视图的使用
    sql 追踪 神器
  • 原文地址:https://www.cnblogs.com/yuyu666/p/12650656.html
Copyright © 2020-2023  润新知