本文整理汇总了Java中tk.mybatis.mapper.entity.Example.createCriteria方法的典型用法代码示例。如果您正苦于以下问题:Java Example.createCriteria方法的具体用法?Java Example.createCriteria怎么用?Java Example.createCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tk.mybatis.mapper.entity.Example
的用法示例。
在下文中一共展示了Example.createCriteria方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取所有机构列表
* @param model
* @return
*/
@PostMapping("/index")
@ResponseBody
public Page<SysOffice> index(HttpServletRequest request,
HttpServletResponse response, SysOffice model) {
Page<SysOffice> pg = new Page<SysOffice>(request, response,-1);
Example example = new Example(SysOffice.class);
Example.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(model.getName())) {
criteria.andLike("name", "%" + model.getName() + "%");
}
if (StringUtils.isEmpty(model.getParentId())) {
criteria.andEqualTo("parentId","0");//获取公司
}else {
criteria.andEqualTo("parentId",model.getParentId());
}
pg = service.selectPageByExample(example, pg);
return pg;
}
示例2: getCurentOffices
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取当前用户机构信息
* @return
*/
@PostMapping("/getofficebyuser")
@ResponseBody
public BaseResult getCurentOffices() {
SysUser user= UserUtils.getUser();
Example example=new Example(SysOffice.class);
List<SysOffice> offices=new ArrayList<SysOffice>();
if(user.isAdmin()){
offices=service.selectAll();
}else{
String companyId=user.getOfficeId();
SysOffice currentOffice= service.selectByPrimaryKey(companyId);
if(currentOffice!=null){
String parentIds= currentOffice.getParentIds();
Example.Criteria criteria= example.createCriteria();
String inCondition=parentIds.substring(0,parentIds.length()-1);
criteria.andCondition(" id in ("+inCondition+")");
offices=service.selectByExample(example);
}
}
return new BaseResult(BaseResultCode.SUCCESS, offices);
}
示例3: index
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
@ResponseBody
@PostMapping("/index")
@ApiOperation(value = "用户管理接口")
public Page<SysUser> index(HttpServletRequest request,
HttpServletResponse response,SysUser user){
Page<SysUser> pg=new Page<SysUser>(request,response);
Example example=new Example(SysUser.class);
Example.Criteria criteria= example.createCriteria();
if(!StringUtils.isEmpty(user.getLoginName())) {
criteria.andLike("loginName", "%"+user.getLoginName()+"%");
}
if(!StringUtils.isEmpty(user.getName())) {
criteria.andLike("name", "%"+user.getName()+"%");
}
pg= userService.selectPageByExample(example,pg);
return pg;
}
示例4: index
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取所有字典列表
* @param model
* @return
*/
@PostMapping("/index")
@ResponseBody
public Page<SysDict> index(HttpServletRequest request,
HttpServletResponse response, SysDict model) {
Page<SysDict> pg = new Page<SysDict>(request, response,-1);
Example example = new Example(SysDict.class);
Example.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(model.getLabel())) {
criteria.andLike("label", "%" + model.getLabel() + "%");
}
if (StringUtils.isEmpty(model.getParentId())) {
criteria.andEqualTo("parentId","0");//获取公司
}else {
criteria.andEqualTo("parentId",model.getParentId());
}
pg = service.selectPageByExample(example, pg);
return pg;
}
示例5: index
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取所有菜单列表
* @param model
* @return
*/
@PostMapping("/index")
@ResponseBody
public Page<SysMenu> index(HttpServletRequest request,
HttpServletResponse response, SysMenu model) {
Page<SysMenu> pg = new Page<SysMenu>(request, response,-1);
Example example = new Example(SysMenu.class);
Example.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(model.getName())) {
criteria.andLike("name", "%" + model.getName() + "%");
}
if (StringUtils.isEmpty(model.getParentId())) {
criteria.andEqualTo("parentId","0");//获取公司
}else {
criteria.andEqualTo("parentId",model.getParentId());
}
pg = service.selectPageByExample(example, pg);
return pg;
}
示例6: index
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取所有角色列表
* @param model
* @return
*/
@PostMapping("/index")
@ResponseBody
public Page<SysRole> index(HttpServletRequest request,
HttpServletResponse response, SysRole model) {
Page<SysRole> pg = new Page<SysRole>(request, response,-1);
Example example = new Example(SysRole.class);
Example.Criteria criteria = example.createCriteria();
if (!StringUtils.isEmpty(model.getName())) {
criteria.andLike("name", "%" + model.getName() + "%");
}
if (!StringUtils.isEmpty(model.getOfficeId())) {
criteria.andEqualTo("officeId", model.getOfficeId());
}
pg = service.selectPageByExample(example, pg);
return pg;
}
示例7: getGrids
import tk.mybatis.mapper.entity.Example; //导入方法依赖的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;
}
示例8: main
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
/*rowBounds*/
RowBounds rowBounds = new RowBounds(2, 5);
/*Example*/
Example example = new Example(Country.class);
Example.Criteria criteria = example.createCriteria();
// criteria.andCountrycodeBetween("0", "ZZZZZZZZZZ");
// criteria.andIdBetween(0, 20);
List<Country> countries1 = countryMapper.selectByExample(example);
log.debug("countries1" + countries1.size());
List<Country> countries2 = countryMapper.selectByExampleAndRowBounds(example, rowBounds);
log.debug("countries2" + countries2.size());
PageInfo<Country> pageInfo = new PageInfo<>(countries1);
System.out.println("PageHelperTest.main() pageInfo :" + pageInfo.getSize());
}
示例9: getAll
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
public List<User> getAll(String type, String value, int page) {
Example example = new Example(User.class);
Example.Criteria criteria = example.createCriteria();
criteria.andLike(type, "%" + value + "%");
PageHelper.startPage(page, Constant.PAGE_SIZE);
return userMapper.selectByExample(example);
}
示例10: getCount
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
public int getCount(String type, String value) {
Example example = new Example(User.class);
Example.Criteria criteria = example.createCriteria();
criteria.andLike(type, "%" + value + "%");
int count = userMapper.selectCountByExample(example);
return count;
}
示例11: tree
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取所有机构列表
* @return
*/
@ApiOperation(value = "机构管理-树层级结构接口")
@PostMapping("/tree")
@ResponseBody
public JSONArray tree(SysOffice model) {
Example example = new Example(SysOffice.class);
Example.Criteria criteria = example.createCriteria();
JSONArray list=new JSONArray();
if (!StringUtils.isEmpty(model.getName())) {
criteria.andLike("name", "%" + model.getName() + "%");
}
if (StringUtils.isEmpty(model.getId())) {
criteria.andEqualTo("parentId","0");//获取公司
}else {
criteria.andEqualTo("parentId",model.getId());
}
List<SysOffice> midList = service.selectByExample(example);
if(midList!=null){
for (SysOffice item:midList) {
JSONObject obj=new JSONObject();
obj.put("name",item.getName());
obj.put("id",item.getId());
obj.put("pId",item.getParentId());
obj.put("pIds",item.getParentIds());
obj.put("isParent",""+isHaveChild(item.getId()));
list.add(obj);
}
}
return list;
}
示例12: getMenus
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 返回菜单
* @param model
* @param getAll 是否返回所有菜单
* @return
*/
public JSONArray getMenus(SysMenu model,boolean getAll){
Example example = new Example(SysMenu.class);
Example.Criteria criteria = example.createCriteria();
JSONArray list=new JSONArray();
if (StringUtils.isEmpty(model.getId())) {
criteria.andEqualTo("parentId","0");//获取公司
}else {
criteria.andEqualTo("parentId",model.getId());
}
List<SysMenu> midList = mapper.selectByExample(example);
if(midList!=null){
for (SysMenu item:midList) {
JSONObject obj=new JSONObject();
obj.put("name",item.getName());
obj.put("id",item.getId());
obj.put("pId",item.getParentId());
boolean isParent=isHaveChild(item.getId());
obj.put("isParent",""+isParent);
if(getAll&&isParent) {
obj.put("children", getMenus(item,getAll));
}
list.add(obj);
}
}
return list;
}
示例13: update
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
public String update(SysDict model, SysUser user) {
String result = "成功!";
model.setDescription(model.getRemarks());
if ("0".equals(model.getParentId())) {
model.setType(model.getValue());
} else {
SysDict pDict = mapper.selectByPrimaryKey(model.getParentId());
model.setType(pDict.getValue());
}
model.setUpdateBy(user.getId());
if (StringUtils.isEmpty(model.getId())) {
model.setCreateBy(user.getId());
model.setId(model.getValue());
if (mapper.existsWithPrimaryKey(model)) {
result = "该字典值已经存在!";
} else {
this.insert(model);
}
} else {
model.setId(model.getLabel());
Example example = new Example(SysDict.class);
Example.Criteria criteria = example.createCriteria();
criteria.andNotEqualTo("id", model.getId());
int count = mapper.selectCountByExample(example);
if (count > 1) {
result = "该字典值已经存在!";
} else {
this.updateByPrimaryKeySelective(model);
}
}
return result;
}
示例14: getDicByParentId
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
/**
* 获取子字典
* @param parentId
* @return
*/
public List<SysDict> getDicByParentId(String parentId) {
Example example = new Example(SysDict.class);
Example.Criteria criteria = example.createCriteria();
if(parentId==null)
parentId="0";
criteria.andEqualTo("parentId",parentId);
return mapper.selectByExample(example);
}
示例15: getCriteria
import tk.mybatis.mapper.entity.Example; //导入方法依赖的package包/类
public static Example.Criteria getCriteria(Class<UUser> aClass, Example example) {
Example.Criteria criteria = example.createCriteria();
return criteria;
}