Java Code Examples for com.baomidou.mybatisplus.mapper.EntityWrapper#like()

The following examples show how to use com.baomidou.mybatisplus.mapper.EntityWrapper#like() . 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: RoleController.java    From mysiteforme with Apache License 2.0 6 votes vote down vote up
@RequiresPermissions("sys:role:list")
@PostMapping("list")
@ResponseBody
public LayerData<Role> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                            @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                            ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<Role> roleLayerData = new LayerData<>();
    EntityWrapper<Role> roleEntityWrapper = new EntityWrapper<>();
    roleEntityWrapper.eq("del_flag",false);
    if(!map.isEmpty()){
        String keys = (String) map.get("key");
        if(StringUtils.isNotBlank(keys)) {
            roleEntityWrapper.like("name", keys);
        }
    }
    Page<Role> rolePage = roleService.selectPage(new Page<>(page,limit),roleEntityWrapper);
    roleLayerData.setCount(rolePage.getTotal());
    roleLayerData.setData(setUserToRole(rolePage.getRecords()));
    return roleLayerData;
}
 
Example 2
Source File: AdminCouponServiceImpl.java    From unimall with Apache License 2.0 6 votes vote down vote up
@Override
public Page<CouponAdminDTO> queryCouponByTitle(Long adminId, String title, Integer type, Integer status, Integer pageNo, Integer limit) throws ServiceException {
    EntityWrapper wrapper = new EntityWrapper();
    Date now = new Date();
    if (!StringUtils.isEmpty(title)) {
        wrapper.like("title", title);
    }
    if (type != null) {
        wrapper.eq("type", type);
    }
    if (status != null) {
        if (status >= 0 && status < 2) {
            wrapper.eq("status", status);
            wrapper.andNew().gt("gmt_end", now).or().isNotNull("days"); //coupon -> conpon.gt("gmt_end", now).or().isNotNull("days")
        } else if (status < 0) {
            wrapper.lt("gmt_end", now);
        } else {
            throw new AdminServiceException(ExceptionDefinition.COUPON_CHECK_DATA_FAILED);
        }
    }
    Integer count = couponMapper.selectCount(wrapper);
    List<CouponAdminDTO> couponDTOList = couponMapper.getAdminCouponList(title, type, status, now, (pageNo - 1) * limit, limit);
    Page<CouponAdminDTO> page = new Page<CouponAdminDTO>(couponDTOList, pageNo, limit, count);
    return page;
}
 
Example 3
Source File: RoleServiceImpl.java    From Ffast-Java with MIT License 6 votes vote down vote up
@Override
protected ServiceRowsResult listBefore(Role m, EntityWrapper<Role> ew) {
    if (m.getName() != null) {
        ew.like("name", m.getName());
        m.setName(null);
    }
    if (m.getDescription() != null) {
        ew.like("description", m.getDescription());
        m.setDescription(null);
    }
    if (m.getStatus() != null) {
        ew.eq("status", m.getStatus());
        m.setStatus(null);
    }
    return null;
}
 
Example 4
Source File: ResServiceImpl.java    From Ffast-Java with MIT License 6 votes vote down vote up
@Override
protected ServiceRowsResult listBefore(Res m, EntityWrapper<Res> ew) {
    if (m.getName() != null) {
        ew.like("name", m.getName());
    }
    if (m.getIdentity() != null) {
        ew.like("identity", m.getIdentity());
    }
    if (m.getUrl() != null) {
        ew.like("url", m.getName());
    }
    if (m.getStatus() != null) {
        ew.eq("status", m.getStatus());
    }
    if (m.getParentId() != null) {
        ew.eq("parent_id", m.getParentId().toString()).or("id=" + m.getParentId().toString());
    }

    m.setParentId(null);
    m.setIdentity(null);
    m.setUrl(null);
    m.setName(null);
    m.setStatus(null);
    return null;
}
 
Example 5
Source File: QuartzTaskLogController.java    From mysiteforme with Apache License 2.0 6 votes vote down vote up
@RequiresPermissions("quartz:log:list")
@PostMapping("list")
@ResponseBody
public LayerData<QuartzTaskLog> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                                  @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                                  ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<QuartzTaskLog> layerData = new LayerData<>();
    EntityWrapper<QuartzTaskLog> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    if(!map.isEmpty()){
        String name = (String) map.get("name");
        if(StringUtils.isNotBlank(name)) {
            wrapper.like("name",name);
        }else{
            map.remove("name");
        }

    }
    Page<QuartzTaskLog> pageData = quartzTaskLogService.selectPage(new Page<>(page,limit),wrapper);
    layerData.setData(pageData.getRecords());
    layerData.setCount(pageData.getTotal());
    return layerData;
}
 
