mirror of
https://github.com/vran-dev/databasir.git
synced 2025-08-08 21:32:16 +08:00
Feature: add operation log (#16)
* feat: auto record operation log * feat: add list project operation log api * feat: update frontend resource
This commit is contained in:
@@ -11,6 +11,7 @@ import com.databasir.dao.tables.DatabaseDocumentHistory;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.Group;
|
||||
import com.databasir.dao.tables.Login;
|
||||
import com.databasir.dao.tables.OperationLog;
|
||||
import com.databasir.dao.tables.Project;
|
||||
import com.databasir.dao.tables.ProjectSyncRule;
|
||||
import com.databasir.dao.tables.SysKey;
|
||||
@@ -78,6 +79,11 @@ public class Databasir extends SchemaImpl {
|
||||
*/
|
||||
public final Login LOGIN = Login.LOGIN;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.operation_log</code>.
|
||||
*/
|
||||
public final OperationLog OPERATION_LOG = OperationLog.OPERATION_LOG;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.project</code>.
|
||||
*/
|
||||
@@ -151,6 +157,7 @@ public class Databasir extends SchemaImpl {
|
||||
DocumentRemark.DOCUMENT_REMARK,
|
||||
Group.GROUP,
|
||||
Login.LOGIN,
|
||||
OperationLog.OPERATION_LOG,
|
||||
Project.PROJECT,
|
||||
ProjectSyncRule.PROJECT_SYNC_RULE,
|
||||
SysKey.SYS_KEY,
|
||||
|
@@ -11,6 +11,7 @@ import com.databasir.dao.tables.DatabaseDocumentHistory;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.Group;
|
||||
import com.databasir.dao.tables.Login;
|
||||
import com.databasir.dao.tables.OperationLog;
|
||||
import com.databasir.dao.tables.Project;
|
||||
import com.databasir.dao.tables.ProjectSyncRule;
|
||||
import com.databasir.dao.tables.SysKey;
|
||||
@@ -28,6 +29,7 @@ import com.databasir.dao.tables.records.DatabaseDocumentRecord;
|
||||
import com.databasir.dao.tables.records.DocumentRemarkRecord;
|
||||
import com.databasir.dao.tables.records.GroupRecord;
|
||||
import com.databasir.dao.tables.records.LoginRecord;
|
||||
import com.databasir.dao.tables.records.OperationLogRecord;
|
||||
import com.databasir.dao.tables.records.ProjectRecord;
|
||||
import com.databasir.dao.tables.records.ProjectSyncRuleRecord;
|
||||
import com.databasir.dao.tables.records.SysKeyRecord;
|
||||
@@ -68,6 +70,7 @@ public class Keys {
|
||||
public static final UniqueKey<GroupRecord> KEY_GROUP_UK_NAME = Internal.createUniqueKey(Group.GROUP, DSL.name("KEY_group_uk_name"), new TableField[] { Group.GROUP.NAME }, 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);
|
||||
public static final UniqueKey<OperationLogRecord> KEY_OPERATION_LOG_PRIMARY = Internal.createUniqueKey(OperationLog.OPERATION_LOG, DSL.name("KEY_operation_log_PRIMARY"), new TableField[] { OperationLog.OPERATION_LOG.ID }, true);
|
||||
public static final UniqueKey<ProjectRecord> KEY_PROJECT_PRIMARY = Internal.createUniqueKey(Project.PROJECT, DSL.name("KEY_project_PRIMARY"), new TableField[] { Project.PROJECT.ID }, true);
|
||||
public static final UniqueKey<ProjectRecord> 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<ProjectSyncRuleRecord> 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);
|
||||
|
@@ -11,6 +11,7 @@ import com.databasir.dao.tables.DatabaseDocumentHistory;
|
||||
import com.databasir.dao.tables.DocumentRemark;
|
||||
import com.databasir.dao.tables.Group;
|
||||
import com.databasir.dao.tables.Login;
|
||||
import com.databasir.dao.tables.OperationLog;
|
||||
import com.databasir.dao.tables.Project;
|
||||
import com.databasir.dao.tables.ProjectSyncRule;
|
||||
import com.databasir.dao.tables.SysKey;
|
||||
@@ -64,6 +65,11 @@ public class Tables {
|
||||
*/
|
||||
public static final Login LOGIN = Login.LOGIN;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.operation_log</code>.
|
||||
*/
|
||||
public static final OperationLog OPERATION_LOG = OperationLog.OPERATION_LOG;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.project</code>.
|
||||
*/
|
||||
|
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* 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.OperationLogRecord;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
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.Row13;
|
||||
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 OperationLog extends TableImpl<OperationLogRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>databasir.operation_log</code>
|
||||
*/
|
||||
public static final OperationLog OPERATION_LOG = new OperationLog();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<OperationLogRecord> getRecordType() {
|
||||
return OperationLogRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.id</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, Long> ID = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operator_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public final TableField<OperationLogRecord, Integer> OPERATOR_USER_ID = createField(DSL.name("operator_user_id"), SQLDataType.INTEGER.nullable(false), this, "ref to user.id");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operator_username</code>.
|
||||
* user.username
|
||||
*/
|
||||
public final TableField<OperationLogRecord, String> OPERATOR_USERNAME = createField(DSL.name("operator_username"), SQLDataType.VARCHAR(128).nullable(false), this, "user.username");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operator_nickname</code>.
|
||||
* user.nickname
|
||||
*/
|
||||
public final TableField<OperationLogRecord, String> OPERATOR_NICKNAME = createField(DSL.name("operator_nickname"), SQLDataType.VARCHAR(255).nullable(false), this, "user.nickname");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operation_module</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, String> OPERATION_MODULE = createField(DSL.name("operation_module"), SQLDataType.VARCHAR(128).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operation_code</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, String> OPERATION_CODE = createField(DSL.name("operation_code"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operation_name</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, String> OPERATION_NAME = createField(DSL.name("operation_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.operation_response</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, JSON> OPERATION_RESPONSE = createField(DSL.name("operation_response"), SQLDataType.JSON.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.is_success</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, Boolean> IS_SUCCESS = createField(DSL.name("is_success"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.inline("0", SQLDataType.BOOLEAN)), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.involved_project_id</code>. ref
|
||||
* to project.id
|
||||
*/
|
||||
public final TableField<OperationLogRecord, Integer> INVOLVED_PROJECT_ID = createField(DSL.name("involved_project_id"), SQLDataType.INTEGER, this, "ref to project.id");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.involved_group_id</code>. ref to
|
||||
* group.id
|
||||
*/
|
||||
public final TableField<OperationLogRecord, Integer> INVOLVED_GROUP_ID = createField(DSL.name("involved_group_id"), SQLDataType.INTEGER, this, "ref to group.id");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.involved_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public final TableField<OperationLogRecord, Integer> INVOLVED_USER_ID = createField(DSL.name("involved_user_id"), SQLDataType.INTEGER, this, "ref to user.id");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.operation_log.create_at</code>.
|
||||
*/
|
||||
public final TableField<OperationLogRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
|
||||
|
||||
private OperationLog(Name alias, Table<OperationLogRecord> aliased) {
|
||||
this(alias, aliased, null);
|
||||
}
|
||||
|
||||
private OperationLog(Name alias, Table<OperationLogRecord> aliased, Field<?>[] parameters) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.operation_log</code> table reference
|
||||
*/
|
||||
public OperationLog(String alias) {
|
||||
this(DSL.name(alias), OPERATION_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.operation_log</code> table reference
|
||||
*/
|
||||
public OperationLog(Name alias) {
|
||||
this(alias, OPERATION_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>databasir.operation_log</code> table reference
|
||||
*/
|
||||
public OperationLog() {
|
||||
this(DSL.name("operation_log"), null);
|
||||
}
|
||||
|
||||
public <O extends Record> OperationLog(Table<O> child, ForeignKey<O, OperationLogRecord> key) {
|
||||
super(child, key, OPERATION_LOG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Databasir.DATABASIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identity<OperationLogRecord, Long> getIdentity() {
|
||||
return (Identity<OperationLogRecord, Long>) super.getIdentity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<OperationLogRecord> getPrimaryKey() {
|
||||
return Keys.KEY_OPERATION_LOG_PRIMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLog as(String alias) {
|
||||
return new OperationLog(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLog as(Name alias) {
|
||||
return new OperationLog(alias, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public OperationLog rename(String name) {
|
||||
return new OperationLog(DSL.name(name), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public OperationLog rename(Name name) {
|
||||
return new OperationLog(name, null);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Row13 type methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> fieldsRow() {
|
||||
return (Row13) super.fieldsRow();
|
||||
}
|
||||
}
|
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* 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 OperationLogPojo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
private Integer operatorUserId;
|
||||
private String operatorUsername;
|
||||
private String operatorNickname;
|
||||
private String operationModule;
|
||||
private String operationCode;
|
||||
private String operationName;
|
||||
private JSON operationResponse;
|
||||
private Boolean isSuccess;
|
||||
private Integer involvedProjectId;
|
||||
private Integer involvedGroupId;
|
||||
private Integer involvedUserId;
|
||||
private LocalDateTime createAt;
|
||||
|
||||
public OperationLogPojo() {}
|
||||
|
||||
public OperationLogPojo(OperationLogPojo value) {
|
||||
this.id = value.id;
|
||||
this.operatorUserId = value.operatorUserId;
|
||||
this.operatorUsername = value.operatorUsername;
|
||||
this.operatorNickname = value.operatorNickname;
|
||||
this.operationModule = value.operationModule;
|
||||
this.operationCode = value.operationCode;
|
||||
this.operationName = value.operationName;
|
||||
this.operationResponse = value.operationResponse;
|
||||
this.isSuccess = value.isSuccess;
|
||||
this.involvedProjectId = value.involvedProjectId;
|
||||
this.involvedGroupId = value.involvedGroupId;
|
||||
this.involvedUserId = value.involvedUserId;
|
||||
this.createAt = value.createAt;
|
||||
}
|
||||
|
||||
public OperationLogPojo(
|
||||
Long id,
|
||||
Integer operatorUserId,
|
||||
String operatorUsername,
|
||||
String operatorNickname,
|
||||
String operationModule,
|
||||
String operationCode,
|
||||
String operationName,
|
||||
JSON operationResponse,
|
||||
Boolean isSuccess,
|
||||
Integer involvedProjectId,
|
||||
Integer involvedGroupId,
|
||||
Integer involvedUserId,
|
||||
LocalDateTime createAt
|
||||
) {
|
||||
this.id = id;
|
||||
this.operatorUserId = operatorUserId;
|
||||
this.operatorUsername = operatorUsername;
|
||||
this.operatorNickname = operatorNickname;
|
||||
this.operationModule = operationModule;
|
||||
this.operationCode = operationCode;
|
||||
this.operationName = operationName;
|
||||
this.operationResponse = operationResponse;
|
||||
this.isSuccess = isSuccess;
|
||||
this.involvedProjectId = involvedProjectId;
|
||||
this.involvedGroupId = involvedGroupId;
|
||||
this.involvedUserId = involvedUserId;
|
||||
this.createAt = createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.id</code>.
|
||||
*/
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.id</code>.
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operator_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public Integer getOperatorUserId() {
|
||||
return this.operatorUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operator_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public void setOperatorUserId(Integer operatorUserId) {
|
||||
this.operatorUserId = operatorUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operator_username</code>.
|
||||
* user.username
|
||||
*/
|
||||
public String getOperatorUsername() {
|
||||
return this.operatorUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operator_username</code>.
|
||||
* user.username
|
||||
*/
|
||||
public void setOperatorUsername(String operatorUsername) {
|
||||
this.operatorUsername = operatorUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operator_nickname</code>.
|
||||
* user.nickname
|
||||
*/
|
||||
public String getOperatorNickname() {
|
||||
return this.operatorNickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operator_nickname</code>.
|
||||
* user.nickname
|
||||
*/
|
||||
public void setOperatorNickname(String operatorNickname) {
|
||||
this.operatorNickname = operatorNickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_module</code>.
|
||||
*/
|
||||
public String getOperationModule() {
|
||||
return this.operationModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_module</code>.
|
||||
*/
|
||||
public void setOperationModule(String operationModule) {
|
||||
this.operationModule = operationModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_code</code>.
|
||||
*/
|
||||
public String getOperationCode() {
|
||||
return this.operationCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_code</code>.
|
||||
*/
|
||||
public void setOperationCode(String operationCode) {
|
||||
this.operationCode = operationCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_name</code>.
|
||||
*/
|
||||
public String getOperationName() {
|
||||
return this.operationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_name</code>.
|
||||
*/
|
||||
public void setOperationName(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_response</code>.
|
||||
*/
|
||||
public JSON getOperationResponse() {
|
||||
return this.operationResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_response</code>.
|
||||
*/
|
||||
public void setOperationResponse(JSON operationResponse) {
|
||||
this.operationResponse = operationResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.is_success</code>.
|
||||
*/
|
||||
public Boolean getIsSuccess() {
|
||||
return this.isSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.is_success</code>.
|
||||
*/
|
||||
public void setIsSuccess(Boolean isSuccess) {
|
||||
this.isSuccess = isSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.involved_project_id</code>. ref
|
||||
* to project.id
|
||||
*/
|
||||
public Integer getInvolvedProjectId() {
|
||||
return this.involvedProjectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.involved_project_id</code>. ref
|
||||
* to project.id
|
||||
*/
|
||||
public void setInvolvedProjectId(Integer involvedProjectId) {
|
||||
this.involvedProjectId = involvedProjectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.involved_group_id</code>. ref to
|
||||
* group.id
|
||||
*/
|
||||
public Integer getInvolvedGroupId() {
|
||||
return this.involvedGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.involved_group_id</code>. ref to
|
||||
* group.id
|
||||
*/
|
||||
public void setInvolvedGroupId(Integer involvedGroupId) {
|
||||
this.involvedGroupId = involvedGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.involved_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public Integer getInvolvedUserId() {
|
||||
return this.involvedUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.involved_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public void setInvolvedUserId(Integer involvedUserId) {
|
||||
this.involvedUserId = involvedUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return this.createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime createAt) {
|
||||
this.createAt = createAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("OperationLogPojo (");
|
||||
|
||||
sb.append(id);
|
||||
sb.append(", ").append(operatorUserId);
|
||||
sb.append(", ").append(operatorUsername);
|
||||
sb.append(", ").append(operatorNickname);
|
||||
sb.append(", ").append(operationModule);
|
||||
sb.append(", ").append(operationCode);
|
||||
sb.append(", ").append(operationName);
|
||||
sb.append(", ").append(operationResponse);
|
||||
sb.append(", ").append(isSuccess);
|
||||
sb.append(", ").append(involvedProjectId);
|
||||
sb.append(", ").append(involvedGroupId);
|
||||
sb.append(", ").append(involvedUserId);
|
||||
sb.append(", ").append(createAt);
|
||||
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,590 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.databasir.dao.tables.records;
|
||||
|
||||
|
||||
import com.databasir.dao.tables.OperationLog;
|
||||
import com.databasir.dao.tables.pojos.OperationLogPojo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.JSON;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Record13;
|
||||
import org.jooq.Row13;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class OperationLogRecord extends UpdatableRecordImpl<OperationLogRecord> implements Record13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.id</code>.
|
||||
*/
|
||||
public void setId(Long value) {
|
||||
set(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.id</code>.
|
||||
*/
|
||||
public Long getId() {
|
||||
return (Long) get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operator_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public void setOperatorUserId(Integer value) {
|
||||
set(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operator_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public Integer getOperatorUserId() {
|
||||
return (Integer) get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operator_username</code>.
|
||||
* user.username
|
||||
*/
|
||||
public void setOperatorUsername(String value) {
|
||||
set(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operator_username</code>.
|
||||
* user.username
|
||||
*/
|
||||
public String getOperatorUsername() {
|
||||
return (String) get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operator_nickname</code>.
|
||||
* user.nickname
|
||||
*/
|
||||
public void setOperatorNickname(String value) {
|
||||
set(3, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operator_nickname</code>.
|
||||
* user.nickname
|
||||
*/
|
||||
public String getOperatorNickname() {
|
||||
return (String) get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_module</code>.
|
||||
*/
|
||||
public void setOperationModule(String value) {
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_module</code>.
|
||||
*/
|
||||
public String getOperationModule() {
|
||||
return (String) get(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_code</code>.
|
||||
*/
|
||||
public void setOperationCode(String value) {
|
||||
set(5, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_code</code>.
|
||||
*/
|
||||
public String getOperationCode() {
|
||||
return (String) get(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_name</code>.
|
||||
*/
|
||||
public void setOperationName(String value) {
|
||||
set(6, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_name</code>.
|
||||
*/
|
||||
public String getOperationName() {
|
||||
return (String) get(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.operation_response</code>.
|
||||
*/
|
||||
public void setOperationResponse(JSON value) {
|
||||
set(7, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.operation_response</code>.
|
||||
*/
|
||||
public JSON getOperationResponse() {
|
||||
return (JSON) get(7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.is_success</code>.
|
||||
*/
|
||||
public void setIsSuccess(Boolean value) {
|
||||
set(8, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.is_success</code>.
|
||||
*/
|
||||
public Boolean getIsSuccess() {
|
||||
return (Boolean) get(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.involved_project_id</code>. ref
|
||||
* to project.id
|
||||
*/
|
||||
public void setInvolvedProjectId(Integer value) {
|
||||
set(9, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.involved_project_id</code>. ref
|
||||
* to project.id
|
||||
*/
|
||||
public Integer getInvolvedProjectId() {
|
||||
return (Integer) get(9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.involved_group_id</code>. ref to
|
||||
* group.id
|
||||
*/
|
||||
public void setInvolvedGroupId(Integer value) {
|
||||
set(10, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.involved_group_id</code>. ref to
|
||||
* group.id
|
||||
*/
|
||||
public Integer getInvolvedGroupId() {
|
||||
return (Integer) get(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.involved_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public void setInvolvedUserId(Integer value) {
|
||||
set(11, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.involved_user_id</code>. ref to
|
||||
* user.id
|
||||
*/
|
||||
public Integer getInvolvedUserId() {
|
||||
return (Integer) get(11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.operation_log.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime value) {
|
||||
set(12, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.operation_log.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return (LocalDateTime) get(12);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Record1<Long> key() {
|
||||
return (Record1) super.key();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Record13 type implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> fieldsRow() {
|
||||
return (Row13) super.fieldsRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Row13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> valuesRow() {
|
||||
return (Row13) super.valuesRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Long> field1() {
|
||||
return OperationLog.OPERATION_LOG.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field2() {
|
||||
return OperationLog.OPERATION_LOG.OPERATOR_USER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field3() {
|
||||
return OperationLog.OPERATION_LOG.OPERATOR_USERNAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field4() {
|
||||
return OperationLog.OPERATION_LOG.OPERATOR_NICKNAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field5() {
|
||||
return OperationLog.OPERATION_LOG.OPERATION_MODULE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field6() {
|
||||
return OperationLog.OPERATION_LOG.OPERATION_CODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field7() {
|
||||
return OperationLog.OPERATION_LOG.OPERATION_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<JSON> field8() {
|
||||
return OperationLog.OPERATION_LOG.OPERATION_RESPONSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Boolean> field9() {
|
||||
return OperationLog.OPERATION_LOG.IS_SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field10() {
|
||||
return OperationLog.OPERATION_LOG.INVOLVED_PROJECT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field11() {
|
||||
return OperationLog.OPERATION_LOG.INVOLVED_GROUP_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field12() {
|
||||
return OperationLog.OPERATION_LOG.INVOLVED_USER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<LocalDateTime> field13() {
|
||||
return OperationLog.OPERATION_LOG.CREATE_AT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long component1() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component2() {
|
||||
return getOperatorUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component3() {
|
||||
return getOperatorUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component4() {
|
||||
return getOperatorNickname();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component5() {
|
||||
return getOperationModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component6() {
|
||||
return getOperationCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component7() {
|
||||
return getOperationName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSON component8() {
|
||||
return getOperationResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean component9() {
|
||||
return getIsSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component10() {
|
||||
return getInvolvedProjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component11() {
|
||||
return getInvolvedGroupId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component12() {
|
||||
return getInvolvedUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime component13() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long value1() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value2() {
|
||||
return getOperatorUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value3() {
|
||||
return getOperatorUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value4() {
|
||||
return getOperatorNickname();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value5() {
|
||||
return getOperationModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value6() {
|
||||
return getOperationCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value7() {
|
||||
return getOperationName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSON value8() {
|
||||
return getOperationResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean value9() {
|
||||
return getIsSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value10() {
|
||||
return getInvolvedProjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value11() {
|
||||
return getInvolvedGroupId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value12() {
|
||||
return getInvolvedUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime value13() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value1(Long value) {
|
||||
setId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value2(Integer value) {
|
||||
setOperatorUserId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value3(String value) {
|
||||
setOperatorUsername(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value4(String value) {
|
||||
setOperatorNickname(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value5(String value) {
|
||||
setOperationModule(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value6(String value) {
|
||||
setOperationCode(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value7(String value) {
|
||||
setOperationName(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value8(JSON value) {
|
||||
setOperationResponse(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value9(Boolean value) {
|
||||
setIsSuccess(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value10(Integer value) {
|
||||
setInvolvedProjectId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value11(Integer value) {
|
||||
setInvolvedGroupId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value12(Integer value) {
|
||||
setInvolvedUserId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord value13(LocalDateTime value) {
|
||||
setCreateAt(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationLogRecord values(Long value1, Integer value2, String value3, String value4, String value5, String value6, String value7, JSON value8, Boolean value9, Integer value10, Integer value11, Integer value12, LocalDateTime value13) {
|
||||
value1(value1);
|
||||
value2(value2);
|
||||
value3(value3);
|
||||
value4(value4);
|
||||
value5(value5);
|
||||
value6(value6);
|
||||
value7(value7);
|
||||
value8(value8);
|
||||
value9(value9);
|
||||
value10(value10);
|
||||
value11(value11);
|
||||
value12(value12);
|
||||
value13(value13);
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached OperationLogRecord
|
||||
*/
|
||||
public OperationLogRecord() {
|
||||
super(OperationLog.OPERATION_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised OperationLogRecord
|
||||
*/
|
||||
public OperationLogRecord(Long id, Integer operatorUserId, String operatorUsername, String operatorNickname, String operationModule, String operationCode, String operationName, JSON operationResponse, Boolean isSuccess, Integer involvedProjectId, Integer involvedGroupId, Integer involvedUserId, LocalDateTime createAt) {
|
||||
super(OperationLog.OPERATION_LOG);
|
||||
|
||||
setId(id);
|
||||
setOperatorUserId(operatorUserId);
|
||||
setOperatorUsername(operatorUsername);
|
||||
setOperatorNickname(operatorNickname);
|
||||
setOperationModule(operationModule);
|
||||
setOperationCode(operationCode);
|
||||
setOperationName(operationName);
|
||||
setOperationResponse(operationResponse);
|
||||
setIsSuccess(isSuccess);
|
||||
setInvolvedProjectId(involvedProjectId);
|
||||
setInvolvedGroupId(involvedGroupId);
|
||||
setInvolvedUserId(involvedUserId);
|
||||
setCreateAt(createAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised OperationLogRecord
|
||||
*/
|
||||
public OperationLogRecord(OperationLogPojo value) {
|
||||
super(OperationLog.OPERATION_LOG);
|
||||
|
||||
if (value != null) {
|
||||
setId(value.getId());
|
||||
setOperatorUserId(value.getOperatorUserId());
|
||||
setOperatorUsername(value.getOperatorUsername());
|
||||
setOperatorNickname(value.getOperatorNickname());
|
||||
setOperationModule(value.getOperationModule());
|
||||
setOperationCode(value.getOperationCode());
|
||||
setOperationName(value.getOperationName());
|
||||
setOperationResponse(value.getOperationResponse());
|
||||
setIsSuccess(value.getIsSuccess());
|
||||
setInvolvedProjectId(value.getInvolvedProjectId());
|
||||
setInvolvedGroupId(value.getInvolvedGroupId());
|
||||
setInvolvedUserId(value.getInvolvedUserId());
|
||||
setCreateAt(value.getCreateAt());
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,72 +2,75 @@ package com.databasir.dao.impl;
|
||||
|
||||
|
||||
import com.databasir.dao.exception.DataNotExistsException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jooq.*;
|
||||
import org.jooq.Record;
|
||||
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.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class BaseDao<T extends Record, R> {
|
||||
public abstract class BaseDao<PO> {
|
||||
|
||||
private final Table<T> table;
|
||||
private final Table<?> table;
|
||||
|
||||
private final Class<R> pojoType;
|
||||
private final Class<PO> pojoType;
|
||||
|
||||
public BaseDao(Table<?> table, Class<PO> pojoType) {
|
||||
this.table = table;
|
||||
this.pojoType = pojoType;
|
||||
}
|
||||
|
||||
public abstract DSLContext getDslContext();
|
||||
|
||||
public boolean existsById(Integer id) {
|
||||
public <T extends Serializable> boolean existsById(T id) {
|
||||
return getDslContext().fetchExists(table, identity().eq(id));
|
||||
}
|
||||
|
||||
public Integer insertAndReturnId(R pojo) {
|
||||
T record = getDslContext().newRecord(table, pojo);
|
||||
public <T> T insertAndReturnId(PO pojo) {
|
||||
Record record = getDslContext().newRecord(table, pojo);
|
||||
UpdatableRecord<?> updatableRecord = (UpdatableRecord<?>) record;
|
||||
updatableRecord.store();
|
||||
Object value = updatableRecord.getValue(table.getIdentity().getField());
|
||||
return (Integer) value;
|
||||
return (T) identityType().cast(value);
|
||||
}
|
||||
|
||||
public int batchInsert(Collection<R> pojoList) {
|
||||
public int batchInsert(Collection<PO> pojoList) {
|
||||
List<TableRecord<?>> records = pojoList.stream()
|
||||
.map(pojo -> {
|
||||
T record = getDslContext().newRecord(table, pojo);
|
||||
Record record = getDslContext().newRecord(table, pojo);
|
||||
return (TableRecord<?>) record;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return Arrays.stream(getDslContext().batchInsert(records).execute()).sum();
|
||||
}
|
||||
|
||||
public int deleteById(Integer id) {
|
||||
public <T extends Serializable> int deleteById(T id) {
|
||||
return getDslContext()
|
||||
.deleteFrom(table).where(identity().eq(id))
|
||||
.execute();
|
||||
}
|
||||
|
||||
public int updateById(R pojo) {
|
||||
T record = getDslContext().newRecord(table, pojo);
|
||||
public int updateById(PO pojo) {
|
||||
Record record = getDslContext().newRecord(table, pojo);
|
||||
record.changed(table.getIdentity().getField(), false);
|
||||
return getDslContext().executeUpdate((UpdatableRecord<?>) record);
|
||||
}
|
||||
|
||||
public Optional<R> selectOptionalById(Integer id) {
|
||||
public <T extends Serializable> Optional<PO> selectOptionalById(T id) {
|
||||
return getDslContext()
|
||||
.select(table.fields()).from(table).where(identity().eq(id))
|
||||
.fetchOptionalInto(pojoType);
|
||||
}
|
||||
|
||||
public R selectById(Integer id) {
|
||||
public <T extends Serializable> PO selectById(T id) {
|
||||
return selectOptionalById(id)
|
||||
.orElseThrow(() -> new DataNotExistsException("data not exists in " + table.getName() + " with id = " + id));
|
||||
}
|
||||
|
||||
public List<R> selectInIds(List<Integer> ids) {
|
||||
public List<PO> selectInIds(List<? extends Serializable> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -77,12 +80,12 @@ public abstract class BaseDao<T extends Record, R> {
|
||||
.fetchInto(pojoType);
|
||||
}
|
||||
|
||||
public Page<R> selectByPage(Pageable request, Condition condition) {
|
||||
public Page<PO> selectByPage(Pageable request, Condition condition) {
|
||||
Integer count = getDslContext()
|
||||
.selectCount().from(table).where(condition)
|
||||
.fetchOne(0, int.class);
|
||||
int total = count == null ? 0 : count;
|
||||
List<R> data = getDslContext()
|
||||
List<PO> data = getDslContext()
|
||||
.selectFrom(table).where(condition)
|
||||
.orderBy(getSortFields(request.getSort()))
|
||||
.offset(request.getOffset()).limit(request.getPageSize())
|
||||
@@ -110,15 +113,19 @@ public abstract class BaseDao<T extends Record, R> {
|
||||
return querySortFields;
|
||||
}
|
||||
|
||||
protected Field<Integer> identity() {
|
||||
Identity<T, ?> identity = table.getIdentity();
|
||||
protected <T extends Serializable> Field<T> 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);
|
||||
return identity.getField().cast(identityType());
|
||||
}
|
||||
|
||||
protected Table<T> table() {
|
||||
protected <T extends Serializable> Class<T> identityType() {
|
||||
return (Class<T>) Integer.class;
|
||||
}
|
||||
|
||||
protected Table<?> table() {
|
||||
return this.table;
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ import static com.databasir.dao.Tables.DATA_SOURCE;
|
||||
|
||||
|
||||
@Repository
|
||||
public class DataSourceDao extends BaseDao<DataSourceRecord, DataSourcePojo> {
|
||||
public class DataSourceDao extends BaseDao<DataSourcePojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -13,7 +12,7 @@ import static com.databasir.dao.Tables.DATA_SOURCE_PROPERTY;
|
||||
|
||||
|
||||
@Repository
|
||||
public class DataSourcePropertyDao extends BaseDao<DataSourcePropertyRecord, DataSourcePropertyPojo> {
|
||||
public class DataSourcePropertyDao extends BaseDao<DataSourcePropertyPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -13,7 +13,7 @@ import static com.databasir.dao.Tables.DATABASE_DOCUMENT;
|
||||
|
||||
|
||||
@Repository
|
||||
public class DatabaseDocumentDao extends BaseDao<DatabaseDocumentRecord, DatabaseDocumentPojo> {
|
||||
public class DatabaseDocumentDao extends BaseDao<DatabaseDocumentPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.DatabaseDocumentHistoryPojo;
|
||||
import com.databasir.dao.tables.records.DatabaseDocumentHistoryRecord;
|
||||
import com.databasir.dao.value.DatabaseDocumentVersionPojo;
|
||||
import lombok.Getter;
|
||||
import org.jooq.Condition;
|
||||
@@ -19,7 +18,7 @@ import static com.databasir.dao.Tables.DATABASE_DOCUMENT_HISTORY;
|
||||
|
||||
|
||||
@Repository
|
||||
public class DatabaseDocumentHistoryDao extends BaseDao<DatabaseDocumentHistoryRecord, DatabaseDocumentHistoryPojo> {
|
||||
public class DatabaseDocumentHistoryDao extends BaseDao<DatabaseDocumentHistoryPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.DocumentRemarkPojo;
|
||||
import com.databasir.dao.tables.records.DocumentRemarkRecord;
|
||||
import lombok.Getter;
|
||||
import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,7 +12,7 @@ import static com.databasir.dao.Tables.DOCUMENT_REMARK;
|
||||
|
||||
|
||||
@Repository
|
||||
public class DocumentRemarkDao extends BaseDao<DocumentRemarkRecord, DocumentRemarkPojo> {
|
||||
public class DocumentRemarkDao extends BaseDao<DocumentRemarkPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -10,6 +9,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -17,7 +17,7 @@ import java.util.Optional;
|
||||
import static com.databasir.dao.Tables.GROUP;
|
||||
|
||||
@Repository
|
||||
public class GroupDao extends BaseDao<GroupRecord, GroupPojo> {
|
||||
public class GroupDao extends BaseDao<GroupPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
@@ -27,10 +27,11 @@ public class GroupDao extends BaseDao<GroupRecord, GroupPojo> {
|
||||
super(GROUP, GroupPojo.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteById(Integer id) {
|
||||
public <T extends Serializable> int deleteById(T id) {
|
||||
return dslContext
|
||||
.update(table()).set(GROUP.DELETED, true).where(GROUP.ID.eq(id))
|
||||
.update(table()).set(GROUP.DELETED, true).where(GROUP.ID.eq((Integer) id))
|
||||
.execute();
|
||||
}
|
||||
|
||||
@@ -40,14 +41,14 @@ public class GroupDao extends BaseDao<GroupRecord, GroupPojo> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GroupPojo> selectOptionalById(Integer id) {
|
||||
public <T extends Serializable> Optional<GroupPojo> selectOptionalById(T id) {
|
||||
return getDslContext()
|
||||
.select(GROUP.fields()).from(GROUP).where(GROUP.ID.eq(id).and(GROUP.DELETED.eq(false)))
|
||||
.select(GROUP.fields()).from(GROUP).where(GROUP.ID.eq((Integer) id).and(GROUP.DELETED.eq(false)))
|
||||
.fetchOptionalInto(GroupPojo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GroupPojo> selectInIds(List<Integer> ids) {
|
||||
public List<GroupPojo> selectInIds(List<? extends Serializable> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -14,7 +13,7 @@ import static com.databasir.dao.Tables.LOGIN;
|
||||
|
||||
|
||||
@Repository
|
||||
public class LoginDao extends BaseDao<LoginRecord, LoginPojo> {
|
||||
public class LoginDao extends BaseDao<LoginPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.OperationLogPojo;
|
||||
import lombok.Getter;
|
||||
import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static com.databasir.dao.Tables.OPERATION_LOG;
|
||||
|
||||
@Repository
|
||||
public class OperationLogDao extends BaseDao<OperationLogPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
private DSLContext dslContext;
|
||||
|
||||
public OperationLogDao() {
|
||||
super(OPERATION_LOG, OperationLogPojo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T extends Serializable> Class<T> identityType() {
|
||||
return (Class<T>) Long.class;
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -12,6 +11,7 @@ import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -22,7 +22,7 @@ import static com.databasir.dao.Tables.PROJECT;
|
||||
|
||||
|
||||
@Repository
|
||||
public class ProjectDao extends BaseDao<ProjectRecord, ProjectPojo> {
|
||||
public class ProjectDao extends BaseDao<ProjectPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
@@ -39,7 +39,7 @@ public class ProjectDao extends BaseDao<ProjectRecord, ProjectPojo> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ProjectPojo> selectOptionalById(Integer id) {
|
||||
public <T extends Serializable> Optional<ProjectPojo> selectOptionalById(T id) {
|
||||
return getDslContext()
|
||||
.select(PROJECT.fields()).from(PROJECT)
|
||||
.where(identity().eq(id).and(PROJECT.DELETED.eq(false)))
|
||||
@@ -47,7 +47,7 @@ public class ProjectDao extends BaseDao<ProjectRecord, ProjectPojo> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsById(Integer id) {
|
||||
public <T extends Serializable> boolean existsById(T id) {
|
||||
return getDslContext().fetchExists(table(), identity().eq(id).and(PROJECT.DELETED.eq(false)));
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ import java.util.Optional;
|
||||
import static com.databasir.dao.Tables.PROJECT_SYNC_RULE;
|
||||
|
||||
@Repository
|
||||
public class ProjectSyncRuleDao extends BaseDao<ProjectSyncRuleRecord, ProjectSyncRulePojo> {
|
||||
public class ProjectSyncRuleDao extends BaseDao<ProjectSyncRulePojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -13,7 +12,7 @@ import java.util.Optional;
|
||||
import static com.databasir.dao.Tables.SYS_KEY;
|
||||
|
||||
@Repository
|
||||
public class SysKeyDao extends BaseDao<SysKeyRecord, SysKeyPojo> {
|
||||
public class SysKeyDao extends BaseDao<SysKeyPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -13,7 +13,7 @@ import java.util.Optional;
|
||||
import static com.databasir.dao.Tables.SYS_MAIL;
|
||||
|
||||
@Repository
|
||||
public class SysMailDao extends BaseDao<SysMailRecord, SysMailPojo> {
|
||||
public class SysMailDao extends BaseDao<SysMailPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -13,7 +12,7 @@ import static com.databasir.dao.Tables.TABLE_COLUMN_DOCUMENT;
|
||||
|
||||
|
||||
@Repository
|
||||
public class TableColumnDocumentDao extends BaseDao<TableColumnDocumentRecord, TableColumnDocumentPojo> {
|
||||
public class TableColumnDocumentDao extends BaseDao<TableColumnDocumentPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
import static com.databasir.dao.Tables.TABLE_DOCUMENT;
|
||||
|
||||
@Repository
|
||||
public class TableDocumentDao extends BaseDao<TableDocumentRecord, TableDocumentPojo> {
|
||||
public class TableDocumentDao extends BaseDao<TableDocumentPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -13,7 +12,7 @@ import static com.databasir.dao.Tables.TABLE_INDEX_DOCUMENT;
|
||||
|
||||
|
||||
@Repository
|
||||
public class TableIndexDocumentDao extends BaseDao<TableIndexDocumentRecord, TableIndexDocumentPojo> {
|
||||
public class TableIndexDocumentDao extends BaseDao<TableIndexDocumentPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -12,7 +11,7 @@ import java.util.List;
|
||||
import static com.databasir.dao.Tables.TABLE_TRIGGER_DOCUMENT;
|
||||
|
||||
@Repository
|
||||
public class TableTriggerDocumentDao extends BaseDao<TableTriggerDocumentRecord, TableTriggerDocumentPojo> {
|
||||
public class TableTriggerDocumentDao extends BaseDao<TableTriggerDocumentPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -23,7 +22,7 @@ import static com.databasir.dao.Tables.USER_ROLE;
|
||||
|
||||
|
||||
@Repository
|
||||
public class UserDao extends BaseDao<UserRecord, UserPojo> {
|
||||
public class UserDao extends BaseDao<UserPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -19,7 +18,7 @@ import static com.databasir.dao.Tables.USER_ROLE;
|
||||
|
||||
|
||||
@Repository
|
||||
public class UserRoleDao extends BaseDao<UserRoleRecord, UserRolePojo> {
|
||||
public class UserRoleDao extends BaseDao<UserRolePojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
|
18
dao/src/main/resources/db/migration/V1.2__operation_log.sql
Normal file
18
dao/src/main/resources/db/migration/V1.2__operation_log.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE operation_log
|
||||
(
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL,
|
||||
|
||||
operator_user_id INT NOT NULL COMMENT 'ref to user.id',
|
||||
operator_username VARCHAR(128) NOT NULL COMMENT 'user.username',
|
||||
operator_nickname VARCHAR(255) NOT NULL COMMENT 'user.nickname',
|
||||
operation_module VARCHAR(128) NOT NULL,
|
||||
operation_code VARCHAR(255) NOT NULL,
|
||||
operation_name VARCHAR(255) NOT NULL,
|
||||
operation_response JSON NOT NULL,
|
||||
is_success BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
involved_project_id INT DEFAULT NULL COMMENT 'ref to project.id',
|
||||
involved_group_id INT DEFAULT NULL COMMENT 'ref to group.id',
|
||||
involved_user_id INT DEFAULT NULL COMMENT 'ref to user.id',
|
||||
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) CHARSET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
Reference in New Issue
Block a user