change remark to discussion model & bug fix (#45)
* feat: change remark to discussion * feat: change remark model to discussion model * fix: sync duplicate column * feat:update frontend resources * fix: checkstyle
This commit is contained in:
parent
f026d406a2
commit
e85e0e6e70
|
@ -3,10 +3,10 @@ package com.databasir.api;
|
|||
import com.databasir.api.config.security.DatabasirUserDetails;
|
||||
import com.databasir.common.JsonData;
|
||||
import com.databasir.core.domain.log.annotation.Operation;
|
||||
import com.databasir.core.domain.remark.data.RemarkCreateRequest;
|
||||
import com.databasir.core.domain.remark.data.RemarkListCondition;
|
||||
import com.databasir.core.domain.remark.data.RemarkResponse;
|
||||
import com.databasir.core.domain.remark.service.DocumentRemarkService;
|
||||
import com.databasir.core.domain.remark.data.DiscussionCreateRequest;
|
||||
import com.databasir.core.domain.remark.data.DiscussionListCondition;
|
||||
import com.databasir.core.domain.remark.data.DiscussionResponse;
|
||||
import com.databasir.core.domain.remark.service.DocumentDiscussionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -22,46 +22,46 @@ import javax.validation.Valid;
|
|||
@RestController
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class DocumentRemarkController {
|
||||
public class DocumentDiscussionController {
|
||||
|
||||
private final DocumentRemarkService documentRemarkService;
|
||||
private final DocumentDiscussionService documentDiscussionService;
|
||||
|
||||
@GetMapping(Routes.DocumentRemark.LIST)
|
||||
public JsonData<Page<RemarkResponse>> listByProjectId(@PathVariable Integer groupId,
|
||||
@GetMapping(Routes.DocumentDiscussion.LIST)
|
||||
public JsonData<Page<DiscussionResponse>> listByProjectId(@PathVariable Integer groupId,
|
||||
@PathVariable Integer projectId,
|
||||
@PageableDefault(sort = "id",
|
||||
direction = Sort.Direction.DESC)
|
||||
Pageable request,
|
||||
RemarkListCondition condition) {
|
||||
var data = documentRemarkService.list(groupId, projectId, request, condition);
|
||||
DiscussionListCondition condition) {
|
||||
var data = documentDiscussionService.list(groupId, projectId, request, condition);
|
||||
return JsonData.ok(data);
|
||||
}
|
||||
|
||||
@DeleteMapping(Routes.DocumentRemark.DELETE)
|
||||
@DeleteMapping(Routes.DocumentDiscussion.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER?groupId='+#groupId)")
|
||||
@Operation(module = Operation.Modules.PROJECT,
|
||||
name = "删除评论",
|
||||
involvedProjectId = "#projectId")
|
||||
public JsonData<Void> delete(@PathVariable Integer groupId,
|
||||
@PathVariable Integer projectId,
|
||||
@PathVariable Integer remarkId) {
|
||||
documentRemarkService.deleteById(groupId, projectId, remarkId);
|
||||
@PathVariable Integer discussionId) {
|
||||
documentDiscussionService.deleteById(groupId, projectId, discussionId);
|
||||
return JsonData.ok();
|
||||
}
|
||||
|
||||
@PostMapping(Routes.DocumentRemark.CREATE)
|
||||
@PostMapping(Routes.DocumentDiscussion.CREATE)
|
||||
@PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER?groupId='+#groupId, 'GROUP_MEMBER?groupId='+#groupId)")
|
||||
@Operation(module = Operation.Modules.PROJECT,
|
||||
name = "新增评论",
|
||||
involvedProjectId = "#projectId")
|
||||
public JsonData<Void> create(@PathVariable Integer groupId,
|
||||
@PathVariable Integer projectId,
|
||||
@RequestBody @Valid RemarkCreateRequest request) {
|
||||
@RequestBody @Valid DiscussionCreateRequest request) {
|
||||
DatabasirUserDetails principal = (DatabasirUserDetails) SecurityContextHolder.getContext()
|
||||
.getAuthentication()
|
||||
.getPrincipal();
|
||||
Integer userId = principal.getUserPojo().getId();
|
||||
documentRemarkService.create(groupId, projectId, userId, request);
|
||||
documentDiscussionService.create(groupId, projectId, userId, request);
|
||||
return JsonData.ok();
|
||||
}
|
||||
}
|
|
@ -85,13 +85,15 @@ public interface Routes {
|
|||
String EXPORT = BASE + "/projects/{projectId}/document_files";
|
||||
}
|
||||
|
||||
interface DocumentRemark {
|
||||
interface DocumentDiscussion {
|
||||
|
||||
String LIST = BASE + "/groups/{groupId}/projects/{projectId}/remarks";
|
||||
String DISCUSSION_BASE = BASE + "/groups/{groupId}/projects/{projectId}/discussions";
|
||||
|
||||
String CREATE = BASE + "/groups/{groupId}/projects/{projectId}/remarks";
|
||||
String LIST = DISCUSSION_BASE;
|
||||
|
||||
String DELETE = BASE + "/groups/{groupId}/projects/{projectId}/remarks/{remarkId}";
|
||||
String CREATE = DISCUSSION_BASE;
|
||||
|
||||
String DELETE = DISCUSSION_BASE + "/{discussionId}";
|
||||
}
|
||||
|
||||
interface Setting {
|
||||
|
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><script defer="defer" type="module" src="/js/chunk-vendors.45746587.js"></script><script defer="defer" type="module" src="/js/app.a4b9bb20.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.54c3660b.js" nomodule></script><script defer="defer" src="/js/app-legacy.2527a373.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><script defer="defer" type="module" src="/js/chunk-vendors.45746587.js"></script><script defer="defer" type="module" src="/js/app.6aec33ce.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.54c3660b.js" nomodule></script><script defer="defer" src="/js/app-legacy.b19c33c1.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -6,10 +6,14 @@ import com.databasir.core.domain.database.data.DatabaseTypePageResponse;
|
|||
import com.databasir.core.domain.database.data.DatabaseTypeUpdateRequest;
|
||||
import com.databasir.dao.tables.pojos.DatabaseTypePojo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface DatabaseTypePojoConverter {
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "updateAt", ignore = true)
|
||||
@Mapping(target = "createAt", ignore = true)
|
||||
DatabaseTypePojo of(DatabaseTypeCreateRequest request);
|
||||
|
||||
DatabaseTypePojo of(DatabaseTypeUpdateRequest request);
|
||||
|
|
|
@ -8,6 +8,8 @@ import org.mapstruct.Mapping;
|
|||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = JsonConverter.class, unmappedTargetPolicy = ReportingPolicy.WARN)
|
||||
public interface DocumentResponseConverter {
|
||||
|
@ -20,6 +22,31 @@ public interface DocumentResponseConverter {
|
|||
List<TableIndexDocumentPojo> indexes,
|
||||
List<TableTriggerDocumentPojo> triggers);
|
||||
|
||||
@Mapping(target = "columns", source = "columns")
|
||||
@Mapping(target = "indexes", source = "indexes")
|
||||
@Mapping(target = "triggers", source = "triggers")
|
||||
@SuppressWarnings("checkstyle:all")
|
||||
DatabaseDocumentResponse.TableDocumentResponse of(TableDocumentPojo tableDocument,
|
||||
Integer discussionCount,
|
||||
List<DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse> columns,
|
||||
List<TableIndexDocumentPojo> indexes,
|
||||
List<TableTriggerDocumentPojo> triggers);
|
||||
|
||||
DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse of(TableColumnDocumentPojo pojo,
|
||||
Integer discussionCount);
|
||||
|
||||
default List<DatabaseDocumentResponse.TableDocumentResponse.ColumnDocumentResponse> of(
|
||||
List<TableColumnDocumentPojo> columns,
|
||||
String tableName,
|
||||
Map<String, Integer> discussionCountMapByJoinName) {
|
||||
return columns.stream()
|
||||
.map(column -> {
|
||||
Integer count = discussionCountMapByJoinName.get(tableName + "." + column.getName());
|
||||
return of(column, count);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Mapping(target = "columnNames", source = "columnNameArray")
|
||||
DatabaseDocumentResponse.TableDocumentResponse.IndexDocumentResponse of(TableIndexDocumentPojo indexDocument);
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.mapstruct.Mapping;
|
|||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = JsonConverter.class, unmappedTargetPolicy = ReportingPolicy.WARN)
|
||||
public interface DocumentSimpleResponseConverter {
|
||||
|
@ -17,5 +19,17 @@ public interface DocumentSimpleResponseConverter {
|
|||
@Mapping(target = "createAt", source = "databaseDocument.createAt")
|
||||
@Mapping(target = "documentVersion", source = "databaseDocument.version")
|
||||
DatabaseDocumentSimpleResponse of(DatabaseDocumentPojo databaseDocument,
|
||||
List<TableDocumentPojo> tables);
|
||||
List<DatabaseDocumentSimpleResponse.TableData> tables);
|
||||
|
||||
DatabaseDocumentSimpleResponse.TableData of(TableDocumentPojo tables, Integer discussionCount);
|
||||
|
||||
default List<DatabaseDocumentSimpleResponse.TableData> of(List<TableDocumentPojo> tables,
|
||||
Map<String, Integer> discussionCountMapByTableName) {
|
||||
return tables.stream()
|
||||
.map(table -> {
|
||||
Integer count = discussionCountMapByTableName.get(table.getName());
|
||||
return of(table, count);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ public class DatabaseDocumentResponse {
|
|||
|
||||
private String comment;
|
||||
|
||||
private Integer discussionCount;
|
||||
|
||||
@Builder.Default
|
||||
private List<ColumnDocumentResponse> columns = new ArrayList<>();
|
||||
|
||||
|
@ -82,6 +84,8 @@ public class DatabaseDocumentResponse {
|
|||
|
||||
private String defaultValue;
|
||||
|
||||
private Integer discussionCount;
|
||||
|
||||
private LocalDateTime createAt;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,5 +35,7 @@ public class DatabaseDocumentSimpleResponse {
|
|||
private String type;
|
||||
|
||||
private String comment;
|
||||
|
||||
private Integer discussionCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,10 @@ import com.databasir.core.meta.data.DatabaseMeta;
|
|||
import com.databasir.core.render.markdown.MarkdownBuilder;
|
||||
import com.databasir.dao.impl.*;
|
||||
import com.databasir.dao.tables.pojos.*;
|
||||
import com.databasir.dao.value.DocumentDiscussionCountPojo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jooq.tools.StringUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -55,6 +57,8 @@ public class DocumentService {
|
|||
|
||||
private final TableTriggerDocumentDao tableTriggerDocumentDao;
|
||||
|
||||
private final DocumentDiscussionDao documentDiscussionDao;
|
||||
|
||||
private final DocumentPojoConverter documentPojoConverter;
|
||||
|
||||
private final DocumentResponseConverter documentResponseConverter;
|
||||
|
@ -129,22 +133,23 @@ public class DocumentService {
|
|||
}
|
||||
|
||||
public Optional<DatabaseDocumentSimpleResponse> getSimpleOneByProjectId(Integer projectId, Long version) {
|
||||
Optional<DatabaseDocumentPojo> documentOption;
|
||||
if (version == null) {
|
||||
return databaseDocumentDao.selectNotArchivedByProjectId(projectId)
|
||||
.map(document -> {
|
||||
Integer id = document.getId();
|
||||
var tables = tableDocumentDao.selectByDatabaseDocumentId(id);
|
||||
return documentSimpleResponseConverter.of(document, tables);
|
||||
});
|
||||
documentOption = databaseDocumentDao.selectNotArchivedByProjectId(projectId);
|
||||
} else {
|
||||
return databaseDocumentDao.selectOptionalByProjectIdAndVersion(projectId, version)
|
||||
.map(document -> {
|
||||
documentOption = databaseDocumentDao.selectOptionalByProjectIdAndVersion(projectId, version);
|
||||
}
|
||||
return documentOption.map(document -> {
|
||||
Integer id = document.getId();
|
||||
var tables = tableDocumentDao.selectByDatabaseDocumentId(id);
|
||||
return documentSimpleResponseConverter.of(document, tables);
|
||||
var discussionCountMapByTableName =
|
||||
documentDiscussionDao.selectTableDiscussionCount(projectId)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(d -> d.getTableName(), d -> d.getCount(), (a, b) -> a));
|
||||
var tableMetas = documentSimpleResponseConverter.of(tables, discussionCountMapByTableName);
|
||||
return documentSimpleResponseConverter.of(document, tableMetas);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<DatabaseDocumentResponse> getOneByProjectId(Integer projectId, Long version) {
|
||||
|
||||
|
@ -207,19 +212,31 @@ public class DocumentService {
|
|||
tableIndexDocumentDao.selectByDatabaseDocumentIdAndIdIn(databaseDocumentId, tableIds);
|
||||
var triggers =
|
||||
tableTriggerDocumentDao.selectByDatabaseDocumentIdAndIdIn(databaseDocumentId, tableIds);
|
||||
var discussions = documentDiscussionDao.selectAllDiscussionCount(projectId);
|
||||
Map<Integer, List<TableColumnDocumentPojo>> columnsGroupByTableMetaId = columns.stream()
|
||||
.collect(Collectors.groupingBy(TableColumnDocumentPojo::getTableDocumentId));
|
||||
Map<Integer, List<TableIndexDocumentPojo>> indexesGroupByTableMetaId = indexes.stream()
|
||||
.collect(Collectors.groupingBy(TableIndexDocumentPojo::getTableDocumentId));
|
||||
Map<Integer, List<TableTriggerDocumentPojo>> triggersGroupByTableMetaId = triggers.stream()
|
||||
.collect(Collectors.groupingBy(TableTriggerDocumentPojo::getTableDocumentId));
|
||||
Map<String, Integer> discussionCountMapByJoinName = discussions.stream()
|
||||
.collect(Collectors.toMap(
|
||||
d -> String.join(".",
|
||||
d.getTableName(),
|
||||
StringUtils.defaultIfBlank(d.getColumnName(), "")),
|
||||
DocumentDiscussionCountPojo::getCount,
|
||||
(a, b) -> a));
|
||||
return tables.stream()
|
||||
.map(table -> {
|
||||
Integer tableId = table.getId();
|
||||
var subColumns = columnsGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
|
||||
var subIndexes = indexesGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
|
||||
var subTriggers = triggersGroupByTableMetaId.getOrDefault(tableId, Collections.emptyList());
|
||||
return documentResponseConverter.of(table, subColumns, subIndexes, subTriggers);
|
||||
var discussionCount = discussionCountMapByJoinName.get(table.getName());
|
||||
var columnResponses =
|
||||
documentResponseConverter.of(subColumns, table.getName(), discussionCountMapByJoinName);
|
||||
return documentResponseConverter.of(table, discussionCount, columnResponses, subIndexes,
|
||||
subTriggers);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.databasir.core.domain.remark.converter;
|
||||
|
||||
import com.databasir.core.domain.remark.data.DiscussionResponse;
|
||||
import com.databasir.dao.tables.pojos.DocumentDiscussionPojo;
|
||||
import com.databasir.dao.tables.pojos.UserPojo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface DiscussionResponseConverter {
|
||||
|
||||
@Mapping(target = "id", source = "discussion.id")
|
||||
@Mapping(target = "createAt", source = "discussion.createAt")
|
||||
@Mapping(target = "content", source = "discussion.content")
|
||||
DiscussionResponse of(DocumentDiscussionPojo discussion,
|
||||
UserPojo discussBy);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.databasir.core.domain.remark.converter;
|
||||
|
||||
import com.databasir.core.domain.remark.data.RemarkResponse;
|
||||
import com.databasir.dao.tables.pojos.DocumentRemarkPojo;
|
||||
import com.databasir.dao.tables.pojos.UserPojo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface RemarkResponseConverter {
|
||||
|
||||
@Mapping(target = "remarkBy.userId", source = "remarkBy.id")
|
||||
@Mapping(target = "remarkBy.nickname", source = "remarkBy.nickname")
|
||||
@Mapping(target = "remarkBy.email", source = "remarkBy.email")
|
||||
@Mapping(target = "id", source = "remark.id")
|
||||
@Mapping(target = "createAt", source = "remark.createAt")
|
||||
RemarkResponse of(DocumentRemarkPojo remark,
|
||||
UserPojo remarkBy);
|
||||
}
|
|
@ -6,10 +6,10 @@ import javax.validation.constraints.NotBlank;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class RemarkCreateRequest {
|
||||
public class DiscussionCreateRequest {
|
||||
|
||||
@NotBlank
|
||||
private String remark;
|
||||
private String content;
|
||||
|
||||
@NotNull
|
||||
private String tableName;
|
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RemarkListCondition {
|
||||
public class DiscussionListCondition {
|
||||
|
||||
@NotBlank
|
||||
private String tableName;
|
||||
|
@ -19,17 +19,17 @@ public class RemarkListCondition {
|
|||
|
||||
public Condition toCondition(Integer projectId) {
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
Condition condition = Tables.DOCUMENT_REMARK.TABLE_NAME.eq(tableName);
|
||||
Condition condition = Tables.DOCUMENT_DISCUSSION.TABLE_NAME.eq(tableName);
|
||||
conditions.add(condition);
|
||||
|
||||
Condition columnCondition;
|
||||
if (columnName != null) {
|
||||
columnCondition = Tables.DOCUMENT_REMARK.COLUMN_NAME.eq(columnName);
|
||||
columnCondition = Tables.DOCUMENT_DISCUSSION.COLUMN_NAME.eq(columnName);
|
||||
} else {
|
||||
columnCondition = Tables.DOCUMENT_REMARK.COLUMN_NAME.isNull();
|
||||
columnCondition = Tables.DOCUMENT_DISCUSSION.COLUMN_NAME.isNull();
|
||||
}
|
||||
conditions.add(columnCondition);
|
||||
conditions.add(Tables.DOCUMENT_REMARK.PROJECT_ID.eq(projectId));
|
||||
conditions.add(Tables.DOCUMENT_DISCUSSION.PROJECT_ID.eq(projectId));
|
||||
return conditions.stream().reduce(Condition::and).orElse(DSL.trueCondition());
|
||||
}
|
||||
}
|
|
@ -5,20 +5,20 @@ import lombok.Data;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RemarkResponse {
|
||||
public class DiscussionResponse {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer projectId;
|
||||
|
||||
private String remark;
|
||||
private String content;
|
||||
|
||||
private RemarkUser remarkBy;
|
||||
private DiscussByUser discussBy;
|
||||
|
||||
private LocalDateTime createAt;
|
||||
|
||||
@Data
|
||||
public static class RemarkUser {
|
||||
public static class DiscussByUser {
|
||||
|
||||
private Integer userId;
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package com.databasir.core.domain.remark.service;
|
||||
|
||||
import com.databasir.common.exception.Forbidden;
|
||||
import com.databasir.core.domain.remark.converter.RemarkResponseConverter;
|
||||
import com.databasir.core.domain.remark.data.RemarkCreateRequest;
|
||||
import com.databasir.core.domain.remark.data.RemarkListCondition;
|
||||
import com.databasir.core.domain.remark.data.RemarkResponse;
|
||||
import com.databasir.dao.impl.DocumentRemarkDao;
|
||||
import com.databasir.core.domain.remark.converter.DiscussionResponseConverter;
|
||||
import com.databasir.core.domain.remark.data.DiscussionCreateRequest;
|
||||
import com.databasir.core.domain.remark.data.DiscussionListCondition;
|
||||
import com.databasir.core.domain.remark.data.DiscussionResponse;
|
||||
import com.databasir.dao.impl.DocumentDiscussionDao;
|
||||
import com.databasir.dao.impl.ProjectDao;
|
||||
import com.databasir.dao.impl.UserDao;
|
||||
import com.databasir.dao.tables.pojos.DocumentRemarkPojo;
|
||||
import com.databasir.dao.tables.pojos.DocumentDiscussionPojo;
|
||||
import com.databasir.dao.tables.pojos.UserPojo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
@ -22,58 +22,59 @@ import java.util.stream.Collectors;
|
|||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DocumentRemarkService {
|
||||
public class DocumentDiscussionService {
|
||||
|
||||
private final DocumentRemarkDao documentRemarkDao;
|
||||
private final DocumentDiscussionDao documentDiscussionDao;
|
||||
|
||||
private final ProjectDao projectDao;
|
||||
|
||||
private final UserDao userDao;
|
||||
|
||||
private final RemarkResponseConverter remarkResponseConverter;
|
||||
private final DiscussionResponseConverter discussionResponseConverter;
|
||||
|
||||
public void deleteById(Integer groupId,
|
||||
Integer projectId,
|
||||
Integer remarkId) {
|
||||
Integer discussionId) {
|
||||
if (projectDao.exists(groupId, projectId)) {
|
||||
documentRemarkDao.deleteById(remarkId);
|
||||
documentDiscussionDao.deleteById(discussionId);
|
||||
} else {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public Page<RemarkResponse> list(Integer groupId,
|
||||
public Page<DiscussionResponse> list(Integer groupId,
|
||||
Integer projectId,
|
||||
Pageable pageable,
|
||||
RemarkListCondition condition) {
|
||||
DiscussionListCondition condition) {
|
||||
if (projectDao.exists(groupId, projectId)) {
|
||||
Page<DocumentRemarkPojo> data = documentRemarkDao.selectByPage(pageable, condition.toCondition(projectId));
|
||||
Page<DocumentDiscussionPojo> data =
|
||||
documentDiscussionDao.selectByPage(pageable, condition.toCondition(projectId));
|
||||
Set<Integer> userIdList = data.getContent()
|
||||
.stream()
|
||||
.map(DocumentRemarkPojo::getUserId)
|
||||
.map(DocumentDiscussionPojo::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
Map<Integer, UserPojo> userMapById = userDao.selectUserIdIn(userIdList)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(UserPojo::getId, Function.identity()));
|
||||
return data
|
||||
.map(remarkPojo -> {
|
||||
UserPojo userPojo = userMapById.get(remarkPojo.getUserId());
|
||||
return remarkResponseConverter.of(remarkPojo, userPojo);
|
||||
.map(dicussionPojo -> {
|
||||
UserPojo userPojo = userMapById.get(dicussionPojo.getUserId());
|
||||
return discussionResponseConverter.of(dicussionPojo, userPojo);
|
||||
});
|
||||
} else {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public void create(Integer groupId, Integer projectId, Integer userId, RemarkCreateRequest request) {
|
||||
public void create(Integer groupId, Integer projectId, Integer userId, DiscussionCreateRequest request) {
|
||||
if (projectDao.exists(groupId, projectId)) {
|
||||
DocumentRemarkPojo pojo = new DocumentRemarkPojo();
|
||||
DocumentDiscussionPojo pojo = new DocumentDiscussionPojo();
|
||||
pojo.setUserId(userId);
|
||||
pojo.setProjectId(projectId);
|
||||
pojo.setRemark(request.getRemark());
|
||||
pojo.setContent(request.getContent());
|
||||
pojo.setTableName(request.getTableName());
|
||||
pojo.setColumnName(request.getColumnName());
|
||||
documentRemarkDao.insertAndReturnId(pojo);
|
||||
documentDiscussionDao.insertAndReturnId(pojo);
|
||||
} else {
|
||||
throw new Forbidden();
|
||||
}
|
|
@ -8,7 +8,7 @@ import com.databasir.dao.tables.DataSource;
|
|||
import com.databasir.dao.tables.DataSourceProperty;
|
||||
import com.databasir.dao.tables.DatabaseDocument;
|
||||
import com.databasir.dao.tables.DatabaseType;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.DocumentDiscussion;
|
||||
import com.databasir.dao.tables.Group;
|
||||
import com.databasir.dao.tables.Login;
|
||||
import com.databasir.dao.tables.OauthApp;
|
||||
|
@ -67,9 +67,9 @@ public class Databasir extends SchemaImpl {
|
|||
public final DatabaseType DATABASE_TYPE = DatabaseType.DATABASE_TYPE;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.document_remark</code>.
|
||||
* The table <code>databasir.document_discussion</code>.
|
||||
*/
|
||||
public final DocumentRemark DOCUMENT_REMARK = DocumentRemark.DOCUMENT_REMARK;
|
||||
public final DocumentDiscussion DOCUMENT_DISCUSSION = DocumentDiscussion.DOCUMENT_DISCUSSION;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.group</code>.
|
||||
|
@ -166,7 +166,7 @@ public class Databasir extends SchemaImpl {
|
|||
DataSourceProperty.DATA_SOURCE_PROPERTY,
|
||||
DatabaseDocument.DATABASE_DOCUMENT,
|
||||
DatabaseType.DATABASE_TYPE,
|
||||
DocumentRemark.DOCUMENT_REMARK,
|
||||
DocumentDiscussion.DOCUMENT_DISCUSSION,
|
||||
Group.GROUP,
|
||||
Login.LOGIN,
|
||||
OauthApp.OAUTH_APP,
|
||||
|
|
|
@ -6,7 +6,7 @@ package com.databasir.dao;
|
|||
|
||||
import com.databasir.dao.tables.DataSourceProperty;
|
||||
import com.databasir.dao.tables.DatabaseDocument;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.DocumentDiscussion;
|
||||
import com.databasir.dao.tables.TableColumnDocument;
|
||||
import com.databasir.dao.tables.TableDocument;
|
||||
import com.databasir.dao.tables.TableIndexDocument;
|
||||
|
@ -34,7 +34,7 @@ public class Indexes {
|
|||
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_IDX_PROJECT_ID = Internal.createIndex(DSL.name("idx_project_id"), DatabaseDocument.DATABASE_DOCUMENT, new OrderField[] { DatabaseDocument.DATABASE_DOCUMENT.PROJECT_ID }, false);
|
||||
public static final Index DOCUMENT_REMARK_IDX_PROJECT_ID = Internal.createIndex(DSL.name("idx_project_id"), DocumentRemark.DOCUMENT_REMARK, new OrderField[] { DocumentRemark.DOCUMENT_REMARK.PROJECT_ID }, false);
|
||||
public static final Index DOCUMENT_DISCUSSION_IDX_PROJECT_ID = Internal.createIndex(DSL.name("idx_project_id"), DocumentDiscussion.DOCUMENT_DISCUSSION, new OrderField[] { DocumentDiscussion.DOCUMENT_DISCUSSION.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);
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.databasir.dao.tables.DataSource;
|
|||
import com.databasir.dao.tables.DataSourceProperty;
|
||||
import com.databasir.dao.tables.DatabaseDocument;
|
||||
import com.databasir.dao.tables.DatabaseType;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.DocumentDiscussion;
|
||||
import com.databasir.dao.tables.Group;
|
||||
import com.databasir.dao.tables.Login;
|
||||
import com.databasir.dao.tables.OauthApp;
|
||||
|
@ -28,7 +28,7 @@ import com.databasir.dao.tables.records.DataSourcePropertyRecord;
|
|||
import com.databasir.dao.tables.records.DataSourceRecord;
|
||||
import com.databasir.dao.tables.records.DatabaseDocumentRecord;
|
||||
import com.databasir.dao.tables.records.DatabaseTypeRecord;
|
||||
import com.databasir.dao.tables.records.DocumentRemarkRecord;
|
||||
import com.databasir.dao.tables.records.DocumentDiscussionRecord;
|
||||
import com.databasir.dao.tables.records.GroupRecord;
|
||||
import com.databasir.dao.tables.records.LoginRecord;
|
||||
import com.databasir.dao.tables.records.OauthAppRecord;
|
||||
|
@ -68,7 +68,7 @@ public class Keys {
|
|||
public static final UniqueKey<DatabaseDocumentRecord> 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<DatabaseTypeRecord> KEY_DATABASE_TYPE_PRIMARY = Internal.createUniqueKey(DatabaseType.DATABASE_TYPE, DSL.name("KEY_database_type_PRIMARY"), new TableField[] { DatabaseType.DATABASE_TYPE.ID }, true);
|
||||
public static final UniqueKey<DatabaseTypeRecord> KEY_DATABASE_TYPE_UK_DATABASE_TYPE_DELETED_DELETED_TOKEN = Internal.createUniqueKey(DatabaseType.DATABASE_TYPE, DSL.name("KEY_database_type_uk_database_type_deleted_deleted_token"), new TableField[] { DatabaseType.DATABASE_TYPE.DATABASE_TYPE_, DatabaseType.DATABASE_TYPE.DELETED, DatabaseType.DATABASE_TYPE.DELETED_TOKEN }, true);
|
||||
public static final UniqueKey<DocumentRemarkRecord> KEY_DOCUMENT_REMARK_PRIMARY = Internal.createUniqueKey(DocumentRemark.DOCUMENT_REMARK, DSL.name("KEY_document_remark_PRIMARY"), new TableField[] { DocumentRemark.DOCUMENT_REMARK.ID }, true);
|
||||
public static final UniqueKey<DocumentDiscussionRecord> KEY_DOCUMENT_DISCUSSION_PRIMARY = Internal.createUniqueKey(DocumentDiscussion.DOCUMENT_DISCUSSION, DSL.name("KEY_document_discussion_PRIMARY"), new TableField[] { DocumentDiscussion.DOCUMENT_DISCUSSION.ID }, true);
|
||||
public static final UniqueKey<GroupRecord> KEY_GROUP_PRIMARY = Internal.createUniqueKey(Group.GROUP, DSL.name("KEY_group_PRIMARY"), new TableField[] { Group.GROUP.ID }, true);
|
||||
public static final UniqueKey<LoginRecord> KEY_LOGIN_PRIMARY = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_PRIMARY"), new TableField[] { Login.LOGIN.ID }, true);
|
||||
public static final UniqueKey<LoginRecord> KEY_LOGIN_UK_USER_ID = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_uk_user_id"), new TableField[] { Login.LOGIN.USER_ID }, true);
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.databasir.dao.tables.DataSource;
|
|||
import com.databasir.dao.tables.DataSourceProperty;
|
||||
import com.databasir.dao.tables.DatabaseDocument;
|
||||
import com.databasir.dao.tables.DatabaseType;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.DocumentDiscussion;
|
||||
import com.databasir.dao.tables.Group;
|
||||
import com.databasir.dao.tables.Login;
|
||||
import com.databasir.dao.tables.OauthApp;
|
||||
|
@ -53,9 +53,9 @@ public class Tables {
|
|||
public static final DatabaseType DATABASE_TYPE = DatabaseType.DATABASE_TYPE;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.document_remark</code>.
|
||||
* The table <code>databasir.document_discussion</code>.
|
||||
*/
|
||||
public static final DocumentRemark DOCUMENT_REMARK = DocumentRemark.DOCUMENT_REMARK;
|
||||
public static final DocumentDiscussion DOCUMENT_DISCUSSION = DocumentDiscussion.DOCUMENT_DISCUSSION;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.group</code>.
|
||||
|
|
|
@ -8,15 +8,27 @@ import com.databasir.dao.Databasir;
|
|||
import com.databasir.dao.Indexes;
|
||||
import com.databasir.dao.Keys;
|
||||
import com.databasir.dao.tables.records.DatabaseDocumentRecord;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.impl.SQLDataType;
|
||||
import org.jooq.impl.TableImpl;
|
||||
|
||||
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.Row10;
|
||||
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.
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* 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.DocumentDiscussionRecord;
|
||||
|
||||
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.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 DocumentDiscussion extends TableImpl<DocumentDiscussionRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>databasir.document_discussion</code>
|
||||
*/
|
||||
public static final DocumentDiscussion DOCUMENT_DISCUSSION = new DocumentDiscussion();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<DocumentDiscussionRecord> getRecordType() {
|
||||
return DocumentDiscussionRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.id</code>.
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.content</code>.
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, String> CONTENT = createField(DSL.name("content"), SQLDataType.CLOB.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.user_id</code>. user.id
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, Integer> USER_ID = createField(DSL.name("user_id"), SQLDataType.INTEGER.nullable(false), this, "user.id");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.project_id</code>.
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, Integer> PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.table_name</code>.
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, String> TABLE_NAME = createField(DSL.name("table_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.column_name</code>.
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, String> COLUMN_NAME = createField(DSL.name("column_name"), SQLDataType.VARCHAR(255), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_discussion.create_at</code>.
|
||||
*/
|
||||
public final TableField<DocumentDiscussionRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
|
||||
|
||||
private DocumentDiscussion(Name alias, Table<DocumentDiscussionRecord> aliased) {
|
||||
this(alias, aliased, null);
|
||||
}
|
||||
|
||||
private DocumentDiscussion(Name alias, Table<DocumentDiscussionRecord> aliased, Field<?>[] parameters) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.document_discussion</code> table
|
||||
* reference
|
||||
*/
|
||||
public DocumentDiscussion(String alias) {
|
||||
this(DSL.name(alias), DOCUMENT_DISCUSSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.document_discussion</code> table
|
||||
* reference
|
||||
*/
|
||||
public DocumentDiscussion(Name alias) {
|
||||
this(alias, DOCUMENT_DISCUSSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>databasir.document_discussion</code> table reference
|
||||
*/
|
||||
public DocumentDiscussion() {
|
||||
this(DSL.name("document_discussion"), null);
|
||||
}
|
||||
|
||||
public <O extends Record> DocumentDiscussion(Table<O> child, ForeignKey<O, DocumentDiscussionRecord> key) {
|
||||
super(child, key, DOCUMENT_DISCUSSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Databasir.DATABASIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Index> getIndexes() {
|
||||
return Arrays.asList(Indexes.DOCUMENT_DISCUSSION_IDX_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identity<DocumentDiscussionRecord, Integer> getIdentity() {
|
||||
return (Identity<DocumentDiscussionRecord, Integer>) super.getIdentity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<DocumentDiscussionRecord> getPrimaryKey() {
|
||||
return Keys.KEY_DOCUMENT_DISCUSSION_PRIMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentDiscussion as(String alias) {
|
||||
return new DocumentDiscussion(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentDiscussion as(Name alias) {
|
||||
return new DocumentDiscussion(alias, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public DocumentDiscussion rename(String name) {
|
||||
return new DocumentDiscussion(DSL.name(name), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public DocumentDiscussion rename(Name name) {
|
||||
return new DocumentDiscussion(name, null);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Row7 type methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row7<Integer, String, Integer, Integer, String, String, LocalDateTime> fieldsRow() {
|
||||
return (Row7) super.fieldsRow();
|
||||
}
|
||||
}
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
* 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.DocumentRemarkRecord;
|
||||
|
||||
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.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 DocumentRemark extends TableImpl<DocumentRemarkRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>databasir.document_remark</code>
|
||||
*/
|
||||
public static final DocumentRemark DOCUMENT_REMARK = new DocumentRemark();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<DocumentRemarkRecord> getRecordType() {
|
||||
return DocumentRemarkRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.id</code>.
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.remark</code>.
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, String> REMARK = createField(DSL.name("remark"), SQLDataType.CLOB.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.user_id</code>. user.id
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, Integer> USER_ID = createField(DSL.name("user_id"), SQLDataType.INTEGER.nullable(false), this, "user.id");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.project_id</code>.
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, Integer> PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.table_name</code>.
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, String> TABLE_NAME = createField(DSL.name("table_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.column_name</code>.
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, String> COLUMN_NAME = createField(DSL.name("column_name"), SQLDataType.VARCHAR(255), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.document_remark.create_at</code>.
|
||||
*/
|
||||
public final TableField<DocumentRemarkRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
|
||||
|
||||
private DocumentRemark(Name alias, Table<DocumentRemarkRecord> aliased) {
|
||||
this(alias, aliased, null);
|
||||
}
|
||||
|
||||
private DocumentRemark(Name alias, Table<DocumentRemarkRecord> aliased, Field<?>[] parameters) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.document_remark</code> table reference
|
||||
*/
|
||||
public DocumentRemark(String alias) {
|
||||
this(DSL.name(alias), DOCUMENT_REMARK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.document_remark</code> table reference
|
||||
*/
|
||||
public DocumentRemark(Name alias) {
|
||||
this(alias, DOCUMENT_REMARK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>databasir.document_remark</code> table reference
|
||||
*/
|
||||
public DocumentRemark() {
|
||||
this(DSL.name("document_remark"), null);
|
||||
}
|
||||
|
||||
public <O extends Record> DocumentRemark(Table<O> child, ForeignKey<O, DocumentRemarkRecord> key) {
|
||||
super(child, key, DOCUMENT_REMARK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Databasir.DATABASIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Index> getIndexes() {
|
||||
return Arrays.asList(Indexes.DOCUMENT_REMARK_IDX_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identity<DocumentRemarkRecord, Integer> getIdentity() {
|
||||
return (Identity<DocumentRemarkRecord, Integer>) super.getIdentity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<DocumentRemarkRecord> getPrimaryKey() {
|
||||
return Keys.KEY_DOCUMENT_REMARK_PRIMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemark as(String alias) {
|
||||
return new DocumentRemark(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemark as(Name alias) {
|
||||
return new DocumentRemark(alias, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public DocumentRemark rename(String name) {
|
||||
return new DocumentRemark(DSL.name(name), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public DocumentRemark rename(Name name) {
|
||||
return new DocumentRemark(name, null);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Row7 type methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row7<Integer, String, Integer, Integer, String, String, LocalDateTime> fieldsRow() {
|
||||
return (Row7) super.fieldsRow();
|
||||
}
|
||||
}
|
|
@ -12,23 +12,23 @@ import java.time.LocalDateTime;
|
|||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class DocumentRemarkPojo implements Serializable {
|
||||
public class DocumentDiscussionPojo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String remark;
|
||||
private String content;
|
||||
private Integer userId;
|
||||
private Integer projectId;
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
private LocalDateTime createAt;
|
||||
|
||||
public DocumentRemarkPojo() {}
|
||||
public DocumentDiscussionPojo() {}
|
||||
|
||||
public DocumentRemarkPojo(DocumentRemarkPojo value) {
|
||||
public DocumentDiscussionPojo(DocumentDiscussionPojo value) {
|
||||
this.id = value.id;
|
||||
this.remark = value.remark;
|
||||
this.content = value.content;
|
||||
this.userId = value.userId;
|
||||
this.projectId = value.projectId;
|
||||
this.tableName = value.tableName;
|
||||
|
@ -36,9 +36,9 @@ public class DocumentRemarkPojo implements Serializable {
|
|||
this.createAt = value.createAt;
|
||||
}
|
||||
|
||||
public DocumentRemarkPojo(
|
||||
public DocumentDiscussionPojo(
|
||||
Integer id,
|
||||
String remark,
|
||||
String content,
|
||||
Integer userId,
|
||||
Integer projectId,
|
||||
String tableName,
|
||||
|
@ -46,7 +46,7 @@ public class DocumentRemarkPojo implements Serializable {
|
|||
LocalDateTime createAt
|
||||
) {
|
||||
this.id = id;
|
||||
this.remark = remark;
|
||||
this.content = content;
|
||||
this.userId = userId;
|
||||
this.projectId = projectId;
|
||||
this.tableName = tableName;
|
||||
|
@ -55,98 +55,98 @@ public class DocumentRemarkPojo implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.id</code>.
|
||||
* Getter for <code>databasir.document_discussion.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.id</code>.
|
||||
* Setter for <code>databasir.document_discussion.id</code>.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.remark</code>.
|
||||
* Getter for <code>databasir.document_discussion.content</code>.
|
||||
*/
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.remark</code>.
|
||||
* Setter for <code>databasir.document_discussion.content</code>.
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.user_id</code>. user.id
|
||||
* Getter for <code>databasir.document_discussion.user_id</code>. user.id
|
||||
*/
|
||||
public Integer getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.user_id</code>. user.id
|
||||
* Setter for <code>databasir.document_discussion.user_id</code>. user.id
|
||||
*/
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.project_id</code>.
|
||||
* Getter for <code>databasir.document_discussion.project_id</code>.
|
||||
*/
|
||||
public Integer getProjectId() {
|
||||
return this.projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.project_id</code>.
|
||||
* Setter for <code>databasir.document_discussion.project_id</code>.
|
||||
*/
|
||||
public void setProjectId(Integer projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.table_name</code>.
|
||||
* Getter for <code>databasir.document_discussion.table_name</code>.
|
||||
*/
|
||||
public String getTableName() {
|
||||
return this.tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.table_name</code>.
|
||||
* Setter for <code>databasir.document_discussion.table_name</code>.
|
||||
*/
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.column_name</code>.
|
||||
* Getter for <code>databasir.document_discussion.column_name</code>.
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return this.columnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.column_name</code>.
|
||||
* Setter for <code>databasir.document_discussion.column_name</code>.
|
||||
*/
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.create_at</code>.
|
||||
* Getter for <code>databasir.document_discussion.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return this.createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.create_at</code>.
|
||||
* Setter for <code>databasir.document_discussion.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime createAt) {
|
||||
this.createAt = createAt;
|
||||
|
@ -154,10 +154,10 @@ public class DocumentRemarkPojo implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("DocumentRemarkPojo (");
|
||||
StringBuilder sb = new StringBuilder("DocumentDiscussionPojo (");
|
||||
|
||||
sb.append(id);
|
||||
sb.append(", ").append(remark);
|
||||
sb.append(", ").append(content);
|
||||
sb.append(", ").append(userId);
|
||||
sb.append(", ").append(projectId);
|
||||
sb.append(", ").append(tableName);
|
|
@ -4,8 +4,8 @@
|
|||
package com.databasir.dao.tables.records;
|
||||
|
||||
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.pojos.DocumentRemarkPojo;
|
||||
import com.databasir.dao.tables.DocumentDiscussion;
|
||||
import com.databasir.dao.tables.pojos.DocumentDiscussionPojo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
@ -20,103 +20,103 @@ import org.jooq.impl.UpdatableRecordImpl;
|
|||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkRecord> implements Record7<Integer, String, Integer, Integer, String, String, LocalDateTime> {
|
||||
public class DocumentDiscussionRecord extends UpdatableRecordImpl<DocumentDiscussionRecord> implements Record7<Integer, String, Integer, Integer, String, String, LocalDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.id</code>.
|
||||
* Setter for <code>databasir.document_discussion.id</code>.
|
||||
*/
|
||||
public void setId(Integer value) {
|
||||
set(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.id</code>.
|
||||
* Getter for <code>databasir.document_discussion.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return (Integer) get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.remark</code>.
|
||||
* Setter for <code>databasir.document_discussion.content</code>.
|
||||
*/
|
||||
public void setRemark(String value) {
|
||||
public void setContent(String value) {
|
||||
set(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.remark</code>.
|
||||
* Getter for <code>databasir.document_discussion.content</code>.
|
||||
*/
|
||||
public String getRemark() {
|
||||
public String getContent() {
|
||||
return (String) get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.user_id</code>. user.id
|
||||
* Setter for <code>databasir.document_discussion.user_id</code>. user.id
|
||||
*/
|
||||
public void setUserId(Integer value) {
|
||||
set(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.user_id</code>. user.id
|
||||
* Getter for <code>databasir.document_discussion.user_id</code>. user.id
|
||||
*/
|
||||
public Integer getUserId() {
|
||||
return (Integer) get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.project_id</code>.
|
||||
* Setter for <code>databasir.document_discussion.project_id</code>.
|
||||
*/
|
||||
public void setProjectId(Integer value) {
|
||||
set(3, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.project_id</code>.
|
||||
* Getter for <code>databasir.document_discussion.project_id</code>.
|
||||
*/
|
||||
public Integer getProjectId() {
|
||||
return (Integer) get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.table_name</code>.
|
||||
* Setter for <code>databasir.document_discussion.table_name</code>.
|
||||
*/
|
||||
public void setTableName(String value) {
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.table_name</code>.
|
||||
* Getter for <code>databasir.document_discussion.table_name</code>.
|
||||
*/
|
||||
public String getTableName() {
|
||||
return (String) get(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.column_name</code>.
|
||||
* Setter for <code>databasir.document_discussion.column_name</code>.
|
||||
*/
|
||||
public void setColumnName(String value) {
|
||||
set(5, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.column_name</code>.
|
||||
* Getter for <code>databasir.document_discussion.column_name</code>.
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return (String) get(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.document_remark.create_at</code>.
|
||||
* Setter for <code>databasir.document_discussion.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime value) {
|
||||
set(6, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.document_remark.create_at</code>.
|
||||
* Getter for <code>databasir.document_discussion.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return (LocalDateTime) get(6);
|
||||
|
@ -147,37 +147,37 @@ public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkReco
|
|||
|
||||
@Override
|
||||
public Field<Integer> field1() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.ID;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field2() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.REMARK;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.CONTENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field3() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.USER_ID;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.USER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field4() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.PROJECT_ID;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.PROJECT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field5() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.TABLE_NAME;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.TABLE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field6() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.COLUMN_NAME;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.COLUMN_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<LocalDateTime> field7() {
|
||||
return DocumentRemark.DOCUMENT_REMARK.CREATE_AT;
|
||||
return DocumentDiscussion.DOCUMENT_DISCUSSION.CREATE_AT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -187,7 +187,7 @@ public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkReco
|
|||
|
||||
@Override
|
||||
public String component2() {
|
||||
return getRemark();
|
||||
return getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -222,7 +222,7 @@ public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkReco
|
|||
|
||||
@Override
|
||||
public String value2() {
|
||||
return getRemark();
|
||||
return getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,49 +251,49 @@ public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkReco
|
|||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value1(Integer value) {
|
||||
public DocumentDiscussionRecord value1(Integer value) {
|
||||
setId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value2(String value) {
|
||||
setRemark(value);
|
||||
public DocumentDiscussionRecord value2(String value) {
|
||||
setContent(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value3(Integer value) {
|
||||
public DocumentDiscussionRecord value3(Integer value) {
|
||||
setUserId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value4(Integer value) {
|
||||
public DocumentDiscussionRecord value4(Integer value) {
|
||||
setProjectId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value5(String value) {
|
||||
public DocumentDiscussionRecord value5(String value) {
|
||||
setTableName(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value6(String value) {
|
||||
public DocumentDiscussionRecord value6(String value) {
|
||||
setColumnName(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord value7(LocalDateTime value) {
|
||||
public DocumentDiscussionRecord value7(LocalDateTime value) {
|
||||
setCreateAt(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentRemarkRecord values(Integer value1, String value2, Integer value3, Integer value4, String value5, String value6, LocalDateTime value7) {
|
||||
public DocumentDiscussionRecord values(Integer value1, String value2, Integer value3, Integer value4, String value5, String value6, LocalDateTime value7) {
|
||||
value1(value1);
|
||||
value2(value2);
|
||||
value3(value3);
|
||||
|
@ -309,20 +309,20 @@ public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkReco
|
|||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached DocumentRemarkRecord
|
||||
* Create a detached DocumentDiscussionRecord
|
||||
*/
|
||||
public DocumentRemarkRecord() {
|
||||
super(DocumentRemark.DOCUMENT_REMARK);
|
||||
public DocumentDiscussionRecord() {
|
||||
super(DocumentDiscussion.DOCUMENT_DISCUSSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised DocumentRemarkRecord
|
||||
* Create a detached, initialised DocumentDiscussionRecord
|
||||
*/
|
||||
public DocumentRemarkRecord(Integer id, String remark, Integer userId, Integer projectId, String tableName, String columnName, LocalDateTime createAt) {
|
||||
super(DocumentRemark.DOCUMENT_REMARK);
|
||||
public DocumentDiscussionRecord(Integer id, String content, Integer userId, Integer projectId, String tableName, String columnName, LocalDateTime createAt) {
|
||||
super(DocumentDiscussion.DOCUMENT_DISCUSSION);
|
||||
|
||||
setId(id);
|
||||
setRemark(remark);
|
||||
setContent(content);
|
||||
setUserId(userId);
|
||||
setProjectId(projectId);
|
||||
setTableName(tableName);
|
||||
|
@ -331,14 +331,14 @@ public class DocumentRemarkRecord extends UpdatableRecordImpl<DocumentRemarkReco
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised DocumentRemarkRecord
|
||||
* Create a detached, initialised DocumentDiscussionRecord
|
||||
*/
|
||||
public DocumentRemarkRecord(DocumentRemarkPojo value) {
|
||||
super(DocumentRemark.DOCUMENT_REMARK);
|
||||
public DocumentDiscussionRecord(DocumentDiscussionPojo value) {
|
||||
super(DocumentDiscussion.DOCUMENT_DISCUSSION);
|
||||
|
||||
if (value != null) {
|
||||
setId(value.getId());
|
||||
setRemark(value.getRemark());
|
||||
setContent(value.getContent());
|
||||
setUserId(value.getUserId());
|
||||
setProjectId(value.getProjectId());
|
||||
setTableName(value.getTableName());
|
|
@ -0,0 +1,52 @@
|
|||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.DocumentDiscussionPojo;
|
||||
import com.databasir.dao.value.DocumentDiscussionCountPojo;
|
||||
import lombok.Getter;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.databasir.dao.Tables.DOCUMENT_DISCUSSION;
|
||||
|
||||
@Repository
|
||||
public class DocumentDiscussionDao extends BaseDao<DocumentDiscussionPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
private DSLContext dslContext;
|
||||
|
||||
public DocumentDiscussionDao() {
|
||||
super(DOCUMENT_DISCUSSION, DocumentDiscussionPojo.class);
|
||||
}
|
||||
|
||||
public Optional<DocumentDiscussionPojo> selectByProjectIdAndId(Integer projectId, Integer id) {
|
||||
return this.getDslContext()
|
||||
.selectFrom(DOCUMENT_DISCUSSION).where(DOCUMENT_DISCUSSION.PROJECT_ID.eq(projectId)
|
||||
.and(DOCUMENT_DISCUSSION.ID.eq(id)))
|
||||
.fetchOptionalInto(DocumentDiscussionPojo.class);
|
||||
}
|
||||
|
||||
public List<DocumentDiscussionCountPojo> selectTableDiscussionCount(Integer projectId) {
|
||||
return this.selectDiscussionCount(DOCUMENT_DISCUSSION.PROJECT_ID.eq(projectId)
|
||||
.and(DOCUMENT_DISCUSSION.COLUMN_NAME.isNull()));
|
||||
}
|
||||
|
||||
public List<DocumentDiscussionCountPojo> selectAllDiscussionCount(Integer projectId) {
|
||||
return this.selectDiscussionCount(DOCUMENT_DISCUSSION.PROJECT_ID.eq(projectId));
|
||||
}
|
||||
|
||||
public List<DocumentDiscussionCountPojo> selectDiscussionCount(Condition condition) {
|
||||
return this.getDslContext()
|
||||
.select(DSL.count(), DOCUMENT_DISCUSSION.TABLE_NAME, DOCUMENT_DISCUSSION.COLUMN_NAME)
|
||||
.from(DOCUMENT_DISCUSSION)
|
||||
.where(condition)
|
||||
.groupBy(DOCUMENT_DISCUSSION.TABLE_NAME, DOCUMENT_DISCUSSION.COLUMN_NAME)
|
||||
.fetchInto(DocumentDiscussionCountPojo.class);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.DocumentRemarkPojo;
|
||||
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.DOCUMENT_REMARK;
|
||||
|
||||
@Repository
|
||||
public class DocumentRemarkDao extends BaseDao<DocumentRemarkPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
private DSLContext dslContext;
|
||||
|
||||
public DocumentRemarkDao() {
|
||||
super(DOCUMENT_REMARK, DocumentRemarkPojo.class);
|
||||
}
|
||||
|
||||
public Optional<DocumentRemarkPojo> selectByProjectIdAndId(Integer projectId, Integer id) {
|
||||
return this.getDslContext()
|
||||
.selectFrom(DOCUMENT_REMARK).where(DOCUMENT_REMARK.PROJECT_ID.eq(projectId)
|
||||
.and(DOCUMENT_REMARK.ID.eq(id)))
|
||||
.fetchOptionalInto(DocumentRemarkPojo.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.databasir.dao.value;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DocumentDiscussionCountPojo {
|
||||
|
||||
private Integer projectId;
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String columnName;
|
||||
|
||||
private Integer count;
|
||||
}
|
|
@ -211,10 +211,10 @@ CREATE TABLE IF NOT EXISTS login
|
|||
) CHARSET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS document_remark
|
||||
CREATE TABLE IF NOT EXISTS document_discussion
|
||||
(
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
remark TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
user_id INT NOT NULL COMMENT 'user.id',
|
||||
project_id INT NOT NULL,
|
||||
table_name VARCHAR(255) NOT NULL,
|
||||
|
|
|
@ -15,6 +15,7 @@ public class TableCondition extends Condition {
|
|||
return TableCondition.builder()
|
||||
.databaseName(condition.getDatabaseName())
|
||||
.tableName(tableName)
|
||||
.schemaName(condition.getSchemaName())
|
||||
.ignoreTableNameRegex(condition.getIgnoreTableNameRegex())
|
||||
.ignoreTableColumnNameRegex(condition.getIgnoreTableColumnNameRegex())
|
||||
.build();
|
||||
|
|
|
@ -30,10 +30,11 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
|||
List<ColumnMeta> columnDocs = new ArrayList<>();
|
||||
String databaseName = tableCondition.getDatabaseName();
|
||||
String tableName = tableCondition.getTableName();
|
||||
List<String> primaryKeyColumns = selectPrimaryKeyColumns(connection.getMetaData(), databaseName, tableName);
|
||||
List<String> primaryKeyColumns = selectPrimaryKeyColumns(connection.getMetaData(), tableCondition);
|
||||
ResultSet columnsResult;
|
||||
try {
|
||||
columnsResult = connection.getMetaData().getColumns(databaseName, null, tableName, null);
|
||||
columnsResult = connection.getMetaData()
|
||||
.getColumns(databaseName, tableCondition.getSchemaName(), tableName, null);
|
||||
} catch (SQLException e) {
|
||||
log.warn("warn: ignore columns in " + databaseName + "." + tableName);
|
||||
return columnDocs;
|
||||
|
@ -85,9 +86,9 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
|||
}
|
||||
|
||||
private List<String> selectPrimaryKeyColumns(DatabaseMetaData meta,
|
||||
String catalog,
|
||||
String tableName) throws SQLException {
|
||||
ResultSet result = meta.getPrimaryKeys(catalog, null, tableName);
|
||||
TableCondition tableCondition) throws SQLException {
|
||||
ResultSet result = meta.getPrimaryKeys(tableCondition.getDatabaseName(),
|
||||
tableCondition.getSchemaName(), tableCondition.getTableName());
|
||||
List<String> columns = new ArrayList<>();
|
||||
while (result.next()) {
|
||||
String columnName = result.getString("COLUMN_NAME");
|
||||
|
|
|
@ -28,7 +28,8 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository {
|
|||
List<IndexMeta> indexMetas = new ArrayList<>();
|
||||
ResultSet indexResults;
|
||||
try {
|
||||
indexResults = connection.getMetaData().getIndexInfo(databaseName, null, tableName, false, false);
|
||||
indexResults = connection.getMetaData()
|
||||
.getIndexInfo(databaseName, condition.getSchemaName(), tableName, false, false);
|
||||
} catch (SQLException e) {
|
||||
log.warn("warn: ignore " + databaseName + "." + tableName);
|
||||
return indexMetas;
|
||||
|
|
Loading…
Reference in New Issue