Example 6
Source File: GlobalFunction.java    From express-ssm with Apache License 2.0 6 votes vote down vote up
/**
 * 构造筛选条件
 * @author jitwxs
 * @since 2018/5/13 15:50
 */
public EntityWrapper<Feedback> getFeedbackWrapper(FeedbackSelectWrapper fsw) {
    EntityWrapper<Feedback> entityWrapper = new EntityWrapper<>();
    // 前台传递,-1表示所有状态
    if(fsw.getStatus() != null && fsw.getStatus() != -1) {
        entityWrapper.eq("status", fsw.getStatus());
    }
    // 前台传递,-1表示所有类型
    if(fsw.getType() != null && fsw.getType() != -1) {
        entityWrapper.eq("type", fsw.getType());
    }
    if(StringUtils.isNotBlank(fsw.getId())){
        entityWrapper.eq("id", fsw.getId());
    }
    if(StringUtils.isNotBlank(fsw.getTel())){
        entityWrapper.eq("tel", fsw.getTel());
    }
    if(StringUtils.isNotBlank(fsw.getName())){
        entityWrapper.like("name", fsw.getName());
    }
    if(StringUtils.isNotBlank(fsw.getStaffName())){
        SysUser user = userService.getByUserName(fsw.getStaffName());
        entityWrapper.eq("staff_id", user.getId());
    }
    return entityWrapper;
}
 
Example 7
Source File: SysLogController.java    From cola-cloud with MIT License 6 votes vote down vote up
/**
 * 查找系统日志
 */
@GetMapping(value = "/list")
@ApiOperation("查找系统日志")
public Result<Page<List<SysLog>>> list(Integer type, String name, Date startDate, Date endDate) {
    EntityWrapper wrapper = new EntityWrapper<>();
    wrapper.like("name", name);
    if (type != null) {
        wrapper.eq("type", type);
    }
    if (startDate != null) {
        wrapper.andNew("create_time >= {0}", startDate);
    }
    //
    if (endDate != null) {
        wrapper.andNew("create_time <= {0}", endDate);
    }
    wrapper.orderBy("id");
    return this.success(sysLogService.selectPage(this.getPagination(), wrapper));
}
 
Example 8
Source File: DictServiceImpl.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@CacheEvict(value = "dictCache",allEntries=true)
@Transactional(readOnly = false, rollbackFor = Exception.class)
@Override
public void deleteByTableName(String tableName) {
    EntityWrapper<Dict> wrapper = new EntityWrapper<>();
    wrapper.like("description","数据表【"+tableName+"】");
    delete(wrapper);
}
 
Example 9
Source File: LogController.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@PostMapping("list")
@ResponseBody
public LayerData<Log> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                            @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                            ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<Log> layerData = new LayerData<>();
    EntityWrapper<Log> wrapper = new EntityWrapper<>();
    if(!map.isEmpty()){
        String keys = (String) map.get("type");
        if(StringUtils.isNotBlank(keys)) {
            wrapper.eq("type", keys);
        }
        String title = (String) map.get("title");
        if(StringUtils.isNotBlank(title)){
            wrapper.like("title",title);
        }
        String username = (String)map.get("username");
        if(StringUtils.isNotBlank(username)){
            wrapper.eq("username",username);
        }
        String httpMethod = (String)map.get("method");
        if(StringUtils.isNotBlank(httpMethod)){
            wrapper.eq("http_method",httpMethod);
        }
    }
    Page<Log> logPage = logService.selectPage(new Page<>(page,limit),wrapper);
    layerData.setCount(logPage.getTotal());
    layerData.setData(logPage.getRecords());
    return  layerData;
}
 
