当前位置: 首页>>代码示例>>Java>>正文


Java Mapper类代码示例

本文整理汇总了Java中tk.mybatis.mapper.common.Mapper的典型用法代码示例。如果您正苦于以下问题:Java Mapper类的具体用法?Java Mapper怎么用?Java Mapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Mapper类属于tk.mybatis.mapper.common包,在下文中一共展示了Mapper类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGrids

import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
/**
 * 数据表grid查询 It's not good enough
 * @param pageIndex
 * @param pageSize
 * @param paramsMap 给criteria添加参数使用
 * @return
 */
private Map<String, Object> getGrids(int pageIndex, int pageSize, HashMap<String, String> paramsMap) {
  PageRowBounds rowBounds = new PageRowBounds(pageIndex+1, pageSize);
  SqlSession sqlSession = MybatisHelper.getSqlSession();
  Mapper mapper = (Mapper) sqlSession.getMapper(UUserMapper.class);
  Example example = new Example(UUser.class);
  Example.Criteria criteria = example.createCriteria();
  /*criteria增加条件...*/
  List<UUser> users = (List<UUser>) mapper.selectByExampleAndRowBounds(example, rowBounds);

  /*4.构造适合miniui_grid展示的map*/
  Map<String, Object> map_grid = new HashedMap();
  map_grid.put("total", users.size());
  map_grid.put("data", users);

  return map_grid;
}
 
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:24,代码来源:SelectController.java

示例2: queryGridKey

import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
@Override
public Map<String, Object> queryGridKey(int pageNum, int pageSize,
                                        String field, String sort,
                                        HashMap<String, String> params)
    throws ClassNotFoundException, IllegalAccessException,
    InstantiationException, NoSuchMethodException, InvocationTargetException {

  String[] strs = params.get("key").split("_"); /*1.strs[0]:接口, strs[1]:方法*/
  SqlSession sqlSession = MybatisHelper.getSqlSession(); /*2.sqlSession*/
  PageRowBounds rowBounds = new PageRowBounds(pageNum, pageSize); /*3.rowBounds*/

  /*
  0 = {[email protected]} "rolename" -> "0001"
  1 = {[email protected]} "key" -> "UUserMapper_gridUsers"
  2 = {[email protected]} "username" -> "0001"
  * */

  /*1.Mapper*/
  Class mapper_clz = Class.forName(MAPPER + strs[0]);
  Mapper mapper = (Mapper) sqlSession.getMapper(mapper_clz);

  /*2.Page分页操作*/
  // List<Object> list = pagePojo(params, strs, mapper, pageNum, pageSize); // pojo
  List<Object> list = pageMap(params, strs, mapper, pageNum, pageSize); // map
  PageInfo page = new PageInfo(list);

  /*4.构造适合miniui_grid展示的map*/
  Map<String, Object> map_grid = new HashedMap();
  map_grid.put("total", page.getTotal());
  map_grid.put("data", list);

  return map_grid;
}
 
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:34,代码来源:SelectServiceImpl.java

示例3: pageMap

import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
/**
   * 2. 2)params==>pojo 属性归档, Map参数更加通用
   *
   * @param params   分页查询参数
   * @param strs     分页查询接口,方法
   * @param mapper   mybatis反射dao/mapper对象
   * @param pageNum
   * @param pageSize
   * @return
   */
  private List<Object> pageMap(HashMap<String, String> params, String[] strs,
                               Mapper mapper, int pageNum, int pageSize)
      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    Method mapper_method = mapper.getClass().getMethod(strs[1], new Class[]{Map.class});
    /*miniui page从0开始 pagehelper从1开始*/
//    PageHelper.startPage(pageNum + 1, pageSize);

//    mapper.selectByRowBounds()
    return (List<Object>) mapper_method.invoke(mapper, params);
  }
 
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:21,代码来源:SelectServiceImpl.java

示例4: getSample

import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
public static Mapper getSample(Class<UUser> aClass) {
  SqlSession sqlSession = MybatisHelper.getSqlSession(); /*2.sqlSession*/
  return (Mapper) sqlSession.getMapper(aClass);
}
 
开发者ID:MiniPa,项目名称:cjs_ssms,代码行数:5,代码来源:GridMiniHelper.java

示例5: getMapper

import tk.mybatis.mapper.common.Mapper; //导入依赖的package包/类
public Mapper<T> getMapper()
{
	return this.mapper;
}
 
开发者ID:atliwen,项目名称:EDIOrderPlatform,代码行数:5,代码来源:BaseService.java


注:本文中的tk.mybatis.mapper.common.Mapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。