feat: 添加通知微服务,支持站内通知已读状态

This commit is contained in:
zetaloop
2026-04-24 12:44:59 +08:00
parent 95f2f10f9f
commit b557bfcc2e
52 changed files with 7035 additions and 30 deletions
@@ -0,0 +1,122 @@
// Code generated by ent, DO NOT EDIT.
package notifications
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the notifications type in the database.
Label = "notifications"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldTitle holds the string denoting the title field in the database.
FieldTitle = "title"
// FieldContent holds the string denoting the content field in the database.
FieldContent = "content"
// FieldRead holds the string denoting the read field in the database.
FieldRead = "read"
// FieldLink holds the string denoting the link field in the database.
FieldLink = "link"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// Table holds the table name of the notifications in the database.
Table = "notifications"
)
// Columns holds all SQL columns for notifications fields.
var Columns = []string{
FieldID,
FieldUserID,
FieldType,
FieldTitle,
FieldContent,
FieldRead,
FieldLink,
FieldCreatedAt,
FieldUpdatedAt,
}
// 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 (
// TypeValidator is a validator for the "type" field. It is called by the builders before save.
TypeValidator func(string) error
// TitleValidator is a validator for the "title" field. It is called by the builders before save.
TitleValidator func(string) error
// DefaultRead holds the default value on creation for the "read" field.
DefaultRead bool
// LinkValidator is a validator for the "link" field. It is called by the builders before save.
LinkValidator func(string) error
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
)
// OrderOption defines the ordering options for the Notifications 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()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByTitle orders the results by the title field.
func ByTitle(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTitle, opts...).ToFunc()
}
// ByContent orders the results by the content field.
func ByContent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldContent, opts...).ToFunc()
}
// ByRead orders the results by the read field.
func ByRead(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRead, opts...).ToFunc()
}
// ByLink orders the results by the link field.
func ByLink(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLink, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
@@ -0,0 +1,510 @@
// Code generated by ent, DO NOT EDIT.
package notifications
import (
"juwan-backend/app/notification/rpc/internal/models/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldID, id))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldUserID, v))
}
// Type applies equality check predicate on the "type" field. It's identical to TypeEQ.
func Type(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldType, v))
}
// Title applies equality check predicate on the "title" field. It's identical to TitleEQ.
func Title(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldTitle, v))
}
// Content applies equality check predicate on the "content" field. It's identical to ContentEQ.
func Content(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldContent, v))
}
// Read applies equality check predicate on the "read" field. It's identical to ReadEQ.
func Read(v bool) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldRead, v))
}
// Link applies equality check predicate on the "link" field. It's identical to LinkEQ.
func Link(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldLink, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldUpdatedAt, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v int64) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldUserID, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldType, vs...))
}
// TypeGT applies the GT predicate on the "type" field.
func TypeGT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldType, v))
}
// TypeGTE applies the GTE predicate on the "type" field.
func TypeGTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldType, v))
}
// TypeLT applies the LT predicate on the "type" field.
func TypeLT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldType, v))
}
// TypeLTE applies the LTE predicate on the "type" field.
func TypeLTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldType, v))
}
// TypeContains applies the Contains predicate on the "type" field.
func TypeContains(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContains(FieldType, v))
}
// TypeHasPrefix applies the HasPrefix predicate on the "type" field.
func TypeHasPrefix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasPrefix(FieldType, v))
}
// TypeHasSuffix applies the HasSuffix predicate on the "type" field.
func TypeHasSuffix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasSuffix(FieldType, v))
}
// TypeEqualFold applies the EqualFold predicate on the "type" field.
func TypeEqualFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEqualFold(FieldType, v))
}
// TypeContainsFold applies the ContainsFold predicate on the "type" field.
func TypeContainsFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContainsFold(FieldType, v))
}
// TitleEQ applies the EQ predicate on the "title" field.
func TitleEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldTitle, v))
}
// TitleNEQ applies the NEQ predicate on the "title" field.
func TitleNEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldTitle, v))
}
// TitleIn applies the In predicate on the "title" field.
func TitleIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldTitle, vs...))
}
// TitleNotIn applies the NotIn predicate on the "title" field.
func TitleNotIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldTitle, vs...))
}
// TitleGT applies the GT predicate on the "title" field.
func TitleGT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldTitle, v))
}
// TitleGTE applies the GTE predicate on the "title" field.
func TitleGTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldTitle, v))
}
// TitleLT applies the LT predicate on the "title" field.
func TitleLT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldTitle, v))
}
// TitleLTE applies the LTE predicate on the "title" field.
func TitleLTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldTitle, v))
}
// TitleContains applies the Contains predicate on the "title" field.
func TitleContains(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContains(FieldTitle, v))
}
// TitleHasPrefix applies the HasPrefix predicate on the "title" field.
func TitleHasPrefix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasPrefix(FieldTitle, v))
}
// TitleHasSuffix applies the HasSuffix predicate on the "title" field.
func TitleHasSuffix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasSuffix(FieldTitle, v))
}
// TitleEqualFold applies the EqualFold predicate on the "title" field.
func TitleEqualFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEqualFold(FieldTitle, v))
}
// TitleContainsFold applies the ContainsFold predicate on the "title" field.
func TitleContainsFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContainsFold(FieldTitle, v))
}
// ContentEQ applies the EQ predicate on the "content" field.
func ContentEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldContent, v))
}
// ContentNEQ applies the NEQ predicate on the "content" field.
func ContentNEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldContent, v))
}
// ContentIn applies the In predicate on the "content" field.
func ContentIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldContent, vs...))
}
// ContentNotIn applies the NotIn predicate on the "content" field.
func ContentNotIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldContent, vs...))
}
// ContentGT applies the GT predicate on the "content" field.
func ContentGT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldContent, v))
}
// ContentGTE applies the GTE predicate on the "content" field.
func ContentGTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldContent, v))
}
// ContentLT applies the LT predicate on the "content" field.
func ContentLT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldContent, v))
}
// ContentLTE applies the LTE predicate on the "content" field.
func ContentLTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldContent, v))
}
// ContentContains applies the Contains predicate on the "content" field.
func ContentContains(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContains(FieldContent, v))
}
// ContentHasPrefix applies the HasPrefix predicate on the "content" field.
func ContentHasPrefix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasPrefix(FieldContent, v))
}
// ContentHasSuffix applies the HasSuffix predicate on the "content" field.
func ContentHasSuffix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasSuffix(FieldContent, v))
}
// ContentEqualFold applies the EqualFold predicate on the "content" field.
func ContentEqualFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEqualFold(FieldContent, v))
}
// ContentContainsFold applies the ContainsFold predicate on the "content" field.
func ContentContainsFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContainsFold(FieldContent, v))
}
// ReadEQ applies the EQ predicate on the "read" field.
func ReadEQ(v bool) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldRead, v))
}
// ReadNEQ applies the NEQ predicate on the "read" field.
func ReadNEQ(v bool) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldRead, v))
}
// LinkEQ applies the EQ predicate on the "link" field.
func LinkEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldLink, v))
}
// LinkNEQ applies the NEQ predicate on the "link" field.
func LinkNEQ(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldLink, v))
}
// LinkIn applies the In predicate on the "link" field.
func LinkIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldLink, vs...))
}
// LinkNotIn applies the NotIn predicate on the "link" field.
func LinkNotIn(vs ...string) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldLink, vs...))
}
// LinkGT applies the GT predicate on the "link" field.
func LinkGT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldLink, v))
}
// LinkGTE applies the GTE predicate on the "link" field.
func LinkGTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldLink, v))
}
// LinkLT applies the LT predicate on the "link" field.
func LinkLT(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldLink, v))
}
// LinkLTE applies the LTE predicate on the "link" field.
func LinkLTE(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldLink, v))
}
// LinkContains applies the Contains predicate on the "link" field.
func LinkContains(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContains(FieldLink, v))
}
// LinkHasPrefix applies the HasPrefix predicate on the "link" field.
func LinkHasPrefix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasPrefix(FieldLink, v))
}
// LinkHasSuffix applies the HasSuffix predicate on the "link" field.
func LinkHasSuffix(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldHasSuffix(FieldLink, v))
}
// LinkIsNil applies the IsNil predicate on the "link" field.
func LinkIsNil() predicate.Notifications {
return predicate.Notifications(sql.FieldIsNull(FieldLink))
}
// LinkNotNil applies the NotNil predicate on the "link" field.
func LinkNotNil() predicate.Notifications {
return predicate.Notifications(sql.FieldNotNull(FieldLink))
}
// LinkEqualFold applies the EqualFold predicate on the "link" field.
func LinkEqualFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldEqualFold(FieldLink, v))
}
// LinkContainsFold applies the ContainsFold predicate on the "link" field.
func LinkContainsFold(v string) predicate.Notifications {
return predicate.Notifications(sql.FieldContainsFold(FieldLink, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Notifications {
return predicate.Notifications(sql.FieldLTE(FieldUpdatedAt, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Notifications) predicate.Notifications {
return predicate.Notifications(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Notifications) predicate.Notifications {
return predicate.Notifications(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.Notifications) predicate.Notifications {
return predicate.Notifications(sql.NotPredicates(p))
}