Example 10
Source File: RescourceController.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@RequiresPermissions("sys:rescource:list")
@PostMapping("list")
@ResponseBody
public LayerData<Rescource> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                                 @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                                 ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<Rescource> layerData = new LayerData<>();
    EntityWrapper<Rescource> wrapper = new EntityWrapper<>();
    if(!map.isEmpty()){
        String type = (String) map.get("type");
        if(StringUtils.isNotBlank(type)) {
            wrapper.like("file_type", type);
        }
        String hash = (String)map.get("hash");
        if(StringUtils.isNotBlank(hash)){
            wrapper.eq("hash",hash);
        }
        String source = (String)map.get("source");
        if(StringUtils.isNotBlank(source)){
            wrapper.eq("source",source);
        }
    }
    Page<Rescource> dataPage = rescourceService.selectPage(new Page<>(page,limit),wrapper);
    layerData.setCount(dataPage.getTotal());
    layerData.setData(dataPage.getRecords());
    return layerData;
}
 
Example 11
Source File: QuartzTaskController.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@RequiresPermissions("quartz:task:list")
@PostMapping("list")
@ResponseBody
public LayerData<QuartzTask> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                                  @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                                  ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<QuartzTask> layerData = new LayerData<>();
    EntityWrapper<QuartzTask> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    if(!map.isEmpty()){
        String name = (String) map.get("name");
        if(StringUtils.isNotBlank(name)) {
            wrapper.like("name",name);
        }else{
            map.remove("name");
        }

        String status = (String) map.get("status");
        if(StringUtils.isNotBlank(status)) {
            wrapper.eq("status",status);
        }else{
            map.remove("status");
        }

    }
    Page<QuartzTask> pageData = quartzTaskService.queryList(wrapper,new Page<>(page,limit));
    layerData.setData(pageData.getRecords());
    layerData.setCount(pageData.getTotal());
    return layerData;
}
 
Example 12
Source File: LikeParser.java    From cola-cloud with MIT License 5 votes vote down vote up
@Override
public void doParse(CriteriaContext<Like> criteriaContext, EntityWrapper entityWrapper, String column) {
    if (criteriaContext.getType().reverse()) {
        entityWrapper.notLike(column, String.valueOf(criteriaContext.getValue()), criteriaContext.getType().likeType());
    } else {
        entityWrapper.like(column, String.valueOf(criteriaContext.getValue()), criteriaContext.getType().likeType());
    }
}
 
Example 13
Source File: DictController.java    From cola-cloud with MIT License 5 votes vote down vote up
/**
 * 获取数据字典目录列表
 */
@GetMapping(value = "/list")
@ApiOperation("获取数据字典目录列表")
public Result<Page<List<Dict>>> list(String code, String name) {
    EntityWrapper wrapper = new EntityWrapper();
    wrapper.like("code",code);
    wrapper.like("name",name);
    return this.success(dictService.selectPage(this.getPagination(),wrapper));
}
 
Example 14
Source File: GlobalFunction.java    From express-ssm with Apache License 2.0 5 votes vote down vote up
/**
 * 构造筛选条件
 * @author jitwxs
 * @since 2018/5/13 15:50
 */
public EntityWrapper<Express> getExpressWrapper(ExpressSelectWrapper esw) {
    EntityWrapper<Express> entityWrapper = new EntityWrapper<>();
    // 前台传递,状态-1表示所有状态
    if(esw.getStatus() != null && esw.getStatus() != -1) {
        entityWrapper.eq("status", esw.getStatus());
    }
    if(StringUtils.isNotBlank(esw.getId())) {
        entityWrapper.eq("id", esw.getId());
    }
    if(StringUtils.isNotBlank(esw.getTel())){
        entityWrapper.eq("tel", esw.getTel());
    }
    if(StringUtils.isNotBlank(esw.getName())){
        entityWrapper.like("name", esw.getName());
    }
    if(StringUtils.isNotBlank(esw.getStaffName())){
        SysUser user = userService.getByUserName(esw.getStaffName());
        entityWrapper.eq("staff", user.getId());
    }
    if(StringUtils.isNotBlank(esw.getAddress())){
        entityWrapper.like("address", esw.getAddress());
    }
    if(esw.getHasDelete() != null) {
        entityWrapper.eq("has_delete", esw.getHasDelete());
    }
    if(esw.getIncludeDay() != null && esw.getIncludeDay() != -1) {
        Date nowDate = new Date();
        Date startDate = DateUtils.addDays(nowDate,-1 * esw.getIncludeDay());
        entityWrapper.between("create_date", startDate, nowDate);
    }

    if(esw.getStartDate() != null && esw.getEndDate() != null) {
        entityWrapper.between("create_date", esw.getStartDate(), esw.getEndDate());
    }

    return entityWrapper;
}
 
