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

The following examples show how to use com.baomidou.mybatisplus.mapper.EntityWrapper#andNew() . 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: 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 2
Source File: SysAuthorityServiceImpl.java    From cola-cloud with MIT License 5 votes vote down vote up
@Override
public List<SysRole> getRoleListByResourceId(Long resourceId) {

    EntityWrapper<SysRole> wrapper = new EntityWrapper<>();
    wrapper.andNew("id in (select sys_role_id from cola_sys_authority t where t.sys_resource_id = {0})",resourceId);
    Long tenantId = SecurityUtils.getTenantId();
    if (tenantId != null) {
        wrapper.eq("tenant_id", tenantId);
    } else {
        wrapper.isNull("tenant_id");
    }
    return this.sysRoleMapper.selectList(wrapper);

    /*String sql = "select sys_role_id from cola_sys_authority t where t.sys_resource_id = {0}";
    List<Object> roleIds = commonMapper.selectObjs(sql, resourceId);
    if (CollectionUtils.isNotEmpty(roleIds)) {
        EntityWrapper<SysRole> wrapper = new EntityWrapper<>();
        wrapper.in("id", roleIds);
        //如果有租户则只显示租户下的角色
        Long tenantId = SecurityUtils.getTenantId();
        if (tenantId != null) {
            wrapper.eq("tenant_id", tenantId);
        } else {
            wrapper.isNull("tenant_id");
        }
        return this.sysRoleMapper.selectList(wrapper);
    }
    return null;*/
}
 
Example 3
Source File: SysAuthorityServiceImpl.java    From cola-cloud with MIT License 5 votes vote down vote up
@Override
public List<SysResource> getResourcesByAuthorizeTargetAndType(Long target, String type){
    EntityWrapper<SysResource> wrapper = new EntityWrapper<>();
    wrapper.andNew("id in (select sys_resource_id from cola_sys_authority t where t.sys_role_id " +
            " in (select sys_role_Id from cola_sys_authorize a where a.authorize_target={0} and a.authorize_type={1}))",target,type);
    return this.sysResourceMapper.selectList(wrapper);
}
 
Example 4
Source File: SysAuthorizeServiceImpl.java    From cola-cloud with MIT License 5 votes vote down vote up
@Override
public List<SysRole> getRoleListByTargetAndType(Long target, String type) {
    EntityWrapper<SysRole> wrapper = new EntityWrapper<>();
    wrapper.andNew("id in (select sys_role_id from cola_sys_authorize t " +
            "where t.authorize_target = {0} and authorize_type = {1})",target,type);
    return this.sysRoleMapper.selectList(wrapper);
}
 
Example 5
Source File: SysAuthorityServiceImpl.java    From cola-cloud with MIT License 4 votes vote down vote up
@Override
public List<SysResource> getResourcesByRoleId(Long roleId) {
    EntityWrapper<SysResource> wrapper = new EntityWrapper<>();
    wrapper.andNew("id in (select sys_resource_id from cola_sys_authority t where t.sys_role_id = {0})",roleId);
    return this.sysResourceMapper.selectList(wrapper);
}