mirror of
https://github.com/vran-dev/databasir.git
synced 2025-08-08 21:32:16 +08:00
Feature/favorite project (#25)
* feat: add project favorite api * feat:update frontend resources
This commit is contained in:
@@ -21,6 +21,7 @@ import com.databasir.dao.tables.TableDocument;
|
||||
import com.databasir.dao.tables.TableIndexDocument;
|
||||
import com.databasir.dao.tables.TableTriggerDocument;
|
||||
import com.databasir.dao.tables.User;
|
||||
import com.databasir.dao.tables.UserFavoriteProject;
|
||||
import com.databasir.dao.tables.UserRole;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -129,6 +130,11 @@ public class Databasir extends SchemaImpl {
|
||||
*/
|
||||
public final User USER = User.USER;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.user_favorite_project</code>.
|
||||
*/
|
||||
public final UserFavoriteProject USER_FAVORITE_PROJECT = UserFavoriteProject.USER_FAVORITE_PROJECT;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.user_role</code>.
|
||||
*/
|
||||
@@ -167,6 +173,7 @@ public class Databasir extends SchemaImpl {
|
||||
TableIndexDocument.TABLE_INDEX_DOCUMENT,
|
||||
TableTriggerDocument.TABLE_TRIGGER_DOCUMENT,
|
||||
User.USER,
|
||||
UserFavoriteProject.USER_FAVORITE_PROJECT,
|
||||
UserRole.USER_ROLE
|
||||
);
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import com.databasir.dao.tables.TableColumnDocument;
|
||||
import com.databasir.dao.tables.TableDocument;
|
||||
import com.databasir.dao.tables.TableIndexDocument;
|
||||
import com.databasir.dao.tables.TableTriggerDocument;
|
||||
import com.databasir.dao.tables.UserFavoriteProject;
|
||||
|
||||
import org.jooq.Index;
|
||||
import org.jooq.OrderField;
|
||||
@@ -38,4 +39,5 @@ public class Indexes {
|
||||
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);
|
||||
public static final Index USER_FAVORITE_PROJECT_IDX_USER_ID = Internal.createIndex(DSL.name("idx_user_id"), UserFavoriteProject.USER_FAVORITE_PROJECT, new OrderField[] { UserFavoriteProject.USER_FAVORITE_PROJECT.USER_ID }, false);
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import com.databasir.dao.tables.TableDocument;
|
||||
import com.databasir.dao.tables.TableIndexDocument;
|
||||
import com.databasir.dao.tables.TableTriggerDocument;
|
||||
import com.databasir.dao.tables.User;
|
||||
import com.databasir.dao.tables.UserFavoriteProject;
|
||||
import com.databasir.dao.tables.UserRole;
|
||||
import com.databasir.dao.tables.records.DataSourcePropertyRecord;
|
||||
import com.databasir.dao.tables.records.DataSourceRecord;
|
||||
@@ -38,6 +39,7 @@ import com.databasir.dao.tables.records.TableColumnDocumentRecord;
|
||||
import com.databasir.dao.tables.records.TableDocumentRecord;
|
||||
import com.databasir.dao.tables.records.TableIndexDocumentRecord;
|
||||
import com.databasir.dao.tables.records.TableTriggerDocumentRecord;
|
||||
import com.databasir.dao.tables.records.UserFavoriteProjectRecord;
|
||||
import com.databasir.dao.tables.records.UserRecord;
|
||||
import com.databasir.dao.tables.records.UserRoleRecord;
|
||||
|
||||
@@ -83,6 +85,7 @@ public class Keys {
|
||||
public static final UniqueKey<UserRecord> KEY_USER_PRIMARY = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_PRIMARY"), new TableField[] { User.USER.ID }, true);
|
||||
public static final UniqueKey<UserRecord> KEY_USER_UK_EMAIL = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_uk_email"), new TableField[] { User.USER.EMAIL }, true);
|
||||
public static final UniqueKey<UserRecord> KEY_USER_UK_USERNAME = Internal.createUniqueKey(User.USER, DSL.name("KEY_user_uk_username"), new TableField[] { User.USER.USERNAME }, true);
|
||||
public static final UniqueKey<UserFavoriteProjectRecord> KEY_USER_FAVORITE_PROJECT_PRIMARY = Internal.createUniqueKey(UserFavoriteProject.USER_FAVORITE_PROJECT, DSL.name("KEY_user_favorite_project_PRIMARY"), new TableField[] { UserFavoriteProject.USER_FAVORITE_PROJECT.ID }, true);
|
||||
public static final UniqueKey<UserRoleRecord> KEY_USER_ROLE_PRIMARY = Internal.createUniqueKey(UserRole.USER_ROLE, DSL.name("KEY_user_role_PRIMARY"), new TableField[] { UserRole.USER_ROLE.ID }, true);
|
||||
public static final UniqueKey<UserRoleRecord> KEY_USER_ROLE_UK_USER_ID_GROUP_ID_ROLE = Internal.createUniqueKey(UserRole.USER_ROLE, DSL.name("KEY_user_role_uk_user_id_group_id_role"), new TableField[] { UserRole.USER_ROLE.USER_ID, UserRole.USER_ROLE.GROUP_ID, UserRole.USER_ROLE.ROLE }, true);
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import com.databasir.dao.tables.TableDocument;
|
||||
import com.databasir.dao.tables.TableIndexDocument;
|
||||
import com.databasir.dao.tables.TableTriggerDocument;
|
||||
import com.databasir.dao.tables.User;
|
||||
import com.databasir.dao.tables.UserFavoriteProject;
|
||||
import com.databasir.dao.tables.UserRole;
|
||||
|
||||
|
||||
@@ -115,6 +116,11 @@ public class Tables {
|
||||
*/
|
||||
public static final User USER = User.USER;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.user_favorite_project</code>.
|
||||
*/
|
||||
public static final UserFavoriteProject USER_FAVORITE_PROJECT = UserFavoriteProject.USER_FAVORITE_PROJECT;
|
||||
|
||||
/**
|
||||
* The table <code>databasir.user_role</code>.
|
||||
*/
|
||||
|
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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.UserFavoriteProjectRecord;
|
||||
|
||||
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.Row4;
|
||||
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 UserFavoriteProject extends TableImpl<UserFavoriteProjectRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The reference instance of <code>databasir.user_favorite_project</code>
|
||||
*/
|
||||
public static final UserFavoriteProject USER_FAVORITE_PROJECT = new UserFavoriteProject();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public Class<UserFavoriteProjectRecord> getRecordType() {
|
||||
return UserFavoriteProjectRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>databasir.user_favorite_project.id</code>.
|
||||
*/
|
||||
public final TableField<UserFavoriteProjectRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.user_favorite_project.user_id</code>.
|
||||
*/
|
||||
public final TableField<UserFavoriteProjectRecord, Integer> USER_ID = createField(DSL.name("user_id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.user_favorite_project.project_id</code>.
|
||||
*/
|
||||
public final TableField<UserFavoriteProjectRecord, Integer> PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.user_favorite_project.create_at</code>.
|
||||
*/
|
||||
public final TableField<UserFavoriteProjectRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
|
||||
|
||||
private UserFavoriteProject(Name alias, Table<UserFavoriteProjectRecord> aliased) {
|
||||
this(alias, aliased, null);
|
||||
}
|
||||
|
||||
private UserFavoriteProject(Name alias, Table<UserFavoriteProjectRecord> aliased, Field<?>[] parameters) {
|
||||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.user_favorite_project</code> table
|
||||
* reference
|
||||
*/
|
||||
public UserFavoriteProject(String alias) {
|
||||
this(DSL.name(alias), USER_FAVORITE_PROJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>databasir.user_favorite_project</code> table
|
||||
* reference
|
||||
*/
|
||||
public UserFavoriteProject(Name alias) {
|
||||
this(alias, USER_FAVORITE_PROJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>databasir.user_favorite_project</code> table reference
|
||||
*/
|
||||
public UserFavoriteProject() {
|
||||
this(DSL.name("user_favorite_project"), null);
|
||||
}
|
||||
|
||||
public <O extends Record> UserFavoriteProject(Table<O> child, ForeignKey<O, UserFavoriteProjectRecord> key) {
|
||||
super(child, key, USER_FAVORITE_PROJECT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema getSchema() {
|
||||
return aliased() ? null : Databasir.DATABASIR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Index> getIndexes() {
|
||||
return Arrays.asList(Indexes.USER_FAVORITE_PROJECT_IDX_USER_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identity<UserFavoriteProjectRecord, Integer> getIdentity() {
|
||||
return (Identity<UserFavoriteProjectRecord, Integer>) super.getIdentity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueKey<UserFavoriteProjectRecord> getPrimaryKey() {
|
||||
return Keys.KEY_USER_FAVORITE_PROJECT_PRIMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProject as(String alias) {
|
||||
return new UserFavoriteProject(DSL.name(alias), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProject as(Name alias) {
|
||||
return new UserFavoriteProject(alias, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public UserFavoriteProject rename(String name) {
|
||||
return new UserFavoriteProject(DSL.name(name), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
@Override
|
||||
public UserFavoriteProject rename(Name name) {
|
||||
return new UserFavoriteProject(name, null);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Row4 type methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row4<Integer, Integer, Integer, LocalDateTime> fieldsRow() {
|
||||
return (Row4) super.fieldsRow();
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.databasir.dao.tables.pojos;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class UserFavoriteProjectPojo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer userId;
|
||||
private Integer projectId;
|
||||
private LocalDateTime createAt;
|
||||
|
||||
public UserFavoriteProjectPojo() {}
|
||||
|
||||
public UserFavoriteProjectPojo(UserFavoriteProjectPojo value) {
|
||||
this.id = value.id;
|
||||
this.userId = value.userId;
|
||||
this.projectId = value.projectId;
|
||||
this.createAt = value.createAt;
|
||||
}
|
||||
|
||||
public UserFavoriteProjectPojo(
|
||||
Integer id,
|
||||
Integer userId,
|
||||
Integer projectId,
|
||||
LocalDateTime createAt
|
||||
) {
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
this.projectId = projectId;
|
||||
this.createAt = createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.id</code>.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.user_id</code>.
|
||||
*/
|
||||
public Integer getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.user_id</code>.
|
||||
*/
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.project_id</code>.
|
||||
*/
|
||||
public Integer getProjectId() {
|
||||
return this.projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.project_id</code>.
|
||||
*/
|
||||
public void setProjectId(Integer projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return this.createAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime createAt) {
|
||||
this.createAt = createAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("UserFavoriteProjectPojo (");
|
||||
|
||||
sb.append(id);
|
||||
sb.append(", ").append(userId);
|
||||
sb.append(", ").append(projectId);
|
||||
sb.append(", ").append(createAt);
|
||||
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* This file is generated by jOOQ.
|
||||
*/
|
||||
package com.databasir.dao.tables.records;
|
||||
|
||||
|
||||
import com.databasir.dao.tables.UserFavoriteProject;
|
||||
import com.databasir.dao.tables.pojos.UserFavoriteProjectPojo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Record4;
|
||||
import org.jooq.Row4;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class UserFavoriteProjectRecord extends UpdatableRecordImpl<UserFavoriteProjectRecord> implements Record4<Integer, Integer, Integer, LocalDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.id</code>.
|
||||
*/
|
||||
public void setId(Integer value) {
|
||||
set(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.id</code>.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return (Integer) get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.user_id</code>.
|
||||
*/
|
||||
public void setUserId(Integer value) {
|
||||
set(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.user_id</code>.
|
||||
*/
|
||||
public Integer getUserId() {
|
||||
return (Integer) get(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.project_id</code>.
|
||||
*/
|
||||
public void setProjectId(Integer value) {
|
||||
set(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.project_id</code>.
|
||||
*/
|
||||
public Integer getProjectId() {
|
||||
return (Integer) get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.user_favorite_project.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime value) {
|
||||
set(3, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.user_favorite_project.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return (LocalDateTime) get(3);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Record1<Integer> key() {
|
||||
return (Record1) super.key();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Record4 type implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row4<Integer, Integer, Integer, LocalDateTime> fieldsRow() {
|
||||
return (Row4) super.fieldsRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Row4<Integer, Integer, Integer, LocalDateTime> valuesRow() {
|
||||
return (Row4) super.valuesRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field1() {
|
||||
return UserFavoriteProject.USER_FAVORITE_PROJECT.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field2() {
|
||||
return UserFavoriteProject.USER_FAVORITE_PROJECT.USER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Integer> field3() {
|
||||
return UserFavoriteProject.USER_FAVORITE_PROJECT.PROJECT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<LocalDateTime> field4() {
|
||||
return UserFavoriteProject.USER_FAVORITE_PROJECT.CREATE_AT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component1() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component2() {
|
||||
return getUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer component3() {
|
||||
return getProjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime component4() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value1() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value2() {
|
||||
return getUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer value3() {
|
||||
return getProjectId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime value4() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProjectRecord value1(Integer value) {
|
||||
setId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProjectRecord value2(Integer value) {
|
||||
setUserId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProjectRecord value3(Integer value) {
|
||||
setProjectId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProjectRecord value4(LocalDateTime value) {
|
||||
setCreateAt(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserFavoriteProjectRecord values(Integer value1, Integer value2, Integer value3, LocalDateTime value4) {
|
||||
value1(value1);
|
||||
value2(value2);
|
||||
value3(value3);
|
||||
value4(value4);
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached UserFavoriteProjectRecord
|
||||
*/
|
||||
public UserFavoriteProjectRecord() {
|
||||
super(UserFavoriteProject.USER_FAVORITE_PROJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised UserFavoriteProjectRecord
|
||||
*/
|
||||
public UserFavoriteProjectRecord(Integer id, Integer userId, Integer projectId, LocalDateTime createAt) {
|
||||
super(UserFavoriteProject.USER_FAVORITE_PROJECT);
|
||||
|
||||
setId(id);
|
||||
setUserId(userId);
|
||||
setProjectId(projectId);
|
||||
setCreateAt(createAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised UserFavoriteProjectRecord
|
||||
*/
|
||||
public UserFavoriteProjectRecord(UserFavoriteProjectPojo value) {
|
||||
super(UserFavoriteProject.USER_FAVORITE_PROJECT);
|
||||
|
||||
if (value != null) {
|
||||
setId(value.getId());
|
||||
setUserId(value.getUserId());
|
||||
setProjectId(value.getProjectId());
|
||||
setCreateAt(value.getCreateAt());
|
||||
}
|
||||
}
|
||||
}
|
@@ -28,6 +28,10 @@ public abstract class BaseDao<R> {
|
||||
return getDslContext().fetchExists(table, identity().eq(id));
|
||||
}
|
||||
|
||||
public boolean exists(Condition condition) {
|
||||
return getDslContext().fetchExists(table, condition);
|
||||
}
|
||||
|
||||
public <T> T insertAndReturnId(R pojo) {
|
||||
Record record = getDslContext().newRecord(table, pojo);
|
||||
UpdatableRecord<?> updatableRecord = (UpdatableRecord<?>) record;
|
||||
@@ -46,6 +50,12 @@ public abstract class BaseDao<R> {
|
||||
return Arrays.stream(getDslContext().batchInsert(records).execute()).sum();
|
||||
}
|
||||
|
||||
public int delete(Condition condition) {
|
||||
return getDslContext()
|
||||
.deleteFrom(table).where(condition)
|
||||
.execute();
|
||||
}
|
||||
|
||||
public <T extends Serializable> int deleteById(T id) {
|
||||
return getDslContext()
|
||||
.deleteFrom(table).where(identity().eq(id))
|
||||
|
@@ -0,0 +1,62 @@
|
||||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.UserFavoriteProjectPojo;
|
||||
import lombok.Getter;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.databasir.dao.Tables.*;
|
||||
|
||||
@Repository
|
||||
public class UserFavoriteProjectDao extends BaseDao<UserFavoriteProjectPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
private DSLContext dslContext;
|
||||
|
||||
public UserFavoriteProjectDao() {
|
||||
super(USER_FAVORITE_PROJECT, UserFavoriteProjectPojo.class);
|
||||
}
|
||||
|
||||
public boolean exists(Integer userId, Integer projectId) {
|
||||
return exists(USER_FAVORITE_PROJECT.USER_ID.eq(userId)
|
||||
.and(USER_FAVORITE_PROJECT.PROJECT_ID.eq(projectId)));
|
||||
}
|
||||
|
||||
public void insert(Integer userId, Integer projectId) {
|
||||
UserFavoriteProjectPojo pojo = new UserFavoriteProjectPojo();
|
||||
pojo.setUserId(userId);
|
||||
pojo.setProjectId(projectId);
|
||||
this.insertAndReturnId(pojo);
|
||||
}
|
||||
|
||||
public void delete(Integer userId, Integer projectId) {
|
||||
this.delete(USER_FAVORITE_PROJECT.USER_ID.eq(userId)
|
||||
.and(USER_FAVORITE_PROJECT.PROJECT_ID.eq(projectId)));
|
||||
}
|
||||
|
||||
public Page<UserFavoriteProjectPojo> selectByCondition(Pageable request, Condition condition) {
|
||||
int total = getDslContext()
|
||||
.selectCount().from(USER_FAVORITE_PROJECT)
|
||||
.innerJoin(USER).on(USER.ID.eq(USER_FAVORITE_PROJECT.USER_ID))
|
||||
.innerJoin(PROJECT).on(PROJECT.ID.eq(USER_FAVORITE_PROJECT.PROJECT_ID))
|
||||
.where(PROJECT.DELETED.eq(false).and(condition))
|
||||
.fetchOne(0, int.class);
|
||||
List<UserFavoriteProjectPojo> data = getDslContext()
|
||||
.select(USER_FAVORITE_PROJECT.fields()).from(USER_FAVORITE_PROJECT)
|
||||
.innerJoin(USER).on(USER.ID.eq(USER_FAVORITE_PROJECT.USER_ID))
|
||||
.innerJoin(PROJECT).on(PROJECT.ID.eq(USER_FAVORITE_PROJECT.PROJECT_ID))
|
||||
.where(PROJECT.DELETED.eq(false).and(condition))
|
||||
.orderBy(getSortFields(request.getSort()))
|
||||
.offset(request.getOffset()).limit(request.getPageSize())
|
||||
.fetchInto(UserFavoriteProjectPojo.class);
|
||||
return new PageImpl<>(data, request, total);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS user_favorite_project
|
||||
(
|
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
user_id INT NOT NULL,
|
||||
project_id INT NOT NULL,
|
||||
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE uk_user_id_project_id (user_id, project_id)
|
||||
) CHARSET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
Reference in New Issue
Block a user