Example 15
Source File: DictServiceImpl.java    From Ffast-Java with MIT License 5 votes vote down vote up
@Override
protected ServiceRowsResult listBefore(Dict m, EntityWrapper<Dict> ew) {
    ew.like("name", m.getName());
    ew.like("code", m.getCode());
    m.setName(null);
    m.setCode(null);
    return null;
}
 
Example 16
Source File: UserServiceImpl.java    From Ffast-Java with MIT License 5 votes vote down vote up
@Override
protected ServiceRowsResult listBefore(User m, EntityWrapper<User> ew) {
    ew.like("username", m.getUsername());
    ew.like("email", m.getEmail());
    ew.like("tel", m.getTel());
    ew.like("login_ip", m.getLoginIp());
    m.setEmail(null);
    m.setTel(null);
    m.setUsername(null);
    m.setLoginIp(null);
    return null;
}
 
Example 17
Source File: AdminCategoryServiceImpl.java    From unimall with Apache License 2.0 5 votes vote down vote up
@Override
public Page<CategoryTreeNodeDTO> queryCategory(Long adminId, Long id, String title, Integer level, Long parentId, Integer pageNo, Integer limit) throws ServiceException {
    EntityWrapper wrapper = new EntityWrapper();
    if (id != null) {
        wrapper.eq("id", id);
    }
    if (title != null) {
        wrapper.like("title", title);
    }
    if (level != null) {
        wrapper.eq("level", level);
    }
    if (parentId != null) {
        wrapper.eq("parent_id", parentId);
    }
    wrapper.orderBy("level");
    Integer count = categoryMapper.selectCount(wrapper);

    List<CategoryDO> categoryDOS = categoryMapper.selectPage(new RowBounds((pageNo - 1) * limit, limit), wrapper);
    List<CategoryTreeNodeDTO> totalCategory = getCategoryList();
    List<CategoryTreeNodeDTO> list = categoryDOS.stream().map(item -> {
        CategoryTreeNodeDTO dto = new CategoryTreeNodeDTO();
        for (CategoryTreeNodeDTO temp : totalCategory) {
            if (temp.getValue().equals(item.getId())) {
                BeanUtils.copyProperties(temp, dto);
                return dto;
            }
        }
        BeanUtils.copyProperties(item, dto);
        ;
        return dto;
    }).collect(Collectors.toList());
    Page<CategoryTreeNodeDTO> page = new Page<>(list, pageNo, limit, count);
    return page;
}
 
Example 18
Source File: DefaultCinemaServiceImpl.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Override
public Page<CinemaVO> getCinemas(CinemaQueryVO cinemaQueryVO) {
    // 业务实体集合
    List<CinemaVO> cinemas = new ArrayList<>();

    Page<MoocCinemaT> page = new Page<>(cinemaQueryVO.getNowPage(), cinemaQueryVO.getPageSize());
    // 判断是否传入查询条件 -> brandId,distId,hallType 是否==99
    EntityWrapper<MoocCinemaT> entityWrapper = new EntityWrapper<>();
    if (cinemaQueryVO.getBrandId() != 99) {
        entityWrapper.eq("brand_id", cinemaQueryVO.getBrandId());
    }
    if (cinemaQueryVO.getDistrictId() != 99) {
        entityWrapper.eq("area_id", cinemaQueryVO.getDistrictId());
    }
    if (cinemaQueryVO.getHallType() != 99) {  // %#3#%
        entityWrapper.like("hall_ids", "%#+" + cinemaQueryVO.getHallType() + "+#%");
    }

    // 将数据实体转换为业务实体
    List<MoocCinemaT> moocCinemaTS = moocCinemaTMapper.selectPage(page, entityWrapper);
    for (MoocCinemaT moocCinemaT : moocCinemaTS) {
        CinemaVO cinemaVO = new CinemaVO();

        cinemaVO.setUuid(moocCinemaT.getUuid() + "");
        cinemaVO.setMinimumPrice(moocCinemaT.getMinimumPrice() + "");
        cinemaVO.setCinemaName(moocCinemaT.getCinemaName());
        cinemaVO.setAddress(moocCinemaT.getCinemaAddress());

        cinemas.add(cinemaVO);
    }

    // 根据条件,判断影院列表总数
    long counts = moocCinemaTMapper.selectCount(entityWrapper);

    // 组织返回值对象
    Page<CinemaVO> result = new Page<>();
    result.setRecords(cinemas);
    result.setSize(cinemaQueryVO.getPageSize());
    result.setTotal(counts);

    return result;
}
 
