diff --git a/api.gradle b/api.gradle new file mode 100644 index 0000000..42e0a91 --- /dev/null +++ b/api.gradle @@ -0,0 +1,5 @@ +rootProject.name = 'api' +include 'plugin' +include 'common' +include 'dao' +include 'core' \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..d5ca640 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,10 @@ +FROM openjdk:11.0.13-jre +ARG service_name_folder +WORKDIR /app +ADD databasir.jar /app +EXPOSE 8080 + +#-Ddatabasir.datasource.username=${databasir.datasource.username} +#-Ddatabasir.datasource.password=${databasir.datasource.password} +#-Ddatabasir.datasource.url=${databasir.datasource.url} +ENTRYPOINT ["sh", "-c","java ${JAVA_OPTS} -jar /app/databasir.jar"] diff --git a/api/build.gradle b/api/build.gradle new file mode 100644 index 0000000..7e26378 --- /dev/null +++ b/api/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'io.spring.dependency-management' + id 'org.springframework.boot' apply false +} + +bootJar { + archiveBaseName = 'databasir' + archiveVersion = '' + enabled = true +} + +bootBuildImage { + imageName = "${project.group}/databasir:${project.version}" + publish = false +} + +dependencies { + implementation project(":common") + implementation project(":plugin") + implementation project(":core") + implementation project(":dao") + + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-aop' + implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.flywaydb:flyway-core' + +} + +/** + * Docker + */ +task copyDockerfile(type: Copy) { + from("Dockerfile") + into("build/libs") +} + +bootJar.finalizedBy copyDockerfile +assemble.finalizedBy copyDockerfile diff --git a/api/src/main/java/com/databasir/DatabasirApplication.java b/api/src/main/java/com/databasir/DatabasirApplication.java new file mode 100644 index 0000000..8ace436 --- /dev/null +++ b/api/src/main/java/com/databasir/DatabasirApplication.java @@ -0,0 +1,13 @@ +package com.databasir; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration; + +@SpringBootApplication(exclude = {R2dbcAutoConfiguration.class}) +public class DatabasirApplication { + + public static void main(String[] args) { + SpringApplication.run(DatabasirApplication.class, args); + } +} diff --git a/api/src/main/java/com/databasir/api/DocumentController.java b/api/src/main/java/com/databasir/api/DocumentController.java new file mode 100644 index 0000000..6979b63 --- /dev/null +++ b/api/src/main/java/com/databasir/api/DocumentController.java @@ -0,0 +1,44 @@ +package com.databasir.api; + +import com.databasir.common.JsonData; +import com.databasir.core.domain.document.data.DatabaseDocumentResponse; +import com.databasir.core.domain.document.data.DatabaseDocumentVersionResponse; +import com.databasir.core.domain.document.service.DocumentService; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@Validated +public class DocumentController { + + private final DocumentService documentService; + + @PostMapping(Routes.Document.SYNC_ONE) + public JsonData sync(@PathVariable Integer projectId) { + documentService.syncByProjectId(projectId); + return JsonData.ok(); + } + + @GetMapping(Routes.Document.GET_ONE) + public JsonData getByProjectId(@PathVariable Integer projectId, + @RequestParam(required = false) Long version) { + return documentService.getOneByProjectId(projectId, version) + .map(JsonData::ok) + .orElseGet(JsonData::ok); + } + + @GetMapping(Routes.Document.LIST_VERSIONS) + public JsonData> getVersionsByProjectId(@PathVariable Integer projectId, + @PageableDefault(sort = "id", direction = Sort.Direction.DESC) + Pageable page) { + return JsonData.ok(documentService.getVersionsBySchemaSourceId(projectId, page)); + } + +} diff --git a/api/src/main/java/com/databasir/api/GroupController.java b/api/src/main/java/com/databasir/api/GroupController.java new file mode 100644 index 0000000..f69c7f5 --- /dev/null +++ b/api/src/main/java/com/databasir/api/GroupController.java @@ -0,0 +1,106 @@ +package com.databasir.api; + +import com.databasir.api.validator.UserOperationValidator; +import com.databasir.common.JsonData; +import com.databasir.core.domain.group.data.*; +import com.databasir.core.domain.group.service.GroupService; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.Arrays; +import java.util.List; + +@RestController +@RequiredArgsConstructor +@Validated +public class GroupController { + + private final GroupService groupService; + + private final UserOperationValidator userOperationValidator; + + @PostMapping(Routes.Group.CREATE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData create(@RequestBody @Valid GroupCreateRequest request) { + groupService.create(request); + return JsonData.ok(); + } + + @PatchMapping(Routes.Group.UPDATE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER'.concat('?groupId='.concat(#request.id)))") + public JsonData update(@RequestBody @Valid GroupUpdateRequest request) { + groupService.update(request); + return JsonData.ok(); + } + + @GetMapping(Routes.Group.LIST) + public JsonData> list(@PageableDefault(sort = "id", direction = Sort.Direction.DESC) + Pageable page, + GroupPageCondition condition) { + return JsonData.ok(groupService.list(page, condition)); + } + + @DeleteMapping(Routes.Group.DELETE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER'.concat('?groupId='.concat(#groupId)))") + public JsonData deleteById(@PathVariable Integer groupId) { + groupService.delete(groupId); + return JsonData.ok(); + } + + @GetMapping(Routes.Group.GET_ONE) + public JsonData getOne(@PathVariable Integer groupId) { + return JsonData.ok(groupService.get(groupId)); + } + + @GetMapping(Routes.Group.MEMBERS) + public JsonData> listGroupMembers(@PathVariable Integer groupId, + @PageableDefault(sort = "user_role.create_at", direction = Sort.Direction.DESC) + Pageable pageable, + GroupMemberPageCondition condition) { + return JsonData.ok(groupService.listGroupMembers(groupId, pageable, condition)); + } + + @PostMapping(Routes.Group.ADD_MEMBER) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER'.concat('?groupId='.concat(#groupId)))") + public JsonData addGroupMember(@PathVariable Integer groupId, + @RequestBody @Valid GroupMemberCreateRequest request) { + userOperationValidator.forbiddenIfUpdateSelfRole(request.getUserId()); + List groupRoles = Arrays.asList("GROUP_OWNER", "GROUP_MEMBER"); + if (!groupRoles.contains(request.getRole())) { + throw new IllegalArgumentException("role should be GROUP_OWNER or GROUP_MEMBER"); + } + groupService.addMember(groupId, request); + return JsonData.ok(); + } + + @DeleteMapping(Routes.Group.DELETE_MEMBER) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER'.concat('?groupId='.concat(#groupId)))") + public JsonData removeGroupMember(@PathVariable Integer groupId, + @PathVariable Integer userId) { + userOperationValidator.forbiddenIfUpdateSelfRole(userId); + groupService.removeMember(groupId, userId); + return JsonData.ok(); + } + + @PatchMapping(Routes.Group.UPDATE_MEMBER) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER'.concat('?groupId='.concat(#groupId)))") + public JsonData updateGroupMemberRole(@PathVariable Integer groupId, + @PathVariable Integer userId, + @RequestBody GroupMemberRoleUpdateRequest request) { + userOperationValidator.forbiddenIfUpdateSelfRole(userId); + List groupRoles = Arrays.asList("GROUP_OWNER", "GROUP_MEMBER"); + if (!groupRoles.contains(request.getRole())) { + throw new IllegalArgumentException("role should be GROUP_OWNER or GROUP_MEMBER"); + } + groupService.changeMemberRole(groupId, userId, request.getRole()); + return JsonData.ok(); + } + +} diff --git a/api/src/main/java/com/databasir/api/LoginController.java b/api/src/main/java/com/databasir/api/LoginController.java new file mode 100644 index 0000000..bd5651f --- /dev/null +++ b/api/src/main/java/com/databasir/api/LoginController.java @@ -0,0 +1,55 @@ +package com.databasir.api; + +import com.databasir.common.DatabasirException; +import com.databasir.common.JsonData; +import com.databasir.common.exception.InvalidTokenException; +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.login.data.AccessTokenRefreshRequest; +import com.databasir.core.domain.login.data.AccessTokenRefreshResponse; +import com.databasir.core.domain.login.service.LoginService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.Objects; + +@RestController +@RequiredArgsConstructor +@Validated +@Slf4j +public class LoginController { + + private final AuthenticationManager authenticationManager; + + private final LoginService loginService; + + @GetMapping(Routes.Login.LOGOUT) + public JsonData logout() { + SecurityContextHolder.clearContext(); + return JsonData.ok(); + } + + @PostMapping(Routes.Login.REFRESH_ACCESS_TOKEN) + public JsonData refreshAccessTokens(@RequestBody @Valid AccessTokenRefreshRequest request, + HttpServletResponse response) { + try { + return JsonData.ok(loginService.refreshAccessTokens(request)); + } catch (DatabasirException e) { + if (Objects.equals(e.getErrCode(), DomainErrors.ACCESS_TOKEN_REFRESH_INVALID.getErrCode())) { + throw new InvalidTokenException(DomainErrors.ACCESS_TOKEN_REFRESH_INVALID); + } + if (Objects.equals(e.getErrCode(), DomainErrors.REFRESH_TOKEN_EXPIRED.getErrCode())) { + throw new InvalidTokenException(DomainErrors.REFRESH_TOKEN_EXPIRED); + } + throw e; + } + } +} diff --git a/api/src/main/java/com/databasir/api/ProjectController.java b/api/src/main/java/com/databasir/api/ProjectController.java new file mode 100644 index 0000000..7587b84 --- /dev/null +++ b/api/src/main/java/com/databasir/api/ProjectController.java @@ -0,0 +1,58 @@ +package com.databasir.api; + +import com.databasir.common.JsonData; +import com.databasir.core.domain.project.data.*; +import com.databasir.core.domain.project.service.ProjectService; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@RestController +@RequiredArgsConstructor +@Validated +public class ProjectController { + + private final ProjectService projectService; + + @PostMapping(Routes.GroupProject.CREATE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER?groupId='+#request.groupId, 'GROUP_MEMBER?groupId='+#request.groupId)") + public JsonData create(@RequestBody @Valid ProjectCreateRequest request) { + projectService.create(request); + return JsonData.ok(); + } + + @PatchMapping(Routes.GroupProject.UPDATE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER?groupId='+#groupId, 'GROUP_MEMBER?groupId='+#groupId)") + public JsonData update(@RequestBody @Valid ProjectUpdateRequest request, + @PathVariable Integer groupId) { + projectService.update(groupId, request); + return JsonData.ok(); + } + + @DeleteMapping(Routes.GroupProject.DELETE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER?groupId='+#groupId, 'GROUP_MEMBER?groupId='+#groupId)") + public JsonData delete(@PathVariable Integer groupId, + @PathVariable Integer projectId) { + projectService.delete(projectId); + return JsonData.ok(); + } + + @GetMapping(Routes.GroupProject.GET_ONE) + public JsonData getOne(@PathVariable Integer projectId) { + return JsonData.ok(projectService.getOne(projectId)); + } + + @GetMapping(Routes.GroupProject.LIST) + public JsonData> list(@PageableDefault(sort = "id", direction = Sort.Direction.DESC) + Pageable page, + ProjectListCondition condition) { + return JsonData.ok(projectService.list(page, condition)); + } +} diff --git a/api/src/main/java/com/databasir/api/Routes.java b/api/src/main/java/com/databasir/api/Routes.java new file mode 100644 index 0000000..409551d --- /dev/null +++ b/api/src/main/java/com/databasir/api/Routes.java @@ -0,0 +1,84 @@ +package com.databasir.api; + +public interface Routes { + + String BASE = "/api/v1.0"; + + interface User { + + String LIST = BASE + "/users"; + + String GET_ONE = BASE + "/users/{userId}"; + + String ENABLE = BASE + "/users/{userId}/enable"; + + String DISABLE = BASE + "/users/{userId}/disable"; + + String CREATE = BASE + "/users"; + + String UPDATE_PASSWORD = BASE + "/users/{userId}/password"; + + String UPDATE_NICKNAME = BASE + "/users/{userId}/nickname"; + + String RENEW_PASSWORD = BASE + "/users/{userId}/renew_password"; + + String ADD_OR_REMOVE_SYS_OWNER = BASE + "/users/{userId}/sys_owners"; + } + + interface Group { + + String LIST = BASE + "/groups"; + + String GET_ONE = BASE + "/groups/{groupId}"; + + String CREATE = BASE + "/groups"; + + String UPDATE = BASE + "/groups"; + + String DELETE = BASE + "/groups/{groupId}"; + + String MEMBERS = GET_ONE + "/members"; + + String DELETE_MEMBER = GET_ONE + "/members/{userId}"; + + String ADD_MEMBER = GET_ONE + "/members"; + + String UPDATE_MEMBER = GET_ONE + "/members/{userId}"; + } + + interface GroupProject { + + String LIST = BASE + "/projects"; + + String GET_ONE = BASE + "/projects/{projectId}"; + + String CREATE = BASE + "/projects"; + + String UPDATE = BASE + "/groups/{groupId}/projects"; + + String DELETE = BASE + "/groups/{groupId}/projects/{projectId}"; + } + + interface Document { + + String GET_ONE = BASE + "/projects/{projectId}/documents"; + + String SYNC_ONE = BASE + "/projects/{projectId}/documents"; + + String LIST_VERSIONS = BASE + "/projects/{projectId}/document_versions"; + } + + interface Setting { + + String GET_SYS_EMAIL = BASE + "/settings/sys_email"; + + String UPDATE_SYS_EMAIL = BASE + "/settings/sys_email"; + } + + interface Login { + + String LOGOUT = "/logout"; + + String REFRESH_ACCESS_TOKEN = "/access_tokens"; + } +} diff --git a/api/src/main/java/com/databasir/api/SettingController.java b/api/src/main/java/com/databasir/api/SettingController.java new file mode 100644 index 0000000..e54257c --- /dev/null +++ b/api/src/main/java/com/databasir/api/SettingController.java @@ -0,0 +1,35 @@ +package com.databasir.api; + + +import com.databasir.common.JsonData; +import com.databasir.core.domain.system.data.SystemEmailResponse; +import com.databasir.core.domain.system.data.SystemEmailUpdateRequest; +import com.databasir.core.domain.system.service.SystemService; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@RestController +@RequiredArgsConstructor +@Validated +@PreAuthorize("hasAnyAuthority('SYS_OWNER')") +public class SettingController { + + private final SystemService systemService; + + @GetMapping(Routes.Setting.GET_SYS_EMAIL) + public JsonData getSystemEmailSetting() { + return systemService.getEmailSetting() + .map(JsonData::ok) + .orElseGet(JsonData::ok); + } + + @PostMapping(Routes.Setting.UPDATE_SYS_EMAIL) + public JsonData updateSystemEmailSetting(@RequestBody @Valid SystemEmailUpdateRequest request) { + systemService.updateEmailSetting(request); + return JsonData.ok(); + } +} diff --git a/api/src/main/java/com/databasir/api/UserController.java b/api/src/main/java/com/databasir/api/UserController.java new file mode 100644 index 0000000..33f12a8 --- /dev/null +++ b/api/src/main/java/com/databasir/api/UserController.java @@ -0,0 +1,105 @@ +package com.databasir.api; + +import com.databasir.api.validator.UserOperationValidator; +import com.databasir.common.JsonData; +import com.databasir.common.exception.Forbidden; +import com.databasir.core.domain.user.data.*; +import com.databasir.core.domain.user.service.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@RestController +@RequiredArgsConstructor +@Validated +public class UserController { + + private final UserService userService; + + private final UserOperationValidator userOperationValidator; + + @GetMapping(Routes.User.LIST) + public JsonData> list(@PageableDefault(sort = "id", direction = Sort.Direction.DESC) + Pageable pageable, + UserPageCondition condition) { + return JsonData.ok(userService.list(pageable, condition)); + } + + @PostMapping(Routes.User.DISABLE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData disableUser(@PathVariable Integer userId) { + userService.switchEnableStatus(userId, false); + return JsonData.ok(); + } + + @PostMapping(Routes.User.ENABLE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData enableUser(@PathVariable Integer userId) { + userService.switchEnableStatus(userId, true); + return JsonData.ok(); + } + + @PostMapping(Routes.User.CREATE) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData create(@RequestBody @Valid UserCreateRequest request) { + userService.create(request); + return JsonData.ok(); + } + + @GetMapping(Routes.User.GET_ONE) + public JsonData getOne(@PathVariable Integer userId) { + return JsonData.ok(userService.get(userId)); + } + + @PostMapping(Routes.User.RENEW_PASSWORD) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData renewPassword(@PathVariable Integer userId) { + userService.renewPassword(userId); + return JsonData.ok(); + } + + @PostMapping(Routes.User.ADD_OR_REMOVE_SYS_OWNER) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData addSysOwner(@PathVariable Integer userId) { + userOperationValidator.forbiddenIfUpdateSelfRole(userId); + userService.addSysOwnerTo(userId); + return JsonData.ok(); + } + + @DeleteMapping(Routes.User.ADD_OR_REMOVE_SYS_OWNER) + @PreAuthorize("hasAnyAuthority('SYS_OWNER')") + public JsonData removeSysOwner(@PathVariable Integer userId) { + userOperationValidator.forbiddenIfUpdateSelfRole(userId); + userService.removeSysOwnerFrom(userId); + return JsonData.ok(); + } + + @PostMapping(Routes.User.UPDATE_PASSWORD) + public JsonData updatePassword(@PathVariable Integer userId, + @RequestBody @Valid UserPasswordUpdateRequest request) { + if (userOperationValidator.isMyself(userId)) { + userService.updatePassword(userId, request); + return JsonData.ok(); + } else { + throw new Forbidden(); + } + } + + @PostMapping(Routes.User.UPDATE_NICKNAME) + public JsonData updateNickname(@PathVariable Integer userId, + @RequestBody @Valid UserNicknameUpdateRequest request) { + if (userOperationValidator.isMyself(userId)) { + userService.updateNickname(userId, request); + return JsonData.ok(); + } else { + throw new Forbidden(); + } + } +} diff --git a/api/src/main/java/com/databasir/api/advice/DatabasirExceptionAdvice.java b/api/src/main/java/com/databasir/api/advice/DatabasirExceptionAdvice.java new file mode 100644 index 0000000..8893170 --- /dev/null +++ b/api/src/main/java/com/databasir/api/advice/DatabasirExceptionAdvice.java @@ -0,0 +1,234 @@ +package com.databasir.api.advice; + + +import com.databasir.common.DatabasirException; +import com.databasir.common.JsonData; +import com.databasir.common.SystemException; +import com.databasir.common.exception.Forbidden; +import com.databasir.common.exception.InvalidTokenException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.TypeMismatchException; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.validation.BindException; +import org.springframework.validation.BindingResult; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.ServletRequestBindingException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.multipart.support.MissingServletRequestPartException; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import java.util.List; +import java.util.Set; + +@RestControllerAdvice +@Slf4j +public class DatabasirExceptionAdvice extends ResponseEntityExceptionHandler { + + @ExceptionHandler({ConstraintViolationException.class}) + public ResponseEntity handleConstraintViolationException( + ConstraintViolationException constraintViolationException, WebRequest request) { + + String errorMsg = ""; + String path = getPath(request); + Set> violations = constraintViolationException.getConstraintViolations(); + for (ConstraintViolation item : violations) { + errorMsg = item.getMessage(); + log.warn("ConstraintViolationException, request: {}, exception: {}, invalid value: {}", + path, errorMsg, item.getInvalidValue()); + break; + } + return handleNon200Response(errorMsg, HttpStatus.BAD_REQUEST, path); + } + + @ExceptionHandler({InvalidTokenException.class}) + protected ResponseEntity handleInvalidTokenException(InvalidTokenException ex, WebRequest request) { + String path = getPath(request); + log.warn("handle InvalidTokenException " + path + ", " + ex); + JsonData data = JsonData.error(ex.getErrCode(), ex.getErrMessage()); + return handleNon200Response(ex.getMessage(), HttpStatus.UNAUTHORIZED, path, data); + } + + @ExceptionHandler({IllegalArgumentException.class}) + protected ResponseEntity handleIllegalArgument(IllegalArgumentException ex, WebRequest request) { + String path = getPath(request); + log.warn("handle illegalArgument " + path, ex); + return handleNon200Response(ex.getMessage(), HttpStatus.BAD_REQUEST, path); + } + + @ExceptionHandler({AccessDeniedException.class}) + protected ResponseEntity handleAccessDeniedException(AccessDeniedException ex, WebRequest request) { + String path = getPath(request); + log.warn("AccessDeniedException, request: {}, exception: {}", path, ex.getMessage()); + return handleNon200Response(ex.getMessage(), HttpStatus.FORBIDDEN, path); + } + + @ExceptionHandler({Forbidden.class}) + protected ResponseEntity handleForbiddenException(Forbidden ex, WebRequest request) { + String path = getPath(request); + log.warn("Forbidden, request: {}, exception: {}", path, ex.getMessage()); + return handleNon200Response(ex.getMessage(), HttpStatus.FORBIDDEN, path); + } + + @ExceptionHandler(value = DatabasirException.class) + public ResponseEntity handleBusinessException( + DatabasirException databasirException, WebRequest request) { + + String path = getPath(request); + JsonData body = JsonData.error(databasirException.getErrCode(), databasirException.getErrMessage()); + if (databasirException.getCause() == null) { + log.warn("BusinessException, request: {}, exception: {}", path, databasirException.getErrMessage()); + } else { + log.warn("BusinessException, request: " + path, databasirException); + } + return ResponseEntity.ok().body(body); + } + + @ExceptionHandler({SystemException.class}) + public ResponseEntity handleSystemException(SystemException systemException, WebRequest request) { + + String path = getPath(request); + if (systemException.getCause() != null) { + log.error("SystemException, request: " + path + + ", exception: " + systemException.getMessage() + ", caused by:", systemException.getCause()); + } else { + log.error("SystemException, request: " + path + ", exception: " + systemException.getMessage()); + } + return handleNon200Response(systemException.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, path); + } + + @ExceptionHandler({Exception.class}) + public ResponseEntity handleUnspecificException(Exception ex, WebRequest request) { + + String path = getPath(request); + String errorMsg = ex.getMessage(); + log.error("Unspecific exception, request: " + path + ", exception: " + errorMsg + ":", ex); + return handleNon200Response(errorMsg, HttpStatus.INTERNAL_SERVER_ERROR, path); + } + + @Override + public ResponseEntity handleBindException( + BindException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + String errorMsg = buildMessages(ex.getBindingResult()); + log.warn("BindException, request: {}, exception: {}", getPath(request), errorMsg); + return handleOverriddenException(ex, headers, status, request, errorMsg); + } + + @Override + public ResponseEntity handleMethodArgumentNotValid( + MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + String errorMsg = buildMessages(ex.getBindingResult()); + log.warn("MethodArgumentNotValidException, request: {}, exception: {}", getPath(request), errorMsg); + return handleOverriddenException(ex, headers, status, request, errorMsg); + } + + @Override + public ResponseEntity handleTypeMismatch( + TypeMismatchException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + log.warn("TypeMismatchException, request: {}, exception: {}", getPath(request), ex.getMessage()); + return handleOverriddenException(ex, headers, status, request, ex.getMessage()); + } + + @Override + public ResponseEntity handleMissingServletRequestParameter( + MissingServletRequestParameterException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + log.warn("MissingServletRequestParameterException, request: {}, exception: {}", + getPath(request), ex.getMessage()); + return handleOverriddenException(ex, headers, status, request, ex.getMessage()); + } + + @Override + public ResponseEntity handleMissingServletRequestPart( + MissingServletRequestPartException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + log.warn("MissingServletRequestPartException, request: {}, exception: {}", getPath(request), ex.getMessage()); + return handleOverriddenException(ex, headers, status, request, ex.getMessage()); + } + + @Override + public ResponseEntity handleHttpMessageNotReadable( + HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + String errorMsg = ex.getMostSpecificCause().getMessage(); + + log.warn("HttpMessageNotReadableException, request: {}, exception: {}", getPath(request), errorMsg); + return handleOverriddenException(ex, headers, status, request, errorMsg); + } + + @Override + public ResponseEntity handleServletRequestBindingException( + ServletRequestBindingException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + log.warn("ServletRequestBindingException, request: {}, exception: {}", getPath(request), ex.getMessage()); + return handleOverriddenException(ex, headers, status, request, ex.getMessage()); + } + + @Override + public ResponseEntity handleHttpRequestMethodNotSupported( + HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { + + String errorMsg = ex.getMessage(); + log.warn("HttpRequestMethodNotSupportedException, request: {}, exception: {}", getPath(request), errorMsg); + return handleOverriddenException(ex, headers, status, request, ex.getMessage()); + } + + @ExceptionHandler({BadCredentialsException.class}) + protected ResponseEntity handleBadCredentialsException(BadCredentialsException ex, WebRequest request) { + String path = getPath(request); + JsonData body = JsonData.error("-1", "用户名或密码错误"); + log.warn("BadCredentialsException, request: {}, exception: {}", path, ex.getMessage()); + return ResponseEntity.ok().body(body); + } + + private String buildMessages(BindingResult result) { + + StringBuilder resultBuilder = new StringBuilder(); + List errors = result.getAllErrors(); + for (ObjectError error : errors) { + if (error instanceof FieldError) { + FieldError fieldError = (FieldError) error; + String fieldName = fieldError.getField(); + String fieldErrMsg = fieldError.getDefaultMessage(); + resultBuilder.append(fieldName).append(" ").append(fieldErrMsg); + } + } + return resultBuilder.toString(); + } + + private ResponseEntity handleNon200Response(String errorMsg, HttpStatus httpStatus, String path) { + return ResponseEntity.status(httpStatus).body(null); + } + + private ResponseEntity handleNon200Response(String errorMsg, + HttpStatus httpStatus, + String path, + Object body) { + return ResponseEntity.status(httpStatus).body(body); + } + + private ResponseEntity handleOverriddenException( + Exception ex, HttpHeaders headers, HttpStatus status, WebRequest request, String errorMsg) { + return handleExceptionInternal(ex, null, headers, status, request); + } + + private String getPath(WebRequest request) { + String description = request.getDescription(false); + return description.startsWith("uri=") ? description.substring(4) : description; + } +} diff --git a/api/src/main/java/com/databasir/api/config/SecurityConfig.java b/api/src/main/java/com/databasir/api/config/SecurityConfig.java new file mode 100644 index 0000000..afc6f55 --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/SecurityConfig.java @@ -0,0 +1,75 @@ +package com.databasir.api.config; + +import com.databasir.api.Routes; +import com.databasir.api.config.security.*; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +@Configuration +@RequiredArgsConstructor +@EnableGlobalMethodSecurity(prePostEnabled = true) +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + private final DatabasirUserDetailService databasirUserDetailService; + + private final DatabasirAuthenticationEntryPoint databasirAuthenticationEntryPoint; + + private final DatabasirJwtTokenFilter databasirJwtTokenFilter; + + private final DatabasirAuthenticationFailureHandler databasirAuthenticationFailureHandler; + + private final DatabasirAuthenticationSuccessHandler databasirAuthenticationSuccessHandler; + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.headers().frameOptions().disable(); + http.csrf().disable(); + http.cors(); + + http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) + .and() + .formLogin() + .loginProcessingUrl("/login") + .failureHandler(databasirAuthenticationFailureHandler) + .successHandler(databasirAuthenticationSuccessHandler) + .and() + .authorizeRequests() + .antMatchers("/login", Routes.Login.REFRESH_ACCESS_TOKEN).permitAll() + .anyRequest().authenticated() + .and() + .exceptionHandling().authenticationEntryPoint(databasirAuthenticationEntryPoint); + + http.addFilterBefore( + databasirJwtTokenFilter, + UsernamePasswordAuthenticationFilter.class + ); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.userDetailsService(databasirUserDetailService) + .passwordEncoder(bCryptPasswordEncoder()); + } + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + @Bean + public PasswordEncoder bCryptPasswordEncoder() { + return new BCryptPasswordEncoder(); + } + +} diff --git a/api/src/main/java/com/databasir/api/config/WebConfig.java b/api/src/main/java/com/databasir/api/config/WebConfig.java new file mode 100644 index 0000000..653a4ae --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/WebConfig.java @@ -0,0 +1,18 @@ +package com.databasir.api.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.web.config.EnableSpringDataWebSupport; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +@EnableSpringDataWebSupport +public class WebConfig extends WebMvcConfigurerAdapter { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("GET", "POST", "DELETE", "PATCH", "PUT"); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationEntryPoint.java b/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationEntryPoint.java new file mode 100644 index 0000000..3238bea --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationEntryPoint.java @@ -0,0 +1,26 @@ +package com.databasir.api.config.security; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Service; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Service +@RequiredArgsConstructor +@Slf4j +public class DatabasirAuthenticationEntryPoint implements AuthenticationEntryPoint { + + @Override + public void commence(javax.servlet.http.HttpServletRequest request, + javax.servlet.http.HttpServletResponse response, + AuthenticationException authException) throws IOException, ServletException { + log.warn("验证未通过. 提示信息 - {}", authException.getMessage()); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); + } + +} diff --git a/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationFailureHandler.java b/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationFailureHandler.java new file mode 100644 index 0000000..a4fdefb --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationFailureHandler.java @@ -0,0 +1,49 @@ +package com.databasir.api.config.security; + +import com.databasir.common.JsonData; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.DisabledException; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +@Component +@RequiredArgsConstructor +public class DatabasirAuthenticationFailureHandler implements AuthenticationFailureHandler { + + private final ObjectMapper objectMapper; + + @Override + public void onAuthenticationFailure(HttpServletRequest request, + HttpServletResponse response, + AuthenticationException exception) throws IOException, ServletException { + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); + if (exception instanceof BadCredentialsException) { + JsonData data = JsonData.error("-1", "用户名或密码错误"); + String jsonString = objectMapper.writeValueAsString(data); + response.setStatus(HttpStatus.OK.value()); + response.getOutputStream().write(jsonString.getBytes(StandardCharsets.UTF_8)); + } else if (exception instanceof DisabledException) { + JsonData data = JsonData.error("-1", "用户已禁用"); + String jsonString = objectMapper.writeValueAsString(data); + response.setStatus(HttpStatus.OK.value()); + response.getOutputStream().write(jsonString.getBytes(StandardCharsets.UTF_8)); + } else { + JsonData data = JsonData.error("-1", "未登录或未授权用户"); + String jsonString = objectMapper.writeValueAsString(data); + response.setStatus(HttpStatus.UNAUTHORIZED.value()); + response.getOutputStream().write(jsonString.getBytes(StandardCharsets.UTF_8)); + } + } +} diff --git a/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationSuccessHandler.java b/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationSuccessHandler.java new file mode 100644 index 0000000..af36496 --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/security/DatabasirAuthenticationSuccessHandler.java @@ -0,0 +1,61 @@ +package com.databasir.api.config.security; + +import com.databasir.common.JsonData; +import com.databasir.core.domain.login.data.LoginKeyResponse; +import com.databasir.core.domain.login.service.LoginService; +import com.databasir.core.domain.user.data.UserLoginResponse; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.RequiredArgsConstructor; +import org.springframework.http.MediaType; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.time.ZoneId; +import java.util.List; +import java.util.stream.Collectors; + +@Component +@RequiredArgsConstructor +public class DatabasirAuthenticationSuccessHandler implements AuthenticationSuccessHandler { + + private final ObjectMapper objectMapper; + + private final LoginService loginService; + + @Override + public void onAuthenticationSuccess(HttpServletRequest request, + HttpServletResponse response, + Authentication authentication) throws IOException, ServletException { + DatabasirUserDetails user = (DatabasirUserDetails) authentication.getPrincipal(); + List roles = user.getRoles() + .stream() + .map(ur -> { + UserLoginResponse.RoleResponse data = new UserLoginResponse.RoleResponse(); + data.setRole(ur.getRole()); + data.setGroupId(ur.getGroupId()); + return data; + }) + .collect(Collectors.toList()); + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); + UserLoginResponse data = new UserLoginResponse(); + data.setId(user.getUserPojo().getId()); + data.setNickname(user.getUserPojo().getNickname()); + data.setEmail(user.getUserPojo().getEmail()); + data.setUsername(user.getUsername()); + + LoginKeyResponse loginKey = loginService.generate(user.getUserPojo().getId()); + data.setAccessToken(loginKey.getAccessToken()); + long expireAt = loginKey.getAccessTokenExpireAt().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + data.setAccessTokenExpireAt(expireAt); + data.setRefreshToken(loginKey.getRefreshToken()); + data.setRoles(roles); + objectMapper.writeValue(response.getWriter(), JsonData.ok(data)); + } +} diff --git a/api/src/main/java/com/databasir/api/config/security/DatabasirJwtTokenFilter.java b/api/src/main/java/com/databasir/api/config/security/DatabasirJwtTokenFilter.java new file mode 100644 index 0000000..057f6da --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/security/DatabasirJwtTokenFilter.java @@ -0,0 +1,56 @@ +package com.databasir.api.config.security; + +import com.databasir.core.infrastructure.jwt.JwtTokens; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +@RequiredArgsConstructor +public class DatabasirJwtTokenFilter extends OncePerRequestFilter { + + private static final String SPACE = " "; + + private final JwtTokens jwtTokens; + + private final UserDetailsService userDetailsService; + + @Override + protected void doFilterInternal(HttpServletRequest request, + HttpServletResponse response, + FilterChain filterChain) throws ServletException, IOException { + + final String header = request.getHeader(HttpHeaders.AUTHORIZATION); + if (!StringUtils.hasText(header) || !header.startsWith(JwtTokens.TOKEN_PREFIX)) { + filterChain.doFilter(request, response); + return; + } + + final String token = header.split(SPACE)[1].trim(); + if (!jwtTokens.verify(token)) { + filterChain.doFilter(request, response); + return; + } + + String username = jwtTokens.getUsername(token); + UserDetails userDetails = userDetailsService.loadUserByUsername(username); + UsernamePasswordAuthenticationToken authentication = + new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities()); + authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); + SecurityContextHolder.getContext().setAuthentication(authentication); + filterChain.doFilter(request, response); + } +} diff --git a/api/src/main/java/com/databasir/api/config/security/DatabasirUserDetailService.java b/api/src/main/java/com/databasir/api/config/security/DatabasirUserDetailService.java new file mode 100644 index 0000000..1780391 --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/security/DatabasirUserDetailService.java @@ -0,0 +1,34 @@ +package com.databasir.api.config.security; + +import com.databasir.dao.impl.LoginDao; +import com.databasir.dao.impl.UserDao; +import com.databasir.dao.impl.UserRoleDao; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.pojos.UserRolePojo; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class DatabasirUserDetailService implements UserDetailsService { + + private final UserDao userDao; + + private final UserRoleDao userRoleDao; + + private final LoginDao loginDao; + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + UserPojo user = userDao.selectByEmailOrUsername(username) + .orElseThrow(() -> new UsernameNotFoundException("用户名或密码错误")); + List roles = userRoleDao.selectByUserIds(Collections.singletonList(user.getId())); + return new DatabasirUserDetails(user, roles); + } +} diff --git a/api/src/main/java/com/databasir/api/config/security/DatabasirUserDetails.java b/api/src/main/java/com/databasir/api/config/security/DatabasirUserDetails.java new file mode 100644 index 0000000..8d8be63 --- /dev/null +++ b/api/src/main/java/com/databasir/api/config/security/DatabasirUserDetails.java @@ -0,0 +1,67 @@ +package com.databasir.api.config.security; + +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.pojos.UserRolePojo; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + + +@RequiredArgsConstructor +public class DatabasirUserDetails implements UserDetails { + + @Getter + private final UserPojo userPojo; + + @Getter + private final List roles; + + @Override + public Collection getAuthorities() { + return roles.stream() + .map(role -> { + String expression = role.getRole(); + if (role.getGroupId() != null) { + expression += "?groupId=" + role.getGroupId(); + } + return new SimpleGrantedAuthority(expression); + }) + .collect(Collectors.toList()); + } + + @Override + public String getPassword() { + return userPojo.getPassword(); + } + + @Override + public String getUsername() { + return userPojo.getEmail(); + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return userPojo.getEnabled(); + } +} diff --git a/api/src/main/java/com/databasir/api/validator/UserOperationValidator.java b/api/src/main/java/com/databasir/api/validator/UserOperationValidator.java new file mode 100644 index 0000000..0f5d60b --- /dev/null +++ b/api/src/main/java/com/databasir/api/validator/UserOperationValidator.java @@ -0,0 +1,27 @@ +package com.databasir.api.validator; + +import com.databasir.api.config.security.DatabasirUserDetails; +import com.databasir.core.domain.DomainErrors; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; + +@Component +public class UserOperationValidator { + + public void forbiddenIfUpdateSelfRole(Integer userId) { + DatabasirUserDetails principal = (DatabasirUserDetails) SecurityContextHolder.getContext() + .getAuthentication() + .getPrincipal(); + if (principal.getUserPojo().getId().equals(userId)) { + throw DomainErrors.CANNOT_UPDATE_SELF_ROLE.exception(); + } + } + + public boolean isMyself(Integer userId) { + DatabasirUserDetails principal = (DatabasirUserDetails) SecurityContextHolder.getContext() + .getAuthentication() + .getPrincipal(); + return principal.getUserPojo().getId().equals(userId); + } + +} diff --git a/api/src/main/resources/application-local.properties b/api/src/main/resources/application-local.properties new file mode 100644 index 0000000..8030a11 --- /dev/null +++ b/api/src/main/resources/application-local.properties @@ -0,0 +1,11 @@ +server.port=8080 +logging.level.org.jooq=DEBUG +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.username=root +spring.datasource.password=123456 +spring.datasource.url=jdbc:mysql://localhost:3306/databasir +spring.jooq.sql-dialect=mysql + +spring.flyway.enabled=true +spring.flyway.baseline-on-migrate=true +spring.flyway.locations=classpath:db/migration \ No newline at end of file diff --git a/api/src/main/resources/application.properties b/api/src/main/resources/application.properties new file mode 100644 index 0000000..46c78ce --- /dev/null +++ b/api/src/main/resources/application.properties @@ -0,0 +1,12 @@ +server.port=8080 +# datasource +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.username=${databasir.datasource.username} +spring.datasource.password=${databasir.datasource.password} +spring.datasource.url=jdbc:mysql://${databasir.datasource.url}/${databasir.datasource.database-name:databasir} +# jooq +spring.jooq.sql-dialect=mysql +# flyway +spring.flyway.enabled=true +spring.flyway.baseline-on-migrate=true +spring.flyway.locations=classpath:db/migration \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3b22ba6..6be041b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,38 @@ plugins { id 'java' + id 'idea' + id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.5.8' apply false + id 'nu.studer.jooq' version '6.0.1' apply false } -subprojects { +allprojects { + repositories { + mavenLocal() + mavenCentral() + } +} +subprojects { apply plugin: 'java' + apply plugin: 'idea' + apply plugin: 'io.spring.dependency-management' + apply plugin: 'org.springframework.boot' + apply plugin: 'nu.studer.jooq' group 'com.databasir' - version '1.0-SNAPSHOT' - - repositories { - mavenCentral() - } + version '1.0.0' ext { lombokVersion = '1.18.22' mapstructVersion = '1.4.2.Final' junitVersion = '5.7.0' slf4jVersion = '1.7.32' + jooqVersion = '3.15.5' + mysqlConnectorVersion = '8.0.27' + postgresqlConnectorVersion = '42.3.1' + hikariVersion = '5.0.0' + jacksonVersion = '2.13.1' } dependencies { @@ -28,10 +43,9 @@ subprojects { annotationProcessor "org.projectlombok:lombok:${lombokVersion}" implementation "org.mapstruct:mapstruct:${mapstructVersion}" - annotationProcessor "org.mapstruct:mapstruct:${mapstructVersion}" + annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}" implementation "org.slf4j:slf4j-api:${slf4jVersion}" - } test { diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..744f676 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,3 @@ +dependencies { + implementation 'org.apache.shiro:shiro-crypto-cipher:1.8.0' +} diff --git a/common/src/main/java/com/databasir/common/DatabasirErrors.java b/common/src/main/java/com/databasir/common/DatabasirErrors.java new file mode 100644 index 0000000..a269a5b --- /dev/null +++ b/common/src/main/java/com/databasir/common/DatabasirErrors.java @@ -0,0 +1,8 @@ +package com.databasir.common; + +public interface DatabasirErrors { + + String getErrCode(); + + String getErrMessage(); +} diff --git a/common/src/main/java/com/databasir/common/DatabasirException.java b/common/src/main/java/com/databasir/common/DatabasirException.java new file mode 100644 index 0000000..563fb90 --- /dev/null +++ b/common/src/main/java/com/databasir/common/DatabasirException.java @@ -0,0 +1,49 @@ +package com.databasir.common; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +public class DatabasirException extends RuntimeException { + + @Getter + private DatabasirErrors errorCodeMessage; + + @Getter + private String errCode; + + @Getter + private String errMessage; + + /** + * @param errorCodeMessage 错误信息 + */ + public DatabasirException(DatabasirErrors errorCodeMessage) { + super(errorCodeMessage.getErrMessage()); + this.errorCodeMessage = errorCodeMessage; + this.errCode = errorCodeMessage.getErrCode(); + this.errMessage = errorCodeMessage.getErrMessage(); + } + + /** + * @param errorCodeMessage 错误信息 + * @param overrideMessage 覆盖 message + */ + public DatabasirException(DatabasirErrors errorCodeMessage, String overrideMessage) { + super(overrideMessage); + this.errorCodeMessage = errorCodeMessage; + this.errCode = errorCodeMessage.getErrCode(); + this.errMessage = overrideMessage; + } + + /** + * @param errorCodeMessage 错误信息 + * @param cause root cause + */ + public DatabasirException(DatabasirErrors errorCodeMessage, Throwable cause) { + super(errorCodeMessage.getErrMessage(), cause); + this.errorCodeMessage = errorCodeMessage; + this.errCode = errorCodeMessage.getErrCode(); + this.errMessage = errorCodeMessage.getErrMessage(); + } +} diff --git a/common/src/main/java/com/databasir/common/JsonData.java b/common/src/main/java/com/databasir/common/JsonData.java new file mode 100644 index 0000000..84d11ed --- /dev/null +++ b/common/src/main/java/com/databasir/common/JsonData.java @@ -0,0 +1,39 @@ +package com.databasir.common; + +import lombok.Data; + +@Data +public class JsonData { + + /** + * maybe null + */ + private T data; + + /** + * only exists when error happened + */ + private String errCode; + + /** + * only exists when error happened + */ + private String errMessage; + + public static JsonData ok() { + return ok(null); + } + + public static JsonData ok(T data) { + JsonData jsonData = new JsonData<>(); + jsonData.setData(data); + return jsonData; + } + + public static JsonData error(String errorCode, String errMessage) { + JsonData jsonData = new JsonData<>(); + jsonData.setErrCode(errorCode); + jsonData.setErrMessage(errMessage); + return jsonData; + } +} diff --git a/common/src/main/java/com/databasir/common/SystemException.java b/common/src/main/java/com/databasir/common/SystemException.java new file mode 100644 index 0000000..678a1c8 --- /dev/null +++ b/common/src/main/java/com/databasir/common/SystemException.java @@ -0,0 +1,27 @@ +package com.databasir.common; + +public class SystemException extends RuntimeException{ + + private static final String MSG_INTERNAL_SERVER_ERROR = "服务器开小差了,请稍后再试"; + + public static final SystemException INTERNAL_SERVER_ERROR = new SystemException(MSG_INTERNAL_SERVER_ERROR); + + /** + * @param msg the detail message + */ + public SystemException(String msg) { + super(msg); + } + + /** + * @param msg the detail message + * @param cause the nested exception + */ + public SystemException(String msg, Throwable cause) { + super(msg, cause); + } + + public static SystemException internalServerErrorWithCause(Throwable cause) { + return new SystemException(MSG_INTERNAL_SERVER_ERROR, cause); + } +} diff --git a/common/src/main/java/com/databasir/common/codec/Aes.java b/common/src/main/java/com/databasir/common/codec/Aes.java new file mode 100644 index 0000000..6c4aa9d --- /dev/null +++ b/common/src/main/java/com/databasir/common/codec/Aes.java @@ -0,0 +1,36 @@ +package com.databasir.common.codec; + +import org.apache.shiro.crypto.AesCipherService; + +import java.nio.charset.StandardCharsets; +import java.security.Key; +import java.util.Base64; + +public class Aes { + + public static String encryptToBase64Data(String data, String key) { + return new AesCipherService() + .encrypt(toBytes(data), toBytes(key)) + .toBase64(); + } + + public static String decryptFromBase64Data(String encryptData, String key) { + byte[] originEncrypted = Base64.getDecoder().decode(toBytes(encryptData)); + byte[] originKey = toBytes(key); + return toString(new AesCipherService().decrypt(originEncrypted, originKey).getBytes()); + } + + public static String randomBase64Key() { + Key key = new AesCipherService().generateNewKey(); + return Base64.getEncoder().encodeToString(key.getEncoded()); + } + + private static byte[] toBytes(String data) { + return data.getBytes(StandardCharsets.UTF_8); + } + + private static String toString(byte[] bytes) { + return new String(bytes, StandardCharsets.UTF_8); + } + +} diff --git a/common/src/main/java/com/databasir/common/codec/Rsa.java b/common/src/main/java/com/databasir/common/codec/Rsa.java new file mode 100644 index 0000000..0c32499 --- /dev/null +++ b/common/src/main/java/com/databasir/common/codec/Rsa.java @@ -0,0 +1,72 @@ +package com.databasir.common.codec; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +import javax.crypto.Cipher; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.security.spec.EncodedKeySpec; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; + +public class Rsa { + + private static final String RSA = "RSA"; + + @SneakyThrows + public static String encryptToBase64DataByPublicKey(String data, String publicBase64Key) { + Cipher encryptCipher = Cipher.getInstance(RSA); + encryptCipher.init(Cipher.ENCRYPT_MODE, decodeBase64PublicKey(publicBase64Key)); + byte[] dataBytes = data.getBytes(StandardCharsets.UTF_8); + byte[] encryptedDataBytes = encryptCipher.doFinal(dataBytes); + return Base64.getEncoder().encodeToString(encryptedDataBytes); + } + + @SneakyThrows + public static String decryptFromBase64DataByPrivateKey(String data, String privateKey) { + Cipher decryptCipher = Cipher.getInstance(RSA); + decryptCipher.init(Cipher.DECRYPT_MODE, decodeBase64PrivateKey(privateKey)); + byte[] dataBytes = Base64.getDecoder().decode(data); + byte[] decryptedBytes = decryptCipher.doFinal(dataBytes); + return new String(decryptedBytes, StandardCharsets.UTF_8); + } + + @SneakyThrows + private static PublicKey decodeBase64PublicKey(String base64PublicKey) { + byte[] keyBytes = Base64.getDecoder().decode(base64PublicKey); + KeyFactory keyFactory = KeyFactory.getInstance(RSA); + EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(keyBytes); + return keyFactory.generatePublic(publicKeySpec); + } + + @SneakyThrows + private static PrivateKey decodeBase64PrivateKey(String base64PrivateKey) { + byte[] keyBytes = Base64.getDecoder().decode(base64PrivateKey); + KeyFactory keyFactory = KeyFactory.getInstance(RSA); + EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(keyBytes); + return keyFactory.generatePrivate(privateKeySpec); + } + + @SneakyThrows + public static RsaBase64Key generateBase64Key() { + KeyPairGenerator generator = KeyPairGenerator.getInstance(RSA); + generator.initialize(2048); + KeyPair keyPair = generator.generateKeyPair(); + String privateKey = Base64.getEncoder().encodeToString(keyPair.getPrivate().getEncoded()); + String publicKey = Base64.getEncoder().encodeToString(keyPair.getPublic().getEncoded()); + return new RsaBase64Key(privateKey, publicKey); + } + + @Getter + @RequiredArgsConstructor + public static class RsaBase64Key { + + private final String privateBase64Key; + + private final String publicBase64Key; + } + +} diff --git a/common/src/main/java/com/databasir/common/codec/Sha.java b/common/src/main/java/com/databasir/common/codec/Sha.java new file mode 100644 index 0000000..9473816 --- /dev/null +++ b/common/src/main/java/com/databasir/common/codec/Sha.java @@ -0,0 +1,18 @@ +package com.databasir.common.codec; + +import lombok.SneakyThrows; +import org.apache.shiro.codec.Hex; + +import java.security.MessageDigest; + +public class Sha { + + @SneakyThrows + public static String sha256(String data) { + MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); + messageDigest.update(data.getBytes()); + byte[] bytes = messageDigest.digest(); + return Hex.encodeToString(bytes); + } + +} diff --git a/common/src/main/java/com/databasir/common/exception/Forbidden.java b/common/src/main/java/com/databasir/common/exception/Forbidden.java new file mode 100644 index 0000000..9bbfdf6 --- /dev/null +++ b/common/src/main/java/com/databasir/common/exception/Forbidden.java @@ -0,0 +1,4 @@ +package com.databasir.common.exception; + +public class Forbidden extends RuntimeException{ +} diff --git a/common/src/main/java/com/databasir/common/exception/InvalidTokenException.java b/common/src/main/java/com/databasir/common/exception/InvalidTokenException.java new file mode 100644 index 0000000..e86299b --- /dev/null +++ b/common/src/main/java/com/databasir/common/exception/InvalidTokenException.java @@ -0,0 +1,24 @@ +package com.databasir.common.exception; + +import com.databasir.common.DatabasirErrors; +import com.databasir.common.DatabasirException; + +public class InvalidTokenException extends DatabasirException { + + public InvalidTokenException(DatabasirErrors errorCodeMessage) { + super(errorCodeMessage); + } + + public InvalidTokenException(DatabasirErrors errorCodeMessage, String overrideMessage) { + super(errorCodeMessage, overrideMessage); + } + + public InvalidTokenException(DatabasirErrors errorCodeMessage, Throwable cause) { + super(errorCodeMessage, cause); + } + + @Override + public String toString() { + return getErrCode() + ": " + getErrMessage(); + } +} diff --git a/common/src/test/java/com/databasir/common/codec/CodecTest.java b/common/src/test/java/com/databasir/common/codec/CodecTest.java new file mode 100644 index 0000000..ef1701c --- /dev/null +++ b/common/src/test/java/com/databasir/common/codec/CodecTest.java @@ -0,0 +1,35 @@ +package com.databasir.common.codec; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CodecTest { + + @Test + public void testAes() { + String key = Aes.randomBase64Key(); + Assertions.assertNotNull(key); + + String data = "hello world!"; + String encryptedData = Aes.encryptToBase64Data(data, key); + Assertions.assertNotNull(encryptedData); + + String decryptedData = Aes.decryptFromBase64Data(encryptedData, key); + Assertions.assertEquals(data, decryptedData); + } + + @Test + public void testRsa() { + Rsa.RsaBase64Key key = Rsa.generateBase64Key(); + Assertions.assertNotNull(key); + Assertions.assertNotNull(key.getPrivateBase64Key()); + Assertions.assertNotNull(key.getPublicBase64Key()); + + String data = "Hello world!"; + String encrypted = Rsa.encryptToBase64DataByPublicKey(data, key.getPublicBase64Key()); + Assertions.assertNotNull(encrypted); + + String decrypted = Rsa.decryptFromBase64DataByPrivateKey(encrypted, key.getPrivateBase64Key()); + Assertions.assertEquals(data, decrypted); + } +} diff --git a/core/build.gradle b/core/build.gradle index 914243b..b274cc2 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,5 +1,37 @@ +plugins { + id 'io.spring.dependency-management' + id 'org.springframework.boot' apply false +} + dependencies { - testImplementation 'mysql:mysql-connector-java:8.0.27' + // internal module + implementation project(":common") + implementation project(":dao") + implementation project(":plugin") + + // spring boot + implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-jooq' + implementation 'org.springframework.boot:spring-boot-starter-mail' + implementation 'org.springframework.boot:spring-boot-starter-security' + + // datasource + implementation "com.zaxxer:HikariCP:${hikariVersion}" + // jdbc driver + implementation "mysql:mysql-connector-java:${mysqlConnectorVersion}" + implementation "org.postgresql:postgresql:${postgresqlConnectorVersion}" + + // jackson + implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}" + implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" + + // others + implementation 'com.auth0:java-jwt:3.18.3' implementation 'org.commonmark:commonmark:0.18.1' implementation 'org.freemarker:freemarker:2.3.31' + + // test + testImplementation "mysql:mysql-connector-java:${mysqlConnectorVersion}" } + diff --git a/core/src/main/java/com/databasir/core/domain/DomainErrors.java b/core/src/main/java/com/databasir/core/domain/DomainErrors.java new file mode 100644 index 0000000..18b4483 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/DomainErrors.java @@ -0,0 +1,38 @@ +package com.databasir.core.domain; + +import com.databasir.common.DatabasirErrors; +import com.databasir.common.DatabasirException; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum DomainErrors implements DatabasirErrors { + REFRESH_TOKEN_EXPIRED("X_0001", "refresh token expired"), + ACCESS_TOKEN_REFRESH_INVALID("X_0002", "invalid refresh token operation"), + + NOT_SUPPORT_DATABASE_TYPE("A_10000", "不支持的数据库类型, 请检查项目配置"), + PROJECT_NOT_FOUND("A_10001", "项目不存在"), + DATABASE_META_NOT_FOUND("A_10002", "获取数据库信息失败"), + CONNECT_DATABASE_FAILED("A_10003", "连接数据库失败,请检查连接配置"), + GROUP_OWNER_MUST_NOT_BE_EMPTY("A_10004", "请至少指定一个分组组长"), + PASSWORD_MUST_NOT_BE_BLANK("A_10005", "密码不能为空"), + USERNAME_OR_EMAIL_DUPLICATE("A_10006", "用户名或邮箱已存在"), + USER_ROLE_DUPLICATE("A_10007", "用户角色已存在"), + PROJECT_NAME_DUPLICATE("A_10008", "项目名称已被占用"), + CANNOT_UPDATE_SELF_ROLE("A_10009", "无法对自己执行角色变更的操作"), + UPDATE_PASSWORD_CONFIRM_FAILED("A_10010", "两次密码输入不一致"), + ORIGIN_PASSWORD_NOT_CORRECT("A_10011", "原密码不正确"); + + private final String errCode; + + private final String errMessage; + + public DatabasirException exception() { + return new DatabasirException(this); + } + + public DatabasirException exception(Throwable origin) { + return new DatabasirException(this, origin); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/document/converter/BaseConverter.java b/core/src/main/java/com/databasir/core/domain/document/converter/BaseConverter.java new file mode 100644 index 0000000..7190117 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/converter/BaseConverter.java @@ -0,0 +1,9 @@ +package com.databasir.core.domain.document.converter; + +public interface BaseConverter { + + @NullToEmpty + default String nullToEmpty(String s) { + return s == null ? "" : s; + } +} diff --git a/core/src/main/java/com/databasir/core/domain/document/converter/DocumentHistoryPojoConverter.java b/core/src/main/java/com/databasir/core/domain/document/converter/DocumentHistoryPojoConverter.java new file mode 100644 index 0000000..ca60d4a --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/converter/DocumentHistoryPojoConverter.java @@ -0,0 +1,20 @@ +package com.databasir.core.domain.document.converter; + +import com.databasir.core.domain.document.data.DatabaseDocumentResponse; +import com.databasir.core.infrastructure.converter.JsonConverter; +import com.databasir.dao.tables.pojos.DatabaseDocumentHistoryPojo; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +@Mapper(componentModel = "spring", uses = JsonConverter.class, unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DocumentHistoryPojoConverter { + + @Mapping(target = "databaseDocumentObject", source = "databaseMetaObject") + @Mapping(target = "id", ignore = true) + @Mapping(target = "createAt", ignore = true) + DatabaseDocumentHistoryPojo of(DatabaseDocumentResponse databaseMetaObject, + Integer projectId, + Integer databaseDocumentId, + Long version); +} diff --git a/core/src/main/java/com/databasir/core/domain/document/converter/DocumentPojoConverter.java b/core/src/main/java/com/databasir/core/domain/document/converter/DocumentPojoConverter.java new file mode 100644 index 0000000..d4c562f --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/converter/DocumentPojoConverter.java @@ -0,0 +1,74 @@ +package com.databasir.core.domain.document.converter; + +import com.databasir.core.infrastructure.converter.JsonConverter; +import com.databasir.core.meta.data.ColumnMeta; +import com.databasir.core.meta.data.IndexMeta; +import com.databasir.core.meta.data.TriggerMeta; +import com.databasir.dao.tables.pojos.*; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +import java.util.List; +import java.util.stream.Collectors; + +@Mapper(componentModel = "spring", uses = JsonConverter.class, unmappedTargetPolicy = ReportingPolicy.WARN) +public interface DocumentPojoConverter extends BaseConverter { + + @Mapping(target = "databaseName", source = "meta.databaseName") + DatabaseDocumentPojo toDatabasePojo(Integer projectId, + com.databasir.core.meta.data.DatabaseMeta meta, + Long version); + + @Mapping(target = "databaseName", source = "meta.databaseName") + DatabaseDocumentPojo toDatabasePojo(Integer projectId, + com.databasir.core.meta.data.DatabaseMeta meta, + Integer id, + Long version); + + @Mapping(target = "comment", qualifiedBy = NullToEmpty.class) + TableDocumentPojo toTablePojo(Integer databaseDocumentId, + com.databasir.core.meta.data.TableMeta meta); + + default List toColumnPojo(Integer databaseDocumentId, + Integer tableDocumentId, + List metaList) { + return metaList.stream() + .map(meta -> toColumnPojo(databaseDocumentId, tableDocumentId, meta)) + .collect(Collectors.toList()); + } + + @Mapping(target = "comment", qualifiedBy = NullToEmpty.class) + TableColumnDocumentPojo toColumnPojo(Integer databaseDocumentId, + Integer tableDocumentId, + ColumnMeta meta); + + default List toIndexPojo(Integer databaseDocumentId, + Integer tableDocumentId, + List metaList) { + return metaList.stream() + .map(meta -> toIndexPojo(databaseDocumentId, tableDocumentId, meta)) + .collect(Collectors.toList()); + } + + @Mapping(target = "isPrimary", source = "meta.isPrimaryKey") + @Mapping(target = "isUnique", source = "meta.isUniqueKey") + @Mapping(target = "columnNameArray", source = "meta.columnNames") + TableIndexDocumentPojo toIndexPojo(Integer databaseDocumentId, + Integer tableDocumentId, + IndexMeta meta); + + default List toTriggerPojo(Integer databaseDocumentId, + Integer tableDocumentId, + List metaList) { + return metaList.stream() + .map(meta -> toTriggerPojo(databaseDocumentId, tableDocumentId, meta)) + .collect(Collectors.toList()); + } + + @Mapping(target = "triggerCreateAt", source = "meta.createAt") + TableTriggerDocumentPojo toTriggerPojo(Integer databaseDocumentId, + Integer tableDocumentId, + TriggerMeta meta); + +} diff --git a/core/src/main/java/com/databasir/core/domain/document/converter/DocumentResponseConverter.java b/core/src/main/java/com/databasir/core/domain/document/converter/DocumentResponseConverter.java new file mode 100644 index 0000000..aeef3bb --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/converter/DocumentResponseConverter.java @@ -0,0 +1,31 @@ +package com.databasir.core.domain.document.converter; + +import com.databasir.core.domain.document.data.DatabaseDocumentResponse; +import com.databasir.core.infrastructure.converter.JsonConverter; +import com.databasir.dao.tables.pojos.*; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +import java.util.List; + +@Mapper(componentModel = "spring", uses = JsonConverter.class, unmappedTargetPolicy = ReportingPolicy.WARN) +public interface DocumentResponseConverter { + + @Mapping(target = "columns", source = "columns") + @Mapping(target = "indexes", source = "indexes") + @Mapping(target = "triggers", source = "triggers") + DatabaseDocumentResponse.TableDocumentResponse of(TableDocumentPojo tableDocument, + List columns, + List indexes, + List triggers); + + @Mapping(target = "columnNames", source = "columnNameArray") + DatabaseDocumentResponse.TableDocumentResponse.IndexDocumentResponse of(TableIndexDocumentPojo indexDocument); + + @Mapping(target = "id", source = "databaseDocument.id") + @Mapping(target = "createAt", source = "databaseDocument.createAt") + @Mapping(target = "documentVersion", source = "databaseDocument.version") + DatabaseDocumentResponse of(DatabaseDocumentPojo databaseDocument, + List tables); +} diff --git a/core/src/main/java/com/databasir/core/domain/document/converter/NullToEmpty.java b/core/src/main/java/com/databasir/core/domain/document/converter/NullToEmpty.java new file mode 100644 index 0000000..e0eaa6e --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/converter/NullToEmpty.java @@ -0,0 +1,14 @@ +package com.databasir.core.domain.document.converter; + +import org.mapstruct.Qualifier; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Qualifier +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +public @interface NullToEmpty { +} diff --git a/core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentResponse.java b/core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentResponse.java new file mode 100644 index 0000000..0afe0f1 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentResponse.java @@ -0,0 +1,125 @@ +package com.databasir.core.domain.document.data; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DatabaseDocumentResponse { + + private Integer id; + + private String databaseName; + + private String productName; + + private String productVersion; + + private Integer documentVersion; + + @Builder.Default + private List tables = new ArrayList<>(); + + private LocalDateTime createAt; + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder + public static class TableDocumentResponse { + + private Integer id; + + private String name; + + private String type; + + private String comment; + + @Builder.Default + private List columns = new ArrayList<>(); + + @Builder.Default + private List indexes = new ArrayList<>(); + + @Builder.Default + private List triggers = new ArrayList<>(); + + private LocalDateTime createAt; + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder + public static class ColumnDocumentResponse { + private Integer id; + + private String name; + + private String type; + + private Integer size; + + private Integer decimalDigits; + + private String comment; + + private String nullable; + + private String autoIncrement; + + private String defaultValue; + + private LocalDateTime createAt; + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder + public static class IndexDocumentResponse { + + private Integer id; + + private String name; + + private Boolean isPrimary; + + private Boolean isUnique; + + @Builder.Default + private List columnNames = new ArrayList<>(); + + private LocalDateTime createAt; + } + + @Data + @NoArgsConstructor + @AllArgsConstructor + @Builder + public static class TriggerDocumentResponse { + + private Integer id; + + private String name; + + private String timing; + + private String manipulation; + + private String statement; + + private String triggerCreateAt; + + private LocalDateTime createAt; + } + } +} diff --git a/core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentVersionResponse.java b/core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentVersionResponse.java new file mode 100644 index 0000000..a148f38 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/data/DatabaseDocumentVersionResponse.java @@ -0,0 +1,20 @@ +package com.databasir.core.domain.document.data; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DatabaseDocumentVersionResponse { + + private Long version; + + private LocalDateTime createAt; + +} diff --git a/core/src/main/java/com/databasir/core/domain/document/service/DocumentService.java b/core/src/main/java/com/databasir/core/domain/document/service/DocumentService.java new file mode 100644 index 0000000..c9726ed --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/document/service/DocumentService.java @@ -0,0 +1,186 @@ +package com.databasir.core.domain.document.service; + +import com.databasir.core.Databasir; +import com.databasir.core.DatabasirConfig; +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.document.converter.DocumentHistoryPojoConverter; +import com.databasir.core.domain.document.converter.DocumentPojoConverter; +import com.databasir.core.domain.document.converter.DocumentResponseConverter; +import com.databasir.core.domain.document.data.DatabaseDocumentResponse; +import com.databasir.core.domain.document.data.DatabaseDocumentVersionResponse; +import com.databasir.core.infrastructure.connection.DatabaseConnectionService; +import com.databasir.core.infrastructure.converter.JsonConverter; +import com.databasir.core.meta.data.DatabaseMeta; +import com.databasir.dao.impl.*; +import com.databasir.dao.tables.pojos.*; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Connection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +@Slf4j +public class DocumentService { + + private final ProjectDao projectDao; + + private final ProjectSyncRuleDao projectSyncRuleDao; + + private final DataSourceDao dataSourceDao; + + private final DataSourcePropertyDao dataSourcePropertyDao; + + private final SysKeyDao sysKeyDao; + + private final DatabaseConnectionService databaseConnectionService; + + private final DatabaseDocumentDao databaseDocumentDao; + + private final TableDocumentDao tableDocumentDao; + + private final TableColumnDocumentDao tableColumnDocumentDao; + + private final TableIndexDocumentDao tableIndexDocumentDao; + + private final TableTriggerDocumentDao tableTriggerDocumentDao; + + private final DatabaseDocumentHistoryDao databaseDocumentHistoryDao; + + private final DocumentPojoConverter documentPojoConverter; + + private final DocumentResponseConverter documentResponseConverter; + + private final DocumentHistoryPojoConverter documentHistoryPojoConverter; + + private final JsonConverter jsonConverter; + + @Transactional + public void syncByProjectId(Integer projectId) { + ProjectPojo project = projectDao.selectOptionalById(projectId) + .orElseThrow(DomainErrors.PROJECT_NOT_FOUND::exception); + DatabaseMeta meta = retrieveDatabaseMeta(projectId); + Optional historyDocumentOpt = databaseDocumentDao.selectOptionalByProjectId(projectId); + if (historyDocumentOpt.isPresent()) { + DatabaseDocumentPojo historyDocument = historyDocumentOpt.get(); + Integer previousDocumentId = historyDocument.getId(); + saveAsHistory(historyDocument); + deleteDeprecatedDocument(previousDocumentId); + saveNewDocument(meta, historyDocument.getVersion() + 1, historyDocument.getProjectId(), previousDocumentId); + } else { + saveNewDocument(meta, 1L, projectId, null); + } + } + + private DatabaseMeta retrieveDatabaseMeta(Integer projectId) { + ProjectSyncRulePojo rule = projectSyncRuleDao.selectByProjectId(projectId); + DataSourcePojo dataSource = dataSourceDao.selectByProjectId(projectId); + List properties = dataSourcePropertyDao.selectByDataSourceId(dataSource.getId()); + Connection jdbcConnection = databaseConnectionService.create(dataSource, properties); + DatabasirConfig databasirConfig = new DatabasirConfig(); + databasirConfig.setIgnoreTableNameRegex(jsonConverter.fromJson(rule.getIgnoreTableNameRegexArray())); + databasirConfig.setIgnoreTableColumnNameRegex(jsonConverter.fromJson(rule.getIgnoreColumnNameRegexArray())); + return Databasir.of(databasirConfig) + .get(jdbcConnection, dataSource.getDatabaseName()) + .orElseThrow(DomainErrors.DATABASE_META_NOT_FOUND::exception); + } + + private void saveAsHistory(DatabaseDocumentPojo databaseDocument) { + // save history + Integer projectId = databaseDocument.getProjectId(); + Integer databaseMetaId = databaseDocument.getId(); + DatabaseDocumentResponse databaseDocumentResponse = getOneByProjectId(projectId, null).orElse(null); + Long currVersion = databaseDocument.getVersion(); + DatabaseDocumentHistoryPojo documentHistoryPojo = + documentHistoryPojoConverter.of(databaseDocumentResponse, projectId, databaseMetaId, currVersion); + databaseDocumentHistoryDao.insertAndReturnId(documentHistoryPojo); + log.info("save old meta info to history success"); + } + + private void deleteDeprecatedDocument(Integer databaseDocumentId) { + // delete old meta info + tableDocumentDao.deleteByDatabaseDocumentId(databaseDocumentId); + tableColumnDocumentDao.deleteByDatabaseDocumentId(databaseDocumentId); + tableIndexDocumentDao.deleteByDatabaseMetaId(databaseDocumentId); + tableTriggerDocumentDao.deleteByDatabaseDocumentId(databaseDocumentId); + log.info("delete old meta info success"); + } + + private void saveNewDocument(DatabaseMeta meta, + Long version, + Integer projectId, + Integer databaseDocumentId) { + + Integer currentDatabaseDocumentId = databaseDocumentId; + if (databaseDocumentId == null) { + currentDatabaseDocumentId = + databaseDocumentDao.insertAndReturnId(documentPojoConverter.toDatabasePojo(projectId, meta, 1L)); + } else { + databaseDocumentDao.update(documentPojoConverter.toDatabasePojo(projectId, meta, databaseDocumentId, version)); + } + + final Integer docId = currentDatabaseDocumentId; + meta.getTables().forEach(table -> { + TableDocumentPojo tableMeta = + documentPojoConverter.toTablePojo(docId, table); + Integer tableMetaId = tableDocumentDao.insertAndReturnId(tableMeta); + List tableColumnMetas = documentPojoConverter.toColumnPojo(docId, tableMetaId, table.getColumns()); + tableColumnDocumentDao.batchInsert(tableColumnMetas); + List tableIndexMetas = documentPojoConverter.toIndexPojo(docId, tableMetaId, table.getIndexes()); + tableIndexDocumentDao.batchInsert(tableIndexMetas); + List tableTriggerMetas = documentPojoConverter.toTriggerPojo(docId, tableMetaId, table.getTriggers()); + tableTriggerDocumentDao.batchInsert(tableTriggerMetas); + }); + log.info("save new meta info success"); + } + + public Optional getOneByProjectId(Integer projectId, Long version) { + if (version == null) { + return databaseDocumentDao.selectOptionalByProjectId(projectId) + .map(document -> { + Integer id = document.getId(); + List tables = tableDocumentDao.selectByDatabaseDocumentId(id); + List columns = tableColumnDocumentDao.selectByDatabaseDocumentId(id); + List indexes = tableIndexDocumentDao.selectByDatabaseMetaId(id); + List triggers = tableTriggerDocumentDao.selectByDatabaseDocumentId(id); + Map> columnsGroupByTableMetaId = columns.stream() + .collect(Collectors.groupingBy(TableColumnDocumentPojo::getTableDocumentId)); + Map> indexesGroupByTableMetaId = indexes.stream() + .collect(Collectors.groupingBy(TableIndexDocumentPojo::getTableDocumentId)); + Map> triggersGroupByTableMetaId = triggers.stream() + .collect(Collectors.groupingBy(TableTriggerDocumentPojo::getTableDocumentId)); + List tableDocumentResponseList = tables.stream() + .map(table -> { + List subColumns = columnsGroupByTableMetaId.getOrDefault(table.getId(), Collections.emptyList()); + List subIndexes = indexesGroupByTableMetaId.getOrDefault(table.getId(), Collections.emptyList()); + List subTriggers = triggersGroupByTableMetaId.getOrDefault(table.getId(), Collections.emptyList()); + return documentResponseConverter.of(table, subColumns, subIndexes, subTriggers); + }) + .collect(Collectors.toList()); + return documentResponseConverter.of(document, tableDocumentResponseList); + }); + } else { + return databaseDocumentHistoryDao.selectOptionalByProjectIdAndVersion(projectId, version) + .map(obj -> jsonConverter.of(obj.getDatabaseDocumentObject())); + } + } + + public Page getVersionsBySchemaSourceId(Integer projectId, Pageable page) { + return databaseDocumentDao.selectOptionalByProjectId(projectId) + .map(schemaMeta -> databaseDocumentHistoryDao.selectPageByDatabaseDocumentId(page, schemaMeta.getId()) + .map(history -> DatabaseDocumentVersionResponse.builder() + .version(history.getVersion()) + .createAt(history.getCreateAt()) + .build())) + .orElseGet(Page::empty); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/group/converter/GroupPojoConverter.java b/core/src/main/java/com/databasir/core/domain/group/converter/GroupPojoConverter.java new file mode 100644 index 0000000..215a993 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/converter/GroupPojoConverter.java @@ -0,0 +1,14 @@ +package com.databasir.core.domain.group.converter; + +import com.databasir.core.domain.group.data.GroupCreateRequest; +import com.databasir.core.domain.group.data.GroupUpdateRequest; +import com.databasir.dao.tables.pojos.GroupPojo; +import org.mapstruct.Mapper; + +@Mapper(componentModel = "spring") +public interface GroupPojoConverter { + + GroupPojo of(GroupCreateRequest groupCreateRequest); + + GroupPojo of(GroupUpdateRequest groupUpdateRequest); +} diff --git a/core/src/main/java/com/databasir/core/domain/group/converter/GroupResponseConverter.java b/core/src/main/java/com/databasir/core/domain/group/converter/GroupResponseConverter.java new file mode 100644 index 0000000..da2700f --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/converter/GroupResponseConverter.java @@ -0,0 +1,39 @@ +package com.databasir.core.domain.group.converter; + +import com.databasir.core.domain.group.data.GroupMemberPageResponse; +import com.databasir.core.domain.group.data.GroupPageResponse; +import com.databasir.core.domain.group.data.GroupResponse; +import com.databasir.dao.tables.pojos.GroupPojo; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.value.GroupMemberDetailPojo; +import org.mapstruct.Mapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Mapper(componentModel = "spring") +public interface GroupResponseConverter { + + default List toResponse(List pojos, + Map> groupOwnerGroupByGroupId, + Map projectCountMapByGroupId) { + return pojos.stream() + .map(group -> { + Integer groupId = group.getId(); + List owners = groupOwnerGroupByGroupId.getOrDefault(groupId, new ArrayList<>()); + Integer projectCount = projectCountMapByGroupId.getOrDefault(groupId, 0); + return toResponse(group, owners, projectCount); + }) + .collect(Collectors.toList()); + } + + GroupPageResponse toResponse(GroupPojo groupPojo, + List groupOwnerNames, + Integer projectCount); + + GroupResponse toResponse(GroupPojo groupPojo, List groupOwners); + + GroupMemberPageResponse toResponse(GroupMemberDetailPojo data); +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupCreateRequest.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupCreateRequest.java new file mode 100644 index 0000000..30ff2cd --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupCreateRequest.java @@ -0,0 +1,24 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; + +@Data +public class GroupCreateRequest { + + @NotBlank + private String name; + + @NotBlank + private String description; + + @NotEmpty + @Size(min = 1, max = 20, message = "一个分组的组长最多为 20 人,最少为 1 人") + private List groupOwnerUserIds = new ArrayList<>(); + +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberCreateRequest.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberCreateRequest.java new file mode 100644 index 0000000..8284d4a --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberCreateRequest.java @@ -0,0 +1,12 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +@Data +public class GroupMemberCreateRequest { + + private Integer userId; + + private String role; + +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberPageCondition.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberPageCondition.java new file mode 100644 index 0000000..5c32436 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberPageCondition.java @@ -0,0 +1,32 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; +import org.jooq.Condition; +import org.jooq.impl.DSL; + +import java.util.ArrayList; +import java.util.List; + +import static com.databasir.dao.Tables.USER; +import static com.databasir.dao.Tables.USER_ROLE; + +@Data +public class GroupMemberPageCondition { + + private String role; + + private String nicknameOrUsernameOrEmailContains; + + public Condition toCondition() { + List conditions = new ArrayList<>(); + if (role != null) { + conditions.add(USER_ROLE.ROLE.eq(role)); + } + if (nicknameOrUsernameOrEmailContains != null) { + conditions.add(USER.USERNAME.contains(nicknameOrUsernameOrEmailContains) + .or(USER.NICKNAME.contains(nicknameOrUsernameOrEmailContains)) + .or(USER.EMAIL.contains(nicknameOrUsernameOrEmailContains))); + } + return conditions.stream().reduce(Condition::and).orElse(DSL.trueCondition()); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberPageResponse.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberPageResponse.java new file mode 100644 index 0000000..07216f5 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberPageResponse.java @@ -0,0 +1,21 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class GroupMemberPageResponse { + + private Integer userId; + + private String role; + + private String username; + + private String nickname; + + private String email; + + private LocalDateTime createAt; +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberRoleUpdateRequest.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberRoleUpdateRequest.java new file mode 100644 index 0000000..46f43df --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupMemberRoleUpdateRequest.java @@ -0,0 +1,14 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +@Data +public class GroupMemberRoleUpdateRequest { + + @NotBlank + private String role; + +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupPageCondition.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupPageCondition.java new file mode 100644 index 0000000..089f7e7 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupPageCondition.java @@ -0,0 +1,19 @@ +package com.databasir.core.domain.group.data; + +import com.databasir.dao.Tables; +import lombok.Data; +import org.jooq.Condition; +import org.jooq.impl.DSL; + +@Data +public class GroupPageCondition { + + private String groupNameContains; + + public Condition toCondition() { + if (groupNameContains != null) { + return Tables.GROUP.NAME.contains(groupNameContains); + } + return DSL.trueCondition(); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupPageResponse.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupPageResponse.java new file mode 100644 index 0000000..016b77d --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupPageResponse.java @@ -0,0 +1,20 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +import java.util.List; + +@Data +public class GroupPageResponse { + + private Integer id; + + private String name; + + private String description; + + private List groupOwnerNames; + + private Integer projectCount; + +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupResponse.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupResponse.java new file mode 100644 index 0000000..b9e1579 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupResponse.java @@ -0,0 +1,34 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +public class GroupResponse { + + private Integer id; + + private String name; + + private String description; + + private List groupOwners = new ArrayList<>(); + + private LocalDateTime updateAt; + + private LocalDateTime createAt; + + @Data + public static class GroupOwnerResponse { + + private Integer id; + + private String nickname; + + private String email; + + } +} diff --git a/core/src/main/java/com/databasir/core/domain/group/data/GroupUpdateRequest.java b/core/src/main/java/com/databasir/core/domain/group/data/GroupUpdateRequest.java new file mode 100644 index 0000000..08b9827 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/data/GroupUpdateRequest.java @@ -0,0 +1,26 @@ +package com.databasir.core.domain.group.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Data +public class GroupUpdateRequest { + + @NotNull + private Integer id; + + @NotBlank + private String name; + + @NotBlank + private String description; + + @NotEmpty + private List groupOwnerUserIds = new ArrayList<>(); + +} diff --git a/core/src/main/java/com/databasir/core/domain/group/service/GroupService.java b/core/src/main/java/com/databasir/core/domain/group/service/GroupService.java new file mode 100644 index 0000000..8794f2c --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/group/service/GroupService.java @@ -0,0 +1,146 @@ +package com.databasir.core.domain.group.service; + +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.group.converter.GroupPojoConverter; +import com.databasir.core.domain.group.converter.GroupResponseConverter; +import com.databasir.core.domain.group.data.*; +import com.databasir.dao.impl.GroupDao; +import com.databasir.dao.impl.ProjectDao; +import com.databasir.dao.impl.UserDao; +import com.databasir.dao.impl.UserRoleDao; +import com.databasir.dao.tables.pojos.GroupPojo; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.pojos.UserRolePojo; +import com.databasir.dao.value.GroupMemberSimplePojo; +import com.databasir.dao.value.GroupProjectCountPojo; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class GroupService { + + private final GroupDao groupDao; + + private final UserDao userDao; + + private final UserRoleDao userRoleDao; + + private final ProjectDao projectDao; + + private final GroupPojoConverter groupPojoConverter; + + private final GroupResponseConverter groupResponseConverter; + + @Transactional + public void create(GroupCreateRequest request) { + GroupPojo groupPojo = groupPojoConverter.of(request); + Integer groupId = groupDao.insertAndReturnId(groupPojo); + List roles = request.getGroupOwnerUserIds() + .stream() + .map(userId -> { + UserRolePojo role = new UserRolePojo(); + role.setUserId(userId); + role.setRole("GROUP_OWNER"); + role.setGroupId(groupId); + return role; + }) + .collect(Collectors.toList()); + userRoleDao.batchInsert(roles); + } + + @Transactional + public void update(GroupUpdateRequest request) { + GroupPojo groupPojo = groupPojoConverter.of(request); + groupDao.updateById(groupPojo); + userRoleDao.deleteByRoleAndGroupId("GROUP_OWNER", groupPojo.getId()); + List roles = request.getGroupOwnerUserIds() + .stream() + .map(userId -> { + UserRolePojo role = new UserRolePojo(); + role.setUserId(userId); + role.setRole("GROUP_OWNER"); + role.setGroupId(groupPojo.getId()); + return role; + }) + .collect(Collectors.toList()); + userRoleDao.batchInsert(roles); + } + + public void delete(Integer groupId) { + groupDao.deleteById(groupId); + userRoleDao.deleteByGroupId(groupId); + } + + public Page list(Pageable pageable, GroupPageCondition condition) { + Page page = groupDao.selectByPage(pageable, condition.toCondition()); + List groupIdList = page.getContent() + .stream() + .map(GroupPojo::getId) + .collect(Collectors.toList()); + Map> ownersGroupByGroupId = userRoleDao.selectOwnerNamesByGroupIdIn(groupIdList) + .stream() + .collect(Collectors.groupingBy(GroupMemberSimplePojo::getGroupId)); + Map projectCountMapByGroupId = projectDao.selectCountByGroupIds(groupIdList) + .stream() + .collect(Collectors.toMap(GroupProjectCountPojo::getGroupId, v -> v)); + return page.map(groupPojo -> { + Integer groupId = groupPojo.getId(); + List owners = ownersGroupByGroupId.getOrDefault(groupId, new ArrayList<>()) + .stream() + .map(GroupMemberSimplePojo::getNickname) + .collect(Collectors.toList()); + GroupProjectCountPojo countPojo = projectCountMapByGroupId.get(groupId); + Integer projectCount = countPojo == null ? 0 : countPojo.getCount(); + return groupResponseConverter.toResponse(groupPojo, owners, projectCount); + }); + } + + public Page listGroupMembers(Integer groupId, + Pageable pageable, + GroupMemberPageCondition condition) { + return userDao.selectGroupMembers(groupId, pageable, condition.toCondition()) + .map(groupResponseConverter::toResponse); + } + + public GroupResponse get(Integer groupId) { + GroupPojo groupPojo = groupDao.selectById(groupId); + List users = userDao.selectLimitUsersByRoleAndGroup(groupId, "GROUP_OWNER", 50); + return groupResponseConverter.toResponse(groupPojo, users); + } + + public void removeMember(Integer groupId, Integer userId) { + userRoleDao.deleteByUserIdAndGroupId(userId, groupId); + } + + public void addMember(Integer groupId, GroupMemberCreateRequest request) { + if (userRoleDao.hasRole(request.getUserId(), groupId)) { + throw DomainErrors.USER_ROLE_DUPLICATE.exception(); + } + UserRolePojo pojo = new UserRolePojo(); + pojo.setGroupId(groupId); + pojo.setUserId(request.getUserId()); + pojo.setRole(request.getRole()); + userRoleDao.insertAndReturnId(pojo); + } + + public void changeMemberRole(Integer groupId, Integer userId, String role) { + if (!userRoleDao.hasRole(userId, groupId, role)) { + // TODO 最多 20 个组长 + userRoleDao.deleteByUserIdAndGroupId(userId, groupId); + UserRolePojo pojo = new UserRolePojo(); + pojo.setUserId(userId); + pojo.setGroupId(groupId); + pojo.setRole(role); + userRoleDao.insertAndReturnId(pojo); + } + } +} diff --git a/core/src/main/java/com/databasir/core/domain/login/data/AccessTokenRefreshRequest.java b/core/src/main/java/com/databasir/core/domain/login/data/AccessTokenRefreshRequest.java new file mode 100644 index 0000000..6dd79be --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/login/data/AccessTokenRefreshRequest.java @@ -0,0 +1,13 @@ +package com.databasir.core.domain.login.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class AccessTokenRefreshRequest { + + @NotBlank + private String refreshToken; + +} diff --git a/core/src/main/java/com/databasir/core/domain/login/data/AccessTokenRefreshResponse.java b/core/src/main/java/com/databasir/core/domain/login/data/AccessTokenRefreshResponse.java new file mode 100644 index 0000000..206d1d0 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/login/data/AccessTokenRefreshResponse.java @@ -0,0 +1,15 @@ +package com.databasir.core.domain.login.data; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AccessTokenRefreshResponse { + + private String accessToken; + + private Long accessTokenExpireAt; +} diff --git a/core/src/main/java/com/databasir/core/domain/login/data/LoginKeyResponse.java b/core/src/main/java/com/databasir/core/domain/login/data/LoginKeyResponse.java new file mode 100644 index 0000000..0beb242 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/login/data/LoginKeyResponse.java @@ -0,0 +1,31 @@ +package com.databasir.core.domain.login.data; + +import lombok.*; + +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@EqualsAndHashCode +public class LoginKeyResponse { + + private Integer userId; + + private String accessToken; + + private LocalDateTime accessTokenExpireAt; + + private String refreshToken; + + private LocalDateTime refreshTokenExpireAt; + + public boolean accessTokenIsExpired() { + return accessTokenExpireAt.isBefore(LocalDateTime.now()); + } + + public boolean refreshTokenIsExpired() { + return refreshTokenExpireAt.isBefore(LocalDateTime.now()); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/login/service/LoginService.java b/core/src/main/java/com/databasir/core/domain/login/service/LoginService.java new file mode 100644 index 0000000..39f1300 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/login/service/LoginService.java @@ -0,0 +1,88 @@ +package com.databasir.core.domain.login.service; + +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.login.data.AccessTokenRefreshRequest; +import com.databasir.core.domain.login.data.AccessTokenRefreshResponse; +import com.databasir.core.domain.login.data.LoginKeyResponse; +import com.databasir.core.infrastructure.jwt.JwtTokens; +import com.databasir.dao.impl.LoginDao; +import com.databasir.dao.impl.UserDao; +import com.databasir.dao.tables.pojos.LoginPojo; +import com.databasir.dao.tables.pojos.UserPojo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Optional; +import java.util.UUID; + +@Service +@RequiredArgsConstructor +@Slf4j +public class LoginService { + + private final LoginDao loginDao; + + private final UserDao userDao; + + private final JwtTokens jwtTokens; + + public AccessTokenRefreshResponse refreshAccessTokens(AccessTokenRefreshRequest request) { + LoginPojo login = loginDao.selectByRefreshToken(request.getRefreshToken()) + .orElseThrow(DomainErrors.ACCESS_TOKEN_REFRESH_INVALID::exception); + // refresh-token 已过期 + if (login.getRefreshTokenExpireAt().isBefore(LocalDateTime.now())) { + throw DomainErrors.REFRESH_TOKEN_EXPIRED.exception(); + } + // access-token 未过期就开始刷新有可能是 refresh-token 泄露了,删除 refresh-token + if (login.getAccessTokenExpireAt().isAfter(LocalDateTime.now())) { + log.warn("invalid access token refresh operation: request = {}, login = {}", request, login); + loginDao.deleteByUserId(login.getUserId()); + throw DomainErrors.ACCESS_TOKEN_REFRESH_INVALID.exception(); + } + UserPojo user = userDao.selectById(login.getUserId()); + String accessToken = jwtTokens.accessToken(user.getEmail()); + LocalDateTime accessTokenExpireAt = jwtTokens.expireAt(accessToken); + loginDao.updateAccessToken(accessToken, accessTokenExpireAt, user.getId()); + Instant instant = accessTokenExpireAt.atZone(ZoneId.systemDefault()).toInstant(); + long accessTokenExpireAtMilli = instant.toEpochMilli(); + return new AccessTokenRefreshResponse(accessToken, accessTokenExpireAtMilli); + } + + public Optional getLoginKey(Integer userId) { + return loginDao.selectByUserId(userId) + .map(loginPojo -> LoginKeyResponse.builder() + .accessToken(loginPojo.getAccessToken()) + .accessTokenExpireAt(loginPojo.getAccessTokenExpireAt()) + .refreshToken(loginPojo.getRefreshToken()) + .refreshTokenExpireAt(loginPojo.getRefreshTokenExpireAt()) + .build()); + } + + public LoginKeyResponse generate(Integer userId) { + UserPojo user = userDao.selectById(userId); + String accessToken = jwtTokens.accessToken(user.getEmail()); + LocalDateTime accessTokenExpireAt = jwtTokens.expireAt(accessToken); + String refreshToken = UUID.randomUUID().toString().replace("-", ""); + LocalDateTime refreshTokenExpireAt = LocalDateTime.now().plusDays(15); + + LoginPojo loginPojo = new LoginPojo(); + loginPojo.setAccessToken(accessToken); + loginPojo.setAccessTokenExpireAt(accessTokenExpireAt); + loginPojo.setRefreshToken(refreshToken); + loginPojo.setRefreshTokenExpireAt(refreshTokenExpireAt); + loginPojo.setUserId(userId); + loginDao.insertOnDuplicateKeyUpdate(loginPojo); + + return LoginKeyResponse.builder() + .userId(userId) + .accessToken(accessToken) + .accessTokenExpireAt(accessTokenExpireAt) + .refreshToken(refreshToken) + .refreshTokenExpireAt(refreshTokenExpireAt) + .build(); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/project/converter/DataSourcePojoConverter.java b/core/src/main/java/com/databasir/core/domain/project/converter/DataSourcePojoConverter.java new file mode 100644 index 0000000..0f1cd83 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/converter/DataSourcePojoConverter.java @@ -0,0 +1,41 @@ +package com.databasir.core.domain.project.converter; + +import com.databasir.core.domain.project.data.DataSourcePropertyValue; +import com.databasir.core.domain.project.data.ProjectCreateRequest; +import com.databasir.core.domain.project.data.ProjectUpdateRequest; +import com.databasir.dao.tables.pojos.DataSourcePojo; +import com.databasir.dao.tables.pojos.DataSourcePropertyPojo; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +import java.util.List; +import java.util.stream.Collectors; + +@Mapper(componentModel = "spring") +public interface DataSourcePojoConverter { + + @Mapping(target = "id", ignore = true) + @Mapping(target = "createAt", ignore = true) + @Mapping(target = "updateAt", ignore = true) + @Mapping(target = "password", source = "password") + DataSourcePojo of(ProjectCreateRequest.DataSourceCreateRequest request, + String password, + Integer projectId); + + @Mapping(target = "updateAt", ignore = true) + @Mapping(target = "createAt", ignore = true) + @Mapping(target = "password", source = "password") + DataSourcePojo of(ProjectUpdateRequest.DataSourceUpdateRequest request, + String password, + Integer projectId); + + @Mapping(target = "id", ignore = true) + @Mapping(target = "createAt", ignore = true) + DataSourcePropertyPojo of(DataSourcePropertyValue propertyValues, Integer dataSourceId); + + default List of(List propertyValues, + Integer dataSourceId) { + return propertyValues.stream().map(value -> of(value, dataSourceId)).collect(Collectors.toList()); + } + +} diff --git a/core/src/main/java/com/databasir/core/domain/project/converter/ProjectPojoConverter.java b/core/src/main/java/com/databasir/core/domain/project/converter/ProjectPojoConverter.java new file mode 100644 index 0000000..dba4e9d --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/converter/ProjectPojoConverter.java @@ -0,0 +1,34 @@ +package com.databasir.core.domain.project.converter; + +import com.databasir.core.domain.project.data.ProjectCreateRequest; +import com.databasir.core.domain.project.data.ProjectDetailResponse; +import com.databasir.core.domain.project.data.ProjectSimpleResponse; +import com.databasir.core.domain.project.data.ProjectUpdateRequest; +import com.databasir.core.infrastructure.converter.JsonConverter; +import com.databasir.dao.tables.pojos.DataSourcePojo; +import com.databasir.dao.tables.pojos.DataSourcePropertyPojo; +import com.databasir.dao.tables.pojos.ProjectPojo; +import com.databasir.dao.tables.pojos.ProjectSyncRulePojo; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +import java.util.List; + +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = JsonConverter.class) +public interface ProjectPojoConverter { + + ProjectPojo of(ProjectCreateRequest request); + + ProjectPojo of(ProjectUpdateRequest request); + + @Mapping(target = "ignoreTableNameRegexArray", source = "request.ignoreTableNameRegexes") + @Mapping(target = "ignoreColumnNameRegexArray", source = "request.ignoreColumnNameRegexes") + ProjectSyncRulePojo of(ProjectCreateRequest.ProjectSyncRuleCreateRequest request, + Integer projectId); + + @Mapping(target = "ignoreTableNameRegexArray", source = "request.ignoreTableNameRegexes") + @Mapping(target = "ignoreColumnNameRegexArray", source = "request.ignoreColumnNameRegexes") + ProjectSyncRulePojo of(ProjectUpdateRequest.ProjectSyncRuleUpdateRequest request, + Integer projectId); +} diff --git a/core/src/main/java/com/databasir/core/domain/project/converter/ProjectResponseConverter.java b/core/src/main/java/com/databasir/core/domain/project/converter/ProjectResponseConverter.java new file mode 100644 index 0000000..f97b19c --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/converter/ProjectResponseConverter.java @@ -0,0 +1,35 @@ +package com.databasir.core.domain.project.converter; + +import com.databasir.core.domain.project.data.ProjectDetailResponse; +import com.databasir.core.domain.project.data.ProjectSimpleResponse; +import com.databasir.core.infrastructure.converter.JsonConverter; +import com.databasir.dao.tables.pojos.DataSourcePojo; +import com.databasir.dao.tables.pojos.DataSourcePropertyPojo; +import com.databasir.dao.tables.pojos.ProjectPojo; +import com.databasir.dao.tables.pojos.ProjectSyncRulePojo; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; + +import java.util.List; + +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = JsonConverter.class) +public interface ProjectResponseConverter { + + @Mapping(target = "id", source = "database.id") + @Mapping(target = "createAt", source = "database.createAt") + ProjectDetailResponse toResponse(ProjectPojo database, + ProjectDetailResponse.DataSourceResponse dataSource, + ProjectDetailResponse.ProjectSyncRuleResponse projectSyncRule); + + ProjectDetailResponse.DataSourceResponse toResponse(DataSourcePojo dataSource, + List properties); + + @Mapping(target = "ignoreTableNameRegexes", source = "ignoreTableNameRegexArray") + @Mapping(target = "ignoreColumnNameRegexes", source = "ignoreColumnNameRegexArray") + ProjectDetailResponse.ProjectSyncRuleResponse toResponse(ProjectSyncRulePojo rule); + + @Mapping(target = "id", source = "project.id") + @Mapping(target = "createAt", source = "project.createAt") + ProjectSimpleResponse toSimple(ProjectPojo project, DataSourcePojo dataSource); +} diff --git a/core/src/main/java/com/databasir/core/domain/project/data/DataSourcePropertyValue.java b/core/src/main/java/com/databasir/core/domain/project/data/DataSourcePropertyValue.java new file mode 100644 index 0000000..990eb82 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/data/DataSourcePropertyValue.java @@ -0,0 +1,16 @@ +package com.databasir.core.domain.project.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class DataSourcePropertyValue { + + @NotBlank + private String key; + + @NotBlank + private String value; + +} diff --git a/core/src/main/java/com/databasir/core/domain/project/data/ProjectCreateRequest.java b/core/src/main/java/com/databasir/core/domain/project/data/ProjectCreateRequest.java new file mode 100644 index 0000000..dd39937 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/data/ProjectCreateRequest.java @@ -0,0 +1,59 @@ +package com.databasir.core.domain.project.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProjectCreateRequest { + + @NotBlank + private String name; + + @NotBlank + private String description; + + @NotNull + private Integer groupId; + + @NotNull + private ProjectCreateRequest.DataSourceCreateRequest dataSource; + + @NotNull + private ProjectCreateRequest.ProjectSyncRuleCreateRequest projectSyncRule; + + @Data + public static class DataSourceCreateRequest { + + @NotBlank + private String username; + + @NotBlank + private String password; + + @NotBlank + private String url; + + @NotBlank + private String databaseName; + + @NotBlank + private String databaseType; + + private List properties = new ArrayList<>(); + + } + + @Data + public static class ProjectSyncRuleCreateRequest { + + private List ignoreTableNameRegexes = new ArrayList<>(); + + private List ignoreColumnNameRegexes = new ArrayList<>(); + + } + +} diff --git a/core/src/main/java/com/databasir/core/domain/project/data/ProjectDetailResponse.java b/core/src/main/java/com/databasir/core/domain/project/data/ProjectDetailResponse.java new file mode 100644 index 0000000..37daa73 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/data/ProjectDetailResponse.java @@ -0,0 +1,56 @@ +package com.databasir.core.domain.project.data; + +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProjectDetailResponse { + + private Integer id; + + private String name; + + private String description; + + private DataSourceResponse dataSource; + + private ProjectSyncRuleResponse projectSyncRule; + + private LocalDateTime createAt; + + @Data + public static class DataSourceResponse { + + private Integer id; + + private String username; + + private String url; + + private String databaseName; + + private String databaseType; + + private List properties = new ArrayList<>(); + + private LocalDateTime updateAt; + + private LocalDateTime createAt; + + } + + @Data + public static class ProjectSyncRuleResponse { + + private Integer id; + + private List ignoreTableNameRegexes = new ArrayList<>(); + + private List ignoreColumnNameRegexes = new ArrayList<>(); + + private LocalDateTime createAt; + } +} diff --git a/core/src/main/java/com/databasir/core/domain/project/data/ProjectListCondition.java b/core/src/main/java/com/databasir/core/domain/project/data/ProjectListCondition.java new file mode 100644 index 0000000..cbf1fc0 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/data/ProjectListCondition.java @@ -0,0 +1,43 @@ +package com.databasir.core.domain.project.data; + +import com.databasir.dao.Tables; +import lombok.Data; +import org.jooq.Condition; +import org.jooq.impl.DSL; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProjectListCondition { + + private String nameContains; + + private String databaseNameContains; + + private String databaseType; + + private Integer groupId; + + public Condition toCondition() { + List conditions = new ArrayList<>(); + if (nameContains != null) { + Condition condition = Tables.PROJECT.NAME.contains(nameContains); + conditions.add(condition); + } + if (databaseNameContains != null) { + Condition condition = Tables.DATA_SOURCE.DATABASE_NAME.contains(databaseNameContains); + conditions.add(condition); + } + if (databaseType != null) { + Condition condition = Tables.DATA_SOURCE.DATABASE_TYPE.eq(databaseType); + conditions.add(condition); + } + if (groupId != null) { + Condition condition = Tables.PROJECT.GROUP_ID.eq(groupId); + conditions.add(condition); + } + conditions.add(Tables.PROJECT.DELETED.eq(false)); + return conditions.stream().reduce(Condition::and).orElse(DSL.trueCondition()); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/project/data/ProjectSimpleResponse.java b/core/src/main/java/com/databasir/core/domain/project/data/ProjectSimpleResponse.java new file mode 100644 index 0000000..770addd --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/data/ProjectSimpleResponse.java @@ -0,0 +1,22 @@ +package com.databasir.core.domain.project.data; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class ProjectSimpleResponse { + + private Integer id; + + private String name; + + private String description; + + private String databaseName; + + private String databaseType; + + private LocalDateTime createAt; + +} diff --git a/core/src/main/java/com/databasir/core/domain/project/data/ProjectUpdateRequest.java b/core/src/main/java/com/databasir/core/domain/project/data/ProjectUpdateRequest.java new file mode 100644 index 0000000..cbc46f0 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/data/ProjectUpdateRequest.java @@ -0,0 +1,56 @@ +package com.databasir.core.domain.project.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Data +public class ProjectUpdateRequest { + + @NotNull + private Integer id; + + @NotBlank + private String name; + + @NotBlank + private String description; + + @NotNull + private ProjectUpdateRequest.DataSourceUpdateRequest dataSource; + + @NotNull + private ProjectUpdateRequest.ProjectSyncRuleUpdateRequest projectSyncRule; + + @Data + public static class DataSourceUpdateRequest { + + @NotBlank + private String username; + + private String password; + + @NotBlank + private String url; + + @NotBlank + private String databaseName; + + @NotBlank + private String databaseType; + + private List properties = new ArrayList<>(); + } + + @Data + public static class ProjectSyncRuleUpdateRequest { + + private List ignoreTableNameRegexes = new ArrayList<>(); + + private List ignoreColumnNameRegexes = new ArrayList<>(); + + } +} diff --git a/core/src/main/java/com/databasir/core/domain/project/service/ProjectService.java b/core/src/main/java/com/databasir/core/domain/project/service/ProjectService.java new file mode 100644 index 0000000..b7b7e9f --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/project/service/ProjectService.java @@ -0,0 +1,141 @@ +package com.databasir.core.domain.project.service; + +import com.databasir.common.codec.Aes; +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.project.converter.DataSourcePojoConverter; +import com.databasir.core.domain.project.converter.ProjectPojoConverter; +import com.databasir.core.domain.project.converter.ProjectResponseConverter; +import com.databasir.core.domain.project.data.*; +import com.databasir.dao.impl.*; +import com.databasir.dao.tables.pojos.*; +import lombok.RequiredArgsConstructor; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class ProjectService { + + private final ProjectDao projectDao; + + private final ProjectSyncRuleDao projectSyncRuleDao; + + private final DataSourceDao dataSourceDao; + + private final SysKeyDao sysKeyDao; + + private final DataSourcePropertyDao dataSourcePropertyDao; + + private final DataSourcePojoConverter dataSourcePojoConverter; + + private final ProjectPojoConverter projectPojoConverter; + + private final ProjectResponseConverter projectResponseConverter; + + public ProjectDetailResponse getOne(Integer id) { + return projectDao.selectOptionalById(id) + .map(schemaSource -> { + DataSourcePojo dataSource = dataSourceDao.selectByProjectId(id); + List properties = dataSourcePropertyDao.selectByDataSourceId(dataSource.getId()); + ProjectDetailResponse.DataSourceResponse dataSourceResponse = projectResponseConverter.toResponse(dataSource, properties); + ProjectSyncRulePojo rule = projectSyncRuleDao.selectByProjectId(id); + ProjectDetailResponse.ProjectSyncRuleResponse ruleResponse = projectResponseConverter.toResponse(rule); + return projectResponseConverter.toResponse(schemaSource, dataSourceResponse, ruleResponse); + }) + .orElseThrow(DomainErrors.PROJECT_NOT_FOUND::exception); + } + + @Transactional + public void create(ProjectCreateRequest request) { + ProjectPojo project = projectPojoConverter.of(request); + Integer projectId = null; + try { + projectId = projectDao.insertAndReturnId(project); + } catch (DuplicateKeyException e) { + throw DomainErrors.PROJECT_NOT_FOUND.exception(); + } + + String newPassword = encryptPassword(request.getDataSource().getPassword()).get(); + DataSourcePojo dataSource = dataSourcePojoConverter.of(request.getDataSource(), newPassword, projectId); + Integer dataSourceId = dataSourceDao.insertAndReturnId(dataSource); + + List propertyValues = request.getDataSource().getProperties(); + List properties = dataSourcePojoConverter.of(propertyValues, dataSourceId); + dataSourcePropertyDao.batchInsert(properties); + + // TODO redesign it + ProjectSyncRulePojo syncRule = projectPojoConverter.of(request.getProjectSyncRule(), projectId); + projectSyncRuleDao.insertAndReturnId(syncRule); + } + + @Transactional + public void update(Integer groupId, ProjectUpdateRequest request) { + Integer projectId = request.getId(); + if (projectDao.exists(groupId, projectId)) { + // update dataSource + String newPassword = encryptPassword(request.getDataSource().getPassword()).orElse(null); + DataSourcePojo dataSource = dataSourcePojoConverter.of(request.getDataSource(), newPassword, projectId); + dataSourceDao.updateByProjectId(dataSource); + + // update connection property + Integer dataSourceId = dataSourceDao.selectByProjectId(projectId).getId(); + List propertyValues = request.getDataSource().getProperties(); + List properties = dataSourcePojoConverter.of(propertyValues, dataSourceId); + if (properties.isEmpty()) { + dataSourcePropertyDao.deleteByDataSourceId(dataSourceId); + } else { + dataSourcePropertyDao.deleteByDataSourceId(dataSourceId); + dataSourcePropertyDao.batchInsert(properties); + } + + // update project sync rule TODO redesign it + ProjectSyncRulePojo syncRule = projectPojoConverter.of(request.getProjectSyncRule(), projectId); + projectSyncRuleDao.updateByProjectId(syncRule); + + // update project info + ProjectPojo project = projectPojoConverter.of(request); + projectDao.updateById(project); + } else { + throw DomainErrors.PROJECT_NOT_FOUND.exception(); + } + } + + private Optional encryptPassword(String password) { + if (!StringUtils.hasText(password)) { + return Optional.empty(); + } + SysKeyPojo sysKey = sysKeyDao.selectTopOne(); +// String decryptedPassword = Rsa.decryptFromBase64DataByPrivateKey(password, sysKey.getRsaPrivateKey()); + return Optional.of(Aes.encryptToBase64Data(password, sysKey.getAesKey())); + } + + public void delete(Integer projectId) { + projectDao.updateDeletedById(true, projectId); + } + + public Page list(Pageable page, ProjectListCondition condition) { + Page pageData = projectDao.selectByCondition(page, condition.toCondition()); + List projectIds = pageData.getContent() + .stream() + .map(ProjectPojo::getId) + .collect(Collectors.toList()); + Map dataSourceMapByProjectId = dataSourceDao.selectInProjectIds(projectIds) + .stream() + .collect(Collectors.toMap(DataSourcePojo::getProjectId, Function.identity())); + return pageData.map(project -> { + DataSourcePojo dataSource = dataSourceMapByProjectId.get(project.getId()); + return projectResponseConverter.toSimple(project, dataSource); + }); + } + +} diff --git a/core/src/main/java/com/databasir/core/domain/system/data/SystemEmailResponse.java b/core/src/main/java/com/databasir/core/domain/system/data/SystemEmailResponse.java new file mode 100644 index 0000000..7774564 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/system/data/SystemEmailResponse.java @@ -0,0 +1,17 @@ +package com.databasir.core.domain.system.data; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class SystemEmailResponse { + + private String username; + + private String smtpHost; + + private Integer smtpPort; + + private LocalDateTime createAt; +} diff --git a/core/src/main/java/com/databasir/core/domain/system/data/SystemEmailUpdateRequest.java b/core/src/main/java/com/databasir/core/domain/system/data/SystemEmailUpdateRequest.java new file mode 100644 index 0000000..2d6a490 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/system/data/SystemEmailUpdateRequest.java @@ -0,0 +1,24 @@ +package com.databasir.core.domain.system.data; + +import lombok.Data; + +import javax.validation.constraints.*; + +@Data +public class SystemEmailUpdateRequest { + + @NotBlank + @Email + private String username; + + private String password; + + @NotBlank + private String smtpHost; + + @NotNull + @Min(0L) + @Max(65535L) + private Integer smtpPort; + +} diff --git a/core/src/main/java/com/databasir/core/domain/system/service/SystemService.java b/core/src/main/java/com/databasir/core/domain/system/service/SystemService.java new file mode 100644 index 0000000..58f473d --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/system/service/SystemService.java @@ -0,0 +1,106 @@ +package com.databasir.core.domain.system.service; + +import com.databasir.common.codec.Aes; +import com.databasir.common.codec.Rsa; +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.system.data.SystemEmailResponse; +import com.databasir.core.domain.system.data.SystemEmailUpdateRequest; +import com.databasir.dao.impl.SysKeyDao; +import com.databasir.dao.impl.SysMailDao; +import com.databasir.dao.impl.UserDao; +import com.databasir.dao.impl.UserRoleDao; +import com.databasir.dao.tables.pojos.SysKeyPojo; +import com.databasir.dao.tables.pojos.SysMailPojo; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.pojos.UserRolePojo; +import lombok.RequiredArgsConstructor; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import javax.annotation.PostConstruct; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +public class SystemService { + + private final SysKeyDao sysKeyDao; + + private final SysMailDao sysMailDao; + + private final UserDao userDao; + + private final UserRoleDao userRoleDao; + + private BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); + + @PostConstruct + public void postInit() { + sysKeyDao.selectOptionTopOne() + .orElseGet(() -> { + SysKeyPojo pojo = new SysKeyPojo(); + pojo.setAesKey(Aes.randomBase64Key()); + Rsa.RsaBase64Key key = Rsa.generateBase64Key(); + pojo.setRsaPublicKey(key.getPublicBase64Key()); + pojo.setRsaPrivateKey(key.getPrivateBase64Key()); + sysKeyDao.insertAndReturnId(pojo); + return pojo; + }); + + String email = "admin@databasir.com"; + String username = "databasir"; + Optional userOpt = userDao.selectByEmail(email); + if (!userOpt.isPresent()) { + UserPojo admin = new UserPojo(); + admin.setEmail(email); + admin.setUsername(username); + admin.setPassword(bCryptPasswordEncoder.encode(username)); + admin.setEnabled(true); + admin.setNickname("Databasir Admin"); + Integer userId = userDao.insertAndReturnId(admin); + UserRolePojo role = new UserRolePojo(); + role.setUserId(userId); + role.setRole("SYS_OWNER"); + userRoleDao.insertAndReturnId(role); + } + } + + public void renewKey() { + // TODO + } + + public Optional getEmailSetting() { + return sysMailDao.selectOptionTopOne() + .map(mail -> { + SystemEmailResponse response = new SystemEmailResponse(); + response.setSmtpHost(mail.getSmtpHost()); + response.setSmtpPort(mail.getSmtpPort()); + response.setUsername(mail.getUsername()); + response.setCreateAt(mail.getCreateAt()); + return response; + }); + } + + public void updateEmailSetting(SystemEmailUpdateRequest request) { + Optional idOpt = sysMailDao.selectOptionTopOne().map(SysMailPojo::getId); + SysMailPojo sysMailPojo = new SysMailPojo(); + sysMailPojo.setSmtpHost(request.getSmtpHost()); + sysMailPojo.setSmtpPort(request.getSmtpPort()); + sysMailPojo.setUsername(request.getUsername()); + idOpt.ifPresent(sysMailPojo::setId); + if (request.getPassword() != null) { + // TODO encrypt password ? + sysMailPojo.setPassword(request.getPassword()); + } + + if (idOpt.isPresent()) { + if (!StringUtils.hasText(request.getPassword())) { + throw DomainErrors.CONNECT_DATABASE_FAILED.exception(); + } + sysMailDao.updateById(sysMailPojo); + } else { + sysMailDao.insertAndReturnId(sysMailPojo); + } + } +} diff --git a/core/src/main/java/com/databasir/core/domain/user/converter/UserPojoConverter.java b/core/src/main/java/com/databasir/core/domain/user/converter/UserPojoConverter.java new file mode 100644 index 0000000..5bdc55f --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/converter/UserPojoConverter.java @@ -0,0 +1,13 @@ +package com.databasir.core.domain.user.converter; + +import com.databasir.core.domain.user.data.UserCreateRequest; +import com.databasir.dao.tables.pojos.UserPojo; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(componentModel = "spring") +public interface UserPojoConverter { + + @Mapping(target = "password", source = "hashedPassword") + UserPojo of(UserCreateRequest request, String hashedPassword); +} diff --git a/core/src/main/java/com/databasir/core/domain/user/converter/UserResponseConverter.java b/core/src/main/java/com/databasir/core/domain/user/converter/UserResponseConverter.java new file mode 100644 index 0000000..fe225b7 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/converter/UserResponseConverter.java @@ -0,0 +1,32 @@ +package com.databasir.core.domain.user.converter; + +import com.databasir.core.domain.user.data.UserDetailResponse; +import com.databasir.core.domain.user.data.UserPageResponse; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.pojos.UserRolePojo; +import org.mapstruct.Mapper; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Mapper(componentModel = "spring") +public interface UserResponseConverter { + + + default UserDetailResponse detailResponse(UserPojo user, + List userRoles, + Map groupNameMapById) { + List roles = userRoles.stream() + .map(pojo -> userRoleDetailResponse(pojo, groupNameMapById.get(pojo.getGroupId()))) + .collect(Collectors.toList()); + return detailResponse(user, roles); + } + + UserDetailResponse detailResponse(UserPojo pojo, List roles); + + UserDetailResponse.UserRoleDetailResponse userRoleDetailResponse(UserRolePojo pojo, String groupName); + + UserPageResponse pageResponse(UserPojo pojo, Boolean isSysOwner, List inGroupIds); + +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserCreateRequest.java b/core/src/main/java/com/databasir/core/domain/user/data/UserCreateRequest.java new file mode 100644 index 0000000..ae68290 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserCreateRequest.java @@ -0,0 +1,28 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class UserCreateRequest { + + private String avatar; + + @NotBlank + private String username; + + @NotBlank + private String nickname; + + @NotBlank + private String email; + + @NotBlank + private String password; + + @NotNull + private Boolean enabled; + +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserDetailResponse.java b/core/src/main/java/com/databasir/core/domain/user/data/UserDetailResponse.java new file mode 100644 index 0000000..d11f1ab --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserDetailResponse.java @@ -0,0 +1,39 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +public class UserDetailResponse { + + private Integer id; + + private String username; + + private String nickname; + + private String avatar; + + private String email; + + private Boolean enabled; + + private List roles = new ArrayList<>(); + + private LocalDateTime createAt; + + @Data + public static class UserRoleDetailResponse { + + private String role; + + private Integer groupId; + + private String groupName; + + private LocalDateTime createAt; + } +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserLoginRequest.java b/core/src/main/java/com/databasir/core/domain/user/data/UserLoginRequest.java new file mode 100644 index 0000000..5b5d8a0 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserLoginRequest.java @@ -0,0 +1,16 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class UserLoginRequest { + + @NotBlank + private String username; + + @NotBlank + private String password; + +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserLoginResponse.java b/core/src/main/java/com/databasir/core/domain/user/data/UserLoginResponse.java new file mode 100644 index 0000000..2d87871 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserLoginResponse.java @@ -0,0 +1,32 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import java.util.List; + +@Data +public class UserLoginResponse { + + private Integer id; + + private String nickname; + + private String email; + + private String username; + + private String accessToken; + + private long accessTokenExpireAt; + + private String refreshToken; + + private List roles; + + @Data + public static class RoleResponse { + private String role; + private Integer groupId; + } +} + diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserNicknameUpdateRequest.java b/core/src/main/java/com/databasir/core/domain/user/data/UserNicknameUpdateRequest.java new file mode 100644 index 0000000..a209502 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserNicknameUpdateRequest.java @@ -0,0 +1,15 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +@Data +public class UserNicknameUpdateRequest { + + @NotBlank + @Size(max = 32, min = 1) + private String nickname; + +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserPageCondition.java b/core/src/main/java/com/databasir/core/domain/user/data/UserPageCondition.java new file mode 100644 index 0000000..fce5a36 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserPageCondition.java @@ -0,0 +1,51 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; +import org.jooq.Condition; +import org.jooq.impl.DSL; + +import java.util.ArrayList; +import java.util.List; + +import static com.databasir.dao.Tables.USER; + +@Data +public class UserPageCondition { + + private String nicknameContains; + + private String usernameContains; + + private String emailContains; + + private String nicknameOrUsernameOrEmailContains; + + private Boolean enabled; + + public Condition toCondition() { + List conditions = new ArrayList<>(); + if (nicknameContains != null) { + Condition condition = USER.NICKNAME.contains(nicknameContains); + conditions.add(condition); + } + if (usernameContains != null) { + Condition condition = USER.USERNAME.contains(usernameContains); + conditions.add(condition); + } + if (emailContains != null) { + Condition condition = USER.EMAIL.contains(emailContains); + conditions.add(condition); + } + if (enabled != null) { + Condition condition = USER.ENABLED.eq(enabled); + conditions.add(condition); + } + if (nicknameOrUsernameOrEmailContains != null) { + Condition condition = USER.EMAIL.contains(nicknameOrUsernameOrEmailContains) + .or(USER.USERNAME.contains(nicknameOrUsernameOrEmailContains)) + .or(USER.EMAIL.contains(nicknameOrUsernameOrEmailContains)); + conditions.add(condition); + } + return conditions.stream().reduce(Condition::and).orElse(DSL.trueCondition()); + } +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserPageResponse.java b/core/src/main/java/com/databasir/core/domain/user/data/UserPageResponse.java new file mode 100644 index 0000000..d93fe0d --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserPageResponse.java @@ -0,0 +1,27 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Data +public class UserPageResponse { + + private Integer id; + + private String username; + + private String nickname; + + private String email; + + private Boolean enabled; + + private Boolean isSysOwner; + + private List inGroupIds = new ArrayList<>(); + + private LocalDateTime createAt; +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserPasswordUpdateRequest.java b/core/src/main/java/com/databasir/core/domain/user/data/UserPasswordUpdateRequest.java new file mode 100644 index 0000000..87e7edc --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserPasswordUpdateRequest.java @@ -0,0 +1,22 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +@Data +public class UserPasswordUpdateRequest { + + @NotBlank + private String originPassword; + + @NotBlank + @Size(min = 6, max = 32) + private String newPassword; + + @NotBlank + @Size(min = 6, max = 32) + private String confirmNewPassword; + +} diff --git a/core/src/main/java/com/databasir/core/domain/user/data/UserRoleAssignRequest.java b/core/src/main/java/com/databasir/core/domain/user/data/UserRoleAssignRequest.java new file mode 100644 index 0000000..3052682 --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/data/UserRoleAssignRequest.java @@ -0,0 +1,13 @@ +package com.databasir.core.domain.user.data; + +import lombok.Data; + +@Data +public class UserRoleAssignRequest { + + private Integer userId; + + private String role; + + private Integer groupId; +} diff --git a/core/src/main/java/com/databasir/core/domain/user/service/UserService.java b/core/src/main/java/com/databasir/core/domain/user/service/UserService.java new file mode 100644 index 0000000..aedb69f --- /dev/null +++ b/core/src/main/java/com/databasir/core/domain/user/service/UserService.java @@ -0,0 +1,146 @@ +package com.databasir.core.domain.user.service; + +import com.databasir.core.domain.DomainErrors; +import com.databasir.core.domain.user.converter.UserPojoConverter; +import com.databasir.core.domain.user.converter.UserResponseConverter; +import com.databasir.core.domain.user.data.*; +import com.databasir.core.infrastructure.mail.MailSender; +import com.databasir.dao.impl.GroupDao; +import com.databasir.dao.impl.SysMailDao; +import com.databasir.dao.impl.UserDao; +import com.databasir.dao.impl.UserRoleDao; +import com.databasir.dao.tables.pojos.GroupPojo; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.pojos.UserRolePojo; +import lombok.RequiredArgsConstructor; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +import static java.util.stream.Collectors.*; + +@Service +@RequiredArgsConstructor +public class UserService { + + private final UserDao userDao; + + private final UserRoleDao userRoleDao; + + private final GroupDao groupDao; + + private final SysMailDao sysMailDao; + + private final UserPojoConverter userPojoConverter; + + private final UserResponseConverter userResponseConverter; + + private final MailSender mailSender; + + private BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); + + public Page list(Pageable pageable, UserPageCondition condition) { + Page users = userDao.selectByPage(pageable, condition.toCondition()); + List userIds = users.getContent() + .stream() + .map(UserPojo::getId) + .collect(toList()); + List userRoles = userRoleDao.selectByUserIds(userIds); + Map> groupIdMapByUserId = userRoles + .stream() + .filter(ur -> ur.getGroupId() != null) + .collect(groupingBy(UserRolePojo::getUserId, mapping(UserRolePojo::getGroupId, toList()))); + Map> sysOwnerGroupByUserId = userRoles.stream() + .filter(ur -> ur.getRole().equals("SYS_OWNER")) + .collect(groupingBy(UserRolePojo::getUserId)); + return users.map(user -> + userResponseConverter.pageResponse(user, sysOwnerGroupByUserId.containsKey(user.getId()), + groupIdMapByUserId.get(user.getId()))); + } + + @Transactional + public void create(UserCreateRequest userCreateRequest) { + userDao.selectByEmailOrUsername(userCreateRequest.getUsername()).ifPresent(data -> { + throw DomainErrors.USERNAME_OR_EMAIL_DUPLICATE.exception(); + }); + String hashedPassword = bCryptPasswordEncoder.encode(userCreateRequest.getPassword()); + UserPojo pojo = userPojoConverter.of(userCreateRequest, hashedPassword); + try { + userDao.insertAndReturnId(pojo); + } catch (DuplicateKeyException e) { + throw DomainErrors.USERNAME_OR_EMAIL_DUPLICATE.exception(); + } + } + + public UserDetailResponse get(Integer userId) { + UserPojo pojo = userDao.selectById(userId); + List roles = userRoleDao.selectByUserIds(Collections.singletonList(userId)); + List groupIds = roles.stream() + .map(UserRolePojo::getGroupId) + .filter(Objects::nonNull) + .collect(toList()); + Map groupNameMapById = groupDao.selectInIds(groupIds) + .stream() + .collect(toMap(GroupPojo::getId, GroupPojo::getName)); + return userResponseConverter.detailResponse(pojo, roles, groupNameMapById); + } + + @Transactional + public String renewPassword(Integer userId) { + UserPojo userPojo = userDao.selectById(userId); + String randomPassword = UUID.randomUUID().toString() + .replace("-", "") + .substring(0, 8); + String hashedPassword = bCryptPasswordEncoder.encode(randomPassword); + userDao.updatePassword(userId, hashedPassword); + sysMailDao.selectOptionTopOne() + .ifPresent(mailPojo -> { + String subject = "Databasir 密码重置提醒"; + String message = "您的密码已被重置,新密码为:" + randomPassword; + mailSender.send(mailPojo, userPojo.getEmail(), subject, message); + }); + return randomPassword; + } + + public void switchEnableStatus(Integer userId, Boolean enable) { + userDao.updateEnabledByUserId(userId, enable); + } + + public void removeSysOwnerFrom(Integer userId) { + if (userRoleDao.hasRole(userId, "SYS_OWNER")) { + userRoleDao.deleteRole(userId, "SYS_OWNER"); + } + } + + public void addSysOwnerTo(Integer userId) { + if (!userRoleDao.hasRole(userId, "SYS_OWNER")) { + UserRolePojo role = new UserRolePojo(); + role.setUserId(userId); + role.setRole("SYS_OWNER"); + userRoleDao.insertAndReturnId(role); + } + } + + public void updatePassword(Integer userId, UserPasswordUpdateRequest request) { + if (!Objects.equals(request.getNewPassword(), request.getConfirmNewPassword())) { + throw DomainErrors.UPDATE_PASSWORD_CONFIRM_FAILED.exception(); + } + UserPojo userPojo = userDao.selectById(userId); + if (!bCryptPasswordEncoder.matches(request.getOriginPassword(), userPojo.getPassword())) { + throw DomainErrors.ORIGIN_PASSWORD_NOT_CORRECT.exception(); + } + String newHashedPassword = bCryptPasswordEncoder.encode(request.getNewPassword()); + userDao.updatePassword(userId, newHashedPassword); + } + + public void updateNickname(Integer userId, UserNicknameUpdateRequest request) { + UserPojo userPojo = userDao.selectById(userId); + userPojo.setNickname(request.getNickname()); + userDao.updateById(userPojo); + } +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionFactory.java b/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionFactory.java new file mode 100644 index 0000000..472c746 --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionFactory.java @@ -0,0 +1,15 @@ +package com.databasir.core.infrastructure.connection; + +import java.sql.Connection; +import java.util.Properties; + +public interface DatabaseConnectionFactory { + + boolean support(String databaseType); + + Connection getConnection(String username, + String password, + String url, + String schema, + Properties properties); +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionService.java b/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionService.java new file mode 100644 index 0000000..2d5b6fb --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseConnectionService.java @@ -0,0 +1,39 @@ +package com.databasir.core.infrastructure.connection; + +import com.databasir.common.codec.Aes; +import com.databasir.core.domain.DomainErrors; +import com.databasir.dao.impl.SysKeyDao; +import com.databasir.dao.tables.pojos.DataSourcePojo; +import com.databasir.dao.tables.pojos.DataSourcePropertyPojo; +import com.databasir.dao.tables.pojos.SysKeyPojo; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.sql.Connection; +import java.util.List; +import java.util.Properties; + +@Component +@RequiredArgsConstructor +public class DatabaseConnectionService { + + private final List factories; + + private final SysKeyDao sysKeyDao; + + public Connection create(DataSourcePojo dataSource, + List dataSourceProperties) { + SysKeyPojo sysKey = sysKeyDao.selectTopOne(); + String username = dataSource.getUsername(); + String password = Aes.decryptFromBase64Data(dataSource.getPassword(), sysKey.getAesKey()); + String url = dataSource.getUrl(); + + Properties info = new Properties(); + dataSourceProperties.forEach(prop -> info.put(prop.getKey(), prop.getValue())); + return factories.stream() + .filter(factory -> factory.support(dataSource.getDatabaseType())) + .findFirst() + .orElseThrow(DomainErrors.NOT_SUPPORT_DATABASE_TYPE::exception) + .getConnection(username, password, url, dataSource.getDatabaseName(), info); + } +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseTypes.java b/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseTypes.java new file mode 100644 index 0000000..e8b160f --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/connection/DatabaseTypes.java @@ -0,0 +1,10 @@ +package com.databasir.core.infrastructure.connection; + +public interface DatabaseTypes { + + String MYSQL = "mysql"; + + String POSTGRESQL = "postgresql"; + + String ORACLE = "oracle"; +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/connection/MysqlDatabaseConnectionFactory.java b/core/src/main/java/com/databasir/core/infrastructure/connection/MysqlDatabaseConnectionFactory.java new file mode 100644 index 0000000..cf59091 --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/connection/MysqlDatabaseConnectionFactory.java @@ -0,0 +1,39 @@ +package com.databasir.core.infrastructure.connection; + +import com.databasir.core.domain.DomainErrors; +import org.springframework.stereotype.Component; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +@Component +public class MysqlDatabaseConnectionFactory implements DatabaseConnectionFactory { + + @Override + public boolean support(String databaseType) { + return DatabaseTypes.MYSQL.equalsIgnoreCase(databaseType); + } + + @Override + public Connection getConnection(String username, String password, String url, String schema, Properties properties) { + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + } catch (ClassNotFoundException e) { + throw new IllegalStateException(e); + } + + Properties info = new Properties(); + info.put("user", username); + info.put("password", password); + info.putAll(properties); + String jdbcUrl = "jdbc:mysql://" + url + "/" + schema; + try { + return DriverManager.getConnection(jdbcUrl, info); + } catch (SQLException e) { + throw DomainErrors.CONNECT_DATABASE_FAILED.exception(e); + } + } + +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/connection/PostgresqlDatabaseConnectionFactory.java b/core/src/main/java/com/databasir/core/infrastructure/connection/PostgresqlDatabaseConnectionFactory.java new file mode 100644 index 0000000..c2166e7 --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/connection/PostgresqlDatabaseConnectionFactory.java @@ -0,0 +1,39 @@ +package com.databasir.core.infrastructure.connection; + + +import com.databasir.core.domain.DomainErrors; +import org.springframework.stereotype.Component; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +@Component +public class PostgresqlDatabaseConnectionFactory implements DatabaseConnectionFactory { + + @Override + public boolean support(String databaseType) { + return DatabaseTypes.POSTGRESQL.equalsIgnoreCase(databaseType); + } + + @Override + public Connection getConnection(String username, String password, String url, String schema, Properties properties) { + try { + Class.forName("org.postgresql.Driver"); + } catch (ClassNotFoundException e) { + throw new IllegalStateException(e); + } + + Properties info = new Properties(); + info.put("user", username); + info.put("password", password); + info.putAll(properties); + String jdbcUrl = "jdbc:postgresql://" + url + "/" + schema; + try { + return DriverManager.getConnection(jdbcUrl, info); + } catch (SQLException e) { + throw DomainErrors.CONNECT_DATABASE_FAILED.exception(e); + } + } +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/converter/JsonConverter.java b/core/src/main/java/com/databasir/core/infrastructure/converter/JsonConverter.java new file mode 100644 index 0000000..6210c6f --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/converter/JsonConverter.java @@ -0,0 +1,65 @@ +package com.databasir.core.infrastructure.converter; + +import com.databasir.core.domain.document.data.DatabaseDocumentResponse; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.jooq.JSON; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; + +@Component +public class JsonConverter { + + @Autowired + private ObjectMapper objectMapper; + + public JSON toJson(List array) { + try { + String json = objectMapper.writeValueAsString(array); + return JSON.valueOf(json); + } catch (JsonProcessingException e) { + throw new IllegalArgumentException(e); + } + } + + public List fromJson(JSON json) { + String data = json.data(); + if (data == null) { + return Collections.emptyList(); + } else { + try { + return objectMapper.readValue(data.getBytes(StandardCharsets.UTF_8), + new TypeReference>() { + }); + } catch (IOException e) { + throw new IllegalArgumentException(e); + } + } + } + + public JSON toJson(DatabaseDocumentResponse response) { + try { + String json = objectMapper.writeValueAsString(response); + return JSON.valueOf(json); + } catch (JsonProcessingException e) { + throw new IllegalArgumentException(e); + } + } + + public DatabaseDocumentResponse of(JSON json) { + try { + if (json == null) { + return null; + } + return objectMapper.readValue(json.data().getBytes(StandardCharsets.UTF_8), DatabaseDocumentResponse.class); + } catch (IOException e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/jwt/JwtTokens.java b/core/src/main/java/com/databasir/core/infrastructure/jwt/JwtTokens.java new file mode 100644 index 0000000..81fbcb7 --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/jwt/JwtTokens.java @@ -0,0 +1,61 @@ +package com.databasir.core.infrastructure.jwt; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.exceptions.JWTVerificationException; +import com.auth0.jwt.interfaces.JWTVerifier; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; + +@Component +@Slf4j +public class JwtTokens { + + // 15 minutes + private static final long ACCESS_EXPIRE_TIME = 1000 * 60 * 15; + + public static final String TOKEN_PREFIX = "Bearer "; + + private static final String ISSUER = "Databasir"; + + private static final String SECRET = "Databasir2022"; + + public String accessToken(String username) { + Algorithm algorithm = Algorithm.HMAC256(SECRET); + + return JWT.create() + .withExpiresAt(new Date(new Date().getTime() + ACCESS_EXPIRE_TIME)) + .withIssuer(ISSUER) + .withClaim("username", username) + .sign(algorithm); + } + + public boolean verify(String token) { + JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SECRET)) + .withIssuer(ISSUER) + .build(); + try { + verifier.verify(token); + return true; + } catch (JWTVerificationException e) { + log.warn("verify jwt token failed " + e.getMessage()); + return false; + } + } + + public String getUsername(String token) { + return JWT.decode(token).getClaim("username").asString(); + } + + public LocalDateTime expireAt(String token) { + long time = JWT.decode(token).getExpiresAt().getTime(); + return Instant.ofEpochMilli(time) + .atZone(ZoneId.systemDefault()) + .toLocalDateTime(); + } +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/mail/MailSender.java b/core/src/main/java/com/databasir/core/infrastructure/mail/MailSender.java new file mode 100644 index 0000000..398b3a6 --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/mail/MailSender.java @@ -0,0 +1,36 @@ +package com.databasir.core.infrastructure.mail; + +import com.databasir.dao.tables.pojos.SysMailPojo; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.stereotype.Component; + +import java.nio.charset.StandardCharsets; + +@Component +public class MailSender { + + public void send(SysMailPojo mail, String to, String subject, String content) { + JavaMailSender sender = initJavaMailSender(mail); + SimpleMailMessage message = new SimpleMailMessage(); + message.setFrom(mail.getUsername()); + message.setTo(to); + message.setSubject(subject); + message.setText(content); + sender.send(message); + } + + private JavaMailSender initJavaMailSender(SysMailPojo properties) { + JavaMailSenderImpl sender = new JavaMailSenderImpl(); + sender.setHost(properties.getSmtpHost()); + if (properties.getSmtpPort() != null) { + sender.setPort(properties.getSmtpPort()); + } + sender.setUsername(properties.getUsername()); + sender.setPassword(properties.getPassword()); + sender.setProtocol("smtp"); + sender.setDefaultEncoding(StandardCharsets.UTF_8.name()); + return sender; + } +} diff --git a/core/src/main/java/com/databasir/core/infrastructure/meta/DatabaseMetaResolver.java b/core/src/main/java/com/databasir/core/infrastructure/meta/DatabaseMetaResolver.java new file mode 100644 index 0000000..182aacc --- /dev/null +++ b/core/src/main/java/com/databasir/core/infrastructure/meta/DatabaseMetaResolver.java @@ -0,0 +1,5 @@ +package com.databasir.core.infrastructure.meta; + +public class DatabaseMetaResolver { + +} diff --git a/dao/build.gradle b/dao/build.gradle new file mode 100644 index 0000000..68f4020 --- /dev/null +++ b/dao/build.gradle @@ -0,0 +1,77 @@ +plugins { + id 'nu.studer.jooq' + id 'io.spring.dependency-management' + id 'org.springframework.boot' apply false +} + +dependencies { + implementation "org.jooq:jooq:${jooqVersion}" + implementation "org.jooq:jooq-codegen:${jooqVersion}" + implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' + jooqGenerator "mysql:mysql-connector-java:${mysqlConnectorVersion}" + // include self to use strategy + jooqGenerator project(':dao') +} + +sourceSets { + main { + java.srcDirs += 'generated-src/jooq/main/java' + } +} + +jooq { + version = "${jooqVersion}" + edition = nu.studer.gradle.jooq.JooqEdition.OSS + + configurations { + databasir { + generateSchemaSourceOnCompilation = true + generationTool { + jdbc { + driver = 'com.mysql.cj.jdbc.Driver' + url = 'jdbc:mysql://localhost:3306/databasir' + user = 'root' + password = '123456' + properties { + property { + key = 'useSSL' + value = 'false' + } + property { + key = 'allowPublicKeyRetrieval' + value = 'true' + } + } + } + generator { + name = 'org.jooq.codegen.DefaultGenerator' + database { + name = 'org.jooq.meta.mysql.MySQLDatabase' + inputSchema = 'databasir' + excludes = 'flyway.*' + forcedTypes { + forcedType { + name = 'BOOLEAN' + includeExpression = 'deleted|enabled|is.*' + includeTypes = '.*' + } + forcedType { + name = 'varchar' + includeExpression = '.*' + includeTypes = 'INET' + } + } + } + generate { + pojos = true + } + target { + packageName = 'com.databasir.dao' + directory = 'generated-src/jooq/main/java' + } + strategy.name = 'com.databasir.dao.strategy.DatabasirPojoNamingStrategy' + } + } + } + } +} \ No newline at end of file diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/Databasir.java b/dao/generated-src/jooq/main/java/com/databasir/dao/Databasir.java new file mode 100644 index 0000000..2a4dd46 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/Databasir.java @@ -0,0 +1,159 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao; + + +import com.databasir.dao.tables.DataSource; +import com.databasir.dao.tables.DataSourceProperty; +import com.databasir.dao.tables.DatabaseDocument; +import com.databasir.dao.tables.DatabaseDocumentHistory; +import com.databasir.dao.tables.Group; +import com.databasir.dao.tables.Login; +import com.databasir.dao.tables.Project; +import com.databasir.dao.tables.ProjectSyncRule; +import com.databasir.dao.tables.SysKey; +import com.databasir.dao.tables.SysMail; +import com.databasir.dao.tables.TableColumnDocument; +import com.databasir.dao.tables.TableDocument; +import com.databasir.dao.tables.TableIndexDocument; +import com.databasir.dao.tables.TableTriggerDocument; +import com.databasir.dao.tables.User; +import com.databasir.dao.tables.UserRole; + +import java.util.Arrays; +import java.util.List; + +import org.jooq.Catalog; +import org.jooq.Table; +import org.jooq.impl.SchemaImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Databasir extends SchemaImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir + */ + public static final Databasir DATABASIR = new Databasir(); + + /** + * The table databasir.data_source. + */ + public final DataSource DATA_SOURCE = DataSource.DATA_SOURCE; + + /** + * The table databasir.data_source_property. + */ + public final DataSourceProperty DATA_SOURCE_PROPERTY = DataSourceProperty.DATA_SOURCE_PROPERTY; + + /** + * The table databasir.database_document. + */ + public final DatabaseDocument DATABASE_DOCUMENT = DatabaseDocument.DATABASE_DOCUMENT; + + /** + * The table databasir.database_document_history. + */ + public final DatabaseDocumentHistory DATABASE_DOCUMENT_HISTORY = DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY; + + /** + * The table databasir.group. + */ + public final Group GROUP = Group.GROUP; + + /** + * The table databasir.login. + */ + public final Login LOGIN = Login.LOGIN; + + /** + * The table databasir.project. + */ + public final Project PROJECT = Project.PROJECT; + + /** + * The table databasir.project_sync_rule. + */ + public final ProjectSyncRule PROJECT_SYNC_RULE = ProjectSyncRule.PROJECT_SYNC_RULE; + + /** + * The table databasir.sys_key. + */ + public final SysKey SYS_KEY = SysKey.SYS_KEY; + + /** + * The table databasir.sys_mail. + */ + public final SysMail SYS_MAIL = SysMail.SYS_MAIL; + + /** + * The table databasir.table_column_document. + */ + public final TableColumnDocument TABLE_COLUMN_DOCUMENT = TableColumnDocument.TABLE_COLUMN_DOCUMENT; + + /** + * The table databasir.table_document. + */ + public final TableDocument TABLE_DOCUMENT = TableDocument.TABLE_DOCUMENT; + + /** + * The table databasir.table_index_document. + */ + public final TableIndexDocument TABLE_INDEX_DOCUMENT = TableIndexDocument.TABLE_INDEX_DOCUMENT; + + /** + * The table databasir.table_trigger_document. + */ + public final TableTriggerDocument TABLE_TRIGGER_DOCUMENT = TableTriggerDocument.TABLE_TRIGGER_DOCUMENT; + + /** + * The table databasir.user. + */ + public final User USER = User.USER; + + /** + * The table databasir.user_role. + */ + public final UserRole USER_ROLE = UserRole.USER_ROLE; + + /** + * No further instances allowed + */ + private Databasir() { + super("databasir", null); + } + + + @Override + public Catalog getCatalog() { + return DefaultCatalog.DEFAULT_CATALOG; + } + + @Override + public final List> getTables() { + return Arrays.asList( + DataSource.DATA_SOURCE, + DataSourceProperty.DATA_SOURCE_PROPERTY, + DatabaseDocument.DATABASE_DOCUMENT, + DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY, + Group.GROUP, + Login.LOGIN, + Project.PROJECT, + ProjectSyncRule.PROJECT_SYNC_RULE, + SysKey.SYS_KEY, + SysMail.SYS_MAIL, + TableColumnDocument.TABLE_COLUMN_DOCUMENT, + TableDocument.TABLE_DOCUMENT, + TableIndexDocument.TABLE_INDEX_DOCUMENT, + TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, + User.USER, + UserRole.USER_ROLE + ); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/DefaultCatalog.java b/dao/generated-src/jooq/main/java/com/databasir/dao/DefaultCatalog.java new file mode 100644 index 0000000..3c77fc3 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/DefaultCatalog.java @@ -0,0 +1,45 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao; + + +import java.util.Arrays; +import java.util.List; + +import org.jooq.Schema; +import org.jooq.impl.CatalogImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DefaultCatalog extends CatalogImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of DEFAULT_CATALOG + */ + public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); + + /** + * The schema databasir. + */ + public final Databasir DATABASIR = Databasir.DATABASIR; + + /** + * No further instances allowed + */ + private DefaultCatalog() { + super(""); + } + + @Override + public final List getSchemas() { + return Arrays.asList( + Databasir.DATABASIR + ); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/Indexes.java b/dao/generated-src/jooq/main/java/com/databasir/dao/Indexes.java new file mode 100644 index 0000000..90ac1bb --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/Indexes.java @@ -0,0 +1,39 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao; + + +import com.databasir.dao.tables.DataSourceProperty; +import com.databasir.dao.tables.DatabaseDocumentHistory; +import com.databasir.dao.tables.TableColumnDocument; +import com.databasir.dao.tables.TableDocument; +import com.databasir.dao.tables.TableIndexDocument; +import com.databasir.dao.tables.TableTriggerDocument; + +import org.jooq.Index; +import org.jooq.OrderField; +import org.jooq.impl.DSL; +import org.jooq.impl.Internal; + + +/** + * A class modelling indexes of tables in databasir. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Indexes { + + // ------------------------------------------------------------------------- + // INDEX definitions + // ------------------------------------------------------------------------- + + public static final Index DATA_SOURCE_PROPERTY_IDX_DATA_SOURCE_ID = Internal.createIndex(DSL.name("idx_data_source_id"), DataSourceProperty.DATA_SOURCE_PROPERTY, new OrderField[] { DataSourceProperty.DATA_SOURCE_PROPERTY.DATA_SOURCE_ID }, false); + public static final Index TABLE_COLUMN_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableColumnDocument.TABLE_COLUMN_DOCUMENT, new OrderField[] { TableColumnDocument.TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID }, false); + public static final Index TABLE_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableDocument.TABLE_DOCUMENT, new OrderField[] { TableDocument.TABLE_DOCUMENT.DATABASE_DOCUMENT_ID }, false); + public static final Index TABLE_INDEX_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableIndexDocument.TABLE_INDEX_DOCUMENT, new OrderField[] { TableIndexDocument.TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID }, false); + public static final Index TABLE_TRIGGER_DOCUMENT_IDX_DATABASE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_database_document_id"), TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, new OrderField[] { TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID }, false); + public static final Index DATABASE_DOCUMENT_HISTORY_IDX_PROJECT_ID = Internal.createIndex(DSL.name("idx_project_id"), DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY, new OrderField[] { DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.PROJECT_ID }, false); + public static final Index TABLE_COLUMN_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableColumnDocument.TABLE_COLUMN_DOCUMENT, new OrderField[] { TableColumnDocument.TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID }, false); + public static final Index TABLE_INDEX_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableIndexDocument.TABLE_INDEX_DOCUMENT, new OrderField[] { TableIndexDocument.TABLE_INDEX_DOCUMENT.TABLE_DOCUMENT_ID }, false); + public static final Index TABLE_TRIGGER_DOCUMENT_IDX_TABLE_DOCUMENT_ID = Internal.createIndex(DSL.name("idx_table_document_id"), TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, new OrderField[] { TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.TABLE_DOCUMENT_ID }, false); +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/Keys.java b/dao/generated-src/jooq/main/java/com/databasir/dao/Keys.java new file mode 100644 index 0000000..7a8706a --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/Keys.java @@ -0,0 +1,83 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao; + + +import com.databasir.dao.tables.DataSource; +import com.databasir.dao.tables.DataSourceProperty; +import com.databasir.dao.tables.DatabaseDocument; +import com.databasir.dao.tables.DatabaseDocumentHistory; +import com.databasir.dao.tables.Group; +import com.databasir.dao.tables.Login; +import com.databasir.dao.tables.Project; +import com.databasir.dao.tables.ProjectSyncRule; +import com.databasir.dao.tables.SysKey; +import com.databasir.dao.tables.SysMail; +import com.databasir.dao.tables.TableColumnDocument; +import com.databasir.dao.tables.TableDocument; +import com.databasir.dao.tables.TableIndexDocument; +import com.databasir.dao.tables.TableTriggerDocument; +import com.databasir.dao.tables.User; +import com.databasir.dao.tables.UserRole; +import com.databasir.dao.tables.records.DataSourcePropertyRecord; +import com.databasir.dao.tables.records.DataSourceRecord; +import com.databasir.dao.tables.records.DatabaseDocumentHistoryRecord; +import com.databasir.dao.tables.records.DatabaseDocumentRecord; +import com.databasir.dao.tables.records.GroupRecord; +import com.databasir.dao.tables.records.LoginRecord; +import com.databasir.dao.tables.records.ProjectRecord; +import com.databasir.dao.tables.records.ProjectSyncRuleRecord; +import com.databasir.dao.tables.records.SysKeyRecord; +import com.databasir.dao.tables.records.SysMailRecord; +import com.databasir.dao.tables.records.TableColumnDocumentRecord; +import com.databasir.dao.tables.records.TableDocumentRecord; +import com.databasir.dao.tables.records.TableIndexDocumentRecord; +import com.databasir.dao.tables.records.TableTriggerDocumentRecord; +import com.databasir.dao.tables.records.UserRecord; +import com.databasir.dao.tables.records.UserRoleRecord; + +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.Internal; + + +/** + * A class modelling foreign key relationships and constraints of tables in + * databasir. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Keys { + + // ------------------------------------------------------------------------- + // UNIQUE and PRIMARY KEY definitions + // ------------------------------------------------------------------------- + + public static final UniqueKey KEY_DATA_SOURCE_PRIMARY = Internal.createUniqueKey(DataSource.DATA_SOURCE, DSL.name("KEY_data_source_PRIMARY"), new TableField[] { DataSource.DATA_SOURCE.ID }, true); + public static final UniqueKey KEY_DATA_SOURCE_UK_PROJECT_ID = Internal.createUniqueKey(DataSource.DATA_SOURCE, DSL.name("KEY_data_source_uk_project_id"), new TableField[] { DataSource.DATA_SOURCE.PROJECT_ID }, true); + public static final UniqueKey KEY_DATA_SOURCE_PROPERTY_PRIMARY = Internal.createUniqueKey(DataSourceProperty.DATA_SOURCE_PROPERTY, DSL.name("KEY_data_source_property_PRIMARY"), new TableField[] { DataSourceProperty.DATA_SOURCE_PROPERTY.ID }, true); + public static final UniqueKey KEY_DATABASE_DOCUMENT_PRIMARY = Internal.createUniqueKey(DatabaseDocument.DATABASE_DOCUMENT, DSL.name("KEY_database_document_PRIMARY"), new TableField[] { DatabaseDocument.DATABASE_DOCUMENT.ID }, true); + public static final UniqueKey KEY_DATABASE_DOCUMENT_UK_PROJECT_ID = Internal.createUniqueKey(DatabaseDocument.DATABASE_DOCUMENT, DSL.name("KEY_database_document_uk_project_id"), new TableField[] { DatabaseDocument.DATABASE_DOCUMENT.PROJECT_ID }, true); + public static final UniqueKey KEY_DATABASE_DOCUMENT_HISTORY_PRIMARY = Internal.createUniqueKey(DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY, DSL.name("KEY_database_document_history_PRIMARY"), new TableField[] { DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.ID }, true); + public static final UniqueKey KEY_DATABASE_DOCUMENT_HISTORY_UK_CONNECTION_ID_VERSION = Internal.createUniqueKey(DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY, DSL.name("KEY_database_document_history_uk_connection_id_version"), new TableField[] { DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.DATABASE_DOCUMENT_ID, DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.VERSION }, true); + public static final UniqueKey KEY_GROUP_PRIMARY = Internal.createUniqueKey(Group.GROUP, DSL.name("KEY_group_PRIMARY"), new TableField[] { Group.GROUP.ID }, true); + public static final UniqueKey KEY_GROUP_UK_NAME = Internal.createUniqueKey(Group.GROUP, DSL.name("KEY_group_uk_name"), new TableField[] { Group.GROUP.NAME }, true); + public static final UniqueKey KEY_LOGIN_PRIMARY = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_PRIMARY"), new TableField[] { Login.LOGIN.ID }, true); + public static final UniqueKey KEY_LOGIN_UK_USER_ID = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_uk_user_id"), new TableField[] { Login.LOGIN.USER_ID }, true); + public static final UniqueKey KEY_PROJECT_PRIMARY = Internal.createUniqueKey(Project.PROJECT, DSL.name("KEY_project_PRIMARY"), new TableField[] { Project.PROJECT.ID }, true); + public static final UniqueKey KEY_PROJECT_UK_GROUP_ID_NAME = Internal.createUniqueKey(Project.PROJECT, DSL.name("KEY_project_uk_group_id_name"), new TableField[] { Project.PROJECT.GROUP_ID, Project.PROJECT.NAME }, true); + public static final UniqueKey KEY_PROJECT_SYNC_RULE_PRIMARY = Internal.createUniqueKey(ProjectSyncRule.PROJECT_SYNC_RULE, DSL.name("KEY_project_sync_rule_PRIMARY"), new TableField[] { ProjectSyncRule.PROJECT_SYNC_RULE.ID }, true); + public static final UniqueKey KEY_PROJECT_SYNC_RULE_UK_PROJECT_ID = Internal.createUniqueKey(ProjectSyncRule.PROJECT_SYNC_RULE, DSL.name("KEY_project_sync_rule_uk_project_id"), new TableField[] { ProjectSyncRule.PROJECT_SYNC_RULE.PROJECT_ID }, true); + public static final UniqueKey KEY_SYS_KEY_PRIMARY = Internal.createUniqueKey(SysKey.SYS_KEY, DSL.name("KEY_sys_key_PRIMARY"), new TableField[] { SysKey.SYS_KEY.ID }, true); + public static final UniqueKey KEY_SYS_MAIL_PRIMARY = Internal.createUniqueKey(SysMail.SYS_MAIL, DSL.name("KEY_sys_mail_PRIMARY"), new TableField[] { SysMail.SYS_MAIL.ID }, true); + public static final UniqueKey KEY_TABLE_COLUMN_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableColumnDocument.TABLE_COLUMN_DOCUMENT, DSL.name("KEY_table_column_document_PRIMARY"), new TableField[] { TableColumnDocument.TABLE_COLUMN_DOCUMENT.ID }, true); + public static final UniqueKey KEY_TABLE_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableDocument.TABLE_DOCUMENT, DSL.name("KEY_table_document_PRIMARY"), new TableField[] { TableDocument.TABLE_DOCUMENT.ID }, true); + public static final UniqueKey KEY_TABLE_INDEX_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableIndexDocument.TABLE_INDEX_DOCUMENT, DSL.name("KEY_table_index_document_PRIMARY"), new TableField[] { TableIndexDocument.TABLE_INDEX_DOCUMENT.ID }, true); + public static final UniqueKey KEY_TABLE_TRIGGER_DOCUMENT_PRIMARY = Internal.createUniqueKey(TableTriggerDocument.TABLE_TRIGGER_DOCUMENT, DSL.name("KEY_table_trigger_document_PRIMARY"), new TableField[] { TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.ID }, true); + public static final UniqueKey KEY_USER_PRIMARY = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_PRIMARY"), new TableField[] { User.USER.ID }, true); + public static final UniqueKey KEY_USER_UK_EMAIL = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_uk_email"), new TableField[] { User.USER.EMAIL }, true); + public static final UniqueKey KEY_USER_UK_USERNAME = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_uk_username"), new TableField[] { User.USER.USERNAME }, true); + public static final UniqueKey KEY_USER_ROLE_PRIMARY = Internal.createUniqueKey(UserRole.USER_ROLE, DSL.name("KEY_user_role_PRIMARY"), new TableField[] { UserRole.USER_ROLE.ID }, true); + public static final UniqueKey KEY_USER_ROLE_UK_USER_ID_GROUP_ID_ROLE = Internal.createUniqueKey(UserRole.USER_ROLE, DSL.name("KEY_user_role_uk_user_id_group_id_role"), new TableField[] { UserRole.USER_ROLE.USER_ID, UserRole.USER_ROLE.GROUP_ID, UserRole.USER_ROLE.ROLE }, true); +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/Tables.java b/dao/generated-src/jooq/main/java/com/databasir/dao/Tables.java new file mode 100644 index 0000000..3eed126 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/Tables.java @@ -0,0 +1,110 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao; + + +import com.databasir.dao.tables.DataSource; +import com.databasir.dao.tables.DataSourceProperty; +import com.databasir.dao.tables.DatabaseDocument; +import com.databasir.dao.tables.DatabaseDocumentHistory; +import com.databasir.dao.tables.Group; +import com.databasir.dao.tables.Login; +import com.databasir.dao.tables.Project; +import com.databasir.dao.tables.ProjectSyncRule; +import com.databasir.dao.tables.SysKey; +import com.databasir.dao.tables.SysMail; +import com.databasir.dao.tables.TableColumnDocument; +import com.databasir.dao.tables.TableDocument; +import com.databasir.dao.tables.TableIndexDocument; +import com.databasir.dao.tables.TableTriggerDocument; +import com.databasir.dao.tables.User; +import com.databasir.dao.tables.UserRole; + + +/** + * Convenience access to all tables in databasir. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Tables { + + /** + * The table databasir.data_source. + */ + public static final DataSource DATA_SOURCE = DataSource.DATA_SOURCE; + + /** + * The table databasir.data_source_property. + */ + public static final DataSourceProperty DATA_SOURCE_PROPERTY = DataSourceProperty.DATA_SOURCE_PROPERTY; + + /** + * The table databasir.database_document. + */ + public static final DatabaseDocument DATABASE_DOCUMENT = DatabaseDocument.DATABASE_DOCUMENT; + + /** + * The table databasir.database_document_history. + */ + public static final DatabaseDocumentHistory DATABASE_DOCUMENT_HISTORY = DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY; + + /** + * The table databasir.group. + */ + public static final Group GROUP = Group.GROUP; + + /** + * The table databasir.login. + */ + public static final Login LOGIN = Login.LOGIN; + + /** + * The table databasir.project. + */ + public static final Project PROJECT = Project.PROJECT; + + /** + * The table databasir.project_sync_rule. + */ + public static final ProjectSyncRule PROJECT_SYNC_RULE = ProjectSyncRule.PROJECT_SYNC_RULE; + + /** + * The table databasir.sys_key. + */ + public static final SysKey SYS_KEY = SysKey.SYS_KEY; + + /** + * The table databasir.sys_mail. + */ + public static final SysMail SYS_MAIL = SysMail.SYS_MAIL; + + /** + * The table databasir.table_column_document. + */ + public static final TableColumnDocument TABLE_COLUMN_DOCUMENT = TableColumnDocument.TABLE_COLUMN_DOCUMENT; + + /** + * The table databasir.table_document. + */ + public static final TableDocument TABLE_DOCUMENT = TableDocument.TABLE_DOCUMENT; + + /** + * The table databasir.table_index_document. + */ + public static final TableIndexDocument TABLE_INDEX_DOCUMENT = TableIndexDocument.TABLE_INDEX_DOCUMENT; + + /** + * The table databasir.table_trigger_document. + */ + public static final TableTriggerDocument TABLE_TRIGGER_DOCUMENT = TableTriggerDocument.TABLE_TRIGGER_DOCUMENT; + + /** + * The table databasir.user. + */ + public static final User USER = User.USER; + + /** + * The table databasir.user_role. + */ + public static final UserRole USER_ROLE = UserRole.USER_ROLE; +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSource.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSource.java new file mode 100644 index 0000000..64251b5 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSource.java @@ -0,0 +1,184 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.DataSourceRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row9; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DataSource extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.data_source + */ + public static final DataSource DATA_SOURCE = new DataSource(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DataSourceRecord.class; + } + + /** + * The column databasir.data_source.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.data_source.project_id. + */ + public final TableField PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.data_source.database_name. + */ + public final TableField DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column databasir.data_source.database_type. + */ + public final TableField DATABASE_TYPE = createField(DSL.name("database_type"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column databasir.data_source.url. + */ + public final TableField URL = createField(DSL.name("url"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.data_source.username. + */ + public final TableField USERNAME = createField(DSL.name("username"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.data_source.password. + */ + public final TableField PASSWORD = createField(DSL.name("password"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.data_source.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.data_source.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private DataSource(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private DataSource(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.data_source table reference + */ + public DataSource(String alias) { + this(DSL.name(alias), DATA_SOURCE); + } + + /** + * Create an aliased databasir.data_source table reference + */ + public DataSource(Name alias) { + this(alias, DATA_SOURCE); + } + + /** + * Create a databasir.data_source table reference + */ + public DataSource() { + this(DSL.name("data_source"), null); + } + + public DataSource(Table child, ForeignKey key) { + super(child, key, DATA_SOURCE); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATA_SOURCE_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_DATA_SOURCE_UK_PROJECT_ID); + } + + @Override + public DataSource as(String alias) { + return new DataSource(DSL.name(alias), this); + } + + @Override + public DataSource as(Name alias) { + return new DataSource(alias, this); + } + + /** + * Rename this table + */ + @Override + public DataSource rename(String name) { + return new DataSource(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public DataSource rename(Name name) { + return new DataSource(name, null); + } + + // ------------------------------------------------------------------------- + // Row9 type methods + // ------------------------------------------------------------------------- + + @Override + public Row9 fieldsRow() { + return (Row9) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSourceProperty.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSourceProperty.java new file mode 100644 index 0000000..d313f35 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DataSourceProperty.java @@ -0,0 +1,168 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Indexes; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.DataSourcePropertyRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row5; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DataSourceProperty extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.data_source_property + */ + public static final DataSourceProperty DATA_SOURCE_PROPERTY = new DataSourceProperty(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DataSourcePropertyRecord.class; + } + + /** + * The column databasir.data_source_property.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.data_source_property.data_source_id. + */ + public final TableField DATA_SOURCE_ID = createField(DSL.name("data_source_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.data_source_property.key. + */ + public final TableField KEY = createField(DSL.name("key"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.data_source_property.value. + */ + public final TableField VALUE = createField(DSL.name("value"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.data_source_property.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private DataSourceProperty(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private DataSourceProperty(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.data_source_property table + * reference + */ + public DataSourceProperty(String alias) { + this(DSL.name(alias), DATA_SOURCE_PROPERTY); + } + + /** + * Create an aliased databasir.data_source_property table + * reference + */ + public DataSourceProperty(Name alias) { + this(alias, DATA_SOURCE_PROPERTY); + } + + /** + * Create a databasir.data_source_property table reference + */ + public DataSourceProperty() { + this(DSL.name("data_source_property"), null); + } + + public DataSourceProperty(Table child, ForeignKey key) { + super(child, key, DATA_SOURCE_PROPERTY); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.DATA_SOURCE_PROPERTY_IDX_DATA_SOURCE_ID); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATA_SOURCE_PROPERTY_PRIMARY; + } + + @Override + public DataSourceProperty as(String alias) { + return new DataSourceProperty(DSL.name(alias), this); + } + + @Override + public DataSourceProperty as(Name alias) { + return new DataSourceProperty(alias, this); + } + + /** + * Rename this table + */ + @Override + public DataSourceProperty rename(String name) { + return new DataSourceProperty(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public DataSourceProperty rename(Name name) { + return new DataSourceProperty(name, null); + } + + // ------------------------------------------------------------------------- + // Row5 type methods + // ------------------------------------------------------------------------- + + @Override + public Row5 fieldsRow() { + return (Row5) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocument.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocument.java new file mode 100644 index 0000000..2e71832 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocument.java @@ -0,0 +1,181 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.DatabaseDocumentRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row8; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatabaseDocument extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.database_document + */ + public static final DatabaseDocument DATABASE_DOCUMENT = new DatabaseDocument(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DatabaseDocumentRecord.class; + } + + /** + * The column databasir.database_document.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.database_document.project_id. + */ + public final TableField PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.database_document.database_name. + */ + public final TableField DATABASE_NAME = createField(DSL.name("database_name"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.database_document.product_name. + */ + public final TableField PRODUCT_NAME = createField(DSL.name("product_name"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.database_document.product_version. + */ + public final TableField PRODUCT_VERSION = createField(DSL.name("product_version"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.database_document.version. + */ + public final TableField VERSION = createField(DSL.name("version"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.inline("1", SQLDataType.BIGINT)), this, ""); + + /** + * The column databasir.database_document.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.database_document.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private DatabaseDocument(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private DatabaseDocument(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.database_document table + * reference + */ + public DatabaseDocument(String alias) { + this(DSL.name(alias), DATABASE_DOCUMENT); + } + + /** + * Create an aliased databasir.database_document table + * reference + */ + public DatabaseDocument(Name alias) { + this(alias, DATABASE_DOCUMENT); + } + + /** + * Create a databasir.database_document table reference + */ + public DatabaseDocument() { + this(DSL.name("database_document"), null); + } + + public DatabaseDocument(Table child, ForeignKey key) { + super(child, key, DATABASE_DOCUMENT); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATABASE_DOCUMENT_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_DATABASE_DOCUMENT_UK_PROJECT_ID); + } + + @Override + public DatabaseDocument as(String alias) { + return new DatabaseDocument(DSL.name(alias), this); + } + + @Override + public DatabaseDocument as(Name alias) { + return new DatabaseDocument(alias, this); + } + + /** + * Rename this table + */ + @Override + public DatabaseDocument rename(String name) { + return new DatabaseDocument(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public DatabaseDocument rename(Name name) { + return new DatabaseDocument(name, null); + } + + // ------------------------------------------------------------------------- + // Row8 type methods + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocumentHistory.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocumentHistory.java new file mode 100644 index 0000000..fa7664b --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/DatabaseDocumentHistory.java @@ -0,0 +1,182 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Indexes; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.DatabaseDocumentHistoryRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.JSON; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatabaseDocumentHistory extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of + * databasir.database_document_history + */ + public static final DatabaseDocumentHistory DATABASE_DOCUMENT_HISTORY = new DatabaseDocumentHistory(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return DatabaseDocumentHistoryRecord.class; + } + + /** + * The column databasir.database_document_history.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.database_document_history.project_id. + */ + public final TableField PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column + * databasir.database_document_history.database_document_id. + */ + public final TableField DATABASE_DOCUMENT_ID = createField(DSL.name("database_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column + * databasir.database_document_history.database_document_object. + */ + public final TableField DATABASE_DOCUMENT_OBJECT = createField(DSL.name("database_document_object"), SQLDataType.JSON, this, ""); + + /** + * The column databasir.database_document_history.version. + */ + public final TableField VERSION = createField(DSL.name("version"), SQLDataType.BIGINT.nullable(false), this, ""); + + /** + * The column databasir.database_document_history.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private DatabaseDocumentHistory(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private DatabaseDocumentHistory(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.database_document_history table + * reference + */ + public DatabaseDocumentHistory(String alias) { + this(DSL.name(alias), DATABASE_DOCUMENT_HISTORY); + } + + /** + * Create an aliased databasir.database_document_history table + * reference + */ + public DatabaseDocumentHistory(Name alias) { + this(alias, DATABASE_DOCUMENT_HISTORY); + } + + /** + * Create a databasir.database_document_history table reference + */ + public DatabaseDocumentHistory() { + this(DSL.name("database_document_history"), null); + } + + public DatabaseDocumentHistory(Table child, ForeignKey key) { + super(child, key, DATABASE_DOCUMENT_HISTORY); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.DATABASE_DOCUMENT_HISTORY_IDX_PROJECT_ID); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_DATABASE_DOCUMENT_HISTORY_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_DATABASE_DOCUMENT_HISTORY_UK_CONNECTION_ID_VERSION); + } + + @Override + public DatabaseDocumentHistory as(String alias) { + return new DatabaseDocumentHistory(DSL.name(alias), this); + } + + @Override + public DatabaseDocumentHistory as(Name alias) { + return new DatabaseDocumentHistory(alias, this); + } + + /** + * Rename this table + */ + @Override + public DatabaseDocumentHistory rename(String name) { + return new DatabaseDocumentHistory(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public DatabaseDocumentHistory rename(Name name) { + return new DatabaseDocumentHistory(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Group.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Group.java new file mode 100644 index 0000000..6a20f38 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Group.java @@ -0,0 +1,169 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.GroupRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Group extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.group + */ + public static final Group GROUP = new Group(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return GroupRecord.class; + } + + /** + * The column databasir.group.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.group.name. + */ + public final TableField NAME = createField(DSL.name("name"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column databasir.group.description. + */ + public final TableField DESCRIPTION = createField(DSL.name("description"), SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column databasir.group.deleted. + */ + public final TableField DELETED = createField(DSL.name("deleted"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.inline("0", SQLDataType.BOOLEAN)), this, ""); + + /** + * The column databasir.group.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.group.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private Group(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Group(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.group table reference + */ + public Group(String alias) { + this(DSL.name(alias), GROUP); + } + + /** + * Create an aliased databasir.group table reference + */ + public Group(Name alias) { + this(alias, GROUP); + } + + /** + * Create a databasir.group table reference + */ + public Group() { + this(DSL.name("group"), null); + } + + public Group(Table child, ForeignKey key) { + super(child, key, GROUP); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_GROUP_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_GROUP_UK_NAME); + } + + @Override + public Group as(String alias) { + return new Group(DSL.name(alias), this); + } + + @Override + public Group as(Name alias) { + return new Group(alias, this); + } + + /** + * Rename this table + */ + @Override + public Group rename(String name) { + return new Group(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Group rename(Name name) { + return new Group(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Login.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Login.java new file mode 100644 index 0000000..55dc139 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Login.java @@ -0,0 +1,179 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.LoginRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row8; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Login extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.login + */ + public static final Login LOGIN = new Login(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return LoginRecord.class; + } + + /** + * The column databasir.login.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.login.user_id. + */ + public final TableField USER_ID = createField(DSL.name("user_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.login.access_token. + */ + public final TableField ACCESS_TOKEN = createField(DSL.name("access_token"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.login.refresh_token. + */ + public final TableField REFRESH_TOKEN = createField(DSL.name("refresh_token"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.login.access_token_expire_at. + */ + public final TableField ACCESS_TOKEN_EXPIRE_AT = createField(DSL.name("access_token_expire_at"), SQLDataType.LOCALDATETIME(0).nullable(false), this, ""); + + /** + * The column databasir.login.refresh_token_expire_at. + */ + public final TableField REFRESH_TOKEN_EXPIRE_AT = createField(DSL.name("refresh_token_expire_at"), SQLDataType.LOCALDATETIME(0).nullable(false), this, ""); + + /** + * The column databasir.login.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.login.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private Login(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Login(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.login table reference + */ + public Login(String alias) { + this(DSL.name(alias), LOGIN); + } + + /** + * Create an aliased databasir.login table reference + */ + public Login(Name alias) { + this(alias, LOGIN); + } + + /** + * Create a databasir.login table reference + */ + public Login() { + this(DSL.name("login"), null); + } + + public Login(Table child, ForeignKey key) { + super(child, key, LOGIN); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_LOGIN_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_LOGIN_UK_USER_ID); + } + + @Override + public Login as(String alias) { + return new Login(DSL.name(alias), this); + } + + @Override + public Login as(Name alias) { + return new Login(alias, this); + } + + /** + * Rename this table + */ + @Override + public Login rename(String name) { + return new Login(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Login rename(Name name) { + return new Login(name, null); + } + + // ------------------------------------------------------------------------- + // Row8 type methods + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Project.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Project.java new file mode 100644 index 0000000..0b06d23 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/Project.java @@ -0,0 +1,169 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.ProjectRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Project extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.project + */ + public static final Project PROJECT = new Project(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return ProjectRecord.class; + } + + /** + * The column databasir.project.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.project.name. + */ + public final TableField NAME = createField(DSL.name("name"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column databasir.project.description. + */ + public final TableField DESCRIPTION = createField(DSL.name("description"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.project.group_id. + */ + public final TableField GROUP_ID = createField(DSL.name("group_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.project.deleted. + */ + public final TableField DELETED = createField(DSL.name("deleted"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.inline("0", SQLDataType.BOOLEAN)), this, ""); + + /** + * The column databasir.project.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private Project(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private Project(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.project table reference + */ + public Project(String alias) { + this(DSL.name(alias), PROJECT); + } + + /** + * Create an aliased databasir.project table reference + */ + public Project(Name alias) { + this(alias, PROJECT); + } + + /** + * Create a databasir.project table reference + */ + public Project() { + this(DSL.name("project"), null); + } + + public Project(Table child, ForeignKey key) { + super(child, key, PROJECT); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_PROJECT_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_PROJECT_UK_GROUP_ID_NAME); + } + + @Override + public Project as(String alias) { + return new Project(DSL.name(alias), this); + } + + @Override + public Project as(Name alias) { + return new Project(alias, this); + } + + /** + * Rename this table + */ + @Override + public Project rename(String name) { + return new Project(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public Project rename(Name name) { + return new Project(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/ProjectSyncRule.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/ProjectSyncRule.java new file mode 100644 index 0000000..3407302 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/ProjectSyncRule.java @@ -0,0 +1,174 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.ProjectSyncRuleRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.JSON; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ProjectSyncRule extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.project_sync_rule + */ + public static final ProjectSyncRule PROJECT_SYNC_RULE = new ProjectSyncRule(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return ProjectSyncRuleRecord.class; + } + + /** + * The column databasir.project_sync_rule.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.project_sync_rule.project_id. + */ + public final TableField PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column + * databasir.project_sync_rule.ignore_table_name_regex_array. + */ + public final TableField IGNORE_TABLE_NAME_REGEX_ARRAY = createField(DSL.name("ignore_table_name_regex_array"), SQLDataType.JSON.nullable(false), this, ""); + + /** + * The column + * databasir.project_sync_rule.ignore_column_name_regex_array. + */ + public final TableField IGNORE_COLUMN_NAME_REGEX_ARRAY = createField(DSL.name("ignore_column_name_regex_array"), SQLDataType.JSON.nullable(false), this, ""); + + /** + * The column databasir.project_sync_rule.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.project_sync_rule.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private ProjectSyncRule(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private ProjectSyncRule(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.project_sync_rule table + * reference + */ + public ProjectSyncRule(String alias) { + this(DSL.name(alias), PROJECT_SYNC_RULE); + } + + /** + * Create an aliased databasir.project_sync_rule table + * reference + */ + public ProjectSyncRule(Name alias) { + this(alias, PROJECT_SYNC_RULE); + } + + /** + * Create a databasir.project_sync_rule table reference + */ + public ProjectSyncRule() { + this(DSL.name("project_sync_rule"), null); + } + + public ProjectSyncRule(Table child, ForeignKey key) { + super(child, key, PROJECT_SYNC_RULE); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_PROJECT_SYNC_RULE_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_PROJECT_SYNC_RULE_UK_PROJECT_ID); + } + + @Override + public ProjectSyncRule as(String alias) { + return new ProjectSyncRule(DSL.name(alias), this); + } + + @Override + public ProjectSyncRule as(Name alias) { + return new ProjectSyncRule(alias, this); + } + + /** + * Rename this table + */ + @Override + public ProjectSyncRule rename(String name) { + return new ProjectSyncRule(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public ProjectSyncRule rename(Name name) { + return new ProjectSyncRule(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/SysKey.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/SysKey.java new file mode 100644 index 0000000..828e984 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/SysKey.java @@ -0,0 +1,162 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.SysKeyRecord; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class SysKey extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.sys_key + */ + public static final SysKey SYS_KEY = new SysKey(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return SysKeyRecord.class; + } + + /** + * The column databasir.sys_key.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.sys_key.rsa_public_key. + */ + public final TableField RSA_PUBLIC_KEY = createField(DSL.name("rsa_public_key"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.sys_key.rsa_private_key. + */ + public final TableField RSA_PRIVATE_KEY = createField(DSL.name("rsa_private_key"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.sys_key.aes_key. + */ + public final TableField AES_KEY = createField(DSL.name("aes_key"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.sys_key.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.sys_key.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private SysKey(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private SysKey(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.sys_key table reference + */ + public SysKey(String alias) { + this(DSL.name(alias), SYS_KEY); + } + + /** + * Create an aliased databasir.sys_key table reference + */ + public SysKey(Name alias) { + this(alias, SYS_KEY); + } + + /** + * Create a databasir.sys_key table reference + */ + public SysKey() { + this(DSL.name("sys_key"), null); + } + + public SysKey(Table child, ForeignKey key) { + super(child, key, SYS_KEY); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_SYS_KEY_PRIMARY; + } + + @Override + public SysKey as(String alias) { + return new SysKey(DSL.name(alias), this); + } + + @Override + public SysKey as(Name alias) { + return new SysKey(alias, this); + } + + /** + * Rename this table + */ + @Override + public SysKey rename(String name) { + return new SysKey(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public SysKey rename(Name name) { + return new SysKey(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/SysMail.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/SysMail.java new file mode 100644 index 0000000..39978db --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/SysMail.java @@ -0,0 +1,167 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.SysMailRecord; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row7; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class SysMail extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.sys_mail + */ + public static final SysMail SYS_MAIL = new SysMail(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return SysMailRecord.class; + } + + /** + * The column databasir.sys_mail.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.sys_mail.username. + */ + public final TableField USERNAME = createField(DSL.name("username"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.sys_mail.password. + */ + public final TableField PASSWORD = createField(DSL.name("password"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.sys_mail.smtp_host. + */ + public final TableField SMTP_HOST = createField(DSL.name("smtp_host"), SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column databasir.sys_mail.smtp_port. + */ + public final TableField SMTP_PORT = createField(DSL.name("smtp_port"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.sys_mail.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.sys_mail.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private SysMail(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private SysMail(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.sys_mail table reference + */ + public SysMail(String alias) { + this(DSL.name(alias), SYS_MAIL); + } + + /** + * Create an aliased databasir.sys_mail table reference + */ + public SysMail(Name alias) { + this(alias, SYS_MAIL); + } + + /** + * Create a databasir.sys_mail table reference + */ + public SysMail() { + this(DSL.name("sys_mail"), null); + } + + public SysMail(Table child, ForeignKey key) { + super(child, key, SYS_MAIL); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_SYS_MAIL_PRIMARY; + } + + @Override + public SysMail as(String alias) { + return new SysMail(DSL.name(alias), this); + } + + @Override + public SysMail as(Name alias) { + return new SysMail(alias, this); + } + + /** + * Rename this table + */ + @Override + public SysMail rename(String name) { + return new SysMail(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public SysMail rename(Name name) { + return new SysMail(name, null); + } + + // ------------------------------------------------------------------------- + // Row7 type methods + // ------------------------------------------------------------------------- + + @Override + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableColumnDocument.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableColumnDocument.java new file mode 100644 index 0000000..2672f31 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableColumnDocument.java @@ -0,0 +1,207 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Indexes; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.TableColumnDocumentRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row12; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableColumnDocument extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.table_column_document + */ + public static final TableColumnDocument TABLE_COLUMN_DOCUMENT = new TableColumnDocument(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return TableColumnDocumentRecord.class; + } + + /** + * The column databasir.table_column_document.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column + * databasir.table_column_document.table_document_id. + */ + public final TableField TABLE_DOCUMENT_ID = createField(DSL.name("table_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column + * databasir.table_column_document.database_document_id. + */ + public final TableField DATABASE_DOCUMENT_ID = createField(DSL.name("database_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.table_column_document.name. + */ + public final TableField NAME = createField(DSL.name("name"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.table_column_document.type. + */ + public final TableField TYPE = createField(DSL.name("type"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column databasir.table_column_document.comment. + */ + public final TableField COMMENT = createField(DSL.name("comment"), SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column databasir.table_column_document.default_value. + */ + public final TableField DEFAULT_VALUE = createField(DSL.name("default_value"), SQLDataType.VARCHAR(512), this, ""); + + /** + * The column databasir.table_column_document.size. + */ + public final TableField SIZE = createField(DSL.name("size"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.table_column_document.decimal_digits. + */ + public final TableField DECIMAL_DIGITS = createField(DSL.name("decimal_digits"), SQLDataType.INTEGER, this, ""); + + /** + * The column databasir.table_column_document.nullable. YES, + * NO, UNKNOWN + */ + public final TableField NULLABLE = createField(DSL.name("nullable"), SQLDataType.VARCHAR(64).nullable(false), this, "YES, NO, UNKNOWN"); + + /** + * The column databasir.table_column_document.auto_increment. + * YES, NO, UNKNOWN + */ + public final TableField AUTO_INCREMENT = createField(DSL.name("auto_increment"), SQLDataType.VARCHAR(64).nullable(false), this, "YES, NO, UNKNOWN"); + + /** + * The column databasir.table_column_document.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private TableColumnDocument(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private TableColumnDocument(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.table_column_document table + * reference + */ + public TableColumnDocument(String alias) { + this(DSL.name(alias), TABLE_COLUMN_DOCUMENT); + } + + /** + * Create an aliased databasir.table_column_document table + * reference + */ + public TableColumnDocument(Name alias) { + this(alias, TABLE_COLUMN_DOCUMENT); + } + + /** + * Create a databasir.table_column_document table reference + */ + public TableColumnDocument() { + this(DSL.name("table_column_document"), null); + } + + public TableColumnDocument(Table child, ForeignKey key) { + super(child, key, TABLE_COLUMN_DOCUMENT); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.TABLE_COLUMN_DOCUMENT_IDX_DATABASE_DOCUMENT_ID, Indexes.TABLE_COLUMN_DOCUMENT_IDX_TABLE_DOCUMENT_ID); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_TABLE_COLUMN_DOCUMENT_PRIMARY; + } + + @Override + public TableColumnDocument as(String alias) { + return new TableColumnDocument(DSL.name(alias), this); + } + + @Override + public TableColumnDocument as(Name alias) { + return new TableColumnDocument(alias, this); + } + + /** + * Rename this table + */ + @Override + public TableColumnDocument rename(String name) { + return new TableColumnDocument(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public TableColumnDocument rename(Name name) { + return new TableColumnDocument(name, null); + } + + // ------------------------------------------------------------------------- + // Row12 type methods + // ------------------------------------------------------------------------- + + @Override + public Row12 fieldsRow() { + return (Row12) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableDocument.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableDocument.java new file mode 100644 index 0000000..3e38576 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableDocument.java @@ -0,0 +1,171 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Indexes; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.TableDocumentRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row6; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableDocument extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.table_document + */ + public static final TableDocument TABLE_DOCUMENT = new TableDocument(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return TableDocumentRecord.class; + } + + /** + * The column databasir.table_document.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.table_document.database_document_id. + */ + public final TableField DATABASE_DOCUMENT_ID = createField(DSL.name("database_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.table_document.name. + */ + public final TableField NAME = createField(DSL.name("name"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.table_document.type. + */ + public final TableField TYPE = createField(DSL.name("type"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.table_document.comment. + */ + public final TableField COMMENT = createField(DSL.name("comment"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.table_document.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private TableDocument(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private TableDocument(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.table_document table reference + */ + public TableDocument(String alias) { + this(DSL.name(alias), TABLE_DOCUMENT); + } + + /** + * Create an aliased databasir.table_document table reference + */ + public TableDocument(Name alias) { + this(alias, TABLE_DOCUMENT); + } + + /** + * Create a databasir.table_document table reference + */ + public TableDocument() { + this(DSL.name("table_document"), null); + } + + public TableDocument(Table child, ForeignKey key) { + super(child, key, TABLE_DOCUMENT); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.TABLE_DOCUMENT_IDX_DATABASE_DOCUMENT_ID); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_TABLE_DOCUMENT_PRIMARY; + } + + @Override + public TableDocument as(String alias) { + return new TableDocument(DSL.name(alias), this); + } + + @Override + public TableDocument as(Name alias) { + return new TableDocument(alias, this); + } + + /** + * Rename this table + */ + @Override + public TableDocument rename(String name) { + return new TableDocument(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public TableDocument rename(Name name) { + return new TableDocument(name, null); + } + + // ------------------------------------------------------------------------- + // Row6 type methods + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableIndexDocument.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableIndexDocument.java new file mode 100644 index 0000000..a97605a --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableIndexDocument.java @@ -0,0 +1,185 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Indexes; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.TableIndexDocumentRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.JSON; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row8; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableIndexDocument extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.table_index_document + */ + public static final TableIndexDocument TABLE_INDEX_DOCUMENT = new TableIndexDocument(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return TableIndexDocumentRecord.class; + } + + /** + * The column databasir.table_index_document.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.table_index_document.table_document_id. + */ + public final TableField TABLE_DOCUMENT_ID = createField(DSL.name("table_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column + * databasir.table_index_document.database_document_id. + */ + public final TableField DATABASE_DOCUMENT_ID = createField(DSL.name("database_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.table_index_document.name. + */ + public final TableField NAME = createField(DSL.name("name"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.table_index_document.is_primary. + */ + public final TableField IS_PRIMARY = createField(DSL.name("is_primary"), SQLDataType.BOOLEAN.nullable(false), this, ""); + + /** + * The column databasir.table_index_document.is_unique. + */ + public final TableField IS_UNIQUE = createField(DSL.name("is_unique"), SQLDataType.BOOLEAN.nullable(false), this, ""); + + /** + * The column databasir.table_index_document.column_name_array. + */ + public final TableField COLUMN_NAME_ARRAY = createField(DSL.name("column_name_array"), SQLDataType.JSON.nullable(false), this, ""); + + /** + * The column databasir.table_index_document.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private TableIndexDocument(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private TableIndexDocument(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.table_index_document table + * reference + */ + public TableIndexDocument(String alias) { + this(DSL.name(alias), TABLE_INDEX_DOCUMENT); + } + + /** + * Create an aliased databasir.table_index_document table + * reference + */ + public TableIndexDocument(Name alias) { + this(alias, TABLE_INDEX_DOCUMENT); + } + + /** + * Create a databasir.table_index_document table reference + */ + public TableIndexDocument() { + this(DSL.name("table_index_document"), null); + } + + public TableIndexDocument(Table child, ForeignKey key) { + super(child, key, TABLE_INDEX_DOCUMENT); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.TABLE_INDEX_DOCUMENT_IDX_DATABASE_DOCUMENT_ID, Indexes.TABLE_INDEX_DOCUMENT_IDX_TABLE_DOCUMENT_ID); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_TABLE_INDEX_DOCUMENT_PRIMARY; + } + + @Override + public TableIndexDocument as(String alias) { + return new TableIndexDocument(DSL.name(alias), this); + } + + @Override + public TableIndexDocument as(Name alias) { + return new TableIndexDocument(alias, this); + } + + /** + * Rename this table + */ + @Override + public TableIndexDocument rename(String name) { + return new TableIndexDocument(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public TableIndexDocument rename(Name name) { + return new TableIndexDocument(name, null); + } + + // ------------------------------------------------------------------------- + // Row8 type methods + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableTriggerDocument.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableTriggerDocument.java new file mode 100644 index 0000000..c0c45cd --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/TableTriggerDocument.java @@ -0,0 +1,186 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Indexes; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.TableTriggerDocumentRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Index; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row8; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableTriggerDocument extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.table_trigger_document + */ + public static final TableTriggerDocument TABLE_TRIGGER_DOCUMENT = new TableTriggerDocument(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return TableTriggerDocumentRecord.class; + } + + /** + * The column databasir.table_trigger_document.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column + * databasir.table_trigger_document.table_document_id. + */ + public final TableField TABLE_DOCUMENT_ID = createField(DSL.name("table_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column + * databasir.table_trigger_document.database_document_id. + */ + public final TableField DATABASE_DOCUMENT_ID = createField(DSL.name("database_document_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.table_trigger_document.timing. + */ + public final TableField TIMING = createField(DSL.name("timing"), SQLDataType.VARCHAR(64).nullable(false), this, ""); + + /** + * The column databasir.table_trigger_document.manipulation. + */ + public final TableField MANIPULATION = createField(DSL.name("manipulation"), SQLDataType.VARCHAR(128).nullable(false), this, ""); + + /** + * The column databasir.table_trigger_document.statement. + */ + public final TableField STATEMENT = createField(DSL.name("statement"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column + * databasir.table_trigger_document.trigger_create_at. + */ + public final TableField TRIGGER_CREATE_AT = createField(DSL.name("trigger_create_at"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column databasir.table_trigger_document.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private TableTriggerDocument(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private TableTriggerDocument(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.table_trigger_document table + * reference + */ + public TableTriggerDocument(String alias) { + this(DSL.name(alias), TABLE_TRIGGER_DOCUMENT); + } + + /** + * Create an aliased databasir.table_trigger_document table + * reference + */ + public TableTriggerDocument(Name alias) { + this(alias, TABLE_TRIGGER_DOCUMENT); + } + + /** + * Create a databasir.table_trigger_document table reference + */ + public TableTriggerDocument() { + this(DSL.name("table_trigger_document"), null); + } + + public TableTriggerDocument(Table child, ForeignKey key) { + super(child, key, TABLE_TRIGGER_DOCUMENT); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public List getIndexes() { + return Arrays.asList(Indexes.TABLE_TRIGGER_DOCUMENT_IDX_DATABASE_DOCUMENT_ID, Indexes.TABLE_TRIGGER_DOCUMENT_IDX_TABLE_DOCUMENT_ID); + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_TABLE_TRIGGER_DOCUMENT_PRIMARY; + } + + @Override + public TableTriggerDocument as(String alias) { + return new TableTriggerDocument(DSL.name(alias), this); + } + + @Override + public TableTriggerDocument as(Name alias) { + return new TableTriggerDocument(alias, this); + } + + /** + * Rename this table + */ + @Override + public TableTriggerDocument rename(String name) { + return new TableTriggerDocument(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public TableTriggerDocument rename(Name name) { + return new TableTriggerDocument(name, null); + } + + // ------------------------------------------------------------------------- + // Row8 type methods + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/User.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/User.java new file mode 100644 index 0000000..91ed384 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/User.java @@ -0,0 +1,184 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.UserRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row9; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class User extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.user + */ + public static final User USER = new User(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return UserRecord.class; + } + + /** + * The column databasir.user.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.user.email. + */ + public final TableField EMAIL = createField(DSL.name("email"), SQLDataType.VARCHAR(512).nullable(false), this, ""); + + /** + * The column databasir.user.username. + */ + public final TableField USERNAME = createField(DSL.name("username"), SQLDataType.VARCHAR(128).nullable(false), this, ""); + + /** + * The column databasir.user.password. + */ + public final TableField PASSWORD = createField(DSL.name("password"), SQLDataType.CLOB.nullable(false), this, ""); + + /** + * The column databasir.user.nickname. + */ + public final TableField NICKNAME = createField(DSL.name("nickname"), SQLDataType.VARCHAR(255).nullable(false), this, ""); + + /** + * The column databasir.user.avatar. + */ + public final TableField AVATAR = createField(DSL.name("avatar"), SQLDataType.VARCHAR(512), this, ""); + + /** + * The column databasir.user.enabled. + */ + public final TableField ENABLED = createField(DSL.name("enabled"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.inline("0", SQLDataType.BOOLEAN)), this, ""); + + /** + * The column databasir.user.update_at. + */ + public final TableField UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + /** + * The column databasir.user.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private User(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private User(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.user table reference + */ + public User(String alias) { + this(DSL.name(alias), USER); + } + + /** + * Create an aliased databasir.user table reference + */ + public User(Name alias) { + this(alias, USER); + } + + /** + * Create a databasir.user table reference + */ + public User() { + this(DSL.name("user"), null); + } + + public User(Table child, ForeignKey key) { + super(child, key, USER); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_USER_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_USER_UK_EMAIL, Keys.KEY_USER_UK_USERNAME); + } + + @Override + public User as(String alias) { + return new User(DSL.name(alias), this); + } + + @Override + public User as(Name alias) { + return new User(alias, this); + } + + /** + * Rename this table + */ + @Override + public User rename(String name) { + return new User(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public User rename(Name name) { + return new User(name, null); + } + + // ------------------------------------------------------------------------- + // Row9 type methods + // ------------------------------------------------------------------------- + + @Override + public Row9 fieldsRow() { + return (Row9) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/UserRole.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/UserRole.java new file mode 100644 index 0000000..42adcda --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/UserRole.java @@ -0,0 +1,165 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables; + + +import com.databasir.dao.Databasir; +import com.databasir.dao.Keys; +import com.databasir.dao.tables.records.UserRoleRecord; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import org.jooq.Field; +import org.jooq.ForeignKey; +import org.jooq.Identity; +import org.jooq.Name; +import org.jooq.Record; +import org.jooq.Row5; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.TableOptions; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.jooq.impl.TableImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UserRole extends TableImpl { + + private static final long serialVersionUID = 1L; + + /** + * The reference instance of databasir.user_role + */ + public static final UserRole USER_ROLE = new UserRole(); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return UserRoleRecord.class; + } + + /** + * The column databasir.user_role.id. + */ + public final TableField ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); + + /** + * The column databasir.user_role.user_id. + */ + public final TableField USER_ID = createField(DSL.name("user_id"), SQLDataType.INTEGER.nullable(false), this, ""); + + /** + * The column databasir.user_role.role. SYS_OWNER, GROUP_OWNER, + * GROUP_MEMBER + */ + public final TableField ROLE = createField(DSL.name("role"), SQLDataType.VARCHAR(128).nullable(false), this, "SYS_OWNER, GROUP_OWNER, GROUP_MEMBER"); + + /** + * The column databasir.user_role.group_id. + */ + public final TableField GROUP_ID = createField(DSL.name("group_id"), SQLDataType.INTEGER, this, ""); + + /** + * The column databasir.user_role.create_at. + */ + public final TableField CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); + + private UserRole(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private UserRole(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); + } + + /** + * Create an aliased databasir.user_role table reference + */ + public UserRole(String alias) { + this(DSL.name(alias), USER_ROLE); + } + + /** + * Create an aliased databasir.user_role table reference + */ + public UserRole(Name alias) { + this(alias, USER_ROLE); + } + + /** + * Create a databasir.user_role table reference + */ + public UserRole() { + this(DSL.name("user_role"), null); + } + + public UserRole(Table child, ForeignKey key) { + super(child, key, USER_ROLE); + } + + @Override + public Schema getSchema() { + return aliased() ? null : Databasir.DATABASIR; + } + + @Override + public Identity getIdentity() { + return (Identity) super.getIdentity(); + } + + @Override + public UniqueKey getPrimaryKey() { + return Keys.KEY_USER_ROLE_PRIMARY; + } + + @Override + public List> getUniqueKeys() { + return Arrays.asList(Keys.KEY_USER_ROLE_UK_USER_ID_GROUP_ID_ROLE); + } + + @Override + public UserRole as(String alias) { + return new UserRole(DSL.name(alias), this); + } + + @Override + public UserRole as(Name alias) { + return new UserRole(alias, this); + } + + /** + * Rename this table + */ + @Override + public UserRole rename(String name) { + return new UserRole(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public UserRole rename(Name name) { + return new UserRole(name, null); + } + + // ------------------------------------------------------------------------- + // Row5 type methods + // ------------------------------------------------------------------------- + + @Override + public Row5 fieldsRow() { + return (Row5) super.fieldsRow(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePojo.java new file mode 100644 index 0000000..090a83e --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePojo.java @@ -0,0 +1,208 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DataSourcePojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer projectId; + private String databaseName; + private String databaseType; + private String url; + private String username; + private String password; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public DataSourcePojo() {} + + public DataSourcePojo(DataSourcePojo value) { + this.id = value.id; + this.projectId = value.projectId; + this.databaseName = value.databaseName; + this.databaseType = value.databaseType; + this.url = value.url; + this.username = value.username; + this.password = value.password; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public DataSourcePojo( + Integer id, + Integer projectId, + String databaseName, + String databaseType, + String url, + String username, + String password, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.projectId = projectId; + this.databaseName = databaseName; + this.databaseType = databaseType; + this.url = url; + this.username = username; + this.password = password; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.data_source.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.data_source.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.data_source.project_id. + */ + public Integer getProjectId() { + return this.projectId; + } + + /** + * Setter for databasir.data_source.project_id. + */ + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + /** + * Getter for databasir.data_source.database_name. + */ + public String getDatabaseName() { + return this.databaseName; + } + + /** + * Setter for databasir.data_source.database_name. + */ + public void setDatabaseName(String databaseName) { + this.databaseName = databaseName; + } + + /** + * Getter for databasir.data_source.database_type. + */ + public String getDatabaseType() { + return this.databaseType; + } + + /** + * Setter for databasir.data_source.database_type. + */ + public void setDatabaseType(String databaseType) { + this.databaseType = databaseType; + } + + /** + * Getter for databasir.data_source.url. + */ + public String getUrl() { + return this.url; + } + + /** + * Setter for databasir.data_source.url. + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * Getter for databasir.data_source.username. + */ + public String getUsername() { + return this.username; + } + + /** + * Setter for databasir.data_source.username. + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Getter for databasir.data_source.password. + */ + public String getPassword() { + return this.password; + } + + /** + * Setter for databasir.data_source.password. + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Getter for databasir.data_source.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.data_source.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.data_source.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.data_source.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("DataSourcePojo ("); + + sb.append(id); + sb.append(", ").append(projectId); + sb.append(", ").append(databaseName); + sb.append(", ").append(databaseType); + sb.append(", ").append(url); + sb.append(", ").append(username); + sb.append(", ").append(password); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePropertyPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePropertyPojo.java new file mode 100644 index 0000000..d63fcfa --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DataSourcePropertyPojo.java @@ -0,0 +1,132 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DataSourcePropertyPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer dataSourceId; + private String key; + private String value; + private LocalDateTime createAt; + + public DataSourcePropertyPojo() {} + + public DataSourcePropertyPojo(DataSourcePropertyPojo value) { + this.id = value.id; + this.dataSourceId = value.dataSourceId; + this.key = value.key; + this.value = value.value; + this.createAt = value.createAt; + } + + public DataSourcePropertyPojo( + Integer id, + Integer dataSourceId, + String key, + String value, + LocalDateTime createAt + ) { + this.id = id; + this.dataSourceId = dataSourceId; + this.key = key; + this.value = value; + this.createAt = createAt; + } + + /** + * Getter for databasir.data_source_property.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.data_source_property.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.data_source_property.data_source_id. + */ + public Integer getDataSourceId() { + return this.dataSourceId; + } + + /** + * Setter for databasir.data_source_property.data_source_id. + */ + public void setDataSourceId(Integer dataSourceId) { + this.dataSourceId = dataSourceId; + } + + /** + * Getter for databasir.data_source_property.key. + */ + public String getKey() { + return this.key; + } + + /** + * Setter for databasir.data_source_property.key. + */ + public void setKey(String key) { + this.key = key; + } + + /** + * Getter for databasir.data_source_property.value. + */ + public String getValue() { + return this.value; + } + + /** + * Setter for databasir.data_source_property.value. + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Getter for databasir.data_source_property.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.data_source_property.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("DataSourcePropertyPojo ("); + + sb.append(id); + sb.append(", ").append(dataSourceId); + sb.append(", ").append(key); + sb.append(", ").append(value); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentHistoryPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentHistoryPojo.java new file mode 100644 index 0000000..db013f5 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentHistoryPojo.java @@ -0,0 +1,157 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + +import org.jooq.JSON; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatabaseDocumentHistoryPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer projectId; + private Integer databaseDocumentId; + private JSON databaseDocumentObject; + private Long version; + private LocalDateTime createAt; + + public DatabaseDocumentHistoryPojo() {} + + public DatabaseDocumentHistoryPojo(DatabaseDocumentHistoryPojo value) { + this.id = value.id; + this.projectId = value.projectId; + this.databaseDocumentId = value.databaseDocumentId; + this.databaseDocumentObject = value.databaseDocumentObject; + this.version = value.version; + this.createAt = value.createAt; + } + + public DatabaseDocumentHistoryPojo( + Integer id, + Integer projectId, + Integer databaseDocumentId, + JSON databaseDocumentObject, + Long version, + LocalDateTime createAt + ) { + this.id = id; + this.projectId = projectId; + this.databaseDocumentId = databaseDocumentId; + this.databaseDocumentObject = databaseDocumentObject; + this.version = version; + this.createAt = createAt; + } + + /** + * Getter for databasir.database_document_history.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.database_document_history.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.database_document_history.project_id. + */ + public Integer getProjectId() { + return this.projectId; + } + + /** + * Setter for databasir.database_document_history.project_id. + */ + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + /** + * Getter for + * databasir.database_document_history.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return this.databaseDocumentId; + } + + /** + * Setter for + * databasir.database_document_history.database_document_id. + */ + public void setDatabaseDocumentId(Integer databaseDocumentId) { + this.databaseDocumentId = databaseDocumentId; + } + + /** + * Getter for + * databasir.database_document_history.database_document_object. + */ + public JSON getDatabaseDocumentObject() { + return this.databaseDocumentObject; + } + + /** + * Setter for + * databasir.database_document_history.database_document_object. + */ + public void setDatabaseDocumentObject(JSON databaseDocumentObject) { + this.databaseDocumentObject = databaseDocumentObject; + } + + /** + * Getter for databasir.database_document_history.version. + */ + public Long getVersion() { + return this.version; + } + + /** + * Setter for databasir.database_document_history.version. + */ + public void setVersion(Long version) { + this.version = version; + } + + /** + * Getter for databasir.database_document_history.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.database_document_history.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("DatabaseDocumentHistoryPojo ("); + + sb.append(id); + sb.append(", ").append(projectId); + sb.append(", ").append(databaseDocumentId); + sb.append(", ").append(databaseDocumentObject); + sb.append(", ").append(version); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentPojo.java new file mode 100644 index 0000000..8da82e7 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/DatabaseDocumentPojo.java @@ -0,0 +1,189 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatabaseDocumentPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer projectId; + private String databaseName; + private String productName; + private String productVersion; + private Long version; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public DatabaseDocumentPojo() {} + + public DatabaseDocumentPojo(DatabaseDocumentPojo value) { + this.id = value.id; + this.projectId = value.projectId; + this.databaseName = value.databaseName; + this.productName = value.productName; + this.productVersion = value.productVersion; + this.version = value.version; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public DatabaseDocumentPojo( + Integer id, + Integer projectId, + String databaseName, + String productName, + String productVersion, + Long version, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.projectId = projectId; + this.databaseName = databaseName; + this.productName = productName; + this.productVersion = productVersion; + this.version = version; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.database_document.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.database_document.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.database_document.project_id. + */ + public Integer getProjectId() { + return this.projectId; + } + + /** + * Setter for databasir.database_document.project_id. + */ + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + /** + * Getter for databasir.database_document.database_name. + */ + public String getDatabaseName() { + return this.databaseName; + } + + /** + * Setter for databasir.database_document.database_name. + */ + public void setDatabaseName(String databaseName) { + this.databaseName = databaseName; + } + + /** + * Getter for databasir.database_document.product_name. + */ + public String getProductName() { + return this.productName; + } + + /** + * Setter for databasir.database_document.product_name. + */ + public void setProductName(String productName) { + this.productName = productName; + } + + /** + * Getter for databasir.database_document.product_version. + */ + public String getProductVersion() { + return this.productVersion; + } + + /** + * Setter for databasir.database_document.product_version. + */ + public void setProductVersion(String productVersion) { + this.productVersion = productVersion; + } + + /** + * Getter for databasir.database_document.version. + */ + public Long getVersion() { + return this.version; + } + + /** + * Setter for databasir.database_document.version. + */ + public void setVersion(Long version) { + this.version = version; + } + + /** + * Getter for databasir.database_document.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.database_document.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.database_document.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.database_document.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("DatabaseDocumentPojo ("); + + sb.append(id); + sb.append(", ").append(projectId); + sb.append(", ").append(databaseName); + sb.append(", ").append(productName); + sb.append(", ").append(productVersion); + sb.append(", ").append(version); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/GroupPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/GroupPojo.java new file mode 100644 index 0000000..20f310a --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/GroupPojo.java @@ -0,0 +1,151 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class GroupPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private String name; + private String description; + private Boolean deleted; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public GroupPojo() {} + + public GroupPojo(GroupPojo value) { + this.id = value.id; + this.name = value.name; + this.description = value.description; + this.deleted = value.deleted; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public GroupPojo( + Integer id, + String name, + String description, + Boolean deleted, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.name = name; + this.description = description; + this.deleted = deleted; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.group.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.group.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.group.name. + */ + public String getName() { + return this.name; + } + + /** + * Setter for databasir.group.name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for databasir.group.description. + */ + public String getDescription() { + return this.description; + } + + /** + * Setter for databasir.group.description. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Getter for databasir.group.deleted. + */ + public Boolean getDeleted() { + return this.deleted; + } + + /** + * Setter for databasir.group.deleted. + */ + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + + /** + * Getter for databasir.group.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.group.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.group.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.group.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("GroupPojo ("); + + sb.append(id); + sb.append(", ").append(name); + sb.append(", ").append(description); + sb.append(", ").append(deleted); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/LoginPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/LoginPojo.java new file mode 100644 index 0000000..a816044 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/LoginPojo.java @@ -0,0 +1,189 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class LoginPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer userId; + private String accessToken; + private String refreshToken; + private LocalDateTime accessTokenExpireAt; + private LocalDateTime refreshTokenExpireAt; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public LoginPojo() {} + + public LoginPojo(LoginPojo value) { + this.id = value.id; + this.userId = value.userId; + this.accessToken = value.accessToken; + this.refreshToken = value.refreshToken; + this.accessTokenExpireAt = value.accessTokenExpireAt; + this.refreshTokenExpireAt = value.refreshTokenExpireAt; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public LoginPojo( + Integer id, + Integer userId, + String accessToken, + String refreshToken, + LocalDateTime accessTokenExpireAt, + LocalDateTime refreshTokenExpireAt, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.userId = userId; + this.accessToken = accessToken; + this.refreshToken = refreshToken; + this.accessTokenExpireAt = accessTokenExpireAt; + this.refreshTokenExpireAt = refreshTokenExpireAt; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.login.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.login.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.login.user_id. + */ + public Integer getUserId() { + return this.userId; + } + + /** + * Setter for databasir.login.user_id. + */ + public void setUserId(Integer userId) { + this.userId = userId; + } + + /** + * Getter for databasir.login.access_token. + */ + public String getAccessToken() { + return this.accessToken; + } + + /** + * Setter for databasir.login.access_token. + */ + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + /** + * Getter for databasir.login.refresh_token. + */ + public String getRefreshToken() { + return this.refreshToken; + } + + /** + * Setter for databasir.login.refresh_token. + */ + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + + /** + * Getter for databasir.login.access_token_expire_at. + */ + public LocalDateTime getAccessTokenExpireAt() { + return this.accessTokenExpireAt; + } + + /** + * Setter for databasir.login.access_token_expire_at. + */ + public void setAccessTokenExpireAt(LocalDateTime accessTokenExpireAt) { + this.accessTokenExpireAt = accessTokenExpireAt; + } + + /** + * Getter for databasir.login.refresh_token_expire_at. + */ + public LocalDateTime getRefreshTokenExpireAt() { + return this.refreshTokenExpireAt; + } + + /** + * Setter for databasir.login.refresh_token_expire_at. + */ + public void setRefreshTokenExpireAt(LocalDateTime refreshTokenExpireAt) { + this.refreshTokenExpireAt = refreshTokenExpireAt; + } + + /** + * Getter for databasir.login.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.login.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.login.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.login.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("LoginPojo ("); + + sb.append(id); + sb.append(", ").append(userId); + sb.append(", ").append(accessToken); + sb.append(", ").append(refreshToken); + sb.append(", ").append(accessTokenExpireAt); + sb.append(", ").append(refreshTokenExpireAt); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/ProjectPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/ProjectPojo.java new file mode 100644 index 0000000..c28942a --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/ProjectPojo.java @@ -0,0 +1,151 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ProjectPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private String name; + private String description; + private Integer groupId; + private Boolean deleted; + private LocalDateTime createAt; + + public ProjectPojo() {} + + public ProjectPojo(ProjectPojo value) { + this.id = value.id; + this.name = value.name; + this.description = value.description; + this.groupId = value.groupId; + this.deleted = value.deleted; + this.createAt = value.createAt; + } + + public ProjectPojo( + Integer id, + String name, + String description, + Integer groupId, + Boolean deleted, + LocalDateTime createAt + ) { + this.id = id; + this.name = name; + this.description = description; + this.groupId = groupId; + this.deleted = deleted; + this.createAt = createAt; + } + + /** + * Getter for databasir.project.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.project.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.project.name. + */ + public String getName() { + return this.name; + } + + /** + * Setter for databasir.project.name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for databasir.project.description. + */ + public String getDescription() { + return this.description; + } + + /** + * Setter for databasir.project.description. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Getter for databasir.project.group_id. + */ + public Integer getGroupId() { + return this.groupId; + } + + /** + * Setter for databasir.project.group_id. + */ + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + + /** + * Getter for databasir.project.deleted. + */ + public Boolean getDeleted() { + return this.deleted; + } + + /** + * Setter for databasir.project.deleted. + */ + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + + /** + * Getter for databasir.project.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.project.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ProjectPojo ("); + + sb.append(id); + sb.append(", ").append(name); + sb.append(", ").append(description); + sb.append(", ").append(groupId); + sb.append(", ").append(deleted); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/ProjectSyncRulePojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/ProjectSyncRulePojo.java new file mode 100644 index 0000000..d16d912 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/ProjectSyncRulePojo.java @@ -0,0 +1,157 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + +import org.jooq.JSON; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ProjectSyncRulePojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer projectId; + private JSON ignoreTableNameRegexArray; + private JSON ignoreColumnNameRegexArray; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public ProjectSyncRulePojo() {} + + public ProjectSyncRulePojo(ProjectSyncRulePojo value) { + this.id = value.id; + this.projectId = value.projectId; + this.ignoreTableNameRegexArray = value.ignoreTableNameRegexArray; + this.ignoreColumnNameRegexArray = value.ignoreColumnNameRegexArray; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public ProjectSyncRulePojo( + Integer id, + Integer projectId, + JSON ignoreTableNameRegexArray, + JSON ignoreColumnNameRegexArray, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.projectId = projectId; + this.ignoreTableNameRegexArray = ignoreTableNameRegexArray; + this.ignoreColumnNameRegexArray = ignoreColumnNameRegexArray; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.project_sync_rule.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.project_sync_rule.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.project_sync_rule.project_id. + */ + public Integer getProjectId() { + return this.projectId; + } + + /** + * Setter for databasir.project_sync_rule.project_id. + */ + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + /** + * Getter for + * databasir.project_sync_rule.ignore_table_name_regex_array. + */ + public JSON getIgnoreTableNameRegexArray() { + return this.ignoreTableNameRegexArray; + } + + /** + * Setter for + * databasir.project_sync_rule.ignore_table_name_regex_array. + */ + public void setIgnoreTableNameRegexArray(JSON ignoreTableNameRegexArray) { + this.ignoreTableNameRegexArray = ignoreTableNameRegexArray; + } + + /** + * Getter for + * databasir.project_sync_rule.ignore_column_name_regex_array. + */ + public JSON getIgnoreColumnNameRegexArray() { + return this.ignoreColumnNameRegexArray; + } + + /** + * Setter for + * databasir.project_sync_rule.ignore_column_name_regex_array. + */ + public void setIgnoreColumnNameRegexArray(JSON ignoreColumnNameRegexArray) { + this.ignoreColumnNameRegexArray = ignoreColumnNameRegexArray; + } + + /** + * Getter for databasir.project_sync_rule.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.project_sync_rule.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.project_sync_rule.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.project_sync_rule.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ProjectSyncRulePojo ("); + + sb.append(id); + sb.append(", ").append(projectId); + sb.append(", ").append(ignoreTableNameRegexArray); + sb.append(", ").append(ignoreColumnNameRegexArray); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/SysKeyPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/SysKeyPojo.java new file mode 100644 index 0000000..1cc8bd2 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/SysKeyPojo.java @@ -0,0 +1,151 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class SysKeyPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private String rsaPublicKey; + private String rsaPrivateKey; + private String aesKey; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public SysKeyPojo() {} + + public SysKeyPojo(SysKeyPojo value) { + this.id = value.id; + this.rsaPublicKey = value.rsaPublicKey; + this.rsaPrivateKey = value.rsaPrivateKey; + this.aesKey = value.aesKey; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public SysKeyPojo( + Integer id, + String rsaPublicKey, + String rsaPrivateKey, + String aesKey, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.rsaPublicKey = rsaPublicKey; + this.rsaPrivateKey = rsaPrivateKey; + this.aesKey = aesKey; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.sys_key.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.sys_key.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.sys_key.rsa_public_key. + */ + public String getRsaPublicKey() { + return this.rsaPublicKey; + } + + /** + * Setter for databasir.sys_key.rsa_public_key. + */ + public void setRsaPublicKey(String rsaPublicKey) { + this.rsaPublicKey = rsaPublicKey; + } + + /** + * Getter for databasir.sys_key.rsa_private_key. + */ + public String getRsaPrivateKey() { + return this.rsaPrivateKey; + } + + /** + * Setter for databasir.sys_key.rsa_private_key. + */ + public void setRsaPrivateKey(String rsaPrivateKey) { + this.rsaPrivateKey = rsaPrivateKey; + } + + /** + * Getter for databasir.sys_key.aes_key. + */ + public String getAesKey() { + return this.aesKey; + } + + /** + * Setter for databasir.sys_key.aes_key. + */ + public void setAesKey(String aesKey) { + this.aesKey = aesKey; + } + + /** + * Getter for databasir.sys_key.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.sys_key.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.sys_key.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.sys_key.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("SysKeyPojo ("); + + sb.append(id); + sb.append(", ").append(rsaPublicKey); + sb.append(", ").append(rsaPrivateKey); + sb.append(", ").append(aesKey); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/SysMailPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/SysMailPojo.java new file mode 100644 index 0000000..966ad6e --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/SysMailPojo.java @@ -0,0 +1,170 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class SysMailPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private String username; + private String password; + private String smtpHost; + private Integer smtpPort; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public SysMailPojo() {} + + public SysMailPojo(SysMailPojo value) { + this.id = value.id; + this.username = value.username; + this.password = value.password; + this.smtpHost = value.smtpHost; + this.smtpPort = value.smtpPort; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public SysMailPojo( + Integer id, + String username, + String password, + String smtpHost, + Integer smtpPort, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.username = username; + this.password = password; + this.smtpHost = smtpHost; + this.smtpPort = smtpPort; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.sys_mail.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.sys_mail.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.sys_mail.username. + */ + public String getUsername() { + return this.username; + } + + /** + * Setter for databasir.sys_mail.username. + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Getter for databasir.sys_mail.password. + */ + public String getPassword() { + return this.password; + } + + /** + * Setter for databasir.sys_mail.password. + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Getter for databasir.sys_mail.smtp_host. + */ + public String getSmtpHost() { + return this.smtpHost; + } + + /** + * Setter for databasir.sys_mail.smtp_host. + */ + public void setSmtpHost(String smtpHost) { + this.smtpHost = smtpHost; + } + + /** + * Getter for databasir.sys_mail.smtp_port. + */ + public Integer getSmtpPort() { + return this.smtpPort; + } + + /** + * Setter for databasir.sys_mail.smtp_port. + */ + public void setSmtpPort(Integer smtpPort) { + this.smtpPort = smtpPort; + } + + /** + * Getter for databasir.sys_mail.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.sys_mail.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.sys_mail.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.sys_mail.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("SysMailPojo ("); + + sb.append(id); + sb.append(", ").append(username); + sb.append(", ").append(password); + sb.append(", ").append(smtpHost); + sb.append(", ").append(smtpPort); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableColumnDocumentPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableColumnDocumentPojo.java new file mode 100644 index 0000000..ca88836 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableColumnDocumentPojo.java @@ -0,0 +1,273 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableColumnDocumentPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer tableDocumentId; + private Integer databaseDocumentId; + private String name; + private String type; + private String comment; + private String defaultValue; + private Integer size; + private Integer decimalDigits; + private String nullable; + private String autoIncrement; + private LocalDateTime createAt; + + public TableColumnDocumentPojo() {} + + public TableColumnDocumentPojo(TableColumnDocumentPojo value) { + this.id = value.id; + this.tableDocumentId = value.tableDocumentId; + this.databaseDocumentId = value.databaseDocumentId; + this.name = value.name; + this.type = value.type; + this.comment = value.comment; + this.defaultValue = value.defaultValue; + this.size = value.size; + this.decimalDigits = value.decimalDigits; + this.nullable = value.nullable; + this.autoIncrement = value.autoIncrement; + this.createAt = value.createAt; + } + + public TableColumnDocumentPojo( + Integer id, + Integer tableDocumentId, + Integer databaseDocumentId, + String name, + String type, + String comment, + String defaultValue, + Integer size, + Integer decimalDigits, + String nullable, + String autoIncrement, + LocalDateTime createAt + ) { + this.id = id; + this.tableDocumentId = tableDocumentId; + this.databaseDocumentId = databaseDocumentId; + this.name = name; + this.type = type; + this.comment = comment; + this.defaultValue = defaultValue; + this.size = size; + this.decimalDigits = decimalDigits; + this.nullable = nullable; + this.autoIncrement = autoIncrement; + this.createAt = createAt; + } + + /** + * Getter for databasir.table_column_document.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.table_column_document.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for + * databasir.table_column_document.table_document_id. + */ + public Integer getTableDocumentId() { + return this.tableDocumentId; + } + + /** + * Setter for + * databasir.table_column_document.table_document_id. + */ + public void setTableDocumentId(Integer tableDocumentId) { + this.tableDocumentId = tableDocumentId; + } + + /** + * Getter for + * databasir.table_column_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return this.databaseDocumentId; + } + + /** + * Setter for + * databasir.table_column_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer databaseDocumentId) { + this.databaseDocumentId = databaseDocumentId; + } + + /** + * Getter for databasir.table_column_document.name. + */ + public String getName() { + return this.name; + } + + /** + * Setter for databasir.table_column_document.name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for databasir.table_column_document.type. + */ + public String getType() { + return this.type; + } + + /** + * Setter for databasir.table_column_document.type. + */ + public void setType(String type) { + this.type = type; + } + + /** + * Getter for databasir.table_column_document.comment. + */ + public String getComment() { + return this.comment; + } + + /** + * Setter for databasir.table_column_document.comment. + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * Getter for databasir.table_column_document.default_value. + */ + public String getDefaultValue() { + return this.defaultValue; + } + + /** + * Setter for databasir.table_column_document.default_value. + */ + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * Getter for databasir.table_column_document.size. + */ + public Integer getSize() { + return this.size; + } + + /** + * Setter for databasir.table_column_document.size. + */ + public void setSize(Integer size) { + this.size = size; + } + + /** + * Getter for databasir.table_column_document.decimal_digits. + */ + public Integer getDecimalDigits() { + return this.decimalDigits; + } + + /** + * Setter for databasir.table_column_document.decimal_digits. + */ + public void setDecimalDigits(Integer decimalDigits) { + this.decimalDigits = decimalDigits; + } + + /** + * Getter for databasir.table_column_document.nullable. YES, + * NO, UNKNOWN + */ + public String getNullable() { + return this.nullable; + } + + /** + * Setter for databasir.table_column_document.nullable. YES, + * NO, UNKNOWN + */ + public void setNullable(String nullable) { + this.nullable = nullable; + } + + /** + * Getter for databasir.table_column_document.auto_increment. + * YES, NO, UNKNOWN + */ + public String getAutoIncrement() { + return this.autoIncrement; + } + + /** + * Setter for databasir.table_column_document.auto_increment. + * YES, NO, UNKNOWN + */ + public void setAutoIncrement(String autoIncrement) { + this.autoIncrement = autoIncrement; + } + + /** + * Getter for databasir.table_column_document.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.table_column_document.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TableColumnDocumentPojo ("); + + sb.append(id); + sb.append(", ").append(tableDocumentId); + sb.append(", ").append(databaseDocumentId); + sb.append(", ").append(name); + sb.append(", ").append(type); + sb.append(", ").append(comment); + sb.append(", ").append(defaultValue); + sb.append(", ").append(size); + sb.append(", ").append(decimalDigits); + sb.append(", ").append(nullable); + sb.append(", ").append(autoIncrement); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableDocumentPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableDocumentPojo.java new file mode 100644 index 0000000..50da9bd --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableDocumentPojo.java @@ -0,0 +1,151 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableDocumentPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer databaseDocumentId; + private String name; + private String type; + private String comment; + private LocalDateTime createAt; + + public TableDocumentPojo() {} + + public TableDocumentPojo(TableDocumentPojo value) { + this.id = value.id; + this.databaseDocumentId = value.databaseDocumentId; + this.name = value.name; + this.type = value.type; + this.comment = value.comment; + this.createAt = value.createAt; + } + + public TableDocumentPojo( + Integer id, + Integer databaseDocumentId, + String name, + String type, + String comment, + LocalDateTime createAt + ) { + this.id = id; + this.databaseDocumentId = databaseDocumentId; + this.name = name; + this.type = type; + this.comment = comment; + this.createAt = createAt; + } + + /** + * Getter for databasir.table_document.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.table_document.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.table_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return this.databaseDocumentId; + } + + /** + * Setter for databasir.table_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer databaseDocumentId) { + this.databaseDocumentId = databaseDocumentId; + } + + /** + * Getter for databasir.table_document.name. + */ + public String getName() { + return this.name; + } + + /** + * Setter for databasir.table_document.name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for databasir.table_document.type. + */ + public String getType() { + return this.type; + } + + /** + * Setter for databasir.table_document.type. + */ + public void setType(String type) { + this.type = type; + } + + /** + * Getter for databasir.table_document.comment. + */ + public String getComment() { + return this.comment; + } + + /** + * Setter for databasir.table_document.comment. + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** + * Getter for databasir.table_document.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.table_document.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TableDocumentPojo ("); + + sb.append(id); + sb.append(", ").append(databaseDocumentId); + sb.append(", ").append(name); + sb.append(", ").append(type); + sb.append(", ").append(comment); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableIndexDocumentPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableIndexDocumentPojo.java new file mode 100644 index 0000000..7fd02b8 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableIndexDocumentPojo.java @@ -0,0 +1,193 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + +import org.jooq.JSON; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableIndexDocumentPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer tableDocumentId; + private Integer databaseDocumentId; + private String name; + private Boolean isPrimary; + private Boolean isUnique; + private JSON columnNameArray; + private LocalDateTime createAt; + + public TableIndexDocumentPojo() {} + + public TableIndexDocumentPojo(TableIndexDocumentPojo value) { + this.id = value.id; + this.tableDocumentId = value.tableDocumentId; + this.databaseDocumentId = value.databaseDocumentId; + this.name = value.name; + this.isPrimary = value.isPrimary; + this.isUnique = value.isUnique; + this.columnNameArray = value.columnNameArray; + this.createAt = value.createAt; + } + + public TableIndexDocumentPojo( + Integer id, + Integer tableDocumentId, + Integer databaseDocumentId, + String name, + Boolean isPrimary, + Boolean isUnique, + JSON columnNameArray, + LocalDateTime createAt + ) { + this.id = id; + this.tableDocumentId = tableDocumentId; + this.databaseDocumentId = databaseDocumentId; + this.name = name; + this.isPrimary = isPrimary; + this.isUnique = isUnique; + this.columnNameArray = columnNameArray; + this.createAt = createAt; + } + + /** + * Getter for databasir.table_index_document.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.table_index_document.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.table_index_document.table_document_id. + */ + public Integer getTableDocumentId() { + return this.tableDocumentId; + } + + /** + * Setter for databasir.table_index_document.table_document_id. + */ + public void setTableDocumentId(Integer tableDocumentId) { + this.tableDocumentId = tableDocumentId; + } + + /** + * Getter for + * databasir.table_index_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return this.databaseDocumentId; + } + + /** + * Setter for + * databasir.table_index_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer databaseDocumentId) { + this.databaseDocumentId = databaseDocumentId; + } + + /** + * Getter for databasir.table_index_document.name. + */ + public String getName() { + return this.name; + } + + /** + * Setter for databasir.table_index_document.name. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getter for databasir.table_index_document.is_primary. + */ + public Boolean getIsPrimary() { + return this.isPrimary; + } + + /** + * Setter for databasir.table_index_document.is_primary. + */ + public void setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + } + + /** + * Getter for databasir.table_index_document.is_unique. + */ + public Boolean getIsUnique() { + return this.isUnique; + } + + /** + * Setter for databasir.table_index_document.is_unique. + */ + public void setIsUnique(Boolean isUnique) { + this.isUnique = isUnique; + } + + /** + * Getter for databasir.table_index_document.column_name_array. + */ + public JSON getColumnNameArray() { + return this.columnNameArray; + } + + /** + * Setter for databasir.table_index_document.column_name_array. + */ + public void setColumnNameArray(JSON columnNameArray) { + this.columnNameArray = columnNameArray; + } + + /** + * Getter for databasir.table_index_document.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.table_index_document.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TableIndexDocumentPojo ("); + + sb.append(id); + sb.append(", ").append(tableDocumentId); + sb.append(", ").append(databaseDocumentId); + sb.append(", ").append(name); + sb.append(", ").append(isPrimary); + sb.append(", ").append(isUnique); + sb.append(", ").append(columnNameArray); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableTriggerDocumentPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableTriggerDocumentPojo.java new file mode 100644 index 0000000..af31324 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/TableTriggerDocumentPojo.java @@ -0,0 +1,195 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableTriggerDocumentPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer tableDocumentId; + private Integer databaseDocumentId; + private String timing; + private String manipulation; + private String statement; + private String triggerCreateAt; + private LocalDateTime createAt; + + public TableTriggerDocumentPojo() {} + + public TableTriggerDocumentPojo(TableTriggerDocumentPojo value) { + this.id = value.id; + this.tableDocumentId = value.tableDocumentId; + this.databaseDocumentId = value.databaseDocumentId; + this.timing = value.timing; + this.manipulation = value.manipulation; + this.statement = value.statement; + this.triggerCreateAt = value.triggerCreateAt; + this.createAt = value.createAt; + } + + public TableTriggerDocumentPojo( + Integer id, + Integer tableDocumentId, + Integer databaseDocumentId, + String timing, + String manipulation, + String statement, + String triggerCreateAt, + LocalDateTime createAt + ) { + this.id = id; + this.tableDocumentId = tableDocumentId; + this.databaseDocumentId = databaseDocumentId; + this.timing = timing; + this.manipulation = manipulation; + this.statement = statement; + this.triggerCreateAt = triggerCreateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.table_trigger_document.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.table_trigger_document.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for + * databasir.table_trigger_document.table_document_id. + */ + public Integer getTableDocumentId() { + return this.tableDocumentId; + } + + /** + * Setter for + * databasir.table_trigger_document.table_document_id. + */ + public void setTableDocumentId(Integer tableDocumentId) { + this.tableDocumentId = tableDocumentId; + } + + /** + * Getter for + * databasir.table_trigger_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return this.databaseDocumentId; + } + + /** + * Setter for + * databasir.table_trigger_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer databaseDocumentId) { + this.databaseDocumentId = databaseDocumentId; + } + + /** + * Getter for databasir.table_trigger_document.timing. + */ + public String getTiming() { + return this.timing; + } + + /** + * Setter for databasir.table_trigger_document.timing. + */ + public void setTiming(String timing) { + this.timing = timing; + } + + /** + * Getter for databasir.table_trigger_document.manipulation. + */ + public String getManipulation() { + return this.manipulation; + } + + /** + * Setter for databasir.table_trigger_document.manipulation. + */ + public void setManipulation(String manipulation) { + this.manipulation = manipulation; + } + + /** + * Getter for databasir.table_trigger_document.statement. + */ + public String getStatement() { + return this.statement; + } + + /** + * Setter for databasir.table_trigger_document.statement. + */ + public void setStatement(String statement) { + this.statement = statement; + } + + /** + * Getter for + * databasir.table_trigger_document.trigger_create_at. + */ + public String getTriggerCreateAt() { + return this.triggerCreateAt; + } + + /** + * Setter for + * databasir.table_trigger_document.trigger_create_at. + */ + public void setTriggerCreateAt(String triggerCreateAt) { + this.triggerCreateAt = triggerCreateAt; + } + + /** + * Getter for databasir.table_trigger_document.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.table_trigger_document.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TableTriggerDocumentPojo ("); + + sb.append(id); + sb.append(", ").append(tableDocumentId); + sb.append(", ").append(databaseDocumentId); + sb.append(", ").append(timing); + sb.append(", ").append(manipulation); + sb.append(", ").append(statement); + sb.append(", ").append(triggerCreateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/UserPojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/UserPojo.java new file mode 100644 index 0000000..779d141 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/UserPojo.java @@ -0,0 +1,208 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UserPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private String email; + private String username; + private String password; + private String nickname; + private String avatar; + private Boolean enabled; + private LocalDateTime updateAt; + private LocalDateTime createAt; + + public UserPojo() {} + + public UserPojo(UserPojo value) { + this.id = value.id; + this.email = value.email; + this.username = value.username; + this.password = value.password; + this.nickname = value.nickname; + this.avatar = value.avatar; + this.enabled = value.enabled; + this.updateAt = value.updateAt; + this.createAt = value.createAt; + } + + public UserPojo( + Integer id, + String email, + String username, + String password, + String nickname, + String avatar, + Boolean enabled, + LocalDateTime updateAt, + LocalDateTime createAt + ) { + this.id = id; + this.email = email; + this.username = username; + this.password = password; + this.nickname = nickname; + this.avatar = avatar; + this.enabled = enabled; + this.updateAt = updateAt; + this.createAt = createAt; + } + + /** + * Getter for databasir.user.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.user.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.user.email. + */ + public String getEmail() { + return this.email; + } + + /** + * Setter for databasir.user.email. + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Getter for databasir.user.username. + */ + public String getUsername() { + return this.username; + } + + /** + * Setter for databasir.user.username. + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Getter for databasir.user.password. + */ + public String getPassword() { + return this.password; + } + + /** + * Setter for databasir.user.password. + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Getter for databasir.user.nickname. + */ + public String getNickname() { + return this.nickname; + } + + /** + * Setter for databasir.user.nickname. + */ + public void setNickname(String nickname) { + this.nickname = nickname; + } + + /** + * Getter for databasir.user.avatar. + */ + public String getAvatar() { + return this.avatar; + } + + /** + * Setter for databasir.user.avatar. + */ + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + /** + * Getter for databasir.user.enabled. + */ + public Boolean getEnabled() { + return this.enabled; + } + + /** + * Setter for databasir.user.enabled. + */ + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * Getter for databasir.user.update_at. + */ + public LocalDateTime getUpdateAt() { + return this.updateAt; + } + + /** + * Setter for databasir.user.update_at. + */ + public void setUpdateAt(LocalDateTime updateAt) { + this.updateAt = updateAt; + } + + /** + * Getter for databasir.user.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.user.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("UserPojo ("); + + sb.append(id); + sb.append(", ").append(email); + sb.append(", ").append(username); + sb.append(", ").append(password); + sb.append(", ").append(nickname); + sb.append(", ").append(avatar); + sb.append(", ").append(enabled); + sb.append(", ").append(updateAt); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/UserRolePojo.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/UserRolePojo.java new file mode 100644 index 0000000..3bc0bd2 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/UserRolePojo.java @@ -0,0 +1,134 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.pojos; + + +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UserRolePojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + private Integer userId; + private String role; + private Integer groupId; + private LocalDateTime createAt; + + public UserRolePojo() {} + + public UserRolePojo(UserRolePojo value) { + this.id = value.id; + this.userId = value.userId; + this.role = value.role; + this.groupId = value.groupId; + this.createAt = value.createAt; + } + + public UserRolePojo( + Integer id, + Integer userId, + String role, + Integer groupId, + LocalDateTime createAt + ) { + this.id = id; + this.userId = userId; + this.role = role; + this.groupId = groupId; + this.createAt = createAt; + } + + /** + * Getter for databasir.user_role.id. + */ + public Integer getId() { + return this.id; + } + + /** + * Setter for databasir.user_role.id. + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * Getter for databasir.user_role.user_id. + */ + public Integer getUserId() { + return this.userId; + } + + /** + * Setter for databasir.user_role.user_id. + */ + public void setUserId(Integer userId) { + this.userId = userId; + } + + /** + * Getter for databasir.user_role.role. SYS_OWNER, GROUP_OWNER, + * GROUP_MEMBER + */ + public String getRole() { + return this.role; + } + + /** + * Setter for databasir.user_role.role. SYS_OWNER, GROUP_OWNER, + * GROUP_MEMBER + */ + public void setRole(String role) { + this.role = role; + } + + /** + * Getter for databasir.user_role.group_id. + */ + public Integer getGroupId() { + return this.groupId; + } + + /** + * Setter for databasir.user_role.group_id. + */ + public void setGroupId(Integer groupId) { + this.groupId = groupId; + } + + /** + * Getter for databasir.user_role.create_at. + */ + public LocalDateTime getCreateAt() { + return this.createAt; + } + + /** + * Setter for databasir.user_role.create_at. + */ + public void setCreateAt(LocalDateTime createAt) { + this.createAt = createAt; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("UserRolePojo ("); + + sb.append(id); + sb.append(", ").append(userId); + sb.append(", ").append(role); + sb.append(", ").append(groupId); + sb.append(", ").append(createAt); + + sb.append(")"); + return sb.toString(); + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourcePropertyRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourcePropertyRecord.java new file mode 100644 index 0000000..e29d0db --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourcePropertyRecord.java @@ -0,0 +1,273 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.DataSourceProperty; +import com.databasir.dao.tables.pojos.DataSourcePropertyPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record5; +import org.jooq.Row5; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DataSourcePropertyRecord extends UpdatableRecordImpl implements Record5 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.data_source_property.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.data_source_property.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.data_source_property.data_source_id. + */ + public void setDataSourceId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.data_source_property.data_source_id. + */ + public Integer getDataSourceId() { + return (Integer) get(1); + } + + /** + * Setter for databasir.data_source_property.key. + */ + public void setKey(String value) { + set(2, value); + } + + /** + * Getter for databasir.data_source_property.key. + */ + public String getKey() { + return (String) get(2); + } + + /** + * Setter for databasir.data_source_property.value. + */ + public void setValue(String value) { + set(3, value); + } + + /** + * Getter for databasir.data_source_property.value. + */ + public String getValue() { + return (String) get(3); + } + + /** + * Setter for databasir.data_source_property.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(4, value); + } + + /** + * Getter for databasir.data_source_property.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(4); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record5 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row5 fieldsRow() { + return (Row5) super.fieldsRow(); + } + + @Override + public Row5 valuesRow() { + return (Row5) super.valuesRow(); + } + + @Override + public Field field1() { + return DataSourceProperty.DATA_SOURCE_PROPERTY.ID; + } + + @Override + public Field field2() { + return DataSourceProperty.DATA_SOURCE_PROPERTY.DATA_SOURCE_ID; + } + + @Override + public Field field3() { + return DataSourceProperty.DATA_SOURCE_PROPERTY.KEY; + } + + @Override + public Field field4() { + return DataSourceProperty.DATA_SOURCE_PROPERTY.VALUE; + } + + @Override + public Field field5() { + return DataSourceProperty.DATA_SOURCE_PROPERTY.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getDataSourceId(); + } + + @Override + public String component3() { + return getKey(); + } + + @Override + public String component4() { + return getValue(); + } + + @Override + public LocalDateTime component5() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getDataSourceId(); + } + + @Override + public String value3() { + return getKey(); + } + + @Override + public String value4() { + return getValue(); + } + + @Override + public LocalDateTime value5() { + return getCreateAt(); + } + + @Override + public DataSourcePropertyRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public DataSourcePropertyRecord value2(Integer value) { + setDataSourceId(value); + return this; + } + + @Override + public DataSourcePropertyRecord value3(String value) { + setKey(value); + return this; + } + + @Override + public DataSourcePropertyRecord value4(String value) { + setValue(value); + return this; + } + + @Override + public DataSourcePropertyRecord value5(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public DataSourcePropertyRecord values(Integer value1, Integer value2, String value3, String value4, LocalDateTime value5) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DataSourcePropertyRecord + */ + public DataSourcePropertyRecord() { + super(DataSourceProperty.DATA_SOURCE_PROPERTY); + } + + /** + * Create a detached, initialised DataSourcePropertyRecord + */ + public DataSourcePropertyRecord(Integer id, Integer dataSourceId, String key, String value, LocalDateTime createAt) { + super(DataSourceProperty.DATA_SOURCE_PROPERTY); + + setId(id); + setDataSourceId(dataSourceId); + setKey(key); + setValue(value); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised DataSourcePropertyRecord + */ + public DataSourcePropertyRecord(DataSourcePropertyPojo value) { + super(DataSourceProperty.DATA_SOURCE_PROPERTY); + + if (value != null) { + setId(value.getId()); + setDataSourceId(value.getDataSourceId()); + setKey(value.getKey()); + setValue(value.getValue()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourceRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourceRecord.java new file mode 100644 index 0000000..e151b72 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DataSourceRecord.java @@ -0,0 +1,425 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.DataSource; +import com.databasir.dao.tables.pojos.DataSourcePojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record9; +import org.jooq.Row9; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DataSourceRecord extends UpdatableRecordImpl implements Record9 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.data_source.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.data_source.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.data_source.project_id. + */ + public void setProjectId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.data_source.project_id. + */ + public Integer getProjectId() { + return (Integer) get(1); + } + + /** + * Setter for databasir.data_source.database_name. + */ + public void setDatabaseName(String value) { + set(2, value); + } + + /** + * Getter for databasir.data_source.database_name. + */ + public String getDatabaseName() { + return (String) get(2); + } + + /** + * Setter for databasir.data_source.database_type. + */ + public void setDatabaseType(String value) { + set(3, value); + } + + /** + * Getter for databasir.data_source.database_type. + */ + public String getDatabaseType() { + return (String) get(3); + } + + /** + * Setter for databasir.data_source.url. + */ + public void setUrl(String value) { + set(4, value); + } + + /** + * Getter for databasir.data_source.url. + */ + public String getUrl() { + return (String) get(4); + } + + /** + * Setter for databasir.data_source.username. + */ + public void setUsername(String value) { + set(5, value); + } + + /** + * Getter for databasir.data_source.username. + */ + public String getUsername() { + return (String) get(5); + } + + /** + * Setter for databasir.data_source.password. + */ + public void setPassword(String value) { + set(6, value); + } + + /** + * Getter for databasir.data_source.password. + */ + public String getPassword() { + return (String) get(6); + } + + /** + * Setter for databasir.data_source.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(7, value); + } + + /** + * Getter for databasir.data_source.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(7); + } + + /** + * Setter for databasir.data_source.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(8, value); + } + + /** + * Getter for databasir.data_source.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(8); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record9 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row9 fieldsRow() { + return (Row9) super.fieldsRow(); + } + + @Override + public Row9 valuesRow() { + return (Row9) super.valuesRow(); + } + + @Override + public Field field1() { + return DataSource.DATA_SOURCE.ID; + } + + @Override + public Field field2() { + return DataSource.DATA_SOURCE.PROJECT_ID; + } + + @Override + public Field field3() { + return DataSource.DATA_SOURCE.DATABASE_NAME; + } + + @Override + public Field field4() { + return DataSource.DATA_SOURCE.DATABASE_TYPE; + } + + @Override + public Field field5() { + return DataSource.DATA_SOURCE.URL; + } + + @Override + public Field field6() { + return DataSource.DATA_SOURCE.USERNAME; + } + + @Override + public Field field7() { + return DataSource.DATA_SOURCE.PASSWORD; + } + + @Override + public Field field8() { + return DataSource.DATA_SOURCE.UPDATE_AT; + } + + @Override + public Field field9() { + return DataSource.DATA_SOURCE.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getProjectId(); + } + + @Override + public String component3() { + return getDatabaseName(); + } + + @Override + public String component4() { + return getDatabaseType(); + } + + @Override + public String component5() { + return getUrl(); + } + + @Override + public String component6() { + return getUsername(); + } + + @Override + public String component7() { + return getPassword(); + } + + @Override + public LocalDateTime component8() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component9() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getProjectId(); + } + + @Override + public String value3() { + return getDatabaseName(); + } + + @Override + public String value4() { + return getDatabaseType(); + } + + @Override + public String value5() { + return getUrl(); + } + + @Override + public String value6() { + return getUsername(); + } + + @Override + public String value7() { + return getPassword(); + } + + @Override + public LocalDateTime value8() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value9() { + return getCreateAt(); + } + + @Override + public DataSourceRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public DataSourceRecord value2(Integer value) { + setProjectId(value); + return this; + } + + @Override + public DataSourceRecord value3(String value) { + setDatabaseName(value); + return this; + } + + @Override + public DataSourceRecord value4(String value) { + setDatabaseType(value); + return this; + } + + @Override + public DataSourceRecord value5(String value) { + setUrl(value); + return this; + } + + @Override + public DataSourceRecord value6(String value) { + setUsername(value); + return this; + } + + @Override + public DataSourceRecord value7(String value) { + setPassword(value); + return this; + } + + @Override + public DataSourceRecord value8(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public DataSourceRecord value9(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public DataSourceRecord values(Integer value1, Integer value2, String value3, String value4, String value5, String value6, String value7, LocalDateTime value8, LocalDateTime value9) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DataSourceRecord + */ + public DataSourceRecord() { + super(DataSource.DATA_SOURCE); + } + + /** + * Create a detached, initialised DataSourceRecord + */ + public DataSourceRecord(Integer id, Integer projectId, String databaseName, String databaseType, String url, String username, String password, LocalDateTime updateAt, LocalDateTime createAt) { + super(DataSource.DATA_SOURCE); + + setId(id); + setProjectId(projectId); + setDatabaseName(databaseName); + setDatabaseType(databaseType); + setUrl(url); + setUsername(username); + setPassword(password); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised DataSourceRecord + */ + public DataSourceRecord(DataSourcePojo value) { + super(DataSource.DATA_SOURCE); + + if (value != null) { + setId(value.getId()); + setProjectId(value.getProjectId()); + setDatabaseName(value.getDatabaseName()); + setDatabaseType(value.getDatabaseType()); + setUrl(value.getUrl()); + setUsername(value.getUsername()); + setPassword(value.getPassword()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentHistoryRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentHistoryRecord.java new file mode 100644 index 0000000..ca46154 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentHistoryRecord.java @@ -0,0 +1,316 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.DatabaseDocumentHistory; +import com.databasir.dao.tables.pojos.DatabaseDocumentHistoryPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.JSON; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatabaseDocumentHistoryRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.database_document_history.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.database_document_history.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.database_document_history.project_id. + */ + public void setProjectId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.database_document_history.project_id. + */ + public Integer getProjectId() { + return (Integer) get(1); + } + + /** + * Setter for + * databasir.database_document_history.database_document_id. + */ + public void setDatabaseDocumentId(Integer value) { + set(2, value); + } + + /** + * Getter for + * databasir.database_document_history.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return (Integer) get(2); + } + + /** + * Setter for + * databasir.database_document_history.database_document_object. + */ + public void setDatabaseDocumentObject(JSON value) { + set(3, value); + } + + /** + * Getter for + * databasir.database_document_history.database_document_object. + */ + public JSON getDatabaseDocumentObject() { + return (JSON) get(3); + } + + /** + * Setter for databasir.database_document_history.version. + */ + public void setVersion(Long value) { + set(4, value); + } + + /** + * Getter for databasir.database_document_history.version. + */ + public Long getVersion() { + return (Long) get(4); + } + + /** + * Setter for databasir.database_document_history.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.database_document_history.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.ID; + } + + @Override + public Field field2() { + return DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.PROJECT_ID; + } + + @Override + public Field field3() { + return DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.DATABASE_DOCUMENT_ID; + } + + @Override + public Field field4() { + return DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.DATABASE_DOCUMENT_OBJECT; + } + + @Override + public Field field5() { + return DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.VERSION; + } + + @Override + public Field field6() { + return DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getProjectId(); + } + + @Override + public Integer component3() { + return getDatabaseDocumentId(); + } + + @Override + public JSON component4() { + return getDatabaseDocumentObject(); + } + + @Override + public Long component5() { + return getVersion(); + } + + @Override + public LocalDateTime component6() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getProjectId(); + } + + @Override + public Integer value3() { + return getDatabaseDocumentId(); + } + + @Override + public JSON value4() { + return getDatabaseDocumentObject(); + } + + @Override + public Long value5() { + return getVersion(); + } + + @Override + public LocalDateTime value6() { + return getCreateAt(); + } + + @Override + public DatabaseDocumentHistoryRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public DatabaseDocumentHistoryRecord value2(Integer value) { + setProjectId(value); + return this; + } + + @Override + public DatabaseDocumentHistoryRecord value3(Integer value) { + setDatabaseDocumentId(value); + return this; + } + + @Override + public DatabaseDocumentHistoryRecord value4(JSON value) { + setDatabaseDocumentObject(value); + return this; + } + + @Override + public DatabaseDocumentHistoryRecord value5(Long value) { + setVersion(value); + return this; + } + + @Override + public DatabaseDocumentHistoryRecord value6(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public DatabaseDocumentHistoryRecord values(Integer value1, Integer value2, Integer value3, JSON value4, Long value5, LocalDateTime value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DatabaseDocumentHistoryRecord + */ + public DatabaseDocumentHistoryRecord() { + super(DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY); + } + + /** + * Create a detached, initialised DatabaseDocumentHistoryRecord + */ + public DatabaseDocumentHistoryRecord(Integer id, Integer projectId, Integer databaseDocumentId, JSON databaseDocumentObject, Long version, LocalDateTime createAt) { + super(DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY); + + setId(id); + setProjectId(projectId); + setDatabaseDocumentId(databaseDocumentId); + setDatabaseDocumentObject(databaseDocumentObject); + setVersion(version); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised DatabaseDocumentHistoryRecord + */ + public DatabaseDocumentHistoryRecord(DatabaseDocumentHistoryPojo value) { + super(DatabaseDocumentHistory.DATABASE_DOCUMENT_HISTORY); + + if (value != null) { + setId(value.getId()); + setProjectId(value.getProjectId()); + setDatabaseDocumentId(value.getDatabaseDocumentId()); + setDatabaseDocumentObject(value.getDatabaseDocumentObject()); + setVersion(value.getVersion()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentRecord.java new file mode 100644 index 0000000..df9edb3 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/DatabaseDocumentRecord.java @@ -0,0 +1,387 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.DatabaseDocument; +import com.databasir.dao.tables.pojos.DatabaseDocumentPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record8; +import org.jooq.Row8; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DatabaseDocumentRecord extends UpdatableRecordImpl implements Record8 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.database_document.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.database_document.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.database_document.project_id. + */ + public void setProjectId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.database_document.project_id. + */ + public Integer getProjectId() { + return (Integer) get(1); + } + + /** + * Setter for databasir.database_document.database_name. + */ + public void setDatabaseName(String value) { + set(2, value); + } + + /** + * Getter for databasir.database_document.database_name. + */ + public String getDatabaseName() { + return (String) get(2); + } + + /** + * Setter for databasir.database_document.product_name. + */ + public void setProductName(String value) { + set(3, value); + } + + /** + * Getter for databasir.database_document.product_name. + */ + public String getProductName() { + return (String) get(3); + } + + /** + * Setter for databasir.database_document.product_version. + */ + public void setProductVersion(String value) { + set(4, value); + } + + /** + * Getter for databasir.database_document.product_version. + */ + public String getProductVersion() { + return (String) get(4); + } + + /** + * Setter for databasir.database_document.version. + */ + public void setVersion(Long value) { + set(5, value); + } + + /** + * Getter for databasir.database_document.version. + */ + public Long getVersion() { + return (Long) get(5); + } + + /** + * Setter for databasir.database_document.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(6, value); + } + + /** + * Getter for databasir.database_document.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(6); + } + + /** + * Setter for databasir.database_document.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(7, value); + } + + /** + * Getter for databasir.database_document.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(7); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record8 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } + + @Override + public Row8 valuesRow() { + return (Row8) super.valuesRow(); + } + + @Override + public Field field1() { + return DatabaseDocument.DATABASE_DOCUMENT.ID; + } + + @Override + public Field field2() { + return DatabaseDocument.DATABASE_DOCUMENT.PROJECT_ID; + } + + @Override + public Field field3() { + return DatabaseDocument.DATABASE_DOCUMENT.DATABASE_NAME; + } + + @Override + public Field field4() { + return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_NAME; + } + + @Override + public Field field5() { + return DatabaseDocument.DATABASE_DOCUMENT.PRODUCT_VERSION; + } + + @Override + public Field field6() { + return DatabaseDocument.DATABASE_DOCUMENT.VERSION; + } + + @Override + public Field field7() { + return DatabaseDocument.DATABASE_DOCUMENT.UPDATE_AT; + } + + @Override + public Field field8() { + return DatabaseDocument.DATABASE_DOCUMENT.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getProjectId(); + } + + @Override + public String component3() { + return getDatabaseName(); + } + + @Override + public String component4() { + return getProductName(); + } + + @Override + public String component5() { + return getProductVersion(); + } + + @Override + public Long component6() { + return getVersion(); + } + + @Override + public LocalDateTime component7() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component8() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getProjectId(); + } + + @Override + public String value3() { + return getDatabaseName(); + } + + @Override + public String value4() { + return getProductName(); + } + + @Override + public String value5() { + return getProductVersion(); + } + + @Override + public Long value6() { + return getVersion(); + } + + @Override + public LocalDateTime value7() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value8() { + return getCreateAt(); + } + + @Override + public DatabaseDocumentRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public DatabaseDocumentRecord value2(Integer value) { + setProjectId(value); + return this; + } + + @Override + public DatabaseDocumentRecord value3(String value) { + setDatabaseName(value); + return this; + } + + @Override + public DatabaseDocumentRecord value4(String value) { + setProductName(value); + return this; + } + + @Override + public DatabaseDocumentRecord value5(String value) { + setProductVersion(value); + return this; + } + + @Override + public DatabaseDocumentRecord value6(Long value) { + setVersion(value); + return this; + } + + @Override + public DatabaseDocumentRecord value7(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public DatabaseDocumentRecord value8(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public DatabaseDocumentRecord values(Integer value1, Integer value2, String value3, String value4, String value5, Long value6, LocalDateTime value7, LocalDateTime value8) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached DatabaseDocumentRecord + */ + public DatabaseDocumentRecord() { + super(DatabaseDocument.DATABASE_DOCUMENT); + } + + /** + * Create a detached, initialised DatabaseDocumentRecord + */ + public DatabaseDocumentRecord(Integer id, Integer projectId, String databaseName, String productName, String productVersion, Long version, LocalDateTime updateAt, LocalDateTime createAt) { + super(DatabaseDocument.DATABASE_DOCUMENT); + + setId(id); + setProjectId(projectId); + setDatabaseName(databaseName); + setProductName(productName); + setProductVersion(productVersion); + setVersion(version); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised DatabaseDocumentRecord + */ + public DatabaseDocumentRecord(DatabaseDocumentPojo value) { + super(DatabaseDocument.DATABASE_DOCUMENT); + + if (value != null) { + setId(value.getId()); + setProjectId(value.getProjectId()); + setDatabaseName(value.getDatabaseName()); + setProductName(value.getProductName()); + setProductVersion(value.getProductVersion()); + setVersion(value.getVersion()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/GroupRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/GroupRecord.java new file mode 100644 index 0000000..fb3c959 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/GroupRecord.java @@ -0,0 +1,311 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.Group; +import com.databasir.dao.tables.pojos.GroupPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class GroupRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.group.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.group.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.group.name. + */ + public void setName(String value) { + set(1, value); + } + + /** + * Getter for databasir.group.name. + */ + public String getName() { + return (String) get(1); + } + + /** + * Setter for databasir.group.description. + */ + public void setDescription(String value) { + set(2, value); + } + + /** + * Getter for databasir.group.description. + */ + public String getDescription() { + return (String) get(2); + } + + /** + * Setter for databasir.group.deleted. + */ + public void setDeleted(Boolean value) { + set(3, value); + } + + /** + * Getter for databasir.group.deleted. + */ + public Boolean getDeleted() { + return (Boolean) get(3); + } + + /** + * Setter for databasir.group.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(4, value); + } + + /** + * Getter for databasir.group.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(4); + } + + /** + * Setter for databasir.group.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.group.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return Group.GROUP.ID; + } + + @Override + public Field field2() { + return Group.GROUP.NAME; + } + + @Override + public Field field3() { + return Group.GROUP.DESCRIPTION; + } + + @Override + public Field field4() { + return Group.GROUP.DELETED; + } + + @Override + public Field field5() { + return Group.GROUP.UPDATE_AT; + } + + @Override + public Field field6() { + return Group.GROUP.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getName(); + } + + @Override + public String component3() { + return getDescription(); + } + + @Override + public Boolean component4() { + return getDeleted(); + } + + @Override + public LocalDateTime component5() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component6() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getName(); + } + + @Override + public String value3() { + return getDescription(); + } + + @Override + public Boolean value4() { + return getDeleted(); + } + + @Override + public LocalDateTime value5() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value6() { + return getCreateAt(); + } + + @Override + public GroupRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public GroupRecord value2(String value) { + setName(value); + return this; + } + + @Override + public GroupRecord value3(String value) { + setDescription(value); + return this; + } + + @Override + public GroupRecord value4(Boolean value) { + setDeleted(value); + return this; + } + + @Override + public GroupRecord value5(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public GroupRecord value6(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public GroupRecord values(Integer value1, String value2, String value3, Boolean value4, LocalDateTime value5, LocalDateTime value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached GroupRecord + */ + public GroupRecord() { + super(Group.GROUP); + } + + /** + * Create a detached, initialised GroupRecord + */ + public GroupRecord(Integer id, String name, String description, Boolean deleted, LocalDateTime updateAt, LocalDateTime createAt) { + super(Group.GROUP); + + setId(id); + setName(name); + setDescription(description); + setDeleted(deleted); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised GroupRecord + */ + public GroupRecord(GroupPojo value) { + super(Group.GROUP); + + if (value != null) { + setId(value.getId()); + setName(value.getName()); + setDescription(value.getDescription()); + setDeleted(value.getDeleted()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/LoginRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/LoginRecord.java new file mode 100644 index 0000000..ad85515 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/LoginRecord.java @@ -0,0 +1,387 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.Login; +import com.databasir.dao.tables.pojos.LoginPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record8; +import org.jooq.Row8; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class LoginRecord extends UpdatableRecordImpl implements Record8 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.login.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.login.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.login.user_id. + */ + public void setUserId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.login.user_id. + */ + public Integer getUserId() { + return (Integer) get(1); + } + + /** + * Setter for databasir.login.access_token. + */ + public void setAccessToken(String value) { + set(2, value); + } + + /** + * Getter for databasir.login.access_token. + */ + public String getAccessToken() { + return (String) get(2); + } + + /** + * Setter for databasir.login.refresh_token. + */ + public void setRefreshToken(String value) { + set(3, value); + } + + /** + * Getter for databasir.login.refresh_token. + */ + public String getRefreshToken() { + return (String) get(3); + } + + /** + * Setter for databasir.login.access_token_expire_at. + */ + public void setAccessTokenExpireAt(LocalDateTime value) { + set(4, value); + } + + /** + * Getter for databasir.login.access_token_expire_at. + */ + public LocalDateTime getAccessTokenExpireAt() { + return (LocalDateTime) get(4); + } + + /** + * Setter for databasir.login.refresh_token_expire_at. + */ + public void setRefreshTokenExpireAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.login.refresh_token_expire_at. + */ + public LocalDateTime getRefreshTokenExpireAt() { + return (LocalDateTime) get(5); + } + + /** + * Setter for databasir.login.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(6, value); + } + + /** + * Getter for databasir.login.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(6); + } + + /** + * Setter for databasir.login.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(7, value); + } + + /** + * Getter for databasir.login.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(7); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record8 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } + + @Override + public Row8 valuesRow() { + return (Row8) super.valuesRow(); + } + + @Override + public Field field1() { + return Login.LOGIN.ID; + } + + @Override + public Field field2() { + return Login.LOGIN.USER_ID; + } + + @Override + public Field field3() { + return Login.LOGIN.ACCESS_TOKEN; + } + + @Override + public Field field4() { + return Login.LOGIN.REFRESH_TOKEN; + } + + @Override + public Field field5() { + return Login.LOGIN.ACCESS_TOKEN_EXPIRE_AT; + } + + @Override + public Field field6() { + return Login.LOGIN.REFRESH_TOKEN_EXPIRE_AT; + } + + @Override + public Field field7() { + return Login.LOGIN.UPDATE_AT; + } + + @Override + public Field field8() { + return Login.LOGIN.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getUserId(); + } + + @Override + public String component3() { + return getAccessToken(); + } + + @Override + public String component4() { + return getRefreshToken(); + } + + @Override + public LocalDateTime component5() { + return getAccessTokenExpireAt(); + } + + @Override + public LocalDateTime component6() { + return getRefreshTokenExpireAt(); + } + + @Override + public LocalDateTime component7() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component8() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getUserId(); + } + + @Override + public String value3() { + return getAccessToken(); + } + + @Override + public String value4() { + return getRefreshToken(); + } + + @Override + public LocalDateTime value5() { + return getAccessTokenExpireAt(); + } + + @Override + public LocalDateTime value6() { + return getRefreshTokenExpireAt(); + } + + @Override + public LocalDateTime value7() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value8() { + return getCreateAt(); + } + + @Override + public LoginRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public LoginRecord value2(Integer value) { + setUserId(value); + return this; + } + + @Override + public LoginRecord value3(String value) { + setAccessToken(value); + return this; + } + + @Override + public LoginRecord value4(String value) { + setRefreshToken(value); + return this; + } + + @Override + public LoginRecord value5(LocalDateTime value) { + setAccessTokenExpireAt(value); + return this; + } + + @Override + public LoginRecord value6(LocalDateTime value) { + setRefreshTokenExpireAt(value); + return this; + } + + @Override + public LoginRecord value7(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public LoginRecord value8(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public LoginRecord values(Integer value1, Integer value2, String value3, String value4, LocalDateTime value5, LocalDateTime value6, LocalDateTime value7, LocalDateTime value8) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached LoginRecord + */ + public LoginRecord() { + super(Login.LOGIN); + } + + /** + * Create a detached, initialised LoginRecord + */ + public LoginRecord(Integer id, Integer userId, String accessToken, String refreshToken, LocalDateTime accessTokenExpireAt, LocalDateTime refreshTokenExpireAt, LocalDateTime updateAt, LocalDateTime createAt) { + super(Login.LOGIN); + + setId(id); + setUserId(userId); + setAccessToken(accessToken); + setRefreshToken(refreshToken); + setAccessTokenExpireAt(accessTokenExpireAt); + setRefreshTokenExpireAt(refreshTokenExpireAt); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised LoginRecord + */ + public LoginRecord(LoginPojo value) { + super(Login.LOGIN); + + if (value != null) { + setId(value.getId()); + setUserId(value.getUserId()); + setAccessToken(value.getAccessToken()); + setRefreshToken(value.getRefreshToken()); + setAccessTokenExpireAt(value.getAccessTokenExpireAt()); + setRefreshTokenExpireAt(value.getRefreshTokenExpireAt()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/ProjectRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/ProjectRecord.java new file mode 100644 index 0000000..b53040b --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/ProjectRecord.java @@ -0,0 +1,311 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.Project; +import com.databasir.dao.tables.pojos.ProjectPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ProjectRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.project.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.project.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.project.name. + */ + public void setName(String value) { + set(1, value); + } + + /** + * Getter for databasir.project.name. + */ + public String getName() { + return (String) get(1); + } + + /** + * Setter for databasir.project.description. + */ + public void setDescription(String value) { + set(2, value); + } + + /** + * Getter for databasir.project.description. + */ + public String getDescription() { + return (String) get(2); + } + + /** + * Setter for databasir.project.group_id. + */ + public void setGroupId(Integer value) { + set(3, value); + } + + /** + * Getter for databasir.project.group_id. + */ + public Integer getGroupId() { + return (Integer) get(3); + } + + /** + * Setter for databasir.project.deleted. + */ + public void setDeleted(Boolean value) { + set(4, value); + } + + /** + * Getter for databasir.project.deleted. + */ + public Boolean getDeleted() { + return (Boolean) get(4); + } + + /** + * Setter for databasir.project.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.project.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return Project.PROJECT.ID; + } + + @Override + public Field field2() { + return Project.PROJECT.NAME; + } + + @Override + public Field field3() { + return Project.PROJECT.DESCRIPTION; + } + + @Override + public Field field4() { + return Project.PROJECT.GROUP_ID; + } + + @Override + public Field field5() { + return Project.PROJECT.DELETED; + } + + @Override + public Field field6() { + return Project.PROJECT.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getName(); + } + + @Override + public String component3() { + return getDescription(); + } + + @Override + public Integer component4() { + return getGroupId(); + } + + @Override + public Boolean component5() { + return getDeleted(); + } + + @Override + public LocalDateTime component6() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getName(); + } + + @Override + public String value3() { + return getDescription(); + } + + @Override + public Integer value4() { + return getGroupId(); + } + + @Override + public Boolean value5() { + return getDeleted(); + } + + @Override + public LocalDateTime value6() { + return getCreateAt(); + } + + @Override + public ProjectRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public ProjectRecord value2(String value) { + setName(value); + return this; + } + + @Override + public ProjectRecord value3(String value) { + setDescription(value); + return this; + } + + @Override + public ProjectRecord value4(Integer value) { + setGroupId(value); + return this; + } + + @Override + public ProjectRecord value5(Boolean value) { + setDeleted(value); + return this; + } + + @Override + public ProjectRecord value6(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public ProjectRecord values(Integer value1, String value2, String value3, Integer value4, Boolean value5, LocalDateTime value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ProjectRecord + */ + public ProjectRecord() { + super(Project.PROJECT); + } + + /** + * Create a detached, initialised ProjectRecord + */ + public ProjectRecord(Integer id, String name, String description, Integer groupId, Boolean deleted, LocalDateTime createAt) { + super(Project.PROJECT); + + setId(id); + setName(name); + setDescription(description); + setGroupId(groupId); + setDeleted(deleted); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised ProjectRecord + */ + public ProjectRecord(ProjectPojo value) { + super(Project.PROJECT); + + if (value != null) { + setId(value.getId()); + setName(value.getName()); + setDescription(value.getDescription()); + setGroupId(value.getGroupId()); + setDeleted(value.getDeleted()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/ProjectSyncRuleRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/ProjectSyncRuleRecord.java new file mode 100644 index 0000000..5c7e61c --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/ProjectSyncRuleRecord.java @@ -0,0 +1,316 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.ProjectSyncRule; +import com.databasir.dao.tables.pojos.ProjectSyncRulePojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.JSON; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class ProjectSyncRuleRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.project_sync_rule.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.project_sync_rule.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.project_sync_rule.project_id. + */ + public void setProjectId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.project_sync_rule.project_id. + */ + public Integer getProjectId() { + return (Integer) get(1); + } + + /** + * Setter for + * databasir.project_sync_rule.ignore_table_name_regex_array. + */ + public void setIgnoreTableNameRegexArray(JSON value) { + set(2, value); + } + + /** + * Getter for + * databasir.project_sync_rule.ignore_table_name_regex_array. + */ + public JSON getIgnoreTableNameRegexArray() { + return (JSON) get(2); + } + + /** + * Setter for + * databasir.project_sync_rule.ignore_column_name_regex_array. + */ + public void setIgnoreColumnNameRegexArray(JSON value) { + set(3, value); + } + + /** + * Getter for + * databasir.project_sync_rule.ignore_column_name_regex_array. + */ + public JSON getIgnoreColumnNameRegexArray() { + return (JSON) get(3); + } + + /** + * Setter for databasir.project_sync_rule.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(4, value); + } + + /** + * Getter for databasir.project_sync_rule.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(4); + } + + /** + * Setter for databasir.project_sync_rule.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.project_sync_rule.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return ProjectSyncRule.PROJECT_SYNC_RULE.ID; + } + + @Override + public Field field2() { + return ProjectSyncRule.PROJECT_SYNC_RULE.PROJECT_ID; + } + + @Override + public Field field3() { + return ProjectSyncRule.PROJECT_SYNC_RULE.IGNORE_TABLE_NAME_REGEX_ARRAY; + } + + @Override + public Field field4() { + return ProjectSyncRule.PROJECT_SYNC_RULE.IGNORE_COLUMN_NAME_REGEX_ARRAY; + } + + @Override + public Field field5() { + return ProjectSyncRule.PROJECT_SYNC_RULE.UPDATE_AT; + } + + @Override + public Field field6() { + return ProjectSyncRule.PROJECT_SYNC_RULE.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getProjectId(); + } + + @Override + public JSON component3() { + return getIgnoreTableNameRegexArray(); + } + + @Override + public JSON component4() { + return getIgnoreColumnNameRegexArray(); + } + + @Override + public LocalDateTime component5() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component6() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getProjectId(); + } + + @Override + public JSON value3() { + return getIgnoreTableNameRegexArray(); + } + + @Override + public JSON value4() { + return getIgnoreColumnNameRegexArray(); + } + + @Override + public LocalDateTime value5() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value6() { + return getCreateAt(); + } + + @Override + public ProjectSyncRuleRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public ProjectSyncRuleRecord value2(Integer value) { + setProjectId(value); + return this; + } + + @Override + public ProjectSyncRuleRecord value3(JSON value) { + setIgnoreTableNameRegexArray(value); + return this; + } + + @Override + public ProjectSyncRuleRecord value4(JSON value) { + setIgnoreColumnNameRegexArray(value); + return this; + } + + @Override + public ProjectSyncRuleRecord value5(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public ProjectSyncRuleRecord value6(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public ProjectSyncRuleRecord values(Integer value1, Integer value2, JSON value3, JSON value4, LocalDateTime value5, LocalDateTime value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached ProjectSyncRuleRecord + */ + public ProjectSyncRuleRecord() { + super(ProjectSyncRule.PROJECT_SYNC_RULE); + } + + /** + * Create a detached, initialised ProjectSyncRuleRecord + */ + public ProjectSyncRuleRecord(Integer id, Integer projectId, JSON ignoreTableNameRegexArray, JSON ignoreColumnNameRegexArray, LocalDateTime updateAt, LocalDateTime createAt) { + super(ProjectSyncRule.PROJECT_SYNC_RULE); + + setId(id); + setProjectId(projectId); + setIgnoreTableNameRegexArray(ignoreTableNameRegexArray); + setIgnoreColumnNameRegexArray(ignoreColumnNameRegexArray); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised ProjectSyncRuleRecord + */ + public ProjectSyncRuleRecord(ProjectSyncRulePojo value) { + super(ProjectSyncRule.PROJECT_SYNC_RULE); + + if (value != null) { + setId(value.getId()); + setProjectId(value.getProjectId()); + setIgnoreTableNameRegexArray(value.getIgnoreTableNameRegexArray()); + setIgnoreColumnNameRegexArray(value.getIgnoreColumnNameRegexArray()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/SysKeyRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/SysKeyRecord.java new file mode 100644 index 0000000..d130a57 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/SysKeyRecord.java @@ -0,0 +1,311 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.SysKey; +import com.databasir.dao.tables.pojos.SysKeyPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class SysKeyRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.sys_key.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.sys_key.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.sys_key.rsa_public_key. + */ + public void setRsaPublicKey(String value) { + set(1, value); + } + + /** + * Getter for databasir.sys_key.rsa_public_key. + */ + public String getRsaPublicKey() { + return (String) get(1); + } + + /** + * Setter for databasir.sys_key.rsa_private_key. + */ + public void setRsaPrivateKey(String value) { + set(2, value); + } + + /** + * Getter for databasir.sys_key.rsa_private_key. + */ + public String getRsaPrivateKey() { + return (String) get(2); + } + + /** + * Setter for databasir.sys_key.aes_key. + */ + public void setAesKey(String value) { + set(3, value); + } + + /** + * Getter for databasir.sys_key.aes_key. + */ + public String getAesKey() { + return (String) get(3); + } + + /** + * Setter for databasir.sys_key.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(4, value); + } + + /** + * Getter for databasir.sys_key.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(4); + } + + /** + * Setter for databasir.sys_key.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.sys_key.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return SysKey.SYS_KEY.ID; + } + + @Override + public Field field2() { + return SysKey.SYS_KEY.RSA_PUBLIC_KEY; + } + + @Override + public Field field3() { + return SysKey.SYS_KEY.RSA_PRIVATE_KEY; + } + + @Override + public Field field4() { + return SysKey.SYS_KEY.AES_KEY; + } + + @Override + public Field field5() { + return SysKey.SYS_KEY.UPDATE_AT; + } + + @Override + public Field field6() { + return SysKey.SYS_KEY.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getRsaPublicKey(); + } + + @Override + public String component3() { + return getRsaPrivateKey(); + } + + @Override + public String component4() { + return getAesKey(); + } + + @Override + public LocalDateTime component5() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component6() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getRsaPublicKey(); + } + + @Override + public String value3() { + return getRsaPrivateKey(); + } + + @Override + public String value4() { + return getAesKey(); + } + + @Override + public LocalDateTime value5() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value6() { + return getCreateAt(); + } + + @Override + public SysKeyRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public SysKeyRecord value2(String value) { + setRsaPublicKey(value); + return this; + } + + @Override + public SysKeyRecord value3(String value) { + setRsaPrivateKey(value); + return this; + } + + @Override + public SysKeyRecord value4(String value) { + setAesKey(value); + return this; + } + + @Override + public SysKeyRecord value5(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public SysKeyRecord value6(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public SysKeyRecord values(Integer value1, String value2, String value3, String value4, LocalDateTime value5, LocalDateTime value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached SysKeyRecord + */ + public SysKeyRecord() { + super(SysKey.SYS_KEY); + } + + /** + * Create a detached, initialised SysKeyRecord + */ + public SysKeyRecord(Integer id, String rsaPublicKey, String rsaPrivateKey, String aesKey, LocalDateTime updateAt, LocalDateTime createAt) { + super(SysKey.SYS_KEY); + + setId(id); + setRsaPublicKey(rsaPublicKey); + setRsaPrivateKey(rsaPrivateKey); + setAesKey(aesKey); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised SysKeyRecord + */ + public SysKeyRecord(SysKeyPojo value) { + super(SysKey.SYS_KEY); + + if (value != null) { + setId(value.getId()); + setRsaPublicKey(value.getRsaPublicKey()); + setRsaPrivateKey(value.getRsaPrivateKey()); + setAesKey(value.getAesKey()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/SysMailRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/SysMailRecord.java new file mode 100644 index 0000000..1aff42f --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/SysMailRecord.java @@ -0,0 +1,349 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.SysMail; +import com.databasir.dao.tables.pojos.SysMailPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record7; +import org.jooq.Row7; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class SysMailRecord extends UpdatableRecordImpl implements Record7 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.sys_mail.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.sys_mail.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.sys_mail.username. + */ + public void setUsername(String value) { + set(1, value); + } + + /** + * Getter for databasir.sys_mail.username. + */ + public String getUsername() { + return (String) get(1); + } + + /** + * Setter for databasir.sys_mail.password. + */ + public void setPassword(String value) { + set(2, value); + } + + /** + * Getter for databasir.sys_mail.password. + */ + public String getPassword() { + return (String) get(2); + } + + /** + * Setter for databasir.sys_mail.smtp_host. + */ + public void setSmtpHost(String value) { + set(3, value); + } + + /** + * Getter for databasir.sys_mail.smtp_host. + */ + public String getSmtpHost() { + return (String) get(3); + } + + /** + * Setter for databasir.sys_mail.smtp_port. + */ + public void setSmtpPort(Integer value) { + set(4, value); + } + + /** + * Getter for databasir.sys_mail.smtp_port. + */ + public Integer getSmtpPort() { + return (Integer) get(4); + } + + /** + * Setter for databasir.sys_mail.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.sys_mail.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(5); + } + + /** + * Setter for databasir.sys_mail.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(6, value); + } + + /** + * Getter for databasir.sys_mail.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(6); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record7 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); + } + + @Override + public Row7 valuesRow() { + return (Row7) super.valuesRow(); + } + + @Override + public Field field1() { + return SysMail.SYS_MAIL.ID; + } + + @Override + public Field field2() { + return SysMail.SYS_MAIL.USERNAME; + } + + @Override + public Field field3() { + return SysMail.SYS_MAIL.PASSWORD; + } + + @Override + public Field field4() { + return SysMail.SYS_MAIL.SMTP_HOST; + } + + @Override + public Field field5() { + return SysMail.SYS_MAIL.SMTP_PORT; + } + + @Override + public Field field6() { + return SysMail.SYS_MAIL.UPDATE_AT; + } + + @Override + public Field field7() { + return SysMail.SYS_MAIL.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getUsername(); + } + + @Override + public String component3() { + return getPassword(); + } + + @Override + public String component4() { + return getSmtpHost(); + } + + @Override + public Integer component5() { + return getSmtpPort(); + } + + @Override + public LocalDateTime component6() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component7() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getUsername(); + } + + @Override + public String value3() { + return getPassword(); + } + + @Override + public String value4() { + return getSmtpHost(); + } + + @Override + public Integer value5() { + return getSmtpPort(); + } + + @Override + public LocalDateTime value6() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value7() { + return getCreateAt(); + } + + @Override + public SysMailRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public SysMailRecord value2(String value) { + setUsername(value); + return this; + } + + @Override + public SysMailRecord value3(String value) { + setPassword(value); + return this; + } + + @Override + public SysMailRecord value4(String value) { + setSmtpHost(value); + return this; + } + + @Override + public SysMailRecord value5(Integer value) { + setSmtpPort(value); + return this; + } + + @Override + public SysMailRecord value6(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public SysMailRecord value7(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public SysMailRecord values(Integer value1, String value2, String value3, String value4, Integer value5, LocalDateTime value6, LocalDateTime value7) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached SysMailRecord + */ + public SysMailRecord() { + super(SysMail.SYS_MAIL); + } + + /** + * Create a detached, initialised SysMailRecord + */ + public SysMailRecord(Integer id, String username, String password, String smtpHost, Integer smtpPort, LocalDateTime updateAt, LocalDateTime createAt) { + super(SysMail.SYS_MAIL); + + setId(id); + setUsername(username); + setPassword(password); + setSmtpHost(smtpHost); + setSmtpPort(smtpPort); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised SysMailRecord + */ + public SysMailRecord(SysMailPojo value) { + super(SysMail.SYS_MAIL); + + if (value != null) { + setId(value.getId()); + setUsername(value.getUsername()); + setPassword(value.getPassword()); + setSmtpHost(value.getSmtpHost()); + setSmtpPort(value.getSmtpPort()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableColumnDocumentRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableColumnDocumentRecord.java new file mode 100644 index 0000000..9a87151 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableColumnDocumentRecord.java @@ -0,0 +1,547 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.TableColumnDocument; +import com.databasir.dao.tables.pojos.TableColumnDocumentPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record12; +import org.jooq.Row12; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableColumnDocumentRecord extends UpdatableRecordImpl implements Record12 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.table_column_document.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.table_column_document.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for + * databasir.table_column_document.table_document_id. + */ + public void setTableDocumentId(Integer value) { + set(1, value); + } + + /** + * Getter for + * databasir.table_column_document.table_document_id. + */ + public Integer getTableDocumentId() { + return (Integer) get(1); + } + + /** + * Setter for + * databasir.table_column_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer value) { + set(2, value); + } + + /** + * Getter for + * databasir.table_column_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return (Integer) get(2); + } + + /** + * Setter for databasir.table_column_document.name. + */ + public void setName(String value) { + set(3, value); + } + + /** + * Getter for databasir.table_column_document.name. + */ + public String getName() { + return (String) get(3); + } + + /** + * Setter for databasir.table_column_document.type. + */ + public void setType(String value) { + set(4, value); + } + + /** + * Getter for databasir.table_column_document.type. + */ + public String getType() { + return (String) get(4); + } + + /** + * Setter for databasir.table_column_document.comment. + */ + public void setComment(String value) { + set(5, value); + } + + /** + * Getter for databasir.table_column_document.comment. + */ + public String getComment() { + return (String) get(5); + } + + /** + * Setter for databasir.table_column_document.default_value. + */ + public void setDefaultValue(String value) { + set(6, value); + } + + /** + * Getter for databasir.table_column_document.default_value. + */ + public String getDefaultValue() { + return (String) get(6); + } + + /** + * Setter for databasir.table_column_document.size. + */ + public void setSize(Integer value) { + set(7, value); + } + + /** + * Getter for databasir.table_column_document.size. + */ + public Integer getSize() { + return (Integer) get(7); + } + + /** + * Setter for databasir.table_column_document.decimal_digits. + */ + public void setDecimalDigits(Integer value) { + set(8, value); + } + + /** + * Getter for databasir.table_column_document.decimal_digits. + */ + public Integer getDecimalDigits() { + return (Integer) get(8); + } + + /** + * Setter for databasir.table_column_document.nullable. YES, + * NO, UNKNOWN + */ + public void setNullable(String value) { + set(9, value); + } + + /** + * Getter for databasir.table_column_document.nullable. YES, + * NO, UNKNOWN + */ + public String getNullable() { + return (String) get(9); + } + + /** + * Setter for databasir.table_column_document.auto_increment. + * YES, NO, UNKNOWN + */ + public void setAutoIncrement(String value) { + set(10, value); + } + + /** + * Getter for databasir.table_column_document.auto_increment. + * YES, NO, UNKNOWN + */ + public String getAutoIncrement() { + return (String) get(10); + } + + /** + * Setter for databasir.table_column_document.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(11, value); + } + + /** + * Getter for databasir.table_column_document.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(11); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record12 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row12 fieldsRow() { + return (Row12) super.fieldsRow(); + } + + @Override + public Row12 valuesRow() { + return (Row12) super.valuesRow(); + } + + @Override + public Field field1() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.ID; + } + + @Override + public Field field2() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID; + } + + @Override + public Field field3() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID; + } + + @Override + public Field field4() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.NAME; + } + + @Override + public Field field5() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.TYPE; + } + + @Override + public Field field6() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.COMMENT; + } + + @Override + public Field field7() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DEFAULT_VALUE; + } + + @Override + public Field field8() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.SIZE; + } + + @Override + public Field field9() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DECIMAL_DIGITS; + } + + @Override + public Field field10() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.NULLABLE; + } + + @Override + public Field field11() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.AUTO_INCREMENT; + } + + @Override + public Field field12() { + return TableColumnDocument.TABLE_COLUMN_DOCUMENT.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getTableDocumentId(); + } + + @Override + public Integer component3() { + return getDatabaseDocumentId(); + } + + @Override + public String component4() { + return getName(); + } + + @Override + public String component5() { + return getType(); + } + + @Override + public String component6() { + return getComment(); + } + + @Override + public String component7() { + return getDefaultValue(); + } + + @Override + public Integer component8() { + return getSize(); + } + + @Override + public Integer component9() { + return getDecimalDigits(); + } + + @Override + public String component10() { + return getNullable(); + } + + @Override + public String component11() { + return getAutoIncrement(); + } + + @Override + public LocalDateTime component12() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getTableDocumentId(); + } + + @Override + public Integer value3() { + return getDatabaseDocumentId(); + } + + @Override + public String value4() { + return getName(); + } + + @Override + public String value5() { + return getType(); + } + + @Override + public String value6() { + return getComment(); + } + + @Override + public String value7() { + return getDefaultValue(); + } + + @Override + public Integer value8() { + return getSize(); + } + + @Override + public Integer value9() { + return getDecimalDigits(); + } + + @Override + public String value10() { + return getNullable(); + } + + @Override + public String value11() { + return getAutoIncrement(); + } + + @Override + public LocalDateTime value12() { + return getCreateAt(); + } + + @Override + public TableColumnDocumentRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public TableColumnDocumentRecord value2(Integer value) { + setTableDocumentId(value); + return this; + } + + @Override + public TableColumnDocumentRecord value3(Integer value) { + setDatabaseDocumentId(value); + return this; + } + + @Override + public TableColumnDocumentRecord value4(String value) { + setName(value); + return this; + } + + @Override + public TableColumnDocumentRecord value5(String value) { + setType(value); + return this; + } + + @Override + public TableColumnDocumentRecord value6(String value) { + setComment(value); + return this; + } + + @Override + public TableColumnDocumentRecord value7(String value) { + setDefaultValue(value); + return this; + } + + @Override + public TableColumnDocumentRecord value8(Integer value) { + setSize(value); + return this; + } + + @Override + public TableColumnDocumentRecord value9(Integer value) { + setDecimalDigits(value); + return this; + } + + @Override + public TableColumnDocumentRecord value10(String value) { + setNullable(value); + return this; + } + + @Override + public TableColumnDocumentRecord value11(String value) { + setAutoIncrement(value); + return this; + } + + @Override + public TableColumnDocumentRecord value12(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public TableColumnDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, String value6, String value7, Integer value8, Integer value9, String value10, String value11, LocalDateTime value12) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + value10(value10); + value11(value11); + value12(value12); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached TableColumnDocumentRecord + */ + public TableColumnDocumentRecord() { + super(TableColumnDocument.TABLE_COLUMN_DOCUMENT); + } + + /** + * Create a detached, initialised TableColumnDocumentRecord + */ + public TableColumnDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, String type, String comment, String defaultValue, Integer size, Integer decimalDigits, String nullable, String autoIncrement, LocalDateTime createAt) { + super(TableColumnDocument.TABLE_COLUMN_DOCUMENT); + + setId(id); + setTableDocumentId(tableDocumentId); + setDatabaseDocumentId(databaseDocumentId); + setName(name); + setType(type); + setComment(comment); + setDefaultValue(defaultValue); + setSize(size); + setDecimalDigits(decimalDigits); + setNullable(nullable); + setAutoIncrement(autoIncrement); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised TableColumnDocumentRecord + */ + public TableColumnDocumentRecord(TableColumnDocumentPojo value) { + super(TableColumnDocument.TABLE_COLUMN_DOCUMENT); + + if (value != null) { + setId(value.getId()); + setTableDocumentId(value.getTableDocumentId()); + setDatabaseDocumentId(value.getDatabaseDocumentId()); + setName(value.getName()); + setType(value.getType()); + setComment(value.getComment()); + setDefaultValue(value.getDefaultValue()); + setSize(value.getSize()); + setDecimalDigits(value.getDecimalDigits()); + setNullable(value.getNullable()); + setAutoIncrement(value.getAutoIncrement()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableDocumentRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableDocumentRecord.java new file mode 100644 index 0000000..3ab353e --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableDocumentRecord.java @@ -0,0 +1,311 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.TableDocument; +import com.databasir.dao.tables.pojos.TableDocumentPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record6; +import org.jooq.Row6; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableDocumentRecord extends UpdatableRecordImpl implements Record6 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.table_document.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.table_document.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.table_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.table_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return (Integer) get(1); + } + + /** + * Setter for databasir.table_document.name. + */ + public void setName(String value) { + set(2, value); + } + + /** + * Getter for databasir.table_document.name. + */ + public String getName() { + return (String) get(2); + } + + /** + * Setter for databasir.table_document.type. + */ + public void setType(String value) { + set(3, value); + } + + /** + * Getter for databasir.table_document.type. + */ + public String getType() { + return (String) get(3); + } + + /** + * Setter for databasir.table_document.comment. + */ + public void setComment(String value) { + set(4, value); + } + + /** + * Getter for databasir.table_document.comment. + */ + public String getComment() { + return (String) get(4); + } + + /** + * Setter for databasir.table_document.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(5, value); + } + + /** + * Getter for databasir.table_document.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(5); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record6 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row6 fieldsRow() { + return (Row6) super.fieldsRow(); + } + + @Override + public Row6 valuesRow() { + return (Row6) super.valuesRow(); + } + + @Override + public Field field1() { + return TableDocument.TABLE_DOCUMENT.ID; + } + + @Override + public Field field2() { + return TableDocument.TABLE_DOCUMENT.DATABASE_DOCUMENT_ID; + } + + @Override + public Field field3() { + return TableDocument.TABLE_DOCUMENT.NAME; + } + + @Override + public Field field4() { + return TableDocument.TABLE_DOCUMENT.TYPE; + } + + @Override + public Field field5() { + return TableDocument.TABLE_DOCUMENT.COMMENT; + } + + @Override + public Field field6() { + return TableDocument.TABLE_DOCUMENT.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getDatabaseDocumentId(); + } + + @Override + public String component3() { + return getName(); + } + + @Override + public String component4() { + return getType(); + } + + @Override + public String component5() { + return getComment(); + } + + @Override + public LocalDateTime component6() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getDatabaseDocumentId(); + } + + @Override + public String value3() { + return getName(); + } + + @Override + public String value4() { + return getType(); + } + + @Override + public String value5() { + return getComment(); + } + + @Override + public LocalDateTime value6() { + return getCreateAt(); + } + + @Override + public TableDocumentRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public TableDocumentRecord value2(Integer value) { + setDatabaseDocumentId(value); + return this; + } + + @Override + public TableDocumentRecord value3(String value) { + setName(value); + return this; + } + + @Override + public TableDocumentRecord value4(String value) { + setType(value); + return this; + } + + @Override + public TableDocumentRecord value5(String value) { + setComment(value); + return this; + } + + @Override + public TableDocumentRecord value6(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public TableDocumentRecord values(Integer value1, Integer value2, String value3, String value4, String value5, LocalDateTime value6) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached TableDocumentRecord + */ + public TableDocumentRecord() { + super(TableDocument.TABLE_DOCUMENT); + } + + /** + * Create a detached, initialised TableDocumentRecord + */ + public TableDocumentRecord(Integer id, Integer databaseDocumentId, String name, String type, String comment, LocalDateTime createAt) { + super(TableDocument.TABLE_DOCUMENT); + + setId(id); + setDatabaseDocumentId(databaseDocumentId); + setName(name); + setType(type); + setComment(comment); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised TableDocumentRecord + */ + public TableDocumentRecord(TableDocumentPojo value) { + super(TableDocument.TABLE_DOCUMENT); + + if (value != null) { + setId(value.getId()); + setDatabaseDocumentId(value.getDatabaseDocumentId()); + setName(value.getName()); + setType(value.getType()); + setComment(value.getComment()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableIndexDocumentRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableIndexDocumentRecord.java new file mode 100644 index 0000000..4c93860 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableIndexDocumentRecord.java @@ -0,0 +1,390 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.TableIndexDocument; +import com.databasir.dao.tables.pojos.TableIndexDocumentPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.JSON; +import org.jooq.Record1; +import org.jooq.Record8; +import org.jooq.Row8; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableIndexDocumentRecord extends UpdatableRecordImpl implements Record8 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.table_index_document.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.table_index_document.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.table_index_document.table_document_id. + */ + public void setTableDocumentId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.table_index_document.table_document_id. + */ + public Integer getTableDocumentId() { + return (Integer) get(1); + } + + /** + * Setter for + * databasir.table_index_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer value) { + set(2, value); + } + + /** + * Getter for + * databasir.table_index_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return (Integer) get(2); + } + + /** + * Setter for databasir.table_index_document.name. + */ + public void setName(String value) { + set(3, value); + } + + /** + * Getter for databasir.table_index_document.name. + */ + public String getName() { + return (String) get(3); + } + + /** + * Setter for databasir.table_index_document.is_primary. + */ + public void setIsPrimary(Boolean value) { + set(4, value); + } + + /** + * Getter for databasir.table_index_document.is_primary. + */ + public Boolean getIsPrimary() { + return (Boolean) get(4); + } + + /** + * Setter for databasir.table_index_document.is_unique. + */ + public void setIsUnique(Boolean value) { + set(5, value); + } + + /** + * Getter for databasir.table_index_document.is_unique. + */ + public Boolean getIsUnique() { + return (Boolean) get(5); + } + + /** + * Setter for databasir.table_index_document.column_name_array. + */ + public void setColumnNameArray(JSON value) { + set(6, value); + } + + /** + * Getter for databasir.table_index_document.column_name_array. + */ + public JSON getColumnNameArray() { + return (JSON) get(6); + } + + /** + * Setter for databasir.table_index_document.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(7, value); + } + + /** + * Getter for databasir.table_index_document.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(7); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record8 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } + + @Override + public Row8 valuesRow() { + return (Row8) super.valuesRow(); + } + + @Override + public Field field1() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.ID; + } + + @Override + public Field field2() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.TABLE_DOCUMENT_ID; + } + + @Override + public Field field3() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID; + } + + @Override + public Field field4() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.NAME; + } + + @Override + public Field field5() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.IS_PRIMARY; + } + + @Override + public Field field6() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.IS_UNIQUE; + } + + @Override + public Field field7() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.COLUMN_NAME_ARRAY; + } + + @Override + public Field field8() { + return TableIndexDocument.TABLE_INDEX_DOCUMENT.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getTableDocumentId(); + } + + @Override + public Integer component3() { + return getDatabaseDocumentId(); + } + + @Override + public String component4() { + return getName(); + } + + @Override + public Boolean component5() { + return getIsPrimary(); + } + + @Override + public Boolean component6() { + return getIsUnique(); + } + + @Override + public JSON component7() { + return getColumnNameArray(); + } + + @Override + public LocalDateTime component8() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getTableDocumentId(); + } + + @Override + public Integer value3() { + return getDatabaseDocumentId(); + } + + @Override + public String value4() { + return getName(); + } + + @Override + public Boolean value5() { + return getIsPrimary(); + } + + @Override + public Boolean value6() { + return getIsUnique(); + } + + @Override + public JSON value7() { + return getColumnNameArray(); + } + + @Override + public LocalDateTime value8() { + return getCreateAt(); + } + + @Override + public TableIndexDocumentRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public TableIndexDocumentRecord value2(Integer value) { + setTableDocumentId(value); + return this; + } + + @Override + public TableIndexDocumentRecord value3(Integer value) { + setDatabaseDocumentId(value); + return this; + } + + @Override + public TableIndexDocumentRecord value4(String value) { + setName(value); + return this; + } + + @Override + public TableIndexDocumentRecord value5(Boolean value) { + setIsPrimary(value); + return this; + } + + @Override + public TableIndexDocumentRecord value6(Boolean value) { + setIsUnique(value); + return this; + } + + @Override + public TableIndexDocumentRecord value7(JSON value) { + setColumnNameArray(value); + return this; + } + + @Override + public TableIndexDocumentRecord value8(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public TableIndexDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, Boolean value5, Boolean value6, JSON value7, LocalDateTime value8) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached TableIndexDocumentRecord + */ + public TableIndexDocumentRecord() { + super(TableIndexDocument.TABLE_INDEX_DOCUMENT); + } + + /** + * Create a detached, initialised TableIndexDocumentRecord + */ + public TableIndexDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, Boolean isPrimary, Boolean isUnique, JSON columnNameArray, LocalDateTime createAt) { + super(TableIndexDocument.TABLE_INDEX_DOCUMENT); + + setId(id); + setTableDocumentId(tableDocumentId); + setDatabaseDocumentId(databaseDocumentId); + setName(name); + setIsPrimary(isPrimary); + setIsUnique(isUnique); + setColumnNameArray(columnNameArray); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised TableIndexDocumentRecord + */ + public TableIndexDocumentRecord(TableIndexDocumentPojo value) { + super(TableIndexDocument.TABLE_INDEX_DOCUMENT); + + if (value != null) { + setId(value.getId()); + setTableDocumentId(value.getTableDocumentId()); + setDatabaseDocumentId(value.getDatabaseDocumentId()); + setName(value.getName()); + setIsPrimary(value.getIsPrimary()); + setIsUnique(value.getIsUnique()); + setColumnNameArray(value.getColumnNameArray()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableTriggerDocumentRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableTriggerDocumentRecord.java new file mode 100644 index 0000000..26d5497 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/TableTriggerDocumentRecord.java @@ -0,0 +1,393 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.TableTriggerDocument; +import com.databasir.dao.tables.pojos.TableTriggerDocumentPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record8; +import org.jooq.Row8; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class TableTriggerDocumentRecord extends UpdatableRecordImpl implements Record8 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.table_trigger_document.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.table_trigger_document.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for + * databasir.table_trigger_document.table_document_id. + */ + public void setTableDocumentId(Integer value) { + set(1, value); + } + + /** + * Getter for + * databasir.table_trigger_document.table_document_id. + */ + public Integer getTableDocumentId() { + return (Integer) get(1); + } + + /** + * Setter for + * databasir.table_trigger_document.database_document_id. + */ + public void setDatabaseDocumentId(Integer value) { + set(2, value); + } + + /** + * Getter for + * databasir.table_trigger_document.database_document_id. + */ + public Integer getDatabaseDocumentId() { + return (Integer) get(2); + } + + /** + * Setter for databasir.table_trigger_document.timing. + */ + public void setTiming(String value) { + set(3, value); + } + + /** + * Getter for databasir.table_trigger_document.timing. + */ + public String getTiming() { + return (String) get(3); + } + + /** + * Setter for databasir.table_trigger_document.manipulation. + */ + public void setManipulation(String value) { + set(4, value); + } + + /** + * Getter for databasir.table_trigger_document.manipulation. + */ + public String getManipulation() { + return (String) get(4); + } + + /** + * Setter for databasir.table_trigger_document.statement. + */ + public void setStatement(String value) { + set(5, value); + } + + /** + * Getter for databasir.table_trigger_document.statement. + */ + public String getStatement() { + return (String) get(5); + } + + /** + * Setter for + * databasir.table_trigger_document.trigger_create_at. + */ + public void setTriggerCreateAt(String value) { + set(6, value); + } + + /** + * Getter for + * databasir.table_trigger_document.trigger_create_at. + */ + public String getTriggerCreateAt() { + return (String) get(6); + } + + /** + * Setter for databasir.table_trigger_document.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(7, value); + } + + /** + * Getter for databasir.table_trigger_document.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(7); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record8 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row8 fieldsRow() { + return (Row8) super.fieldsRow(); + } + + @Override + public Row8 valuesRow() { + return (Row8) super.valuesRow(); + } + + @Override + public Field field1() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.ID; + } + + @Override + public Field field2() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.TABLE_DOCUMENT_ID; + } + + @Override + public Field field3() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID; + } + + @Override + public Field field4() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.TIMING; + } + + @Override + public Field field5() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.MANIPULATION; + } + + @Override + public Field field6() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.STATEMENT; + } + + @Override + public Field field7() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.TRIGGER_CREATE_AT; + } + + @Override + public Field field8() { + return TableTriggerDocument.TABLE_TRIGGER_DOCUMENT.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getTableDocumentId(); + } + + @Override + public Integer component3() { + return getDatabaseDocumentId(); + } + + @Override + public String component4() { + return getTiming(); + } + + @Override + public String component5() { + return getManipulation(); + } + + @Override + public String component6() { + return getStatement(); + } + + @Override + public String component7() { + return getTriggerCreateAt(); + } + + @Override + public LocalDateTime component8() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getTableDocumentId(); + } + + @Override + public Integer value3() { + return getDatabaseDocumentId(); + } + + @Override + public String value4() { + return getTiming(); + } + + @Override + public String value5() { + return getManipulation(); + } + + @Override + public String value6() { + return getStatement(); + } + + @Override + public String value7() { + return getTriggerCreateAt(); + } + + @Override + public LocalDateTime value8() { + return getCreateAt(); + } + + @Override + public TableTriggerDocumentRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value2(Integer value) { + setTableDocumentId(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value3(Integer value) { + setDatabaseDocumentId(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value4(String value) { + setTiming(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value5(String value) { + setManipulation(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value6(String value) { + setStatement(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value7(String value) { + setTriggerCreateAt(value); + return this; + } + + @Override + public TableTriggerDocumentRecord value8(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public TableTriggerDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, String value6, String value7, LocalDateTime value8) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached TableTriggerDocumentRecord + */ + public TableTriggerDocumentRecord() { + super(TableTriggerDocument.TABLE_TRIGGER_DOCUMENT); + } + + /** + * Create a detached, initialised TableTriggerDocumentRecord + */ + public TableTriggerDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String timing, String manipulation, String statement, String triggerCreateAt, LocalDateTime createAt) { + super(TableTriggerDocument.TABLE_TRIGGER_DOCUMENT); + + setId(id); + setTableDocumentId(tableDocumentId); + setDatabaseDocumentId(databaseDocumentId); + setTiming(timing); + setManipulation(manipulation); + setStatement(statement); + setTriggerCreateAt(triggerCreateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised TableTriggerDocumentRecord + */ + public TableTriggerDocumentRecord(TableTriggerDocumentPojo value) { + super(TableTriggerDocument.TABLE_TRIGGER_DOCUMENT); + + if (value != null) { + setId(value.getId()); + setTableDocumentId(value.getTableDocumentId()); + setDatabaseDocumentId(value.getDatabaseDocumentId()); + setTiming(value.getTiming()); + setManipulation(value.getManipulation()); + setStatement(value.getStatement()); + setTriggerCreateAt(value.getTriggerCreateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/UserRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/UserRecord.java new file mode 100644 index 0000000..b37b51f --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/UserRecord.java @@ -0,0 +1,425 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.User; +import com.databasir.dao.tables.pojos.UserPojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record9; +import org.jooq.Row9; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UserRecord extends UpdatableRecordImpl implements Record9 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.user.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.user.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.user.email. + */ + public void setEmail(String value) { + set(1, value); + } + + /** + * Getter for databasir.user.email. + */ + public String getEmail() { + return (String) get(1); + } + + /** + * Setter for databasir.user.username. + */ + public void setUsername(String value) { + set(2, value); + } + + /** + * Getter for databasir.user.username. + */ + public String getUsername() { + return (String) get(2); + } + + /** + * Setter for databasir.user.password. + */ + public void setPassword(String value) { + set(3, value); + } + + /** + * Getter for databasir.user.password. + */ + public String getPassword() { + return (String) get(3); + } + + /** + * Setter for databasir.user.nickname. + */ + public void setNickname(String value) { + set(4, value); + } + + /** + * Getter for databasir.user.nickname. + */ + public String getNickname() { + return (String) get(4); + } + + /** + * Setter for databasir.user.avatar. + */ + public void setAvatar(String value) { + set(5, value); + } + + /** + * Getter for databasir.user.avatar. + */ + public String getAvatar() { + return (String) get(5); + } + + /** + * Setter for databasir.user.enabled. + */ + public void setEnabled(Boolean value) { + set(6, value); + } + + /** + * Getter for databasir.user.enabled. + */ + public Boolean getEnabled() { + return (Boolean) get(6); + } + + /** + * Setter for databasir.user.update_at. + */ + public void setUpdateAt(LocalDateTime value) { + set(7, value); + } + + /** + * Getter for databasir.user.update_at. + */ + public LocalDateTime getUpdateAt() { + return (LocalDateTime) get(7); + } + + /** + * Setter for databasir.user.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(8, value); + } + + /** + * Getter for databasir.user.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(8); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record9 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row9 fieldsRow() { + return (Row9) super.fieldsRow(); + } + + @Override + public Row9 valuesRow() { + return (Row9) super.valuesRow(); + } + + @Override + public Field field1() { + return User.USER.ID; + } + + @Override + public Field field2() { + return User.USER.EMAIL; + } + + @Override + public Field field3() { + return User.USER.USERNAME; + } + + @Override + public Field field4() { + return User.USER.PASSWORD; + } + + @Override + public Field field5() { + return User.USER.NICKNAME; + } + + @Override + public Field field6() { + return User.USER.AVATAR; + } + + @Override + public Field field7() { + return User.USER.ENABLED; + } + + @Override + public Field field8() { + return User.USER.UPDATE_AT; + } + + @Override + public Field field9() { + return User.USER.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public String component2() { + return getEmail(); + } + + @Override + public String component3() { + return getUsername(); + } + + @Override + public String component4() { + return getPassword(); + } + + @Override + public String component5() { + return getNickname(); + } + + @Override + public String component6() { + return getAvatar(); + } + + @Override + public Boolean component7() { + return getEnabled(); + } + + @Override + public LocalDateTime component8() { + return getUpdateAt(); + } + + @Override + public LocalDateTime component9() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public String value2() { + return getEmail(); + } + + @Override + public String value3() { + return getUsername(); + } + + @Override + public String value4() { + return getPassword(); + } + + @Override + public String value5() { + return getNickname(); + } + + @Override + public String value6() { + return getAvatar(); + } + + @Override + public Boolean value7() { + return getEnabled(); + } + + @Override + public LocalDateTime value8() { + return getUpdateAt(); + } + + @Override + public LocalDateTime value9() { + return getCreateAt(); + } + + @Override + public UserRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public UserRecord value2(String value) { + setEmail(value); + return this; + } + + @Override + public UserRecord value3(String value) { + setUsername(value); + return this; + } + + @Override + public UserRecord value4(String value) { + setPassword(value); + return this; + } + + @Override + public UserRecord value5(String value) { + setNickname(value); + return this; + } + + @Override + public UserRecord value6(String value) { + setAvatar(value); + return this; + } + + @Override + public UserRecord value7(Boolean value) { + setEnabled(value); + return this; + } + + @Override + public UserRecord value8(LocalDateTime value) { + setUpdateAt(value); + return this; + } + + @Override + public UserRecord value9(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public UserRecord values(Integer value1, String value2, String value3, String value4, String value5, String value6, Boolean value7, LocalDateTime value8, LocalDateTime value9) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached UserRecord + */ + public UserRecord() { + super(User.USER); + } + + /** + * Create a detached, initialised UserRecord + */ + public UserRecord(Integer id, String email, String username, String password, String nickname, String avatar, Boolean enabled, LocalDateTime updateAt, LocalDateTime createAt) { + super(User.USER); + + setId(id); + setEmail(email); + setUsername(username); + setPassword(password); + setNickname(nickname); + setAvatar(avatar); + setEnabled(enabled); + setUpdateAt(updateAt); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised UserRecord + */ + public UserRecord(UserPojo value) { + super(User.USER); + + if (value != null) { + setId(value.getId()); + setEmail(value.getEmail()); + setUsername(value.getUsername()); + setPassword(value.getPassword()); + setNickname(value.getNickname()); + setAvatar(value.getAvatar()); + setEnabled(value.getEnabled()); + setUpdateAt(value.getUpdateAt()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/UserRoleRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/UserRoleRecord.java new file mode 100644 index 0000000..0a2e641 --- /dev/null +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/UserRoleRecord.java @@ -0,0 +1,275 @@ +/* + * This file is generated by jOOQ. + */ +package com.databasir.dao.tables.records; + + +import com.databasir.dao.tables.UserRole; +import com.databasir.dao.tables.pojos.UserRolePojo; + +import java.time.LocalDateTime; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record5; +import org.jooq.Row5; +import org.jooq.impl.UpdatableRecordImpl; + + +/** + * This class is generated by jOOQ. + */ +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class UserRoleRecord extends UpdatableRecordImpl implements Record5 { + + private static final long serialVersionUID = 1L; + + /** + * Setter for databasir.user_role.id. + */ + public void setId(Integer value) { + set(0, value); + } + + /** + * Getter for databasir.user_role.id. + */ + public Integer getId() { + return (Integer) get(0); + } + + /** + * Setter for databasir.user_role.user_id. + */ + public void setUserId(Integer value) { + set(1, value); + } + + /** + * Getter for databasir.user_role.user_id. + */ + public Integer getUserId() { + return (Integer) get(1); + } + + /** + * Setter for databasir.user_role.role. SYS_OWNER, GROUP_OWNER, + * GROUP_MEMBER + */ + public void setRole(String value) { + set(2, value); + } + + /** + * Getter for databasir.user_role.role. SYS_OWNER, GROUP_OWNER, + * GROUP_MEMBER + */ + public String getRole() { + return (String) get(2); + } + + /** + * Setter for databasir.user_role.group_id. + */ + public void setGroupId(Integer value) { + set(3, value); + } + + /** + * Getter for databasir.user_role.group_id. + */ + public Integer getGroupId() { + return (Integer) get(3); + } + + /** + * Setter for databasir.user_role.create_at. + */ + public void setCreateAt(LocalDateTime value) { + set(4, value); + } + + /** + * Getter for databasir.user_role.create_at. + */ + public LocalDateTime getCreateAt() { + return (LocalDateTime) get(4); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record5 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row5 fieldsRow() { + return (Row5) super.fieldsRow(); + } + + @Override + public Row5 valuesRow() { + return (Row5) super.valuesRow(); + } + + @Override + public Field field1() { + return UserRole.USER_ROLE.ID; + } + + @Override + public Field field2() { + return UserRole.USER_ROLE.USER_ID; + } + + @Override + public Field field3() { + return UserRole.USER_ROLE.ROLE; + } + + @Override + public Field field4() { + return UserRole.USER_ROLE.GROUP_ID; + } + + @Override + public Field field5() { + return UserRole.USER_ROLE.CREATE_AT; + } + + @Override + public Integer component1() { + return getId(); + } + + @Override + public Integer component2() { + return getUserId(); + } + + @Override + public String component3() { + return getRole(); + } + + @Override + public Integer component4() { + return getGroupId(); + } + + @Override + public LocalDateTime component5() { + return getCreateAt(); + } + + @Override + public Integer value1() { + return getId(); + } + + @Override + public Integer value2() { + return getUserId(); + } + + @Override + public String value3() { + return getRole(); + } + + @Override + public Integer value4() { + return getGroupId(); + } + + @Override + public LocalDateTime value5() { + return getCreateAt(); + } + + @Override + public UserRoleRecord value1(Integer value) { + setId(value); + return this; + } + + @Override + public UserRoleRecord value2(Integer value) { + setUserId(value); + return this; + } + + @Override + public UserRoleRecord value3(String value) { + setRole(value); + return this; + } + + @Override + public UserRoleRecord value4(Integer value) { + setGroupId(value); + return this; + } + + @Override + public UserRoleRecord value5(LocalDateTime value) { + setCreateAt(value); + return this; + } + + @Override + public UserRoleRecord values(Integer value1, Integer value2, String value3, Integer value4, LocalDateTime value5) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + return this; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached UserRoleRecord + */ + public UserRoleRecord() { + super(UserRole.USER_ROLE); + } + + /** + * Create a detached, initialised UserRoleRecord + */ + public UserRoleRecord(Integer id, Integer userId, String role, Integer groupId, LocalDateTime createAt) { + super(UserRole.USER_ROLE); + + setId(id); + setUserId(userId); + setRole(role); + setGroupId(groupId); + setCreateAt(createAt); + } + + /** + * Create a detached, initialised UserRoleRecord + */ + public UserRoleRecord(UserRolePojo value) { + super(UserRole.USER_ROLE); + + if (value != null) { + setId(value.getId()); + setUserId(value.getUserId()); + setRole(value.getRole()); + setGroupId(value.getGroupId()); + setCreateAt(value.getCreateAt()); + } + } +} diff --git a/core/src/main/java/com/databasir/core/render/html/.gitkeep b/dao/src/main/java/com/databasir/dao/converter/.gitkeep similarity index 100% rename from core/src/main/java/com/databasir/core/render/html/.gitkeep rename to dao/src/main/java/com/databasir/dao/converter/.gitkeep diff --git a/dao/src/main/java/com/databasir/dao/exception/DataNotExistsException.java b/dao/src/main/java/com/databasir/dao/exception/DataNotExistsException.java new file mode 100644 index 0000000..1c3c923 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/exception/DataNotExistsException.java @@ -0,0 +1,24 @@ +package com.databasir.dao.exception; + +public class DataNotExistsException extends RuntimeException { + + public DataNotExistsException() { + super(); + } + + public DataNotExistsException(String message) { + super(message); + } + + public DataNotExistsException(String message, Throwable cause) { + super(message, cause); + } + + public DataNotExistsException(Throwable cause) { + super(cause); + } + + protected DataNotExistsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/BaseDao.java b/dao/src/main/java/com/databasir/dao/impl/BaseDao.java new file mode 100644 index 0000000..189a92e --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/BaseDao.java @@ -0,0 +1,123 @@ +package com.databasir.dao.impl; + + +import com.databasir.dao.exception.DataNotExistsException; +import lombok.RequiredArgsConstructor; +import org.jooq.*; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; + +import java.util.*; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +public abstract class BaseDao { + + private final Table table; + + private final Class pojoType; + + public abstract DSLContext getDslContext(); + + public boolean existsById(Integer id) { + return getDslContext().fetchExists(table, identity().eq(id)); + } + + public Integer insertAndReturnId(R pojo) { + T record = getDslContext().newRecord(table, pojo); + UpdatableRecord updatableRecord = (UpdatableRecord) record; + updatableRecord.store(); + Object value = updatableRecord.getValue(table.getIdentity().getField()); + return (Integer) value; + } + + public int batchInsert(Collection pojoList) { + List> records = pojoList.stream() + .map(pojo -> { + T record = getDslContext().newRecord(table, pojo); + return (TableRecord) record; + }) + .collect(Collectors.toList()); + return Arrays.stream(getDslContext().batchInsert(records).execute()).sum(); + } + + public int deleteById(Integer id) { + return getDslContext() + .deleteFrom(table).where(identity().eq(id)) + .execute(); + } + + public int updateById(R pojo) { + T record = getDslContext().newRecord(table, pojo); + record.changed(table.getIdentity().getField(), false); + return getDslContext().executeUpdate((UpdatableRecord) record); + } + + public Optional selectOptionalById(Integer id) { + return getDslContext() + .select(table.fields()).from(table).where(identity().eq(id)) + .fetchOptionalInto(pojoType); + } + + public R selectById(Integer id) { + return selectOptionalById(id) + .orElseThrow(() -> new DataNotExistsException("data not exists in " + table.getName() + " with id = " + id)); + } + + public List selectInIds(List ids) { + if (ids == null || ids.isEmpty()) { + return Collections.emptyList(); + } + return getDslContext() + .select(table().fields()).from(table()) + .where(identity().in(ids)) + .fetchInto(pojoType); + } + + public Page selectByPage(Pageable request, Condition condition) { + Integer count = getDslContext() + .selectCount().from(table).where(condition) + .fetchOne(0, int.class); + int total = count == null ? 0 : count; + List data = getDslContext() + .selectFrom(table).where(condition) + .orderBy(getSortFields(request.getSort())) + .offset(request.getOffset()).limit(request.getPageSize()) + .fetchInto(pojoType); + return new PageImpl<>(data, request, total); + } + + protected Collection> getSortFields(Sort sortSpecification) { + Collection> querySortFields = new ArrayList<>(); + if (sortSpecification == null) { + return querySortFields; + } + Iterator specifiedFields = sortSpecification.iterator(); + while (specifiedFields.hasNext()) { + Sort.Order specifiedField = specifiedFields.next(); + String sortFieldName = specifiedField.getProperty(); + Field field = table().field(sortFieldName); + TableField tableField = (TableField) field; + if (specifiedField.getDirection() == Sort.Direction.ASC) { + querySortFields.add(tableField.asc()); + } else { + querySortFields.add(tableField.desc()); + } + } + return querySortFields; + } + + protected Field identity() { + Identity identity = table.getIdentity(); + if (identity == null) { + throw new IllegalStateException("can not find identity column in " + table.getName()); + } + return identity.getField().cast(Integer.class); + } + + protected Table table() { + return this.table; + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/DataSourceDao.java b/dao/src/main/java/com/databasir/dao/impl/DataSourceDao.java new file mode 100644 index 0000000..ae4bab4 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/DataSourceDao.java @@ -0,0 +1,62 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.exception.DataNotExistsException; +import com.databasir.dao.tables.pojos.DataSourcePojo; +import com.databasir.dao.tables.records.DataSourceRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import static com.databasir.dao.Tables.DATA_SOURCE; + + +@Repository +public class DataSourceDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public DataSourceDao() { + super(DATA_SOURCE, DataSourcePojo.class); + } + + public Optional selectOptionalByProjectId(Integer projectId) { + return getDslContext() + .select(DATA_SOURCE.fields()).from(DATA_SOURCE).where(DATA_SOURCE.PROJECT_ID.eq(projectId)) + .fetchOptionalInto(DataSourcePojo.class); + } + + public DataSourcePojo selectByProjectId(Integer projectId) { + return getDslContext() + .select(DATA_SOURCE.fields()).from(DATA_SOURCE).where(DATA_SOURCE.PROJECT_ID.eq(projectId)) + .fetchOptionalInto(DataSourcePojo.class) + .orElseThrow(() -> new DataNotExistsException("data not exists in " + table().getName() + " with schemaSourceId = " + projectId)); + } + + public int updateByProjectId(DataSourcePojo dataSource) { + DataSourceRecord record = getDslContext().newRecord(DATA_SOURCE, dataSource); + record.changed(DATA_SOURCE.ID, false); + record.changed(DATA_SOURCE.PROJECT_ID, false); + if (dataSource.getPassword() == null || dataSource.getPassword().trim().equals("")) { + record.changed(DATA_SOURCE.PASSWORD, false); + } + return getDslContext() + .update(DATA_SOURCE).set(record).where(DATA_SOURCE.PROJECT_ID.eq(dataSource.getProjectId())) + .execute(); + } + + public List selectInProjectIds(List projectIds) { + if (projectIds == null || projectIds.isEmpty()) { + return Collections.emptyList(); + } + return getDslContext() + .select(DATA_SOURCE.fields()).from(DATA_SOURCE).where(DATA_SOURCE.PROJECT_ID.in(projectIds)) + .fetchInto(DataSourcePojo.class); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/DataSourcePropertyDao.java b/dao/src/main/java/com/databasir/dao/impl/DataSourcePropertyDao.java new file mode 100644 index 0000000..9c2d1bc --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/DataSourcePropertyDao.java @@ -0,0 +1,38 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.DataSourcePropertyPojo; +import com.databasir.dao.tables.records.DataSourcePropertyRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.databasir.dao.Tables.DATA_SOURCE_PROPERTY; + + +@Repository +public class DataSourcePropertyDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public DataSourcePropertyDao() { + super(DATA_SOURCE_PROPERTY, DataSourcePropertyPojo.class); + } + + public int deleteByDataSourceId(Integer dataSourceId) { + return dslContext + .deleteFrom(DATA_SOURCE_PROPERTY).where(DATA_SOURCE_PROPERTY.DATA_SOURCE_ID.eq(dataSourceId)) + .execute(); + } + + public List selectByDataSourceId(Integer id) { + return dslContext + .select(DATA_SOURCE_PROPERTY.fields()).from(DATA_SOURCE_PROPERTY) + .where(DATA_SOURCE_PROPERTY.DATA_SOURCE_ID.eq(id)) + .fetchInto(DataSourcePropertyPojo.class); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/DatabaseDocumentDao.java b/dao/src/main/java/com/databasir/dao/impl/DatabaseDocumentDao.java new file mode 100644 index 0000000..b9e24de --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/DatabaseDocumentDao.java @@ -0,0 +1,38 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.DatabaseDocumentPojo; +import com.databasir.dao.tables.records.DatabaseDocumentRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +import static com.databasir.dao.Tables.DATABASE_DOCUMENT; + + +@Repository +public class DatabaseDocumentDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public DatabaseDocumentDao() { + super(DATABASE_DOCUMENT, DatabaseDocumentPojo.class); + } + + public Optional selectOptionalByProjectId(Integer projectId) { + return getDslContext() + .select(DATABASE_DOCUMENT.fields()).from(DATABASE_DOCUMENT).where(DATABASE_DOCUMENT.PROJECT_ID.eq(projectId)) + .fetchOptionalInto(DatabaseDocumentPojo.class); + } + + public void update(DatabaseDocumentPojo toPojo) { + DatabaseDocumentRecord record = getDslContext().newRecord(DATABASE_DOCUMENT, toPojo); + record.changed(DATABASE_DOCUMENT.ID, false); + record.changed(DATABASE_DOCUMENT.CREATE_AT, false); + record.update(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/DatabaseDocumentHistoryDao.java b/dao/src/main/java/com/databasir/dao/impl/DatabaseDocumentHistoryDao.java new file mode 100644 index 0000000..6f48c5a --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/DatabaseDocumentHistoryDao.java @@ -0,0 +1,38 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.DatabaseDocumentHistoryPojo; +import com.databasir.dao.tables.records.DatabaseDocumentHistoryRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +import static com.databasir.dao.Tables.DATABASE_DOCUMENT_HISTORY; + + +@Repository +public class DatabaseDocumentHistoryDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public DatabaseDocumentHistoryDao() { + super(DATABASE_DOCUMENT_HISTORY, DatabaseDocumentHistoryPojo.class); + } + + public Optional selectOptionalByProjectIdAndVersion(Integer projectId, Long version) { + return dslContext + .selectFrom(DATABASE_DOCUMENT_HISTORY).where(DATABASE_DOCUMENT_HISTORY.PROJECT_ID.eq(projectId).and(DATABASE_DOCUMENT_HISTORY.VERSION.eq(version))) + .fetchOptionalInto(DatabaseDocumentHistoryPojo.class); + } + + public Page selectPageByDatabaseDocumentId(Pageable request, Integer schemaDocumentId) { + return super.selectByPage(request, DATABASE_DOCUMENT_HISTORY.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)); + } + +} diff --git a/dao/src/main/java/com/databasir/dao/impl/GroupDao.java b/dao/src/main/java/com/databasir/dao/impl/GroupDao.java new file mode 100644 index 0000000..e0f1340 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/GroupDao.java @@ -0,0 +1,59 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.GroupPojo; +import com.databasir.dao.tables.records.GroupRecord; +import lombok.Getter; +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import static com.databasir.dao.Tables.GROUP; + +@Repository +public class GroupDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public GroupDao() { + super(GROUP, GroupPojo.class); + } + + @Override + public int deleteById(Integer id) { + return dslContext + .update(table()).set(GROUP.DELETED, true).where(GROUP.ID.eq(id)) + .execute(); + } + + @Override + public Page selectByPage(Pageable request, Condition condition) { + return super.selectByPage(request, condition.and(GROUP.DELETED.eq(false))); + } + + @Override + public Optional selectOptionalById(Integer id) { + return getDslContext() + .select(GROUP.fields()).from(GROUP).where(GROUP.ID.eq(id).and(GROUP.DELETED.eq(false))) + .fetchOptionalInto(GroupPojo.class); + } + + @Override + public List selectInIds(List ids) { + if (ids == null || ids.isEmpty()) { + return Collections.emptyList(); + } + return getDslContext() + .select(GROUP.fields()).from(GROUP) + .where(GROUP.ID.in(ids)).and(GROUP.DELETED.eq(false)) + .fetchInto(GroupPojo.class); + } +} \ No newline at end of file diff --git a/dao/src/main/java/com/databasir/dao/impl/LoginDao.java b/dao/src/main/java/com/databasir/dao/impl/LoginDao.java new file mode 100644 index 0000000..f3d870b --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/LoginDao.java @@ -0,0 +1,69 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.LoginPojo; +import com.databasir.dao.tables.records.LoginRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.time.LocalDateTime; +import java.util.Optional; + +import static com.databasir.dao.Tables.LOGIN; + + +@Repository +public class LoginDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public LoginDao() { + super(LOGIN, LoginPojo.class); + } + + public void deleteByUserId(Integer userId) { + getDslContext() + .deleteFrom(LOGIN).where(LOGIN.USER_ID.eq(userId)) + .execute(); + } + + public Optional selectByUserId(Integer userId) { + return getDslContext() + .select(LOGIN.fields()).from(LOGIN).where(LOGIN.USER_ID.eq(userId)) + .fetchOptionalInto(LoginPojo.class); + } + + public Optional selectByRefreshToken(String refreshToken) { + return getDslContext() + .select(LOGIN.fields()).from(LOGIN).where(LOGIN.REFRESH_TOKEN.eq(refreshToken)) + .fetchOptionalInto(LoginPojo.class); + } + + public void updateAccessToken(String accessToken, LocalDateTime accessTokenExpireAt, Integer userId) { + getDslContext() + .update(LOGIN) + .set(LOGIN.ACCESS_TOKEN, accessToken) + .set(LOGIN.ACCESS_TOKEN_EXPIRE_AT, accessTokenExpireAt) + .where(LOGIN.USER_ID.eq(userId)) + .execute(); + } + + public void insertOnDuplicateKeyUpdate(LoginPojo loginPojo) { + getDslContext() + .insertInto(LOGIN) + .set(LOGIN.USER_ID, loginPojo.getUserId()) + .set(LOGIN.ACCESS_TOKEN, loginPojo.getAccessToken()) + .set(LOGIN.ACCESS_TOKEN_EXPIRE_AT, loginPojo.getAccessTokenExpireAt()) + .set(LOGIN.REFRESH_TOKEN, loginPojo.getRefreshToken()) + .set(LOGIN.REFRESH_TOKEN_EXPIRE_AT, loginPojo.getRefreshTokenExpireAt()) + .onDuplicateKeyUpdate() + .set(LOGIN.ACCESS_TOKEN, loginPojo.getAccessToken()) + .set(LOGIN.ACCESS_TOKEN_EXPIRE_AT, loginPojo.getAccessTokenExpireAt()) + .set(LOGIN.REFRESH_TOKEN, loginPojo.getRefreshToken()) + .set(LOGIN.REFRESH_TOKEN_EXPIRE_AT, loginPojo.getRefreshTokenExpireAt()) + .execute(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/ProjectDao.java b/dao/src/main/java/com/databasir/dao/impl/ProjectDao.java new file mode 100644 index 0000000..ffb50b1 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/ProjectDao.java @@ -0,0 +1,89 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.ProjectPojo; +import com.databasir.dao.tables.records.ProjectRecord; +import com.databasir.dao.value.GroupProjectCountPojo; +import lombok.Getter; +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static com.databasir.dao.Tables.DATA_SOURCE; +import static com.databasir.dao.Tables.PROJECT; + + +@Repository +public class ProjectDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public ProjectDao() { + super(PROJECT, ProjectPojo.class); + } + + public int updateDeletedById(boolean b, Integer databaseId) { + return dslContext + .update(PROJECT).set(PROJECT.DELETED, b).where(PROJECT.ID.eq(databaseId)) + .execute(); + } + + @Override + public Optional selectOptionalById(Integer id) { + return getDslContext() + .select(PROJECT.fields()).from(PROJECT) + .where(identity().eq(id).and(PROJECT.DELETED.eq(false))) + .fetchOptionalInto(ProjectPojo.class); + } + + @Override + public boolean existsById(Integer id) { + return getDslContext().fetchExists(table(), identity().eq(id).and(PROJECT.DELETED.eq(false))); + } + + public boolean exists(Integer groupId, Integer projectId) { + return getDslContext() + .fetchExists(table(), identity().eq(projectId) + .and(PROJECT.GROUP_ID.eq(groupId)) + .and(PROJECT.DELETED.eq(false))); + } + + public Page selectByCondition(Pageable request, Condition condition) { + int total = getDslContext() + .selectCount().from(PROJECT) + .innerJoin(DATA_SOURCE).on(DATA_SOURCE.PROJECT_ID.eq(PROJECT.ID)) + .where(condition) + .fetchOne(0, int.class); + List data = getDslContext() + .select(PROJECT.fields()).from(PROJECT) + .innerJoin(DATA_SOURCE).on(DATA_SOURCE.PROJECT_ID.eq(PROJECT.ID)) + .where(condition) + .orderBy(getSortFields(request.getSort())) + .offset(request.getOffset()).limit(request.getPageSize()) + .fetchInto(ProjectPojo.class); + return new PageImpl<>(data, request, total); + } + + public List selectCountByGroupIds(List groupIds) { + if (groupIds == null || groupIds.isEmpty()) { + return Collections.emptyList(); + } + String groupIdIn = groupIds.stream() + .map(Object::toString) + .collect(Collectors.joining(",", "(", ")")); + String sql = "select `group`.id group_id, count(project.id) as count from project " + + " inner join `group` on `group`.id = project.group_id " + + " where project.deleted = false and `group`.id in " + groupIdIn + " group by `group`.id;"; + return dslContext.resultQuery(sql).fetchInto(GroupProjectCountPojo.class); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/ProjectSyncRuleDao.java b/dao/src/main/java/com/databasir/dao/impl/ProjectSyncRuleDao.java new file mode 100644 index 0000000..70efc5c --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/ProjectSyncRuleDao.java @@ -0,0 +1,49 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.exception.DataNotExistsException; +import com.databasir.dao.tables.ProjectSyncRule; +import com.databasir.dao.tables.pojos.ProjectSyncRulePojo; +import com.databasir.dao.tables.records.ProjectSyncRuleRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +import static com.databasir.dao.Tables.PROJECT_SYNC_RULE; + +@Repository +public class ProjectSyncRuleDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public ProjectSyncRuleDao() { + super(PROJECT_SYNC_RULE, ProjectSyncRulePojo.class); + } + + public Optional selectOptionalByProjectId(Integer projectId) { + return getDslContext() + .select(PROJECT_SYNC_RULE.fields()).from(PROJECT_SYNC_RULE).where(PROJECT_SYNC_RULE.PROJECT_ID.eq(projectId)) + .fetchOptionalInto(ProjectSyncRulePojo.class); + } + + public ProjectSyncRulePojo selectByProjectId(Integer projectId) { + return getDslContext() + .select(PROJECT_SYNC_RULE.fields()).from(PROJECT_SYNC_RULE).where(PROJECT_SYNC_RULE.PROJECT_ID.eq(projectId)) + .fetchOptionalInto(ProjectSyncRulePojo.class) + .orElseThrow(() -> new DataNotExistsException("data not exists in " + table().getName() + " with projectId = " + projectId)); + } + + public int updateByProjectId(ProjectSyncRulePojo rule) { + ProjectSyncRule table = PROJECT_SYNC_RULE; + ProjectSyncRuleRecord record = getDslContext().newRecord(table, rule); + record.changed(table.ID, false); + record.changed(table.PROJECT_ID, false); + return getDslContext() + .update(table).set(record).where(table.PROJECT_ID.eq(rule.getProjectId())) + .execute(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/SysKeyDao.java b/dao/src/main/java/com/databasir/dao/impl/SysKeyDao.java new file mode 100644 index 0000000..0a4a94b --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/SysKeyDao.java @@ -0,0 +1,36 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.exception.DataNotExistsException; +import com.databasir.dao.tables.pojos.SysKeyPojo; +import com.databasir.dao.tables.records.SysKeyRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +import static com.databasir.dao.Tables.SYS_KEY; + +@Repository +public class SysKeyDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public SysKeyDao() { + super(SYS_KEY, SysKeyPojo.class); + } + + public Optional selectOptionTopOne() { + return dslContext.select(SYS_KEY.fields()).from(SYS_KEY) + .limit(1) + .fetchOptionalInto(SysKeyPojo.class); + } + + public SysKeyPojo selectTopOne() { + return selectOptionTopOne() + .orElseThrow(() -> new DataNotExistsException("no syskey data find")); + } +} \ No newline at end of file diff --git a/dao/src/main/java/com/databasir/dao/impl/SysMailDao.java b/dao/src/main/java/com/databasir/dao/impl/SysMailDao.java new file mode 100644 index 0000000..80c729e --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/SysMailDao.java @@ -0,0 +1,46 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.exception.DataNotExistsException; +import com.databasir.dao.tables.pojos.SysMailPojo; +import com.databasir.dao.tables.records.SysMailRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +import static com.databasir.dao.Tables.SYS_MAIL; + +@Repository +public class SysMailDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public SysMailDao() { + super(SYS_MAIL, SysMailPojo.class); + } + + public Optional selectOptionTopOne() { + return dslContext.select(SYS_MAIL.fields()).from(SYS_MAIL) + .limit(1) + .fetchOptionalInto(SysMailPojo.class); + } + + public SysMailPojo selectTopOne() { + return selectOptionTopOne() + .orElseThrow(() -> new DataNotExistsException("no sysmail data find")); + } + + @Override + public int updateById(SysMailPojo pojo) { + SysMailRecord record = getDslContext().newRecord(SYS_MAIL, pojo); + record.changed(SYS_MAIL.ID, false); + if (pojo.getPassword() == null) { + record.changed(SYS_MAIL.PASSWORD, false); + } + return getDslContext().executeUpdate(record); + } +} \ No newline at end of file diff --git a/dao/src/main/java/com/databasir/dao/impl/TableColumnDocumentDao.java b/dao/src/main/java/com/databasir/dao/impl/TableColumnDocumentDao.java new file mode 100644 index 0000000..04414ef --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/TableColumnDocumentDao.java @@ -0,0 +1,38 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.TableColumnDocumentPojo; +import com.databasir.dao.tables.records.TableColumnDocumentRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.databasir.dao.Tables.TABLE_COLUMN_DOCUMENT; + + +@Repository +public class TableColumnDocumentDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public TableColumnDocumentDao() { + super(TABLE_COLUMN_DOCUMENT, TableColumnDocumentPojo.class); + } + + public List selectByDatabaseDocumentId(Integer schemaDocumentId) { + return getDslContext() + .select(TABLE_COLUMN_DOCUMENT.fields()).from(TABLE_COLUMN_DOCUMENT) + .where(TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)) + .fetchInto(TableColumnDocumentPojo.class); + } + + public void deleteByDatabaseDocumentId(Integer schemaDocumentId) { + getDslContext() + .deleteFrom(TABLE_COLUMN_DOCUMENT).where(TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)) + .execute(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/TableDocumentDao.java b/dao/src/main/java/com/databasir/dao/impl/TableDocumentDao.java new file mode 100644 index 0000000..a95bdbd --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/TableDocumentDao.java @@ -0,0 +1,36 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.TableDocumentPojo; +import com.databasir.dao.tables.records.TableDocumentRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.databasir.dao.Tables.TABLE_DOCUMENT; + +@Repository +public class TableDocumentDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public TableDocumentDao() { + super(TABLE_DOCUMENT, TableDocumentPojo.class); + } + + public List selectByDatabaseDocumentId(Integer schemaDocumentId) { + return getDslContext() + .select(TABLE_DOCUMENT.fields()).from(TABLE_DOCUMENT).where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)) + .fetchInto(TableDocumentPojo.class); + } + + public void deleteByDatabaseDocumentId(Integer schemaDocumentId) { + getDslContext() + .deleteFrom(TABLE_DOCUMENT).where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)) + .execute(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/TableIndexDocumentDao.java b/dao/src/main/java/com/databasir/dao/impl/TableIndexDocumentDao.java new file mode 100644 index 0000000..7f741ed --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/TableIndexDocumentDao.java @@ -0,0 +1,38 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.TableIndexDocumentPojo; +import com.databasir.dao.tables.records.TableIndexDocumentRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.databasir.dao.Tables.TABLE_INDEX_DOCUMENT; + + +@Repository +public class TableIndexDocumentDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public TableIndexDocumentDao() { + super(TABLE_INDEX_DOCUMENT, TableIndexDocumentPojo.class); + } + + public List selectByDatabaseMetaId(Integer schemaMetaId) { + return getDslContext() + .select(TABLE_INDEX_DOCUMENT.fields()).from(TABLE_INDEX_DOCUMENT) + .where(TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaMetaId)) + .fetchInto(TableIndexDocumentPojo.class); + } + + public void deleteByDatabaseMetaId(Integer schemaMetaId) { + getDslContext() + .deleteFrom(TABLE_INDEX_DOCUMENT).where(TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaMetaId)) + .execute(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/TableTriggerDocumentDao.java b/dao/src/main/java/com/databasir/dao/impl/TableTriggerDocumentDao.java new file mode 100644 index 0000000..2351984 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/TableTriggerDocumentDao.java @@ -0,0 +1,36 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.TableTriggerDocumentPojo; +import com.databasir.dao.tables.records.TableTriggerDocumentRecord; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.databasir.dao.Tables.TABLE_TRIGGER_DOCUMENT; + +@Repository +public class TableTriggerDocumentDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public TableTriggerDocumentDao() { + super(TABLE_TRIGGER_DOCUMENT, TableTriggerDocumentPojo.class); + } + + public List selectByDatabaseDocumentId(Integer schemaDocumentId) { + return getDslContext() + .select(TABLE_TRIGGER_DOCUMENT.fields()).from(TABLE_TRIGGER_DOCUMENT).where(TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)) + .fetchInto(TableTriggerDocumentPojo.class); + } + + public void deleteByDatabaseDocumentId(Integer schemaDocumentId) { + getDslContext() + .deleteFrom(TABLE_TRIGGER_DOCUMENT).where(TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)) + .execute(); + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/UserDao.java b/dao/src/main/java/com/databasir/dao/impl/UserDao.java new file mode 100644 index 0000000..5718a73 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/UserDao.java @@ -0,0 +1,140 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.Databasir; +import com.databasir.dao.tables.pojos.UserPojo; +import com.databasir.dao.tables.records.UserRecord; +import com.databasir.dao.value.GroupMemberDetailPojo; +import lombok.Getter; +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.jooq.SortField; +import org.jooq.TableField; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Repository; + +import java.util.*; + +import static com.databasir.dao.Tables.USER; +import static com.databasir.dao.Tables.USER_ROLE; + + +@Repository +public class UserDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public UserDao() { + super(USER, UserPojo.class); + } + + public void updateEnabledByUserId(Integer userId, Boolean enabled) { + dslContext + .update(USER).set(USER.ENABLED, enabled).where(USER.ID.eq(userId)) + .execute(); + } + + public void updatePassword(Integer userId, String password) { + dslContext + .update(USER).set(USER.PASSWORD, password).where(USER.ID.eq(userId)) + .execute(); + } + + public List selectUserIdIn(List userIds) { + if (userIds == null || userIds.isEmpty()) { + return Collections.emptyList(); + } + return dslContext + .select(USER.fields()).from(USER) + .where(USER.ID.in(userIds)) + .fetchInto(UserPojo.class); + } + + public List selectLimitUsersByRoleAndGroup(Integer groupId, + String role, + Integer size) { + return dslContext + .select(USER.fields()).from(USER) + .innerJoin(USER_ROLE).on(USER_ROLE.USER_ID.eq(USER.ID)) + .where(USER_ROLE.GROUP_ID.eq(groupId).and(USER_ROLE.ROLE.eq(role))) + .orderBy(USER_ROLE.ID.desc()) + .limit(size) + .fetchInto(UserPojo.class); + } + + public Optional selectByEmail(String email) { + return dslContext + .select(USER.fields()).from(USER).where(USER.EMAIL.eq(email)) + .fetchOptionalInto(UserPojo.class); + } + + public Optional selectByEmailOrUsername(String emailOrUsername) { + return dslContext + .select(USER.fields()).from(USER) + .where(USER.EMAIL.eq(emailOrUsername).or(USER.USERNAME.eq(emailOrUsername))) + .fetchOptionalInto(UserPojo.class); + } + + public Page selectGroupMembers(Integer groupId, Pageable request, Condition condition) { + // total + Integer count = dslContext + .selectCount() + .from(USER) + .innerJoin(USER_ROLE).on(USER.ID.eq(USER_ROLE.USER_ID)) + .where(USER_ROLE.GROUP_ID.eq(groupId).and(condition)) + .fetchOne(0, int.class); + + // data + List content = dslContext + .select(USER.NICKNAME, USER.EMAIL, USER.USERNAME, USER.AVATAR, USER.ENABLED, + USER_ROLE.USER_ID, USER_ROLE.ROLE, USER_ROLE.GROUP_ID, USER_ROLE.CREATE_AT) + .from(USER) + .innerJoin(USER_ROLE).on(USER.ID.eq(USER_ROLE.USER_ID)) + .where(USER_ROLE.GROUP_ID.eq(groupId).and(condition)) + .orderBy(getSortFields(request.getSort())) + .offset(request.getOffset()).limit(request.getPageSize()) + .fetchInto(GroupMemberDetailPojo.class); + return new PageImpl<>(content, request, count); + } + + protected Collection> getSortFields(Sort sortSpecification) { + Collection> querySortFields = new ArrayList<>(); + if (sortSpecification == null) { + return querySortFields; + } + Iterator specifiedFields = sortSpecification.iterator(); + while (specifiedFields.hasNext()) { + Sort.Order specifiedField = specifiedFields.next(); + String[] sortFields = specifiedField.getProperty().split("\\."); + String fieldName; + String tableName; + if (sortFields.length == 1) { + tableName = table().getName(); + fieldName = sortFields[0]; + } else { + tableName = sortFields[0]; + fieldName = sortFields[1]; + } + TableField tableField = tableField(tableName, fieldName); + querySortFields.add(sortField(specifiedField, tableField)); + } + return querySortFields; + } + + private TableField tableField(String tableName, String fieldName) { + return (TableField) Databasir.DATABASIR.getTable(tableName).field(fieldName); + } + + private SortField sortField(Sort.Order specifiedField, TableField tableField) { + if (specifiedField.getDirection() == Sort.Direction.ASC) { + return tableField.asc(); + } else { + return tableField.desc(); + } + } +} diff --git a/dao/src/main/java/com/databasir/dao/impl/UserRoleDao.java b/dao/src/main/java/com/databasir/dao/impl/UserRoleDao.java new file mode 100644 index 0000000..706ec76 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/UserRoleDao.java @@ -0,0 +1,97 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.UserRolePojo; +import com.databasir.dao.tables.records.UserRoleRecord; +import com.databasir.dao.value.GroupMemberSimplePojo; +import lombok.Getter; +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import java.util.Collections; +import java.util.List; + +import static com.databasir.dao.Tables.USER; +import static com.databasir.dao.Tables.USER_ROLE; + + +@Repository +public class UserRoleDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public UserRoleDao() { + super(USER_ROLE, UserRolePojo.class); + } + + public List selectOwnerNamesByGroupIdIn(List groupIdList) { + if (groupIdList == null || groupIdList.isEmpty()) { + return Collections.emptyList(); + } + return dslContext.select(USER.NICKNAME, USER_ROLE.GROUP_ID, USER_ROLE.ROLE).from(USER) + .innerJoin(USER_ROLE).on(USER.ID.eq(USER_ROLE.USER_ID)) + .where(USER_ROLE.GROUP_ID.in(groupIdList)).and(USER_ROLE.ROLE.eq("GROUP_OWNER")) + .fetchInto(GroupMemberSimplePojo.class); + } + + public void deleteByUserIdAndGroupId(Integer userId, Integer groupId) { + dslContext + .deleteFrom(USER_ROLE).where(USER_ROLE.USER_ID.eq(userId).and(USER_ROLE.GROUP_ID.eq(groupId))) + .execute(); + } + + public Page selectPageByGroupId(Pageable pageable, Integer groupId) { + return super.selectByPage(pageable, USER_ROLE.GROUP_ID.eq(groupId)); + } + + public void deleteByRoleAndGroupId(String role, Integer groupId) { + dslContext + .deleteFrom(USER_ROLE).where(USER_ROLE.GROUP_ID.eq(groupId).and(USER_ROLE.ROLE.eq(role))) + .execute(); + } + + public void deleteByGroupId(Integer groupId) { + dslContext + .deleteFrom(USER_ROLE).where(USER_ROLE.GROUP_ID.eq(groupId)) + .execute(); + } + + public void deleteRole(Integer userId, String role) { + dslContext + .deleteFrom(USER_ROLE).where(USER_ROLE.USER_ID.eq(userId).and(USER_ROLE.ROLE.eq(role))) + .execute(); + } + + public boolean hasRole(Integer userId, Integer groupId) { + Condition condition = USER_ROLE.USER_ID.eq(userId) + .and(USER_ROLE.GROUP_ID.eq(groupId)); + return dslContext.fetchExists(USER_ROLE, condition); + } + + public boolean hasRole(Integer userId, String role) { + Condition condition = USER_ROLE.USER_ID.eq(userId) + .and(USER_ROLE.ROLE.eq(role)); + return dslContext.fetchExists(USER_ROLE, condition); + } + + public boolean hasRole(Integer userId, Integer groupId, String role) { + Condition condition = USER_ROLE.USER_ID.eq(userId) + .and(USER_ROLE.GROUP_ID.eq(groupId)) + .and(USER_ROLE.ROLE.eq(role)); + return dslContext.fetchExists(USER_ROLE, condition); + } + + public List selectByUserIds(List userIds) { + if (userIds == null || userIds.isEmpty()) { + return Collections.emptyList(); + } + return dslContext + .select(USER_ROLE.fields()).from(USER_ROLE).where(USER_ROLE.USER_ID.in(userIds)) + .fetchInto(UserRolePojo.class); + } +} diff --git a/dao/src/main/java/com/databasir/dao/strategy/DatabasirPojoNamingStrategy.java b/dao/src/main/java/com/databasir/dao/strategy/DatabasirPojoNamingStrategy.java new file mode 100644 index 0000000..32edd1a --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/strategy/DatabasirPojoNamingStrategy.java @@ -0,0 +1,21 @@ +package com.databasir.dao.strategy; + +import org.jooq.codegen.DefaultGeneratorStrategy; +import org.jooq.meta.Definition; + +public class DatabasirPojoNamingStrategy extends DefaultGeneratorStrategy { + + @Override + public String getJavaClassName(Definition definition, Mode mode) { + if (mode == Mode.POJO) { + String javaClassName = super.getJavaClassName(definition, mode); + if (javaClassName.endsWith("Pojo")) { + return javaClassName; + } else { + return javaClassName + "Pojo"; + } + } else { + return super.getJavaClassName(definition, mode); + } + } +} diff --git a/dao/src/main/java/com/databasir/dao/value/GroupMemberDetailPojo.java b/dao/src/main/java/com/databasir/dao/value/GroupMemberDetailPojo.java new file mode 100644 index 0000000..0321c78 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/value/GroupMemberDetailPojo.java @@ -0,0 +1,23 @@ +package com.databasir.dao.value; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class GroupMemberDetailPojo { + + private Integer userId; + + private String role; + + private Integer groupId; + + private String username; + + private String nickname; + + private String email; + + private LocalDateTime createAt; +} diff --git a/dao/src/main/java/com/databasir/dao/value/GroupMemberSimplePojo.java b/dao/src/main/java/com/databasir/dao/value/GroupMemberSimplePojo.java new file mode 100644 index 0000000..c191d4f --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/value/GroupMemberSimplePojo.java @@ -0,0 +1,14 @@ +package com.databasir.dao.value; + +import lombok.Data; + +@Data +public class GroupMemberSimplePojo { + + private String nickname; + + private Integer groupId; + + private String role; + +} diff --git a/dao/src/main/java/com/databasir/dao/value/GroupProjectCountPojo.java b/dao/src/main/java/com/databasir/dao/value/GroupProjectCountPojo.java new file mode 100644 index 0000000..5e5c3b7 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/value/GroupProjectCountPojo.java @@ -0,0 +1,12 @@ +package com.databasir.dao.value; + +import lombok.Data; + +@Data +public class GroupProjectCountPojo { + + private Integer groupId; + + private Integer count; + +} diff --git a/dao/src/main/resources/db/migration/V1__init.sql b/dao/src/main/resources/db/migration/V1__init.sql new file mode 100644 index 0000000..4af21d2 --- /dev/null +++ b/dao/src/main/resources/db/migration/V1__init.sql @@ -0,0 +1,220 @@ +CREATE DATABASE IF NOT EXISTS databasir; +USE databasir; + +CREATE TABLE sys_key +( + id INT PRIMARY KEY AUTO_INCREMENT, + rsa_public_key TEXT NOT NULL, + rsa_private_key TEXT NOT NULL, + aes_key TEXT NOT NULL, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE sys_mail +( + id INT PRIMARY KEY AUTO_INCREMENT, + username TEXT NOT NULL, + password TEXT NOT NULL, + smtp_host VARCHAR(512) NOT NULL, + smtp_port INT NOT NULL, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE user +( + id INT PRIMARY KEY AUTO_INCREMENT, + email VARCHAR(512) NOT NULL, + username VARCHAR(128) NOT NULL, + password TEXT NOT NULL, + nickname VARCHAR(255) NOT NULL, + avatar VARCHAR(512) DEFAULT NULL, + enabled BOOLEAN NOT NULL DEFAULT FALSE, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_email (email), + CONSTRAINT UNIQUE uk_username (username) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE user_role +( + id INT PRIMARY KEY AUTO_INCREMENT, + user_id INT NOT NULL, + role VARCHAR(128) NOT NULL COMMENT 'SYS_OWNER, GROUP_OWNER, GROUP_MEMBER', + group_id INT DEFAULT NULL, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_user_id_group_id_role (user_id, group_id, role) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE `group` +( + id INT PRIMARY KEY AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + description VARCHAR(512) NOT NULL, + deleted BOOLEAN NOT NULL DEFAULT FALSE, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_name (name) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE `project` +( + id INT PRIMARY KEY AUTO_INCREMENT, + name VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + group_id INT NOT NULL, + deleted BOOLEAN NOT NULL DEFAULT FALSE, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_group_id_name (group_id, name) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE `project_sync_rule` +( + id INT PRIMARY KEY AUTO_INCREMENT, + project_id INT NOT NULL, + ignore_table_name_regex_array JSON NOT NULL, + ignore_column_name_regex_array JSON NOT NULL, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_project_id (project_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE `data_source` +( + id INT PRIMARY KEY AUTO_INCREMENT, + project_id INT NOT NULL, + database_name VARCHAR(512) NOT NULL, + database_type VARCHAR(255) NOT NULL, + url TEXT NOT NULL, + username TEXT NOT NULL, + password TEXT NOT NULL, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_project_id (project_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE `data_source_property` +( + id INT PRIMARY KEY AUTO_INCREMENT, + data_source_id INT NOT NULL, + `key` TEXT NOT NULL, + `value` TEXT NOT NULL, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX idx_data_source_id (data_source_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE database_document +( + id INT PRIMARY KEY AUTO_INCREMENT, + project_id INT NOT NULL, + database_name TEXT NOT NULL, + product_name TEXT NOT NULL, + product_version TEXT NOT NULL, + version BIGINT NOT NULL DEFAULT 1, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT uk_project_id UNIQUE (project_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE database_document_history +( + id INT PRIMARY KEY AUTO_INCREMENT, + project_id INT NOT NULL, + database_document_id INT NOT NULL, + database_document_object JSON DEFAULT NULL, + version BIGINT NOT NULL, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT uk_connection_id_version UNIQUE (database_document_id, version), + INDEX idx_project_id (project_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE table_document +( + + id INT PRIMARY KEY AUTO_INCREMENT, + database_document_id INT NOT NULL, + name TEXT NOT NULL, + type TEXT NOT NULL, + comment TEXT NOT NULL, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX idx_database_document_id (database_document_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE table_column_document +( + + id INT PRIMARY KEY AUTO_INCREMENT, + table_document_id INT NOT NULL, + database_document_id INT NOT NULL, + name TEXT NOT NULL, + type VARCHAR(255) NOT NULL, + comment VARCHAR(512) NOT NULL, + default_value VARCHAR(512) DEFAULT NULL, + size INT NOT NULL, + decimal_digits INT DEFAULT NULL, + nullable VARCHAR(64) NOT NULL COMMENT 'YES, NO, UNKNOWN', + auto_increment VARCHAR(64) NOT NULL COMMENT 'YES, NO, UNKNOWN', + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX idx_table_document_id (table_document_id), + INDEX idx_database_document_id (database_document_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE table_index_document +( + + id INT PRIMARY KEY AUTO_INCREMENT, + table_document_id INT NOT NULL, + database_document_id INT NOT NULL, + name TEXT NOT NULL, + is_primary BOOLEAN NOT NULL, + is_unique BOOLEAN NOT NULL, + column_name_array JSON NOT NULL, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX idx_table_document_id (table_document_id), + INDEX idx_database_document_id (database_document_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE table_trigger_document +( + + id INT PRIMARY KEY AUTO_INCREMENT, + table_document_id INT NOT NULL, + database_document_id INT NOT NULL, + timing VARCHAR(64) NOT NULL, + manipulation VARCHAR(128) NOT NULL, + statement TEXT NOT NULL, + trigger_create_at VARCHAR(255) NOT NULL, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + INDEX idx_table_document_id (table_document_id), + INDEX idx_database_document_id (database_document_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; + +CREATE TABLE login +( + id INT PRIMARY KEY AUTO_INCREMENT, + user_id INT NOT NULL, + access_token TEXT NOT NULL, + refresh_token TEXT NOT NULL, + access_token_expire_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + refresh_token_expire_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + update_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT UNIQUE uk_user_id (user_id) +) CHARSET utf8mb4 + COLLATE utf8mb4_unicode_ci; \ No newline at end of file diff --git a/plugin/build.gradle b/plugin/build.gradle new file mode 100644 index 0000000..914243b --- /dev/null +++ b/plugin/build.gradle @@ -0,0 +1,5 @@ +dependencies { + testImplementation 'mysql:mysql-connector-java:8.0.27' + implementation 'org.commonmark:commonmark:0.18.1' + implementation 'org.freemarker:freemarker:2.3.31' +} diff --git a/core/src/main/java/com/databasir/core/Databasir.java b/plugin/src/main/java/com/databasir/core/Databasir.java similarity index 98% rename from core/src/main/java/com/databasir/core/Databasir.java rename to plugin/src/main/java/com/databasir/core/Databasir.java index 5d94c68..046c535 100644 --- a/core/src/main/java/com/databasir/core/Databasir.java +++ b/plugin/src/main/java/com/databasir/core/Databasir.java @@ -1,6 +1,6 @@ package com.databasir.core; -import com.databasir.core.meta.pojo.DatabaseMeta; +import com.databasir.core.meta.data.DatabaseMeta; import com.databasir.core.meta.repository.*; import com.databasir.core.meta.repository.condition.Condition; import com.databasir.core.meta.repository.impl.jdbc.*; diff --git a/core/src/main/java/com/databasir/core/DatabasirConfig.java b/plugin/src/main/java/com/databasir/core/DatabasirConfig.java similarity index 100% rename from core/src/main/java/com/databasir/core/DatabasirConfig.java rename to plugin/src/main/java/com/databasir/core/DatabasirConfig.java diff --git a/core/src/main/java/com/databasir/core/meta/pojo/ColumnMeta.java b/plugin/src/main/java/com/databasir/core/meta/data/ColumnMeta.java similarity index 76% rename from core/src/main/java/com/databasir/core/meta/pojo/ColumnMeta.java rename to plugin/src/main/java/com/databasir/core/meta/data/ColumnMeta.java index 0f01c1e..2ee53eb 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/ColumnMeta.java +++ b/plugin/src/main/java/com/databasir/core/meta/data/ColumnMeta.java @@ -1,4 +1,4 @@ -package com.databasir.core.meta.pojo; +package com.databasir.core.meta.data; import lombok.Builder; import lombok.Data; @@ -22,8 +22,8 @@ public class ColumnMeta { private Integer decimalDigits; - private Boolean isNullable; + private String nullable; - private Boolean isAutoIncrement; + private String autoIncrement; } \ No newline at end of file diff --git a/core/src/main/java/com/databasir/core/meta/pojo/DatabaseMeta.java b/plugin/src/main/java/com/databasir/core/meta/data/DatabaseMeta.java similarity index 89% rename from core/src/main/java/com/databasir/core/meta/pojo/DatabaseMeta.java rename to plugin/src/main/java/com/databasir/core/meta/data/DatabaseMeta.java index b43455d..331ea15 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/DatabaseMeta.java +++ b/plugin/src/main/java/com/databasir/core/meta/data/DatabaseMeta.java @@ -1,4 +1,4 @@ -package com.databasir.core.meta.pojo; +package com.databasir.core.meta.data; import lombok.Builder; import lombok.Data; @@ -35,8 +35,6 @@ public class DatabaseMeta { */ private String databaseName; - private String remark; - @Builder.Default private List tables = Collections.emptyList(); diff --git a/core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java b/plugin/src/main/java/com/databasir/core/meta/data/IndexMeta.java similarity index 89% rename from core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java rename to plugin/src/main/java/com/databasir/core/meta/data/IndexMeta.java index 4cc5640..207487b 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/IndexMeta.java +++ b/plugin/src/main/java/com/databasir/core/meta/data/IndexMeta.java @@ -1,4 +1,4 @@ -package com.databasir.core.meta.pojo; +package com.databasir.core.meta.data; import lombok.Builder; import lombok.Data; diff --git a/core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java b/plugin/src/main/java/com/databasir/core/meta/data/TableMeta.java similarity index 93% rename from core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java rename to plugin/src/main/java/com/databasir/core/meta/data/TableMeta.java index 9953bbe..04c3d07 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/TableMeta.java +++ b/plugin/src/main/java/com/databasir/core/meta/data/TableMeta.java @@ -1,4 +1,4 @@ -package com.databasir.core.meta.pojo; +package com.databasir.core.meta.data; import lombok.Builder; import lombok.Data; diff --git a/core/src/main/java/com/databasir/core/meta/pojo/TriggerMeta.java b/plugin/src/main/java/com/databasir/core/meta/data/TriggerMeta.java similarity index 90% rename from core/src/main/java/com/databasir/core/meta/pojo/TriggerMeta.java rename to plugin/src/main/java/com/databasir/core/meta/data/TriggerMeta.java index a67061f..1b9291f 100644 --- a/core/src/main/java/com/databasir/core/meta/pojo/TriggerMeta.java +++ b/plugin/src/main/java/com/databasir/core/meta/data/TriggerMeta.java @@ -1,4 +1,4 @@ -package com.databasir.core.meta.pojo; +package com.databasir.core.meta.data; import lombok.Builder; import lombok.Data; diff --git a/core/src/main/java/com/databasir/core/meta/provider/SqlProvider.java b/plugin/src/main/java/com/databasir/core/meta/provider/SqlProvider.java similarity index 100% rename from core/src/main/java/com/databasir/core/meta/provider/SqlProvider.java rename to plugin/src/main/java/com/databasir/core/meta/provider/SqlProvider.java diff --git a/core/src/main/java/com/databasir/core/meta/repository/ColumnMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/ColumnMetaRepository.java similarity index 86% rename from core/src/main/java/com/databasir/core/meta/repository/ColumnMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/ColumnMetaRepository.java index b907998..fbf3829 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/ColumnMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/ColumnMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository; -import com.databasir.core.meta.pojo.ColumnMeta; +import com.databasir.core.meta.data.ColumnMeta; import com.databasir.core.meta.repository.condition.TableCondition; import java.sql.Connection; diff --git a/core/src/main/java/com/databasir/core/meta/repository/DatabaseMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/DatabaseMetaRepository.java similarity index 85% rename from core/src/main/java/com/databasir/core/meta/repository/DatabaseMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/DatabaseMetaRepository.java index 962786d..b027c06 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/DatabaseMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/DatabaseMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository; -import com.databasir.core.meta.pojo.DatabaseMeta; +import com.databasir.core.meta.data.DatabaseMeta; import com.databasir.core.meta.repository.condition.Condition; import java.sql.Connection; diff --git a/core/src/main/java/com/databasir/core/meta/repository/IndexMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/IndexMetaRepository.java similarity index 86% rename from core/src/main/java/com/databasir/core/meta/repository/IndexMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/IndexMetaRepository.java index 72a9e24..f62ca3b 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/IndexMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/IndexMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository; -import com.databasir.core.meta.pojo.IndexMeta; +import com.databasir.core.meta.data.IndexMeta; import com.databasir.core.meta.repository.condition.TableCondition; import java.sql.Connection; diff --git a/core/src/main/java/com/databasir/core/meta/repository/TableMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/TableMetaRepository.java similarity index 85% rename from core/src/main/java/com/databasir/core/meta/repository/TableMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/TableMetaRepository.java index e52f54e..e651272 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/TableMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/TableMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository; -import com.databasir.core.meta.pojo.TableMeta; +import com.databasir.core.meta.data.TableMeta; import com.databasir.core.meta.repository.condition.Condition; import java.sql.Connection; diff --git a/core/src/main/java/com/databasir/core/meta/repository/TriggerMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/TriggerMetaRepository.java similarity index 85% rename from core/src/main/java/com/databasir/core/meta/repository/TriggerMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/TriggerMetaRepository.java index b14c054..f7acaf0 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/TriggerMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/TriggerMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository; -import com.databasir.core.meta.pojo.TriggerMeta; +import com.databasir.core.meta.data.TriggerMeta; import com.databasir.core.meta.repository.condition.TableCondition; import java.sql.Connection; diff --git a/core/src/main/java/com/databasir/core/meta/repository/condition/Condition.java b/plugin/src/main/java/com/databasir/core/meta/repository/condition/Condition.java similarity index 100% rename from core/src/main/java/com/databasir/core/meta/repository/condition/Condition.java rename to plugin/src/main/java/com/databasir/core/meta/repository/condition/Condition.java diff --git a/core/src/main/java/com/databasir/core/meta/repository/condition/TableCondition.java b/plugin/src/main/java/com/databasir/core/meta/repository/condition/TableCondition.java similarity index 100% rename from core/src/main/java/com/databasir/core/meta/repository/condition/TableCondition.java rename to plugin/src/main/java/com/databasir/core/meta/repository/condition/TableCondition.java diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/extension/MysqlTableTriggerMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/extension/MysqlTableTriggerMetaRepository.java similarity index 98% rename from core/src/main/java/com/databasir/core/meta/repository/impl/extension/MysqlTableTriggerMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/impl/extension/MysqlTableTriggerMetaRepository.java index 7c3a764..6abd039 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/extension/MysqlTableTriggerMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/extension/MysqlTableTriggerMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository.impl.extension; -import com.databasir.core.meta.pojo.TriggerMeta; +import com.databasir.core.meta.data.TriggerMeta; import com.databasir.core.meta.repository.TriggerMetaRepository; import com.databasir.core.meta.repository.condition.TableCondition; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java similarity index 76% rename from core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java index 6f4aab4..fde8ad6 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository.impl.jdbc; -import com.databasir.core.meta.pojo.ColumnMeta; +import com.databasir.core.meta.data.ColumnMeta; import com.databasir.core.meta.repository.ColumnMetaRepository; import com.databasir.core.meta.repository.condition.TableCondition; import lombok.RequiredArgsConstructor; @@ -11,7 +11,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import java.util.Objects; @Slf4j @RequiredArgsConstructor @@ -46,10 +45,21 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository { } else { String columnType = columnsResult.getString("TYPE_NAME"); Integer columnSize = columnsResult.getInt("COLUMN_SIZE"); - Integer decimalDigits = columnsResult.getInt("DECIMAL_DIGITS"); + Integer decimalDigits; + if (columnsResult.getObject("DECIMAL_DIGITS") == null) { + decimalDigits = null; + } else { + decimalDigits = columnsResult.getInt("DECIMAL_DIGITS"); + } String defaultValue = columnsResult.getString("COLUMN_DEF"); - boolean isNullable = Objects.equals("YES", columnsResult.getString("IS_NULLABLE")); - boolean isAutoIncrement = Objects.equals("YES", columnsResult.getString("IS_AUTOINCREMENT")); + String isNullable = columnsResult.getString("IS_NULLABLE"); + if (isNullable.trim().equals("")) { + isNullable = "UNKNOWN"; + } + String isAutoIncrement = columnsResult.getString("IS_AUTOINCREMENT"); + if (isAutoIncrement.trim().equals("")) { + isAutoIncrement = "UNKNOWN"; + } String columnComment = columnsResult.getString("REMARKS"); if (defaultValue != null && defaultValue.trim().equals("")) { defaultValue = "'" + defaultValue + "'"; @@ -59,8 +69,8 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository { .type(columnType) .size(columnSize) .decimalDigits(decimalDigits) - .isNullable(isNullable) - .isAutoIncrement(isAutoIncrement) + .nullable(isNullable) + .autoIncrement(isAutoIncrement) .comment(columnComment) .defaultValue(defaultValue) .build(); diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java similarity index 94% rename from core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java index 54fb713..dfe20e4 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcDatabaseMetaRepository.java @@ -1,7 +1,7 @@ package com.databasir.core.meta.repository.impl.jdbc; -import com.databasir.core.meta.pojo.DatabaseMeta; -import com.databasir.core.meta.pojo.TableMeta; +import com.databasir.core.meta.data.DatabaseMeta; +import com.databasir.core.meta.data.TableMeta; import com.databasir.core.meta.repository.DatabaseMetaRepository; import com.databasir.core.meta.repository.TableMetaRepository; import com.databasir.core.meta.repository.condition.Condition; diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java similarity index 98% rename from core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java index 130e9eb..b2ebc38 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcIndexMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository.impl.jdbc; -import com.databasir.core.meta.pojo.IndexMeta; +import com.databasir.core.meta.data.IndexMeta; import com.databasir.core.meta.repository.IndexMetaRepository; import com.databasir.core.meta.repository.condition.TableCondition; import lombok.extern.slf4j.Slf4j; diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java similarity index 79% rename from core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java index 1e6904b..8c107ab 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTableMetaRepository.java @@ -1,6 +1,7 @@ package com.databasir.core.meta.repository.impl.jdbc; -import com.databasir.core.meta.pojo.TableMeta; +import com.databasir.core.meta.data.ColumnMeta; +import com.databasir.core.meta.data.TableMeta; import com.databasir.core.meta.repository.ColumnMetaRepository; import com.databasir.core.meta.repository.IndexMetaRepository; import com.databasir.core.meta.repository.TableMetaRepository; @@ -38,7 +39,8 @@ public class JdbcTableMetaRepository implements TableMetaRepository { private List doSelect(Connection connection, Condition condition) throws SQLException { List tableMetas = new ArrayList<>(); String databaseName = condition.getDatabaseName(); - ResultSet tablesResult = connection.getMetaData().getTables(databaseName, null, null, null); + ResultSet tablesResult = connection.getMetaData() + .getTables(databaseName, null, null, new String[]{"TABLE"}); while (tablesResult.next()) { String tableName = tablesResult.getString("TABLE_NAME"); if (condition.tableIsIgnored(tableName)) { @@ -49,11 +51,18 @@ public class JdbcTableMetaRepository implements TableMetaRepository { String tableType = tablesResult.getString("TABLE_TYPE"); String tableComment = tablesResult.getString("REMARKS"); TableCondition tableCondition = TableCondition.of(condition, tableName); + List columns = columnMetaRepository.selectColumns(connection, tableCondition); + if (columns.isEmpty()) { + if (log.isWarnEnabled()) { + log.warn("ignored table: " + databaseName + "." + tableName + ", caused by get empty columns"); + } + continue; + } TableMeta tableMeta = TableMeta.builder() .name(tableName) .type(tableType) .comment(tableComment) - .columns(columnMetaRepository.selectColumns(connection, tableCondition)) + .columns(columns) .indexes(indexMetaRepository.selectIndexes(connection, tableCondition)) .triggers(triggerMetaRepository.selectTriggers(connection, tableCondition)) .build(); diff --git a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTriggerMetaRepository.java b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTriggerMetaRepository.java similarity index 91% rename from core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTriggerMetaRepository.java rename to plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTriggerMetaRepository.java index 982e8bd..8aa2e2a 100644 --- a/core/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTriggerMetaRepository.java +++ b/plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcTriggerMetaRepository.java @@ -1,6 +1,6 @@ package com.databasir.core.meta.repository.impl.jdbc; -import com.databasir.core.meta.pojo.TriggerMeta; +import com.databasir.core.meta.data.TriggerMeta; import com.databasir.core.meta.repository.TriggerMetaRepository; import com.databasir.core.meta.repository.condition.TableCondition; diff --git a/core/src/main/java/com/databasir/core/render/Render.java b/plugin/src/main/java/com/databasir/core/render/Render.java similarity index 88% rename from core/src/main/java/com/databasir/core/render/Render.java rename to plugin/src/main/java/com/databasir/core/render/Render.java index 07a661f..53d287a 100644 --- a/core/src/main/java/com/databasir/core/render/Render.java +++ b/plugin/src/main/java/com/databasir/core/render/Render.java @@ -1,6 +1,6 @@ package com.databasir.core.render; -import com.databasir.core.meta.pojo.DatabaseMeta; +import com.databasir.core.meta.data.DatabaseMeta; import com.databasir.core.render.markdown.MarkdownTemplateRender; import java.io.IOException; diff --git a/core/src/main/java/com/databasir/core/render/RenderConfig.java b/plugin/src/main/java/com/databasir/core/render/RenderConfig.java similarity index 77% rename from core/src/main/java/com/databasir/core/render/RenderConfig.java rename to plugin/src/main/java/com/databasir/core/render/RenderConfig.java index bbe84e0..4b614f3 100644 --- a/core/src/main/java/com/databasir/core/render/RenderConfig.java +++ b/plugin/src/main/java/com/databasir/core/render/RenderConfig.java @@ -1,8 +1,8 @@ package com.databasir.core.render; -import com.databasir.core.meta.pojo.ColumnMeta; -import com.databasir.core.meta.pojo.IndexMeta; -import com.databasir.core.meta.pojo.TriggerMeta; +import com.databasir.core.meta.data.ColumnMeta; +import com.databasir.core.meta.data.IndexMeta; +import com.databasir.core.meta.data.TriggerMeta; import lombok.Data; import java.util.LinkedHashMap; @@ -39,18 +39,18 @@ public class RenderConfig { } return type; }); - mapping.put("Not Null", column -> column.getIsNullable() ? "" : "YES"); - mapping.put("Auto Increment", column -> column.getIsAutoIncrement() ? "YES" : ""); - mapping.put("Default", column -> { - if (column.getDefaultValue() == null) { - return ""; - } - if (column.getDefaultValue().trim().equals("")) { - return "'" + column.getDefaultValue() + "'"; - } - return column.getDefaultValue(); - }); - mapping.put("Comment", ColumnMeta::getComment); +// mapping.put("Not Null", column -> column.getIsNullable() ? "" : "YES"); +// mapping.put("Auto Increment", column -> column.getIsAutoIncrement() ? "YES" : ""); +// mapping.put("Default", column -> { +// if (column.getDefaultValue() == null) { +// return ""; +// } +// if (column.getDefaultValue().trim().equals("")) { +// return "'" + column.getDefaultValue() + "'"; +// } +// return column.getDefaultValue(); +// }); +// mapping.put("Comment", ColumnMeta::getComment); return mapping; } diff --git a/core/src/main/java/com/databasir/core/render/pdf/.gitkeep b/plugin/src/main/java/com/databasir/core/render/html/.gitkeep similarity index 100% rename from core/src/main/java/com/databasir/core/render/pdf/.gitkeep rename to plugin/src/main/java/com/databasir/core/render/html/.gitkeep diff --git a/core/src/main/java/com/databasir/core/render/markdown/MarkdownBuilder.java b/plugin/src/main/java/com/databasir/core/render/markdown/MarkdownBuilder.java similarity index 100% rename from core/src/main/java/com/databasir/core/render/markdown/MarkdownBuilder.java rename to plugin/src/main/java/com/databasir/core/render/markdown/MarkdownBuilder.java diff --git a/core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java b/plugin/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java similarity index 97% rename from core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java rename to plugin/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java index 1e73cdf..7e90dda 100644 --- a/core/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java +++ b/plugin/src/main/java/com/databasir/core/render/markdown/MarkdownRender.java @@ -1,7 +1,7 @@ package com.databasir.core.render.markdown; -import com.databasir.core.meta.pojo.DatabaseMeta; -import com.databasir.core.meta.pojo.TableMeta; +import com.databasir.core.meta.data.DatabaseMeta; +import com.databasir.core.meta.data.TableMeta; import com.databasir.core.render.Render; import com.databasir.core.render.RenderConfig; import lombok.Getter; diff --git a/core/src/main/java/com/databasir/core/render/markdown/MarkdownTemplateRender.java b/plugin/src/main/java/com/databasir/core/render/markdown/MarkdownTemplateRender.java similarity index 97% rename from core/src/main/java/com/databasir/core/render/markdown/MarkdownTemplateRender.java rename to plugin/src/main/java/com/databasir/core/render/markdown/MarkdownTemplateRender.java index 826a9d5..fcf7711 100644 --- a/core/src/main/java/com/databasir/core/render/markdown/MarkdownTemplateRender.java +++ b/plugin/src/main/java/com/databasir/core/render/markdown/MarkdownTemplateRender.java @@ -1,6 +1,6 @@ package com.databasir.core.render.markdown; -import com.databasir.core.meta.pojo.DatabaseMeta; +import com.databasir.core.meta.data.DatabaseMeta; import com.databasir.core.render.Render; import com.databasir.core.render.RenderConfig; import freemarker.template.Configuration; diff --git a/plugin/src/main/java/com/databasir/core/render/pdf/.gitkeep b/plugin/src/main/java/com/databasir/core/render/pdf/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/core/src/main/resources/template/render/markdown/markdown.ftlh b/plugin/src/main/resources/template/render/markdown/markdown.ftlh similarity index 100% rename from core/src/main/resources/template/render/markdown/markdown.ftlh rename to plugin/src/main/resources/template/render/markdown/markdown.ftlh diff --git a/core/src/test/java/App.java b/plugin/src/test/java/App.java similarity index 96% rename from core/src/test/java/App.java rename to plugin/src/test/java/App.java index 4515334..b81d09f 100644 --- a/core/src/test/java/App.java +++ b/plugin/src/test/java/App.java @@ -1,5 +1,5 @@ import com.databasir.core.Databasir; -import com.databasir.core.meta.pojo.DatabaseMeta; +import com.databasir.core.meta.data.DatabaseMeta; import org.junit.jupiter.api.Test; import java.io.FileOutputStream; diff --git a/settings.gradle b/settings.gradle index 230e893..a0ebaba 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,15 @@ +pluginManagement { + repositories { + maven { url 'https://repo.spring.io/milestone' } + maven { url 'https://repo.spring.io/snapshot' } + gradlePluginPortal() + } +} + rootProject.name = 'databasir' +include 'plugin' +include 'api' +include 'common' +include 'dao' include 'core'