tk.mybatis.mapper.common.Mapper Java Examples

The following examples show how to use tk.mybatis.mapper.common.Mapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectController.java    From cjs_ssms with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 数据表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;
}
 
Example #2
Source File: SelectServiceImpl.java    From cjs_ssms with GNU General Public License v2.0 5 votes vote down vote up
@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 = {HashMap$Node@7360} "rolename" -> "0001"
  1 = {HashMap$Node@7361} "key" -> "UUserMapper_gridUsers"
  2 = {HashMap$Node@7362} "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;
}
 
Example #3
Source File: SelectServiceImpl.java    From cjs_ssms with GNU General Public License v2.0 5 votes vote down vote up
/**
   * 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);
  }
 
Example #4
Source File: BaseServiceImpl.java    From erp-framework with MIT License 4 votes vote down vote up
public void setMapper(Mapper<T> mapper) {
    this.mapper = mapper;
}
 
Example #5
Source File: BaseService.java    From luckwheel with Apache License 2.0 4 votes vote down vote up
protected Mapper getMapper(){
    return mapper;
}
 
Example #6
Source File: BaseServiceImpl.java    From ShiroJwt with MIT License 4 votes vote down vote up
public Mapper<T> getMapper() {
    return mapper;
}
 
Example #7
Source File: BaseService.java    From java-tutorial with MIT License 4 votes vote down vote up
public Mapper<T> getMapper() {
    return mapper;
}
 
Example #8
Source File: BaseService.java    From FEBS-Security with Apache License 2.0 4 votes vote down vote up
public Mapper<T> getMapper() {
	return mapper;
}
 
Example #9
Source File: BaseService.java    From SpringAll with MIT License 4 votes vote down vote up
public Mapper<T> getMapper() {
    return mapper;
}
 
Example #10
Source File: BaseService.java    From SpringAll with MIT License 4 votes vote down vote up
public Mapper<T> getMapper() {
    return mapper;
}
 
Example #11
Source File: GridMiniHelper.java    From cjs_ssms with GNU General Public License v2.0 4 votes vote down vote up
public static Mapper getSample(Class<UUser> aClass) {
  SqlSession sqlSession = MybatisHelper.getSqlSession(); /*2.sqlSession*/
  return (Mapper) sqlSession.getMapper(aClass);
}
 
Example #12
Source File: BaseService.java    From paascloud-master with Apache License 2.0 2 votes vote down vote up
/**
 * Gets mapper.
 *
 * @return the mapper
 */
public Mapper<T> getMapper() {
	return mapper;
}