Example 19
Source File: BlogCommentController.java    From mysiteforme with Apache License 2.0 4 votes vote down vote up
@RequiresPermissions("blog:comment:list")
@PostMapping("list")
@ResponseBody
public LayerData<BlogComment> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                                  @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                                  ServletRequest request){
    Map map = WebUtils.getParametersStartingWith(request, "s_");
    LayerData<BlogComment> layerData = new LayerData<>();
    EntityWrapper<BlogComment> wrapper = new EntityWrapper<>();
    wrapper.eq("del_flag",false);
    if(!map.isEmpty()){
        String content = (String) map.get("content");
        if(StringUtils.isNotBlank(content)) {
            wrapper.like("content",content);
        }else{
            map.remove("content");
        }

        String ip = (String) map.get("ip");
        if(StringUtils.isNotBlank(ip)) {
            wrapper.like("ip",ip);
        }else{
            map.remove("ip");
        }

        String isAdminReply = (String) map.get("isAdminReply");
        if(StringUtils.isNotBlank(isAdminReply)) {
            if(isAdminReply.equalsIgnoreCase("true")){
                wrapper.eq("is_admin_reply",true);
            }else if(isAdminReply.equalsIgnoreCase("false")){
                wrapper.eq("is_admin_reply",false);
            }else{
                map.remove("isAdminReply");
            }
        }else{
            map.remove("isAdminReply");
        }

    }
    Page<BlogComment> pageData = blogCommentService.selectPage(new Page<>(page,limit),wrapper);
    layerData.setData(pageData.getRecords());
    layerData.setCount(pageData.getTotal());
    return layerData;
}
 
Example 20
Source File: DefaultFilmServiceImpl.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Override
public FilmVO getClassicFilms(int nums, int nowPage, int sortId, int sourceId, int yearId, int catId) {
    FilmVO filmVO = new FilmVO();
    List<FilmInfo> filmInfos = new ArrayList<>();

    // 即将上映影片的限制条件
    EntityWrapper<MoocFilmT> entityWrapper = new EntityWrapper<>();
    entityWrapper.eq("film_status", "3");

    // 如果不是,则是列表页,同样需要限制内容为即将上映影片
    Page<MoocFilmT> page = null;
    // 根据sortId的不同,来组织不同的Page对象
    // 1-按热门搜索,2-按时间搜索,3-按评价搜索
    switch (sortId) {
        case 1:
            page = new Page<>(nowPage, nums, "film_box_office");
            break;
        case 2:
            page = new Page<>(nowPage, nums, "film_time");
            break;
        case 3:
            page = new Page<>(nowPage, nums, "film_score");
            break;
        default:
            page = new Page<>(nowPage, nums, "film_box_office");
            break;
    }

    // 如果sourceId,yearId,catId 不为99 ,则表示要按照对应的编号进行查询
    if (sourceId != 99) {
        entityWrapper.eq("film_source", sourceId);
    }
    if (yearId != 99) {
        entityWrapper.eq("film_date", yearId);
    }
    if (catId != 99) {
        // #2#4#22#
        String catStr = "%#" + catId + "#%";
        entityWrapper.like("film_cats", catStr);
    }

    List<MoocFilmT> moocFilms = moocFilmTMapper.selectPage(page, entityWrapper);
    // 组织filmInfos
    filmInfos = getFilmInfos(moocFilms);
    filmVO.setFilmNum(moocFilms.size());

    // 需要总页数 totalCounts/nums -> 0 + 1 = 1
    // 每页10条,我现在有6条 -> 1
    int totalCounts = moocFilmTMapper.selectCount(entityWrapper);
    int totalPages = (totalCounts / nums) + 1;

    filmVO.setFilmInfo(filmInfos);
    filmVO.setTotalPage(totalPages);
    filmVO.setNowPage(nowPage);

    return filmVO;
}