Package com.bytedesk.core.ip_access
Class IpAccessRestService
java.lang.Object
com.bytedesk.core.base.BaseRestService<IpAccessEntity,IpAccessRequest,IpAccessResponse>
com.bytedesk.core.ip_access.IpAccessRestService
@Service
@Transactional
public class IpAccessRestService
extends BaseRestService<IpAccessEntity,IpAccessRequest,IpAccessResponse>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final IpAccessRepository
private final IpBlackRestService
private final IpService
private static final int
private static final int
private final org.modelmapper.ModelMapper
private final UidUtils
Fields inherited from class com.bytedesk.core.base.BaseRestService
authService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToResponse
(IpAccessEntity entity) create
(IpAccessRequest request) 记录IP访问(原 recordAccess 功能迁移至此)private IpAccessEntity
createIpAccessEntity
(String ip, String endpoint, String httpMethod, String params, ZonedDateTime now) 创建IP访问实体createIpAccessRequest
(String ip, String endpoint, String httpMethod, String params) 创建IP访问请求对象protected org.springframework.data.jpa.domain.Specification<IpAccessEntity>
createSpecification
(IpAccessRequest request) 创建Specification对象,子类必须实现 用于queryByOrg的通用实现void
delete
(IpAccessRequest request) void
deleteByUid
(String uid) protected IpAccessEntity
doSave
(IpAccessEntity entity) 子类实现具体的保存逻辑protected org.springframework.data.domain.Page<IpAccessEntity>
executePageQuery
(org.springframework.data.jpa.domain.Specification<IpAccessEntity> spec, org.springframework.data.domain.Pageable pageable) 执行分页查询,子类必须实现 用于queryByOrg的通用实现existsByUid
(String uid) handleOptimisticLockingFailureException
(org.springframework.orm.ObjectOptimisticLockingFailureException e, IpAccessEntity entity) update
(IpAccessRequest request) Methods inherited from class com.bytedesk.core.base.BaseRestService
deleteByOrgUid, findByOrgUid, getUidFromRequest, queryByOrg, queryByUid, queryByUser, recover, save, setUserUidToRequest
-
Field Details
-
MAX_REQUESTS_PER_MINUTE
private static final int MAX_REQUESTS_PER_MINUTE- See Also:
-
MAX_RETRY_COUNT
private static final int MAX_RETRY_COUNT- See Also:
-
BLACKLIST_THRESHOLD
private static final int BLACKLIST_THRESHOLD- See Also:
-
ipAccessRepository
-
ipBlackRestService
-
ipService
-
uidUtils
-
modelMapper
private final org.modelmapper.ModelMapper modelMapper
-
-
Constructor Details
-
IpAccessRestService
public IpAccessRestService()
-
-
Method Details
-
createSpecification
protected org.springframework.data.jpa.domain.Specification<IpAccessEntity> createSpecification(IpAccessRequest request) Description copied from class:BaseRestService
创建Specification对象,子类必须实现 用于queryByOrg的通用实现- Specified by:
createSpecification
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
executePageQuery
protected org.springframework.data.domain.Page<IpAccessEntity> executePageQuery(org.springframework.data.jpa.domain.Specification<IpAccessEntity> spec, org.springframework.data.domain.Pageable pageable) Description copied from class:BaseRestService
执行分页查询,子类必须实现 用于queryByOrg的通用实现- Specified by:
executePageQuery
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
findByUid
- Specified by:
findByUid
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
existsByUid
-
create
记录IP访问(原 recordAccess 功能迁移至此)- Specified by:
create
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse> - Parameters:
request
- IpAccessRequest,需包含 ip, endpoint, httpMethod, params- Returns:
- IpAccessResponse
-
update
- Specified by:
update
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
doSave
Description copied from class:BaseRestService
子类实现具体的保存逻辑- Specified by:
doSave
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
handleOptimisticLockingFailureException
public IpAccessEntity handleOptimisticLockingFailureException(org.springframework.orm.ObjectOptimisticLockingFailureException e, IpAccessEntity entity) - Specified by:
handleOptimisticLockingFailureException
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
deleteByUid
- Specified by:
deleteByUid
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
delete
- Specified by:
delete
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
convertToResponse
- Specified by:
convertToResponse
in classBaseRestService<IpAccessEntity,
IpAccessRequest, IpAccessResponse>
-
createIpAccessRequest
public IpAccessRequest createIpAccessRequest(String ip, String endpoint, String httpMethod, String params) 创建IP访问请求对象- Parameters:
ip
- IP地址endpoint
- 访问端点httpMethod
- HTTP方法params
- 请求参数- Returns:
- IpAccessRequest
-
createIpAccessEntity
private IpAccessEntity createIpAccessEntity(String ip, String endpoint, String httpMethod, String params, ZonedDateTime now) 创建IP访问实体- Parameters:
ip
- IP地址endpoint
- 访问端点httpMethod
- HTTP方法params
- 请求参数now
- 当前时间- Returns:
- IpAccessEntity
-