Commit b7f69844 authored by ducky's avatar ducky
Browse files

feat(announcements): add admin/user announcement system

Implements announcements end-to-end (admin CRUD + read status, user list + mark read) with OR-of-AND targeting. Also breaks the ent<->service import cycle by moving schema-facing constants/targeting into a new domain package.
parent cadca752
This diff is collapsed.
...@@ -15,6 +15,12 @@ type Account func(*sql.Selector) ...@@ -15,6 +15,12 @@ type Account func(*sql.Selector)
// AccountGroup is the predicate function for accountgroup builders. // AccountGroup is the predicate function for accountgroup builders.
type AccountGroup func(*sql.Selector) type AccountGroup func(*sql.Selector)
// Announcement is the predicate function for announcement builders.
type Announcement func(*sql.Selector)
// AnnouncementRead is the predicate function for announcementread builders.
type AnnouncementRead func(*sql.Selector)
// Group is the predicate function for group builders. // Group is the predicate function for group builders.
type Group func(*sql.Selector) type Group func(*sql.Selector)
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ package schema ...@@ -4,7 +4,7 @@ package schema
import ( import (
"github.com/Wei-Shaw/sub2api/ent/schema/mixins" "github.com/Wei-Shaw/sub2api/ent/schema/mixins"
"github.com/Wei-Shaw/sub2api/internal/service" "github.com/Wei-Shaw/sub2api/internal/domain"
"entgo.io/ent" "entgo.io/ent"
"entgo.io/ent/dialect" "entgo.io/ent/dialect"
...@@ -111,7 +111,7 @@ func (Account) Fields() []ent.Field { ...@@ -111,7 +111,7 @@ func (Account) Fields() []ent.Field {
// status: 账户状态,如 "active", "error", "disabled" // status: 账户状态,如 "active", "error", "disabled"
field.String("status"). field.String("status").
MaxLen(20). MaxLen(20).
Default(service.StatusActive), Default(domain.StatusActive),
// error_message: 错误信息,记录账户异常时的详细信息 // error_message: 错误信息,记录账户异常时的详细信息
field.String("error_message"). field.String("error_message").
......
This diff is collapsed.
This diff is collapsed.
...@@ -2,7 +2,7 @@ package schema ...@@ -2,7 +2,7 @@ package schema
import ( import (
"github.com/Wei-Shaw/sub2api/ent/schema/mixins" "github.com/Wei-Shaw/sub2api/ent/schema/mixins"
"github.com/Wei-Shaw/sub2api/internal/service" "github.com/Wei-Shaw/sub2api/internal/domain"
"entgo.io/ent" "entgo.io/ent"
"entgo.io/ent/dialect/entsql" "entgo.io/ent/dialect/entsql"
...@@ -45,7 +45,7 @@ func (APIKey) Fields() []ent.Field { ...@@ -45,7 +45,7 @@ func (APIKey) Fields() []ent.Field {
Nillable(), Nillable(),
field.String("status"). field.String("status").
MaxLen(20). MaxLen(20).
Default(service.StatusActive), Default(domain.StatusActive),
field.JSON("ip_whitelist", []string{}). field.JSON("ip_whitelist", []string{}).
Optional(). Optional().
Comment("Allowed IPs/CIDRs, e.g. [\"192.168.1.100\", \"10.0.0.0/8\"]"), Comment("Allowed IPs/CIDRs, e.g. [\"192.168.1.100\", \"10.0.0.0/8\"]"),
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment