From b2d753e832ffc7ad76ffdb9b8cdc55adc9733f0c Mon Sep 17 00:00:00 2001
From: landaiqing <3517283258@qq.com>
Date: Thu, 14 Nov 2024 16:02:11 +0800
Subject: [PATCH] :sparkles: add casbin ent adapter & code migration
---
.idea/GOHCache.xml | 3401 ++---------------
.idea/JavaSceneConfigState.xml | 2 +-
app/core/api/common/constant/deleted.go | 6 +
app/core/api/common/constant/gender.go | 6 +
app/core/api/common/constant/redis_prefix.go | 9 +-
app/core/api/common/constant/user_role.go | 7 +
app/core/api/common/jwt/access_token.go | 14 +-
app/core/api/common/jwt/refresh_token.go | 14 +-
.../api/common/random_name/actsomething.go | 8 +
app/core/api/common/random_name/adjective.go | 31 +
app/core/api/common/random_name/person.go | 11 +
app/core/api/common/random_name/randomname.go | 20 +
app/core/api/common/random_name/randomtype.go | 8 +
app/core/api/common/response/response.go | 41 +-
app/core/api/core.api | 3 +
app/core/api/core.go | 10 +-
app/core/api/etc/rbac_model.conf | 14 +
app/core/api/internal/handler/routes.go | 5 +
.../handler/user/phone_login_handler.go | 2 +-
.../handler/user/refresh_token_handler.go | 22 +
.../logic/client/generate_client_id_logic.go | 4 +-
.../logic/user/account_login_logic.go | 56 +-
.../internal/logic/user/phone_login_logic.go | 67 +-
.../logic/user/refresh_token_logic.go | 66 +
.../logic/user/reset_password_logic.go | 41 +-
app/core/api/internal/svc/service_context.go | 4 +
app/core/api/internal/types/redis_token.go | 16 +
app/core/api/internal/types/session.go | 17 +
.../api/repository/casbinx/adapter/adapter.go | 515 +++
app/core/api/repository/casbinx/init.go | 39 +
app/core/api/repository/idgenerator/init.go | 10 +
app/core/api/repository/mysql/ent/client.go | 105 +-
app/core/api/repository/mysql/ent/entql.go | 169 +-
.../repository/mysql/ent/migrate/schema.go | 40 +-
app/core/api/repository/mysql/ent/mutation.go | 809 ++--
app/core/api/repository/mysql/ent/runtime.go | 4 -
.../mysql/ent/scaauthpermissionrule.go | 122 +-
.../scaauthpermissionrule.go | 35 -
.../mysql/ent/scaauthpermissionrule/where.go | 72 +-
.../mysql/ent/scaauthpermissionrule_create.go | 93 +-
.../mysql/ent/scaauthpermissionrule_delete.go | 2 +-
.../mysql/ent/scaauthpermissionrule_query.go | 127 +-
.../mysql/ent/scaauthpermissionrule_update.go | 167 +-
.../api/repository/mysql/ent/scaauthrole.go | 28 +-
.../mysql/ent/scaauthrole/scaauthrole.go | 31 -
.../repository/mysql/ent/scaauthrole/where.go | 24 -
.../mysql/ent/scaauthrole_create.go | 32 -
.../repository/mysql/ent/scaauthrole_query.go | 104 +-
.../mysql/ent/scaauthrole_update.go | 163 -
.../api/repository/mysql/ent/scaauthuser.go | 56 +-
.../mysql/ent/scaauthuser/scaauthuser.go | 63 -
.../repository/mysql/ent/scaauthuser/where.go | 90 +-
.../mysql/ent/scaauthuser_create.go | 81 +-
.../repository/mysql/ent/scaauthuser_query.go | 181 +-
.../mysql/ent/scaauthuser_update.go | 384 +-
.../repository/mysql/ent/scaauthuserdevice.go | 41 +-
.../scaauthuserdevice/scaauthuserdevice.go | 35 -
.../mysql/ent/scaauthuserdevice/where.go | 24 -
.../mysql/ent/scaauthuserdevice_create.go | 37 -
.../mysql/ent/scaauthuserdevice_query.go | 109 +-
.../mysql/ent/scaauthuserdevice_update.go | 109 -
.../repository/mysql/ent/scaauthusersocial.go | 43 +-
.../scaauthusersocial/scaauthusersocial.go | 35 -
.../mysql/ent/scaauthusersocial/where.go | 24 -
.../mysql/ent/scaauthusersocial_create.go | 37 -
.../mysql/ent/scaauthusersocial_query.go | 109 +-
.../mysql/ent/scaauthusersocial_update.go | 109 -
.../mysql/model/sca_auth_permission_rule.go | 31 +-
.../repository/mysql/model/sca_auth_role.go | 5 +-
.../repository/mysql/model/sca_auth_user.go | 9 +-
.../mysql/model/sca_auth_user_device.go | 7 +-
.../mysql/model/sca_auth_user_social.go | 7 +-
app/core/api/repository/redis_session/init.go | 2 +-
.../repository/redis_session/types/session.go | 7 -
.../repository/redisx/types/redis_token.go | 6 -
.../api/resources/language/active.en.toml | 10 +-
.../api/resources/language/active.zh.toml | 8 +
go.mod | 23 +-
go.sum | 40 +-
79 files changed, 1856 insertions(+), 6462 deletions(-)
create mode 100644 app/core/api/common/constant/deleted.go
create mode 100644 app/core/api/common/constant/gender.go
create mode 100644 app/core/api/common/constant/user_role.go
create mode 100644 app/core/api/common/random_name/actsomething.go
create mode 100644 app/core/api/common/random_name/adjective.go
create mode 100644 app/core/api/common/random_name/person.go
create mode 100644 app/core/api/common/random_name/randomname.go
create mode 100644 app/core/api/common/random_name/randomtype.go
create mode 100644 app/core/api/etc/rbac_model.conf
create mode 100644 app/core/api/internal/handler/user/refresh_token_handler.go
create mode 100644 app/core/api/internal/logic/user/refresh_token_logic.go
create mode 100644 app/core/api/internal/types/redis_token.go
create mode 100644 app/core/api/internal/types/session.go
create mode 100644 app/core/api/repository/casbinx/adapter/adapter.go
create mode 100644 app/core/api/repository/casbinx/init.go
create mode 100644 app/core/api/repository/idgenerator/init.go
delete mode 100644 app/core/api/repository/redis_session/types/session.go
delete mode 100644 app/core/api/repository/redisx/types/redis_token.go
diff --git a/.idea/GOHCache.xml b/.idea/GOHCache.xml
index c6c4438..3e954df 100644
--- a/.idea/GOHCache.xml
+++ b/.idea/GOHCache.xml
@@ -7,7 +7,6 @@
-
@@ -15,26 +14,28 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -42,9 +43,6 @@
-
-
-
@@ -52,38 +50,20 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -91,18 +71,21 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -117,24 +100,20 @@
-
-
-
-
-
+
@@ -142,9 +121,6 @@
-
-
-
@@ -152,9 +128,6 @@
-
-
-
@@ -162,9 +135,6 @@
-
-
-
@@ -172,33 +142,28 @@
-
-
-
-
-
-
-
+
+
@@ -206,7 +171,6 @@
-
@@ -214,26 +178,27 @@
-
+
+
+
+
+
+
+
-
-
-
-
-
@@ -249,12 +214,6 @@
-
-
-
-
-
-
@@ -262,9 +221,6 @@
-
-
-
@@ -272,9 +228,6 @@
-
-
-
@@ -282,9 +235,6 @@
-
-
-
@@ -292,9 +242,6 @@
-
-
-
@@ -302,9 +249,6 @@
-
-
-
@@ -312,9 +256,6 @@
-
-
-
@@ -322,9 +263,6 @@
-
-
-
@@ -332,9 +270,6 @@
-
-
-
@@ -342,9 +277,6 @@
-
-
-
@@ -352,9 +284,6 @@
-
-
-
@@ -362,9 +291,6 @@
-
-
-
@@ -372,9 +298,6 @@
-
-
-
@@ -382,9 +305,6 @@
-
-
-
@@ -393,15 +313,6 @@
-
-
-
-
-
-
-
-
-
@@ -409,9 +320,6 @@
-
-
-
@@ -419,9 +327,6 @@
-
-
-
@@ -429,9 +334,6 @@
-
-
-
@@ -439,9 +341,6 @@
-
-
-
@@ -449,9 +348,6 @@
-
-
-
@@ -459,9 +355,6 @@
-
-
-
@@ -469,9 +362,6 @@
-
-
-
@@ -479,9 +369,6 @@
-
-
-
@@ -489,9 +376,6 @@
-
-
-
@@ -499,9 +383,6 @@
-
-
-
@@ -509,9 +390,6 @@
-
-
-
@@ -519,9 +397,6 @@
-
-
-
@@ -529,9 +404,6 @@
-
-
-
@@ -540,15 +412,6 @@
-
-
-
-
-
-
-
-
-
@@ -556,9 +419,6 @@
-
-
-
@@ -566,9 +426,6 @@
-
-
-
@@ -576,9 +433,6 @@
-
-
-
@@ -586,9 +440,6 @@
-
-
-
@@ -596,9 +447,6 @@
-
-
-
@@ -607,15 +455,6 @@
-
-
-
-
-
-
-
-
-
@@ -623,9 +462,6 @@
-
-
-
@@ -633,9 +469,6 @@
-
-
-
@@ -643,9 +476,6 @@
-
-
-
@@ -653,9 +483,6 @@
-
-
-
@@ -663,9 +490,6 @@
-
-
-
@@ -673,9 +497,6 @@
-
-
-
@@ -683,9 +504,6 @@
-
-
-
@@ -693,9 +511,6 @@
-
-
-
@@ -703,9 +518,6 @@
-
-
-
@@ -713,9 +525,6 @@
-
-
-
@@ -723,9 +532,6 @@
-
-
-
@@ -733,9 +539,6 @@
-
-
-
@@ -743,9 +546,6 @@
-
-
-
@@ -753,9 +553,6 @@
-
-
-
@@ -763,9 +560,6 @@
-
-
-
@@ -773,9 +567,6 @@
-
-
-
@@ -783,9 +574,6 @@
-
-
-
@@ -793,9 +581,6 @@
-
-
-
@@ -803,9 +588,6 @@
-
-
-
@@ -814,15 +596,6 @@
-
-
-
-
-
-
-
-
-
@@ -830,9 +603,6 @@
-
-
-
@@ -840,9 +610,6 @@
-
-
-
@@ -850,9 +617,6 @@
-
-
-
@@ -860,9 +624,6 @@
-
-
-
@@ -870,9 +631,6 @@
-
-
-
@@ -880,9 +638,6 @@
-
-
-
@@ -890,9 +645,6 @@
-
-
-
@@ -900,9 +652,6 @@
-
-
-
@@ -910,9 +659,6 @@
-
-
-
@@ -920,9 +666,6 @@
-
-
-
@@ -930,9 +673,6 @@
-
-
-
@@ -940,9 +680,6 @@
-
-
-
@@ -950,9 +687,6 @@
-
-
-
@@ -960,9 +694,6 @@
-
-
-
@@ -970,9 +701,6 @@
-
-
-
@@ -980,35 +708,27 @@
-
-
-
-
-
-
-
-
-
+
@@ -1017,8 +737,6 @@
-
-
@@ -1026,9 +744,6 @@
-
-
-
@@ -1036,9 +751,6 @@
-
-
-
@@ -1046,9 +758,6 @@
-
-
-
@@ -1056,9 +765,6 @@
-
-
-
@@ -1066,9 +772,6 @@
-
-
-
@@ -1076,9 +779,6 @@
-
-
-
@@ -1086,9 +786,6 @@
-
-
-
@@ -1096,9 +793,6 @@
-
-
-
@@ -1106,8 +800,6 @@
-
-
@@ -1115,144 +807,10 @@
-
+
\ No newline at end of file
diff --git a/.idea/JavaSceneConfigState.xml b/.idea/JavaSceneConfigState.xml
index 198ab03..9f1a23a 100644
--- a/.idea/JavaSceneConfigState.xml
+++ b/.idea/JavaSceneConfigState.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/core/api/common/constant/deleted.go b/app/core/api/common/constant/deleted.go
new file mode 100644
index 0000000..a898057
--- /dev/null
+++ b/app/core/api/common/constant/deleted.go
@@ -0,0 +1,6 @@
+package constant
+
+const (
+ NotDeleted int8 = iota
+ Deleted int8 = 1
+)
diff --git a/app/core/api/common/constant/gender.go b/app/core/api/common/constant/gender.go
new file mode 100644
index 0000000..0be77ae
--- /dev/null
+++ b/app/core/api/common/constant/gender.go
@@ -0,0 +1,6 @@
+package constant
+
+const (
+ Female int8 = iota
+ Male
+)
diff --git a/app/core/api/common/constant/redis_prefix.go b/app/core/api/common/constant/redis_prefix.go
index 19165e2..2299021 100644
--- a/app/core/api/common/constant/redis_prefix.go
+++ b/app/core/api/common/constant/redis_prefix.go
@@ -1,8 +1,9 @@
package constant
const (
- UserClientPrefix string = "user:client:"
- UserSessionPrefix string = "user:session:"
- UserCaptchaPrefix string = "user:captcha:"
- UserTokenPrefix string = "user:token:"
+ UserClientPrefix string = "user:client:"
+ UserSessionPrefix string = "user:session:"
+ UserCaptchaPrefix string = "user:captcha:"
+ UserTokenPrefix string = "user:token:"
+ UserSmsRedisPrefix string = "user:sms:"
)
diff --git a/app/core/api/common/constant/user_role.go b/app/core/api/common/constant/user_role.go
new file mode 100644
index 0000000..2da19f2
--- /dev/null
+++ b/app/core/api/common/constant/user_role.go
@@ -0,0 +1,7 @@
+package constant
+
+const (
+ Root string = "root"
+ Admin string = "admin"
+ User string = "user"
+)
diff --git a/app/core/api/common/jwt/access_token.go b/app/core/api/common/jwt/access_token.go
index 8a3d3e5..e2cdc76 100644
--- a/app/core/api/common/jwt/access_token.go
+++ b/app/core/api/common/jwt/access_token.go
@@ -1,11 +1,9 @@
package jwt
import (
- "context"
"time"
- "github.com/golang-jwt/jwt/v4"
- "github.com/zeromicro/go-zero/core/logc"
+ "github.com/golang-jwt/jwt/v5"
)
type AccessJWTPayload struct {
@@ -29,23 +27,21 @@ func GenerateAccessToken(secret string, payload AccessJWTPayload) string {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
accessToken, err := token.SignedString([]byte(secret))
if err != nil {
- logc.Error(context.Background(), err)
return ""
}
return accessToken
}
// ParseAccessToken parses a JWT token and returns the payload
-func ParseAccessToken(secret string, tokenString string) *AccessJWTPayload {
+func ParseAccessToken(secret string, tokenString string) (*AccessJWTPayload, bool) {
token, err := jwt.ParseWithClaims(tokenString, &AccessJWTClaims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(secret), nil
})
if err != nil {
- logc.Error(context.Background(), err)
- return nil
+ return nil, false
}
if claims, ok := token.Claims.(*AccessJWTClaims); ok && token.Valid {
- return &claims.AccessJWTPayload
+ return &claims.AccessJWTPayload, true
}
- return nil
+ return nil, false
}
diff --git a/app/core/api/common/jwt/refresh_token.go b/app/core/api/common/jwt/refresh_token.go
index 36f624a..8e3ca61 100644
--- a/app/core/api/common/jwt/refresh_token.go
+++ b/app/core/api/common/jwt/refresh_token.go
@@ -1,11 +1,9 @@
package jwt
import (
- "context"
"time"
- "github.com/golang-jwt/jwt/v4"
- "github.com/zeromicro/go-zero/core/logc"
+ "github.com/golang-jwt/jwt/v5"
)
type RefreshJWTPayload struct {
@@ -30,23 +28,21 @@ func GenerateRefreshToken(secret string, payload RefreshJWTPayload, days time.Du
refreshToken := jwt.NewWithClaims(jwt.SigningMethodHS256, refreshClaims)
refreshTokenString, err := refreshToken.SignedString([]byte(secret))
if err != nil {
- logc.Error(context.Background(), err)
return ""
}
return refreshTokenString
}
// ParseRefreshToken parses a JWT token and returns the payload
-func ParseRefreshToken(secret string, refreshTokenString string) *RefreshJWTPayload {
+func ParseRefreshToken(secret string, refreshTokenString string) (*RefreshJWTPayload, bool) {
token, err := jwt.ParseWithClaims(refreshTokenString, &RefreshJWTClaims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(secret), nil
})
if err != nil {
- logc.Error(context.Background(), err)
- return nil
+ return nil, false
}
if claims, ok := token.Claims.(*RefreshJWTClaims); ok && token.Valid {
- return &claims.RefreshJWTPayload
+ return &claims.RefreshJWTPayload, true
}
- return nil
+ return nil, false
}
diff --git a/app/core/api/common/random_name/actsomething.go b/app/core/api/common/random_name/actsomething.go
new file mode 100644
index 0000000..4471fe3
--- /dev/null
+++ b/app/core/api/common/random_name/actsomething.go
@@ -0,0 +1,8 @@
+package randomname
+
+// ActSomethingSlice 做什么事情
+var ActSomethingSlice = []string{
+ "打豆豆", "吃爆米花", "走向人生巅峰", "大力出奇迹", "得到了金球奖", "爆射世界杯", "有亿点点忧伤", "完成了梅开二度", "完成了帽子戏法", "完成了大四喜", "完成了五子登科",
+ "望穿秋水", "掐指一算", "横扫千军", "一眼定情", "会发财", "求而不得", "舞力四射", "横扫六合", "救了一个美女", "使出了佛怒火莲", "在巴黎徒步", "心花怒放", "在武汉看电影",
+}
+var ActSomethingSliceCount = len(ActSomethingSlice)
diff --git a/app/core/api/common/random_name/adjective.go b/app/core/api/common/random_name/adjective.go
new file mode 100644
index 0000000..8a43ee7
--- /dev/null
+++ b/app/core/api/common/random_name/adjective.go
@@ -0,0 +1,31 @@
+package randomname
+
+// AdjectiveSlice 形容词
+var AdjectiveSlice = []string{
+ "帅气的", "迷人的", "大汗淋漓的", "朝气蓬勃的", "隐身的", "天神下凡的", "快乐的", "冷静的", "醉熏的", "潇洒的", "糊涂的", "积极的",
+ "冷酷的", "深情的", "粗暴的", "温柔的", "可爱的", "愉快的", "义气的", "认真的", "威武的", "传统的", "潇洒的", "漂亮的", "自然的",
+ "专一的", "听话的", "昏睡的", "狂野的", "等待的", "搞怪的", "幽默的", "魁梧的", "活泼的", "开心的", "高兴的", "超帅的", "留胡子的",
+ "坦率的", "直率的", "轻松的", "痴情的", "完美的", "精明的", "无聊的", "有魅力的", "丰富的", "高挑的", "傻傻的", "冷艳的", "爱听歌的",
+ "繁荣的", "饱满的", "炙热的", "暴躁的", "碧蓝的", "俊逸的", "英勇的", "健忘的", "故意的", "无心的", "土豪的", "朴实的", "兴奋的",
+ "幸福的", "淡定的", "不安的", "阔达的", "孤独的", "独特的", "疯狂的", "时尚的", "落后的", "风趣的", "忧伤的", "大胆的", "爱笑的", "矮小的",
+ "健康的", "合适的", "玩命的", "沉默的", "斯文的", "香蕉的", "苹果的", "鲤鱼的", "鳗鱼的", "任性的", "细心的", "粗心的", "大意的", "甜甜的",
+ "酷酷的", "健壮的", "英俊的", "霸气的", "阳光的", "默默的", "大力的", "孝顺的", "忧虑的", "着急的", "紧张的", "善良的", "凶狠的", "害怕的",
+ "重要的", "危机的", "欢喜的", "欣慰的", "满意的", "跳跃的", "诚心的", "称心的", "如意的", "怡然的", "娇气的", "无奈的", "无语的", "激动的",
+ "愤怒的", "美好的", "感动的", "激情的", "激昂的", "震动的", "虚拟的", "超级的", "寒冷的", "精明的", "明理的", "犹豫的", "忧郁的", "寂寞的",
+ "奋斗的", "勤奋的", "现代的", "过时的", "稳重的", "热情的", "含蓄的", "开放的", "无辜的", "多情的", "纯真的", "拉长的", "热心的", "从容的",
+ "体贴的", "风中的", "曾经的", "追寻的", "儒雅的", "优雅的", "开朗的", "外向的", "内向的", "清爽的", "文艺的", "长情的", "平常的", "单身的",
+ "伶俐的", "高大的", "懦弱的", "柔弱的", "爱笑的", "乐观的", "耍酷的", "酷炫的", "神勇的", "年轻的", "唠叨的", "瘦瘦的", "无情的", "包容的",
+ "顺心的", "畅快的", "舒适的", "靓丽的", "负责的", "背后的", "简单的", "谦让的", "彩色的", "缥缈的", "欢呼的", "生动的", "复杂的", "慈祥的",
+ "仁爱的", "魔幻的", "虚幻的", "淡然的", "受伤的", "雪白的", "高高的", "糟糕的", "顺利的", "闪闪的", "羞涩的", "缓慢的", "迅速的", "优秀的",
+ "聪明的", "含糊的", "俏皮的", "淡淡的", "坚强的", "平淡的", "欣喜的", "能干的", "灵巧的", "友好的", "机智的", "机灵的", "正直的", "谨慎的",
+ "俭朴的", "殷勤的", "虚心的", "辛勤的", "自觉的", "无私的", "无限的", "踏实的", "老实的", "现实的", "可靠的", "务实的", "拼搏的", "个性的",
+ "粗犷的", "活力的", "成就的", "勤劳的", "单纯的", "落寞的", "朴素的", "悲凉的", "忧心的", "洁净的", "清秀的", "自由的", "小巧的", "单薄的",
+ "贪玩的", "刻苦的", "干净的", "壮观的", "和谐的", "文静的", "调皮的", "害羞的", "安详的", "自信的", "端庄的", "坚定的", "美满的", "舒心的",
+ "温暖的", "专注的", "勤恳的", "美丽的", "腼腆的", "优美的", "甜美的", "甜蜜的", "整齐的", "动人的", "典雅的", "尊敬的", "舒服的", "妩媚的",
+ "秀丽的", "喜悦的", "甜美的", "彪壮的", "强健的", "大方的", "俊秀的", "聪慧的", "陶醉的", "悦耳的", "动听的", "明亮的", "结实的", "魁梧的",
+ "标致的", "清脆的", "敏感的", "光亮的", "大气的", "老迟到的", "知性的", "冷傲的", "呆萌的", "野性的", "隐形的", "笑点低的", "微笑的", "笨笨的",
+ "难过的", "沉静的", "火星上的", "失眠的", "安静的", "纯情的", "要减肥的", "迷路的", "烂漫的", "哭泣的", "贤惠的", "苗条的", "温婉的", "发嗲的",
+ "会撒娇的", "贪玩的", "执着的", "眯眯眼的", "花痴的", "想人陪的", "眼睛大的", "高贵的", "傲娇的", "心灵美的", "爱撒娇的", "细腻的", "天真的",
+ "怕黑的", "感性的", "飘逸的", "怕孤独的", "忐忑的", "还单身的", "怕孤单的", "懵懂的",
+}
+var AdjectiveSliceCount = len(AdjectiveSlice)
diff --git a/app/core/api/common/random_name/person.go b/app/core/api/common/random_name/person.go
new file mode 100644
index 0000000..66f0836
--- /dev/null
+++ b/app/core/api/common/random_name/person.go
@@ -0,0 +1,11 @@
+package randomname
+
+// PersonSlice 人物
+var PersonSlice = []string{
+ "梅西", "罗纳尔多", "内马尔", "贝克汉姆", "姆巴佩", "苏牙", "小罗", "大罗", "鲁尼", "本泽马", "贝利", "约翰", "柯南", "米老鼠",
+ "弗朗茨", "普拉蒂尼", "迪斯蒂法诺", "普斯卡什", "乔治·贝斯特", "范巴斯滕", "尤西比奥", "列夫·雅辛", "博比", "博比·摩尔", "盖德·穆勒",
+ "巴乔", "斯坦利", "济科", "弗兰科", "加林查", "保罗", "肯尼", "巴蒂斯图塔", "坎通纳", "哈吉", "罗马里奥",
+ "齐达內", "古利特", "约翰·查尔斯", "卡卡", "哈维", "伊布", "莫德里奇", "欧文", "巴乔", "萧炎", "鸣人", "佐助", "盖茨比", "乔布斯", "索尔",
+ "宙斯", "雅典娜", "星矢", "托尼", "科比", "乔丹", "西瓜太郎", "一休", "莫甘娜", "永恩", "爱因斯坦", "肖申克", "摩尔",
+}
+var PersonSliceCount = len(PersonSlice)
diff --git a/app/core/api/common/random_name/randomname.go b/app/core/api/common/random_name/randomname.go
new file mode 100644
index 0000000..a1e3dbb
--- /dev/null
+++ b/app/core/api/common/random_name/randomname.go
@@ -0,0 +1,20 @@
+package randomname
+
+import (
+ "math/rand"
+ "time"
+)
+
+// GenerateName 生成随机昵称
+func GenerateName() string {
+ var name string
+ rand.New(rand.NewSource(time.Now().UnixNano()))
+ selectedType := RandomType(rand.Intn(2))
+ switch selectedType {
+ case AdjectiveAndPerson:
+ name = AdjectiveSlice[rand.Intn(AdjectiveSliceCount)] + PersonSlice[rand.Intn(PersonSliceCount)]
+ case PersonActSomething:
+ name = PersonSlice[rand.Intn(PersonSliceCount)] + ActSomethingSlice[rand.Intn(ActSomethingSliceCount)]
+ }
+ return name
+}
diff --git a/app/core/api/common/random_name/randomtype.go b/app/core/api/common/random_name/randomtype.go
new file mode 100644
index 0000000..85294e8
--- /dev/null
+++ b/app/core/api/common/random_name/randomtype.go
@@ -0,0 +1,8 @@
+package randomname
+
+type RandomType int
+
+const (
+ AdjectiveAndPerson RandomType = iota // 形容词+人物 例如:帅气的罗纳尔多
+ PersonActSomething // 人物+做事情 例如:梅西吃爆米花
+)
diff --git a/app/core/api/common/response/response.go b/app/core/api/common/response/response.go
index fa02a41..51f44f3 100644
--- a/app/core/api/common/response/response.go
+++ b/app/core/api/common/response/response.go
@@ -1,9 +1,14 @@
package response
-import "schisandra-album-cloud-microservices/app/core/api/internal/types"
+import (
+ "context"
-// Success returns a success response with the given data.
-func Success[T any](data T) *types.Response {
+ "schisandra-album-cloud-microservices/app/core/api/common/i18n"
+ "schisandra-album-cloud-microservices/app/core/api/internal/types"
+)
+
+// SuccessWithData returns a success response with the given data.
+func SuccessWithData[T any](data T) *types.Response {
return &types.Response{
Code: 200,
Message: "success",
@@ -11,6 +16,15 @@ func Success[T any](data T) *types.Response {
}
}
+// Success returns a success response with nil data.
+func Success() *types.Response {
+ return &types.Response{
+ Code: 200,
+ Message: "success",
+ Data: nil,
+ }
+}
+
// SuccessWithMessage returns a success response with the given message.
func SuccessWithMessage(message string) *types.Response {
return &types.Response{
@@ -30,7 +44,16 @@ func Error() *types.Response {
}
// ErrorWithCode returns an error response with the given code and message.
-func ErrorWithCode(code int64, message string) *types.Response {
+func ErrorWithCode(code int64) *types.Response {
+ return &types.Response{
+ Code: code,
+ Message: "error",
+ Data: nil,
+ }
+}
+
+// ErrorWithCodeMessage returns an error response with the given code and message.
+func ErrorWithCodeMessage(code int64, message string) *types.Response {
return &types.Response{
Code: code,
Message: message,
@@ -46,3 +69,13 @@ func ErrorWithMessage(message string) *types.Response {
Data: nil,
}
}
+
+// ErrorWithI18n returns an error response with the given message.
+func ErrorWithI18n(ctx context.Context, msgId string, defaultMsg string) *types.Response {
+ message := i18n.FormatText(ctx, msgId, defaultMsg)
+ return &types.Response{
+ Code: 500,
+ Message: message,
+ Data: nil,
+ }
+}
diff --git a/app/core/api/core.api b/app/core/api/core.api
index d419fc8..990f833 100644
--- a/app/core/api/core.api
+++ b/app/core/api/core.api
@@ -74,6 +74,9 @@ service core {
// 重置密码
@handler resetPassword
post /reset_password (ResetPasswordRequest) returns (Response)
+
+ @handler refreshToken
+ post /token/refresh returns (Response)
}
// 客户端服务
diff --git a/app/core/api/core.go b/app/core/api/core.go
index dbe5c90..57acf3b 100644
--- a/app/core/api/core.go
+++ b/app/core/api/core.go
@@ -4,13 +4,14 @@ import (
"flag"
"fmt"
+ "github.com/zeromicro/go-zero/core/conf"
+ "github.com/zeromicro/go-zero/rest"
+
"schisandra-album-cloud-microservices/app/core/api/common/middleware"
"schisandra-album-cloud-microservices/app/core/api/internal/config"
"schisandra-album-cloud-microservices/app/core/api/internal/handler"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
-
- "github.com/zeromicro/go-zero/core/conf"
- "github.com/zeromicro/go-zero/rest"
+ "schisandra-album-cloud-microservices/app/core/api/repository/idgenerator"
)
var configFile = flag.String("f", "etc/core.yaml", "the config file")
@@ -27,7 +28,8 @@ func main() {
server.Use(middleware.I18nMiddleware)
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
-
+ // init id generator
+ idgenerator.NewIDGenerator()
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}
diff --git a/app/core/api/etc/rbac_model.conf b/app/core/api/etc/rbac_model.conf
new file mode 100644
index 0000000..fa9d928
--- /dev/null
+++ b/app/core/api/etc/rbac_model.conf
@@ -0,0 +1,14 @@
+[request_definition]
+r = sub, obj, act
+
+[policy_definition]
+p = sub, obj, act
+
+[role_definition]
+g = _, _
+
+[policy_effect]
+e = some(where (p.eft == allow)) && !some(where (p_eft == deny))
+
+[matchers]
+m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act
\ No newline at end of file
diff --git a/app/core/api/internal/handler/routes.go b/app/core/api/internal/handler/routes.go
index 5f905b9..82fb81e 100644
--- a/app/core/api/internal/handler/routes.go
+++ b/app/core/api/internal/handler/routes.go
@@ -50,6 +50,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/reset_password",
Handler: user.ResetPasswordHandler(serverCtx),
},
+ {
+ Method: http.MethodPost,
+ Path: "/token/refresh",
+ Handler: user.RefreshTokenHandler(serverCtx),
+ },
}...,
),
rest.WithSignature(serverCtx.Config.Signature),
diff --git a/app/core/api/internal/handler/user/phone_login_handler.go b/app/core/api/internal/handler/user/phone_login_handler.go
index 2914cc6..3704a43 100644
--- a/app/core/api/internal/handler/user/phone_login_handler.go
+++ b/app/core/api/internal/handler/user/phone_login_handler.go
@@ -19,7 +19,7 @@ func PhoneLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := user.NewPhoneLoginLogic(r.Context(), svcCtx)
- resp, err := l.PhoneLogin(&req)
+ resp, err := l.PhoneLogin(r, w, &req)
if err != nil || resp.Code == 500 {
httpx.ErrorCtx(r.Context(), w, err)
} else {
diff --git a/app/core/api/internal/handler/user/refresh_token_handler.go b/app/core/api/internal/handler/user/refresh_token_handler.go
new file mode 100644
index 0000000..7938c5e
--- /dev/null
+++ b/app/core/api/internal/handler/user/refresh_token_handler.go
@@ -0,0 +1,22 @@
+package user
+
+import (
+ "net/http"
+
+ "github.com/zeromicro/go-zero/rest/httpx"
+
+ "schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
+ "schisandra-album-cloud-microservices/app/core/api/internal/svc"
+)
+
+func RefreshTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ l := user.NewRefreshTokenLogic(r.Context(), svcCtx)
+ resp, err := l.RefreshToken(r)
+ if err != nil {
+ httpx.ErrorCtx(r.Context(), w, err)
+ } else {
+ httpx.OkJsonCtx(r.Context(), w, resp)
+ }
+ }
+}
diff --git a/app/core/api/internal/logic/client/generate_client_id_logic.go b/app/core/api/internal/logic/client/generate_client_id_logic.go
index d181fa3..328bc89 100644
--- a/app/core/api/internal/logic/client/generate_client_id_logic.go
+++ b/app/core/api/internal/logic/client/generate_client_id_logic.go
@@ -32,12 +32,12 @@ func (l *GenerateClientIdLogic) GenerateClientId(clientIP string) (resp *types.R
clientId := l.svcCtx.RedisClient.Get(l.ctx, constant.UserClientPrefix+clientIP).Val()
if clientId != "" {
- return response.Success(clientId), nil
+ return response.SuccessWithData(clientId), nil
}
simpleUuid := kgo.SimpleUuid()
if err = l.svcCtx.RedisClient.SetEx(l.ctx, constant.UserClientPrefix+clientIP, simpleUuid, time.Hour*24*7).Err(); err != nil {
l.Error(err)
return response.Error(), err
}
- return response.Success(simpleUuid), nil
+ return response.SuccessWithData(simpleUuid), nil
}
diff --git a/app/core/api/internal/logic/user/account_login_logic.go b/app/core/api/internal/logic/user/account_login_logic.go
index c69d609..85a9e7f 100644
--- a/app/core/api/internal/logic/user/account_login_logic.go
+++ b/app/core/api/internal/logic/user/account_login_logic.go
@@ -12,7 +12,6 @@ import (
"schisandra-album-cloud-microservices/app/core/api/common/captcha/verify"
"schisandra-album-cloud-microservices/app/core/api/common/constant"
- "schisandra-album-cloud-microservices/app/core/api/common/i18n"
"schisandra-album-cloud-microservices/app/core/api/common/jwt"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/common/utils"
@@ -21,8 +20,6 @@ import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
- types3 "schisandra-album-cloud-microservices/app/core/api/repository/redis_session/types"
- types2 "schisandra-album-cloud-microservices/app/core/api/repository/redisx/types"
)
type AccountLoginLogic struct {
@@ -42,7 +39,7 @@ func NewAccountLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Acco
func (l *AccountLoginLogic) AccountLogin(w http.ResponseWriter, r *http.Request, req *types.AccountLoginRequest) (resp *types.Response, err error) {
verifyResult := verify.VerifyRotateCaptcha(l.ctx, l.svcCtx.RedisClient, req.Angle, req.Key)
if !verifyResult {
- return response.ErrorWithMessage(i18n.FormatText(l.ctx, "captcha.verificationFailure", "验证失败!")), nil
+ return response.ErrorWithI18n(l.ctx, "captcha.verificationFailure", "验证失败!"), nil
}
var user *ent.ScaAuthUser
var query *ent.ScaAuthUserQuery
@@ -55,31 +52,31 @@ func (l *AccountLoginLogic) AccountLogin(w http.ResponseWriter, r *http.Request,
case utils.IsUsername(req.Account):
query = l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.UsernameEQ(req.Account), scaauthuser.DeletedEQ(0))
default:
- return response.ErrorWithMessage(i18n.FormatText(l.ctx, "login.invalidAccount", "无效账号!")), nil
+ return response.ErrorWithI18n(l.ctx, "login.invalidAccount", "无效账号!"), nil
}
user, err = query.First(l.ctx)
if err != nil {
if ent.IsNotFound(err) {
- return response.ErrorWithMessage(i18n.FormatText(l.ctx, "login.notFoundAccount", "无效账号!")), nil
+ return response.ErrorWithI18n(l.ctx, "login.userNotRegistered", "用户未注册!"), nil
}
return nil, err
}
if !utils.Verify(user.Password, req.Password) {
- return response.ErrorWithMessage(i18n.FormatText(l.ctx, "login.invalidPassword", "密码错误!")), nil
+ return response.ErrorWithI18n(l.ctx, "login.invalidPassword", "密码错误!"), nil
}
- data, result := HandleUserLogin(user, l, req.AutoLogin, r, w, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient)
+ data, result := HandleUserLogin(user, l.svcCtx, req.AutoLogin, r, w, l.ctx)
if !result {
- return response.ErrorWithMessage(i18n.FormatText(l.ctx, "login.loginFailed", "登录失败!")), nil
+ return response.ErrorWithI18n(l.ctx, "login.loginFailed", "登录失败!"), nil
}
- return response.Success(data), nil
+ return response.SuccessWithData(data), nil
}
// HandleUserLogin 处理用户登录
-func HandleUserLogin(user *ent.ScaAuthUser, l *AccountLoginLogic, autoLogin bool, r *http.Request, w http.ResponseWriter, ip2location *xdb.Searcher, entClient *ent.Client) (*types.LoginResponse, bool) {
+func HandleUserLogin(user *ent.ScaAuthUser, svcCtx *svc.ServiceContext, autoLogin bool, r *http.Request, w http.ResponseWriter, ctx context.Context) (*types.LoginResponse, bool) {
// 生成jwt token
- accessToken := jwt.GenerateAccessToken(l.svcCtx.Config.Auth.AccessSecret, jwt.AccessJWTPayload{
+ accessToken := jwt.GenerateAccessToken(svcCtx.Config.Auth.AccessSecret, jwt.AccessJWTPayload{
UserID: user.UID,
})
var days time.Duration
@@ -88,7 +85,7 @@ func HandleUserLogin(user *ent.ScaAuthUser, l *AccountLoginLogic, autoLogin bool
} else {
days = time.Hour * 24
}
- refreshToken := jwt.GenerateRefreshToken(l.svcCtx.Config.Auth.AccessSecret, jwt.RefreshJWTPayload{
+ refreshToken := jwt.GenerateRefreshToken(svcCtx.Config.Auth.AccessSecret, jwt.RefreshJWTPayload{
UserID: user.UID,
}, days)
data := types.LoginResponse{
@@ -100,31 +97,31 @@ func HandleUserLogin(user *ent.ScaAuthUser, l *AccountLoginLogic, autoLogin bool
Status: user.Status,
}
- redisToken := types2.RedisToken{
+ redisToken := types.RedisToken{
AccessToken: accessToken,
UID: user.UID,
}
- err := l.svcCtx.RedisClient.SetEx(l.ctx, constant.UserTokenPrefix+user.UID, redisToken, days).Err()
+ err := svcCtx.RedisClient.Set(ctx, constant.UserTokenPrefix+user.UID, redisToken, days).Err()
if err != nil {
- logc.Error(l.ctx, err)
+ logc.Error(ctx, err)
return nil, false
}
- sessionData := types3.SessionData{
+ sessionData := types.SessionData{
RefreshToken: refreshToken,
UID: user.UID,
}
- session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
+ session, err := svcCtx.Session.Get(r, constant.SESSION_KEY)
if err != nil {
- logc.Error(l.ctx, err)
+ logc.Error(ctx, err)
return nil, false
}
session.Values[constant.SESSION_KEY] = sessionData
if err = session.Save(r, w); err != nil {
- logc.Error(l.ctx, err)
+ logc.Error(ctx, err)
return nil, false
}
// 记录用户登录设备
- if !getUserLoginDevice(user.UID, r, ip2location, entClient, l.ctx) {
+ if !getUserLoginDevice(user.UID, r, svcCtx.Ip2Region, svcCtx.MySQLClient, ctx) {
return nil, false
}
return &data, true
@@ -160,7 +157,7 @@ func getUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searche
// 如果有错误,表示设备不存在,执行插入
if ent.IsNotFound(err) {
// 创建新的设备记录
- entClient.ScaAuthUserDevice.Create().
+ err = entClient.ScaAuthUserDevice.Create().
SetBot(isBot).
SetAgent(userAgent).
SetBrowser(browser).
@@ -173,10 +170,14 @@ func getUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searche
SetMobile(mobile).
SetMozilla(mozilla).
SetPlatform(platform).
- SaveX(ctx)
+ Exec(ctx)
+ if err != nil {
+ return false
+ }
+ return true
} else if err == nil {
// 如果设备存在,执行更新
- device.Update().
+ err = device.Update().
SetBot(isBot).
SetAgent(userAgent).
SetBrowser(browser).
@@ -189,10 +190,13 @@ func getUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searche
SetMobile(mobile).
SetMozilla(mozilla).
SetPlatform(platform).
- SaveX(ctx)
+ Exec(ctx)
+ if err != nil {
+ return false
+ }
+ return true
} else {
logc.Error(ctx, err)
return false
}
- return true
}
diff --git a/app/core/api/internal/logic/user/phone_login_logic.go b/app/core/api/internal/logic/user/phone_login_logic.go
index fc53591..293a965 100644
--- a/app/core/api/internal/logic/user/phone_login_logic.go
+++ b/app/core/api/internal/logic/user/phone_login_logic.go
@@ -2,11 +2,20 @@ package user
import (
"context"
+ "net/http"
+ "strconv"
+ "github.com/yitter/idgenerator-go/idgen"
+ "github.com/zeromicro/go-zero/core/logx"
+
+ "schisandra-album-cloud-microservices/app/core/api/common/constant"
+ randomname "schisandra-album-cloud-microservices/app/core/api/common/random_name"
+ "schisandra-album-cloud-microservices/app/core/api/common/response"
+ "schisandra-album-cloud-microservices/app/core/api/common/utils"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
)
type PhoneLoginLogic struct {
@@ -23,8 +32,56 @@ func NewPhoneLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PhoneL
}
}
-func (l *PhoneLoginLogic) PhoneLogin(req *types.PhoneLoginRequest) (resp *types.Response, err error) {
- // todo: add your logic here and delete this line
+func (l *PhoneLoginLogic) PhoneLogin(r *http.Request, w http.ResponseWriter, req *types.PhoneLoginRequest) (resp *types.Response, err error) {
+ if !utils.IsPhone(req.Phone) {
+ return response.ErrorWithI18n(l.ctx, "login.phoneFormatError", "手机号格式错误"), nil
+ }
+ code := l.svcCtx.RedisClient.Get(l.ctx, constant.UserSmsRedisPrefix+req.Phone).Val()
+ if code == "" {
+ return response.ErrorWithI18n(l.ctx, "login.captchaExpired", "验证码已过期"), nil
+ }
+ if req.Captcha != code {
+ return response.ErrorWithI18n(l.ctx, "login.captchaError", "验证码错误"), nil
+ }
+ user, err := l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.Phone(req.Phone), scaauthuser.Deleted(0)).Only(l.ctx)
+ tx, wrong := l.svcCtx.MySQLClient.Tx(l.ctx)
+ if wrong != nil {
+ return response.ErrorWithI18n(l.ctx, "login.loginFailed", "登录失败"), err
+ }
+ if ent.IsNotFound(err) {
+ uid := idgen.NextId()
+ uidStr := strconv.FormatInt(uid, 10)
+ avatar := utils.GenerateAvatar(uidStr)
+ name := randomname.GenerateName()
- return
+ addUser, wrong := l.svcCtx.MySQLClient.ScaAuthUser.Create().
+ SetUID(uidStr).
+ SetPhone(req.Phone).
+ SetAvatar(avatar).
+ SetNickname(name).
+ SetDeleted(constant.NotDeleted).
+ SetGender(constant.Male).
+ Save(l.ctx)
+ if wrong != nil {
+ err = tx.Rollback()
+ return response.ErrorWithI18n(l.ctx, "login.registerError", "注册失败"), err
+ }
+ data, result := HandleUserLogin(addUser, l.svcCtx, req.AutoLogin, r, w, l.ctx)
+ if !result {
+ err = tx.Rollback()
+ return response.ErrorWithI18n(l.ctx, "login.registerError", "注册失败"), err
+ }
+ err = tx.Commit()
+ return response.SuccessWithData(data), err
+ } else if err != nil {
+ data, result := HandleUserLogin(user, l.svcCtx, req.AutoLogin, r, w, l.ctx)
+ if !result {
+ err = tx.Rollback()
+ return response.ErrorWithI18n(l.ctx, "login.loginFailed", "登录失败"), err
+ }
+ err = tx.Commit()
+ return response.SuccessWithData(data), err
+ } else {
+ return response.ErrorWithI18n(l.ctx, "login.loginFailed", "登录失败"), nil
+ }
}
diff --git a/app/core/api/internal/logic/user/refresh_token_logic.go b/app/core/api/internal/logic/user/refresh_token_logic.go
new file mode 100644
index 0000000..46160f9
--- /dev/null
+++ b/app/core/api/internal/logic/user/refresh_token_logic.go
@@ -0,0 +1,66 @@
+package user
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "time"
+
+ "schisandra-album-cloud-microservices/app/core/api/common/constant"
+ "schisandra-album-cloud-microservices/app/core/api/common/jwt"
+ "schisandra-album-cloud-microservices/app/core/api/common/response"
+ "schisandra-album-cloud-microservices/app/core/api/internal/svc"
+ "schisandra-album-cloud-microservices/app/core/api/internal/types"
+
+ "github.com/zeromicro/go-zero/core/logx"
+)
+
+type RefreshTokenLogic struct {
+ logx.Logger
+ ctx context.Context
+ svcCtx *svc.ServiceContext
+}
+
+func NewRefreshTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RefreshTokenLogic {
+ return &RefreshTokenLogic{
+ Logger: logx.WithContext(ctx),
+ ctx: ctx,
+ svcCtx: svcCtx,
+ }
+}
+
+func (l *RefreshTokenLogic) RefreshToken(r *http.Request) (resp *types.Response, err error) {
+ session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
+ if err != nil {
+ return response.ErrorWithCode(403), err
+ }
+ sessionData, ok := session.Values[constant.SESSION_KEY]
+ if !ok {
+ return response.ErrorWithCode(403), err
+ }
+ data := types.SessionData{}
+ err = json.Unmarshal(sessionData.([]byte), &data)
+ if err != nil {
+ return response.ErrorWithCode(403), err
+ }
+ refreshToken, result := jwt.ParseRefreshToken(l.svcCtx.Config.Auth.AccessSecret, data.RefreshToken)
+ if !result {
+ return response.ErrorWithCode(403), err
+ }
+ accessToken := jwt.GenerateAccessToken(l.svcCtx.Config.Auth.AccessSecret, jwt.AccessJWTPayload{
+ UserID: refreshToken.UserID,
+ })
+ if accessToken == "" {
+ return response.ErrorWithCode(403), err
+ }
+ redisToken := types.RedisToken{
+ AccessToken: accessToken,
+ UID: refreshToken.UserID,
+ }
+ err = l.svcCtx.RedisClient.Set(l.ctx, constant.UserTokenPrefix+refreshToken.UserID, redisToken, time.Hour*24*7).Err()
+ if err != nil {
+ return response.ErrorWithCode(403), err
+ }
+
+ return response.SuccessWithData(accessToken), nil
+}
diff --git a/app/core/api/internal/logic/user/reset_password_logic.go b/app/core/api/internal/logic/user/reset_password_logic.go
index 0d08037..382645c 100644
--- a/app/core/api/internal/logic/user/reset_password_logic.go
+++ b/app/core/api/internal/logic/user/reset_password_logic.go
@@ -3,8 +3,13 @@ package user
import (
"context"
+ "schisandra-album-cloud-microservices/app/core/api/common/constant"
+ "schisandra-album-cloud-microservices/app/core/api/common/response"
+ "schisandra-album-cloud-microservices/app/core/api/common/utils"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -24,7 +29,37 @@ func NewResetPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Res
}
func (l *ResetPasswordLogic) ResetPassword(req *types.ResetPasswordRequest) (resp *types.Response, err error) {
- // todo: add your logic here and delete this line
-
- return
+ if !utils.IsPhone(req.Phone) {
+ return response.ErrorWithI18n(l.ctx, "login.phoneFormatError", "手机号格式错误"), nil
+ }
+ if req.Password != req.Repassword {
+ return response.ErrorWithI18n(l.ctx, "login.passwordNotMatch", "两次密码输入不一致"), nil
+ }
+ if !utils.IsPassword(req.Password) {
+ return response.ErrorWithI18n(l.ctx, "login.passwordFormatError", "密码格式错误"), nil
+ }
+ code := l.svcCtx.RedisClient.Get(l.ctx, constant.UserSmsRedisPrefix+req.Phone).Val()
+ if code == "" {
+ return response.ErrorWithI18n(l.ctx, "login.captchaExpired", "验证码已过期"), nil
+ }
+ if req.Captcha != code {
+ return response.ErrorWithI18n(l.ctx, "login.captchaError", "验证码错误"), nil
+ }
+ // 验证码检查通过后立即删除或标记为已使用
+ if err = l.svcCtx.RedisClient.Del(l.ctx, constant.UserSmsRedisPrefix+req.Phone).Err(); err != nil {
+ return response.ErrorWithI18n(l.ctx, "login.captchaError", "验证码错误"), nil
+ }
+ user, err := l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.Phone(req.Phone), scaauthuser.Deleted(constant.NotDeleted)).First(l.ctx)
+ if err != nil && ent.IsNotFound(err) {
+ return response.ErrorWithI18n(l.ctx, "login.userNotRegistered", "用户未注册"), nil
+ }
+ encrypt, err := utils.Encrypt(req.Password)
+ if err != nil {
+ return response.ErrorWithI18n(l.ctx, "login.resetPasswordError", "重置密码失败"), nil
+ }
+ err = user.Update().SetPassword(encrypt).Exec(l.ctx)
+ if err != nil {
+ return response.ErrorWithI18n(l.ctx, "login.resetPasswordError", "重置密码失败"), err
+ }
+ return response.Success(), nil
}
diff --git a/app/core/api/internal/svc/service_context.go b/app/core/api/internal/svc/service_context.go
index d348322..32ed338 100644
--- a/app/core/api/internal/svc/service_context.go
+++ b/app/core/api/internal/svc/service_context.go
@@ -1,6 +1,7 @@
package svc
import (
+ "github.com/casbin/casbin/v2"
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
"github.com/rbcervilla/redisstore/v9"
"github.com/redis/go-redis/v9"
@@ -10,6 +11,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/internal/config"
"schisandra-album-cloud-microservices/app/core/api/internal/middleware"
+ "schisandra-album-cloud-microservices/app/core/api/repository/casbinx"
"schisandra-album-cloud-microservices/app/core/api/repository/ip2region"
"schisandra-album-cloud-microservices/app/core/api/repository/mongodb"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql"
@@ -26,6 +28,7 @@ type ServiceContext struct {
MongoClient *mongo.Database
Session *redisstore.RedisStore
Ip2Region *xdb.Searcher
+ CasbinEnforcer *casbin.CachedEnforcer
}
func NewServiceContext(c config.Config) *ServiceContext {
@@ -37,5 +40,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
MongoClient: mongodb.NewMongoDB(c.Mongo.Uri, c.Mongo.Username, c.Mongo.Password, c.Mongo.AuthSource, c.Mongo.Database),
Session: redis_session.NewRedisSession(c.Redis.Host, c.Redis.Pass),
Ip2Region: ip2region.NewIP2Region(),
+ CasbinEnforcer: casbinx.NewCasbin(c.Mysql.DataSource),
}
}
diff --git a/app/core/api/internal/types/redis_token.go b/app/core/api/internal/types/redis_token.go
new file mode 100644
index 0000000..ec2c23c
--- /dev/null
+++ b/app/core/api/internal/types/redis_token.go
@@ -0,0 +1,16 @@
+package types
+
+import "encoding/json"
+
+type RedisToken struct {
+ AccessToken string `json:"access_token"`
+ UID string `json:"uid"`
+}
+
+func (res RedisToken) MarshalBinary() ([]byte, error) {
+ return json.Marshal(res)
+}
+
+func (res RedisToken) UnmarshalBinary(data []byte) error {
+ return json.Unmarshal(data, &res)
+}
diff --git a/app/core/api/internal/types/session.go b/app/core/api/internal/types/session.go
new file mode 100644
index 0000000..4a41c94
--- /dev/null
+++ b/app/core/api/internal/types/session.go
@@ -0,0 +1,17 @@
+package types
+
+import "encoding/json"
+
+// SessionData 返回数据
+type SessionData struct {
+ RefreshToken string `json:"refresh_token"`
+ UID string `json:"uid"`
+}
+
+func (res SessionData) MarshalBinary() ([]byte, error) {
+ return json.Marshal(res)
+}
+
+func (res SessionData) UnmarshalBinary(data []byte) error {
+ return json.Unmarshal(data, &res)
+}
diff --git a/app/core/api/repository/casbinx/adapter/adapter.go b/app/core/api/repository/casbinx/adapter/adapter.go
new file mode 100644
index 0000000..e92a897
--- /dev/null
+++ b/app/core/api/repository/casbinx/adapter/adapter.go
@@ -0,0 +1,515 @@
+package adapter
+
+import (
+ "context"
+ "database/sql"
+ "fmt"
+ "reflect"
+ "strings"
+
+ "entgo.io/ent/dialect"
+ entsql "entgo.io/ent/dialect/sql"
+ "github.com/casbin/casbin/v2/model"
+ "github.com/casbin/casbin/v2/persist"
+
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
+ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
+
+ "github.com/pkg/errors"
+)
+
+const (
+ DefaultTableName = "sca_auth_permission_rule"
+ DefaultDatabase = "schisandra_album_cloud"
+)
+
+type Adapter struct {
+ client *ent.Client
+ ctx context.Context
+
+ filtered bool
+}
+
+type Filter struct {
+ Ptype []string
+ V0 []string
+ V1 []string
+ V2 []string
+ V3 []string
+ V4 []string
+ V5 []string
+}
+
+type Option func(a *Adapter) error
+
+func open(driverName, dataSourceName string) (*ent.Client, error) {
+ db, err := sql.Open(driverName, dataSourceName)
+ if err != nil {
+ return nil, err
+ }
+ var drv dialect.Driver
+ if driverName == "pgx" {
+ drv = entsql.OpenDB(dialect.Postgres, db)
+ } else {
+ drv = entsql.OpenDB(driverName, db)
+ }
+ return ent.NewClient(ent.Driver(drv)), nil
+}
+
+// NewAdapter returns an adapter by driver name and data source string.
+func NewAdapter(driverName, dataSourceName string, options ...Option) (*Adapter, error) {
+ client, err := open(driverName, dataSourceName)
+ if err != nil {
+ return nil, err
+ }
+ a := &Adapter{
+ client: client,
+ ctx: context.Background(),
+ }
+ for _, option := range options {
+ if err := option(a); err != nil {
+ return nil, err
+ }
+ }
+ if err := client.Schema.Create(a.ctx); err != nil {
+ return nil, err
+ }
+ return a, nil
+}
+
+// NewAdapterWithClient create an adapter with client passed in.
+// This method does not ensure the existence of database, user should create database manually.
+func NewAdapterWithClient(client *ent.Client, options ...Option) (*Adapter, error) {
+ a := &Adapter{
+ client: client,
+ ctx: context.Background(),
+ }
+ for _, option := range options {
+ if err := option(a); err != nil {
+ return nil, err
+ }
+ }
+ if err := client.Schema.Create(a.ctx); err != nil {
+ return nil, err
+ }
+ return a, nil
+}
+
+// LoadPolicy loads all policy rules from the storage.
+func (a *Adapter) LoadPolicy(model model.Model) error {
+ policies, err := a.client.ScaAuthPermissionRule.Query().Order(ent.Asc("id")).All(a.ctx)
+ if err != nil {
+ return err
+ }
+ for _, policy := range policies {
+ loadPolicyLine(policy, model)
+ }
+ return nil
+}
+
+// LoadFilteredPolicy loads only policy rules that match the filter.
+// Filter parameter here is a Filter structure
+func (a *Adapter) LoadFilteredPolicy(model model.Model, filter interface{}) error {
+
+ filterValue, ok := filter.(Filter)
+ if !ok {
+ return fmt.Errorf("invalid filter type: %v", reflect.TypeOf(filter))
+ }
+
+ session := a.client.ScaAuthPermissionRule.Query()
+ if len(filterValue.Ptype) != 0 {
+ session.Where(scaauthpermissionrule.PtypeIn(filterValue.Ptype...))
+ }
+ if len(filterValue.V0) != 0 {
+ session.Where(scaauthpermissionrule.V0In(filterValue.V0...))
+ }
+ if len(filterValue.V1) != 0 {
+ session.Where(scaauthpermissionrule.V1In(filterValue.V1...))
+ }
+ if len(filterValue.V2) != 0 {
+ session.Where(scaauthpermissionrule.V2In(filterValue.V2...))
+ }
+ if len(filterValue.V3) != 0 {
+ session.Where(scaauthpermissionrule.V3In(filterValue.V3...))
+ }
+ if len(filterValue.V4) != 0 {
+ session.Where(scaauthpermissionrule.V4In(filterValue.V4...))
+ }
+ if len(filterValue.V5) != 0 {
+ session.Where(scaauthpermissionrule.V5In(filterValue.V5...))
+ }
+
+ lines, err := session.All(a.ctx)
+ if err != nil {
+ return err
+ }
+
+ for _, line := range lines {
+ loadPolicyLine(line, model)
+ }
+ a.filtered = true
+
+ return nil
+}
+
+// IsFiltered returns true if the loaded policy has been filtered.
+func (a *Adapter) IsFiltered() bool {
+ return a.filtered
+}
+
+// SavePolicy saves all policy rules to the storage.
+func (a *Adapter) SavePolicy(model model.Model) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ if _, err := tx.ScaAuthPermissionRule.Delete().Exec(a.ctx); err != nil {
+ return err
+ }
+ lines := make([]*ent.ScaAuthPermissionRuleCreate, 0)
+
+ for ptype, ast := range model["p"] {
+ for _, policy := range ast.Policy {
+ line := a.savePolicyLine(tx, ptype, policy)
+ lines = append(lines, line)
+ }
+ }
+
+ for ptype, ast := range model["g"] {
+ for _, policy := range ast.Policy {
+ line := a.savePolicyLine(tx, ptype, policy)
+ lines = append(lines, line)
+ }
+ }
+
+ _, err := tx.ScaAuthPermissionRule.CreateBulk(lines...).Save(a.ctx)
+ return err
+ })
+}
+
+// AddPolicy adds a policy rule to the storage.
+// This is part of the Auto-Save feature.
+func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ _, err := a.savePolicyLine(tx, ptype, rule).Save(a.ctx)
+ return err
+ })
+}
+
+// RemovePolicy removes a policy rule from the storage.
+// This is part of the Auto-Save feature.
+func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ instance := a.toInstance(ptype, rule)
+ _, err := tx.ScaAuthPermissionRule.Delete().Where(
+ scaauthpermissionrule.PtypeEQ(instance.Ptype),
+ scaauthpermissionrule.V0EQ(instance.V0),
+ scaauthpermissionrule.V1EQ(instance.V1),
+ scaauthpermissionrule.V2EQ(instance.V2),
+ scaauthpermissionrule.V3EQ(instance.V3),
+ scaauthpermissionrule.V4EQ(instance.V4),
+ scaauthpermissionrule.V5EQ(instance.V5),
+ ).Exec(a.ctx)
+ return err
+ })
+}
+
+// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
+// This is part of the Auto-Save feature.
+func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ cond := make([]predicate.ScaAuthPermissionRule, 0)
+ cond = append(cond, scaauthpermissionrule.PtypeEQ(ptype))
+ if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) && len(fieldValues[0-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V0EQ(fieldValues[0-fieldIndex]))
+ }
+ if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) && len(fieldValues[1-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V1EQ(fieldValues[1-fieldIndex]))
+ }
+ if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) && len(fieldValues[2-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V2EQ(fieldValues[2-fieldIndex]))
+ }
+ if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) && len(fieldValues[3-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V3EQ(fieldValues[3-fieldIndex]))
+ }
+ if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) && len(fieldValues[4-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V4EQ(fieldValues[4-fieldIndex]))
+ }
+ if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) && len(fieldValues[5-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V5EQ(fieldValues[5-fieldIndex]))
+ }
+ _, err := tx.ScaAuthPermissionRule.Delete().Where(
+ cond...,
+ ).Exec(a.ctx)
+ return err
+ })
+}
+
+// AddPolicies adds policy rules to the storage.
+// This is part of the Auto-Save feature.
+func (a *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ return a.createPolicies(tx, ptype, rules)
+ })
+}
+
+// RemovePolicies removes policy rules from the storage.
+// This is part of the Auto-Save feature.
+func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ for _, rule := range rules {
+ instance := a.toInstance(ptype, rule)
+ if _, err := tx.ScaAuthPermissionRule.Delete().Where(
+ scaauthpermissionrule.PtypeEQ(instance.Ptype),
+ scaauthpermissionrule.V0EQ(instance.V0),
+ scaauthpermissionrule.V1EQ(instance.V1),
+ scaauthpermissionrule.V2EQ(instance.V2),
+ scaauthpermissionrule.V3EQ(instance.V3),
+ scaauthpermissionrule.V4EQ(instance.V4),
+ scaauthpermissionrule.V5EQ(instance.V5),
+ ).Exec(a.ctx); err != nil {
+ return err
+ }
+ }
+ return nil
+ })
+}
+
+func (a *Adapter) WithTx(fn func(tx *ent.Tx) error) error {
+ tx, err := a.client.Tx(a.ctx)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if v := recover(); v != nil {
+ _ = tx.Rollback()
+ panic(v)
+ }
+ }()
+ if err := fn(tx); err != nil {
+ if rerr := tx.Rollback(); rerr != nil {
+ err = errors.Wrapf(err, "rolling back transaction: %v", rerr)
+ }
+ return err
+ }
+ if err := tx.Commit(); err != nil {
+ return errors.Wrapf(err, "committing transaction: %v", err)
+ }
+ return nil
+}
+
+func loadPolicyLine(line *ent.ScaAuthPermissionRule, model model.Model) {
+ var p = []string{line.Ptype,
+ line.V0, line.V1, line.V2, line.V3, line.V4, line.V5}
+
+ var lineText string
+ if line.V5 != "" {
+ lineText = strings.Join(p, ", ")
+ } else if line.V4 != "" {
+ lineText = strings.Join(p[:6], ", ")
+ } else if line.V3 != "" {
+ lineText = strings.Join(p[:5], ", ")
+ } else if line.V2 != "" {
+ lineText = strings.Join(p[:4], ", ")
+ } else if line.V1 != "" {
+ lineText = strings.Join(p[:3], ", ")
+ } else if line.V0 != "" {
+ lineText = strings.Join(p[:2], ", ")
+ }
+
+ persist.LoadPolicyLine(lineText, model)
+}
+
+func (a *Adapter) toInstance(ptype string, rule []string) *ent.ScaAuthPermissionRule {
+ instance := &ent.ScaAuthPermissionRule{}
+
+ instance.Ptype = ptype
+
+ if len(rule) > 0 {
+ instance.V0 = rule[0]
+ }
+ if len(rule) > 1 {
+ instance.V1 = rule[1]
+ }
+ if len(rule) > 2 {
+ instance.V2 = rule[2]
+ }
+ if len(rule) > 3 {
+ instance.V3 = rule[3]
+ }
+ if len(rule) > 4 {
+ instance.V4 = rule[4]
+ }
+ if len(rule) > 5 {
+ instance.V5 = rule[5]
+ }
+ return instance
+}
+
+func (a *Adapter) savePolicyLine(tx *ent.Tx, ptype string, rule []string) *ent.ScaAuthPermissionRuleCreate {
+ line := tx.ScaAuthPermissionRule.Create()
+
+ line.SetPtype(ptype)
+ if len(rule) > 0 {
+ line.SetV0(rule[0])
+ }
+ if len(rule) > 1 {
+ line.SetV1(rule[1])
+ }
+ if len(rule) > 2 {
+ line.SetV2(rule[2])
+ }
+ if len(rule) > 3 {
+ line.SetV3(rule[3])
+ }
+ if len(rule) > 4 {
+ line.SetV4(rule[4])
+ }
+ if len(rule) > 5 {
+ line.SetV5(rule[5])
+ }
+
+ return line
+}
+
+// UpdatePolicy updates a policy rule from storage.
+// This is part of the Auto-Save feature.
+func (a *Adapter) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ rule := a.toInstance(ptype, oldRule)
+ line := tx.ScaAuthPermissionRule.Update().Where(
+ scaauthpermissionrule.PtypeEQ(rule.Ptype),
+ scaauthpermissionrule.V0EQ(rule.V0),
+ scaauthpermissionrule.V1EQ(rule.V1),
+ scaauthpermissionrule.V2EQ(rule.V2),
+ scaauthpermissionrule.V3EQ(rule.V3),
+ scaauthpermissionrule.V4EQ(rule.V4),
+ scaauthpermissionrule.V5EQ(rule.V5),
+ )
+ rule = a.toInstance(ptype, newPolicy)
+ line.SetV0(rule.V0)
+ line.SetV1(rule.V1)
+ line.SetV2(rule.V2)
+ line.SetV3(rule.V3)
+ line.SetV4(rule.V4)
+ line.SetV5(rule.V5)
+ _, err := line.Save(a.ctx)
+ return err
+ })
+}
+
+// UpdatePolicies updates some policy rules to storage, like db, redis.
+func (a *Adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error {
+ return a.WithTx(func(tx *ent.Tx) error {
+ for _, policy := range oldRules {
+ rule := a.toInstance(ptype, policy)
+ if _, err := tx.ScaAuthPermissionRule.Delete().Where(
+ scaauthpermissionrule.PtypeEQ(rule.Ptype),
+ scaauthpermissionrule.V0EQ(rule.V0),
+ scaauthpermissionrule.V1EQ(rule.V1),
+ scaauthpermissionrule.V2EQ(rule.V2),
+ scaauthpermissionrule.V3EQ(rule.V3),
+ scaauthpermissionrule.V4EQ(rule.V4),
+ scaauthpermissionrule.V5EQ(rule.V5),
+ ).Exec(a.ctx); err != nil {
+ return err
+ }
+ }
+ lines := make([]*ent.ScaAuthPermissionRuleCreate, 0)
+ for _, policy := range newRules {
+ lines = append(lines, a.savePolicyLine(tx, ptype, policy))
+ }
+ if _, err := tx.ScaAuthPermissionRule.CreateBulk(lines...).Save(a.ctx); err != nil {
+ return err
+ }
+ return nil
+ })
+}
+
+// UpdateFilteredPolicies deletes old rules and adds new rules.
+func (a *Adapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) ([][]string, error) {
+ oldPolicies := make([][]string, 0)
+ err := a.WithTx(func(tx *ent.Tx) error {
+ cond := make([]predicate.ScaAuthPermissionRule, 0)
+ cond = append(cond, scaauthpermissionrule.PtypeEQ(ptype))
+ if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) && len(fieldValues[0-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V0EQ(fieldValues[0-fieldIndex]))
+ }
+ if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) && len(fieldValues[1-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V1EQ(fieldValues[1-fieldIndex]))
+ }
+ if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) && len(fieldValues[2-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V2EQ(fieldValues[2-fieldIndex]))
+ }
+ if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) && len(fieldValues[3-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V3EQ(fieldValues[3-fieldIndex]))
+ }
+ if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) && len(fieldValues[4-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V4EQ(fieldValues[4-fieldIndex]))
+ }
+ if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) && len(fieldValues[5-fieldIndex]) > 0 {
+ cond = append(cond, scaauthpermissionrule.V5EQ(fieldValues[5-fieldIndex]))
+ }
+ rules, err := tx.ScaAuthPermissionRule.Query().
+ Where(cond...).
+ All(a.ctx)
+ if err != nil {
+ return err
+ }
+ ruleIDs := make([]int, 0, len(rules))
+ for _, r := range rules {
+ ruleIDs = append(ruleIDs, r.ID)
+ }
+
+ _, err = tx.ScaAuthPermissionRule.Delete().
+ Where(scaauthpermissionrule.IDIn(ruleIDs...)).
+ Exec(a.ctx)
+ if err != nil {
+ return err
+ }
+
+ if err := a.createPolicies(tx, ptype, newPolicies); err != nil {
+ return err
+ }
+ for _, rule := range rules {
+ oldPolicies = append(oldPolicies, ScaAuthPermissionRuleToStringArray(rule))
+ }
+ return nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ return oldPolicies, nil
+}
+
+func (a *Adapter) createPolicies(tx *ent.Tx, ptype string, policies [][]string) error {
+ lines := make([]*ent.ScaAuthPermissionRuleCreate, 0)
+ for _, policy := range policies {
+ lines = append(lines, a.savePolicyLine(tx, ptype, policy))
+ }
+ if _, err := tx.ScaAuthPermissionRule.CreateBulk(lines...).Save(a.ctx); err != nil {
+ return err
+ }
+ return nil
+}
+
+func ScaAuthPermissionRuleToStringArray(rule *ent.ScaAuthPermissionRule) []string {
+ arr := make([]string, 0)
+ if rule.V0 != "" {
+ arr = append(arr, rule.V0)
+ }
+ if rule.V1 != "" {
+ arr = append(arr, rule.V1)
+ }
+ if rule.V2 != "" {
+ arr = append(arr, rule.V2)
+ }
+ if rule.V3 != "" {
+ arr = append(arr, rule.V3)
+ }
+ if rule.V4 != "" {
+ arr = append(arr, rule.V4)
+ }
+ if rule.V5 != "" {
+ arr = append(arr, rule.V5)
+ }
+ return arr
+}
diff --git a/app/core/api/repository/casbinx/init.go b/app/core/api/repository/casbinx/init.go
new file mode 100644
index 0000000..2699adc
--- /dev/null
+++ b/app/core/api/repository/casbinx/init.go
@@ -0,0 +1,39 @@
+package casbinx
+
+import (
+ "os"
+ "path/filepath"
+
+ "github.com/casbin/casbin/v2"
+ "github.com/casbin/casbin/v2/model"
+
+ "schisandra-album-cloud-microservices/app/core/api/repository/casbinx/adapter"
+)
+
+// NewCasbin creates a new casbinx enforcer with a mysql adapter and loads the policy from the file system.
+func NewCasbin(dataSourceName string) *casbin.CachedEnforcer {
+ a, err := adapter.NewAdapter("mysql", dataSourceName)
+ if err != nil {
+ panic(err)
+ }
+ cwd, err := os.Getwd()
+ if err != nil {
+ panic(err)
+ }
+ path := filepath.Join(cwd, "etc", "rbac_model.conf")
+ modelFile, err := model.NewModelFromFile(path)
+ if err != nil {
+ panic(err)
+ }
+ e, err := casbin.NewCachedEnforcer(modelFile, a)
+ if err != nil {
+ panic(err)
+ }
+ e.EnableCache(true)
+ e.SetExpireTime(60 * 60)
+ err = e.LoadPolicy()
+ if err != nil {
+ panic(err)
+ }
+ return e
+}
diff --git a/app/core/api/repository/idgenerator/init.go b/app/core/api/repository/idgenerator/init.go
new file mode 100644
index 0000000..c3819a1
--- /dev/null
+++ b/app/core/api/repository/idgenerator/init.go
@@ -0,0 +1,10 @@
+package idgenerator
+
+import "github.com/yitter/idgenerator-go/idgen"
+
+func NewIDGenerator() {
+ var options = idgen.NewIdGeneratorOptions(1)
+ options.WorkerIdBitLength = 6 // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
+ options.SeqBitLength = 6 // 默认值6,限制每毫秒生成的ID个数。若生成速度超过5万个/秒,建议加大 SeqBitLength 到 10。
+ idgen.SetIdGenerator(options)
+}
diff --git a/app/core/api/repository/mysql/ent/client.go b/app/core/api/repository/mysql/ent/client.go
index fea3b5c..a6eb270 100644
--- a/app/core/api/repository/mysql/ent/client.go
+++ b/app/core/api/repository/mysql/ent/client.go
@@ -20,7 +20,6 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
// Client is the client that holds all ent builders.
@@ -299,7 +298,7 @@ func (c *ScaAuthPermissionRuleClient) UpdateOne(sapr *ScaAuthPermissionRule) *Sc
}
// UpdateOneID returns an update builder for the given id.
-func (c *ScaAuthPermissionRuleClient) UpdateOneID(id int64) *ScaAuthPermissionRuleUpdateOne {
+func (c *ScaAuthPermissionRuleClient) UpdateOneID(id int) *ScaAuthPermissionRuleUpdateOne {
mutation := newScaAuthPermissionRuleMutation(c.config, OpUpdateOne, withScaAuthPermissionRuleID(id))
return &ScaAuthPermissionRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
@@ -316,7 +315,7 @@ func (c *ScaAuthPermissionRuleClient) DeleteOne(sapr *ScaAuthPermissionRule) *Sc
}
// DeleteOneID returns a builder for deleting the given entity by its id.
-func (c *ScaAuthPermissionRuleClient) DeleteOneID(id int64) *ScaAuthPermissionRuleDeleteOne {
+func (c *ScaAuthPermissionRuleClient) DeleteOneID(id int) *ScaAuthPermissionRuleDeleteOne {
builder := c.Delete().Where(scaauthpermissionrule.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
@@ -333,12 +332,12 @@ func (c *ScaAuthPermissionRuleClient) Query() *ScaAuthPermissionRuleQuery {
}
// Get returns a ScaAuthPermissionRule entity by its id.
-func (c *ScaAuthPermissionRuleClient) Get(ctx context.Context, id int64) (*ScaAuthPermissionRule, error) {
+func (c *ScaAuthPermissionRuleClient) Get(ctx context.Context, id int) (*ScaAuthPermissionRule, error) {
return c.Query().Where(scaauthpermissionrule.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
-func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int64) *ScaAuthPermissionRule {
+func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int) *ScaAuthPermissionRule {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
@@ -346,22 +345,6 @@ func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int64) *ScaAu
return obj
}
-// QueryScaAuthRole queries the sca_auth_role edge of a ScaAuthPermissionRule.
-func (c *ScaAuthPermissionRuleClient) QueryScaAuthRole(sapr *ScaAuthPermissionRule) *ScaAuthRoleQuery {
- query := (&ScaAuthRoleClient{config: c.config}).Query()
- query.path = func(context.Context) (fromV *sql.Selector, _ error) {
- id := sapr.ID
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID, id),
- sqlgraph.To(scaauthrole.Table, scaauthrole.FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, scaauthpermissionrule.ScaAuthRoleTable, scaauthpermissionrule.ScaAuthRoleColumn),
- )
- fromV = sqlgraph.Neighbors(sapr.driver.Dialect(), step)
- return fromV, nil
- }
- return query
-}
-
// Hooks returns the client hooks.
func (c *ScaAuthPermissionRuleClient) Hooks() []Hook {
return c.hooks.ScaAuthPermissionRule
@@ -495,22 +478,6 @@ func (c *ScaAuthRoleClient) GetX(ctx context.Context, id int64) *ScaAuthRole {
return obj
}
-// QueryScaAuthPermissionRule queries the sca_auth_permission_rule edge of a ScaAuthRole.
-func (c *ScaAuthRoleClient) QueryScaAuthPermissionRule(sar *ScaAuthRole) *ScaAuthPermissionRuleQuery {
- query := (&ScaAuthPermissionRuleClient{config: c.config}).Query()
- query.path = func(context.Context) (fromV *sql.Selector, _ error) {
- id := sar.ID
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthrole.Table, scaauthrole.FieldID, id),
- sqlgraph.To(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, scaauthrole.ScaAuthPermissionRuleTable, scaauthrole.ScaAuthPermissionRuleColumn),
- )
- fromV = sqlgraph.Neighbors(sar.driver.Dialect(), step)
- return fromV, nil
- }
- return query
-}
-
// Hooks returns the client hooks.
func (c *ScaAuthRoleClient) Hooks() []Hook {
return c.hooks.ScaAuthRole
@@ -644,38 +611,6 @@ func (c *ScaAuthUserClient) GetX(ctx context.Context, id int64) *ScaAuthUser {
return obj
}
-// QueryScaAuthUserSocial queries the sca_auth_user_social edge of a ScaAuthUser.
-func (c *ScaAuthUserClient) QueryScaAuthUserSocial(sau *ScaAuthUser) *ScaAuthUserSocialQuery {
- query := (&ScaAuthUserSocialClient{config: c.config}).Query()
- query.path = func(context.Context) (fromV *sql.Selector, _ error) {
- id := sau.ID
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, id),
- sqlgraph.To(scaauthusersocial.Table, scaauthusersocial.FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserSocialTable, scaauthuser.ScaAuthUserSocialColumn),
- )
- fromV = sqlgraph.Neighbors(sau.driver.Dialect(), step)
- return fromV, nil
- }
- return query
-}
-
-// QueryScaAuthUserDevice queries the sca_auth_user_device edge of a ScaAuthUser.
-func (c *ScaAuthUserClient) QueryScaAuthUserDevice(sau *ScaAuthUser) *ScaAuthUserDeviceQuery {
- query := (&ScaAuthUserDeviceClient{config: c.config}).Query()
- query.path = func(context.Context) (fromV *sql.Selector, _ error) {
- id := sau.ID
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, id),
- sqlgraph.To(scaauthuserdevice.Table, scaauthuserdevice.FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserDeviceTable, scaauthuser.ScaAuthUserDeviceColumn),
- )
- fromV = sqlgraph.Neighbors(sau.driver.Dialect(), step)
- return fromV, nil
- }
- return query
-}
-
// Hooks returns the client hooks.
func (c *ScaAuthUserClient) Hooks() []Hook {
return c.hooks.ScaAuthUser
@@ -809,22 +744,6 @@ func (c *ScaAuthUserDeviceClient) GetX(ctx context.Context, id int64) *ScaAuthUs
return obj
}
-// QueryScaAuthUser queries the sca_auth_user edge of a ScaAuthUserDevice.
-func (c *ScaAuthUserDeviceClient) QueryScaAuthUser(saud *ScaAuthUserDevice) *ScaAuthUserQuery {
- query := (&ScaAuthUserClient{config: c.config}).Query()
- query.path = func(context.Context) (fromV *sql.Selector, _ error) {
- id := saud.ID
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthuserdevice.Table, scaauthuserdevice.FieldID, id),
- sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, scaauthuserdevice.ScaAuthUserTable, scaauthuserdevice.ScaAuthUserColumn),
- )
- fromV = sqlgraph.Neighbors(saud.driver.Dialect(), step)
- return fromV, nil
- }
- return query
-}
-
// Hooks returns the client hooks.
func (c *ScaAuthUserDeviceClient) Hooks() []Hook {
return c.hooks.ScaAuthUserDevice
@@ -958,22 +877,6 @@ func (c *ScaAuthUserSocialClient) GetX(ctx context.Context, id int64) *ScaAuthUs
return obj
}
-// QueryScaAuthUser queries the sca_auth_user edge of a ScaAuthUserSocial.
-func (c *ScaAuthUserSocialClient) QueryScaAuthUser(saus *ScaAuthUserSocial) *ScaAuthUserQuery {
- query := (&ScaAuthUserClient{config: c.config}).Query()
- query.path = func(context.Context) (fromV *sql.Selector, _ error) {
- id := saus.ID
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, id),
- sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn),
- )
- fromV = sqlgraph.Neighbors(saus.driver.Dialect(), step)
- return fromV, nil
- }
- return query
-}
-
// Hooks returns the client hooks.
func (c *ScaAuthUserSocialClient) Hooks() []Hook {
return c.hooks.ScaAuthUserSocial
diff --git a/app/core/api/repository/mysql/ent/entql.go b/app/core/api/repository/mysql/ent/entql.go
index 5d58d00..da3ac1e 100644
--- a/app/core/api/repository/mysql/ent/entql.go
+++ b/app/core/api/repository/mysql/ent/entql.go
@@ -3,7 +3,6 @@
package ent
import (
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
@@ -24,7 +23,7 @@ var schemaGraph = func() *sqlgraph.Schema {
Table: scaauthpermissionrule.Table,
Columns: scaauthpermissionrule.Columns,
ID: &sqlgraph.FieldSpec{
- Type: field.TypeInt64,
+ Type: field.TypeInt,
Column: scaauthpermissionrule.FieldID,
},
},
@@ -77,7 +76,7 @@ var schemaGraph = func() *sqlgraph.Schema {
scaauthuser.FieldEmail: {Type: field.TypeString, Column: scaauthuser.FieldEmail},
scaauthuser.FieldPhone: {Type: field.TypeString, Column: scaauthuser.FieldPhone},
scaauthuser.FieldPassword: {Type: field.TypeString, Column: scaauthuser.FieldPassword},
- scaauthuser.FieldGender: {Type: field.TypeString, Column: scaauthuser.FieldGender},
+ scaauthuser.FieldGender: {Type: field.TypeInt8, Column: scaauthuser.FieldGender},
scaauthuser.FieldAvatar: {Type: field.TypeString, Column: scaauthuser.FieldAvatar},
scaauthuser.FieldStatus: {Type: field.TypeInt8, Column: scaauthuser.FieldStatus},
scaauthuser.FieldIntroduce: {Type: field.TypeString, Column: scaauthuser.FieldIntroduce},
@@ -135,78 +134,6 @@ var schemaGraph = func() *sqlgraph.Schema {
scaauthusersocial.FieldStatus: {Type: field.TypeInt, Column: scaauthusersocial.FieldStatus},
},
}
- graph.MustAddE(
- "sca_auth_role",
- &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthpermissionrule.ScaAuthRoleTable,
- Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
- Bidi: false,
- },
- "ScaAuthPermissionRule",
- "ScaAuthRole",
- )
- graph.MustAddE(
- "sca_auth_permission_rule",
- &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- },
- "ScaAuthRole",
- "ScaAuthPermissionRule",
- )
- graph.MustAddE(
- "sca_auth_user_social",
- &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- },
- "ScaAuthUser",
- "ScaAuthUserSocial",
- )
- graph.MustAddE(
- "sca_auth_user_device",
- &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- },
- "ScaAuthUser",
- "ScaAuthUserDevice",
- )
- graph.MustAddE(
- "sca_auth_user",
- &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthuserdevice.ScaAuthUserTable,
- Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
- Bidi: false,
- },
- "ScaAuthUserDevice",
- "ScaAuthUser",
- )
- graph.MustAddE(
- "sca_auth_user",
- &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthusersocial.ScaAuthUserTable,
- Columns: []string{scaauthusersocial.ScaAuthUserColumn},
- Bidi: false,
- },
- "ScaAuthUserSocial",
- "ScaAuthUser",
- )
return graph
}()
@@ -251,8 +178,8 @@ func (f *ScaAuthPermissionRuleFilter) Where(p entql.P) {
})
}
-// WhereID applies the entql int64 predicate on the id field.
-func (f *ScaAuthPermissionRuleFilter) WhereID(p entql.Int64P) {
+// WhereID applies the entql int predicate on the id field.
+func (f *ScaAuthPermissionRuleFilter) WhereID(p entql.IntP) {
f.Where(p.Field(scaauthpermissionrule.FieldID))
}
@@ -291,20 +218,6 @@ func (f *ScaAuthPermissionRuleFilter) WhereV5(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldV5))
}
-// WhereHasScaAuthRole applies a predicate to check if query has an edge sca_auth_role.
-func (f *ScaAuthPermissionRuleFilter) WhereHasScaAuthRole() {
- f.Where(entql.HasEdge("sca_auth_role"))
-}
-
-// WhereHasScaAuthRoleWith applies a predicate to check if query has an edge sca_auth_role with a given conditions (other predicates).
-func (f *ScaAuthPermissionRuleFilter) WhereHasScaAuthRoleWith(preds ...predicate.ScaAuthRole) {
- f.Where(entql.HasEdgeWith("sca_auth_role", sqlgraph.WrapFunc(func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })))
-}
-
// addPredicate implements the predicateAdder interface.
func (sarq *ScaAuthRoleQuery) addPredicate(pred func(s *sql.Selector)) {
sarq.predicates = append(sarq.predicates, pred)
@@ -370,20 +283,6 @@ func (f *ScaAuthRoleFilter) WhereRoleKey(p entql.StringP) {
f.Where(p.Field(scaauthrole.FieldRoleKey))
}
-// WhereHasScaAuthPermissionRule applies a predicate to check if query has an edge sca_auth_permission_rule.
-func (f *ScaAuthRoleFilter) WhereHasScaAuthPermissionRule() {
- f.Where(entql.HasEdge("sca_auth_permission_rule"))
-}
-
-// WhereHasScaAuthPermissionRuleWith applies a predicate to check if query has an edge sca_auth_permission_rule with a given conditions (other predicates).
-func (f *ScaAuthRoleFilter) WhereHasScaAuthPermissionRuleWith(preds ...predicate.ScaAuthPermissionRule) {
- f.Where(entql.HasEdgeWith("sca_auth_permission_rule", sqlgraph.WrapFunc(func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })))
-}
-
// addPredicate implements the predicateAdder interface.
func (sauq *ScaAuthUserQuery) addPredicate(pred func(s *sql.Selector)) {
sauq.predicates = append(sauq.predicates, pred)
@@ -469,8 +368,8 @@ func (f *ScaAuthUserFilter) WherePassword(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldPassword))
}
-// WhereGender applies the entql string predicate on the gender field.
-func (f *ScaAuthUserFilter) WhereGender(p entql.StringP) {
+// WhereGender applies the entql int8 predicate on the gender field.
+func (f *ScaAuthUserFilter) WhereGender(p entql.Int8P) {
f.Where(p.Field(scaauthuser.FieldGender))
}
@@ -504,34 +403,6 @@ func (f *ScaAuthUserFilter) WhereCompany(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldCompany))
}
-// WhereHasScaAuthUserSocial applies a predicate to check if query has an edge sca_auth_user_social.
-func (f *ScaAuthUserFilter) WhereHasScaAuthUserSocial() {
- f.Where(entql.HasEdge("sca_auth_user_social"))
-}
-
-// WhereHasScaAuthUserSocialWith applies a predicate to check if query has an edge sca_auth_user_social with a given conditions (other predicates).
-func (f *ScaAuthUserFilter) WhereHasScaAuthUserSocialWith(preds ...predicate.ScaAuthUserSocial) {
- f.Where(entql.HasEdgeWith("sca_auth_user_social", sqlgraph.WrapFunc(func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })))
-}
-
-// WhereHasScaAuthUserDevice applies a predicate to check if query has an edge sca_auth_user_device.
-func (f *ScaAuthUserFilter) WhereHasScaAuthUserDevice() {
- f.Where(entql.HasEdge("sca_auth_user_device"))
-}
-
-// WhereHasScaAuthUserDeviceWith applies a predicate to check if query has an edge sca_auth_user_device with a given conditions (other predicates).
-func (f *ScaAuthUserFilter) WhereHasScaAuthUserDeviceWith(preds ...predicate.ScaAuthUserDevice) {
- f.Where(entql.HasEdgeWith("sca_auth_user_device", sqlgraph.WrapFunc(func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })))
-}
-
// addPredicate implements the predicateAdder interface.
func (saudq *ScaAuthUserDeviceQuery) addPredicate(pred func(s *sql.Selector)) {
saudq.predicates = append(saudq.predicates, pred)
@@ -652,20 +523,6 @@ func (f *ScaAuthUserDeviceFilter) WhereEngineVersion(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldEngineVersion))
}
-// WhereHasScaAuthUser applies a predicate to check if query has an edge sca_auth_user.
-func (f *ScaAuthUserDeviceFilter) WhereHasScaAuthUser() {
- f.Where(entql.HasEdge("sca_auth_user"))
-}
-
-// WhereHasScaAuthUserWith applies a predicate to check if query has an edge sca_auth_user with a given conditions (other predicates).
-func (f *ScaAuthUserDeviceFilter) WhereHasScaAuthUserWith(preds ...predicate.ScaAuthUser) {
- f.Where(entql.HasEdgeWith("sca_auth_user", sqlgraph.WrapFunc(func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })))
-}
-
// addPredicate implements the predicateAdder interface.
func (sausq *ScaAuthUserSocialQuery) addPredicate(pred func(s *sql.Selector)) {
sausq.predicates = append(sausq.predicates, pred)
@@ -740,17 +597,3 @@ func (f *ScaAuthUserSocialFilter) WhereSource(p entql.StringP) {
func (f *ScaAuthUserSocialFilter) WhereStatus(p entql.IntP) {
f.Where(p.Field(scaauthusersocial.FieldStatus))
}
-
-// WhereHasScaAuthUser applies a predicate to check if query has an edge sca_auth_user.
-func (f *ScaAuthUserSocialFilter) WhereHasScaAuthUser() {
- f.Where(entql.HasEdge("sca_auth_user"))
-}
-
-// WhereHasScaAuthUserWith applies a predicate to check if query has an edge sca_auth_user with a given conditions (other predicates).
-func (f *ScaAuthUserSocialFilter) WhereHasScaAuthUserWith(preds ...predicate.ScaAuthUser) {
- f.Where(entql.HasEdgeWith("sca_auth_user", sqlgraph.WrapFunc(func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })))
-}
diff --git a/app/core/api/repository/mysql/ent/migrate/schema.go b/app/core/api/repository/mysql/ent/migrate/schema.go
index 8b138aa..26cc2e7 100644
--- a/app/core/api/repository/mysql/ent/migrate/schema.go
+++ b/app/core/api/repository/mysql/ent/migrate/schema.go
@@ -11,15 +11,14 @@ import (
var (
// ScaAuthPermissionRuleColumns holds the columns for the "sca_auth_permission_rule" table.
ScaAuthPermissionRuleColumns = []*schema.Column{
- {Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20) unsigned"}},
- {Name: "ptype", Type: field.TypeString, Size: 100},
- {Name: "v0", Type: field.TypeString, Size: 100},
- {Name: "v1", Type: field.TypeString, Size: 100},
+ {Name: "id", Type: field.TypeInt, Increment: true, SchemaType: map[string]string{"mysql": "int(11)"}},
+ {Name: "ptype", Type: field.TypeString, Nullable: true, Size: 100},
+ {Name: "v0", Type: field.TypeString, Nullable: true, Size: 100},
+ {Name: "v1", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "v2", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "v3", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "v4", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "v5", Type: field.TypeString, Nullable: true, Size: 100},
- {Name: "sca_auth_role_sca_auth_permission_rule", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}},
}
// ScaAuthPermissionRuleTable holds the schema information for the "sca_auth_permission_rule" table.
ScaAuthPermissionRuleTable = &schema.Table{
@@ -27,14 +26,6 @@ var (
Comment: "角色权限规则表",
Columns: ScaAuthPermissionRuleColumns,
PrimaryKey: []*schema.Column{ScaAuthPermissionRuleColumns[0]},
- ForeignKeys: []*schema.ForeignKey{
- {
- Symbol: "sca_auth_permission_rule_sca_auth_role_sca_auth_permission_rule",
- Columns: []*schema.Column{ScaAuthPermissionRuleColumns[8]},
- RefColumns: []*schema.Column{ScaAuthRoleColumns[0]},
- OnDelete: schema.SetNull,
- },
- },
}
// ScaAuthRoleColumns holds the columns for the "sca_auth_role" table.
ScaAuthRoleColumns = []*schema.Column{
@@ -64,7 +55,7 @@ var (
{Name: "email", Type: field.TypeString, Nullable: true, Size: 32, Comment: "邮箱"},
{Name: "phone", Type: field.TypeString, Nullable: true, Size: 32, Comment: "电话"},
{Name: "password", Type: field.TypeString, Nullable: true, Size: 64, Comment: "密码"},
- {Name: "gender", Type: field.TypeString, Nullable: true, Size: 32, Comment: "性别"},
+ {Name: "gender", Type: field.TypeInt8, Nullable: true, Comment: "性别"},
{Name: "avatar", Type: field.TypeString, Nullable: true, Comment: "头像"},
{Name: "status", Type: field.TypeInt8, Nullable: true, Comment: "状态 0 正常 1 封禁", Default: 0},
{Name: "introduce", Type: field.TypeString, Nullable: true, Size: 255, Comment: "介绍"},
@@ -115,7 +106,6 @@ var (
{Name: "platform", Type: field.TypeString, Size: 20, Comment: "平台"},
{Name: "engine_name", Type: field.TypeString, Size: 20, Comment: "引擎名称"},
{Name: "engine_version", Type: field.TypeString, Size: 20, Comment: "引擎版本"},
- {Name: "sca_auth_user_sca_auth_user_device", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}},
}
// ScaAuthUserDeviceTable holds the schema information for the "sca_auth_user_device" table.
ScaAuthUserDeviceTable = &schema.Table{
@@ -123,14 +113,6 @@ var (
Comment: "用户设备表",
Columns: ScaAuthUserDeviceColumns,
PrimaryKey: []*schema.Column{ScaAuthUserDeviceColumns[0]},
- ForeignKeys: []*schema.ForeignKey{
- {
- Symbol: "sca_auth_user_device_sca_auth_user_sca_auth_user_device",
- Columns: []*schema.Column{ScaAuthUserDeviceColumns[17]},
- RefColumns: []*schema.Column{ScaAuthUserColumns[0]},
- OnDelete: schema.SetNull,
- },
- },
Indexes: []*schema.Index{
{
Name: "scaauthuserdevice_id",
@@ -149,7 +131,6 @@ var (
{Name: "open_id", Type: field.TypeString, Size: 50, Comment: "第三方用户的 open id"},
{Name: "source", Type: field.TypeString, Size: 10, Comment: "第三方用户来源"},
{Name: "status", Type: field.TypeInt, Comment: "状态 0正常 1 封禁", Default: 0},
- {Name: "sca_auth_user_sca_auth_user_social", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}},
}
// ScaAuthUserSocialTable holds the schema information for the "sca_auth_user_social" table.
ScaAuthUserSocialTable = &schema.Table{
@@ -157,14 +138,6 @@ var (
Comment: "用户第三方登录信息",
Columns: ScaAuthUserSocialColumns,
PrimaryKey: []*schema.Column{ScaAuthUserSocialColumns[0]},
- ForeignKeys: []*schema.ForeignKey{
- {
- Symbol: "sca_auth_user_social_sca_auth_user_sca_auth_user_social",
- Columns: []*schema.Column{ScaAuthUserSocialColumns[8]},
- RefColumns: []*schema.Column{ScaAuthUserColumns[0]},
- OnDelete: schema.SetNull,
- },
- },
Indexes: []*schema.Index{
{
Name: "scaauthusersocial_id",
@@ -194,7 +167,6 @@ var (
)
func init() {
- ScaAuthPermissionRuleTable.ForeignKeys[0].RefTable = ScaAuthRoleTable
ScaAuthPermissionRuleTable.Annotation = &entsql.Annotation{
Table: "sca_auth_permission_rule",
}
@@ -204,11 +176,9 @@ func init() {
ScaAuthUserTable.Annotation = &entsql.Annotation{
Table: "sca_auth_user",
}
- ScaAuthUserDeviceTable.ForeignKeys[0].RefTable = ScaAuthUserTable
ScaAuthUserDeviceTable.Annotation = &entsql.Annotation{
Table: "sca_auth_user_device",
}
- ScaAuthUserSocialTable.ForeignKeys[0].RefTable = ScaAuthUserTable
ScaAuthUserSocialTable.Annotation = &entsql.Annotation{
Table: "sca_auth_user_social",
}
diff --git a/app/core/api/repository/mysql/ent/mutation.go b/app/core/api/repository/mysql/ent/mutation.go
index 43a5967..566f263 100644
--- a/app/core/api/repository/mysql/ent/mutation.go
+++ b/app/core/api/repository/mysql/ent/mutation.go
@@ -38,22 +38,20 @@ const (
// ScaAuthPermissionRuleMutation represents an operation that mutates the ScaAuthPermissionRule nodes in the graph.
type ScaAuthPermissionRuleMutation struct {
config
- op Op
- typ string
- id *int64
- ptype *string
- v0 *string
- v1 *string
- v2 *string
- v3 *string
- v4 *string
- v5 *string
- clearedFields map[string]struct{}
- sca_auth_role *int64
- clearedsca_auth_role bool
- done bool
- oldValue func(context.Context) (*ScaAuthPermissionRule, error)
- predicates []predicate.ScaAuthPermissionRule
+ op Op
+ typ string
+ id *int
+ ptype *string
+ v0 *string
+ v1 *string
+ v2 *string
+ v3 *string
+ v4 *string
+ v5 *string
+ clearedFields map[string]struct{}
+ done bool
+ oldValue func(context.Context) (*ScaAuthPermissionRule, error)
+ predicates []predicate.ScaAuthPermissionRule
}
var _ ent.Mutation = (*ScaAuthPermissionRuleMutation)(nil)
@@ -76,7 +74,7 @@ func newScaAuthPermissionRuleMutation(c config, op Op, opts ...scaauthpermission
}
// withScaAuthPermissionRuleID sets the ID field of the mutation.
-func withScaAuthPermissionRuleID(id int64) scaauthpermissionruleOption {
+func withScaAuthPermissionRuleID(id int) scaauthpermissionruleOption {
return func(m *ScaAuthPermissionRuleMutation) {
var (
err error
@@ -128,13 +126,13 @@ func (m ScaAuthPermissionRuleMutation) Tx() (*Tx, error) {
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of ScaAuthPermissionRule entities.
-func (m *ScaAuthPermissionRuleMutation) SetID(id int64) {
+func (m *ScaAuthPermissionRuleMutation) SetID(id int) {
m.id = &id
}
// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
-func (m *ScaAuthPermissionRuleMutation) ID() (id int64, exists bool) {
+func (m *ScaAuthPermissionRuleMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
@@ -145,12 +143,12 @@ func (m *ScaAuthPermissionRuleMutation) ID() (id int64, exists bool) {
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
-func (m *ScaAuthPermissionRuleMutation) IDs(ctx context.Context) ([]int64, error) {
+func (m *ScaAuthPermissionRuleMutation) IDs(ctx context.Context) ([]int, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
- return []int64{id}, nil
+ return []int{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
@@ -177,7 +175,7 @@ func (m *ScaAuthPermissionRuleMutation) Ptype() (r string, exists bool) {
// OldPtype returns the old "ptype" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldPtype(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldPtype(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPtype is only allowed on UpdateOne operations")
}
@@ -191,9 +189,22 @@ func (m *ScaAuthPermissionRuleMutation) OldPtype(ctx context.Context) (v *string
return oldValue.Ptype, nil
}
+// ClearPtype clears the value of the "ptype" field.
+func (m *ScaAuthPermissionRuleMutation) ClearPtype() {
+ m.ptype = nil
+ m.clearedFields[scaauthpermissionrule.FieldPtype] = struct{}{}
+}
+
+// PtypeCleared returns if the "ptype" field was cleared in this mutation.
+func (m *ScaAuthPermissionRuleMutation) PtypeCleared() bool {
+ _, ok := m.clearedFields[scaauthpermissionrule.FieldPtype]
+ return ok
+}
+
// ResetPtype resets all changes to the "ptype" field.
func (m *ScaAuthPermissionRuleMutation) ResetPtype() {
m.ptype = nil
+ delete(m.clearedFields, scaauthpermissionrule.FieldPtype)
}
// SetV0 sets the "v0" field.
@@ -213,7 +224,7 @@ func (m *ScaAuthPermissionRuleMutation) V0() (r string, exists bool) {
// OldV0 returns the old "v0" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldV0(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldV0(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldV0 is only allowed on UpdateOne operations")
}
@@ -227,9 +238,22 @@ func (m *ScaAuthPermissionRuleMutation) OldV0(ctx context.Context) (v *string, e
return oldValue.V0, nil
}
+// ClearV0 clears the value of the "v0" field.
+func (m *ScaAuthPermissionRuleMutation) ClearV0() {
+ m.v0 = nil
+ m.clearedFields[scaauthpermissionrule.FieldV0] = struct{}{}
+}
+
+// V0Cleared returns if the "v0" field was cleared in this mutation.
+func (m *ScaAuthPermissionRuleMutation) V0Cleared() bool {
+ _, ok := m.clearedFields[scaauthpermissionrule.FieldV0]
+ return ok
+}
+
// ResetV0 resets all changes to the "v0" field.
func (m *ScaAuthPermissionRuleMutation) ResetV0() {
m.v0 = nil
+ delete(m.clearedFields, scaauthpermissionrule.FieldV0)
}
// SetV1 sets the "v1" field.
@@ -249,7 +273,7 @@ func (m *ScaAuthPermissionRuleMutation) V1() (r string, exists bool) {
// OldV1 returns the old "v1" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldV1(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldV1(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldV1 is only allowed on UpdateOne operations")
}
@@ -263,9 +287,22 @@ func (m *ScaAuthPermissionRuleMutation) OldV1(ctx context.Context) (v *string, e
return oldValue.V1, nil
}
+// ClearV1 clears the value of the "v1" field.
+func (m *ScaAuthPermissionRuleMutation) ClearV1() {
+ m.v1 = nil
+ m.clearedFields[scaauthpermissionrule.FieldV1] = struct{}{}
+}
+
+// V1Cleared returns if the "v1" field was cleared in this mutation.
+func (m *ScaAuthPermissionRuleMutation) V1Cleared() bool {
+ _, ok := m.clearedFields[scaauthpermissionrule.FieldV1]
+ return ok
+}
+
// ResetV1 resets all changes to the "v1" field.
func (m *ScaAuthPermissionRuleMutation) ResetV1() {
m.v1 = nil
+ delete(m.clearedFields, scaauthpermissionrule.FieldV1)
}
// SetV2 sets the "v2" field.
@@ -285,7 +322,7 @@ func (m *ScaAuthPermissionRuleMutation) V2() (r string, exists bool) {
// OldV2 returns the old "v2" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldV2(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldV2(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldV2 is only allowed on UpdateOne operations")
}
@@ -334,7 +371,7 @@ func (m *ScaAuthPermissionRuleMutation) V3() (r string, exists bool) {
// OldV3 returns the old "v3" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldV3(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldV3(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldV3 is only allowed on UpdateOne operations")
}
@@ -383,7 +420,7 @@ func (m *ScaAuthPermissionRuleMutation) V4() (r string, exists bool) {
// OldV4 returns the old "v4" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldV4(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldV4(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldV4 is only allowed on UpdateOne operations")
}
@@ -432,7 +469,7 @@ func (m *ScaAuthPermissionRuleMutation) V5() (r string, exists bool) {
// OldV5 returns the old "v5" field's value of the ScaAuthPermissionRule entity.
// If the ScaAuthPermissionRule object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthPermissionRuleMutation) OldV5(ctx context.Context) (v *string, err error) {
+func (m *ScaAuthPermissionRuleMutation) OldV5(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldV5 is only allowed on UpdateOne operations")
}
@@ -464,45 +501,6 @@ func (m *ScaAuthPermissionRuleMutation) ResetV5() {
delete(m.clearedFields, scaauthpermissionrule.FieldV5)
}
-// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by id.
-func (m *ScaAuthPermissionRuleMutation) SetScaAuthRoleID(id int64) {
- m.sca_auth_role = &id
-}
-
-// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity.
-func (m *ScaAuthPermissionRuleMutation) ClearScaAuthRole() {
- m.clearedsca_auth_role = true
-}
-
-// ScaAuthRoleCleared reports if the "sca_auth_role" edge to the ScaAuthRole entity was cleared.
-func (m *ScaAuthPermissionRuleMutation) ScaAuthRoleCleared() bool {
- return m.clearedsca_auth_role
-}
-
-// ScaAuthRoleID returns the "sca_auth_role" edge ID in the mutation.
-func (m *ScaAuthPermissionRuleMutation) ScaAuthRoleID() (id int64, exists bool) {
- if m.sca_auth_role != nil {
- return *m.sca_auth_role, true
- }
- return
-}
-
-// ScaAuthRoleIDs returns the "sca_auth_role" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// ScaAuthRoleID instead. It exists only for internal usage by the builders.
-func (m *ScaAuthPermissionRuleMutation) ScaAuthRoleIDs() (ids []int64) {
- if id := m.sca_auth_role; id != nil {
- ids = append(ids, *id)
- }
- return
-}
-
-// ResetScaAuthRole resets all changes to the "sca_auth_role" edge.
-func (m *ScaAuthPermissionRuleMutation) ResetScaAuthRole() {
- m.sca_auth_role = nil
- m.clearedsca_auth_role = false
-}
-
// Where appends a list predicates to the ScaAuthPermissionRuleMutation builder.
func (m *ScaAuthPermissionRuleMutation) Where(ps ...predicate.ScaAuthPermissionRule) {
m.predicates = append(m.predicates, ps...)
@@ -692,6 +690,15 @@ func (m *ScaAuthPermissionRuleMutation) AddField(name string, value ent.Value) e
// mutation.
func (m *ScaAuthPermissionRuleMutation) ClearedFields() []string {
var fields []string
+ if m.FieldCleared(scaauthpermissionrule.FieldPtype) {
+ fields = append(fields, scaauthpermissionrule.FieldPtype)
+ }
+ if m.FieldCleared(scaauthpermissionrule.FieldV0) {
+ fields = append(fields, scaauthpermissionrule.FieldV0)
+ }
+ if m.FieldCleared(scaauthpermissionrule.FieldV1) {
+ fields = append(fields, scaauthpermissionrule.FieldV1)
+ }
if m.FieldCleared(scaauthpermissionrule.FieldV2) {
fields = append(fields, scaauthpermissionrule.FieldV2)
}
@@ -718,6 +725,15 @@ func (m *ScaAuthPermissionRuleMutation) FieldCleared(name string) bool {
// error if the field is not defined in the schema.
func (m *ScaAuthPermissionRuleMutation) ClearField(name string) error {
switch name {
+ case scaauthpermissionrule.FieldPtype:
+ m.ClearPtype()
+ return nil
+ case scaauthpermissionrule.FieldV0:
+ m.ClearV0()
+ return nil
+ case scaauthpermissionrule.FieldV1:
+ m.ClearV1()
+ return nil
case scaauthpermissionrule.FieldV2:
m.ClearV2()
return nil
@@ -765,28 +781,19 @@ func (m *ScaAuthPermissionRuleMutation) ResetField(name string) error {
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ScaAuthPermissionRuleMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.sca_auth_role != nil {
- edges = append(edges, scaauthpermissionrule.EdgeScaAuthRole)
- }
+ edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ScaAuthPermissionRuleMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case scaauthpermissionrule.EdgeScaAuthRole:
- if id := m.sca_auth_role; id != nil {
- return []ent.Value{*id}
- }
- }
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ScaAuthPermissionRuleMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
+ edges := make([]string, 0, 0)
return edges
}
@@ -798,64 +805,44 @@ func (m *ScaAuthPermissionRuleMutation) RemovedIDs(name string) []ent.Value {
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ScaAuthPermissionRuleMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedsca_auth_role {
- edges = append(edges, scaauthpermissionrule.EdgeScaAuthRole)
- }
+ edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ScaAuthPermissionRuleMutation) EdgeCleared(name string) bool {
- switch name {
- case scaauthpermissionrule.EdgeScaAuthRole:
- return m.clearedsca_auth_role
- }
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *ScaAuthPermissionRuleMutation) ClearEdge(name string) error {
- switch name {
- case scaauthpermissionrule.EdgeScaAuthRole:
- m.ClearScaAuthRole()
- return nil
- }
return fmt.Errorf("unknown ScaAuthPermissionRule unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *ScaAuthPermissionRuleMutation) ResetEdge(name string) error {
- switch name {
- case scaauthpermissionrule.EdgeScaAuthRole:
- m.ResetScaAuthRole()
- return nil
- }
return fmt.Errorf("unknown ScaAuthPermissionRule edge %s", name)
}
// ScaAuthRoleMutation represents an operation that mutates the ScaAuthRole nodes in the graph.
type ScaAuthRoleMutation struct {
config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted *int8
- adddeleted *int8
- role_name *string
- role_key *string
- clearedFields map[string]struct{}
- sca_auth_permission_rule map[int64]struct{}
- removedsca_auth_permission_rule map[int64]struct{}
- clearedsca_auth_permission_rule bool
- done bool
- oldValue func(context.Context) (*ScaAuthRole, error)
- predicates []predicate.ScaAuthRole
+ op Op
+ typ string
+ id *int64
+ created_at *time.Time
+ updated_at *time.Time
+ deleted *int8
+ adddeleted *int8
+ role_name *string
+ role_key *string
+ clearedFields map[string]struct{}
+ done bool
+ oldValue func(context.Context) (*ScaAuthRole, error)
+ predicates []predicate.ScaAuthRole
}
var _ ent.Mutation = (*ScaAuthRoleMutation)(nil)
@@ -1176,60 +1163,6 @@ func (m *ScaAuthRoleMutation) ResetRoleKey() {
m.role_key = nil
}
-// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by ids.
-func (m *ScaAuthRoleMutation) AddScaAuthPermissionRuleIDs(ids ...int64) {
- if m.sca_auth_permission_rule == nil {
- m.sca_auth_permission_rule = make(map[int64]struct{})
- }
- for i := range ids {
- m.sca_auth_permission_rule[ids[i]] = struct{}{}
- }
-}
-
-// ClearScaAuthPermissionRule clears the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity.
-func (m *ScaAuthRoleMutation) ClearScaAuthPermissionRule() {
- m.clearedsca_auth_permission_rule = true
-}
-
-// ScaAuthPermissionRuleCleared reports if the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity was cleared.
-func (m *ScaAuthRoleMutation) ScaAuthPermissionRuleCleared() bool {
- return m.clearedsca_auth_permission_rule
-}
-
-// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
-func (m *ScaAuthRoleMutation) RemoveScaAuthPermissionRuleIDs(ids ...int64) {
- if m.removedsca_auth_permission_rule == nil {
- m.removedsca_auth_permission_rule = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.sca_auth_permission_rule, ids[i])
- m.removedsca_auth_permission_rule[ids[i]] = struct{}{}
- }
-}
-
-// RemovedScaAuthPermissionRule returns the removed IDs of the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity.
-func (m *ScaAuthRoleMutation) RemovedScaAuthPermissionRuleIDs() (ids []int64) {
- for id := range m.removedsca_auth_permission_rule {
- ids = append(ids, id)
- }
- return
-}
-
-// ScaAuthPermissionRuleIDs returns the "sca_auth_permission_rule" edge IDs in the mutation.
-func (m *ScaAuthRoleMutation) ScaAuthPermissionRuleIDs() (ids []int64) {
- for id := range m.sca_auth_permission_rule {
- ids = append(ids, id)
- }
- return
-}
-
-// ResetScaAuthPermissionRule resets all changes to the "sca_auth_permission_rule" edge.
-func (m *ScaAuthRoleMutation) ResetScaAuthPermissionRule() {
- m.sca_auth_permission_rule = nil
- m.clearedsca_auth_permission_rule = false
- m.removedsca_auth_permission_rule = nil
-}
-
// Where appends a list predicates to the ScaAuthRoleMutation builder.
func (m *ScaAuthRoleMutation) Where(ps ...predicate.ScaAuthRole) {
m.predicates = append(m.predicates, ps...)
@@ -1455,122 +1388,81 @@ func (m *ScaAuthRoleMutation) ResetField(name string) error {
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ScaAuthRoleMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.sca_auth_permission_rule != nil {
- edges = append(edges, scaauthrole.EdgeScaAuthPermissionRule)
- }
+ edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ScaAuthRoleMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case scaauthrole.EdgeScaAuthPermissionRule:
- ids := make([]ent.Value, 0, len(m.sca_auth_permission_rule))
- for id := range m.sca_auth_permission_rule {
- ids = append(ids, id)
- }
- return ids
- }
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ScaAuthRoleMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removedsca_auth_permission_rule != nil {
- edges = append(edges, scaauthrole.EdgeScaAuthPermissionRule)
- }
+ edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ScaAuthRoleMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case scaauthrole.EdgeScaAuthPermissionRule:
- ids := make([]ent.Value, 0, len(m.removedsca_auth_permission_rule))
- for id := range m.removedsca_auth_permission_rule {
- ids = append(ids, id)
- }
- return ids
- }
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ScaAuthRoleMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedsca_auth_permission_rule {
- edges = append(edges, scaauthrole.EdgeScaAuthPermissionRule)
- }
+ edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ScaAuthRoleMutation) EdgeCleared(name string) bool {
- switch name {
- case scaauthrole.EdgeScaAuthPermissionRule:
- return m.clearedsca_auth_permission_rule
- }
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *ScaAuthRoleMutation) ClearEdge(name string) error {
- switch name {
- }
return fmt.Errorf("unknown ScaAuthRole unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *ScaAuthRoleMutation) ResetEdge(name string) error {
- switch name {
- case scaauthrole.EdgeScaAuthPermissionRule:
- m.ResetScaAuthPermissionRule()
- return nil
- }
return fmt.Errorf("unknown ScaAuthRole edge %s", name)
}
// ScaAuthUserMutation represents an operation that mutates the ScaAuthUser nodes in the graph.
type ScaAuthUserMutation struct {
config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted *int8
- adddeleted *int8
- uid *string
- username *string
- nickname *string
- email *string
- phone *string
- password *string
- gender *string
- avatar *string
- status *int8
- addstatus *int8
- introduce *string
- blog *string
- location *string
- company *string
- clearedFields map[string]struct{}
- sca_auth_user_social map[int64]struct{}
- removedsca_auth_user_social map[int64]struct{}
- clearedsca_auth_user_social bool
- sca_auth_user_device map[int64]struct{}
- removedsca_auth_user_device map[int64]struct{}
- clearedsca_auth_user_device bool
- done bool
- oldValue func(context.Context) (*ScaAuthUser, error)
- predicates []predicate.ScaAuthUser
+ op Op
+ typ string
+ id *int64
+ created_at *time.Time
+ updated_at *time.Time
+ deleted *int8
+ adddeleted *int8
+ uid *string
+ username *string
+ nickname *string
+ email *string
+ phone *string
+ password *string
+ gender *int8
+ addgender *int8
+ avatar *string
+ status *int8
+ addstatus *int8
+ introduce *string
+ blog *string
+ location *string
+ company *string
+ clearedFields map[string]struct{}
+ done bool
+ oldValue func(context.Context) (*ScaAuthUser, error)
+ predicates []predicate.ScaAuthUser
}
var _ ent.Mutation = (*ScaAuthUserMutation)(nil)
@@ -2101,12 +1993,13 @@ func (m *ScaAuthUserMutation) ResetPassword() {
}
// SetGender sets the "gender" field.
-func (m *ScaAuthUserMutation) SetGender(s string) {
- m.gender = &s
+func (m *ScaAuthUserMutation) SetGender(i int8) {
+ m.gender = &i
+ m.addgender = nil
}
// Gender returns the value of the "gender" field in the mutation.
-func (m *ScaAuthUserMutation) Gender() (r string, exists bool) {
+func (m *ScaAuthUserMutation) Gender() (r int8, exists bool) {
v := m.gender
if v == nil {
return
@@ -2117,7 +2010,7 @@ func (m *ScaAuthUserMutation) Gender() (r string, exists bool) {
// OldGender returns the old "gender" field's value of the ScaAuthUser entity.
// If the ScaAuthUser object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *ScaAuthUserMutation) OldGender(ctx context.Context) (v string, err error) {
+func (m *ScaAuthUserMutation) OldGender(ctx context.Context) (v int8, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGender is only allowed on UpdateOne operations")
}
@@ -2131,9 +2024,28 @@ func (m *ScaAuthUserMutation) OldGender(ctx context.Context) (v string, err erro
return oldValue.Gender, nil
}
+// AddGender adds i to the "gender" field.
+func (m *ScaAuthUserMutation) AddGender(i int8) {
+ if m.addgender != nil {
+ *m.addgender += i
+ } else {
+ m.addgender = &i
+ }
+}
+
+// AddedGender returns the value that was added to the "gender" field in this mutation.
+func (m *ScaAuthUserMutation) AddedGender() (r int8, exists bool) {
+ v := m.addgender
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
// ClearGender clears the value of the "gender" field.
func (m *ScaAuthUserMutation) ClearGender() {
m.gender = nil
+ m.addgender = nil
m.clearedFields[scaauthuser.FieldGender] = struct{}{}
}
@@ -2146,6 +2058,7 @@ func (m *ScaAuthUserMutation) GenderCleared() bool {
// ResetGender resets all changes to the "gender" field.
func (m *ScaAuthUserMutation) ResetGender() {
m.gender = nil
+ m.addgender = nil
delete(m.clearedFields, scaauthuser.FieldGender)
}
@@ -2464,114 +2377,6 @@ func (m *ScaAuthUserMutation) ResetCompany() {
delete(m.clearedFields, scaauthuser.FieldCompany)
}
-// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by ids.
-func (m *ScaAuthUserMutation) AddScaAuthUserSocialIDs(ids ...int64) {
- if m.sca_auth_user_social == nil {
- m.sca_auth_user_social = make(map[int64]struct{})
- }
- for i := range ids {
- m.sca_auth_user_social[ids[i]] = struct{}{}
- }
-}
-
-// ClearScaAuthUserSocial clears the "sca_auth_user_social" edge to the ScaAuthUserSocial entity.
-func (m *ScaAuthUserMutation) ClearScaAuthUserSocial() {
- m.clearedsca_auth_user_social = true
-}
-
-// ScaAuthUserSocialCleared reports if the "sca_auth_user_social" edge to the ScaAuthUserSocial entity was cleared.
-func (m *ScaAuthUserMutation) ScaAuthUserSocialCleared() bool {
- return m.clearedsca_auth_user_social
-}
-
-// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
-func (m *ScaAuthUserMutation) RemoveScaAuthUserSocialIDs(ids ...int64) {
- if m.removedsca_auth_user_social == nil {
- m.removedsca_auth_user_social = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.sca_auth_user_social, ids[i])
- m.removedsca_auth_user_social[ids[i]] = struct{}{}
- }
-}
-
-// RemovedScaAuthUserSocial returns the removed IDs of the "sca_auth_user_social" edge to the ScaAuthUserSocial entity.
-func (m *ScaAuthUserMutation) RemovedScaAuthUserSocialIDs() (ids []int64) {
- for id := range m.removedsca_auth_user_social {
- ids = append(ids, id)
- }
- return
-}
-
-// ScaAuthUserSocialIDs returns the "sca_auth_user_social" edge IDs in the mutation.
-func (m *ScaAuthUserMutation) ScaAuthUserSocialIDs() (ids []int64) {
- for id := range m.sca_auth_user_social {
- ids = append(ids, id)
- }
- return
-}
-
-// ResetScaAuthUserSocial resets all changes to the "sca_auth_user_social" edge.
-func (m *ScaAuthUserMutation) ResetScaAuthUserSocial() {
- m.sca_auth_user_social = nil
- m.clearedsca_auth_user_social = false
- m.removedsca_auth_user_social = nil
-}
-
-// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by ids.
-func (m *ScaAuthUserMutation) AddScaAuthUserDeviceIDs(ids ...int64) {
- if m.sca_auth_user_device == nil {
- m.sca_auth_user_device = make(map[int64]struct{})
- }
- for i := range ids {
- m.sca_auth_user_device[ids[i]] = struct{}{}
- }
-}
-
-// ClearScaAuthUserDevice clears the "sca_auth_user_device" edge to the ScaAuthUserDevice entity.
-func (m *ScaAuthUserMutation) ClearScaAuthUserDevice() {
- m.clearedsca_auth_user_device = true
-}
-
-// ScaAuthUserDeviceCleared reports if the "sca_auth_user_device" edge to the ScaAuthUserDevice entity was cleared.
-func (m *ScaAuthUserMutation) ScaAuthUserDeviceCleared() bool {
- return m.clearedsca_auth_user_device
-}
-
-// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
-func (m *ScaAuthUserMutation) RemoveScaAuthUserDeviceIDs(ids ...int64) {
- if m.removedsca_auth_user_device == nil {
- m.removedsca_auth_user_device = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.sca_auth_user_device, ids[i])
- m.removedsca_auth_user_device[ids[i]] = struct{}{}
- }
-}
-
-// RemovedScaAuthUserDevice returns the removed IDs of the "sca_auth_user_device" edge to the ScaAuthUserDevice entity.
-func (m *ScaAuthUserMutation) RemovedScaAuthUserDeviceIDs() (ids []int64) {
- for id := range m.removedsca_auth_user_device {
- ids = append(ids, id)
- }
- return
-}
-
-// ScaAuthUserDeviceIDs returns the "sca_auth_user_device" edge IDs in the mutation.
-func (m *ScaAuthUserMutation) ScaAuthUserDeviceIDs() (ids []int64) {
- for id := range m.sca_auth_user_device {
- ids = append(ids, id)
- }
- return
-}
-
-// ResetScaAuthUserDevice resets all changes to the "sca_auth_user_device" edge.
-func (m *ScaAuthUserMutation) ResetScaAuthUserDevice() {
- m.sca_auth_user_device = nil
- m.clearedsca_auth_user_device = false
- m.removedsca_auth_user_device = nil
-}
-
// Where appends a list predicates to the ScaAuthUserMutation builder.
func (m *ScaAuthUserMutation) Where(ps ...predicate.ScaAuthUser) {
m.predicates = append(m.predicates, ps...)
@@ -2809,7 +2614,7 @@ func (m *ScaAuthUserMutation) SetField(name string, value ent.Value) error {
m.SetPassword(v)
return nil
case scaauthuser.FieldGender:
- v, ok := value.(string)
+ v, ok := value.(int8)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
@@ -2868,6 +2673,9 @@ func (m *ScaAuthUserMutation) AddedFields() []string {
if m.adddeleted != nil {
fields = append(fields, scaauthuser.FieldDeleted)
}
+ if m.addgender != nil {
+ fields = append(fields, scaauthuser.FieldGender)
+ }
if m.addstatus != nil {
fields = append(fields, scaauthuser.FieldStatus)
}
@@ -2881,6 +2689,8 @@ func (m *ScaAuthUserMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case scaauthuser.FieldDeleted:
return m.AddedDeleted()
+ case scaauthuser.FieldGender:
+ return m.AddedGender()
case scaauthuser.FieldStatus:
return m.AddedStatus()
}
@@ -2899,6 +2709,13 @@ func (m *ScaAuthUserMutation) AddField(name string, value ent.Value) error {
}
m.AddDeleted(v)
return nil
+ case scaauthuser.FieldGender:
+ v, ok := value.(int8)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.AddGender(v)
+ return nil
case scaauthuser.FieldStatus:
v, ok := value.(int8)
if !ok {
@@ -3068,143 +2885,79 @@ func (m *ScaAuthUserMutation) ResetField(name string) error {
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ScaAuthUserMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.sca_auth_user_social != nil {
- edges = append(edges, scaauthuser.EdgeScaAuthUserSocial)
- }
- if m.sca_auth_user_device != nil {
- edges = append(edges, scaauthuser.EdgeScaAuthUserDevice)
- }
+ edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ScaAuthUserMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case scaauthuser.EdgeScaAuthUserSocial:
- ids := make([]ent.Value, 0, len(m.sca_auth_user_social))
- for id := range m.sca_auth_user_social {
- ids = append(ids, id)
- }
- return ids
- case scaauthuser.EdgeScaAuthUserDevice:
- ids := make([]ent.Value, 0, len(m.sca_auth_user_device))
- for id := range m.sca_auth_user_device {
- ids = append(ids, id)
- }
- return ids
- }
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ScaAuthUserMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- if m.removedsca_auth_user_social != nil {
- edges = append(edges, scaauthuser.EdgeScaAuthUserSocial)
- }
- if m.removedsca_auth_user_device != nil {
- edges = append(edges, scaauthuser.EdgeScaAuthUserDevice)
- }
+ edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ScaAuthUserMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case scaauthuser.EdgeScaAuthUserSocial:
- ids := make([]ent.Value, 0, len(m.removedsca_auth_user_social))
- for id := range m.removedsca_auth_user_social {
- ids = append(ids, id)
- }
- return ids
- case scaauthuser.EdgeScaAuthUserDevice:
- ids := make([]ent.Value, 0, len(m.removedsca_auth_user_device))
- for id := range m.removedsca_auth_user_device {
- ids = append(ids, id)
- }
- return ids
- }
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ScaAuthUserMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedsca_auth_user_social {
- edges = append(edges, scaauthuser.EdgeScaAuthUserSocial)
- }
- if m.clearedsca_auth_user_device {
- edges = append(edges, scaauthuser.EdgeScaAuthUserDevice)
- }
+ edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ScaAuthUserMutation) EdgeCleared(name string) bool {
- switch name {
- case scaauthuser.EdgeScaAuthUserSocial:
- return m.clearedsca_auth_user_social
- case scaauthuser.EdgeScaAuthUserDevice:
- return m.clearedsca_auth_user_device
- }
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *ScaAuthUserMutation) ClearEdge(name string) error {
- switch name {
- }
return fmt.Errorf("unknown ScaAuthUser unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *ScaAuthUserMutation) ResetEdge(name string) error {
- switch name {
- case scaauthuser.EdgeScaAuthUserSocial:
- m.ResetScaAuthUserSocial()
- return nil
- case scaauthuser.EdgeScaAuthUserDevice:
- m.ResetScaAuthUserDevice()
- return nil
- }
return fmt.Errorf("unknown ScaAuthUser edge %s", name)
}
// ScaAuthUserDeviceMutation represents an operation that mutates the ScaAuthUserDevice nodes in the graph.
type ScaAuthUserDeviceMutation struct {
config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted *int8
- adddeleted *int8
- user_id *string
- ip *string
- location *string
- agent *string
- browser *string
- operating_system *string
- browser_version *string
- mobile *bool
- bot *bool
- mozilla *string
- platform *string
- engine_name *string
- engine_version *string
- clearedFields map[string]struct{}
- sca_auth_user *int64
- clearedsca_auth_user bool
- done bool
- oldValue func(context.Context) (*ScaAuthUserDevice, error)
- predicates []predicate.ScaAuthUserDevice
+ op Op
+ typ string
+ id *int64
+ created_at *time.Time
+ updated_at *time.Time
+ deleted *int8
+ adddeleted *int8
+ user_id *string
+ ip *string
+ location *string
+ agent *string
+ browser *string
+ operating_system *string
+ browser_version *string
+ mobile *bool
+ bot *bool
+ mozilla *string
+ platform *string
+ engine_name *string
+ engine_version *string
+ clearedFields map[string]struct{}
+ done bool
+ oldValue func(context.Context) (*ScaAuthUserDevice, error)
+ predicates []predicate.ScaAuthUserDevice
}
var _ ent.Mutation = (*ScaAuthUserDeviceMutation)(nil)
@@ -3921,45 +3674,6 @@ func (m *ScaAuthUserDeviceMutation) ResetEngineVersion() {
m.engine_version = nil
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by id.
-func (m *ScaAuthUserDeviceMutation) SetScaAuthUserID(id int64) {
- m.sca_auth_user = &id
-}
-
-// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
-func (m *ScaAuthUserDeviceMutation) ClearScaAuthUser() {
- m.clearedsca_auth_user = true
-}
-
-// ScaAuthUserCleared reports if the "sca_auth_user" edge to the ScaAuthUser entity was cleared.
-func (m *ScaAuthUserDeviceMutation) ScaAuthUserCleared() bool {
- return m.clearedsca_auth_user
-}
-
-// ScaAuthUserID returns the "sca_auth_user" edge ID in the mutation.
-func (m *ScaAuthUserDeviceMutation) ScaAuthUserID() (id int64, exists bool) {
- if m.sca_auth_user != nil {
- return *m.sca_auth_user, true
- }
- return
-}
-
-// ScaAuthUserIDs returns the "sca_auth_user" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// ScaAuthUserID instead. It exists only for internal usage by the builders.
-func (m *ScaAuthUserDeviceMutation) ScaAuthUserIDs() (ids []int64) {
- if id := m.sca_auth_user; id != nil {
- ids = append(ids, *id)
- }
- return
-}
-
-// ResetScaAuthUser resets all changes to the "sca_auth_user" edge.
-func (m *ScaAuthUserDeviceMutation) ResetScaAuthUser() {
- m.sca_auth_user = nil
- m.clearedsca_auth_user = false
-}
-
// Where appends a list predicates to the ScaAuthUserDeviceMutation builder.
func (m *ScaAuthUserDeviceMutation) Where(ps ...predicate.ScaAuthUserDevice) {
m.predicates = append(m.predicates, ps...)
@@ -4372,28 +4086,19 @@ func (m *ScaAuthUserDeviceMutation) ResetField(name string) error {
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ScaAuthUserDeviceMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.sca_auth_user != nil {
- edges = append(edges, scaauthuserdevice.EdgeScaAuthUser)
- }
+ edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ScaAuthUserDeviceMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case scaauthuserdevice.EdgeScaAuthUser:
- if id := m.sca_auth_user; id != nil {
- return []ent.Value{*id}
- }
- }
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ScaAuthUserDeviceMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
+ edges := make([]string, 0, 0)
return edges
}
@@ -4405,66 +4110,47 @@ func (m *ScaAuthUserDeviceMutation) RemovedIDs(name string) []ent.Value {
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ScaAuthUserDeviceMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedsca_auth_user {
- edges = append(edges, scaauthuserdevice.EdgeScaAuthUser)
- }
+ edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ScaAuthUserDeviceMutation) EdgeCleared(name string) bool {
- switch name {
- case scaauthuserdevice.EdgeScaAuthUser:
- return m.clearedsca_auth_user
- }
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *ScaAuthUserDeviceMutation) ClearEdge(name string) error {
- switch name {
- case scaauthuserdevice.EdgeScaAuthUser:
- m.ClearScaAuthUser()
- return nil
- }
return fmt.Errorf("unknown ScaAuthUserDevice unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *ScaAuthUserDeviceMutation) ResetEdge(name string) error {
- switch name {
- case scaauthuserdevice.EdgeScaAuthUser:
- m.ResetScaAuthUser()
- return nil
- }
return fmt.Errorf("unknown ScaAuthUserDevice edge %s", name)
}
// ScaAuthUserSocialMutation represents an operation that mutates the ScaAuthUserSocial nodes in the graph.
type ScaAuthUserSocialMutation struct {
config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted *int8
- adddeleted *int8
- user_id *string
- open_id *string
- source *string
- status *int
- addstatus *int
- clearedFields map[string]struct{}
- sca_auth_user *int64
- clearedsca_auth_user bool
- done bool
- oldValue func(context.Context) (*ScaAuthUserSocial, error)
- predicates []predicate.ScaAuthUserSocial
+ op Op
+ typ string
+ id *int64
+ created_at *time.Time
+ updated_at *time.Time
+ deleted *int8
+ adddeleted *int8
+ user_id *string
+ open_id *string
+ source *string
+ status *int
+ addstatus *int
+ clearedFields map[string]struct{}
+ done bool
+ oldValue func(context.Context) (*ScaAuthUserSocial, error)
+ predicates []predicate.ScaAuthUserSocial
}
var _ ent.Mutation = (*ScaAuthUserSocialMutation)(nil)
@@ -4877,45 +4563,6 @@ func (m *ScaAuthUserSocialMutation) ResetStatus() {
m.addstatus = nil
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by id.
-func (m *ScaAuthUserSocialMutation) SetScaAuthUserID(id int64) {
- m.sca_auth_user = &id
-}
-
-// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
-func (m *ScaAuthUserSocialMutation) ClearScaAuthUser() {
- m.clearedsca_auth_user = true
-}
-
-// ScaAuthUserCleared reports if the "sca_auth_user" edge to the ScaAuthUser entity was cleared.
-func (m *ScaAuthUserSocialMutation) ScaAuthUserCleared() bool {
- return m.clearedsca_auth_user
-}
-
-// ScaAuthUserID returns the "sca_auth_user" edge ID in the mutation.
-func (m *ScaAuthUserSocialMutation) ScaAuthUserID() (id int64, exists bool) {
- if m.sca_auth_user != nil {
- return *m.sca_auth_user, true
- }
- return
-}
-
-// ScaAuthUserIDs returns the "sca_auth_user" edge IDs in the mutation.
-// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
-// ScaAuthUserID instead. It exists only for internal usage by the builders.
-func (m *ScaAuthUserSocialMutation) ScaAuthUserIDs() (ids []int64) {
- if id := m.sca_auth_user; id != nil {
- ids = append(ids, *id)
- }
- return
-}
-
-// ResetScaAuthUser resets all changes to the "sca_auth_user" edge.
-func (m *ScaAuthUserSocialMutation) ResetScaAuthUser() {
- m.sca_auth_user = nil
- m.clearedsca_auth_user = false
-}
-
// Where appends a list predicates to the ScaAuthUserSocialMutation builder.
func (m *ScaAuthUserSocialMutation) Where(ps ...predicate.ScaAuthUserSocial) {
m.predicates = append(m.predicates, ps...)
@@ -5187,28 +4834,19 @@ func (m *ScaAuthUserSocialMutation) ResetField(name string) error {
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ScaAuthUserSocialMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.sca_auth_user != nil {
- edges = append(edges, scaauthusersocial.EdgeScaAuthUser)
- }
+ edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ScaAuthUserSocialMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case scaauthusersocial.EdgeScaAuthUser:
- if id := m.sca_auth_user; id != nil {
- return []ent.Value{*id}
- }
- }
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ScaAuthUserSocialMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
+ edges := make([]string, 0, 0)
return edges
}
@@ -5220,41 +4858,24 @@ func (m *ScaAuthUserSocialMutation) RemovedIDs(name string) []ent.Value {
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ScaAuthUserSocialMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedsca_auth_user {
- edges = append(edges, scaauthusersocial.EdgeScaAuthUser)
- }
+ edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ScaAuthUserSocialMutation) EdgeCleared(name string) bool {
- switch name {
- case scaauthusersocial.EdgeScaAuthUser:
- return m.clearedsca_auth_user
- }
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *ScaAuthUserSocialMutation) ClearEdge(name string) error {
- switch name {
- case scaauthusersocial.EdgeScaAuthUser:
- m.ClearScaAuthUser()
- return nil
- }
return fmt.Errorf("unknown ScaAuthUserSocial unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *ScaAuthUserSocialMutation) ResetEdge(name string) error {
- switch name {
- case scaauthusersocial.EdgeScaAuthUser:
- m.ResetScaAuthUser()
- return nil
- }
return fmt.Errorf("unknown ScaAuthUserSocial edge %s", name)
}
diff --git a/app/core/api/repository/mysql/ent/runtime.go b/app/core/api/repository/mysql/ent/runtime.go
index 97e0cad..59e7504 100644
--- a/app/core/api/repository/mysql/ent/runtime.go
+++ b/app/core/api/repository/mysql/ent/runtime.go
@@ -120,10 +120,6 @@ func init() {
scaauthuserDescPassword := scaauthuserFields[6].Descriptor()
// scaauthuser.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
scaauthuser.PasswordValidator = scaauthuserDescPassword.Validators[0].(func(string) error)
- // scaauthuserDescGender is the schema descriptor for gender field.
- scaauthuserDescGender := scaauthuserFields[7].Descriptor()
- // scaauthuser.GenderValidator is a validator for the "gender" field. It is called by the builders before save.
- scaauthuser.GenderValidator = scaauthuserDescGender.Validators[0].(func(string) error)
// scaauthuserDescStatus is the schema descriptor for status field.
scaauthuserDescStatus := scaauthuserFields[9].Descriptor()
// scaauthuser.DefaultStatus holds the default value on creation for the status field.
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule.go
index dd7ca12..ded03f5 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule.go
@@ -5,7 +5,6 @@ package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"strings"
"entgo.io/ent"
@@ -16,46 +15,22 @@ import (
type ScaAuthPermissionRule struct {
config `json:"-"`
// ID of the ent.
- ID int64 `json:"id,omitempty"`
+ ID int `json:"id,omitempty"`
// Ptype holds the value of the "ptype" field.
- Ptype *string `json:"ptype,omitempty"`
+ Ptype string `json:"ptype,omitempty"`
// V0 holds the value of the "v0" field.
- V0 *string `json:"v0,omitempty"`
+ V0 string `json:"v0,omitempty"`
// V1 holds the value of the "v1" field.
- V1 *string `json:"v1,omitempty"`
+ V1 string `json:"v1,omitempty"`
// V2 holds the value of the "v2" field.
- V2 *string `json:"v2,omitempty"`
+ V2 string `json:"v2,omitempty"`
// V3 holds the value of the "v3" field.
- V3 *string `json:"v3,omitempty"`
+ V3 string `json:"v3,omitempty"`
// V4 holds the value of the "v4" field.
- V4 *string `json:"v4,omitempty"`
+ V4 string `json:"v4,omitempty"`
// V5 holds the value of the "v5" field.
- V5 *string `json:"v5,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ScaAuthPermissionRuleQuery when eager-loading is set.
- Edges ScaAuthPermissionRuleEdges `json:"edges"`
- sca_auth_role_sca_auth_permission_rule *int64
- selectValues sql.SelectValues
-}
-
-// ScaAuthPermissionRuleEdges holds the relations/edges for other nodes in the graph.
-type ScaAuthPermissionRuleEdges struct {
- // ScaAuthRole holds the value of the sca_auth_role edge.
- ScaAuthRole *ScaAuthRole `json:"sca_auth_role,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
-}
-
-// ScaAuthRoleOrErr returns the ScaAuthRole value or an error if the edge
-// was not loaded in eager-loading, or loaded but was not found.
-func (e ScaAuthPermissionRuleEdges) ScaAuthRoleOrErr() (*ScaAuthRole, error) {
- if e.ScaAuthRole != nil {
- return e.ScaAuthRole, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: scaauthrole.Label}
- }
- return nil, &NotLoadedError{edge: "sca_auth_role"}
+ V5 string `json:"v5,omitempty"`
+ selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -67,8 +42,6 @@ func (*ScaAuthPermissionRule) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullInt64)
case scaauthpermissionrule.FieldPtype, scaauthpermissionrule.FieldV0, scaauthpermissionrule.FieldV1, scaauthpermissionrule.FieldV2, scaauthpermissionrule.FieldV3, scaauthpermissionrule.FieldV4, scaauthpermissionrule.FieldV5:
values[i] = new(sql.NullString)
- case scaauthpermissionrule.ForeignKeys[0]: // sca_auth_role_sca_auth_permission_rule
- values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
@@ -89,62 +62,48 @@ func (sapr *ScaAuthPermissionRule) assignValues(columns []string, values []any)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
- sapr.ID = int64(value.Int64)
+ sapr.ID = int(value.Int64)
case scaauthpermissionrule.FieldPtype:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field ptype", values[i])
} else if value.Valid {
- sapr.Ptype = new(string)
- *sapr.Ptype = value.String
+ sapr.Ptype = value.String
}
case scaauthpermissionrule.FieldV0:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field v0", values[i])
} else if value.Valid {
- sapr.V0 = new(string)
- *sapr.V0 = value.String
+ sapr.V0 = value.String
}
case scaauthpermissionrule.FieldV1:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field v1", values[i])
} else if value.Valid {
- sapr.V1 = new(string)
- *sapr.V1 = value.String
+ sapr.V1 = value.String
}
case scaauthpermissionrule.FieldV2:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field v2", values[i])
} else if value.Valid {
- sapr.V2 = new(string)
- *sapr.V2 = value.String
+ sapr.V2 = value.String
}
case scaauthpermissionrule.FieldV3:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field v3", values[i])
} else if value.Valid {
- sapr.V3 = new(string)
- *sapr.V3 = value.String
+ sapr.V3 = value.String
}
case scaauthpermissionrule.FieldV4:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field v4", values[i])
} else if value.Valid {
- sapr.V4 = new(string)
- *sapr.V4 = value.String
+ sapr.V4 = value.String
}
case scaauthpermissionrule.FieldV5:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field v5", values[i])
} else if value.Valid {
- sapr.V5 = new(string)
- *sapr.V5 = value.String
- }
- case scaauthpermissionrule.ForeignKeys[0]:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for edge-field sca_auth_role_sca_auth_permission_rule", value)
- } else if value.Valid {
- sapr.sca_auth_role_sca_auth_permission_rule = new(int64)
- *sapr.sca_auth_role_sca_auth_permission_rule = int64(value.Int64)
+ sapr.V5 = value.String
}
default:
sapr.selectValues.Set(columns[i], values[i])
@@ -159,11 +118,6 @@ func (sapr *ScaAuthPermissionRule) Value(name string) (ent.Value, error) {
return sapr.selectValues.Get(name)
}
-// QueryScaAuthRole queries the "sca_auth_role" edge of the ScaAuthPermissionRule entity.
-func (sapr *ScaAuthPermissionRule) QueryScaAuthRole() *ScaAuthRoleQuery {
- return NewScaAuthPermissionRuleClient(sapr.config).QueryScaAuthRole(sapr)
-}
-
// Update returns a builder for updating this ScaAuthPermissionRule.
// Note that you need to call ScaAuthPermissionRule.Unwrap() before calling this method if this ScaAuthPermissionRule
// was returned from a transaction, and the transaction was committed or rolled back.
@@ -187,40 +141,26 @@ func (sapr *ScaAuthPermissionRule) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthPermissionRule(")
builder.WriteString(fmt.Sprintf("id=%v, ", sapr.ID))
- if v := sapr.Ptype; v != nil {
- builder.WriteString("ptype=")
- builder.WriteString(*v)
- }
+ builder.WriteString("ptype=")
+ builder.WriteString(sapr.Ptype)
builder.WriteString(", ")
- if v := sapr.V0; v != nil {
- builder.WriteString("v0=")
- builder.WriteString(*v)
- }
+ builder.WriteString("v0=")
+ builder.WriteString(sapr.V0)
builder.WriteString(", ")
- if v := sapr.V1; v != nil {
- builder.WriteString("v1=")
- builder.WriteString(*v)
- }
+ builder.WriteString("v1=")
+ builder.WriteString(sapr.V1)
builder.WriteString(", ")
- if v := sapr.V2; v != nil {
- builder.WriteString("v2=")
- builder.WriteString(*v)
- }
+ builder.WriteString("v2=")
+ builder.WriteString(sapr.V2)
builder.WriteString(", ")
- if v := sapr.V3; v != nil {
- builder.WriteString("v3=")
- builder.WriteString(*v)
- }
+ builder.WriteString("v3=")
+ builder.WriteString(sapr.V3)
builder.WriteString(", ")
- if v := sapr.V4; v != nil {
- builder.WriteString("v4=")
- builder.WriteString(*v)
- }
+ builder.WriteString("v4=")
+ builder.WriteString(sapr.V4)
builder.WriteString(", ")
- if v := sapr.V5; v != nil {
- builder.WriteString("v5=")
- builder.WriteString(*v)
- }
+ builder.WriteString("v5=")
+ builder.WriteString(sapr.V5)
builder.WriteByte(')')
return builder.String()
}
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule/scaauthpermissionrule.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule/scaauthpermissionrule.go
index 8abc890..0ed08d6 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule/scaauthpermissionrule.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule/scaauthpermissionrule.go
@@ -4,7 +4,6 @@ package scaauthpermissionrule
import (
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -26,17 +25,8 @@ const (
FieldV4 = "v4"
// FieldV5 holds the string denoting the v5 field in the database.
FieldV5 = "v5"
- // EdgeScaAuthRole holds the string denoting the sca_auth_role edge name in mutations.
- EdgeScaAuthRole = "sca_auth_role"
// Table holds the table name of the scaauthpermissionrule in the database.
Table = "sca_auth_permission_rule"
- // ScaAuthRoleTable is the table that holds the sca_auth_role relation/edge.
- ScaAuthRoleTable = "sca_auth_permission_rule"
- // ScaAuthRoleInverseTable is the table name for the ScaAuthRole entity.
- // It exists in this package in order to avoid circular dependency with the "scaauthrole" package.
- ScaAuthRoleInverseTable = "sca_auth_role"
- // ScaAuthRoleColumn is the table column denoting the sca_auth_role relation/edge.
- ScaAuthRoleColumn = "sca_auth_role_sca_auth_permission_rule"
)
// Columns holds all SQL columns for scaauthpermissionrule fields.
@@ -51,12 +41,6 @@ var Columns = []string{
FieldV5,
}
-// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_permission_rule"
-// table and are not defined as standalone fields in the schema.
-var ForeignKeys = []string{
- "sca_auth_role_sca_auth_permission_rule",
-}
-
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
@@ -64,11 +48,6 @@ func ValidColumn(column string) bool {
return true
}
}
- for i := range ForeignKeys {
- if column == ForeignKeys[i] {
- return true
- }
- }
return false
}
@@ -131,17 +110,3 @@ func ByV4(opts ...sql.OrderTermOption) OrderOption {
func ByV5(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV5, opts...).ToFunc()
}
-
-// ByScaAuthRoleField orders the results by sca_auth_role field.
-func ByScaAuthRoleField(field string, opts ...sql.OrderTermOption) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborTerms(s, newScaAuthRoleStep(), sql.OrderByField(field, opts...))
- }
-}
-func newScaAuthRoleStep() *sqlgraph.Step {
- return sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.To(ScaAuthRoleInverseTable, FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthRoleTable, ScaAuthRoleColumn),
- )
-}
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule/where.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule/where.go
index 027f1ff..630c30e 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule/where.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule/where.go
@@ -6,51 +6,50 @@ import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
-func ID(id int64) predicate.ScaAuthPermissionRule {
+func ID(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
-func IDEQ(id int64) predicate.ScaAuthPermissionRule {
+func IDEQ(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
-func IDNEQ(id int64) predicate.ScaAuthPermissionRule {
+func IDNEQ(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
-func IDIn(ids ...int64) predicate.ScaAuthPermissionRule {
+func IDIn(ids ...int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
-func IDNotIn(ids ...int64) predicate.ScaAuthPermissionRule {
+func IDNotIn(ids ...int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
-func IDGT(id int64) predicate.ScaAuthPermissionRule {
+func IDGT(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
-func IDGTE(id int64) predicate.ScaAuthPermissionRule {
+func IDGTE(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
-func IDLT(id int64) predicate.ScaAuthPermissionRule {
+func IDLT(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
-func IDLTE(id int64) predicate.ScaAuthPermissionRule {
+func IDLTE(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldID, id))
}
@@ -144,6 +143,16 @@ func PtypeHasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldPtype, v))
}
+// PtypeIsNil applies the IsNil predicate on the "ptype" field.
+func PtypeIsNil() predicate.ScaAuthPermissionRule {
+ return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldPtype))
+}
+
+// PtypeNotNil applies the NotNil predicate on the "ptype" field.
+func PtypeNotNil() predicate.ScaAuthPermissionRule {
+ return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldPtype))
+}
+
// PtypeEqualFold applies the EqualFold predicate on the "ptype" field.
func PtypeEqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldPtype, v))
@@ -209,6 +218,16 @@ func V0HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV0, v))
}
+// V0IsNil applies the IsNil predicate on the "v0" field.
+func V0IsNil() predicate.ScaAuthPermissionRule {
+ return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV0))
+}
+
+// V0NotNil applies the NotNil predicate on the "v0" field.
+func V0NotNil() predicate.ScaAuthPermissionRule {
+ return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV0))
+}
+
// V0EqualFold applies the EqualFold predicate on the "v0" field.
func V0EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV0, v))
@@ -274,6 +293,16 @@ func V1HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV1, v))
}
+// V1IsNil applies the IsNil predicate on the "v1" field.
+func V1IsNil() predicate.ScaAuthPermissionRule {
+ return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV1))
+}
+
+// V1NotNil applies the NotNil predicate on the "v1" field.
+func V1NotNil() predicate.ScaAuthPermissionRule {
+ return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV1))
+}
+
// V1EqualFold applies the EqualFold predicate on the "v1" field.
func V1EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV1, v))
@@ -584,29 +613,6 @@ func V5ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV5, v))
}
-// HasScaAuthRole applies the HasEdge predicate on the "sca_auth_role" edge.
-func HasScaAuthRole() predicate.ScaAuthPermissionRule {
- return predicate.ScaAuthPermissionRule(func(s *sql.Selector) {
- step := sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthRoleTable, ScaAuthRoleColumn),
- )
- sqlgraph.HasNeighbors(s, step)
- })
-}
-
-// HasScaAuthRoleWith applies the HasEdge predicate on the "sca_auth_role" edge with a given conditions (other predicates).
-func HasScaAuthRoleWith(preds ...predicate.ScaAuthRole) predicate.ScaAuthPermissionRule {
- return predicate.ScaAuthPermissionRule(func(s *sql.Selector) {
- step := newScaAuthRoleStep()
- sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })
- })
-}
-
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.AndPredicates(predicates...))
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule_create.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule_create.go
index ce6cac1..63ce368 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule_create.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule_create.go
@@ -4,10 +4,8 @@ package ent
import (
"context"
- "errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
@@ -26,18 +24,42 @@ func (saprc *ScaAuthPermissionRuleCreate) SetPtype(s string) *ScaAuthPermissionR
return saprc
}
+// SetNillablePtype sets the "ptype" field if the given value is not nil.
+func (saprc *ScaAuthPermissionRuleCreate) SetNillablePtype(s *string) *ScaAuthPermissionRuleCreate {
+ if s != nil {
+ saprc.SetPtype(*s)
+ }
+ return saprc
+}
+
// SetV0 sets the "v0" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV0(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV0(s)
return saprc
}
+// SetNillableV0 sets the "v0" field if the given value is not nil.
+func (saprc *ScaAuthPermissionRuleCreate) SetNillableV0(s *string) *ScaAuthPermissionRuleCreate {
+ if s != nil {
+ saprc.SetV0(*s)
+ }
+ return saprc
+}
+
// SetV1 sets the "v1" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV1(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV1(s)
return saprc
}
+// SetNillableV1 sets the "v1" field if the given value is not nil.
+func (saprc *ScaAuthPermissionRuleCreate) SetNillableV1(s *string) *ScaAuthPermissionRuleCreate {
+ if s != nil {
+ saprc.SetV1(*s)
+ }
+ return saprc
+}
+
// SetV2 sets the "v2" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV2(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV2(s)
@@ -95,30 +117,11 @@ func (saprc *ScaAuthPermissionRuleCreate) SetNillableV5(s *string) *ScaAuthPermi
}
// SetID sets the "id" field.
-func (saprc *ScaAuthPermissionRuleCreate) SetID(i int64) *ScaAuthPermissionRuleCreate {
+func (saprc *ScaAuthPermissionRuleCreate) SetID(i int) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetID(i)
return saprc
}
-// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID.
-func (saprc *ScaAuthPermissionRuleCreate) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleCreate {
- saprc.mutation.SetScaAuthRoleID(id)
- return saprc
-}
-
-// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil.
-func (saprc *ScaAuthPermissionRuleCreate) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleCreate {
- if id != nil {
- saprc = saprc.SetScaAuthRoleID(*id)
- }
- return saprc
-}
-
-// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity.
-func (saprc *ScaAuthPermissionRuleCreate) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleCreate {
- return saprc.SetScaAuthRoleID(s.ID)
-}
-
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
func (saprc *ScaAuthPermissionRuleCreate) Mutation() *ScaAuthPermissionRuleMutation {
return saprc.mutation
@@ -153,25 +156,16 @@ func (saprc *ScaAuthPermissionRuleCreate) ExecX(ctx context.Context) {
// check runs all checks and user-defined validators on the builder.
func (saprc *ScaAuthPermissionRuleCreate) check() error {
- if _, ok := saprc.mutation.Ptype(); !ok {
- return &ValidationError{Name: "ptype", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.ptype"`)}
- }
if v, ok := saprc.mutation.Ptype(); ok {
if err := scaauthpermissionrule.PtypeValidator(v); err != nil {
return &ValidationError{Name: "ptype", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.ptype": %w`, err)}
}
}
- if _, ok := saprc.mutation.V0(); !ok {
- return &ValidationError{Name: "v0", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.v0"`)}
- }
if v, ok := saprc.mutation.V0(); ok {
if err := scaauthpermissionrule.V0Validator(v); err != nil {
return &ValidationError{Name: "v0", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v0": %w`, err)}
}
}
- if _, ok := saprc.mutation.V1(); !ok {
- return &ValidationError{Name: "v1", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.v1"`)}
- }
if v, ok := saprc.mutation.V1(); ok {
if err := scaauthpermissionrule.V1Validator(v); err != nil {
return &ValidationError{Name: "v1", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v1": %w`, err)}
@@ -213,7 +207,7 @@ func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuth
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
- _node.ID = int64(id)
+ _node.ID = int(id)
}
saprc.mutation.id = &_node.ID
saprc.mutation.done = true
@@ -223,7 +217,7 @@ func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuth
func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthPermissionRule{config: saprc.config}
- _spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
+ _spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
)
if id, ok := saprc.mutation.ID(); ok {
_node.ID = id
@@ -231,48 +225,31 @@ func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule,
}
if value, ok := saprc.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
- _node.Ptype = &value
+ _node.Ptype = value
}
if value, ok := saprc.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
- _node.V0 = &value
+ _node.V0 = value
}
if value, ok := saprc.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
- _node.V1 = &value
+ _node.V1 = value
}
if value, ok := saprc.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
- _node.V2 = &value
+ _node.V2 = value
}
if value, ok := saprc.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
- _node.V3 = &value
+ _node.V3 = value
}
if value, ok := saprc.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
- _node.V4 = &value
+ _node.V4 = value
}
if value, ok := saprc.mutation.V5(); ok {
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
- _node.V5 = &value
- }
- if nodes := saprc.mutation.ScaAuthRoleIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthpermissionrule.ScaAuthRoleTable,
- Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.sca_auth_role_sca_auth_permission_rule = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
+ _node.V5 = value
}
return _node, _spec
}
@@ -323,7 +300,7 @@ func (saprcb *ScaAuthPermissionRuleCreateBulk) Save(ctx context.Context) ([]*Sca
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
- nodes[i].ID = int64(id)
+ nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule_delete.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule_delete.go
index db1c0fe..9bdb731 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule_delete.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule_delete.go
@@ -40,7 +40,7 @@ func (saprd *ScaAuthPermissionRuleDelete) ExecX(ctx context.Context) int {
}
func (saprd *ScaAuthPermissionRuleDelete) sqlExec(ctx context.Context) (int, error) {
- _spec := sqlgraph.NewDeleteSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
+ _spec := sqlgraph.NewDeleteSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
if ps := saprd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule_query.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule_query.go
index 63458d1..e3f494f 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule_query.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule_query.go
@@ -8,7 +8,6 @@ import (
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
@@ -19,12 +18,10 @@ import (
// ScaAuthPermissionRuleQuery is the builder for querying ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleQuery struct {
config
- ctx *QueryContext
- order []scaauthpermissionrule.OrderOption
- inters []Interceptor
- predicates []predicate.ScaAuthPermissionRule
- withScaAuthRole *ScaAuthRoleQuery
- withFKs bool
+ ctx *QueryContext
+ order []scaauthpermissionrule.OrderOption
+ inters []Interceptor
+ predicates []predicate.ScaAuthPermissionRule
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -61,28 +58,6 @@ func (saprq *ScaAuthPermissionRuleQuery) Order(o ...scaauthpermissionrule.OrderO
return saprq
}
-// QueryScaAuthRole chains the current query on the "sca_auth_role" edge.
-func (saprq *ScaAuthPermissionRuleQuery) QueryScaAuthRole() *ScaAuthRoleQuery {
- query := (&ScaAuthRoleClient{config: saprq.config}).Query()
- query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
- if err := saprq.prepareQuery(ctx); err != nil {
- return nil, err
- }
- selector := saprq.sqlQuery(ctx)
- if err := selector.Err(); err != nil {
- return nil, err
- }
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID, selector),
- sqlgraph.To(scaauthrole.Table, scaauthrole.FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, scaauthpermissionrule.ScaAuthRoleTable, scaauthpermissionrule.ScaAuthRoleColumn),
- )
- fromU = sqlgraph.SetNeighbors(saprq.driver.Dialect(), step)
- return fromU, nil
- }
- return query
-}
-
// First returns the first ScaAuthPermissionRule entity from the query.
// Returns a *NotFoundError when no ScaAuthPermissionRule was found.
func (saprq *ScaAuthPermissionRuleQuery) First(ctx context.Context) (*ScaAuthPermissionRule, error) {
@@ -107,8 +82,8 @@ func (saprq *ScaAuthPermissionRuleQuery) FirstX(ctx context.Context) *ScaAuthPer
// FirstID returns the first ScaAuthPermissionRule ID from the query.
// Returns a *NotFoundError when no ScaAuthPermissionRule ID was found.
-func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int64, err error) {
- var ids []int64
+func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int, err error) {
+ var ids []int
if ids, err = saprq.Limit(1).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
@@ -120,7 +95,7 @@ func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int64,
}
// FirstIDX is like FirstID, but panics if an error occurs.
-func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int64 {
+func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int {
id, err := saprq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
@@ -158,8 +133,8 @@ func (saprq *ScaAuthPermissionRuleQuery) OnlyX(ctx context.Context) *ScaAuthPerm
// OnlyID is like Only, but returns the only ScaAuthPermissionRule ID in the query.
// Returns a *NotSingularError when more than one ScaAuthPermissionRule ID is found.
// Returns a *NotFoundError when no entities are found.
-func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int64, err error) {
- var ids []int64
+func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int, err error) {
+ var ids []int
if ids, err = saprq.Limit(2).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
@@ -175,7 +150,7 @@ func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int64,
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
-func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int64 {
+func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int {
id, err := saprq.OnlyID(ctx)
if err != nil {
panic(err)
@@ -203,7 +178,7 @@ func (saprq *ScaAuthPermissionRuleQuery) AllX(ctx context.Context) []*ScaAuthPer
}
// IDs executes the query and returns a list of ScaAuthPermissionRule IDs.
-func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int64, err error) {
+func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int, err error) {
if saprq.ctx.Unique == nil && saprq.path != nil {
saprq.Unique(true)
}
@@ -215,7 +190,7 @@ func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int64,
}
// IDsX is like IDs, but panics if an error occurs.
-func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int64 {
+func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int {
ids, err := saprq.IDs(ctx)
if err != nil {
panic(err)
@@ -270,29 +245,17 @@ func (saprq *ScaAuthPermissionRuleQuery) Clone() *ScaAuthPermissionRuleQuery {
return nil
}
return &ScaAuthPermissionRuleQuery{
- config: saprq.config,
- ctx: saprq.ctx.Clone(),
- order: append([]scaauthpermissionrule.OrderOption{}, saprq.order...),
- inters: append([]Interceptor{}, saprq.inters...),
- predicates: append([]predicate.ScaAuthPermissionRule{}, saprq.predicates...),
- withScaAuthRole: saprq.withScaAuthRole.Clone(),
+ config: saprq.config,
+ ctx: saprq.ctx.Clone(),
+ order: append([]scaauthpermissionrule.OrderOption{}, saprq.order...),
+ inters: append([]Interceptor{}, saprq.inters...),
+ predicates: append([]predicate.ScaAuthPermissionRule{}, saprq.predicates...),
// clone intermediate query.
sql: saprq.sql.Clone(),
path: saprq.path,
}
}
-// WithScaAuthRole tells the query-builder to eager-load the nodes that are connected to
-// the "sca_auth_role" edge. The optional arguments are used to configure the query builder of the edge.
-func (saprq *ScaAuthPermissionRuleQuery) WithScaAuthRole(opts ...func(*ScaAuthRoleQuery)) *ScaAuthPermissionRuleQuery {
- query := (&ScaAuthRoleClient{config: saprq.config}).Query()
- for _, opt := range opts {
- opt(query)
- }
- saprq.withScaAuthRole = query
- return saprq
-}
-
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
@@ -369,26 +332,15 @@ func (saprq *ScaAuthPermissionRuleQuery) prepareQuery(ctx context.Context) error
func (saprq *ScaAuthPermissionRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthPermissionRule, error) {
var (
- nodes = []*ScaAuthPermissionRule{}
- withFKs = saprq.withFKs
- _spec = saprq.querySpec()
- loadedTypes = [1]bool{
- saprq.withScaAuthRole != nil,
- }
+ nodes = []*ScaAuthPermissionRule{}
+ _spec = saprq.querySpec()
)
- if saprq.withScaAuthRole != nil {
- withFKs = true
- }
- if withFKs {
- _spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.ForeignKeys...)
- }
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthPermissionRule).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthPermissionRule{config: saprq.config}
nodes = append(nodes, node)
- node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
@@ -400,48 +352,9 @@ func (saprq *ScaAuthPermissionRuleQuery) sqlAll(ctx context.Context, hooks ...qu
if len(nodes) == 0 {
return nodes, nil
}
- if query := saprq.withScaAuthRole; query != nil {
- if err := saprq.loadScaAuthRole(ctx, query, nodes, nil,
- func(n *ScaAuthPermissionRule, e *ScaAuthRole) { n.Edges.ScaAuthRole = e }); err != nil {
- return nil, err
- }
- }
return nodes, nil
}
-func (saprq *ScaAuthPermissionRuleQuery) loadScaAuthRole(ctx context.Context, query *ScaAuthRoleQuery, nodes []*ScaAuthPermissionRule, init func(*ScaAuthPermissionRule), assign func(*ScaAuthPermissionRule, *ScaAuthRole)) error {
- ids := make([]int64, 0, len(nodes))
- nodeids := make(map[int64][]*ScaAuthPermissionRule)
- for i := range nodes {
- if nodes[i].sca_auth_role_sca_auth_permission_rule == nil {
- continue
- }
- fk := *nodes[i].sca_auth_role_sca_auth_permission_rule
- if _, ok := nodeids[fk]; !ok {
- ids = append(ids, fk)
- }
- nodeids[fk] = append(nodeids[fk], nodes[i])
- }
- if len(ids) == 0 {
- return nil
- }
- query.Where(scaauthrole.IDIn(ids...))
- neighbors, err := query.All(ctx)
- if err != nil {
- return err
- }
- for _, n := range neighbors {
- nodes, ok := nodeids[n.ID]
- if !ok {
- return fmt.Errorf(`unexpected foreign-key "sca_auth_role_sca_auth_permission_rule" returned %v`, n.ID)
- }
- for i := range nodes {
- assign(nodes[i], n)
- }
- }
- return nil
-}
-
func (saprq *ScaAuthPermissionRuleQuery) sqlCount(ctx context.Context) (int, error) {
_spec := saprq.querySpec()
_spec.Node.Columns = saprq.ctx.Fields
@@ -452,7 +365,7 @@ func (saprq *ScaAuthPermissionRuleQuery) sqlCount(ctx context.Context) (int, err
}
func (saprq *ScaAuthPermissionRuleQuery) querySpec() *sqlgraph.QuerySpec {
- _spec := sqlgraph.NewQuerySpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
+ _spec := sqlgraph.NewQuerySpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
_spec.From = saprq.sql
if unique := saprq.ctx.Unique; unique != nil {
_spec.Unique = *unique
diff --git a/app/core/api/repository/mysql/ent/scaauthpermissionrule_update.go b/app/core/api/repository/mysql/ent/scaauthpermissionrule_update.go
index c8202e2..bbafc57 100644
--- a/app/core/api/repository/mysql/ent/scaauthpermissionrule_update.go
+++ b/app/core/api/repository/mysql/ent/scaauthpermissionrule_update.go
@@ -8,7 +8,6 @@ import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@@ -42,6 +41,12 @@ func (sapru *ScaAuthPermissionRuleUpdate) SetNillablePtype(s *string) *ScaAuthPe
return sapru
}
+// ClearPtype clears the value of the "ptype" field.
+func (sapru *ScaAuthPermissionRuleUpdate) ClearPtype() *ScaAuthPermissionRuleUpdate {
+ sapru.mutation.ClearPtype()
+ return sapru
+}
+
// SetV0 sets the "v0" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV0(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV0(s)
@@ -56,6 +61,12 @@ func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV0(s *string) *ScaAuthPermi
return sapru
}
+// ClearV0 clears the value of the "v0" field.
+func (sapru *ScaAuthPermissionRuleUpdate) ClearV0() *ScaAuthPermissionRuleUpdate {
+ sapru.mutation.ClearV0()
+ return sapru
+}
+
// SetV1 sets the "v1" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV1(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV1(s)
@@ -70,6 +81,12 @@ func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV1(s *string) *ScaAuthPermi
return sapru
}
+// ClearV1 clears the value of the "v1" field.
+func (sapru *ScaAuthPermissionRuleUpdate) ClearV1() *ScaAuthPermissionRuleUpdate {
+ sapru.mutation.ClearV1()
+ return sapru
+}
+
// SetV2 sets the "v2" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV2(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV2(s)
@@ -150,36 +167,11 @@ func (sapru *ScaAuthPermissionRuleUpdate) ClearV5() *ScaAuthPermissionRuleUpdate
return sapru
}
-// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID.
-func (sapru *ScaAuthPermissionRuleUpdate) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleUpdate {
- sapru.mutation.SetScaAuthRoleID(id)
- return sapru
-}
-
-// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil.
-func (sapru *ScaAuthPermissionRuleUpdate) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleUpdate {
- if id != nil {
- sapru = sapru.SetScaAuthRoleID(*id)
- }
- return sapru
-}
-
-// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity.
-func (sapru *ScaAuthPermissionRuleUpdate) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleUpdate {
- return sapru.SetScaAuthRoleID(s.ID)
-}
-
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
func (sapru *ScaAuthPermissionRuleUpdate) Mutation() *ScaAuthPermissionRuleMutation {
return sapru.mutation
}
-// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity.
-func (sapru *ScaAuthPermissionRuleUpdate) ClearScaAuthRole() *ScaAuthPermissionRuleUpdate {
- sapru.mutation.ClearScaAuthRole()
- return sapru
-}
-
// Save executes the query and returns the number of nodes affected by the update operation.
func (sapru *ScaAuthPermissionRuleUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, sapru.sqlSave, sapru.mutation, sapru.hooks)
@@ -251,7 +243,7 @@ func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, e
if err := sapru.check(); err != nil {
return n, err
}
- _spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
+ _spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
if ps := sapru.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -262,12 +254,21 @@ func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, e
if value, ok := sapru.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
}
+ if sapru.mutation.PtypeCleared() {
+ _spec.ClearField(scaauthpermissionrule.FieldPtype, field.TypeString)
+ }
if value, ok := sapru.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
}
+ if sapru.mutation.V0Cleared() {
+ _spec.ClearField(scaauthpermissionrule.FieldV0, field.TypeString)
+ }
if value, ok := sapru.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
}
+ if sapru.mutation.V1Cleared() {
+ _spec.ClearField(scaauthpermissionrule.FieldV1, field.TypeString)
+ }
if value, ok := sapru.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
}
@@ -292,35 +293,6 @@ func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, e
if sapru.mutation.V5Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString)
}
- if sapru.mutation.ScaAuthRoleCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthpermissionrule.ScaAuthRoleTable,
- Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sapru.mutation.ScaAuthRoleIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthpermissionrule.ScaAuthRoleTable,
- Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
if n, err = sqlgraph.UpdateNodes(ctx, sapru.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthpermissionrule.Label}
@@ -355,6 +327,12 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillablePtype(s *string) *ScaAu
return sapruo
}
+// ClearPtype clears the value of the "ptype" field.
+func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearPtype() *ScaAuthPermissionRuleUpdateOne {
+ sapruo.mutation.ClearPtype()
+ return sapruo
+}
+
// SetV0 sets the "v0" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV0(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV0(s)
@@ -369,6 +347,12 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV0(s *string) *ScaAuthP
return sapruo
}
+// ClearV0 clears the value of the "v0" field.
+func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV0() *ScaAuthPermissionRuleUpdateOne {
+ sapruo.mutation.ClearV0()
+ return sapruo
+}
+
// SetV1 sets the "v1" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV1(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV1(s)
@@ -383,6 +367,12 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV1(s *string) *ScaAuthP
return sapruo
}
+// ClearV1 clears the value of the "v1" field.
+func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV1() *ScaAuthPermissionRuleUpdateOne {
+ sapruo.mutation.ClearV1()
+ return sapruo
+}
+
// SetV2 sets the "v2" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV2(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV2(s)
@@ -463,36 +453,11 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV5() *ScaAuthPermissionRuleUp
return sapruo
}
-// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID.
-func (sapruo *ScaAuthPermissionRuleUpdateOne) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleUpdateOne {
- sapruo.mutation.SetScaAuthRoleID(id)
- return sapruo
-}
-
-// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil.
-func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleUpdateOne {
- if id != nil {
- sapruo = sapruo.SetScaAuthRoleID(*id)
- }
- return sapruo
-}
-
-// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity.
-func (sapruo *ScaAuthPermissionRuleUpdateOne) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleUpdateOne {
- return sapruo.SetScaAuthRoleID(s.ID)
-}
-
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Mutation() *ScaAuthPermissionRuleMutation {
return sapruo.mutation
}
-// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity.
-func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearScaAuthRole() *ScaAuthPermissionRuleUpdateOne {
- sapruo.mutation.ClearScaAuthRole()
- return sapruo
-}
-
// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.Where(ps...)
@@ -577,7 +542,7 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_nod
if err := sapruo.check(); err != nil {
return _node, err
}
- _spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
+ _spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
id, ok := sapruo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthPermissionRule.id" for update`)}
@@ -605,12 +570,21 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_nod
if value, ok := sapruo.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
}
+ if sapruo.mutation.PtypeCleared() {
+ _spec.ClearField(scaauthpermissionrule.FieldPtype, field.TypeString)
+ }
if value, ok := sapruo.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
}
+ if sapruo.mutation.V0Cleared() {
+ _spec.ClearField(scaauthpermissionrule.FieldV0, field.TypeString)
+ }
if value, ok := sapruo.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
}
+ if sapruo.mutation.V1Cleared() {
+ _spec.ClearField(scaauthpermissionrule.FieldV1, field.TypeString)
+ }
if value, ok := sapruo.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
}
@@ -635,35 +609,6 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_nod
if sapruo.mutation.V5Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString)
}
- if sapruo.mutation.ScaAuthRoleCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthpermissionrule.ScaAuthRoleTable,
- Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sapruo.mutation.ScaAuthRoleIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthpermissionrule.ScaAuthRoleTable,
- Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
_node = &ScaAuthPermissionRule{config: sapruo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/app/core/api/repository/mysql/ent/scaauthrole.go b/app/core/api/repository/mysql/ent/scaauthrole.go
index 6742894..09c25f7 100644
--- a/app/core/api/repository/mysql/ent/scaauthrole.go
+++ b/app/core/api/repository/mysql/ent/scaauthrole.go
@@ -27,31 +27,10 @@ type ScaAuthRole struct {
// 角色名称
RoleName string `json:"role_name,omitempty"`
// 角色关键字
- RoleKey string `json:"role_key,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ScaAuthRoleQuery when eager-loading is set.
- Edges ScaAuthRoleEdges `json:"edges"`
+ RoleKey string `json:"role_key,omitempty"`
selectValues sql.SelectValues
}
-// ScaAuthRoleEdges holds the relations/edges for other nodes in the graph.
-type ScaAuthRoleEdges struct {
- // ScaAuthPermissionRule holds the value of the sca_auth_permission_rule edge.
- ScaAuthPermissionRule []*ScaAuthPermissionRule `json:"sca_auth_permission_rule,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
-}
-
-// ScaAuthPermissionRuleOrErr returns the ScaAuthPermissionRule value or an error if the edge
-// was not loaded in eager-loading.
-func (e ScaAuthRoleEdges) ScaAuthPermissionRuleOrErr() ([]*ScaAuthPermissionRule, error) {
- if e.loadedTypes[0] {
- return e.ScaAuthPermissionRule, nil
- }
- return nil, &NotLoadedError{edge: "sca_auth_permission_rule"}
-}
-
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthRole) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
@@ -127,11 +106,6 @@ func (sar *ScaAuthRole) Value(name string) (ent.Value, error) {
return sar.selectValues.Get(name)
}
-// QueryScaAuthPermissionRule queries the "sca_auth_permission_rule" edge of the ScaAuthRole entity.
-func (sar *ScaAuthRole) QueryScaAuthPermissionRule() *ScaAuthPermissionRuleQuery {
- return NewScaAuthRoleClient(sar.config).QueryScaAuthPermissionRule(sar)
-}
-
// Update returns a builder for updating this ScaAuthRole.
// Note that you need to call ScaAuthRole.Unwrap() before calling this method if this ScaAuthRole
// was returned from a transaction, and the transaction was committed or rolled back.
diff --git a/app/core/api/repository/mysql/ent/scaauthrole/scaauthrole.go b/app/core/api/repository/mysql/ent/scaauthrole/scaauthrole.go
index de2a2f8..a9c9445 100644
--- a/app/core/api/repository/mysql/ent/scaauthrole/scaauthrole.go
+++ b/app/core/api/repository/mysql/ent/scaauthrole/scaauthrole.go
@@ -6,7 +6,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -24,17 +23,8 @@ const (
FieldRoleName = "role_name"
// FieldRoleKey holds the string denoting the role_key field in the database.
FieldRoleKey = "role_key"
- // EdgeScaAuthPermissionRule holds the string denoting the sca_auth_permission_rule edge name in mutations.
- EdgeScaAuthPermissionRule = "sca_auth_permission_rule"
// Table holds the table name of the scaauthrole in the database.
Table = "sca_auth_role"
- // ScaAuthPermissionRuleTable is the table that holds the sca_auth_permission_rule relation/edge.
- ScaAuthPermissionRuleTable = "sca_auth_permission_rule"
- // ScaAuthPermissionRuleInverseTable is the table name for the ScaAuthPermissionRule entity.
- // It exists in this package in order to avoid circular dependency with the "scaauthpermissionrule" package.
- ScaAuthPermissionRuleInverseTable = "sca_auth_permission_rule"
- // ScaAuthPermissionRuleColumn is the table column denoting the sca_auth_permission_rule relation/edge.
- ScaAuthPermissionRuleColumn = "sca_auth_role_sca_auth_permission_rule"
)
// Columns holds all SQL columns for scaauthrole fields.
@@ -106,24 +96,3 @@ func ByRoleName(opts ...sql.OrderTermOption) OrderOption {
func ByRoleKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRoleKey, opts...).ToFunc()
}
-
-// ByScaAuthPermissionRuleCount orders the results by sca_auth_permission_rule count.
-func ByScaAuthPermissionRuleCount(opts ...sql.OrderTermOption) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborsCount(s, newScaAuthPermissionRuleStep(), opts...)
- }
-}
-
-// ByScaAuthPermissionRule orders the results by sca_auth_permission_rule terms.
-func ByScaAuthPermissionRule(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborTerms(s, newScaAuthPermissionRuleStep(), append([]sql.OrderTerm{term}, terms...)...)
- }
-}
-func newScaAuthPermissionRuleStep() *sqlgraph.Step {
- return sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.To(ScaAuthPermissionRuleInverseTable, FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthPermissionRuleTable, ScaAuthPermissionRuleColumn),
- )
-}
diff --git a/app/core/api/repository/mysql/ent/scaauthrole/where.go b/app/core/api/repository/mysql/ent/scaauthrole/where.go
index 3fc5c56..ef6ae18 100644
--- a/app/core/api/repository/mysql/ent/scaauthrole/where.go
+++ b/app/core/api/repository/mysql/ent/scaauthrole/where.go
@@ -7,7 +7,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
@@ -340,29 +339,6 @@ func RoleKeyContainsFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleKey, v))
}
-// HasScaAuthPermissionRule applies the HasEdge predicate on the "sca_auth_permission_rule" edge.
-func HasScaAuthPermissionRule() predicate.ScaAuthRole {
- return predicate.ScaAuthRole(func(s *sql.Selector) {
- step := sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthPermissionRuleTable, ScaAuthPermissionRuleColumn),
- )
- sqlgraph.HasNeighbors(s, step)
- })
-}
-
-// HasScaAuthPermissionRuleWith applies the HasEdge predicate on the "sca_auth_permission_rule" edge with a given conditions (other predicates).
-func HasScaAuthPermissionRuleWith(preds ...predicate.ScaAuthPermissionRule) predicate.ScaAuthRole {
- return predicate.ScaAuthRole(func(s *sql.Selector) {
- step := newScaAuthPermissionRuleStep()
- sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })
- })
-}
-
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.AndPredicates(predicates...))
diff --git a/app/core/api/repository/mysql/ent/scaauthrole_create.go b/app/core/api/repository/mysql/ent/scaauthrole_create.go
index 853d095..bb050da 100644
--- a/app/core/api/repository/mysql/ent/scaauthrole_create.go
+++ b/app/core/api/repository/mysql/ent/scaauthrole_create.go
@@ -6,7 +6,6 @@ import (
"context"
"errors"
"fmt"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"time"
@@ -81,21 +80,6 @@ func (sarc *ScaAuthRoleCreate) SetID(i int64) *ScaAuthRoleCreate {
return sarc
}
-// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
-func (sarc *ScaAuthRoleCreate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleCreate {
- sarc.mutation.AddScaAuthPermissionRuleIDs(ids...)
- return sarc
-}
-
-// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
-func (sarc *ScaAuthRoleCreate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleCreate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sarc.AddScaAuthPermissionRuleIDs(ids...)
-}
-
// Mutation returns the ScaAuthRoleMutation object of the builder.
func (sarc *ScaAuthRoleCreate) Mutation() *ScaAuthRoleMutation {
return sarc.mutation
@@ -226,22 +210,6 @@ func (sarc *ScaAuthRoleCreate) createSpec() (*ScaAuthRole, *sqlgraph.CreateSpec)
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
_node.RoleKey = value
}
- if nodes := sarc.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
return _node, _spec
}
diff --git a/app/core/api/repository/mysql/ent/scaauthrole_query.go b/app/core/api/repository/mysql/ent/scaauthrole_query.go
index a67b149..353e56e 100644
--- a/app/core/api/repository/mysql/ent/scaauthrole_query.go
+++ b/app/core/api/repository/mysql/ent/scaauthrole_query.go
@@ -4,11 +4,9 @@ package ent
import (
"context"
- "database/sql/driver"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"entgo.io/ent"
@@ -20,11 +18,10 @@ import (
// ScaAuthRoleQuery is the builder for querying ScaAuthRole entities.
type ScaAuthRoleQuery struct {
config
- ctx *QueryContext
- order []scaauthrole.OrderOption
- inters []Interceptor
- predicates []predicate.ScaAuthRole
- withScaAuthPermissionRule *ScaAuthPermissionRuleQuery
+ ctx *QueryContext
+ order []scaauthrole.OrderOption
+ inters []Interceptor
+ predicates []predicate.ScaAuthRole
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -61,28 +58,6 @@ func (sarq *ScaAuthRoleQuery) Order(o ...scaauthrole.OrderOption) *ScaAuthRoleQu
return sarq
}
-// QueryScaAuthPermissionRule chains the current query on the "sca_auth_permission_rule" edge.
-func (sarq *ScaAuthRoleQuery) QueryScaAuthPermissionRule() *ScaAuthPermissionRuleQuery {
- query := (&ScaAuthPermissionRuleClient{config: sarq.config}).Query()
- query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
- if err := sarq.prepareQuery(ctx); err != nil {
- return nil, err
- }
- selector := sarq.sqlQuery(ctx)
- if err := selector.Err(); err != nil {
- return nil, err
- }
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthrole.Table, scaauthrole.FieldID, selector),
- sqlgraph.To(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, scaauthrole.ScaAuthPermissionRuleTable, scaauthrole.ScaAuthPermissionRuleColumn),
- )
- fromU = sqlgraph.SetNeighbors(sarq.driver.Dialect(), step)
- return fromU, nil
- }
- return query
-}
-
// First returns the first ScaAuthRole entity from the query.
// Returns a *NotFoundError when no ScaAuthRole was found.
func (sarq *ScaAuthRoleQuery) First(ctx context.Context) (*ScaAuthRole, error) {
@@ -270,29 +245,17 @@ func (sarq *ScaAuthRoleQuery) Clone() *ScaAuthRoleQuery {
return nil
}
return &ScaAuthRoleQuery{
- config: sarq.config,
- ctx: sarq.ctx.Clone(),
- order: append([]scaauthrole.OrderOption{}, sarq.order...),
- inters: append([]Interceptor{}, sarq.inters...),
- predicates: append([]predicate.ScaAuthRole{}, sarq.predicates...),
- withScaAuthPermissionRule: sarq.withScaAuthPermissionRule.Clone(),
+ config: sarq.config,
+ ctx: sarq.ctx.Clone(),
+ order: append([]scaauthrole.OrderOption{}, sarq.order...),
+ inters: append([]Interceptor{}, sarq.inters...),
+ predicates: append([]predicate.ScaAuthRole{}, sarq.predicates...),
// clone intermediate query.
sql: sarq.sql.Clone(),
path: sarq.path,
}
}
-// WithScaAuthPermissionRule tells the query-builder to eager-load the nodes that are connected to
-// the "sca_auth_permission_rule" edge. The optional arguments are used to configure the query builder of the edge.
-func (sarq *ScaAuthRoleQuery) WithScaAuthPermissionRule(opts ...func(*ScaAuthPermissionRuleQuery)) *ScaAuthRoleQuery {
- query := (&ScaAuthPermissionRuleClient{config: sarq.config}).Query()
- for _, opt := range opts {
- opt(query)
- }
- sarq.withScaAuthPermissionRule = query
- return sarq
-}
-
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
@@ -369,11 +332,8 @@ func (sarq *ScaAuthRoleQuery) prepareQuery(ctx context.Context) error {
func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthRole, error) {
var (
- nodes = []*ScaAuthRole{}
- _spec = sarq.querySpec()
- loadedTypes = [1]bool{
- sarq.withScaAuthPermissionRule != nil,
- }
+ nodes = []*ScaAuthRole{}
+ _spec = sarq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthRole).scanValues(nil, columns)
@@ -381,7 +341,6 @@ func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthRole{config: sarq.config}
nodes = append(nodes, node)
- node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
@@ -393,50 +352,9 @@ func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
if len(nodes) == 0 {
return nodes, nil
}
- if query := sarq.withScaAuthPermissionRule; query != nil {
- if err := sarq.loadScaAuthPermissionRule(ctx, query, nodes,
- func(n *ScaAuthRole) { n.Edges.ScaAuthPermissionRule = []*ScaAuthPermissionRule{} },
- func(n *ScaAuthRole, e *ScaAuthPermissionRule) {
- n.Edges.ScaAuthPermissionRule = append(n.Edges.ScaAuthPermissionRule, e)
- }); err != nil {
- return nil, err
- }
- }
return nodes, nil
}
-func (sarq *ScaAuthRoleQuery) loadScaAuthPermissionRule(ctx context.Context, query *ScaAuthPermissionRuleQuery, nodes []*ScaAuthRole, init func(*ScaAuthRole), assign func(*ScaAuthRole, *ScaAuthPermissionRule)) error {
- fks := make([]driver.Value, 0, len(nodes))
- nodeids := make(map[int64]*ScaAuthRole)
- for i := range nodes {
- fks = append(fks, nodes[i].ID)
- nodeids[nodes[i].ID] = nodes[i]
- if init != nil {
- init(nodes[i])
- }
- }
- query.withFKs = true
- query.Where(predicate.ScaAuthPermissionRule(func(s *sql.Selector) {
- s.Where(sql.InValues(s.C(scaauthrole.ScaAuthPermissionRuleColumn), fks...))
- }))
- neighbors, err := query.All(ctx)
- if err != nil {
- return err
- }
- for _, n := range neighbors {
- fk := n.sca_auth_role_sca_auth_permission_rule
- if fk == nil {
- return fmt.Errorf(`foreign-key "sca_auth_role_sca_auth_permission_rule" is nil for node %v`, n.ID)
- }
- node, ok := nodeids[*fk]
- if !ok {
- return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_role_sca_auth_permission_rule" returned %v for node %v`, *fk, n.ID)
- }
- assign(node, n)
- }
- return nil
-}
-
func (sarq *ScaAuthRoleQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sarq.querySpec()
_spec.Node.Columns = sarq.ctx.Fields
diff --git a/app/core/api/repository/mysql/ent/scaauthrole_update.go b/app/core/api/repository/mysql/ent/scaauthrole_update.go
index e35f8c9..93b1c35 100644
--- a/app/core/api/repository/mysql/ent/scaauthrole_update.go
+++ b/app/core/api/repository/mysql/ent/scaauthrole_update.go
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"time"
@@ -90,47 +89,11 @@ func (saru *ScaAuthRoleUpdate) SetNillableRoleKey(s *string) *ScaAuthRoleUpdate
return saru
}
-// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
-func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate {
- saru.mutation.AddScaAuthPermissionRuleIDs(ids...)
- return saru
-}
-
-// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
-func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return saru.AddScaAuthPermissionRuleIDs(ids...)
-}
-
// Mutation returns the ScaAuthRoleMutation object of the builder.
func (saru *ScaAuthRoleUpdate) Mutation() *ScaAuthRoleMutation {
return saru.mutation
}
-// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
-func (saru *ScaAuthRoleUpdate) ClearScaAuthPermissionRule() *ScaAuthRoleUpdate {
- saru.mutation.ClearScaAuthPermissionRule()
- return saru
-}
-
-// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs.
-func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate {
- saru.mutation.RemoveScaAuthPermissionRuleIDs(ids...)
- return saru
-}
-
-// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities.
-func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return saru.RemoveScaAuthPermissionRuleIDs(ids...)
-}
-
// Save executes the query and returns the number of nodes affected by the update operation.
func (saru *ScaAuthRoleUpdate) Save(ctx context.Context) (int, error) {
saru.defaults()
@@ -217,51 +180,6 @@ func (saru *ScaAuthRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := saru.mutation.RoleKey(); ok {
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
}
- if saru.mutation.ScaAuthPermissionRuleCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := saru.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saru.mutation.ScaAuthPermissionRuleCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := saru.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
if n, err = sqlgraph.UpdateNodes(ctx, saru.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthrole.Label}
@@ -343,47 +261,11 @@ func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleKey(s *string) *ScaAuthRoleUpd
return saruo
}
-// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
-func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne {
- saruo.mutation.AddScaAuthPermissionRuleIDs(ids...)
- return saruo
-}
-
-// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
-func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return saruo.AddScaAuthPermissionRuleIDs(ids...)
-}
-
// Mutation returns the ScaAuthRoleMutation object of the builder.
func (saruo *ScaAuthRoleUpdateOne) Mutation() *ScaAuthRoleMutation {
return saruo.mutation
}
-// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
-func (saruo *ScaAuthRoleUpdateOne) ClearScaAuthPermissionRule() *ScaAuthRoleUpdateOne {
- saruo.mutation.ClearScaAuthPermissionRule()
- return saruo
-}
-
-// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs.
-func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne {
- saruo.mutation.RemoveScaAuthPermissionRuleIDs(ids...)
- return saruo
-}
-
-// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities.
-func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return saruo.RemoveScaAuthPermissionRuleIDs(ids...)
-}
-
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
func (saruo *ScaAuthRoleUpdateOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdateOne {
saruo.mutation.Where(ps...)
@@ -500,51 +382,6 @@ func (saruo *ScaAuthRoleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthR
if value, ok := saruo.mutation.RoleKey(); ok {
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
}
- if saruo.mutation.ScaAuthPermissionRuleCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := saruo.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saruo.mutation.ScaAuthPermissionRuleCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := saruo.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthrole.ScaAuthPermissionRuleTable,
- Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
_node = &ScaAuthRole{config: saruo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/app/core/api/repository/mysql/ent/scaauthuser.go b/app/core/api/repository/mysql/ent/scaauthuser.go
index a3ff289..2ac33f9 100644
--- a/app/core/api/repository/mysql/ent/scaauthuser.go
+++ b/app/core/api/repository/mysql/ent/scaauthuser.go
@@ -37,7 +37,7 @@ type ScaAuthUser struct {
// 密码
Password string `json:"-"`
// 性别
- Gender string `json:"gender,omitempty"`
+ Gender int8 `json:"gender,omitempty"`
// 头像
Avatar string `json:"avatar,omitempty"`
// 状态 0 正常 1 封禁
@@ -49,50 +49,18 @@ type ScaAuthUser struct {
// 地址
Location *string `json:"location,omitempty"`
// 公司
- Company *string `json:"company,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ScaAuthUserQuery when eager-loading is set.
- Edges ScaAuthUserEdges `json:"edges"`
+ Company *string `json:"company,omitempty"`
selectValues sql.SelectValues
}
-// ScaAuthUserEdges holds the relations/edges for other nodes in the graph.
-type ScaAuthUserEdges struct {
- // ScaAuthUserSocial holds the value of the sca_auth_user_social edge.
- ScaAuthUserSocial []*ScaAuthUserSocial `json:"sca_auth_user_social,omitempty"`
- // ScaAuthUserDevice holds the value of the sca_auth_user_device edge.
- ScaAuthUserDevice []*ScaAuthUserDevice `json:"sca_auth_user_device,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [2]bool
-}
-
-// ScaAuthUserSocialOrErr returns the ScaAuthUserSocial value or an error if the edge
-// was not loaded in eager-loading.
-func (e ScaAuthUserEdges) ScaAuthUserSocialOrErr() ([]*ScaAuthUserSocial, error) {
- if e.loadedTypes[0] {
- return e.ScaAuthUserSocial, nil
- }
- return nil, &NotLoadedError{edge: "sca_auth_user_social"}
-}
-
-// ScaAuthUserDeviceOrErr returns the ScaAuthUserDevice value or an error if the edge
-// was not loaded in eager-loading.
-func (e ScaAuthUserEdges) ScaAuthUserDeviceOrErr() ([]*ScaAuthUserDevice, error) {
- if e.loadedTypes[1] {
- return e.ScaAuthUserDevice, nil
- }
- return nil, &NotLoadedError{edge: "sca_auth_user_device"}
-}
-
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthUser) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
- case scaauthuser.FieldID, scaauthuser.FieldDeleted, scaauthuser.FieldStatus:
+ case scaauthuser.FieldID, scaauthuser.FieldDeleted, scaauthuser.FieldGender, scaauthuser.FieldStatus:
values[i] = new(sql.NullInt64)
- case scaauthuser.FieldUID, scaauthuser.FieldUsername, scaauthuser.FieldNickname, scaauthuser.FieldEmail, scaauthuser.FieldPhone, scaauthuser.FieldPassword, scaauthuser.FieldGender, scaauthuser.FieldAvatar, scaauthuser.FieldIntroduce, scaauthuser.FieldBlog, scaauthuser.FieldLocation, scaauthuser.FieldCompany:
+ case scaauthuser.FieldUID, scaauthuser.FieldUsername, scaauthuser.FieldNickname, scaauthuser.FieldEmail, scaauthuser.FieldPhone, scaauthuser.FieldPassword, scaauthuser.FieldAvatar, scaauthuser.FieldIntroduce, scaauthuser.FieldBlog, scaauthuser.FieldLocation, scaauthuser.FieldCompany:
values[i] = new(sql.NullString)
case scaauthuser.FieldCreatedAt, scaauthuser.FieldUpdatedAt:
values[i] = new(sql.NullTime)
@@ -172,10 +140,10 @@ func (sau *ScaAuthUser) assignValues(columns []string, values []any) error {
sau.Password = value.String
}
case scaauthuser.FieldGender:
- if value, ok := values[i].(*sql.NullString); !ok {
+ if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field gender", values[i])
} else if value.Valid {
- sau.Gender = value.String
+ sau.Gender = int8(value.Int64)
}
case scaauthuser.FieldAvatar:
if value, ok := values[i].(*sql.NullString); !ok {
@@ -229,16 +197,6 @@ func (sau *ScaAuthUser) Value(name string) (ent.Value, error) {
return sau.selectValues.Get(name)
}
-// QueryScaAuthUserSocial queries the "sca_auth_user_social" edge of the ScaAuthUser entity.
-func (sau *ScaAuthUser) QueryScaAuthUserSocial() *ScaAuthUserSocialQuery {
- return NewScaAuthUserClient(sau.config).QueryScaAuthUserSocial(sau)
-}
-
-// QueryScaAuthUserDevice queries the "sca_auth_user_device" edge of the ScaAuthUser entity.
-func (sau *ScaAuthUser) QueryScaAuthUserDevice() *ScaAuthUserDeviceQuery {
- return NewScaAuthUserClient(sau.config).QueryScaAuthUserDevice(sau)
-}
-
// Update returns a builder for updating this ScaAuthUser.
// Note that you need to call ScaAuthUser.Unwrap() before calling this method if this ScaAuthUser
// was returned from a transaction, and the transaction was committed or rolled back.
@@ -289,7 +247,7 @@ func (sau *ScaAuthUser) String() string {
builder.WriteString("password=")
builder.WriteString(", ")
builder.WriteString("gender=")
- builder.WriteString(sau.Gender)
+ builder.WriteString(fmt.Sprintf("%v", sau.Gender))
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(sau.Avatar)
diff --git a/app/core/api/repository/mysql/ent/scaauthuser/scaauthuser.go b/app/core/api/repository/mysql/ent/scaauthuser/scaauthuser.go
index cff1a70..f9cf257 100644
--- a/app/core/api/repository/mysql/ent/scaauthuser/scaauthuser.go
+++ b/app/core/api/repository/mysql/ent/scaauthuser/scaauthuser.go
@@ -6,7 +6,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -46,26 +45,8 @@ const (
FieldLocation = "location"
// FieldCompany holds the string denoting the company field in the database.
FieldCompany = "company"
- // EdgeScaAuthUserSocial holds the string denoting the sca_auth_user_social edge name in mutations.
- EdgeScaAuthUserSocial = "sca_auth_user_social"
- // EdgeScaAuthUserDevice holds the string denoting the sca_auth_user_device edge name in mutations.
- EdgeScaAuthUserDevice = "sca_auth_user_device"
// Table holds the table name of the scaauthuser in the database.
Table = "sca_auth_user"
- // ScaAuthUserSocialTable is the table that holds the sca_auth_user_social relation/edge.
- ScaAuthUserSocialTable = "sca_auth_user_social"
- // ScaAuthUserSocialInverseTable is the table name for the ScaAuthUserSocial entity.
- // It exists in this package in order to avoid circular dependency with the "scaauthusersocial" package.
- ScaAuthUserSocialInverseTable = "sca_auth_user_social"
- // ScaAuthUserSocialColumn is the table column denoting the sca_auth_user_social relation/edge.
- ScaAuthUserSocialColumn = "sca_auth_user_sca_auth_user_social"
- // ScaAuthUserDeviceTable is the table that holds the sca_auth_user_device relation/edge.
- ScaAuthUserDeviceTable = "sca_auth_user_device"
- // ScaAuthUserDeviceInverseTable is the table name for the ScaAuthUserDevice entity.
- // It exists in this package in order to avoid circular dependency with the "scaauthuserdevice" package.
- ScaAuthUserDeviceInverseTable = "sca_auth_user_device"
- // ScaAuthUserDeviceColumn is the table column denoting the sca_auth_user_device relation/edge.
- ScaAuthUserDeviceColumn = "sca_auth_user_sca_auth_user_device"
)
// Columns holds all SQL columns for scaauthuser fields.
@@ -122,8 +103,6 @@ var (
PhoneValidator func(string) error
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
PasswordValidator func(string) error
- // GenderValidator is a validator for the "gender" field. It is called by the builders before save.
- GenderValidator func(string) error
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus int8
// IntroduceValidator is a validator for the "introduce" field. It is called by the builders before save.
@@ -223,45 +202,3 @@ func ByLocation(opts ...sql.OrderTermOption) OrderOption {
func ByCompany(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCompany, opts...).ToFunc()
}
-
-// ByScaAuthUserSocialCount orders the results by sca_auth_user_social count.
-func ByScaAuthUserSocialCount(opts ...sql.OrderTermOption) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborsCount(s, newScaAuthUserSocialStep(), opts...)
- }
-}
-
-// ByScaAuthUserSocial orders the results by sca_auth_user_social terms.
-func ByScaAuthUserSocial(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborTerms(s, newScaAuthUserSocialStep(), append([]sql.OrderTerm{term}, terms...)...)
- }
-}
-
-// ByScaAuthUserDeviceCount orders the results by sca_auth_user_device count.
-func ByScaAuthUserDeviceCount(opts ...sql.OrderTermOption) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborsCount(s, newScaAuthUserDeviceStep(), opts...)
- }
-}
-
-// ByScaAuthUserDevice orders the results by sca_auth_user_device terms.
-func ByScaAuthUserDevice(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborTerms(s, newScaAuthUserDeviceStep(), append([]sql.OrderTerm{term}, terms...)...)
- }
-}
-func newScaAuthUserSocialStep() *sqlgraph.Step {
- return sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.To(ScaAuthUserSocialInverseTable, FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserSocialTable, ScaAuthUserSocialColumn),
- )
-}
-func newScaAuthUserDeviceStep() *sqlgraph.Step {
- return sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.To(ScaAuthUserDeviceInverseTable, FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserDeviceTable, ScaAuthUserDeviceColumn),
- )
-}
diff --git a/app/core/api/repository/mysql/ent/scaauthuser/where.go b/app/core/api/repository/mysql/ent/scaauthuser/where.go
index 99bb1f7..89c32c5 100644
--- a/app/core/api/repository/mysql/ent/scaauthuser/where.go
+++ b/app/core/api/repository/mysql/ent/scaauthuser/where.go
@@ -7,7 +7,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
@@ -101,7 +100,7 @@ func Password(v string) predicate.ScaAuthUser {
}
// Gender applies equality check predicate on the "gender" field. It's identical to GenderEQ.
-func Gender(v string) predicate.ScaAuthUser {
+func Gender(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldEQ(FieldGender, v))
}
@@ -706,60 +705,45 @@ func PasswordContainsFold(v string) predicate.ScaAuthUser {
}
// GenderEQ applies the EQ predicate on the "gender" field.
-func GenderEQ(v string) predicate.ScaAuthUser {
+func GenderEQ(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldEQ(FieldGender, v))
}
// GenderNEQ applies the NEQ predicate on the "gender" field.
-func GenderNEQ(v string) predicate.ScaAuthUser {
+func GenderNEQ(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldNEQ(FieldGender, v))
}
// GenderIn applies the In predicate on the "gender" field.
-func GenderIn(vs ...string) predicate.ScaAuthUser {
+func GenderIn(vs ...int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldIn(FieldGender, vs...))
}
// GenderNotIn applies the NotIn predicate on the "gender" field.
-func GenderNotIn(vs ...string) predicate.ScaAuthUser {
+func GenderNotIn(vs ...int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldNotIn(FieldGender, vs...))
}
// GenderGT applies the GT predicate on the "gender" field.
-func GenderGT(v string) predicate.ScaAuthUser {
+func GenderGT(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldGT(FieldGender, v))
}
// GenderGTE applies the GTE predicate on the "gender" field.
-func GenderGTE(v string) predicate.ScaAuthUser {
+func GenderGTE(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldGTE(FieldGender, v))
}
// GenderLT applies the LT predicate on the "gender" field.
-func GenderLT(v string) predicate.ScaAuthUser {
+func GenderLT(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldLT(FieldGender, v))
}
// GenderLTE applies the LTE predicate on the "gender" field.
-func GenderLTE(v string) predicate.ScaAuthUser {
+func GenderLTE(v int8) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldLTE(FieldGender, v))
}
-// GenderContains applies the Contains predicate on the "gender" field.
-func GenderContains(v string) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(sql.FieldContains(FieldGender, v))
-}
-
-// GenderHasPrefix applies the HasPrefix predicate on the "gender" field.
-func GenderHasPrefix(v string) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldGender, v))
-}
-
-// GenderHasSuffix applies the HasSuffix predicate on the "gender" field.
-func GenderHasSuffix(v string) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldGender, v))
-}
-
// GenderIsNil applies the IsNil predicate on the "gender" field.
func GenderIsNil() predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldIsNull(FieldGender))
@@ -770,16 +754,6 @@ func GenderNotNil() predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldNotNull(FieldGender))
}
-// GenderEqualFold applies the EqualFold predicate on the "gender" field.
-func GenderEqualFold(v string) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(sql.FieldEqualFold(FieldGender, v))
-}
-
-// GenderContainsFold applies the ContainsFold predicate on the "gender" field.
-func GenderContainsFold(v string) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(sql.FieldContainsFold(FieldGender, v))
-}
-
// AvatarEQ applies the EQ predicate on the "avatar" field.
func AvatarEQ(v string) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldEQ(FieldAvatar, v))
@@ -1205,52 +1179,6 @@ func CompanyContainsFold(v string) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.FieldContainsFold(FieldCompany, v))
}
-// HasScaAuthUserSocial applies the HasEdge predicate on the "sca_auth_user_social" edge.
-func HasScaAuthUserSocial() predicate.ScaAuthUser {
- return predicate.ScaAuthUser(func(s *sql.Selector) {
- step := sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserSocialTable, ScaAuthUserSocialColumn),
- )
- sqlgraph.HasNeighbors(s, step)
- })
-}
-
-// HasScaAuthUserSocialWith applies the HasEdge predicate on the "sca_auth_user_social" edge with a given conditions (other predicates).
-func HasScaAuthUserSocialWith(preds ...predicate.ScaAuthUserSocial) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(func(s *sql.Selector) {
- step := newScaAuthUserSocialStep()
- sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })
- })
-}
-
-// HasScaAuthUserDevice applies the HasEdge predicate on the "sca_auth_user_device" edge.
-func HasScaAuthUserDevice() predicate.ScaAuthUser {
- return predicate.ScaAuthUser(func(s *sql.Selector) {
- step := sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserDeviceTable, ScaAuthUserDeviceColumn),
- )
- sqlgraph.HasNeighbors(s, step)
- })
-}
-
-// HasScaAuthUserDeviceWith applies the HasEdge predicate on the "sca_auth_user_device" edge with a given conditions (other predicates).
-func HasScaAuthUserDeviceWith(preds ...predicate.ScaAuthUserDevice) predicate.ScaAuthUser {
- return predicate.ScaAuthUser(func(s *sql.Selector) {
- step := newScaAuthUserDeviceStep()
- sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })
- })
-}
-
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthUser) predicate.ScaAuthUser {
return predicate.ScaAuthUser(sql.AndPredicates(predicates...))
diff --git a/app/core/api/repository/mysql/ent/scaauthuser_create.go b/app/core/api/repository/mysql/ent/scaauthuser_create.go
index aaca20e..73d661e 100644
--- a/app/core/api/repository/mysql/ent/scaauthuser_create.go
+++ b/app/core/api/repository/mysql/ent/scaauthuser_create.go
@@ -7,8 +7,6 @@ import (
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
@@ -141,15 +139,15 @@ func (sauc *ScaAuthUserCreate) SetNillablePassword(s *string) *ScaAuthUserCreate
}
// SetGender sets the "gender" field.
-func (sauc *ScaAuthUserCreate) SetGender(s string) *ScaAuthUserCreate {
- sauc.mutation.SetGender(s)
+func (sauc *ScaAuthUserCreate) SetGender(i int8) *ScaAuthUserCreate {
+ sauc.mutation.SetGender(i)
return sauc
}
// SetNillableGender sets the "gender" field if the given value is not nil.
-func (sauc *ScaAuthUserCreate) SetNillableGender(s *string) *ScaAuthUserCreate {
- if s != nil {
- sauc.SetGender(*s)
+func (sauc *ScaAuthUserCreate) SetNillableGender(i *int8) *ScaAuthUserCreate {
+ if i != nil {
+ sauc.SetGender(*i)
}
return sauc
}
@@ -244,36 +242,6 @@ func (sauc *ScaAuthUserCreate) SetID(i int64) *ScaAuthUserCreate {
return sauc
}
-// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
-func (sauc *ScaAuthUserCreate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserCreate {
- sauc.mutation.AddScaAuthUserSocialIDs(ids...)
- return sauc
-}
-
-// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
-func (sauc *ScaAuthUserCreate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserCreate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauc.AddScaAuthUserSocialIDs(ids...)
-}
-
-// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
-func (sauc *ScaAuthUserCreate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserCreate {
- sauc.mutation.AddScaAuthUserDeviceIDs(ids...)
- return sauc
-}
-
-// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
-func (sauc *ScaAuthUserCreate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserCreate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauc.AddScaAuthUserDeviceIDs(ids...)
-}
-
// Mutation returns the ScaAuthUserMutation object of the builder.
func (sauc *ScaAuthUserCreate) Mutation() *ScaAuthUserMutation {
return sauc.mutation
@@ -373,11 +341,6 @@ func (sauc *ScaAuthUserCreate) check() error {
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)}
}
}
- if v, ok := sauc.mutation.Gender(); ok {
- if err := scaauthuser.GenderValidator(v); err != nil {
- return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)}
- }
- }
if v, ok := sauc.mutation.Introduce(); ok {
if err := scaauthuser.IntroduceValidator(v); err != nil {
return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)}
@@ -467,7 +430,7 @@ func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec)
_node.Password = value
}
if value, ok := sauc.mutation.Gender(); ok {
- _spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
+ _spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
_node.Gender = value
}
if value, ok := sauc.mutation.Avatar(); ok {
@@ -494,38 +457,6 @@ func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec)
_spec.SetField(scaauthuser.FieldCompany, field.TypeString, value)
_node.Company = &value
}
- if nodes := sauc.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := sauc.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
return _node, _spec
}
diff --git a/app/core/api/repository/mysql/ent/scaauthuser_query.go b/app/core/api/repository/mysql/ent/scaauthuser_query.go
index 10971a3..e55b11f 100644
--- a/app/core/api/repository/mysql/ent/scaauthuser_query.go
+++ b/app/core/api/repository/mysql/ent/scaauthuser_query.go
@@ -4,13 +4,10 @@ package ent
import (
"context"
- "database/sql/driver"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
@@ -21,12 +18,10 @@ import (
// ScaAuthUserQuery is the builder for querying ScaAuthUser entities.
type ScaAuthUserQuery struct {
config
- ctx *QueryContext
- order []scaauthuser.OrderOption
- inters []Interceptor
- predicates []predicate.ScaAuthUser
- withScaAuthUserSocial *ScaAuthUserSocialQuery
- withScaAuthUserDevice *ScaAuthUserDeviceQuery
+ ctx *QueryContext
+ order []scaauthuser.OrderOption
+ inters []Interceptor
+ predicates []predicate.ScaAuthUser
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -63,50 +58,6 @@ func (sauq *ScaAuthUserQuery) Order(o ...scaauthuser.OrderOption) *ScaAuthUserQu
return sauq
}
-// QueryScaAuthUserSocial chains the current query on the "sca_auth_user_social" edge.
-func (sauq *ScaAuthUserQuery) QueryScaAuthUserSocial() *ScaAuthUserSocialQuery {
- query := (&ScaAuthUserSocialClient{config: sauq.config}).Query()
- query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
- if err := sauq.prepareQuery(ctx); err != nil {
- return nil, err
- }
- selector := sauq.sqlQuery(ctx)
- if err := selector.Err(); err != nil {
- return nil, err
- }
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, selector),
- sqlgraph.To(scaauthusersocial.Table, scaauthusersocial.FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserSocialTable, scaauthuser.ScaAuthUserSocialColumn),
- )
- fromU = sqlgraph.SetNeighbors(sauq.driver.Dialect(), step)
- return fromU, nil
- }
- return query
-}
-
-// QueryScaAuthUserDevice chains the current query on the "sca_auth_user_device" edge.
-func (sauq *ScaAuthUserQuery) QueryScaAuthUserDevice() *ScaAuthUserDeviceQuery {
- query := (&ScaAuthUserDeviceClient{config: sauq.config}).Query()
- query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
- if err := sauq.prepareQuery(ctx); err != nil {
- return nil, err
- }
- selector := sauq.sqlQuery(ctx)
- if err := selector.Err(); err != nil {
- return nil, err
- }
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, selector),
- sqlgraph.To(scaauthuserdevice.Table, scaauthuserdevice.FieldID),
- sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserDeviceTable, scaauthuser.ScaAuthUserDeviceColumn),
- )
- fromU = sqlgraph.SetNeighbors(sauq.driver.Dialect(), step)
- return fromU, nil
- }
- return query
-}
-
// First returns the first ScaAuthUser entity from the query.
// Returns a *NotFoundError when no ScaAuthUser was found.
func (sauq *ScaAuthUserQuery) First(ctx context.Context) (*ScaAuthUser, error) {
@@ -294,41 +245,17 @@ func (sauq *ScaAuthUserQuery) Clone() *ScaAuthUserQuery {
return nil
}
return &ScaAuthUserQuery{
- config: sauq.config,
- ctx: sauq.ctx.Clone(),
- order: append([]scaauthuser.OrderOption{}, sauq.order...),
- inters: append([]Interceptor{}, sauq.inters...),
- predicates: append([]predicate.ScaAuthUser{}, sauq.predicates...),
- withScaAuthUserSocial: sauq.withScaAuthUserSocial.Clone(),
- withScaAuthUserDevice: sauq.withScaAuthUserDevice.Clone(),
+ config: sauq.config,
+ ctx: sauq.ctx.Clone(),
+ order: append([]scaauthuser.OrderOption{}, sauq.order...),
+ inters: append([]Interceptor{}, sauq.inters...),
+ predicates: append([]predicate.ScaAuthUser{}, sauq.predicates...),
// clone intermediate query.
sql: sauq.sql.Clone(),
path: sauq.path,
}
}
-// WithScaAuthUserSocial tells the query-builder to eager-load the nodes that are connected to
-// the "sca_auth_user_social" edge. The optional arguments are used to configure the query builder of the edge.
-func (sauq *ScaAuthUserQuery) WithScaAuthUserSocial(opts ...func(*ScaAuthUserSocialQuery)) *ScaAuthUserQuery {
- query := (&ScaAuthUserSocialClient{config: sauq.config}).Query()
- for _, opt := range opts {
- opt(query)
- }
- sauq.withScaAuthUserSocial = query
- return sauq
-}
-
-// WithScaAuthUserDevice tells the query-builder to eager-load the nodes that are connected to
-// the "sca_auth_user_device" edge. The optional arguments are used to configure the query builder of the edge.
-func (sauq *ScaAuthUserQuery) WithScaAuthUserDevice(opts ...func(*ScaAuthUserDeviceQuery)) *ScaAuthUserQuery {
- query := (&ScaAuthUserDeviceClient{config: sauq.config}).Query()
- for _, opt := range opts {
- opt(query)
- }
- sauq.withScaAuthUserDevice = query
- return sauq
-}
-
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
@@ -405,12 +332,8 @@ func (sauq *ScaAuthUserQuery) prepareQuery(ctx context.Context) error {
func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUser, error) {
var (
- nodes = []*ScaAuthUser{}
- _spec = sauq.querySpec()
- loadedTypes = [2]bool{
- sauq.withScaAuthUserSocial != nil,
- sauq.withScaAuthUserDevice != nil,
- }
+ nodes = []*ScaAuthUser{}
+ _spec = sauq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthUser).scanValues(nil, columns)
@@ -418,7 +341,6 @@ func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthUser{config: sauq.config}
nodes = append(nodes, node)
- node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
@@ -430,90 +352,9 @@ func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
if len(nodes) == 0 {
return nodes, nil
}
- if query := sauq.withScaAuthUserSocial; query != nil {
- if err := sauq.loadScaAuthUserSocial(ctx, query, nodes,
- func(n *ScaAuthUser) { n.Edges.ScaAuthUserSocial = []*ScaAuthUserSocial{} },
- func(n *ScaAuthUser, e *ScaAuthUserSocial) {
- n.Edges.ScaAuthUserSocial = append(n.Edges.ScaAuthUserSocial, e)
- }); err != nil {
- return nil, err
- }
- }
- if query := sauq.withScaAuthUserDevice; query != nil {
- if err := sauq.loadScaAuthUserDevice(ctx, query, nodes,
- func(n *ScaAuthUser) { n.Edges.ScaAuthUserDevice = []*ScaAuthUserDevice{} },
- func(n *ScaAuthUser, e *ScaAuthUserDevice) {
- n.Edges.ScaAuthUserDevice = append(n.Edges.ScaAuthUserDevice, e)
- }); err != nil {
- return nil, err
- }
- }
return nodes, nil
}
-func (sauq *ScaAuthUserQuery) loadScaAuthUserSocial(ctx context.Context, query *ScaAuthUserSocialQuery, nodes []*ScaAuthUser, init func(*ScaAuthUser), assign func(*ScaAuthUser, *ScaAuthUserSocial)) error {
- fks := make([]driver.Value, 0, len(nodes))
- nodeids := make(map[int64]*ScaAuthUser)
- for i := range nodes {
- fks = append(fks, nodes[i].ID)
- nodeids[nodes[i].ID] = nodes[i]
- if init != nil {
- init(nodes[i])
- }
- }
- query.withFKs = true
- query.Where(predicate.ScaAuthUserSocial(func(s *sql.Selector) {
- s.Where(sql.InValues(s.C(scaauthuser.ScaAuthUserSocialColumn), fks...))
- }))
- neighbors, err := query.All(ctx)
- if err != nil {
- return err
- }
- for _, n := range neighbors {
- fk := n.sca_auth_user_sca_auth_user_social
- if fk == nil {
- return fmt.Errorf(`foreign-key "sca_auth_user_sca_auth_user_social" is nil for node %v`, n.ID)
- }
- node, ok := nodeids[*fk]
- if !ok {
- return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_user_sca_auth_user_social" returned %v for node %v`, *fk, n.ID)
- }
- assign(node, n)
- }
- return nil
-}
-func (sauq *ScaAuthUserQuery) loadScaAuthUserDevice(ctx context.Context, query *ScaAuthUserDeviceQuery, nodes []*ScaAuthUser, init func(*ScaAuthUser), assign func(*ScaAuthUser, *ScaAuthUserDevice)) error {
- fks := make([]driver.Value, 0, len(nodes))
- nodeids := make(map[int64]*ScaAuthUser)
- for i := range nodes {
- fks = append(fks, nodes[i].ID)
- nodeids[nodes[i].ID] = nodes[i]
- if init != nil {
- init(nodes[i])
- }
- }
- query.withFKs = true
- query.Where(predicate.ScaAuthUserDevice(func(s *sql.Selector) {
- s.Where(sql.InValues(s.C(scaauthuser.ScaAuthUserDeviceColumn), fks...))
- }))
- neighbors, err := query.All(ctx)
- if err != nil {
- return err
- }
- for _, n := range neighbors {
- fk := n.sca_auth_user_sca_auth_user_device
- if fk == nil {
- return fmt.Errorf(`foreign-key "sca_auth_user_sca_auth_user_device" is nil for node %v`, n.ID)
- }
- node, ok := nodeids[*fk]
- if !ok {
- return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_user_sca_auth_user_device" returned %v for node %v`, *fk, n.ID)
- }
- assign(node, n)
- }
- return nil
-}
-
func (sauq *ScaAuthUserQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sauq.querySpec()
_spec.Node.Columns = sauq.ctx.Fields
diff --git a/app/core/api/repository/mysql/ent/scaauthuser_update.go b/app/core/api/repository/mysql/ent/scaauthuser_update.go
index b3f0837..5928ffd 100644
--- a/app/core/api/repository/mysql/ent/scaauthuser_update.go
+++ b/app/core/api/repository/mysql/ent/scaauthuser_update.go
@@ -8,8 +8,6 @@ import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql"
@@ -178,19 +176,26 @@ func (sauu *ScaAuthUserUpdate) ClearPassword() *ScaAuthUserUpdate {
}
// SetGender sets the "gender" field.
-func (sauu *ScaAuthUserUpdate) SetGender(s string) *ScaAuthUserUpdate {
- sauu.mutation.SetGender(s)
+func (sauu *ScaAuthUserUpdate) SetGender(i int8) *ScaAuthUserUpdate {
+ sauu.mutation.ResetGender()
+ sauu.mutation.SetGender(i)
return sauu
}
// SetNillableGender sets the "gender" field if the given value is not nil.
-func (sauu *ScaAuthUserUpdate) SetNillableGender(s *string) *ScaAuthUserUpdate {
- if s != nil {
- sauu.SetGender(*s)
+func (sauu *ScaAuthUserUpdate) SetNillableGender(i *int8) *ScaAuthUserUpdate {
+ if i != nil {
+ sauu.SetGender(*i)
}
return sauu
}
+// AddGender adds i to the "gender" field.
+func (sauu *ScaAuthUserUpdate) AddGender(i int8) *ScaAuthUserUpdate {
+ sauu.mutation.AddGender(i)
+ return sauu
+}
+
// ClearGender clears the value of the "gender" field.
func (sauu *ScaAuthUserUpdate) ClearGender() *ScaAuthUserUpdate {
sauu.mutation.ClearGender()
@@ -324,83 +329,11 @@ func (sauu *ScaAuthUserUpdate) ClearCompany() *ScaAuthUserUpdate {
return sauu
}
-// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
-func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate {
- sauu.mutation.AddScaAuthUserSocialIDs(ids...)
- return sauu
-}
-
-// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
-func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauu.AddScaAuthUserSocialIDs(ids...)
-}
-
-// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
-func (sauu *ScaAuthUserUpdate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate {
- sauu.mutation.AddScaAuthUserDeviceIDs(ids...)
- return sauu
-}
-
-// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
-func (sauu *ScaAuthUserUpdate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauu.AddScaAuthUserDeviceIDs(ids...)
-}
-
// Mutation returns the ScaAuthUserMutation object of the builder.
func (sauu *ScaAuthUserUpdate) Mutation() *ScaAuthUserMutation {
return sauu.mutation
}
-// ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
-func (sauu *ScaAuthUserUpdate) ClearScaAuthUserSocial() *ScaAuthUserUpdate {
- sauu.mutation.ClearScaAuthUserSocial()
- return sauu
-}
-
-// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs.
-func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate {
- sauu.mutation.RemoveScaAuthUserSocialIDs(ids...)
- return sauu
-}
-
-// RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities.
-func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauu.RemoveScaAuthUserSocialIDs(ids...)
-}
-
-// ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
-func (sauu *ScaAuthUserUpdate) ClearScaAuthUserDevice() *ScaAuthUserUpdate {
- sauu.mutation.ClearScaAuthUserDevice()
- return sauu
-}
-
-// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs.
-func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate {
- sauu.mutation.RemoveScaAuthUserDeviceIDs(ids...)
- return sauu
-}
-
-// RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities.
-func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauu.RemoveScaAuthUserDeviceIDs(ids...)
-}
-
// Save executes the query and returns the number of nodes affected by the update operation.
func (sauu *ScaAuthUserUpdate) Save(ctx context.Context) (int, error) {
sauu.defaults()
@@ -474,11 +407,6 @@ func (sauu *ScaAuthUserUpdate) check() error {
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)}
}
}
- if v, ok := sauu.mutation.Gender(); ok {
- if err := scaauthuser.GenderValidator(v); err != nil {
- return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)}
- }
- }
if v, ok := sauu.mutation.Introduce(); ok {
if err := scaauthuser.IntroduceValidator(v); err != nil {
return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)}
@@ -560,10 +488,13 @@ func (sauu *ScaAuthUserUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec.ClearField(scaauthuser.FieldPassword, field.TypeString)
}
if value, ok := sauu.mutation.Gender(); ok {
- _spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
+ _spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
+ }
+ if value, ok := sauu.mutation.AddedGender(); ok {
+ _spec.AddField(scaauthuser.FieldGender, field.TypeInt8, value)
}
if sauu.mutation.GenderCleared() {
- _spec.ClearField(scaauthuser.FieldGender, field.TypeString)
+ _spec.ClearField(scaauthuser.FieldGender, field.TypeInt8)
}
if value, ok := sauu.mutation.Avatar(); ok {
_spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value)
@@ -604,96 +535,6 @@ func (sauu *ScaAuthUserUpdate) sqlSave(ctx context.Context) (n int, err error) {
if sauu.mutation.CompanyCleared() {
_spec.ClearField(scaauthuser.FieldCompany, field.TypeString)
}
- if sauu.mutation.ScaAuthUserSocialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauu.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserSocialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauu.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if sauu.mutation.ScaAuthUserDeviceCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauu.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserDeviceCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauu.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
if n, err = sqlgraph.UpdateNodes(ctx, sauu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthuser.Label}
@@ -862,19 +703,26 @@ func (sauuo *ScaAuthUserUpdateOne) ClearPassword() *ScaAuthUserUpdateOne {
}
// SetGender sets the "gender" field.
-func (sauuo *ScaAuthUserUpdateOne) SetGender(s string) *ScaAuthUserUpdateOne {
- sauuo.mutation.SetGender(s)
+func (sauuo *ScaAuthUserUpdateOne) SetGender(i int8) *ScaAuthUserUpdateOne {
+ sauuo.mutation.ResetGender()
+ sauuo.mutation.SetGender(i)
return sauuo
}
// SetNillableGender sets the "gender" field if the given value is not nil.
-func (sauuo *ScaAuthUserUpdateOne) SetNillableGender(s *string) *ScaAuthUserUpdateOne {
- if s != nil {
- sauuo.SetGender(*s)
+func (sauuo *ScaAuthUserUpdateOne) SetNillableGender(i *int8) *ScaAuthUserUpdateOne {
+ if i != nil {
+ sauuo.SetGender(*i)
}
return sauuo
}
+// AddGender adds i to the "gender" field.
+func (sauuo *ScaAuthUserUpdateOne) AddGender(i int8) *ScaAuthUserUpdateOne {
+ sauuo.mutation.AddGender(i)
+ return sauuo
+}
+
// ClearGender clears the value of the "gender" field.
func (sauuo *ScaAuthUserUpdateOne) ClearGender() *ScaAuthUserUpdateOne {
sauuo.mutation.ClearGender()
@@ -1008,83 +856,11 @@ func (sauuo *ScaAuthUserUpdateOne) ClearCompany() *ScaAuthUserUpdateOne {
return sauuo
}
-// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
-func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne {
- sauuo.mutation.AddScaAuthUserSocialIDs(ids...)
- return sauuo
-}
-
-// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
-func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauuo.AddScaAuthUserSocialIDs(ids...)
-}
-
-// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
-func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne {
- sauuo.mutation.AddScaAuthUserDeviceIDs(ids...)
- return sauuo
-}
-
-// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
-func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauuo.AddScaAuthUserDeviceIDs(ids...)
-}
-
// Mutation returns the ScaAuthUserMutation object of the builder.
func (sauuo *ScaAuthUserUpdateOne) Mutation() *ScaAuthUserMutation {
return sauuo.mutation
}
-// ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
-func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserSocial() *ScaAuthUserUpdateOne {
- sauuo.mutation.ClearScaAuthUserSocial()
- return sauuo
-}
-
-// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs.
-func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne {
- sauuo.mutation.RemoveScaAuthUserSocialIDs(ids...)
- return sauuo
-}
-
-// RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities.
-func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauuo.RemoveScaAuthUserSocialIDs(ids...)
-}
-
-// ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
-func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserDevice() *ScaAuthUserUpdateOne {
- sauuo.mutation.ClearScaAuthUserDevice()
- return sauuo
-}
-
-// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs.
-func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne {
- sauuo.mutation.RemoveScaAuthUserDeviceIDs(ids...)
- return sauuo
-}
-
-// RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities.
-func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne {
- ids := make([]int64, len(s))
- for i := range s {
- ids[i] = s[i].ID
- }
- return sauuo.RemoveScaAuthUserDeviceIDs(ids...)
-}
-
// Where appends a list predicates to the ScaAuthUserUpdate builder.
func (sauuo *ScaAuthUserUpdateOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserUpdateOne {
sauuo.mutation.Where(ps...)
@@ -1171,11 +947,6 @@ func (sauuo *ScaAuthUserUpdateOne) check() error {
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)}
}
}
- if v, ok := sauuo.mutation.Gender(); ok {
- if err := scaauthuser.GenderValidator(v); err != nil {
- return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)}
- }
- }
if v, ok := sauuo.mutation.Introduce(); ok {
if err := scaauthuser.IntroduceValidator(v); err != nil {
return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)}
@@ -1274,10 +1045,13 @@ func (sauuo *ScaAuthUserUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthU
_spec.ClearField(scaauthuser.FieldPassword, field.TypeString)
}
if value, ok := sauuo.mutation.Gender(); ok {
- _spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
+ _spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
+ }
+ if value, ok := sauuo.mutation.AddedGender(); ok {
+ _spec.AddField(scaauthuser.FieldGender, field.TypeInt8, value)
}
if sauuo.mutation.GenderCleared() {
- _spec.ClearField(scaauthuser.FieldGender, field.TypeString)
+ _spec.ClearField(scaauthuser.FieldGender, field.TypeInt8)
}
if value, ok := sauuo.mutation.Avatar(); ok {
_spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value)
@@ -1318,96 +1092,6 @@ func (sauuo *ScaAuthUserUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthU
if sauuo.mutation.CompanyCleared() {
_spec.ClearField(scaauthuser.FieldCompany, field.TypeString)
}
- if sauuo.mutation.ScaAuthUserSocialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauuo.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserSocialCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauuo.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserSocialTable,
- Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if sauuo.mutation.ScaAuthUserDeviceCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauuo.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserDeviceCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauuo.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: scaauthuser.ScaAuthUserDeviceTable,
- Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
_node = &ScaAuthUser{config: sauuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/app/core/api/repository/mysql/ent/scaauthuserdevice.go b/app/core/api/repository/mysql/ent/scaauthuserdevice.go
index 42d4615..112d3ce 100644
--- a/app/core/api/repository/mysql/ent/scaauthuserdevice.go
+++ b/app/core/api/repository/mysql/ent/scaauthuserdevice.go
@@ -4,7 +4,6 @@ package ent
import (
"fmt"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"strings"
"time"
@@ -51,31 +50,7 @@ type ScaAuthUserDevice struct {
EngineName string `json:"engine_name,omitempty"`
// 引擎版本
EngineVersion string `json:"engine_version,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ScaAuthUserDeviceQuery when eager-loading is set.
- Edges ScaAuthUserDeviceEdges `json:"edges"`
- sca_auth_user_sca_auth_user_device *int64
- selectValues sql.SelectValues
-}
-
-// ScaAuthUserDeviceEdges holds the relations/edges for other nodes in the graph.
-type ScaAuthUserDeviceEdges struct {
- // ScaAuthUser holds the value of the sca_auth_user edge.
- ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
-}
-
-// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge
-// was not loaded in eager-loading, or loaded but was not found.
-func (e ScaAuthUserDeviceEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) {
- if e.ScaAuthUser != nil {
- return e.ScaAuthUser, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: scaauthuser.Label}
- }
- return nil, &NotLoadedError{edge: "sca_auth_user"}
+ selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -91,8 +66,6 @@ func (*ScaAuthUserDevice) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullString)
case scaauthuserdevice.FieldCreatedAt, scaauthuserdevice.FieldUpdatedAt:
values[i] = new(sql.NullTime)
- case scaauthuserdevice.ForeignKeys[0]: // sca_auth_user_sca_auth_user_device
- values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
@@ -210,13 +183,6 @@ func (saud *ScaAuthUserDevice) assignValues(columns []string, values []any) erro
} else if value.Valid {
saud.EngineVersion = value.String
}
- case scaauthuserdevice.ForeignKeys[0]:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_device", value)
- } else if value.Valid {
- saud.sca_auth_user_sca_auth_user_device = new(int64)
- *saud.sca_auth_user_sca_auth_user_device = int64(value.Int64)
- }
default:
saud.selectValues.Set(columns[i], values[i])
}
@@ -230,11 +196,6 @@ func (saud *ScaAuthUserDevice) Value(name string) (ent.Value, error) {
return saud.selectValues.Get(name)
}
-// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserDevice entity.
-func (saud *ScaAuthUserDevice) QueryScaAuthUser() *ScaAuthUserQuery {
- return NewScaAuthUserDeviceClient(saud.config).QueryScaAuthUser(saud)
-}
-
// Update returns a builder for updating this ScaAuthUserDevice.
// Note that you need to call ScaAuthUserDevice.Unwrap() before calling this method if this ScaAuthUserDevice
// was returned from a transaction, and the transaction was committed or rolled back.
diff --git a/app/core/api/repository/mysql/ent/scaauthuserdevice/scaauthuserdevice.go b/app/core/api/repository/mysql/ent/scaauthuserdevice/scaauthuserdevice.go
index 0378f19..c3dd69d 100644
--- a/app/core/api/repository/mysql/ent/scaauthuserdevice/scaauthuserdevice.go
+++ b/app/core/api/repository/mysql/ent/scaauthuserdevice/scaauthuserdevice.go
@@ -6,7 +6,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -46,17 +45,8 @@ const (
FieldEngineName = "engine_name"
// FieldEngineVersion holds the string denoting the engine_version field in the database.
FieldEngineVersion = "engine_version"
- // EdgeScaAuthUser holds the string denoting the sca_auth_user edge name in mutations.
- EdgeScaAuthUser = "sca_auth_user"
// Table holds the table name of the scaauthuserdevice in the database.
Table = "sca_auth_user_device"
- // ScaAuthUserTable is the table that holds the sca_auth_user relation/edge.
- ScaAuthUserTable = "sca_auth_user_device"
- // ScaAuthUserInverseTable is the table name for the ScaAuthUser entity.
- // It exists in this package in order to avoid circular dependency with the "scaauthuser" package.
- ScaAuthUserInverseTable = "sca_auth_user"
- // ScaAuthUserColumn is the table column denoting the sca_auth_user relation/edge.
- ScaAuthUserColumn = "sca_auth_user_sca_auth_user_device"
)
// Columns holds all SQL columns for scaauthuserdevice fields.
@@ -80,12 +70,6 @@ var Columns = []string{
FieldEngineVersion,
}
-// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_user_device"
-// table and are not defined as standalone fields in the schema.
-var ForeignKeys = []string{
- "sca_auth_user_sca_auth_user_device",
-}
-
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
@@ -93,11 +77,6 @@ func ValidColumn(column string) bool {
return true
}
}
- for i := range ForeignKeys {
- if column == ForeignKeys[i] {
- return true
- }
- }
return false
}
@@ -223,17 +202,3 @@ func ByEngineName(opts ...sql.OrderTermOption) OrderOption {
func ByEngineVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEngineVersion, opts...).ToFunc()
}
-
-// ByScaAuthUserField orders the results by sca_auth_user field.
-func ByScaAuthUserField(field string, opts ...sql.OrderTermOption) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborTerms(s, newScaAuthUserStep(), sql.OrderByField(field, opts...))
- }
-}
-func newScaAuthUserStep() *sqlgraph.Step {
- return sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.To(ScaAuthUserInverseTable, FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
- )
-}
diff --git a/app/core/api/repository/mysql/ent/scaauthuserdevice/where.go b/app/core/api/repository/mysql/ent/scaauthuserdevice/where.go
index ac0b156..146a56b 100644
--- a/app/core/api/repository/mysql/ent/scaauthuserdevice/where.go
+++ b/app/core/api/repository/mysql/ent/scaauthuserdevice/where.go
@@ -7,7 +7,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
@@ -1000,29 +999,6 @@ func EngineVersionContainsFold(v string) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldEngineVersion, v))
}
-// HasScaAuthUser applies the HasEdge predicate on the "sca_auth_user" edge.
-func HasScaAuthUser() predicate.ScaAuthUserDevice {
- return predicate.ScaAuthUserDevice(func(s *sql.Selector) {
- step := sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
- )
- sqlgraph.HasNeighbors(s, step)
- })
-}
-
-// HasScaAuthUserWith applies the HasEdge predicate on the "sca_auth_user" edge with a given conditions (other predicates).
-func HasScaAuthUserWith(preds ...predicate.ScaAuthUser) predicate.ScaAuthUserDevice {
- return predicate.ScaAuthUserDevice(func(s *sql.Selector) {
- step := newScaAuthUserStep()
- sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })
- })
-}
-
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthUserDevice) predicate.ScaAuthUserDevice {
return predicate.ScaAuthUserDevice(sql.AndPredicates(predicates...))
diff --git a/app/core/api/repository/mysql/ent/scaauthuserdevice_create.go b/app/core/api/repository/mysql/ent/scaauthuserdevice_create.go
index e8e76f6..cf1a071 100644
--- a/app/core/api/repository/mysql/ent/scaauthuserdevice_create.go
+++ b/app/core/api/repository/mysql/ent/scaauthuserdevice_create.go
@@ -6,7 +6,6 @@ import (
"context"
"errors"
"fmt"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"time"
@@ -147,25 +146,6 @@ func (saudc *ScaAuthUserDeviceCreate) SetID(i int64) *ScaAuthUserDeviceCreate {
return saudc
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
-func (saudc *ScaAuthUserDeviceCreate) SetScaAuthUserID(id int64) *ScaAuthUserDeviceCreate {
- saudc.mutation.SetScaAuthUserID(id)
- return saudc
-}
-
-// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
-func (saudc *ScaAuthUserDeviceCreate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceCreate {
- if id != nil {
- saudc = saudc.SetScaAuthUserID(*id)
- }
- return saudc
-}
-
-// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
-func (saudc *ScaAuthUserDeviceCreate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceCreate {
- return saudc.SetScaAuthUserID(s.ID)
-}
-
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
func (saudc *ScaAuthUserDeviceCreate) Mutation() *ScaAuthUserDeviceMutation {
return saudc.mutation
@@ -418,23 +398,6 @@ func (saudc *ScaAuthUserDeviceCreate) createSpec() (*ScaAuthUserDevice, *sqlgrap
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
_node.EngineVersion = value
}
- if nodes := saudc.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthuserdevice.ScaAuthUserTable,
- Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.sca_auth_user_sca_auth_user_device = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
return _node, _spec
}
diff --git a/app/core/api/repository/mysql/ent/scaauthuserdevice_query.go b/app/core/api/repository/mysql/ent/scaauthuserdevice_query.go
index 130bf86..616a144 100644
--- a/app/core/api/repository/mysql/ent/scaauthuserdevice_query.go
+++ b/app/core/api/repository/mysql/ent/scaauthuserdevice_query.go
@@ -7,7 +7,6 @@ import (
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"entgo.io/ent"
@@ -19,12 +18,10 @@ import (
// ScaAuthUserDeviceQuery is the builder for querying ScaAuthUserDevice entities.
type ScaAuthUserDeviceQuery struct {
config
- ctx *QueryContext
- order []scaauthuserdevice.OrderOption
- inters []Interceptor
- predicates []predicate.ScaAuthUserDevice
- withScaAuthUser *ScaAuthUserQuery
- withFKs bool
+ ctx *QueryContext
+ order []scaauthuserdevice.OrderOption
+ inters []Interceptor
+ predicates []predicate.ScaAuthUserDevice
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -61,28 +58,6 @@ func (saudq *ScaAuthUserDeviceQuery) Order(o ...scaauthuserdevice.OrderOption) *
return saudq
}
-// QueryScaAuthUser chains the current query on the "sca_auth_user" edge.
-func (saudq *ScaAuthUserDeviceQuery) QueryScaAuthUser() *ScaAuthUserQuery {
- query := (&ScaAuthUserClient{config: saudq.config}).Query()
- query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
- if err := saudq.prepareQuery(ctx); err != nil {
- return nil, err
- }
- selector := saudq.sqlQuery(ctx)
- if err := selector.Err(); err != nil {
- return nil, err
- }
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthuserdevice.Table, scaauthuserdevice.FieldID, selector),
- sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, scaauthuserdevice.ScaAuthUserTable, scaauthuserdevice.ScaAuthUserColumn),
- )
- fromU = sqlgraph.SetNeighbors(saudq.driver.Dialect(), step)
- return fromU, nil
- }
- return query
-}
-
// First returns the first ScaAuthUserDevice entity from the query.
// Returns a *NotFoundError when no ScaAuthUserDevice was found.
func (saudq *ScaAuthUserDeviceQuery) First(ctx context.Context) (*ScaAuthUserDevice, error) {
@@ -270,29 +245,17 @@ func (saudq *ScaAuthUserDeviceQuery) Clone() *ScaAuthUserDeviceQuery {
return nil
}
return &ScaAuthUserDeviceQuery{
- config: saudq.config,
- ctx: saudq.ctx.Clone(),
- order: append([]scaauthuserdevice.OrderOption{}, saudq.order...),
- inters: append([]Interceptor{}, saudq.inters...),
- predicates: append([]predicate.ScaAuthUserDevice{}, saudq.predicates...),
- withScaAuthUser: saudq.withScaAuthUser.Clone(),
+ config: saudq.config,
+ ctx: saudq.ctx.Clone(),
+ order: append([]scaauthuserdevice.OrderOption{}, saudq.order...),
+ inters: append([]Interceptor{}, saudq.inters...),
+ predicates: append([]predicate.ScaAuthUserDevice{}, saudq.predicates...),
// clone intermediate query.
sql: saudq.sql.Clone(),
path: saudq.path,
}
}
-// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to
-// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge.
-func (saudq *ScaAuthUserDeviceQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserDeviceQuery {
- query := (&ScaAuthUserClient{config: saudq.config}).Query()
- for _, opt := range opts {
- opt(query)
- }
- saudq.withScaAuthUser = query
- return saudq
-}
-
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
@@ -369,26 +332,15 @@ func (saudq *ScaAuthUserDeviceQuery) prepareQuery(ctx context.Context) error {
func (saudq *ScaAuthUserDeviceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserDevice, error) {
var (
- nodes = []*ScaAuthUserDevice{}
- withFKs = saudq.withFKs
- _spec = saudq.querySpec()
- loadedTypes = [1]bool{
- saudq.withScaAuthUser != nil,
- }
+ nodes = []*ScaAuthUserDevice{}
+ _spec = saudq.querySpec()
)
- if saudq.withScaAuthUser != nil {
- withFKs = true
- }
- if withFKs {
- _spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.ForeignKeys...)
- }
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthUserDevice).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthUserDevice{config: saudq.config}
nodes = append(nodes, node)
- node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
@@ -400,48 +352,9 @@ func (saudq *ScaAuthUserDeviceQuery) sqlAll(ctx context.Context, hooks ...queryH
if len(nodes) == 0 {
return nodes, nil
}
- if query := saudq.withScaAuthUser; query != nil {
- if err := saudq.loadScaAuthUser(ctx, query, nodes, nil,
- func(n *ScaAuthUserDevice, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil {
- return nil, err
- }
- }
return nodes, nil
}
-func (saudq *ScaAuthUserDeviceQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserDevice, init func(*ScaAuthUserDevice), assign func(*ScaAuthUserDevice, *ScaAuthUser)) error {
- ids := make([]int64, 0, len(nodes))
- nodeids := make(map[int64][]*ScaAuthUserDevice)
- for i := range nodes {
- if nodes[i].sca_auth_user_sca_auth_user_device == nil {
- continue
- }
- fk := *nodes[i].sca_auth_user_sca_auth_user_device
- if _, ok := nodeids[fk]; !ok {
- ids = append(ids, fk)
- }
- nodeids[fk] = append(nodeids[fk], nodes[i])
- }
- if len(ids) == 0 {
- return nil
- }
- query.Where(scaauthuser.IDIn(ids...))
- neighbors, err := query.All(ctx)
- if err != nil {
- return err
- }
- for _, n := range neighbors {
- nodes, ok := nodeids[n.ID]
- if !ok {
- return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_device" returned %v`, n.ID)
- }
- for i := range nodes {
- assign(nodes[i], n)
- }
- }
- return nil
-}
-
func (saudq *ScaAuthUserDeviceQuery) sqlCount(ctx context.Context) (int, error) {
_spec := saudq.querySpec()
_spec.Node.Columns = saudq.ctx.Fields
diff --git a/app/core/api/repository/mysql/ent/scaauthuserdevice_update.go b/app/core/api/repository/mysql/ent/scaauthuserdevice_update.go
index 4d54a9c..4338a90 100644
--- a/app/core/api/repository/mysql/ent/scaauthuserdevice_update.go
+++ b/app/core/api/repository/mysql/ent/scaauthuserdevice_update.go
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"time"
@@ -244,36 +243,11 @@ func (saudu *ScaAuthUserDeviceUpdate) SetNillableEngineVersion(s *string) *ScaAu
return saudu
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
-func (saudu *ScaAuthUserDeviceUpdate) SetScaAuthUserID(id int64) *ScaAuthUserDeviceUpdate {
- saudu.mutation.SetScaAuthUserID(id)
- return saudu
-}
-
-// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
-func (saudu *ScaAuthUserDeviceUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceUpdate {
- if id != nil {
- saudu = saudu.SetScaAuthUserID(*id)
- }
- return saudu
-}
-
-// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
-func (saudu *ScaAuthUserDeviceUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceUpdate {
- return saudu.SetScaAuthUserID(s.ID)
-}
-
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
func (saudu *ScaAuthUserDeviceUpdate) Mutation() *ScaAuthUserDeviceMutation {
return saudu.mutation
}
-// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
-func (saudu *ScaAuthUserDeviceUpdate) ClearScaAuthUser() *ScaAuthUserDeviceUpdate {
- saudu.mutation.ClearScaAuthUser()
- return saudu
-}
-
// Save executes the query and returns the number of nodes affected by the update operation.
func (saudu *ScaAuthUserDeviceUpdate) Save(ctx context.Context) (int, error) {
saudu.defaults()
@@ -438,35 +412,6 @@ func (saudu *ScaAuthUserDeviceUpdate) sqlSave(ctx context.Context) (n int, err e
if value, ok := saudu.mutation.EngineVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
}
- if saudu.mutation.ScaAuthUserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthuserdevice.ScaAuthUserTable,
- Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := saudu.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthuserdevice.ScaAuthUserTable,
- Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
if n, err = sqlgraph.UpdateNodes(ctx, saudu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthuserdevice.Label}
@@ -702,36 +647,11 @@ func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableEngineVersion(s *string) *S
return sauduo
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
-func (sauduo *ScaAuthUserDeviceUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserDeviceUpdateOne {
- sauduo.mutation.SetScaAuthUserID(id)
- return sauduo
-}
-
-// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
-func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceUpdateOne {
- if id != nil {
- sauduo = sauduo.SetScaAuthUserID(*id)
- }
- return sauduo
-}
-
-// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sauduo *ScaAuthUserDeviceUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceUpdateOne {
- return sauduo.SetScaAuthUserID(s.ID)
-}
-
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
func (sauduo *ScaAuthUserDeviceUpdateOne) Mutation() *ScaAuthUserDeviceMutation {
return sauduo.mutation
}
-// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sauduo *ScaAuthUserDeviceUpdateOne) ClearScaAuthUser() *ScaAuthUserDeviceUpdateOne {
- sauduo.mutation.ClearScaAuthUser()
- return sauduo
-}
-
// Where appends a list predicates to the ScaAuthUserDeviceUpdate builder.
func (sauduo *ScaAuthUserDeviceUpdateOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.Where(ps...)
@@ -926,35 +846,6 @@ func (sauduo *ScaAuthUserDeviceUpdateOne) sqlSave(ctx context.Context) (_node *S
if value, ok := sauduo.mutation.EngineVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
}
- if sauduo.mutation.ScaAuthUserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthuserdevice.ScaAuthUserTable,
- Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sauduo.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthuserdevice.ScaAuthUserTable,
- Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
_node = &ScaAuthUserDevice{config: sauduo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/app/core/api/repository/mysql/ent/scaauthusersocial.go b/app/core/api/repository/mysql/ent/scaauthusersocial.go
index e84fccb..2f2d82a 100644
--- a/app/core/api/repository/mysql/ent/scaauthusersocial.go
+++ b/app/core/api/repository/mysql/ent/scaauthusersocial.go
@@ -4,7 +4,6 @@ package ent
import (
"fmt"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"strings"
"time"
@@ -32,32 +31,8 @@ type ScaAuthUserSocial struct {
// 第三方用户来源
Source string `json:"source,omitempty"`
// 状态 0正常 1 封禁
- Status int `json:"status,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ScaAuthUserSocialQuery when eager-loading is set.
- Edges ScaAuthUserSocialEdges `json:"edges"`
- sca_auth_user_sca_auth_user_social *int64
- selectValues sql.SelectValues
-}
-
-// ScaAuthUserSocialEdges holds the relations/edges for other nodes in the graph.
-type ScaAuthUserSocialEdges struct {
- // ScaAuthUser holds the value of the sca_auth_user edge.
- ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
-}
-
-// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge
-// was not loaded in eager-loading, or loaded but was not found.
-func (e ScaAuthUserSocialEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) {
- if e.ScaAuthUser != nil {
- return e.ScaAuthUser, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: scaauthuser.Label}
- }
- return nil, &NotLoadedError{edge: "sca_auth_user"}
+ Status int `json:"status,omitempty"`
+ selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -71,8 +46,6 @@ func (*ScaAuthUserSocial) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullString)
case scaauthusersocial.FieldCreatedAt, scaauthusersocial.FieldUpdatedAt:
values[i] = new(sql.NullTime)
- case scaauthusersocial.ForeignKeys[0]: // sca_auth_user_sca_auth_user_social
- values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
@@ -136,13 +109,6 @@ func (saus *ScaAuthUserSocial) assignValues(columns []string, values []any) erro
} else if value.Valid {
saus.Status = int(value.Int64)
}
- case scaauthusersocial.ForeignKeys[0]:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_social", value)
- } else if value.Valid {
- saus.sca_auth_user_sca_auth_user_social = new(int64)
- *saus.sca_auth_user_sca_auth_user_social = int64(value.Int64)
- }
default:
saus.selectValues.Set(columns[i], values[i])
}
@@ -156,11 +122,6 @@ func (saus *ScaAuthUserSocial) Value(name string) (ent.Value, error) {
return saus.selectValues.Get(name)
}
-// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserSocial entity.
-func (saus *ScaAuthUserSocial) QueryScaAuthUser() *ScaAuthUserQuery {
- return NewScaAuthUserSocialClient(saus.config).QueryScaAuthUser(saus)
-}
-
// Update returns a builder for updating this ScaAuthUserSocial.
// Note that you need to call ScaAuthUserSocial.Unwrap() before calling this method if this ScaAuthUserSocial
// was returned from a transaction, and the transaction was committed or rolled back.
diff --git a/app/core/api/repository/mysql/ent/scaauthusersocial/scaauthusersocial.go b/app/core/api/repository/mysql/ent/scaauthusersocial/scaauthusersocial.go
index 1a51fdd..bca262d 100644
--- a/app/core/api/repository/mysql/ent/scaauthusersocial/scaauthusersocial.go
+++ b/app/core/api/repository/mysql/ent/scaauthusersocial/scaauthusersocial.go
@@ -6,7 +6,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
const (
@@ -28,17 +27,8 @@ const (
FieldSource = "source"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
- // EdgeScaAuthUser holds the string denoting the sca_auth_user edge name in mutations.
- EdgeScaAuthUser = "sca_auth_user"
// Table holds the table name of the scaauthusersocial in the database.
Table = "sca_auth_user_social"
- // ScaAuthUserTable is the table that holds the sca_auth_user relation/edge.
- ScaAuthUserTable = "sca_auth_user_social"
- // ScaAuthUserInverseTable is the table name for the ScaAuthUser entity.
- // It exists in this package in order to avoid circular dependency with the "scaauthuser" package.
- ScaAuthUserInverseTable = "sca_auth_user"
- // ScaAuthUserColumn is the table column denoting the sca_auth_user relation/edge.
- ScaAuthUserColumn = "sca_auth_user_sca_auth_user_social"
)
// Columns holds all SQL columns for scaauthusersocial fields.
@@ -53,12 +43,6 @@ var Columns = []string{
FieldStatus,
}
-// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_user_social"
-// table and are not defined as standalone fields in the schema.
-var ForeignKeys = []string{
- "sca_auth_user_sca_auth_user_social",
-}
-
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
@@ -66,11 +50,6 @@ func ValidColumn(column string) bool {
return true
}
}
- for i := range ForeignKeys {
- if column == ForeignKeys[i] {
- return true
- }
- }
return false
}
@@ -137,17 +116,3 @@ func BySource(opts ...sql.OrderTermOption) OrderOption {
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
-
-// ByScaAuthUserField orders the results by sca_auth_user field.
-func ByScaAuthUserField(field string, opts ...sql.OrderTermOption) OrderOption {
- return func(s *sql.Selector) {
- sqlgraph.OrderByNeighborTerms(s, newScaAuthUserStep(), sql.OrderByField(field, opts...))
- }
-}
-func newScaAuthUserStep() *sqlgraph.Step {
- return sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.To(ScaAuthUserInverseTable, FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
- )
-}
diff --git a/app/core/api/repository/mysql/ent/scaauthusersocial/where.go b/app/core/api/repository/mysql/ent/scaauthusersocial/where.go
index 53313a6..6b63463 100644
--- a/app/core/api/repository/mysql/ent/scaauthusersocial/where.go
+++ b/app/core/api/repository/mysql/ent/scaauthusersocial/where.go
@@ -7,7 +7,6 @@ import (
"time"
"entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
@@ -455,29 +454,6 @@ func StatusLTE(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldStatus, v))
}
-// HasScaAuthUser applies the HasEdge predicate on the "sca_auth_user" edge.
-func HasScaAuthUser() predicate.ScaAuthUserSocial {
- return predicate.ScaAuthUserSocial(func(s *sql.Selector) {
- step := sqlgraph.NewStep(
- sqlgraph.From(Table, FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
- )
- sqlgraph.HasNeighbors(s, step)
- })
-}
-
-// HasScaAuthUserWith applies the HasEdge predicate on the "sca_auth_user" edge with a given conditions (other predicates).
-func HasScaAuthUserWith(preds ...predicate.ScaAuthUser) predicate.ScaAuthUserSocial {
- return predicate.ScaAuthUserSocial(func(s *sql.Selector) {
- step := newScaAuthUserStep()
- sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
- for _, p := range preds {
- p(s)
- }
- })
- })
-}
-
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.AndPredicates(predicates...))
diff --git a/app/core/api/repository/mysql/ent/scaauthusersocial_create.go b/app/core/api/repository/mysql/ent/scaauthusersocial_create.go
index f5073ec..7d78561 100644
--- a/app/core/api/repository/mysql/ent/scaauthusersocial_create.go
+++ b/app/core/api/repository/mysql/ent/scaauthusersocial_create.go
@@ -6,7 +6,6 @@ import (
"context"
"errors"
"fmt"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"time"
@@ -101,25 +100,6 @@ func (sausc *ScaAuthUserSocialCreate) SetID(i int64) *ScaAuthUserSocialCreate {
return sausc
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
-func (sausc *ScaAuthUserSocialCreate) SetScaAuthUserID(id int64) *ScaAuthUserSocialCreate {
- sausc.mutation.SetScaAuthUserID(id)
- return sausc
-}
-
-// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
-func (sausc *ScaAuthUserSocialCreate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialCreate {
- if id != nil {
- sausc = sausc.SetScaAuthUserID(*id)
- }
- return sausc
-}
-
-// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sausc *ScaAuthUserSocialCreate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialCreate {
- return sausc.SetScaAuthUserID(s.ID)
-}
-
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
func (sausc *ScaAuthUserSocialCreate) Mutation() *ScaAuthUserSocialMutation {
return sausc.mutation
@@ -273,23 +253,6 @@ func (sausc *ScaAuthUserSocialCreate) createSpec() (*ScaAuthUserSocial, *sqlgrap
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
_node.Status = value
}
- if nodes := sausc.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthusersocial.ScaAuthUserTable,
- Columns: []string{scaauthusersocial.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.sca_auth_user_sca_auth_user_social = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
return _node, _spec
}
diff --git a/app/core/api/repository/mysql/ent/scaauthusersocial_query.go b/app/core/api/repository/mysql/ent/scaauthusersocial_query.go
index 0fa0d65..1756178 100644
--- a/app/core/api/repository/mysql/ent/scaauthusersocial_query.go
+++ b/app/core/api/repository/mysql/ent/scaauthusersocial_query.go
@@ -7,7 +7,6 @@ import (
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"entgo.io/ent"
@@ -19,12 +18,10 @@ import (
// ScaAuthUserSocialQuery is the builder for querying ScaAuthUserSocial entities.
type ScaAuthUserSocialQuery struct {
config
- ctx *QueryContext
- order []scaauthusersocial.OrderOption
- inters []Interceptor
- predicates []predicate.ScaAuthUserSocial
- withScaAuthUser *ScaAuthUserQuery
- withFKs bool
+ ctx *QueryContext
+ order []scaauthusersocial.OrderOption
+ inters []Interceptor
+ predicates []predicate.ScaAuthUserSocial
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -61,28 +58,6 @@ func (sausq *ScaAuthUserSocialQuery) Order(o ...scaauthusersocial.OrderOption) *
return sausq
}
-// QueryScaAuthUser chains the current query on the "sca_auth_user" edge.
-func (sausq *ScaAuthUserSocialQuery) QueryScaAuthUser() *ScaAuthUserQuery {
- query := (&ScaAuthUserClient{config: sausq.config}).Query()
- query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
- if err := sausq.prepareQuery(ctx); err != nil {
- return nil, err
- }
- selector := sausq.sqlQuery(ctx)
- if err := selector.Err(); err != nil {
- return nil, err
- }
- step := sqlgraph.NewStep(
- sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, selector),
- sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
- sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn),
- )
- fromU = sqlgraph.SetNeighbors(sausq.driver.Dialect(), step)
- return fromU, nil
- }
- return query
-}
-
// First returns the first ScaAuthUserSocial entity from the query.
// Returns a *NotFoundError when no ScaAuthUserSocial was found.
func (sausq *ScaAuthUserSocialQuery) First(ctx context.Context) (*ScaAuthUserSocial, error) {
@@ -270,29 +245,17 @@ func (sausq *ScaAuthUserSocialQuery) Clone() *ScaAuthUserSocialQuery {
return nil
}
return &ScaAuthUserSocialQuery{
- config: sausq.config,
- ctx: sausq.ctx.Clone(),
- order: append([]scaauthusersocial.OrderOption{}, sausq.order...),
- inters: append([]Interceptor{}, sausq.inters...),
- predicates: append([]predicate.ScaAuthUserSocial{}, sausq.predicates...),
- withScaAuthUser: sausq.withScaAuthUser.Clone(),
+ config: sausq.config,
+ ctx: sausq.ctx.Clone(),
+ order: append([]scaauthusersocial.OrderOption{}, sausq.order...),
+ inters: append([]Interceptor{}, sausq.inters...),
+ predicates: append([]predicate.ScaAuthUserSocial{}, sausq.predicates...),
// clone intermediate query.
sql: sausq.sql.Clone(),
path: sausq.path,
}
}
-// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to
-// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge.
-func (sausq *ScaAuthUserSocialQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserSocialQuery {
- query := (&ScaAuthUserClient{config: sausq.config}).Query()
- for _, opt := range opts {
- opt(query)
- }
- sausq.withScaAuthUser = query
- return sausq
-}
-
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
@@ -369,26 +332,15 @@ func (sausq *ScaAuthUserSocialQuery) prepareQuery(ctx context.Context) error {
func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserSocial, error) {
var (
- nodes = []*ScaAuthUserSocial{}
- withFKs = sausq.withFKs
- _spec = sausq.querySpec()
- loadedTypes = [1]bool{
- sausq.withScaAuthUser != nil,
- }
+ nodes = []*ScaAuthUserSocial{}
+ _spec = sausq.querySpec()
)
- if sausq.withScaAuthUser != nil {
- withFKs = true
- }
- if withFKs {
- _spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.ForeignKeys...)
- }
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthUserSocial).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthUserSocial{config: sausq.config}
nodes = append(nodes, node)
- node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
@@ -400,48 +352,9 @@ func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryH
if len(nodes) == 0 {
return nodes, nil
}
- if query := sausq.withScaAuthUser; query != nil {
- if err := sausq.loadScaAuthUser(ctx, query, nodes, nil,
- func(n *ScaAuthUserSocial, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil {
- return nil, err
- }
- }
return nodes, nil
}
-func (sausq *ScaAuthUserSocialQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserSocial, init func(*ScaAuthUserSocial), assign func(*ScaAuthUserSocial, *ScaAuthUser)) error {
- ids := make([]int64, 0, len(nodes))
- nodeids := make(map[int64][]*ScaAuthUserSocial)
- for i := range nodes {
- if nodes[i].sca_auth_user_sca_auth_user_social == nil {
- continue
- }
- fk := *nodes[i].sca_auth_user_sca_auth_user_social
- if _, ok := nodeids[fk]; !ok {
- ids = append(ids, fk)
- }
- nodeids[fk] = append(nodeids[fk], nodes[i])
- }
- if len(ids) == 0 {
- return nil
- }
- query.Where(scaauthuser.IDIn(ids...))
- neighbors, err := query.All(ctx)
- if err != nil {
- return err
- }
- for _, n := range neighbors {
- nodes, ok := nodeids[n.ID]
- if !ok {
- return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_social" returned %v`, n.ID)
- }
- for i := range nodes {
- assign(nodes[i], n)
- }
- }
- return nil
-}
-
func (sausq *ScaAuthUserSocialQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sausq.querySpec()
_spec.Node.Columns = sausq.ctx.Fields
diff --git a/app/core/api/repository/mysql/ent/scaauthusersocial_update.go b/app/core/api/repository/mysql/ent/scaauthusersocial_update.go
index e59c478..88ec8aa 100644
--- a/app/core/api/repository/mysql/ent/scaauthusersocial_update.go
+++ b/app/core/api/repository/mysql/ent/scaauthusersocial_update.go
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
- "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"time"
@@ -125,36 +124,11 @@ func (sausu *ScaAuthUserSocialUpdate) AddStatus(i int) *ScaAuthUserSocialUpdate
return sausu
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
-func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdate {
- sausu.mutation.SetScaAuthUserID(id)
- return sausu
-}
-
-// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
-func (sausu *ScaAuthUserSocialUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdate {
- if id != nil {
- sausu = sausu.SetScaAuthUserID(*id)
- }
- return sausu
-}
-
-// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdate {
- return sausu.SetScaAuthUserID(s.ID)
-}
-
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
func (sausu *ScaAuthUserSocialUpdate) Mutation() *ScaAuthUserSocialMutation {
return sausu.mutation
}
-// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sausu *ScaAuthUserSocialUpdate) ClearScaAuthUser() *ScaAuthUserSocialUpdate {
- sausu.mutation.ClearScaAuthUser()
- return sausu
-}
-
// Save executes the query and returns the number of nodes affected by the update operation.
func (sausu *ScaAuthUserSocialUpdate) Save(ctx context.Context) (int, error) {
sausu.defaults()
@@ -255,35 +229,6 @@ func (sausu *ScaAuthUserSocialUpdate) sqlSave(ctx context.Context) (n int, err e
if value, ok := sausu.mutation.AddedStatus(); ok {
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
- if sausu.mutation.ScaAuthUserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthusersocial.ScaAuthUserTable,
- Columns: []string{scaauthusersocial.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sausu.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthusersocial.ScaAuthUserTable,
- Columns: []string{scaauthusersocial.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
if n, err = sqlgraph.UpdateNodes(ctx, sausu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthusersocial.Label}
@@ -400,36 +345,11 @@ func (sausuo *ScaAuthUserSocialUpdateOne) AddStatus(i int) *ScaAuthUserSocialUpd
return sausuo
}
-// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
-func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdateOne {
- sausuo.mutation.SetScaAuthUserID(id)
- return sausuo
-}
-
-// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
-func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdateOne {
- if id != nil {
- sausuo = sausuo.SetScaAuthUserID(*id)
- }
- return sausuo
-}
-
-// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdateOne {
- return sausuo.SetScaAuthUserID(s.ID)
-}
-
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
func (sausuo *ScaAuthUserSocialUpdateOne) Mutation() *ScaAuthUserSocialMutation {
return sausuo.mutation
}
-// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
-func (sausuo *ScaAuthUserSocialUpdateOne) ClearScaAuthUser() *ScaAuthUserSocialUpdateOne {
- sausuo.mutation.ClearScaAuthUser()
- return sausuo
-}
-
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
func (sausuo *ScaAuthUserSocialUpdateOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.Where(ps...)
@@ -560,35 +480,6 @@ func (sausuo *ScaAuthUserSocialUpdateOne) sqlSave(ctx context.Context) (_node *S
if value, ok := sausuo.mutation.AddedStatus(); ok {
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
- if sausuo.mutation.ScaAuthUserCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthusersocial.ScaAuthUserTable,
- Columns: []string{scaauthusersocial.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := sausuo.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: scaauthusersocial.ScaAuthUserTable,
- Columns: []string{scaauthusersocial.ScaAuthUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
_node = &ScaAuthUserSocial{config: sausuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
diff --git a/app/core/api/repository/mysql/model/sca_auth_permission_rule.go b/app/core/api/repository/mysql/model/sca_auth_permission_rule.go
index 9d10638..721fa48 100644
--- a/app/core/api/repository/mysql/model/sca_auth_permission_rule.go
+++ b/app/core/api/repository/mysql/model/sca_auth_permission_rule.go
@@ -5,7 +5,6 @@ import (
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
@@ -17,48 +16,42 @@ type ScaAuthPermissionRule struct {
// Fields of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Fields() []ent.Field {
return []ent.Field{
- field.Int64("id").
+ field.Int("id").
SchemaType(map[string]string{
- dialect.MySQL: "bigint(20) unsigned",
+ dialect.MySQL: "int(11)",
}).
Unique(),
field.String("ptype").
MaxLen(100).
- Nillable(),
+ Optional(),
field.String("v0").
MaxLen(100).
- Nillable(),
+ Optional(),
field.String("v1").
MaxLen(100).
- Nillable(),
+ Optional(),
field.String("v2").
MaxLen(100).
Optional().
- Nillable(),
+ Optional(),
field.String("v3").
MaxLen(100).
- Optional().
- Nillable(),
+ Optional(),
field.String("v4").
MaxLen(100).
- Optional().
- Nillable(),
+ Optional(),
field.String("v5").
MaxLen(100).
Optional().
- Nillable().Annotations(
- entsql.WithComments(true),
- ),
+ Annotations(
+ entsql.WithComments(true),
+ ),
}
}
// Edges of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Edges() []ent.Edge {
- return []ent.Edge{
- edge.From("sca_auth_role", ScaAuthRole.Type).
- Ref("sca_auth_permission_rule").
- Unique(),
- }
+ return nil
}
// Annotations of the ScaAuthPermissionRule.
diff --git a/app/core/api/repository/mysql/model/sca_auth_role.go b/app/core/api/repository/mysql/model/sca_auth_role.go
index ece0f40..d22dd89 100644
--- a/app/core/api/repository/mysql/model/sca_auth_role.go
+++ b/app/core/api/repository/mysql/model/sca_auth_role.go
@@ -5,7 +5,6 @@ import (
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model/mixin"
@@ -45,9 +44,7 @@ func (ScaAuthRole) Fields() []ent.Field {
// Edges of the ScaAuthRole.
func (ScaAuthRole) Edges() []ent.Edge {
- return []ent.Edge{
- edge.To("sca_auth_permission_rule", ScaAuthPermissionRule.Type),
- }
+ return nil
}
// Indexes of the ScaAuthRole.
diff --git a/app/core/api/repository/mysql/model/sca_auth_user.go b/app/core/api/repository/mysql/model/sca_auth_user.go
index 649b42a..984efcf 100644
--- a/app/core/api/repository/mysql/model/sca_auth_user.go
+++ b/app/core/api/repository/mysql/model/sca_auth_user.go
@@ -5,7 +5,6 @@ import (
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
@@ -57,8 +56,7 @@ func (ScaAuthUser) Fields() []ent.Field {
Optional().
Sensitive().
Comment("密码"),
- field.String("gender").
- MaxLen(32).
+ field.Int8("gender").
Optional().
Comment("性别"),
field.String("avatar").
@@ -95,10 +93,7 @@ func (ScaAuthUser) Fields() []ent.Field {
// Edges of the ScaAuthUser.
func (ScaAuthUser) Edges() []ent.Edge {
- return []ent.Edge{
- edge.To("sca_auth_user_social", ScaAuthUserSocial.Type),
- edge.To("sca_auth_user_device", ScaAuthUserDevice.Type),
- }
+ return nil
}
// Indexes of the ScaAuthUser.
diff --git a/app/core/api/repository/mysql/model/sca_auth_user_device.go b/app/core/api/repository/mysql/model/sca_auth_user_device.go
index 5287a5a..43e9222 100644
--- a/app/core/api/repository/mysql/model/sca_auth_user_device.go
+++ b/app/core/api/repository/mysql/model/sca_auth_user_device.go
@@ -5,7 +5,6 @@ import (
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
@@ -76,11 +75,7 @@ func (ScaAuthUserDevice) Fields() []ent.Field {
// Edges of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Edges() []ent.Edge {
- return []ent.Edge{
- edge.From("sca_auth_user", ScaAuthUser.Type).
- Ref("sca_auth_user_device").
- Unique(),
- }
+ return nil
}
// Indexes of the ScaAuthUserDevice.
diff --git a/app/core/api/repository/mysql/model/sca_auth_user_social.go b/app/core/api/repository/mysql/model/sca_auth_user_social.go
index 5e1ba19..37b3dcb 100644
--- a/app/core/api/repository/mysql/model/sca_auth_user_social.go
+++ b/app/core/api/repository/mysql/model/sca_auth_user_social.go
@@ -5,7 +5,6 @@ import (
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
@@ -51,11 +50,7 @@ func (ScaAuthUserSocial) Fields() []ent.Field {
// Edges of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Edges() []ent.Edge {
- return []ent.Edge{
- edge.From("sca_auth_user", ScaAuthUser.Type).
- Ref("sca_auth_user_social").
- Unique(),
- }
+ return nil
}
// Indexes of the ScaAuthUserSocial.
diff --git a/app/core/api/repository/redis_session/init.go b/app/core/api/repository/redis_session/init.go
index 992d932..ba973ad 100644
--- a/app/core/api/repository/redis_session/init.go
+++ b/app/core/api/repository/redis_session/init.go
@@ -11,7 +11,7 @@ import (
"github.com/zeromicro/go-zero/core/logc"
"schisandra-album-cloud-microservices/app/core/api/common/constant"
- "schisandra-album-cloud-microservices/app/core/api/repository/redis_session/types"
+ "schisandra-album-cloud-microservices/app/core/api/internal/types"
)
func NewRedisSession(addr string, password string) *redisstore.RedisStore {
diff --git a/app/core/api/repository/redis_session/types/session.go b/app/core/api/repository/redis_session/types/session.go
deleted file mode 100644
index 6aa638c..0000000
--- a/app/core/api/repository/redis_session/types/session.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package types
-
-// SessionData 返回数据
-type SessionData struct {
- RefreshToken string `json:"refresh_token"`
- UID string `json:"uid"`
-}
diff --git a/app/core/api/repository/redisx/types/redis_token.go b/app/core/api/repository/redisx/types/redis_token.go
deleted file mode 100644
index 931deac..0000000
--- a/app/core/api/repository/redisx/types/redis_token.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package types
-
-type RedisToken struct {
- AccessToken string `json:"access_token"`
- UID string `json:"uid"`
-}
diff --git a/app/core/api/resources/language/active.en.toml b/app/core/api/resources/language/active.en.toml
index 0550cf7..bb158a3 100644
--- a/app/core/api/resources/language/active.en.toml
+++ b/app/core/api/resources/language/active.en.toml
@@ -4,4 +4,12 @@ verificationFailure = "verification failure!"
invalidAccount = "invalid account!"
notFoundAccount = "account not found!"
invalidPassword = "invalid password!"
-loginFailed = "login failed!"
\ No newline at end of file
+loginFailed = "login failed!"
+phoneFormatError = "phone number format error!"
+captchaExpired = "captcha expired!"
+captchaError = "captcha error!"
+userNotRegistered = "user not registered!"
+registerError = "register error!"
+passwordNotMatch = "password not match!"
+passwordFormatError = "password format error!"
+resetPasswordError = "reset password error!"
\ No newline at end of file
diff --git a/app/core/api/resources/language/active.zh.toml b/app/core/api/resources/language/active.zh.toml
index 778d62a..b18eb69 100644
--- a/app/core/api/resources/language/active.zh.toml
+++ b/app/core/api/resources/language/active.zh.toml
@@ -5,3 +5,11 @@ invalidAccount = "无效的账号!"
notFoundAccount = "未找到账号!"
invalidPassword = "密码错误!"
loginFailed = "登录失败!"
+phoneFormatError = "手机号码格式错误!"
+captchaExpired = "验证码已过期!"
+captchaError = "验证码错误!"
+userNotRegistered = "用户未注册!"
+registerError = "注册失败!"
+passwordNotMatch = "两次输入的密码不一致!"
+passwordFormatError = "密码格式错误!"
+resetPasswordError = "重置密码失败!"
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 8a9e617..4cddb00 100644
--- a/go.mod
+++ b/go.mod
@@ -4,10 +4,21 @@ go 1.23.3
require (
entgo.io/ent v0.14.1
+ github.com/casbin/casbin/v2 v2.100.0
+ github.com/ccpwcn/kgo v1.2.3
github.com/chenmingyong0423/go-mongox/v2 v2.0.0-beta1
github.com/go-sql-driver/mysql v1.8.1
+ github.com/golang-jwt/jwt/v5 v5.2.1
+ github.com/gorilla/sessions v1.2.0
+ github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20240510055607-89e20ab7b6c6
+ github.com/mssola/useragent v1.0.0
github.com/nicksnyder/go-i18n/v2 v2.4.1
github.com/pelletier/go-toml/v2 v2.2.2
+ github.com/pkg/errors v0.9.1
+ github.com/rbcervilla/redisstore/v9 v9.0.0
+ github.com/redis/go-redis/v9 v9.7.0
+ github.com/wenlng/go-captcha/v2 v2.0.1
+ github.com/yitter/idgenerator-go v1.3.1
github.com/zeromicro/go-zero v1.7.3
go.mongodb.org/mongo-driver/v2 v2.0.0-beta2
golang.org/x/crypto v0.28.0
@@ -21,13 +32,13 @@ require (
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
- github.com/ccpwcn/kgo v1.2.3 // indirect
+ github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
+ github.com/casbin/govaluate v1.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
- github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
@@ -40,28 +51,20 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
- github.com/gorilla/sessions v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
- github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20240510055607-89e20ab7b6c6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
- github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
- github.com/mssola/useragent v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
- github.com/rbcervilla/redisstore/v9 v9.0.0 // indirect
- github.com/redis/go-redis/v9 v9.7.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
- github.com/wenlng/go-captcha-assets v1.0.1 // indirect
- github.com/wenlng/go-captcha/v2 v2.0.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
diff --git a/go.sum b/go.sum
index 981e86e..1867186 100644
--- a/go.sum
+++ b/go.sum
@@ -10,18 +10,20 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
-github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
-github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
-github.com/alicebob/miniredis/v2 v2.33.0 h1:uvTF0EDeu9RLnUEG27Db5I68ESoIxTiXbNUiji6lZrA=
-github.com/alicebob/miniredis/v2 v2.33.0/go.mod h1:MhP4a3EU7aENRi9aO+tHfTBZicLqQevyi/DJpoj6mi0=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
+github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
+github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
+github.com/casbin/casbin/v2 v2.100.0 h1:aeugSNjjHfCrgA22nHkVvw2xsscboHv5r0a13ljQKGQ=
+github.com/casbin/casbin/v2 v2.100.0/go.mod h1:LO7YPez4dX3LgoTCqSQAleQDo0S0BeZBDxYnPUl95Ng=
+github.com/casbin/govaluate v1.2.0 h1:wXCXFmqyY+1RwiKfYo3jMKyrtZmOL3kHwaqDyCPOYak=
+github.com/casbin/govaluate v1.2.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
github.com/ccpwcn/kgo v1.2.3 h1:lcCO26EH/FcAhjuVgEkkJ2YcEOQd5TiFYAak9qwYknI=
github.com/ccpwcn/kgo v1.2.3/go.mod h1:y6G244zGfW95c6aCcw00TdZR6JUfBCmQ4acJcFdaktA=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
@@ -39,8 +41,6 @@ github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
-github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
-github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@@ -66,6 +66,9 @@ github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17w
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
+github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
+github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
+github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
@@ -111,8 +114,6 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
-github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
-github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mssola/useragent v1.0.0 h1:WRlDpXyxHDNfvZaPEut5Biveq86Ze4o4EMffyMxmH5o=
@@ -127,6 +128,8 @@ github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7s
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
@@ -167,8 +170,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
-github.com/wenlng/go-captcha-assets v1.0.1 h1:AdjRFMKmadPRWRTv0XEYfjDvcaayZ2yExITDvlK/7bk=
-github.com/wenlng/go-captcha-assets v1.0.1/go.mod h1:yQqc7rRbxgLCg+tWtVp+7Y317D1wIZDan/yIwt8wSac=
github.com/wenlng/go-captcha/v2 v2.0.1 h1:N6XSHymJ7e9Z/LyWWTWLMAkAXtW27ZROZpvNrqPhSnA=
github.com/wenlng/go-captcha/v2 v2.0.1/go.mod h1:5hac1em3uXoyC5ipZ0xFv9umNM/waQvYAQdr0cx/h34=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
@@ -177,11 +178,11 @@ github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
+github.com/yitter/idgenerator-go v1.3.1 h1:GjVi2BupiDb1IXaXqrkOJE4p6qKdj3NaM3GdAjWok14=
+github.com/yitter/idgenerator-go v1.3.1/go.mod h1:VVjbqFjGUsIkaXVkXEdmx1LiXUL3K1NvyxWPJBPbBpE=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
-github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
-github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zeromicro/go-zero v1.7.3 h1:yDUQF2DXDhUHc77/NZF6mzsoRPMBfldjPmG2O/ZSzss=
@@ -220,26 +221,21 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
-golang.org/x/image v0.16.0/go.mod h1:ugSZItdV4nOxyqp56HmXwH0Ry0nBCpjnZdpDaIHdoPs=
golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g=
golang.org/x/image v0.22.0/go.mod h1:9hPFhljd4zZ1GNSIZJ49sqbp45GKK9t6w+iXvGqZUz4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
-golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
-golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -248,29 +244,23 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
-golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
-golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
-golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
-golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=