feat: community RPC 从内存存储迁移到 ent 数据库

This commit is contained in:
zetaloop
2026-04-24 08:16:31 +08:00
parent 5ad579f03c
commit 6cc14479c5
69 changed files with 14396 additions and 501 deletions
@@ -0,0 +1,96 @@
// Code generated by ent, DO NOT EDIT.
package comments
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the comments type in the database.
Label = "comments"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldPostID holds the string denoting the post_id field in the database.
FieldPostID = "post_id"
// FieldAuthorID holds the string denoting the author_id field in the database.
FieldAuthorID = "author_id"
// FieldContent holds the string denoting the content field in the database.
FieldContent = "content"
// FieldLikeCount holds the string denoting the like_count field in the database.
FieldLikeCount = "like_count"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// Table holds the table name of the comments in the database.
Table = "comments"
)
// Columns holds all SQL columns for comments fields.
var Columns = []string{
FieldID,
FieldPostID,
FieldAuthorID,
FieldContent,
FieldLikeCount,
FieldCreatedAt,
FieldDeletedAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultLikeCount holds the default value on creation for the "like_count" field.
DefaultLikeCount int
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the Comments queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByPostID orders the results by the post_id field.
func ByPostID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPostID, opts...).ToFunc()
}
// ByAuthorID orders the results by the author_id field.
func ByAuthorID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAuthorID, opts...).ToFunc()
}
// ByContent orders the results by the content field.
func ByContent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldContent, opts...).ToFunc()
}
// ByLikeCount orders the results by the like_count field.
func ByLikeCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLikeCount, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
@@ -0,0 +1,385 @@
// Code generated by ent, DO NOT EDIT.
package comments
import (
"juwan-backend/app/community/rpc/internal/models/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldID, id))
}
// PostID applies equality check predicate on the "post_id" field. It's identical to PostIDEQ.
func PostID(v int64) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldPostID, v))
}
// AuthorID applies equality check predicate on the "author_id" field. It's identical to AuthorIDEQ.
func AuthorID(v int64) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldAuthorID, v))
}
// Content applies equality check predicate on the "content" field. It's identical to ContentEQ.
func Content(v string) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldContent, v))
}
// LikeCount applies equality check predicate on the "like_count" field. It's identical to LikeCountEQ.
func LikeCount(v int) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldLikeCount, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldCreatedAt, v))
}
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
func DeletedAt(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldDeletedAt, v))
}
// PostIDEQ applies the EQ predicate on the "post_id" field.
func PostIDEQ(v int64) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldPostID, v))
}
// PostIDNEQ applies the NEQ predicate on the "post_id" field.
func PostIDNEQ(v int64) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldPostID, v))
}
// PostIDIn applies the In predicate on the "post_id" field.
func PostIDIn(vs ...int64) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldPostID, vs...))
}
// PostIDNotIn applies the NotIn predicate on the "post_id" field.
func PostIDNotIn(vs ...int64) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldPostID, vs...))
}
// PostIDGT applies the GT predicate on the "post_id" field.
func PostIDGT(v int64) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldPostID, v))
}
// PostIDGTE applies the GTE predicate on the "post_id" field.
func PostIDGTE(v int64) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldPostID, v))
}
// PostIDLT applies the LT predicate on the "post_id" field.
func PostIDLT(v int64) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldPostID, v))
}
// PostIDLTE applies the LTE predicate on the "post_id" field.
func PostIDLTE(v int64) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldPostID, v))
}
// AuthorIDEQ applies the EQ predicate on the "author_id" field.
func AuthorIDEQ(v int64) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldAuthorID, v))
}
// AuthorIDNEQ applies the NEQ predicate on the "author_id" field.
func AuthorIDNEQ(v int64) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldAuthorID, v))
}
// AuthorIDIn applies the In predicate on the "author_id" field.
func AuthorIDIn(vs ...int64) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldAuthorID, vs...))
}
// AuthorIDNotIn applies the NotIn predicate on the "author_id" field.
func AuthorIDNotIn(vs ...int64) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldAuthorID, vs...))
}
// AuthorIDGT applies the GT predicate on the "author_id" field.
func AuthorIDGT(v int64) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldAuthorID, v))
}
// AuthorIDGTE applies the GTE predicate on the "author_id" field.
func AuthorIDGTE(v int64) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldAuthorID, v))
}
// AuthorIDLT applies the LT predicate on the "author_id" field.
func AuthorIDLT(v int64) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldAuthorID, v))
}
// AuthorIDLTE applies the LTE predicate on the "author_id" field.
func AuthorIDLTE(v int64) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldAuthorID, v))
}
// ContentEQ applies the EQ predicate on the "content" field.
func ContentEQ(v string) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldContent, v))
}
// ContentNEQ applies the NEQ predicate on the "content" field.
func ContentNEQ(v string) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldContent, v))
}
// ContentIn applies the In predicate on the "content" field.
func ContentIn(vs ...string) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldContent, vs...))
}
// ContentNotIn applies the NotIn predicate on the "content" field.
func ContentNotIn(vs ...string) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldContent, vs...))
}
// ContentGT applies the GT predicate on the "content" field.
func ContentGT(v string) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldContent, v))
}
// ContentGTE applies the GTE predicate on the "content" field.
func ContentGTE(v string) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldContent, v))
}
// ContentLT applies the LT predicate on the "content" field.
func ContentLT(v string) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldContent, v))
}
// ContentLTE applies the LTE predicate on the "content" field.
func ContentLTE(v string) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldContent, v))
}
// ContentContains applies the Contains predicate on the "content" field.
func ContentContains(v string) predicate.Comments {
return predicate.Comments(sql.FieldContains(FieldContent, v))
}
// ContentHasPrefix applies the HasPrefix predicate on the "content" field.
func ContentHasPrefix(v string) predicate.Comments {
return predicate.Comments(sql.FieldHasPrefix(FieldContent, v))
}
// ContentHasSuffix applies the HasSuffix predicate on the "content" field.
func ContentHasSuffix(v string) predicate.Comments {
return predicate.Comments(sql.FieldHasSuffix(FieldContent, v))
}
// ContentEqualFold applies the EqualFold predicate on the "content" field.
func ContentEqualFold(v string) predicate.Comments {
return predicate.Comments(sql.FieldEqualFold(FieldContent, v))
}
// ContentContainsFold applies the ContainsFold predicate on the "content" field.
func ContentContainsFold(v string) predicate.Comments {
return predicate.Comments(sql.FieldContainsFold(FieldContent, v))
}
// LikeCountEQ applies the EQ predicate on the "like_count" field.
func LikeCountEQ(v int) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldLikeCount, v))
}
// LikeCountNEQ applies the NEQ predicate on the "like_count" field.
func LikeCountNEQ(v int) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldLikeCount, v))
}
// LikeCountIn applies the In predicate on the "like_count" field.
func LikeCountIn(vs ...int) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldLikeCount, vs...))
}
// LikeCountNotIn applies the NotIn predicate on the "like_count" field.
func LikeCountNotIn(vs ...int) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldLikeCount, vs...))
}
// LikeCountGT applies the GT predicate on the "like_count" field.
func LikeCountGT(v int) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldLikeCount, v))
}
// LikeCountGTE applies the GTE predicate on the "like_count" field.
func LikeCountGTE(v int) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldLikeCount, v))
}
// LikeCountLT applies the LT predicate on the "like_count" field.
func LikeCountLT(v int) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldLikeCount, v))
}
// LikeCountLTE applies the LTE predicate on the "like_count" field.
func LikeCountLTE(v int) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldLikeCount, v))
}
// LikeCountIsNil applies the IsNil predicate on the "like_count" field.
func LikeCountIsNil() predicate.Comments {
return predicate.Comments(sql.FieldIsNull(FieldLikeCount))
}
// LikeCountNotNil applies the NotNil predicate on the "like_count" field.
func LikeCountNotNil() predicate.Comments {
return predicate.Comments(sql.FieldNotNull(FieldLikeCount))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldCreatedAt, v))
}
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
func DeletedAtEQ(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldEQ(FieldDeletedAt, v))
}
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
func DeletedAtNEQ(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldNEQ(FieldDeletedAt, v))
}
// DeletedAtIn applies the In predicate on the "deleted_at" field.
func DeletedAtIn(vs ...time.Time) predicate.Comments {
return predicate.Comments(sql.FieldIn(FieldDeletedAt, vs...))
}
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
func DeletedAtNotIn(vs ...time.Time) predicate.Comments {
return predicate.Comments(sql.FieldNotIn(FieldDeletedAt, vs...))
}
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
func DeletedAtGT(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldGT(FieldDeletedAt, v))
}
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
func DeletedAtGTE(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldGTE(FieldDeletedAt, v))
}
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
func DeletedAtLT(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldLT(FieldDeletedAt, v))
}
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
func DeletedAtLTE(v time.Time) predicate.Comments {
return predicate.Comments(sql.FieldLTE(FieldDeletedAt, v))
}
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
func DeletedAtIsNil() predicate.Comments {
return predicate.Comments(sql.FieldIsNull(FieldDeletedAt))
}
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
func DeletedAtNotNil() predicate.Comments {
return predicate.Comments(sql.FieldNotNull(FieldDeletedAt))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Comments) predicate.Comments {
return predicate.Comments(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Comments) predicate.Comments {
return predicate.Comments(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.Comments) predicate.Comments {
return predicate.Comments(sql.NotPredicates(p))
}