🎨 remove ent orm & add xorm

This commit is contained in:
landaiqing
2024-11-20 18:04:54 +08:00
parent 3328647b37
commit 9b5e454eca
126 changed files with 1841 additions and 41963 deletions

View File

@@ -6,7 +6,9 @@ Web:
Middlewares:
Log: true
Mysql:
DataSource: root:LDQ20020618xxx@tcp(1.95.0.111:3306)/schisandra-cloud-album?charset=utf8mb4&parseTime=True&loc=Local
DataSource: root:1611@tcp(127.0.0.1:3306)/schisandra-cloud-album?charset=utf8mb4&parseTime=True&loc=Local
MaxOpenConn: 10
MaxIdleConn: 5
Auth:
AccessSecret: uOvKLmVfztaXGpNYd4Z0I1SiT7MweJhl
Signature:

View File

@@ -11,7 +11,9 @@ type Config struct {
AccessSecret string
}
Mysql struct {
DataSource string
DataSource string
MaxOpenConn int
MaxIdleConn int
}
Redis struct {
Host string

View File

@@ -21,7 +21,7 @@ func SubmitReplyReplyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := comment.NewSubmitReplyReplyLogic(r.Context(), svcCtx)
resp, err := l.SubmitReplyReply(&req)
resp, err := l.SubmitReplyReply(r, &req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(

View File

@@ -3,11 +3,10 @@ package comment
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"github.com/zeromicro/go-zero/core/logx"
"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 GetCommentListLogic struct {
@@ -25,7 +24,12 @@ func NewGetCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
}
func (l *GetCommentListLogic) GetCommentList(req *types.CommentListRequest) (resp *types.Response, err error) {
// todo: add your logic here and delete this line
// 获取用户ID
// uid, ok := l.ctx.Value("user_id").(string)
// if !ok {
// return nil, errors.New("user_id not found in context")
// }
return response.Success(), nil
// 查询评论列表
return
}

View File

@@ -14,6 +14,7 @@ import (
"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/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -57,11 +58,14 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
browser, _ := ua.Browser()
operatingSystem := ua.OS()
isAuthor := 0
session, wrong := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
if wrong == nil {
return nil, wrong
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
if err == nil {
return nil, err
}
uid, ok := session.Values["uid"].(string)
if !ok {
return nil, errors.New("uid not found in session")
}
uid := session.Values["uid"].(string)
if uid == req.Author {
isAuthor = 1
}
@@ -70,39 +74,36 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
commentContent := l.svcCtx.Sensitive.Replace(xssFilterContent, '*')
comment, err := l.svcCtx.MySQLClient.ScaCommentReply.Create().
SetContent(commentContent).
SetUserID(uid).
SetTopicID(req.TopicId).
SetCommentType(constant.CommentTopicType).
SetCommentType(constant.COMMENT).
SetAuthor(isAuthor).
SetCommentIP(ip).
SetLocation(location).
SetBrowser(browser).
SetOperatingSystem(operatingSystem).
SetAgent(userAgent).Save(l.ctx)
comment := model.ScaCommentReply{
Content: commentContent,
UserId: uid,
TopicId: req.TopicId,
TopicType: constant.CommentTopicType,
CommentType: constant.COMMENT,
Author: isAuthor,
CommentIp: ip,
Location: location,
Browser: browser,
OperatingSystem: operatingSystem,
Agent: userAgent,
}
affected, err := l.svcCtx.DB.InsertOne(&comment)
if err != nil {
return nil, err
}
if affected == 0 {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
if len(req.Images) > 0 {
imagesDataCh := make(chan [][]byte)
go func() {
imagesData, err := utils.ProcessImages(req.Images)
if err != nil {
imagesDataCh <- nil
return
}
imagesDataCh <- imagesData
}()
imagesData := <-imagesDataCh
if imagesData == nil {
return nil, errors.New("process images failed")
imagesData, err := utils.ProcessImages(req.Images)
if err != nil {
return nil, err
}
commentImages := types.CommentImages{
UserId: uid,
TopicId: req.TopicId,
CommentId: comment.ID,
CommentId: comment.Id,
Images: imagesData,
CreatedAt: comment.CreatedAt.String(),
}
@@ -111,7 +112,7 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
}
}
commentResponse := types.CommentResponse{
Id: comment.ID,
Id: comment.Id,
Content: commentContent,
UserId: uid,
TopicId: req.TopicId,

View File

@@ -2,7 +2,9 @@ package comment
import (
"context"
"errors"
"net/http"
"time"
"github.com/mssola/useragent"
@@ -12,6 +14,7 @@ import (
"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/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -53,20 +56,96 @@ func (l *SubmitReplyCommentLogic) SubmitReplyComment(r *http.Request, req *types
browser, _ := ua.Browser()
operatingSystem := ua.OS()
isAuthor := 0
session, wrong := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
if wrong == nil {
return nil, wrong
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
if err != nil {
return nil, err
}
uid := session.Values["uid"].(string)
uid, ok := session.Values["uid"].(string)
if !ok {
return nil, errors.New("uid not found in session")
}
isAuthor := 0
if uid == req.Author {
isAuthor = 1
}
xssFilterContent := utils.XssFilter(req.Content)
if xssFilterContent == "" {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
commentContent := l.svcCtx.Sensitive.Replace(xssFilterContent, '*')
return
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err = tx.Begin(); err != nil {
return nil, err
}
reply := model.ScaCommentReply{
Content: commentContent,
UserId: uid,
TopicId: req.TopicId,
TopicType: constant.CommentTopicType,
CommentType: constant.COMMENT,
Author: isAuthor,
CommentIp: ip,
Location: location,
Browser: browser,
OperatingSystem: operatingSystem,
Agent: userAgent,
ReplyId: req.ReplyId,
ReplyUser: req.ReplyUser,
}
affected, err := tx.Insert(&reply)
if err != nil {
return nil, err
}
if affected == 0 {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
update, err := tx.Table(model.ScaCommentReply{}).Where("id = ? and deleted = 0", req.ReplyId).Incr("reply_count", 1).Update(nil)
if err != nil {
return nil, err
}
if update == 0 {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
if len(req.Images) > 0 {
imagesData, err := utils.ProcessImages(req.Images)
if err != nil {
return nil, err
}
commentImages := types.CommentImages{
UserId: uid,
TopicId: req.TopicId,
CommentId: reply.Id,
Images: imagesData,
CreatedAt: reply.CreatedAt.String(),
}
if _, err = l.svcCtx.MongoClient.Collection("comment_images").InsertOne(l.ctx, commentImages); err != nil {
return nil, err
}
}
commentResponse := types.CommentResponse{
Id: reply.Id,
Content: commentContent,
UserId: uid,
TopicId: reply.TopicId,
Author: isAuthor,
Location: location,
Browser: browser,
OperatingSystem: operatingSystem,
CreatedTime: time.Now(),
ReplyId: reply.ReplyId,
ReplyUser: reply.ReplyUser,
}
err = tx.Commit()
if err != nil {
return nil, err
}
return response.SuccessWithData(commentResponse), nil
}

View File

@@ -2,9 +2,19 @@ package comment
import (
"context"
"errors"
"net/http"
"time"
"github.com/mssola/useragent"
"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/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/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -23,8 +33,133 @@ func NewSubmitReplyReplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
}
func (l *SubmitReplyReplyLogic) SubmitReplyReply(req *types.ReplyReplyRequest) (resp *types.Response, err error) {
// todo: add your logic here and delete this line
func (l *SubmitReplyReplyLogic) SubmitReplyReply(r *http.Request, req *types.ReplyReplyRequest) (resp *types.Response, err error) {
// 验证验证码
if !verify.VerifySlideCaptcha(l.ctx, l.svcCtx.RedisClient, req.Point, req.Key) {
return response.ErrorWithI18n(l.ctx, "captcha.verificationFailure"), nil
}
return
// 检查图片数量
if len(req.Images) > 3 {
return response.ErrorWithI18n(l.ctx, "comment.tooManyImages"), nil
}
// 获取用户代理
userAgent := r.Header.Get("User-Agent")
if userAgent == "" {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
ua := useragent.New(userAgent)
// 获取客户端IP及位置信息
ip := utils.GetClientIP(r)
location, err := l.svcCtx.Ip2Region.SearchByStr(ip)
if err != nil {
return nil, err
}
location = utils.RemoveZeroAndAdjust(location)
// 获取浏览器与操作系统信息
browser, _ := ua.Browser()
operatingSystem := ua.OS()
// 获取用户会话信息
session, err := l.svcCtx.Session.Get(r, constant.SESSION_KEY)
if err != nil {
return nil, err
}
uid, ok := session.Values["uid"].(string)
if !ok {
return nil, errors.New("uid not found in session")
}
// 判断作者身份
isAuthor := 0
if uid == req.Author {
isAuthor = 1
}
// XSS过滤
xssFilterContent := utils.XssFilter(req.Content)
if xssFilterContent == "" {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
commentContent := l.svcCtx.Sensitive.Replace(xssFilterContent, '*')
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err = tx.Begin(); err != nil {
return nil, err
}
replyReply := model.ScaCommentReply{
Content: commentContent,
UserId: uid,
TopicId: req.TopicId,
TopicType: constant.CommentTopicType,
CommentType: constant.COMMENT,
Author: isAuthor,
CommentIp: ip,
Location: location,
Browser: browser,
OperatingSystem: operatingSystem,
Agent: userAgent,
ReplyId: req.ReplyId,
ReplyUser: req.ReplyUser,
ReplyTo: req.ReplyTo,
}
affected, err := tx.Insert(&replyReply)
if err != nil {
return nil, err
}
if affected == 0 {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
update, err := tx.Table(model.ScaCommentReply{}).Where("id = ? and version = ? and deleted = 0", req.ReplyId, replyReply.Version).Incr("reply_count", 1).Update(nil)
if err != nil {
return nil, err
}
if update == 0 {
return response.ErrorWithI18n(l.ctx, "comment.commentError"), nil
}
// 处理图片
if len(req.Images) > 0 {
imagesData, err := utils.ProcessImages(req.Images)
if err != nil {
return nil, err
}
commentImages := types.CommentImages{
UserId: uid,
TopicId: req.TopicId,
CommentId: replyReply.Id,
Images: imagesData,
CreatedAt: replyReply.CreatedAt.String(),
}
if _, err = l.svcCtx.MongoClient.Collection("comment_images").InsertOne(l.ctx, commentImages); err != nil {
return nil, err
}
}
// 构建响应
commentResponse := types.CommentResponse{
Id: replyReply.Id,
Content: commentContent,
UserId: uid,
TopicId: replyReply.TopicId,
Author: isAuthor,
Location: location,
Browser: browser,
OperatingSystem: operatingSystem,
CreatedTime: time.Now(),
ReplyId: replyReply.ReplyId,
ReplyUser: replyReply.ReplyUser,
ReplyTo: replyReply.ReplyTo,
}
// 提交事务
if err = tx.Commit(); err != nil {
return nil, err
}
return response.SuccessWithData(commentResponse), nil
}

View File

@@ -15,9 +15,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -102,81 +100,84 @@ func (l *GiteeCallbackLogic) GiteeCallback(w http.ResponseWriter, r *http.Reques
if err = json.Unmarshal(marshal, &giteeUser); err != nil {
return err
}
Id := strconv.Itoa(giteeUser.ID)
tx, err := l.svcCtx.MySQLClient.Tx(l.ctx)
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err = tx.Begin(); err != nil {
return err
}
userSocial := model.ScaAuthUserSocial{
OpenId: Id,
Source: constant.OAuthSourceGitee,
Deleted: constant.NotDeleted,
}
has, err := tx.Get(&userSocial)
if err != nil {
return err
}
Id := strconv.Itoa(giteeUser.ID)
socialUser, err := l.svcCtx.MySQLClient.ScaAuthUserSocial.Query().
Where(scaauthusersocial.OpenID(Id),
scaauthusersocial.Source(constant.OAuthSourceGitee),
scaauthusersocial.Deleted(constant.NotDeleted)).
First(l.ctx)
if err != nil && !ent.IsNotFound(err) {
return err
}
if ent.IsNotFound(err) {
if !has {
// 创建用户
uid := idgen.NextId()
uidStr := strconv.FormatInt(uid, 10)
addUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Create().
SetUID(uidStr).
SetAvatar(giteeUser.AvatarURL).
SetUsername(giteeUser.Login).
SetNickname(giteeUser.Name).
SetBlog(giteeUser.Blog).
SetEmail(giteeUser.Email).
SetDeleted(constant.NotDeleted).
SetGender(constant.Male).
Save(l.ctx)
if fault != nil {
return tx.Rollback()
addUser := model.ScaAuthUser{
UID: uidStr,
Avatar: giteeUser.AvatarURL,
Username: giteeUser.Login,
Nickname: giteeUser.Name,
Blog: giteeUser.Blog,
Email: giteeUser.Email,
Deleted: constant.NotDeleted,
Gender: constant.Male,
}
if err = l.svcCtx.MySQLClient.ScaAuthUserSocial.Create().
SetUserID(uidStr).
SetOpenID(Id).
SetSource(constant.OAuthSourceGitee).
Exec(l.ctx); err != nil {
return tx.Rollback()
affected, err := tx.Insert(&addUser)
if err != nil || affected == 0 {
return err
}
socialUser := model.ScaAuthUserSocial{
UserId: uidStr,
OpenId: Id,
Source: constant.OAuthSourceGitee,
}
insert, err := tx.Insert(&socialUser)
if err != nil || insert == 0 {
return err
}
if res, err := l.svcCtx.CasbinEnforcer.AddRoleForUser(uidStr, constant.User); !res || err != nil {
return tx.Rollback()
return err
}
if result := HandleOauthLoginResponse(addUser, l.svcCtx, r, w, l.ctx); !result {
return tx.Rollback()
if err = HandleOauthLoginResponse(addUser, l.svcCtx, r, w, l.ctx); err != nil {
return err
}
} else {
sacAuthUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Query().
Where(scaauthuser.UID(socialUser.UserID), scaauthuser.Deleted(constant.NotDeleted)).
First(l.ctx)
if fault != nil {
return tx.Rollback()
user := model.ScaAuthUser{
UID: userSocial.UserId,
Deleted: constant.NotDeleted,
}
have, err := tx.Get(&user)
if err != nil || !have {
return err
}
if result := HandleOauthLoginResponse(sacAuthUser, l.svcCtx, r, w, l.ctx); !result {
return tx.Rollback()
if err = HandleOauthLoginResponse(user, l.svcCtx, r, w, l.ctx); err != nil {
return err
}
}
if err := tx.Commit(); err != nil {
return tx.Rollback()
if err = tx.Commit(); err != nil {
return err
}
return nil
}
// HandleOauthLoginResponse 处理登录响应
func HandleOauthLoginResponse(scaAuthUser *ent.ScaAuthUser, svcCtx *svc.ServiceContext, r *http.Request, w http.ResponseWriter, ctx context.Context) bool {
data, result := user.HandleUserLogin(scaAuthUser, svcCtx, true, r, w, ctx)
if !result {
return false
func HandleOauthLoginResponse(scaAuthUser model.ScaAuthUser, svcCtx *svc.ServiceContext, r *http.Request, w http.ResponseWriter, ctx context.Context) error {
data, err := user.HandleUserLogin(scaAuthUser, svcCtx, true, r, w, ctx)
if err != nil {
return err
}
responseData := response.SuccessWithData(data)
formattedScript := fmt.Sprintf(Script, responseData, svcCtx.Config.Web.URL)
@@ -187,9 +188,9 @@ func HandleOauthLoginResponse(scaAuthUser *ent.ScaAuthUser, svcCtx *svc.ServiceC
// 写入响应内容
if _, writeErr := w.Write([]byte(formattedScript)); writeErr != nil {
return false
return writeErr
}
return true
return nil
}
// GetGiteeTokenAuthUrl 获取Gitee token

View File

@@ -12,9 +12,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/common/constant"
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -102,70 +100,76 @@ func (l *GithubCallbackLogic) GithubCallback(w http.ResponseWriter, r *http.Requ
if err != nil {
return err
}
tx, err := l.svcCtx.MySQLClient.Tx(l.ctx)
Id := strconv.Itoa(gitHubUser.ID)
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err = tx.Begin(); err != nil {
return err
}
userSocial := model.ScaAuthUserSocial{
OpenId: Id,
Source: constant.OAuthSourceGithub,
Deleted: constant.NotDeleted,
}
has, err := tx.Get(&userSocial)
if err != nil {
return err
}
Id := strconv.Itoa(gitHubUser.ID)
socialUser, err := l.svcCtx.MySQLClient.ScaAuthUserSocial.Query().
Where(scaauthusersocial.OpenID(Id),
scaauthusersocial.Source(constant.OAuthSourceGithub),
scaauthusersocial.Deleted(constant.NotDeleted)).
First(l.ctx)
if err != nil && !ent.IsNotFound(err) {
return err
}
if ent.IsNotFound(err) {
if !has {
// 创建用户
uid := idgen.NextId()
uidStr := strconv.FormatInt(uid, 10)
addUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Create().
SetUID(uidStr).
SetAvatar(gitHubUser.AvatarURL).
SetUsername(gitHubUser.Login).
SetNickname(gitHubUser.Name).
SetBlog(gitHubUser.Blog).
SetEmail(gitHubUser.Email).
SetDeleted(constant.NotDeleted).
SetGender(constant.Male).
Save(l.ctx)
if fault != nil {
return tx.Rollback()
addUser := model.ScaAuthUser{
UID: uidStr,
Avatar: gitHubUser.AvatarURL,
Username: gitHubUser.Login,
Nickname: gitHubUser.Name,
Blog: gitHubUser.Blog,
Email: gitHubUser.Email,
Deleted: constant.NotDeleted,
Gender: constant.Male,
}
affected, err := tx.Insert(&addUser)
if err != nil || affected == 0 {
return err
}
if err = l.svcCtx.MySQLClient.ScaAuthUserSocial.Create().
SetUserID(uidStr).
SetOpenID(Id).
SetSource(constant.OAuthSourceGithub).
Exec(l.ctx); err != nil {
return tx.Rollback()
socialUser := model.ScaAuthUserSocial{
UserId: uidStr,
OpenId: Id,
Source: constant.OAuthSourceGithub,
}
insert, err := tx.Insert(&socialUser)
if err != nil || insert == 0 {
return err
}
if res, err := l.svcCtx.CasbinEnforcer.AddRoleForUser(uidStr, constant.User); !res || err != nil {
return tx.Rollback()
return err
}
if result := HandleOauthLoginResponse(addUser, l.svcCtx, r, w, l.ctx); !result {
return tx.Rollback()
if err = HandleOauthLoginResponse(addUser, l.svcCtx, r, w, l.ctx); err != nil {
return err
}
} else {
sacAuthUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Query().
Where(scaauthuser.UID(socialUser.UserID), scaauthuser.Deleted(constant.NotDeleted)).
First(l.ctx)
if fault != nil {
return tx.Rollback()
user := model.ScaAuthUser{
UID: userSocial.UserId,
Deleted: constant.NotDeleted,
}
have, err := tx.Get(&user)
if err != nil || !have {
return err
}
if result := HandleOauthLoginResponse(sacAuthUser, l.svcCtx, r, w, l.ctx); !result {
return tx.Rollback()
if err = HandleOauthLoginResponse(user, l.svcCtx, r, w, l.ctx); err != nil {
return err
}
}
if err := tx.Commit(); err != nil {
return tx.Rollback()
return err
}
return nil
}

View File

@@ -12,9 +12,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/common/constant"
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -99,67 +97,74 @@ func (l *QqCallbackLogic) QqCallback(w http.ResponseWriter, r *http.Request, req
if err != nil {
return err
}
tx, err := l.svcCtx.MySQLClient.Tx(l.ctx)
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err = tx.Begin(); err != nil {
return err
}
userSocial := model.ScaAuthUserSocial{
OpenId: authQQme.OpenID,
Source: constant.OAuthSourceQQ,
Deleted: constant.NotDeleted,
}
has, err := tx.Get(&userSocial)
if err != nil {
return err
}
socialUser, err := l.svcCtx.MySQLClient.ScaAuthUserSocial.Query().
Where(scaauthusersocial.OpenID(authQQme.OpenID),
scaauthusersocial.Source(constant.OAuthSourceQQ),
scaauthusersocial.Deleted(constant.NotDeleted)).
First(l.ctx)
if err != nil && !ent.IsNotFound(err) {
return err
}
if ent.IsNotFound(err) {
if !has {
// 创建用户
uid := idgen.NextId()
uidStr := strconv.FormatInt(uid, 10)
addUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Create().
SetUID(uidStr).
SetAvatar(qqUserInfo.FigureurlQq1).
SetUsername(authQQme.OpenID).
SetNickname(qqUserInfo.Nickname).
SetDeleted(constant.NotDeleted).
SetGender(constant.Male).
Save(l.ctx)
if fault != nil {
return tx.Rollback()
addUser := model.ScaAuthUser{
UID: uidStr,
Avatar: qqUserInfo.FigureurlQq1,
Username: authQQme.OpenID,
Nickname: qqUserInfo.Nickname,
Deleted: constant.NotDeleted,
Gender: constant.Male,
}
affected, err := tx.Insert(&addUser)
if err != nil || affected == 0 {
return err
}
if err = l.svcCtx.MySQLClient.ScaAuthUserSocial.Create().
SetUserID(uidStr).
SetOpenID(authQQme.OpenID).
SetSource(constant.OAuthSourceQQ).
Exec(l.ctx); err != nil {
return tx.Rollback()
socialUser := model.ScaAuthUserSocial{
UserId: uidStr,
OpenId: authQQme.OpenID,
Source: constant.OAuthSourceGithub,
}
insert, err := tx.Insert(&socialUser)
if err != nil || insert == 0 {
return err
}
if res, err := l.svcCtx.CasbinEnforcer.AddRoleForUser(uidStr, constant.User); !res || err != nil {
return tx.Rollback()
return err
}
if result := HandleOauthLoginResponse(addUser, l.svcCtx, r, w, l.ctx); !result {
return tx.Rollback()
if err = HandleOauthLoginResponse(addUser, l.svcCtx, r, w, l.ctx); err != nil {
return err
}
} else {
sacAuthUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Query().
Where(scaauthuser.UID(socialUser.UserID), scaauthuser.Deleted(constant.NotDeleted)).
First(l.ctx)
if fault != nil {
return tx.Rollback()
user := model.ScaAuthUser{
UID: userSocial.UserId,
Deleted: constant.NotDeleted,
}
have, err := tx.Get(&user)
if err != nil || !have {
return err
}
if result := HandleOauthLoginResponse(sacAuthUser, l.svcCtx, r, w, l.ctx); !result {
return tx.Rollback()
if err = HandleOauthLoginResponse(user, l.svcCtx, r, w, l.ctx); err != nil {
return err
}
}
if err := tx.Commit(); err != nil {
return tx.Rollback()
return err
}
return nil
}

View File

@@ -23,9 +23,7 @@ import (
"schisandra-album-cloud-microservices/app/core/api/internal/logic/user"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/websocket"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"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/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
)
type WechatCallbackLogic struct {
@@ -115,86 +113,92 @@ func (l *WechatCallbackLogic) HandlerWechatLogin(openId string, clientId string,
if openId == "" {
return errors.New("openId is empty")
}
socialUser, err := l.svcCtx.MySQLClient.ScaAuthUserSocial.Query().
Where(scaauthusersocial.OpenID(openId),
scaauthusersocial.Source(constant.OAuthSourceWechat),
scaauthusersocial.Deleted(constant.NotDeleted)).
First(l.ctx)
if err != nil && !ent.IsNotFound(err) {
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err := tx.Begin(); err != nil {
return err
}
tx, err := l.svcCtx.MySQLClient.Tx(l.ctx)
userSocial := model.ScaAuthUserSocial{
OpenId: openId,
Source: constant.OAuthSourceWechat,
Deleted: constant.NotDeleted,
}
has, err := tx.Get(&userSocial)
if err != nil {
return err
}
if ent.IsNotFound(err) {
if !has {
// 创建用户
uid := idgen.NextId()
uidStr := strconv.FormatInt(uid, 10)
avatar := utils.GenerateAvatar(uidStr)
name := randomname.GenerateName()
addUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Create().
SetUID(uidStr).
SetAvatar(avatar).
SetUsername(openId).
SetNickname(name).
SetDeleted(constant.NotDeleted).
SetGender(constant.Male).
Save(l.ctx)
if fault != nil {
return tx.Rollback()
addUser := model.ScaAuthUser{
UID: uidStr,
Avatar: avatar,
Username: openId,
Nickname: name,
Deleted: constant.NotDeleted,
Gender: constant.Male,
}
affected, err := tx.Insert(&addUser)
if err != nil || affected == 0 {
return err
}
if err = l.svcCtx.MySQLClient.ScaAuthUserSocial.Create().
SetUserID(uidStr).
SetOpenID(openId).
SetSource(constant.OAuthSourceWechat).
Exec(l.ctx); err != nil {
return tx.Rollback()
socialUser := model.ScaAuthUserSocial{
UserId: uidStr,
OpenId: openId,
Source: constant.OAuthSourceGithub,
}
insert, err := tx.Insert(&socialUser)
if err != nil || insert == 0 {
return err
}
if res, err := l.svcCtx.CasbinEnforcer.AddRoleForUser(uidStr, constant.User); !res || err != nil {
return tx.Rollback()
return err
}
data, result := user.HandleUserLogin(addUser, l.svcCtx, true, r, w, l.ctx)
if !result {
return tx.Rollback()
data, err := user.HandleUserLogin(addUser, l.svcCtx, true, r, w, l.ctx)
if err != nil {
return err
}
marshal, fault := json.Marshal(data)
if fault != nil {
return tx.Rollback()
marshal, err := json.Marshal(data)
if err != nil {
return err
}
err = websocket.QrcodeWebSocketHandler.SendMessageToClient(clientId, marshal)
if err != nil {
return tx.Rollback()
return err
}
} else {
sacAuthUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Query().
Where(scaauthuser.UID(socialUser.UserID), scaauthuser.Deleted(constant.NotDeleted)).
First(l.ctx)
if fault != nil {
return tx.Rollback()
authUser := model.ScaAuthUser{
UID: userSocial.UserId,
Deleted: constant.NotDeleted,
}
have, err := tx.Get(&authUser)
if err != nil || !have {
return err
}
data, result := user.HandleUserLogin(sacAuthUser, l.svcCtx, true, r, w, l.ctx)
if !result {
return tx.Rollback()
data, err := user.HandleUserLogin(authUser, l.svcCtx, true, r, w, l.ctx)
if err != nil {
return err
}
marshal, fault := json.Marshal(data)
if fault != nil {
return tx.Rollback()
marshal, err := json.Marshal(data)
if err != nil {
return err
}
err = websocket.QrcodeWebSocketHandler.SendMessageToClient(clientId, marshal)
if err != nil {
return tx.Rollback()
return err
}
}
if err := tx.Commit(); err != nil {
return tx.Rollback()
return err
}
return nil

View File

@@ -5,8 +5,8 @@ import (
"net/http"
"time"
"github.com/zeromicro/go-zero/core/logc"
"github.com/zeromicro/go-zero/core/logx"
"xorm.io/xorm"
"schisandra-album-cloud-microservices/app/core/api/common/captcha/verify"
"schisandra-album-cloud-microservices/app/core/api/common/constant"
@@ -15,8 +15,7 @@ import (
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
)
type AccountLoginLogic struct {
@@ -38,44 +37,43 @@ func (l *AccountLoginLogic) AccountLogin(w http.ResponseWriter, r *http.Request,
if !verifyResult {
return response.ErrorWithI18n(l.ctx, "captcha.verificationFailure"), nil
}
var user *ent.ScaAuthUser
var query *ent.ScaAuthUserQuery
var user model.ScaAuthUser
var query *xorm.Session
switch {
case utils.IsPhone(req.Account):
query = l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.PhoneEQ(req.Account), scaauthuser.DeletedEQ(0))
query = l.svcCtx.DB.Where("phone = ? AND deleted = ?", req.Account, 0)
case utils.IsEmail(req.Account):
query = l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.EmailEQ(req.Account), scaauthuser.DeletedEQ(0))
query = l.svcCtx.DB.Where("email = ? AND deleted = ?", req.Account, 0)
case utils.IsUsername(req.Account):
query = l.svcCtx.MySQLClient.ScaAuthUser.Query().Where(scaauthuser.UsernameEQ(req.Account), scaauthuser.DeletedEQ(0))
query = l.svcCtx.DB.Where("username = ? AND deleted = ?", req.Account, 0)
default:
return response.ErrorWithI18n(l.ctx, "login.invalidAccount"), nil
}
user, err = query.First(l.ctx)
has, err := query.Get(&user)
if err != nil {
if ent.IsNotFound(err) {
return response.ErrorWithI18n(l.ctx, "login.userNotRegistered"), nil
}
return nil, err
}
if !has {
return response.ErrorWithI18n(l.ctx, "login.userNotRegistered"), nil
}
if !utils.Verify(user.Password, req.Password) {
return response.ErrorWithI18n(l.ctx, "login.invalidPassword"), nil
}
data, result := HandleUserLogin(user, l.svcCtx, req.AutoLogin, r, w, l.ctx)
if !result {
return response.ErrorWithI18n(l.ctx, "login.loginFailed"), nil
data, err := HandleUserLogin(user, l.svcCtx, req.AutoLogin, r, w, l.ctx)
if err != nil {
return nil, err
}
// 记录用户登录设备
if !GetUserLoginDevice(user.UID, r, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient, l.ctx) {
return response.ErrorWithI18n(l.ctx, "login.loginFailed"), nil
if err = GetUserLoginDevice(user.UID, r, l.svcCtx.Ip2Region, l.svcCtx.DB, l.ctx); err != nil {
return nil, err
}
return response.SuccessWithData(data), nil
}
// HandleUserLogin 处理用户登录
func HandleUserLogin(user *ent.ScaAuthUser, svcCtx *svc.ServiceContext, autoLogin bool, r *http.Request, w http.ResponseWriter, ctx context.Context) (*types.LoginResponse, bool) {
func HandleUserLogin(user model.ScaAuthUser, svcCtx *svc.ServiceContext, autoLogin bool, r *http.Request, w http.ResponseWriter, ctx context.Context) (*types.LoginResponse, error) {
// 生成jwt token
accessToken := jwt.GenerateAccessToken(svcCtx.Config.Auth.AccessSecret, jwt.AccessJWTPayload{
UserID: user.UID,
@@ -105,20 +103,18 @@ func HandleUserLogin(user *ent.ScaAuthUser, svcCtx *svc.ServiceContext, autoLogi
}
err := svcCtx.RedisClient.Set(ctx, constant.UserTokenPrefix+user.UID, redisToken, days).Err()
if err != nil {
logc.Error(ctx, err)
return nil, false
return nil, err
}
session, err := svcCtx.Session.Get(r, constant.SESSION_KEY)
if err != nil {
logc.Error(ctx, err)
return nil, false
return nil, err
}
session.Values["refresh_token"] = refreshToken
session.Values["uid"] = user.UID
err = session.Save(r, w)
if err != nil {
return nil, false
return nil, err
}
return &data, true
return &data, nil
}

View File

@@ -8,12 +8,12 @@ import (
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
"github.com/mssola/useragent"
"github.com/zeromicro/go-zero/core/logx"
"xorm.io/xorm"
"schisandra-album-cloud-microservices/app/core/api/common/constant"
"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/repository/mysql/ent"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
)
type GetUserDeviceLogic struct {
@@ -40,23 +40,22 @@ func (l *GetUserDeviceLogic) GetUserDevice(r *http.Request) error {
return errors.New("user session not found")
}
res := GetUserLoginDevice(uid, r, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient, l.ctx)
if !res {
return errors.New("user device not found")
if err = GetUserLoginDevice(uid, r, l.svcCtx.Ip2Region, l.svcCtx.DB, l.ctx); err != nil {
return err
}
return nil
}
// GetUserLoginDevice 获取用户登录设备
func GetUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searcher, entClient *ent.Client, ctx context.Context) bool {
func GetUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searcher, db *xorm.Engine, ctx context.Context) error {
userAgent := r.Header.Get("User-Agent")
if userAgent == "" {
return false
return errors.New("user agent not found")
}
ip := utils.GetClientIP(r)
location, err := ip2location.SearchByStr(ip)
if err != nil {
return false
return err
}
location = utils.RemoveZeroAndAdjust(location)
@@ -69,57 +68,54 @@ func GetUserLoginDevice(userId string, r *http.Request, ip2location *xdb.Searche
platform := ua.Platform()
engine, engineVersion := ua.Engine()
device, err := entClient.ScaAuthUserDevice.Query().
Where(scaauthuserdevice.UserID(userId), scaauthuserdevice.IP(ip), scaauthuserdevice.Agent(userAgent)).
Only(ctx)
var device model.ScaAuthUserDevice
has, err := db.Where("user_id = ? AND ip = ? AND agent = ?", userId, ip, userAgent).Get(&device)
if err != nil {
return err
}
// 如果有错误,表示设备不存在,执行插入
if ent.IsNotFound(err) {
if !has {
// 创建新的设备记录
err = entClient.ScaAuthUserDevice.Create().
SetUserID(userId).
SetBot(isBot).
SetAgent(userAgent).
SetBrowser(browser).
SetBrowserVersion(browserVersion).
SetEngineName(engine).
SetEngineVersion(engineVersion).
SetIP(ip).
SetLocation(location).
SetOperatingSystem(os).
SetMobile(mobile).
SetMozilla(mozilla).
SetPlatform(platform).
Exec(ctx)
if err != nil {
logx.Error(err)
return false
newDevice := &model.ScaAuthUserDevice{
UserId: userId,
Bot: isBot,
Agent: userAgent,
Browser: browser,
BrowserVersion: browserVersion,
EngineName: engine,
EngineVersion: engineVersion,
Ip: ip,
Location: location,
OperatingSystem: os,
Mobile: mobile,
Mozilla: mozilla,
Platform: platform,
}
return true
} else if err == nil {
// 如果设备存在,执行更新
err = device.Update().
SetUserID(userId).
SetBot(isBot).
SetAgent(userAgent).
SetBrowser(browser).
SetBrowserVersion(browserVersion).
SetEngineName(engine).
SetEngineVersion(engineVersion).
SetIP(ip).
SetLocation(location).
SetOperatingSystem(os).
SetMobile(mobile).
SetMozilla(mozilla).
SetPlatform(platform).
Exec(ctx)
if err != nil {
logx.Error(err)
return false
affected, err := db.Insert(newDevice)
if err != nil || affected == 0 {
return errors.New("create user device failed")
}
return true
return nil
} else {
logx.Error(err)
return false
// 如果设备存在,执行更新
device.Bot = isBot
device.Agent = userAgent
device.Browser = browser
device.BrowserVersion = browserVersion
device.EngineName = engine
device.EngineVersion = engineVersion
device.Ip = ip
device.Location = location
device.OperatingSystem = os
device.Mobile = mobile
device.Mozilla = mozilla
device.Platform = platform
affected, err := db.ID(device.Id).Update(&device)
if err != nil || affected == 0 {
return errors.New("update user device failed")
}
return nil
}
}

View File

@@ -2,6 +2,7 @@ package user
import (
"context"
"errors"
"net/http"
"strconv"
@@ -14,8 +15,7 @@ import (
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
)
type PhoneLoginLogic struct {
@@ -43,64 +43,68 @@ func (l *PhoneLoginLogic) PhoneLogin(r *http.Request, w http.ResponseWriter, req
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)).First(l.ctx)
tx, wrong := l.svcCtx.MySQLClient.Tx(l.ctx)
if wrong != nil {
authUser := model.ScaAuthUser{
Phone: req.Phone,
Deleted: constant.NotDeleted,
}
has, err := l.svcCtx.DB.Get(&authUser)
if err != nil {
return nil, err
}
if ent.IsNotFound(err) {
tx := l.svcCtx.DB.NewSession()
defer tx.Close()
if err = tx.Begin(); err != nil {
return nil, err
}
if !has {
uid := idgen.NextId()
uidStr := strconv.FormatInt(uid, 10)
avatar := utils.GenerateAvatar(uidStr)
name := randomname.GenerateName()
addUser, fault := l.svcCtx.MySQLClient.ScaAuthUser.Create().
SetUID(uidStr).
SetPhone(req.Phone).
SetAvatar(avatar).
SetNickname(name).
SetDeleted(constant.NotDeleted).
SetGender(constant.Male).
Save(l.ctx)
if fault != nil {
err = tx.Rollback()
return nil, err
user := model.ScaAuthUser{
UID: uidStr,
Phone: req.Phone,
Avatar: avatar,
Nickname: name,
Deleted: constant.NotDeleted,
Gender: constant.Male,
}
insert, err := tx.Insert(&user)
if err != nil || insert == 0 {
return nil, errors.New("register failed")
}
_, err = l.svcCtx.CasbinEnforcer.AddRoleForUser(uidStr, constant.User)
if err != nil {
err = tx.Rollback()
return nil, 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
data, err := HandleUserLogin(user, l.svcCtx, req.AutoLogin, r, w, l.ctx)
if err != nil {
return nil, err
}
// 记录用户登录设备
if !GetUserLoginDevice(addUser.UID, r, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient, l.ctx) {
return response.ErrorWithI18n(l.ctx, "login.registerError"), nil
if err = GetUserLoginDevice(user.UID, r, l.svcCtx.Ip2Region, l.svcCtx.DB, l.ctx); err != nil {
return nil, err
}
err = tx.Commit()
if err != nil {
tx.Rollback()
}
return response.SuccessWithData(data), nil
} 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
}
// 记录用户登录设备
if !GetUserLoginDevice(user.UID, r, l.svcCtx.Ip2Region, l.svcCtx.MySQLClient, l.ctx) {
return response.ErrorWithI18n(l.ctx, "login.loginFailed"), nil
}
err = tx.Commit()
if err != nil {
tx.Rollback()
return nil, err
}
return response.SuccessWithData(data), nil
} else {
return response.ErrorWithI18n(l.ctx, "login.loginFailed"), nil
data, err := HandleUserLogin(authUser, l.svcCtx, req.AutoLogin, r, w, l.ctx)
if err != nil {
return nil, err
}
// 记录用户登录设备
if err = GetUserLoginDevice(authUser.UID, r, l.svcCtx.Ip2Region, l.svcCtx.DB, l.ctx); err != nil {
return nil, err
}
err = tx.Commit()
if err != nil {
return nil, err
}
return response.SuccessWithData(data), nil
}
}

View File

@@ -8,8 +8,7 @@ import (
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -49,17 +48,28 @@ func (l *ResetPasswordLogic) ResetPassword(req *types.ResetPasswordRequest) (res
if err = l.svcCtx.RedisClient.Del(l.ctx, constant.UserSmsRedisPrefix+req.Phone).Err(); err != nil {
return nil, err
}
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) {
authUser := model.ScaAuthUser{
Phone: req.Phone,
Deleted: constant.NotDeleted,
}
has, err := l.svcCtx.DB.Get(&authUser)
if err != nil {
return nil, err
}
if !has {
return response.ErrorWithI18n(l.ctx, "login.userNotRegistered"), nil
}
encrypt, err := utils.Encrypt(req.Password)
if err != nil {
return nil, err
}
err = user.Update().SetPassword(encrypt).Exec(l.ctx)
affected, err := l.svcCtx.DB.ID(authUser.Id).Cols("password").Update(&model.ScaAuthUser{Password: encrypt})
if err != nil {
return nil, err
}
if affected == 0 {
return response.ErrorWithI18n(l.ctx, "login.resetPasswordError"), nil
}
return response.Success(), nil
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/wenlng/go-captcha/v2/rotate"
"github.com/wenlng/go-captcha/v2/slide"
sensitive "github.com/zmexing/go-sensitive-word"
"xorm.io/xorm"
"github.com/zeromicro/go-zero/rest"
"go.mongodb.org/mongo-driver/v2/mongo"
@@ -20,7 +21,6 @@ import (
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
"schisandra-album-cloud-microservices/app/core/api/repository/redis_session"
"schisandra-album-cloud-microservices/app/core/api/repository/redisx"
"schisandra-album-cloud-microservices/app/core/api/repository/sensitivex"
@@ -31,7 +31,7 @@ type ServiceContext struct {
Config config.Config
SecurityHeadersMiddleware rest.Middleware
CasbinVerifyMiddleware rest.Middleware
MySQLClient *ent.Client
DB *xorm.Engine
RedisClient *redis.Client
MongoClient *mongo.Database
Session *redisstore.RedisStore
@@ -44,14 +44,15 @@ type ServiceContext struct {
}
func NewServiceContext(c config.Config) *ServiceContext {
casbinEnforcer := casbinx.NewCasbin(c.Mysql.DataSource)
db := mysql.NewMySQL(c.Mysql.DataSource, c.Mysql.MaxOpenConn, c.Mysql.MaxIdleConn)
casbinEnforcer := casbinx.NewCasbin(db)
redisClient := redisx.NewRedis(c.Redis.Host, c.Redis.Pass, c.Redis.DB)
session := redis_session.NewRedisSession(redisClient)
return &ServiceContext{
Config: c,
SecurityHeadersMiddleware: middleware.NewSecurityHeadersMiddleware().Handle,
CasbinVerifyMiddleware: middleware.NewCasbinVerifyMiddleware(casbinEnforcer, session).Handle,
MySQLClient: mysql.NewMySQL(c.Mysql.DataSource),
DB: db,
RedisClient: redisClient,
MongoClient: mongodb.NewMongoDB(c.Mongo.Uri, c.Mongo.Username, c.Mongo.Password, c.Mongo.AuthSource, c.Mongo.Database),
Session: session,

View File

@@ -2,6 +2,7 @@ package types
import "time"
// CommentResponse 评论响应
type CommentResponse struct {
Id int64 `json:"id"`
Content string `json:"content"`
@@ -12,6 +13,9 @@ type CommentResponse struct {
Browser string `json:"browser"`
OperatingSystem string `json:"operating_system"`
CreatedTime time.Time `json:"created_time"`
ReplyId int64 `json:"reply_id,omitempty"`
ReplyUser string `json:"reply_user,omitempty"`
ReplyTo int64 `json:"reply_to,omitempty"`
}
// CommentImages 评论图片

View File

@@ -1,515 +0,0 @@
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
}

View File

@@ -6,13 +6,14 @@ import (
"github.com/casbin/casbin/v2"
"github.com/casbin/casbin/v2/model"
"schisandra-album-cloud-microservices/app/core/api/repository/casbinx/adapter"
xormadapter "github.com/casbin/xorm-adapter/v3"
_ "github.com/go-sql-driver/mysql"
"xorm.io/xorm"
)
// 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)
func NewCasbin(engine *xorm.Engine) *casbin.CachedEnforcer {
a, err := xormadapter.NewAdapterByEngineWithTableName(engine, "permission_rule", "sca_auth_")
if err != nil {
panic(err)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,626 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"reflect"
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentreply"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserlevel"
"sync"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// ent aliases to avoid import conflicts in user's code.
type (
Op = ent.Op
Hook = ent.Hook
Value = ent.Value
Query = ent.Query
QueryContext = ent.QueryContext
Querier = ent.Querier
QuerierFunc = ent.QuerierFunc
Interceptor = ent.Interceptor
InterceptFunc = ent.InterceptFunc
Traverser = ent.Traverser
TraverseFunc = ent.TraverseFunc
Policy = ent.Policy
Mutator = ent.Mutator
Mutation = ent.Mutation
MutateFunc = ent.MutateFunc
)
type clientCtxKey struct{}
// FromContext returns a Client stored inside a context, or nil if there isn't one.
func FromContext(ctx context.Context) *Client {
c, _ := ctx.Value(clientCtxKey{}).(*Client)
return c
}
// NewContext returns a new context with the given Client attached.
func NewContext(parent context.Context, c *Client) context.Context {
return context.WithValue(parent, clientCtxKey{}, c)
}
type txCtxKey struct{}
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
func TxFromContext(ctx context.Context) *Tx {
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
return tx
}
// NewTxContext returns a new context with the given Tx attached.
func NewTxContext(parent context.Context, tx *Tx) context.Context {
return context.WithValue(parent, txCtxKey{}, tx)
}
// OrderFunc applies an ordering on the sql selector.
// Deprecated: Use Asc/Desc functions or the package builders instead.
type OrderFunc func(*sql.Selector)
var (
initCheck sync.Once
columnCheck sql.ColumnCheck
)
// checkColumn checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
scaauthpermissionrule.Table: scaauthpermissionrule.ValidColumn,
scaauthrole.Table: scaauthrole.ValidColumn,
scaauthuser.Table: scaauthuser.ValidColumn,
scaauthuserdevice.Table: scaauthuserdevice.ValidColumn,
scaauthusersocial.Table: scaauthusersocial.ValidColumn,
scacommentlikes.Table: scacommentlikes.ValidColumn,
scacommentmessage.Table: scacommentmessage.ValidColumn,
scacommentreply.Table: scacommentreply.ValidColumn,
scauserfollows.Table: scauserfollows.ValidColumn,
scauserlevel.Table: scauserlevel.ValidColumn,
})
})
return columnCheck(table, column)
}
// Asc applies the given fields in ASC order.
func Asc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
for _, f := range fields {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Asc(s.C(f)))
}
}
}
// Desc applies the given fields in DESC order.
func Desc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
for _, f := range fields {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Desc(s.C(f)))
}
}
}
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
type AggregateFunc func(*sql.Selector) string
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
//
// GroupBy(field1, field2).
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
// Scan(ctx, &v)
func As(fn AggregateFunc, end string) AggregateFunc {
return func(s *sql.Selector) string {
return sql.As(fn(s), end)
}
}
// Count applies the "count" aggregation function on each group.
func Count() AggregateFunc {
return func(s *sql.Selector) string {
return sql.Count("*")
}
}
// Max applies the "max" aggregation function on the given field of each group.
func Max(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Max(s.C(field))
}
}
// Mean applies the "mean" aggregation function on the given field of each group.
func Mean(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Avg(s.C(field))
}
}
// Min applies the "min" aggregation function on the given field of each group.
func Min(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Min(s.C(field))
}
}
// Sum applies the "sum" aggregation function on the given field of each group.
func Sum(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Sum(s.C(field))
}
}
// ValidationError returns when validating a field or edge fails.
type ValidationError struct {
Name string // Field or edge name.
err error
}
// Error implements the error interface.
func (e *ValidationError) Error() string {
return e.err.Error()
}
// Unwrap implements the errors.Wrapper interface.
func (e *ValidationError) Unwrap() error {
return e.err
}
// IsValidationError returns a boolean indicating whether the error is a validation error.
func IsValidationError(err error) bool {
if err == nil {
return false
}
var e *ValidationError
return errors.As(err, &e)
}
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
type NotFoundError struct {
label string
}
// Error implements the error interface.
func (e *NotFoundError) Error() string {
return "ent: " + e.label + " not found"
}
// IsNotFound returns a boolean indicating whether the error is a not found error.
func IsNotFound(err error) bool {
if err == nil {
return false
}
var e *NotFoundError
return errors.As(err, &e)
}
// MaskNotFound masks not found error.
func MaskNotFound(err error) error {
if IsNotFound(err) {
return nil
}
return err
}
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
type NotSingularError struct {
label string
}
// Error implements the error interface.
func (e *NotSingularError) Error() string {
return "ent: " + e.label + " not singular"
}
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
func IsNotSingular(err error) bool {
if err == nil {
return false
}
var e *NotSingularError
return errors.As(err, &e)
}
// NotLoadedError returns when trying to get a node that was not loaded by the query.
type NotLoadedError struct {
edge string
}
// Error implements the error interface.
func (e *NotLoadedError) Error() string {
return "ent: " + e.edge + " edge was not loaded"
}
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
func IsNotLoaded(err error) bool {
if err == nil {
return false
}
var e *NotLoadedError
return errors.As(err, &e)
}
// ConstraintError returns when trying to create/update one or more entities and
// one or more of their constraints failed. For example, violation of edge or
// field uniqueness.
type ConstraintError struct {
msg string
wrap error
}
// Error implements the error interface.
func (e ConstraintError) Error() string {
return "ent: constraint failed: " + e.msg
}
// Unwrap implements the errors.Wrapper interface.
func (e *ConstraintError) Unwrap() error {
return e.wrap
}
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
func IsConstraintError(err error) bool {
if err == nil {
return false
}
var e *ConstraintError
return errors.As(err, &e)
}
// selector embedded by the different Select/GroupBy builders.
type selector struct {
label string
flds *[]string
fns []AggregateFunc
scan func(context.Context, any) error
}
// ScanX is like Scan, but panics if an error occurs.
func (s *selector) ScanX(ctx context.Context, v any) {
if err := s.scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (s *selector) Strings(ctx context.Context) ([]string, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (s *selector) StringsX(ctx context.Context) []string {
v, err := s.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (s *selector) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = s.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (s *selector) StringX(ctx context.Context) string {
v, err := s.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (s *selector) Ints(ctx context.Context) ([]int, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (s *selector) IntsX(ctx context.Context) []int {
v, err := s.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (s *selector) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = s.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (s *selector) IntX(ctx context.Context) int {
v, err := s.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (s *selector) Float64sX(ctx context.Context) []float64 {
v, err := s.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = s.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (s *selector) Float64X(ctx context.Context) float64 {
v, err := s.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (s *selector) BoolsX(ctx context.Context) []bool {
v, err := s.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = s.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (s *selector) BoolX(ctx context.Context) bool {
v, err := s.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
// withHooks invokes the builder operation with the given hooks, if any.
func withHooks[V Value, M any, PM interface {
*M
Mutation
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
if len(hooks) == 0 {
return exec(ctx)
}
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutationT, ok := any(m).(PM)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
// Set the mutation to the builder.
*mutation = *mutationT
return exec(ctx)
})
for i := len(hooks) - 1; i >= 0; i-- {
if hooks[i] == nil {
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = hooks[i](mut)
}
v, err := mut.Mutate(ctx, mutation)
if err != nil {
return value, err
}
nv, ok := v.(V)
if !ok {
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
}
return nv, nil
}
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
if ent.QueryFromContext(ctx) == nil {
qc.Op = op
ctx = ent.NewQueryContext(ctx, qc)
}
return ctx
}
func querierAll[V Value, Q interface {
sqlAll(context.Context, ...queryHook) (V, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlAll(ctx)
})
}
func querierCount[Q interface {
sqlCount(context.Context) (int, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlCount(ctx)
})
}
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
rv, err := qr.Query(ctx, q)
if err != nil {
return v, err
}
vt, ok := rv.(V)
if !ok {
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
}
return vt, nil
}
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
sqlScan(context.Context, Q1, any) error
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
rv := reflect.ValueOf(v)
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q1)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
return nil, err
}
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
return rv.Elem().Interface(), nil
}
return v, nil
})
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
vv, err := qr.Query(ctx, rootQuery)
if err != nil {
return err
}
switch rv2 := reflect.ValueOf(vv); {
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
case rv.Type() == rv2.Type():
rv.Elem().Set(rv2.Elem())
case rv.Elem().Type() == rv2.Type():
rv.Elem().Set(rv2)
}
return nil
}
// queryHook describes an internal hook for the different sqlAll methods.
type queryHook func(context.Context, *sqlgraph.QuerySpec)

File diff suppressed because it is too large Load Diff

View File

@@ -1,85 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package enttest
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
// required by schema hooks.
_ "schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/runtime"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/migrate"
"entgo.io/ent/dialect/sql/schema"
)
type (
// TestingT is the interface that is shared between
// testing.T and testing.B and used by enttest.
TestingT interface {
FailNow()
Error(...any)
}
// Option configures client creation.
Option func(*options)
options struct {
opts []ent.Option
migrateOpts []schema.MigrateOption
}
)
// WithOptions forwards options to client creation.
func WithOptions(opts ...ent.Option) Option {
return func(o *options) {
o.opts = append(o.opts, opts...)
}
}
// WithMigrateOptions forwards options to auto migration.
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
return func(o *options) {
o.migrateOpts = append(o.migrateOpts, opts...)
}
}
func newOptions(opts []Option) *options {
o := &options{}
for _, opt := range opts {
opt(o)
}
return o
}
// Open calls ent.Open and auto-run migration.
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
o := newOptions(opts)
c, err := ent.Open(driverName, dataSourceName, o.opts...)
if err != nil {
t.Error(err)
t.FailNow()
}
migrateSchema(t, c, o)
return c
}
// NewClient calls ent.NewClient and auto-run migration.
func NewClient(t TestingT, opts ...Option) *ent.Client {
o := newOptions(opts)
c := ent.NewClient(o.opts...)
migrateSchema(t, c, o)
return c
}
func migrateSchema(t TestingT, c *ent.Client, o *options) {
tables, err := schema.CopyTables(migrate.Tables)
if err != nil {
t.Error(err)
t.FailNow()
}
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
t.Error(err)
t.FailNow()
}
}

View File

@@ -1,306 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package hook
import (
"context"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
)
// The ScaAuthPermissionRuleFunc type is an adapter to allow the use of ordinary
// function as ScaAuthPermissionRule mutator.
type ScaAuthPermissionRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthPermissionRuleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthPermissionRuleMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthPermissionRuleMutation", m)
}
// The ScaAuthRoleFunc type is an adapter to allow the use of ordinary
// function as ScaAuthRole mutator.
type ScaAuthRoleFunc func(context.Context, *ent.ScaAuthRoleMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthRoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthRoleMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthRoleMutation", m)
}
// The ScaAuthUserFunc type is an adapter to allow the use of ordinary
// function as ScaAuthUser mutator.
type ScaAuthUserFunc func(context.Context, *ent.ScaAuthUserMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthUserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthUserMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserMutation", m)
}
// The ScaAuthUserDeviceFunc type is an adapter to allow the use of ordinary
// function as ScaAuthUserDevice mutator.
type ScaAuthUserDeviceFunc func(context.Context, *ent.ScaAuthUserDeviceMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthUserDeviceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthUserDeviceMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserDeviceMutation", m)
}
// The ScaAuthUserSocialFunc type is an adapter to allow the use of ordinary
// function as ScaAuthUserSocial mutator.
type ScaAuthUserSocialFunc func(context.Context, *ent.ScaAuthUserSocialMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthUserSocialFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthUserSocialMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserSocialMutation", m)
}
// The ScaCommentLikesFunc type is an adapter to allow the use of ordinary
// function as ScaCommentLikes mutator.
type ScaCommentLikesFunc func(context.Context, *ent.ScaCommentLikesMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaCommentLikesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaCommentLikesMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaCommentLikesMutation", m)
}
// The ScaCommentMessageFunc type is an adapter to allow the use of ordinary
// function as ScaCommentMessage mutator.
type ScaCommentMessageFunc func(context.Context, *ent.ScaCommentMessageMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaCommentMessageFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaCommentMessageMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaCommentMessageMutation", m)
}
// The ScaCommentReplyFunc type is an adapter to allow the use of ordinary
// function as ScaCommentReply mutator.
type ScaCommentReplyFunc func(context.Context, *ent.ScaCommentReplyMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaCommentReplyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaCommentReplyMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaCommentReplyMutation", m)
}
// The ScaUserFollowsFunc type is an adapter to allow the use of ordinary
// function as ScaUserFollows mutator.
type ScaUserFollowsFunc func(context.Context, *ent.ScaUserFollowsMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaUserFollowsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaUserFollowsMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaUserFollowsMutation", m)
}
// The ScaUserLevelFunc type is an adapter to allow the use of ordinary
// function as ScaUserLevel mutator.
type ScaUserLevelFunc func(context.Context, *ent.ScaUserLevelMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaUserLevelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaUserLevelMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaUserLevelMutation", m)
}
// Condition is a hook condition function.
type Condition func(context.Context, ent.Mutation) bool
// And groups conditions with the AND operator.
func And(first, second Condition, rest ...Condition) Condition {
return func(ctx context.Context, m ent.Mutation) bool {
if !first(ctx, m) || !second(ctx, m) {
return false
}
for _, cond := range rest {
if !cond(ctx, m) {
return false
}
}
return true
}
}
// Or groups conditions with the OR operator.
func Or(first, second Condition, rest ...Condition) Condition {
return func(ctx context.Context, m ent.Mutation) bool {
if first(ctx, m) || second(ctx, m) {
return true
}
for _, cond := range rest {
if cond(ctx, m) {
return true
}
}
return false
}
}
// Not negates a given condition.
func Not(cond Condition) Condition {
return func(ctx context.Context, m ent.Mutation) bool {
return !cond(ctx, m)
}
}
// HasOp is a condition testing mutation operation.
func HasOp(op ent.Op) Condition {
return func(_ context.Context, m ent.Mutation) bool {
return m.Op().Is(op)
}
}
// HasAddedFields is a condition validating `.AddedField` on fields.
func HasAddedFields(field string, fields ...string) Condition {
return func(_ context.Context, m ent.Mutation) bool {
if _, exists := m.AddedField(field); !exists {
return false
}
for _, field := range fields {
if _, exists := m.AddedField(field); !exists {
return false
}
}
return true
}
}
// HasClearedFields is a condition validating `.FieldCleared` on fields.
func HasClearedFields(field string, fields ...string) Condition {
return func(_ context.Context, m ent.Mutation) bool {
if exists := m.FieldCleared(field); !exists {
return false
}
for _, field := range fields {
if exists := m.FieldCleared(field); !exists {
return false
}
}
return true
}
}
// HasFields is a condition validating `.Field` on fields.
func HasFields(field string, fields ...string) Condition {
return func(_ context.Context, m ent.Mutation) bool {
if _, exists := m.Field(field); !exists {
return false
}
for _, field := range fields {
if _, exists := m.Field(field); !exists {
return false
}
}
return true
}
}
// If executes the given hook under condition.
//
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
func If(hk ent.Hook, cond Condition) ent.Hook {
return func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if cond(ctx, m) {
return hk(next).Mutate(ctx, m)
}
return next.Mutate(ctx, m)
})
}
}
// On executes the given hook only for the given operation.
//
// hook.On(Log, ent.Delete|ent.Create)
func On(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, HasOp(op))
}
// Unless skips the given hook only for the given operation.
//
// hook.Unless(Log, ent.Update|ent.UpdateOne)
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, Not(HasOp(op)))
}
// FixedError is a hook returning a fixed error.
func FixedError(err error) ent.Hook {
return func(ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
return nil, err
})
}
}
// Reject returns a hook that rejects all operations that match op.
//
// func (T) Hooks() []ent.Hook {
// return []ent.Hook{
// Reject(ent.Delete|ent.Update),
// }
// }
func Reject(op ent.Op) ent.Hook {
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
return On(hk, op)
}
// Chain acts as a list of hooks and is effectively immutable.
// Once created, it will always hold the same set of hooks in the same order.
type Chain struct {
hooks []ent.Hook
}
// NewChain creates a new chain of hooks.
func NewChain(hooks ...ent.Hook) Chain {
return Chain{append([]ent.Hook(nil), hooks...)}
}
// Hook chains the list of hooks and returns the final hook.
func (c Chain) Hook() ent.Hook {
return func(mutator ent.Mutator) ent.Mutator {
for i := len(c.hooks) - 1; i >= 0; i-- {
mutator = c.hooks[i](mutator)
}
return mutator
}
}
// Append extends a chain, adding the specified hook
// as the last ones in the mutation flow.
func (c Chain) Append(hooks ...ent.Hook) Chain {
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
newHooks = append(newHooks, c.hooks...)
newHooks = append(newHooks, hooks...)
return Chain{newHooks}
}
// Extend extends a chain, adding the specified chain
// as the last ones in the mutation flow.
func (c Chain) Extend(chain Chain) Chain {
return c.Append(chain.hooks...)
}

View File

@@ -1,64 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"context"
"fmt"
"io"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql/schema"
)
var (
// WithGlobalUniqueID sets the universal ids options to the migration.
// If this option is enabled, ent migration will allocate a 1<<32 range
// for the ids of each entity (table).
// Note that this option cannot be applied on tables that already exist.
WithGlobalUniqueID = schema.WithGlobalUniqueID
// WithDropColumn sets the drop column option to the migration.
// If this option is enabled, ent migration will drop old columns
// that were used for both fields and edges. This defaults to false.
WithDropColumn = schema.WithDropColumn
// WithDropIndex sets the drop index option to the migration.
// If this option is enabled, ent migration will drop old indexes
// that were defined in the schema. This defaults to false.
// Note that unique constraints are defined using `UNIQUE INDEX`,
// and therefore, it's recommended to enable this option to get more
// flexibility in the schema changes.
WithDropIndex = schema.WithDropIndex
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
WithForeignKeys = schema.WithForeignKeys
)
// Schema is the API for creating, migrating and dropping a schema.
type Schema struct {
drv dialect.Driver
}
// NewSchema creates a new schema client.
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
// Create creates all schema resources.
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
return Create(ctx, s, Tables, opts...)
}
// Create creates all table resources using the given schema driver.
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, tables...)
}
// WriteTo writes the schema changes to w instead of running them against the database.
//
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
// log.Fatal(err)
// }
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
}

View File

@@ -1,320 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// ScaAuthPermissionRuleColumns holds the columns for the "sca_auth_permission_rule" table.
ScaAuthPermissionRuleColumns = []*schema.Column{
{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},
}
// ScaAuthPermissionRuleTable holds the schema information for the "sca_auth_permission_rule" table.
ScaAuthPermissionRuleTable = &schema.Table{
Name: "sca_auth_permission_rule",
Comment: "角色权限规则表",
Columns: ScaAuthPermissionRuleColumns,
PrimaryKey: []*schema.Column{ScaAuthPermissionRuleColumns[0]},
}
// ScaAuthRoleColumns holds the columns for the "sca_auth_role" table.
ScaAuthRoleColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "role_name", Type: field.TypeString, Size: 32, Comment: "角色名称"},
{Name: "role_key", Type: field.TypeString, Size: 64, Comment: "角色关键字"},
}
// ScaAuthRoleTable holds the schema information for the "sca_auth_role" table.
ScaAuthRoleTable = &schema.Table{
Name: "sca_auth_role",
Comment: "角色表",
Columns: ScaAuthRoleColumns,
PrimaryKey: []*schema.Column{ScaAuthRoleColumns[0]},
}
// ScaAuthUserColumns holds the columns for the "sca_auth_user" table.
ScaAuthUserColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "自增ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "uid", Type: field.TypeString, Unique: true, Size: 20, Comment: "唯一ID"},
{Name: "username", Type: field.TypeString, Nullable: true, Size: 32, Comment: "用户名"},
{Name: "nickname", Type: field.TypeString, Nullable: true, Size: 32, Comment: "昵称"},
{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.TypeInt8, Nullable: true, Comment: "性别"},
{Name: "avatar", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "头像"},
{Name: "status", Type: field.TypeInt8, Nullable: true, Comment: "状态 0 正常 1 封禁", Default: 0},
{Name: "introduce", Type: field.TypeString, Nullable: true, Size: 255, Comment: "介绍"},
{Name: "blog", Type: field.TypeString, Nullable: true, Size: 30, Comment: "博客"},
{Name: "location", Type: field.TypeString, Nullable: true, Size: 50, Comment: "地址"},
{Name: "company", Type: field.TypeString, Nullable: true, Size: 50, Comment: "公司"},
}
// ScaAuthUserTable holds the schema information for the "sca_auth_user" table.
ScaAuthUserTable = &schema.Table{
Name: "sca_auth_user",
Comment: "用户表",
Columns: ScaAuthUserColumns,
PrimaryKey: []*schema.Column{ScaAuthUserColumns[0]},
Indexes: []*schema.Index{
{
Name: "scaauthuser_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserColumns[0]},
},
{
Name: "scaauthuser_uid",
Unique: true,
Columns: []*schema.Column{ScaAuthUserColumns[4]},
},
{
Name: "scaauthuser_phone",
Unique: true,
Columns: []*schema.Column{ScaAuthUserColumns[8]},
},
},
}
// ScaAuthUserDeviceColumns holds the columns for the "sca_auth_user_device" table.
ScaAuthUserDeviceColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "user_id", Type: field.TypeString, Size: 20, Comment: "用户ID"},
{Name: "ip", Type: field.TypeString, Size: 20, Comment: "登录IP"},
{Name: "location", Type: field.TypeString, Size: 20, Comment: "地址"},
{Name: "agent", Type: field.TypeString, Size: 255, Comment: "设备信息"},
{Name: "browser", Type: field.TypeString, Size: 20, Comment: "浏览器"},
{Name: "operating_system", Type: field.TypeString, Size: 20, Comment: "操作系统"},
{Name: "browser_version", Type: field.TypeString, Size: 20, Comment: "浏览器版本"},
{Name: "mobile", Type: field.TypeBool, Comment: "是否为手机 0否1是"},
{Name: "bot", Type: field.TypeBool, Comment: "是否为bot 0否1是"},
{Name: "mozilla", Type: field.TypeString, Size: 10, Comment: "火狐版本"},
{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: "引擎版本"},
}
// ScaAuthUserDeviceTable holds the schema information for the "sca_auth_user_device" table.
ScaAuthUserDeviceTable = &schema.Table{
Name: "sca_auth_user_device",
Comment: "用户设备表",
Columns: ScaAuthUserDeviceColumns,
PrimaryKey: []*schema.Column{ScaAuthUserDeviceColumns[0]},
Indexes: []*schema.Index{
{
Name: "scaauthuserdevice_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserDeviceColumns[0]},
},
},
}
// ScaAuthUserSocialColumns holds the columns for the "sca_auth_user_social" table.
ScaAuthUserSocialColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "user_id", Type: field.TypeString, Size: 20, Comment: "用户ID"},
{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},
}
// ScaAuthUserSocialTable holds the schema information for the "sca_auth_user_social" table.
ScaAuthUserSocialTable = &schema.Table{
Name: "sca_auth_user_social",
Comment: "用户第三方登录信息",
Columns: ScaAuthUserSocialColumns,
PrimaryKey: []*schema.Column{ScaAuthUserSocialColumns[0]},
Indexes: []*schema.Index{
{
Name: "scaauthusersocial_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserSocialColumns[0]},
},
{
Name: "scaauthusersocial_user_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserSocialColumns[4]},
},
{
Name: "scaauthusersocial_open_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserSocialColumns[5]},
},
},
}
// ScaCommentLikesColumns holds the columns for the "sca_comment_likes" table.
ScaCommentLikesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键id"},
{Name: "topic_id", Type: field.TypeString, Comment: "话题ID"},
{Name: "user_id", Type: field.TypeString, Comment: "用户ID"},
{Name: "comment_id", Type: field.TypeInt64, Comment: "评论ID"},
{Name: "like_time", Type: field.TypeTime, Comment: "点赞时间"},
}
// ScaCommentLikesTable holds the schema information for the "sca_comment_likes" table.
ScaCommentLikesTable = &schema.Table{
Name: "sca_comment_likes",
Comment: "评论点赞表",
Columns: ScaCommentLikesColumns,
PrimaryKey: []*schema.Column{ScaCommentLikesColumns[0]},
Indexes: []*schema.Index{
{
Name: "scacommentlikes_user_id",
Unique: false,
Columns: []*schema.Column{ScaCommentLikesColumns[2]},
},
{
Name: "scacommentlikes_comment_id",
Unique: false,
Columns: []*schema.Column{ScaCommentLikesColumns[3]},
},
},
}
// ScaCommentMessageColumns holds the columns for the "sca_comment_message" table.
ScaCommentMessageColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键"},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "topic_id", Type: field.TypeString, Comment: "话题Id"},
{Name: "from_id", Type: field.TypeString, Comment: "来自人"},
{Name: "to_id", Type: field.TypeString, Comment: "送达人"},
{Name: "content", Type: field.TypeString, Comment: "消息内容"},
{Name: "is_read", Type: field.TypeInt, Nullable: true, Comment: "是否已读"},
}
// ScaCommentMessageTable holds the schema information for the "sca_comment_message" table.
ScaCommentMessageTable = &schema.Table{
Name: "sca_comment_message",
Comment: "评论消息表",
Columns: ScaCommentMessageColumns,
PrimaryKey: []*schema.Column{ScaCommentMessageColumns[0]},
}
// ScaCommentReplyColumns holds the columns for the "sca_comment_reply" table.
ScaCommentReplyColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键id", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Nullable: true, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "user_id", Type: field.TypeString, Comment: "评论用户id"},
{Name: "topic_id", Type: field.TypeString, Comment: "评论话题id"},
{Name: "topic_type", Type: field.TypeInt, Comment: "话题类型"},
{Name: "content", Type: field.TypeString, Comment: "评论内容"},
{Name: "comment_type", Type: field.TypeInt, Comment: "评论类型 0评论 1 回复"},
{Name: "reply_to", Type: field.TypeInt64, Nullable: true, Comment: "回复子评论ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "reply_id", Type: field.TypeInt64, Nullable: true, Comment: "回复父评论Id", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "reply_user", Type: field.TypeString, Nullable: true, Comment: "回复人id"},
{Name: "author", Type: field.TypeInt, Comment: "评论回复是否作者 0否 1是", Default: 0},
{Name: "likes", Type: field.TypeInt64, Nullable: true, Comment: "点赞数", Default: 0, SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "reply_count", Type: field.TypeInt64, Nullable: true, Comment: "回复数量", Default: 0, SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "browser", Type: field.TypeString, Comment: "浏览器"},
{Name: "operating_system", Type: field.TypeString, Comment: "操作系统"},
{Name: "comment_ip", Type: field.TypeString, Comment: "IP地址"},
{Name: "location", Type: field.TypeString, Comment: "地址"},
{Name: "agent", Type: field.TypeString, Size: 255, Comment: "设备信息"},
}
// ScaCommentReplyTable holds the schema information for the "sca_comment_reply" table.
ScaCommentReplyTable = &schema.Table{
Name: "sca_comment_reply",
Comment: "评论回复表",
Columns: ScaCommentReplyColumns,
PrimaryKey: []*schema.Column{ScaCommentReplyColumns[0]},
Indexes: []*schema.Index{
{
Name: "scacommentreply_id",
Unique: true,
Columns: []*schema.Column{ScaCommentReplyColumns[0]},
},
},
}
// ScaUserFollowsColumns holds the columns for the "sca_user_follows" table.
ScaUserFollowsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "follower_id", Type: field.TypeString, Comment: "关注者"},
{Name: "followee_id", Type: field.TypeString, Comment: "被关注者"},
{Name: "status", Type: field.TypeUint8, Comment: "关注状态0 未互关 1 互关)", Default: 0},
}
// ScaUserFollowsTable holds the schema information for the "sca_user_follows" table.
ScaUserFollowsTable = &schema.Table{
Name: "sca_user_follows",
Comment: "用户关注表",
Columns: ScaUserFollowsColumns,
PrimaryKey: []*schema.Column{ScaUserFollowsColumns[0]},
}
// ScaUserLevelColumns holds the columns for the "sca_user_level" table.
ScaUserLevelColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键"},
{Name: "user_id", Type: field.TypeString, Comment: "用户Id"},
{Name: "level_type", Type: field.TypeUint8, Comment: "等级类型"},
{Name: "level", Type: field.TypeInt, Comment: "等级"},
{Name: "level_name", Type: field.TypeString, Size: 50, Comment: "等级名称"},
{Name: "exp_start", Type: field.TypeInt64, Comment: "开始经验值"},
{Name: "exp_end", Type: field.TypeInt64, Comment: "结束经验值"},
{Name: "level_description", Type: field.TypeString, Nullable: true, Size: 2147483647, Comment: "等级描述"},
}
// ScaUserLevelTable holds the schema information for the "sca_user_level" table.
ScaUserLevelTable = &schema.Table{
Name: "sca_user_level",
Comment: "用户等级表",
Columns: ScaUserLevelColumns,
PrimaryKey: []*schema.Column{ScaUserLevelColumns[0]},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
ScaAuthPermissionRuleTable,
ScaAuthRoleTable,
ScaAuthUserTable,
ScaAuthUserDeviceTable,
ScaAuthUserSocialTable,
ScaCommentLikesTable,
ScaCommentMessageTable,
ScaCommentReplyTable,
ScaUserFollowsTable,
ScaUserLevelTable,
}
)
func init() {
ScaAuthPermissionRuleTable.Annotation = &entsql.Annotation{
Table: "sca_auth_permission_rule",
}
ScaAuthRoleTable.Annotation = &entsql.Annotation{
Table: "sca_auth_role",
}
ScaAuthUserTable.Annotation = &entsql.Annotation{
Table: "sca_auth_user",
}
ScaAuthUserDeviceTable.Annotation = &entsql.Annotation{
Table: "sca_auth_user_device",
}
ScaAuthUserSocialTable.Annotation = &entsql.Annotation{
Table: "sca_auth_user_social",
}
ScaCommentLikesTable.Annotation = &entsql.Annotation{
Table: "sca_comment_likes",
}
ScaCommentMessageTable.Annotation = &entsql.Annotation{
Table: "sca_comment_message",
}
ScaCommentReplyTable.Annotation = &entsql.Annotation{
Table: "sca_comment_reply",
}
ScaUserFollowsTable.Annotation = &entsql.Annotation{
Table: "sca_user_follows",
}
ScaUserLevelTable.Annotation = &entsql.Annotation{
Table: "sca_user_level",
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package predicate
import (
"entgo.io/ent/dialect/sql"
)
// ScaAuthPermissionRule is the predicate function for scaauthpermissionrule builders.
type ScaAuthPermissionRule func(*sql.Selector)
// ScaAuthRole is the predicate function for scaauthrole builders.
type ScaAuthRole func(*sql.Selector)
// ScaAuthUser is the predicate function for scaauthuser builders.
type ScaAuthUser func(*sql.Selector)
// ScaAuthUserDevice is the predicate function for scaauthuserdevice builders.
type ScaAuthUserDevice func(*sql.Selector)
// ScaAuthUserSocial is the predicate function for scaauthusersocial builders.
type ScaAuthUserSocial func(*sql.Selector)
// ScaCommentLikes is the predicate function for scacommentlikes builders.
type ScaCommentLikes func(*sql.Selector)
// ScaCommentMessage is the predicate function for scacommentmessage builders.
type ScaCommentMessage func(*sql.Selector)
// ScaCommentReply is the predicate function for scacommentreply builders.
type ScaCommentReply func(*sql.Selector)
// ScaUserFollows is the predicate function for scauserfollows builders.
type ScaUserFollows func(*sql.Selector)
// ScaUserLevel is the predicate function for scauserlevel builders.
type ScaUserLevel func(*sql.Selector)

View File

@@ -1,439 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package privacy
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
"entgo.io/ent/entql"
"entgo.io/ent/privacy"
)
var (
// Allow may be returned by rules to indicate that the policy
// evaluation should terminate with allow decision.
Allow = privacy.Allow
// Deny may be returned by rules to indicate that the policy
// evaluation should terminate with deny decision.
Deny = privacy.Deny
// Skip may be returned by rules to indicate that the policy
// evaluation should continue to the next rule.
Skip = privacy.Skip
)
// Allowf returns a formatted wrapped Allow decision.
func Allowf(format string, a ...any) error {
return privacy.Allowf(format, a...)
}
// Denyf returns a formatted wrapped Deny decision.
func Denyf(format string, a ...any) error {
return privacy.Denyf(format, a...)
}
// Skipf returns a formatted wrapped Skip decision.
func Skipf(format string, a ...any) error {
return privacy.Skipf(format, a...)
}
// DecisionContext creates a new context from the given parent context with
// a policy decision attach to it.
func DecisionContext(parent context.Context, decision error) context.Context {
return privacy.DecisionContext(parent, decision)
}
// DecisionFromContext retrieves the policy decision from the context.
func DecisionFromContext(ctx context.Context) (error, bool) {
return privacy.DecisionFromContext(ctx)
}
type (
// Policy groups query and mutation policies.
Policy = privacy.Policy
// QueryRule defines the interface deciding whether a
// query is allowed and optionally modify it.
QueryRule = privacy.QueryRule
// QueryPolicy combines multiple query rules into a single policy.
QueryPolicy = privacy.QueryPolicy
// MutationRule defines the interface which decides whether a
// mutation is allowed and optionally modifies it.
MutationRule = privacy.MutationRule
// MutationPolicy combines multiple mutation rules into a single policy.
MutationPolicy = privacy.MutationPolicy
// MutationRuleFunc type is an adapter which allows the use of
// ordinary functions as mutation rules.
MutationRuleFunc = privacy.MutationRuleFunc
// QueryMutationRule is an interface which groups query and mutation rules.
QueryMutationRule = privacy.QueryMutationRule
)
// QueryRuleFunc type is an adapter to allow the use of
// ordinary functions as query rules.
type QueryRuleFunc func(context.Context, ent.Query) error
// Eval returns f(ctx, q).
func (f QueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
return f(ctx, q)
}
// AlwaysAllowRule returns a rule that returns an allow decision.
func AlwaysAllowRule() QueryMutationRule {
return privacy.AlwaysAllowRule()
}
// AlwaysDenyRule returns a rule that returns a deny decision.
func AlwaysDenyRule() QueryMutationRule {
return privacy.AlwaysDenyRule()
}
// ContextQueryMutationRule creates a query/mutation rule from a context eval func.
func ContextQueryMutationRule(eval func(context.Context) error) QueryMutationRule {
return privacy.ContextQueryMutationRule(eval)
}
// OnMutationOperation evaluates the given rule only on a given mutation operation.
func OnMutationOperation(rule MutationRule, op ent.Op) MutationRule {
return privacy.OnMutationOperation(rule, op)
}
// DenyMutationOperationRule returns a rule denying specified mutation operation.
func DenyMutationOperationRule(op ent.Op) MutationRule {
rule := MutationRuleFunc(func(_ context.Context, m ent.Mutation) error {
return Denyf("ent/privacy: operation %s is not allowed", m.Op())
})
return OnMutationOperation(rule, op)
}
// The ScaAuthPermissionRuleQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthPermissionRuleQueryRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthPermissionRuleQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthPermissionRuleQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthPermissionRuleQuery", q)
}
// The ScaAuthPermissionRuleMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthPermissionRuleMutationRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthPermissionRuleMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthPermissionRuleMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthPermissionRuleMutation", m)
}
// The ScaAuthRoleQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthRoleQueryRuleFunc func(context.Context, *ent.ScaAuthRoleQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthRoleQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthRoleQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthRoleQuery", q)
}
// The ScaAuthRoleMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthRoleMutationRuleFunc func(context.Context, *ent.ScaAuthRoleMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthRoleMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthRoleMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthRoleMutation", m)
}
// The ScaAuthUserQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthUserQueryRuleFunc func(context.Context, *ent.ScaAuthUserQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthUserQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthUserQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthUserQuery", q)
}
// The ScaAuthUserMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthUserMutationRuleFunc func(context.Context, *ent.ScaAuthUserMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthUserMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthUserMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthUserMutation", m)
}
// The ScaAuthUserDeviceQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthUserDeviceQueryRuleFunc func(context.Context, *ent.ScaAuthUserDeviceQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthUserDeviceQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthUserDeviceQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthUserDeviceQuery", q)
}
// The ScaAuthUserDeviceMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthUserDeviceMutationRuleFunc func(context.Context, *ent.ScaAuthUserDeviceMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthUserDeviceMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthUserDeviceMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthUserDeviceMutation", m)
}
// The ScaAuthUserSocialQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthUserSocialQueryRuleFunc func(context.Context, *ent.ScaAuthUserSocialQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthUserSocialQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthUserSocialQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthUserSocialQuery", q)
}
// The ScaAuthUserSocialMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthUserSocialMutationRuleFunc func(context.Context, *ent.ScaAuthUserSocialMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthUserSocialMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthUserSocialMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthUserSocialMutation", m)
}
// The ScaCommentLikesQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaCommentLikesQueryRuleFunc func(context.Context, *ent.ScaCommentLikesQuery) error
// EvalQuery return f(ctx, q).
func (f ScaCommentLikesQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaCommentLikesQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaCommentLikesQuery", q)
}
// The ScaCommentLikesMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaCommentLikesMutationRuleFunc func(context.Context, *ent.ScaCommentLikesMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaCommentLikesMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaCommentLikesMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaCommentLikesMutation", m)
}
// The ScaCommentMessageQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaCommentMessageQueryRuleFunc func(context.Context, *ent.ScaCommentMessageQuery) error
// EvalQuery return f(ctx, q).
func (f ScaCommentMessageQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaCommentMessageQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaCommentMessageQuery", q)
}
// The ScaCommentMessageMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaCommentMessageMutationRuleFunc func(context.Context, *ent.ScaCommentMessageMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaCommentMessageMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaCommentMessageMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaCommentMessageMutation", m)
}
// The ScaCommentReplyQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaCommentReplyQueryRuleFunc func(context.Context, *ent.ScaCommentReplyQuery) error
// EvalQuery return f(ctx, q).
func (f ScaCommentReplyQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaCommentReplyQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaCommentReplyQuery", q)
}
// The ScaCommentReplyMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaCommentReplyMutationRuleFunc func(context.Context, *ent.ScaCommentReplyMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaCommentReplyMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaCommentReplyMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaCommentReplyMutation", m)
}
// The ScaUserFollowsQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaUserFollowsQueryRuleFunc func(context.Context, *ent.ScaUserFollowsQuery) error
// EvalQuery return f(ctx, q).
func (f ScaUserFollowsQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaUserFollowsQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaUserFollowsQuery", q)
}
// The ScaUserFollowsMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaUserFollowsMutationRuleFunc func(context.Context, *ent.ScaUserFollowsMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaUserFollowsMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaUserFollowsMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaUserFollowsMutation", m)
}
// The ScaUserLevelQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaUserLevelQueryRuleFunc func(context.Context, *ent.ScaUserLevelQuery) error
// EvalQuery return f(ctx, q).
func (f ScaUserLevelQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaUserLevelQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaUserLevelQuery", q)
}
// The ScaUserLevelMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaUserLevelMutationRuleFunc func(context.Context, *ent.ScaUserLevelMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaUserLevelMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaUserLevelMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaUserLevelMutation", m)
}
type (
// Filter is the interface that wraps the Where function
// for filtering nodes in queries and mutations.
Filter interface {
// Where applies a filter on the executed query/mutation.
Where(entql.P)
}
// The FilterFunc type is an adapter that allows the use of ordinary
// functions as filters for query and mutation types.
FilterFunc func(context.Context, Filter) error
)
// EvalQuery calls f(ctx, q) if the query implements the Filter interface, otherwise it is denied.
func (f FilterFunc) EvalQuery(ctx context.Context, q ent.Query) error {
fr, err := queryFilter(q)
if err != nil {
return err
}
return f(ctx, fr)
}
// EvalMutation calls f(ctx, q) if the mutation implements the Filter interface, otherwise it is denied.
func (f FilterFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
fr, err := mutationFilter(m)
if err != nil {
return err
}
return f(ctx, fr)
}
var _ QueryMutationRule = FilterFunc(nil)
func queryFilter(q ent.Query) (Filter, error) {
switch q := q.(type) {
case *ent.ScaAuthPermissionRuleQuery:
return q.Filter(), nil
case *ent.ScaAuthRoleQuery:
return q.Filter(), nil
case *ent.ScaAuthUserQuery:
return q.Filter(), nil
case *ent.ScaAuthUserDeviceQuery:
return q.Filter(), nil
case *ent.ScaAuthUserSocialQuery:
return q.Filter(), nil
case *ent.ScaCommentLikesQuery:
return q.Filter(), nil
case *ent.ScaCommentMessageQuery:
return q.Filter(), nil
case *ent.ScaCommentReplyQuery:
return q.Filter(), nil
case *ent.ScaUserFollowsQuery:
return q.Filter(), nil
case *ent.ScaUserLevelQuery:
return q.Filter(), nil
default:
return nil, Denyf("ent/privacy: unexpected query type %T for query filter", q)
}
}
func mutationFilter(m ent.Mutation) (Filter, error) {
switch m := m.(type) {
case *ent.ScaAuthPermissionRuleMutation:
return m.Filter(), nil
case *ent.ScaAuthRoleMutation:
return m.Filter(), nil
case *ent.ScaAuthUserMutation:
return m.Filter(), nil
case *ent.ScaAuthUserDeviceMutation:
return m.Filter(), nil
case *ent.ScaAuthUserSocialMutation:
return m.Filter(), nil
case *ent.ScaCommentLikesMutation:
return m.Filter(), nil
case *ent.ScaCommentMessageMutation:
return m.Filter(), nil
case *ent.ScaCommentReplyMutation:
return m.Filter(), nil
case *ent.ScaUserFollowsMutation:
return m.Filter(), nil
case *ent.ScaUserLevelMutation:
return m.Filter(), nil
default:
return nil, Denyf("ent/privacy: unexpected mutation type %T for mutation filter", m)
}
}

View File

@@ -1,314 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"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"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentreply"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserlevel"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model"
"time"
)
// The init function reads all schema descriptors with runtime code
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
scaauthpermissionruleFields := model.ScaAuthPermissionRule{}.Fields()
_ = scaauthpermissionruleFields
// scaauthpermissionruleDescPtype is the schema descriptor for ptype field.
scaauthpermissionruleDescPtype := scaauthpermissionruleFields[1].Descriptor()
// scaauthpermissionrule.PtypeValidator is a validator for the "ptype" field. It is called by the builders before save.
scaauthpermissionrule.PtypeValidator = scaauthpermissionruleDescPtype.Validators[0].(func(string) error)
// scaauthpermissionruleDescV0 is the schema descriptor for v0 field.
scaauthpermissionruleDescV0 := scaauthpermissionruleFields[2].Descriptor()
// scaauthpermissionrule.V0Validator is a validator for the "v0" field. It is called by the builders before save.
scaauthpermissionrule.V0Validator = scaauthpermissionruleDescV0.Validators[0].(func(string) error)
// scaauthpermissionruleDescV1 is the schema descriptor for v1 field.
scaauthpermissionruleDescV1 := scaauthpermissionruleFields[3].Descriptor()
// scaauthpermissionrule.V1Validator is a validator for the "v1" field. It is called by the builders before save.
scaauthpermissionrule.V1Validator = scaauthpermissionruleDescV1.Validators[0].(func(string) error)
// scaauthpermissionruleDescV2 is the schema descriptor for v2 field.
scaauthpermissionruleDescV2 := scaauthpermissionruleFields[4].Descriptor()
// scaauthpermissionrule.V2Validator is a validator for the "v2" field. It is called by the builders before save.
scaauthpermissionrule.V2Validator = scaauthpermissionruleDescV2.Validators[0].(func(string) error)
// scaauthpermissionruleDescV3 is the schema descriptor for v3 field.
scaauthpermissionruleDescV3 := scaauthpermissionruleFields[5].Descriptor()
// scaauthpermissionrule.V3Validator is a validator for the "v3" field. It is called by the builders before save.
scaauthpermissionrule.V3Validator = scaauthpermissionruleDescV3.Validators[0].(func(string) error)
// scaauthpermissionruleDescV4 is the schema descriptor for v4 field.
scaauthpermissionruleDescV4 := scaauthpermissionruleFields[6].Descriptor()
// scaauthpermissionrule.V4Validator is a validator for the "v4" field. It is called by the builders before save.
scaauthpermissionrule.V4Validator = scaauthpermissionruleDescV4.Validators[0].(func(string) error)
// scaauthpermissionruleDescV5 is the schema descriptor for v5 field.
scaauthpermissionruleDescV5 := scaauthpermissionruleFields[7].Descriptor()
// scaauthpermissionrule.V5Validator is a validator for the "v5" field. It is called by the builders before save.
scaauthpermissionrule.V5Validator = scaauthpermissionruleDescV5.Validators[0].(func(string) error)
scaauthroleMixin := model.ScaAuthRole{}.Mixin()
scaauthroleMixinFields0 := scaauthroleMixin[0].Fields()
_ = scaauthroleMixinFields0
scaauthroleFields := model.ScaAuthRole{}.Fields()
_ = scaauthroleFields
// scaauthroleDescCreatedAt is the schema descriptor for created_at field.
scaauthroleDescCreatedAt := scaauthroleMixinFields0[0].Descriptor()
// scaauthrole.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthrole.DefaultCreatedAt = scaauthroleDescCreatedAt.Default.(func() time.Time)
// scaauthroleDescUpdatedAt is the schema descriptor for updated_at field.
scaauthroleDescUpdatedAt := scaauthroleMixinFields0[1].Descriptor()
// scaauthrole.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthrole.UpdateDefaultUpdatedAt = scaauthroleDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthroleDescDeleted is the schema descriptor for deleted field.
scaauthroleDescDeleted := scaauthroleMixinFields0[2].Descriptor()
// scaauthrole.DefaultDeleted holds the default value on creation for the deleted field.
scaauthrole.DefaultDeleted = scaauthroleDescDeleted.Default.(int8)
// scaauthrole.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthrole.DeletedValidator = scaauthroleDescDeleted.Validators[0].(func(int8) error)
// scaauthroleDescRoleName is the schema descriptor for role_name field.
scaauthroleDescRoleName := scaauthroleFields[1].Descriptor()
// scaauthrole.RoleNameValidator is a validator for the "role_name" field. It is called by the builders before save.
scaauthrole.RoleNameValidator = scaauthroleDescRoleName.Validators[0].(func(string) error)
// scaauthroleDescRoleKey is the schema descriptor for role_key field.
scaauthroleDescRoleKey := scaauthroleFields[2].Descriptor()
// scaauthrole.RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save.
scaauthrole.RoleKeyValidator = scaauthroleDescRoleKey.Validators[0].(func(string) error)
scaauthuserMixin := model.ScaAuthUser{}.Mixin()
scaauthuserMixinFields0 := scaauthuserMixin[0].Fields()
_ = scaauthuserMixinFields0
scaauthuserFields := model.ScaAuthUser{}.Fields()
_ = scaauthuserFields
// scaauthuserDescCreatedAt is the schema descriptor for created_at field.
scaauthuserDescCreatedAt := scaauthuserMixinFields0[0].Descriptor()
// scaauthuser.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthuser.DefaultCreatedAt = scaauthuserDescCreatedAt.Default.(func() time.Time)
// scaauthuserDescUpdatedAt is the schema descriptor for updated_at field.
scaauthuserDescUpdatedAt := scaauthuserMixinFields0[1].Descriptor()
// scaauthuser.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthuser.UpdateDefaultUpdatedAt = scaauthuserDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthuserDescDeleted is the schema descriptor for deleted field.
scaauthuserDescDeleted := scaauthuserMixinFields0[2].Descriptor()
// scaauthuser.DefaultDeleted holds the default value on creation for the deleted field.
scaauthuser.DefaultDeleted = scaauthuserDescDeleted.Default.(int8)
// scaauthuser.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthuser.DeletedValidator = scaauthuserDescDeleted.Validators[0].(func(int8) error)
// scaauthuserDescUID is the schema descriptor for uid field.
scaauthuserDescUID := scaauthuserFields[1].Descriptor()
// scaauthuser.UIDValidator is a validator for the "uid" field. It is called by the builders before save.
scaauthuser.UIDValidator = scaauthuserDescUID.Validators[0].(func(string) error)
// scaauthuserDescUsername is the schema descriptor for username field.
scaauthuserDescUsername := scaauthuserFields[2].Descriptor()
// scaauthuser.UsernameValidator is a validator for the "username" field. It is called by the builders before save.
scaauthuser.UsernameValidator = scaauthuserDescUsername.Validators[0].(func(string) error)
// scaauthuserDescNickname is the schema descriptor for nickname field.
scaauthuserDescNickname := scaauthuserFields[3].Descriptor()
// scaauthuser.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save.
scaauthuser.NicknameValidator = scaauthuserDescNickname.Validators[0].(func(string) error)
// scaauthuserDescEmail is the schema descriptor for email field.
scaauthuserDescEmail := scaauthuserFields[4].Descriptor()
// scaauthuser.EmailValidator is a validator for the "email" field. It is called by the builders before save.
scaauthuser.EmailValidator = scaauthuserDescEmail.Validators[0].(func(string) error)
// scaauthuserDescPhone is the schema descriptor for phone field.
scaauthuserDescPhone := scaauthuserFields[5].Descriptor()
// scaauthuser.PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
scaauthuser.PhoneValidator = scaauthuserDescPhone.Validators[0].(func(string) error)
// scaauthuserDescPassword is the schema descriptor for password field.
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)
// scaauthuserDescStatus is the schema descriptor for status field.
scaauthuserDescStatus := scaauthuserFields[9].Descriptor()
// scaauthuser.DefaultStatus holds the default value on creation for the status field.
scaauthuser.DefaultStatus = scaauthuserDescStatus.Default.(int8)
// scaauthuserDescIntroduce is the schema descriptor for introduce field.
scaauthuserDescIntroduce := scaauthuserFields[10].Descriptor()
// scaauthuser.IntroduceValidator is a validator for the "introduce" field. It is called by the builders before save.
scaauthuser.IntroduceValidator = scaauthuserDescIntroduce.Validators[0].(func(string) error)
// scaauthuserDescBlog is the schema descriptor for blog field.
scaauthuserDescBlog := scaauthuserFields[11].Descriptor()
// scaauthuser.BlogValidator is a validator for the "blog" field. It is called by the builders before save.
scaauthuser.BlogValidator = scaauthuserDescBlog.Validators[0].(func(string) error)
// scaauthuserDescLocation is the schema descriptor for location field.
scaauthuserDescLocation := scaauthuserFields[12].Descriptor()
// scaauthuser.LocationValidator is a validator for the "location" field. It is called by the builders before save.
scaauthuser.LocationValidator = scaauthuserDescLocation.Validators[0].(func(string) error)
// scaauthuserDescCompany is the schema descriptor for company field.
scaauthuserDescCompany := scaauthuserFields[13].Descriptor()
// scaauthuser.CompanyValidator is a validator for the "company" field. It is called by the builders before save.
scaauthuser.CompanyValidator = scaauthuserDescCompany.Validators[0].(func(string) error)
scaauthuserdeviceMixin := model.ScaAuthUserDevice{}.Mixin()
scaauthuserdeviceMixinFields0 := scaauthuserdeviceMixin[0].Fields()
_ = scaauthuserdeviceMixinFields0
scaauthuserdeviceFields := model.ScaAuthUserDevice{}.Fields()
_ = scaauthuserdeviceFields
// scaauthuserdeviceDescCreatedAt is the schema descriptor for created_at field.
scaauthuserdeviceDescCreatedAt := scaauthuserdeviceMixinFields0[0].Descriptor()
// scaauthuserdevice.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthuserdevice.DefaultCreatedAt = scaauthuserdeviceDescCreatedAt.Default.(func() time.Time)
// scaauthuserdeviceDescUpdatedAt is the schema descriptor for updated_at field.
scaauthuserdeviceDescUpdatedAt := scaauthuserdeviceMixinFields0[1].Descriptor()
// scaauthuserdevice.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthuserdevice.UpdateDefaultUpdatedAt = scaauthuserdeviceDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthuserdeviceDescDeleted is the schema descriptor for deleted field.
scaauthuserdeviceDescDeleted := scaauthuserdeviceMixinFields0[2].Descriptor()
// scaauthuserdevice.DefaultDeleted holds the default value on creation for the deleted field.
scaauthuserdevice.DefaultDeleted = scaauthuserdeviceDescDeleted.Default.(int8)
// scaauthuserdevice.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthuserdevice.DeletedValidator = scaauthuserdeviceDescDeleted.Validators[0].(func(int8) error)
// scaauthuserdeviceDescUserID is the schema descriptor for user_id field.
scaauthuserdeviceDescUserID := scaauthuserdeviceFields[1].Descriptor()
// scaauthuserdevice.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
scaauthuserdevice.UserIDValidator = scaauthuserdeviceDescUserID.Validators[0].(func(string) error)
// scaauthuserdeviceDescIP is the schema descriptor for ip field.
scaauthuserdeviceDescIP := scaauthuserdeviceFields[2].Descriptor()
// scaauthuserdevice.IPValidator is a validator for the "ip" field. It is called by the builders before save.
scaauthuserdevice.IPValidator = scaauthuserdeviceDescIP.Validators[0].(func(string) error)
// scaauthuserdeviceDescLocation is the schema descriptor for location field.
scaauthuserdeviceDescLocation := scaauthuserdeviceFields[3].Descriptor()
// scaauthuserdevice.LocationValidator is a validator for the "location" field. It is called by the builders before save.
scaauthuserdevice.LocationValidator = scaauthuserdeviceDescLocation.Validators[0].(func(string) error)
// scaauthuserdeviceDescAgent is the schema descriptor for agent field.
scaauthuserdeviceDescAgent := scaauthuserdeviceFields[4].Descriptor()
// scaauthuserdevice.AgentValidator is a validator for the "agent" field. It is called by the builders before save.
scaauthuserdevice.AgentValidator = scaauthuserdeviceDescAgent.Validators[0].(func(string) error)
// scaauthuserdeviceDescBrowser is the schema descriptor for browser field.
scaauthuserdeviceDescBrowser := scaauthuserdeviceFields[5].Descriptor()
// scaauthuserdevice.BrowserValidator is a validator for the "browser" field. It is called by the builders before save.
scaauthuserdevice.BrowserValidator = scaauthuserdeviceDescBrowser.Validators[0].(func(string) error)
// scaauthuserdeviceDescOperatingSystem is the schema descriptor for operating_system field.
scaauthuserdeviceDescOperatingSystem := scaauthuserdeviceFields[6].Descriptor()
// scaauthuserdevice.OperatingSystemValidator is a validator for the "operating_system" field. It is called by the builders before save.
scaauthuserdevice.OperatingSystemValidator = scaauthuserdeviceDescOperatingSystem.Validators[0].(func(string) error)
// scaauthuserdeviceDescBrowserVersion is the schema descriptor for browser_version field.
scaauthuserdeviceDescBrowserVersion := scaauthuserdeviceFields[7].Descriptor()
// scaauthuserdevice.BrowserVersionValidator is a validator for the "browser_version" field. It is called by the builders before save.
scaauthuserdevice.BrowserVersionValidator = scaauthuserdeviceDescBrowserVersion.Validators[0].(func(string) error)
// scaauthuserdeviceDescMozilla is the schema descriptor for mozilla field.
scaauthuserdeviceDescMozilla := scaauthuserdeviceFields[10].Descriptor()
// scaauthuserdevice.MozillaValidator is a validator for the "mozilla" field. It is called by the builders before save.
scaauthuserdevice.MozillaValidator = scaauthuserdeviceDescMozilla.Validators[0].(func(string) error)
// scaauthuserdeviceDescPlatform is the schema descriptor for platform field.
scaauthuserdeviceDescPlatform := scaauthuserdeviceFields[11].Descriptor()
// scaauthuserdevice.PlatformValidator is a validator for the "platform" field. It is called by the builders before save.
scaauthuserdevice.PlatformValidator = scaauthuserdeviceDescPlatform.Validators[0].(func(string) error)
// scaauthuserdeviceDescEngineName is the schema descriptor for engine_name field.
scaauthuserdeviceDescEngineName := scaauthuserdeviceFields[12].Descriptor()
// scaauthuserdevice.EngineNameValidator is a validator for the "engine_name" field. It is called by the builders before save.
scaauthuserdevice.EngineNameValidator = scaauthuserdeviceDescEngineName.Validators[0].(func(string) error)
// scaauthuserdeviceDescEngineVersion is the schema descriptor for engine_version field.
scaauthuserdeviceDescEngineVersion := scaauthuserdeviceFields[13].Descriptor()
// scaauthuserdevice.EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save.
scaauthuserdevice.EngineVersionValidator = scaauthuserdeviceDescEngineVersion.Validators[0].(func(string) error)
scaauthusersocialMixin := model.ScaAuthUserSocial{}.Mixin()
scaauthusersocialMixinFields0 := scaauthusersocialMixin[0].Fields()
_ = scaauthusersocialMixinFields0
scaauthusersocialFields := model.ScaAuthUserSocial{}.Fields()
_ = scaauthusersocialFields
// scaauthusersocialDescCreatedAt is the schema descriptor for created_at field.
scaauthusersocialDescCreatedAt := scaauthusersocialMixinFields0[0].Descriptor()
// scaauthusersocial.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthusersocial.DefaultCreatedAt = scaauthusersocialDescCreatedAt.Default.(func() time.Time)
// scaauthusersocialDescUpdatedAt is the schema descriptor for updated_at field.
scaauthusersocialDescUpdatedAt := scaauthusersocialMixinFields0[1].Descriptor()
// scaauthusersocial.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthusersocial.UpdateDefaultUpdatedAt = scaauthusersocialDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthusersocialDescDeleted is the schema descriptor for deleted field.
scaauthusersocialDescDeleted := scaauthusersocialMixinFields0[2].Descriptor()
// scaauthusersocial.DefaultDeleted holds the default value on creation for the deleted field.
scaauthusersocial.DefaultDeleted = scaauthusersocialDescDeleted.Default.(int8)
// scaauthusersocial.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthusersocial.DeletedValidator = scaauthusersocialDescDeleted.Validators[0].(func(int8) error)
// scaauthusersocialDescUserID is the schema descriptor for user_id field.
scaauthusersocialDescUserID := scaauthusersocialFields[1].Descriptor()
// scaauthusersocial.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
scaauthusersocial.UserIDValidator = scaauthusersocialDescUserID.Validators[0].(func(string) error)
// scaauthusersocialDescOpenID is the schema descriptor for open_id field.
scaauthusersocialDescOpenID := scaauthusersocialFields[2].Descriptor()
// scaauthusersocial.OpenIDValidator is a validator for the "open_id" field. It is called by the builders before save.
scaauthusersocial.OpenIDValidator = scaauthusersocialDescOpenID.Validators[0].(func(string) error)
// scaauthusersocialDescSource is the schema descriptor for source field.
scaauthusersocialDescSource := scaauthusersocialFields[3].Descriptor()
// scaauthusersocial.SourceValidator is a validator for the "source" field. It is called by the builders before save.
scaauthusersocial.SourceValidator = scaauthusersocialDescSource.Validators[0].(func(string) error)
// scaauthusersocialDescStatus is the schema descriptor for status field.
scaauthusersocialDescStatus := scaauthusersocialFields[4].Descriptor()
// scaauthusersocial.DefaultStatus holds the default value on creation for the status field.
scaauthusersocial.DefaultStatus = scaauthusersocialDescStatus.Default.(int)
scacommentlikesFields := model.ScaCommentLikes{}.Fields()
_ = scacommentlikesFields
// scacommentlikesDescLikeTime is the schema descriptor for like_time field.
scacommentlikesDescLikeTime := scacommentlikesFields[4].Descriptor()
// scacommentlikes.DefaultLikeTime holds the default value on creation for the like_time field.
scacommentlikes.DefaultLikeTime = scacommentlikesDescLikeTime.Default.(func() time.Time)
scacommentmessageMixin := model.ScaCommentMessage{}.Mixin()
scacommentmessageMixinFields0 := scacommentmessageMixin[0].Fields()
_ = scacommentmessageMixinFields0
scacommentmessageFields := model.ScaCommentMessage{}.Fields()
_ = scacommentmessageFields
// scacommentmessageDescCreatedAt is the schema descriptor for created_at field.
scacommentmessageDescCreatedAt := scacommentmessageMixinFields0[0].Descriptor()
// scacommentmessage.DefaultCreatedAt holds the default value on creation for the created_at field.
scacommentmessage.DefaultCreatedAt = scacommentmessageDescCreatedAt.Default.(func() time.Time)
// scacommentmessageDescUpdatedAt is the schema descriptor for updated_at field.
scacommentmessageDescUpdatedAt := scacommentmessageMixinFields0[1].Descriptor()
// scacommentmessage.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scacommentmessage.UpdateDefaultUpdatedAt = scacommentmessageDescUpdatedAt.UpdateDefault.(func() time.Time)
// scacommentmessageDescDeleted is the schema descriptor for deleted field.
scacommentmessageDescDeleted := scacommentmessageMixinFields0[2].Descriptor()
// scacommentmessage.DefaultDeleted holds the default value on creation for the deleted field.
scacommentmessage.DefaultDeleted = scacommentmessageDescDeleted.Default.(int8)
// scacommentmessage.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scacommentmessage.DeletedValidator = scacommentmessageDescDeleted.Validators[0].(func(int8) error)
scacommentreplyMixin := model.ScaCommentReply{}.Mixin()
scacommentreplyMixinFields0 := scacommentreplyMixin[0].Fields()
_ = scacommentreplyMixinFields0
scacommentreplyFields := model.ScaCommentReply{}.Fields()
_ = scacommentreplyFields
// scacommentreplyDescCreatedAt is the schema descriptor for created_at field.
scacommentreplyDescCreatedAt := scacommentreplyMixinFields0[0].Descriptor()
// scacommentreply.DefaultCreatedAt holds the default value on creation for the created_at field.
scacommentreply.DefaultCreatedAt = scacommentreplyDescCreatedAt.Default.(func() time.Time)
// scacommentreplyDescUpdatedAt is the schema descriptor for updated_at field.
scacommentreplyDescUpdatedAt := scacommentreplyMixinFields0[1].Descriptor()
// scacommentreply.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scacommentreply.UpdateDefaultUpdatedAt = scacommentreplyDescUpdatedAt.UpdateDefault.(func() time.Time)
// scacommentreplyDescDeleted is the schema descriptor for deleted field.
scacommentreplyDescDeleted := scacommentreplyMixinFields0[2].Descriptor()
// scacommentreply.DefaultDeleted holds the default value on creation for the deleted field.
scacommentreply.DefaultDeleted = scacommentreplyDescDeleted.Default.(int8)
// scacommentreply.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scacommentreply.DeletedValidator = scacommentreplyDescDeleted.Validators[0].(func(int8) error)
// scacommentreplyDescAuthor is the schema descriptor for author field.
scacommentreplyDescAuthor := scacommentreplyFields[9].Descriptor()
// scacommentreply.DefaultAuthor holds the default value on creation for the author field.
scacommentreply.DefaultAuthor = scacommentreplyDescAuthor.Default.(int)
// scacommentreplyDescLikes is the schema descriptor for likes field.
scacommentreplyDescLikes := scacommentreplyFields[10].Descriptor()
// scacommentreply.DefaultLikes holds the default value on creation for the likes field.
scacommentreply.DefaultLikes = scacommentreplyDescLikes.Default.(int64)
// scacommentreplyDescReplyCount is the schema descriptor for reply_count field.
scacommentreplyDescReplyCount := scacommentreplyFields[11].Descriptor()
// scacommentreply.DefaultReplyCount holds the default value on creation for the reply_count field.
scacommentreply.DefaultReplyCount = scacommentreplyDescReplyCount.Default.(int64)
// scacommentreplyDescAgent is the schema descriptor for agent field.
scacommentreplyDescAgent := scacommentreplyFields[16].Descriptor()
// scacommentreply.AgentValidator is a validator for the "agent" field. It is called by the builders before save.
scacommentreply.AgentValidator = scacommentreplyDescAgent.Validators[0].(func(string) error)
scauserfollowsFields := model.ScaUserFollows{}.Fields()
_ = scauserfollowsFields
// scauserfollowsDescStatus is the schema descriptor for status field.
scauserfollowsDescStatus := scauserfollowsFields[2].Descriptor()
// scauserfollows.DefaultStatus holds the default value on creation for the status field.
scauserfollows.DefaultStatus = scauserfollowsDescStatus.Default.(uint8)
scauserlevelFields := model.ScaUserLevel{}.Fields()
_ = scauserlevelFields
// scauserlevelDescLevelName is the schema descriptor for level_name field.
scauserlevelDescLevelName := scauserlevelFields[4].Descriptor()
// scauserlevel.LevelNameValidator is a validator for the "level_name" field. It is called by the builders before save.
scauserlevel.LevelNameValidator = scauserlevelDescLevelName.Validators[0].(func(string) error)
}

View File

@@ -1,10 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package runtime
// The schema-stitching logic is generated in schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/runtime.go
const (
Version = "v0.14.1" // Version of ent codegen.
Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
)

View File

@@ -1,169 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 角色权限规则表
type ScaAuthPermissionRule struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Ptype holds the value of the "ptype" field.
Ptype string `json:"ptype,omitempty"`
// V0 holds the value of the "v0" field.
V0 string `json:"v0,omitempty"`
// V1 holds the value of the "v1" field.
V1 string `json:"v1,omitempty"`
// V2 holds the value of the "v2" field.
V2 string `json:"v2,omitempty"`
// V3 holds the value of the "v3" field.
V3 string `json:"v3,omitempty"`
// V4 holds the value of the "v4" field.
V4 string `json:"v4,omitempty"`
// V5 holds the value of the "v5" field.
V5 string `json:"v5,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthPermissionRule) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthpermissionrule.FieldID:
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)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthPermissionRule fields.
func (sapr *ScaAuthPermissionRule) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthpermissionrule.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
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 = 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 = 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 = 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 = 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 = 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 = 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 = value.String
}
default:
sapr.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthPermissionRule.
// This includes values selected through modifiers, order, etc.
func (sapr *ScaAuthPermissionRule) Value(name string) (ent.Value, error) {
return sapr.selectValues.Get(name)
}
// 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.
func (sapr *ScaAuthPermissionRule) Update() *ScaAuthPermissionRuleUpdateOne {
return NewScaAuthPermissionRuleClient(sapr.config).UpdateOne(sapr)
}
// Unwrap unwraps the ScaAuthPermissionRule entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sapr *ScaAuthPermissionRule) Unwrap() *ScaAuthPermissionRule {
_tx, ok := sapr.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthPermissionRule is not a transactional entity")
}
sapr.config.driver = _tx.drv
return sapr
}
// String implements the fmt.Stringer.
func (sapr *ScaAuthPermissionRule) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthPermissionRule(")
builder.WriteString(fmt.Sprintf("id=%v, ", sapr.ID))
builder.WriteString("ptype=")
builder.WriteString(sapr.Ptype)
builder.WriteString(", ")
builder.WriteString("v0=")
builder.WriteString(sapr.V0)
builder.WriteString(", ")
builder.WriteString("v1=")
builder.WriteString(sapr.V1)
builder.WriteString(", ")
builder.WriteString("v2=")
builder.WriteString(sapr.V2)
builder.WriteString(", ")
builder.WriteString("v3=")
builder.WriteString(sapr.V3)
builder.WriteString(", ")
builder.WriteString("v4=")
builder.WriteString(sapr.V4)
builder.WriteString(", ")
builder.WriteString("v5=")
builder.WriteString(sapr.V5)
builder.WriteByte(')')
return builder.String()
}
// ScaAuthPermissionRules is a parsable slice of ScaAuthPermissionRule.
type ScaAuthPermissionRules []*ScaAuthPermissionRule

View File

@@ -1,112 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthpermissionrule
import (
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scaauthpermissionrule type in the database.
Label = "sca_auth_permission_rule"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldPtype holds the string denoting the ptype field in the database.
FieldPtype = "ptype"
// FieldV0 holds the string denoting the v0 field in the database.
FieldV0 = "v0"
// FieldV1 holds the string denoting the v1 field in the database.
FieldV1 = "v1"
// FieldV2 holds the string denoting the v2 field in the database.
FieldV2 = "v2"
// FieldV3 holds the string denoting the v3 field in the database.
FieldV3 = "v3"
// FieldV4 holds the string denoting the v4 field in the database.
FieldV4 = "v4"
// FieldV5 holds the string denoting the v5 field in the database.
FieldV5 = "v5"
// Table holds the table name of the scaauthpermissionrule in the database.
Table = "sca_auth_permission_rule"
)
// Columns holds all SQL columns for scaauthpermissionrule fields.
var Columns = []string{
FieldID,
FieldPtype,
FieldV0,
FieldV1,
FieldV2,
FieldV3,
FieldV4,
FieldV5,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// PtypeValidator is a validator for the "ptype" field. It is called by the builders before save.
PtypeValidator func(string) error
// V0Validator is a validator for the "v0" field. It is called by the builders before save.
V0Validator func(string) error
// V1Validator is a validator for the "v1" field. It is called by the builders before save.
V1Validator func(string) error
// V2Validator is a validator for the "v2" field. It is called by the builders before save.
V2Validator func(string) error
// V3Validator is a validator for the "v3" field. It is called by the builders before save.
V3Validator func(string) error
// V4Validator is a validator for the "v4" field. It is called by the builders before save.
V4Validator func(string) error
// V5Validator is a validator for the "v5" field. It is called by the builders before save.
V5Validator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthPermissionRule queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByPtype orders the results by the ptype field.
func ByPtype(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPtype, opts...).ToFunc()
}
// ByV0 orders the results by the v0 field.
func ByV0(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV0, opts...).ToFunc()
}
// ByV1 orders the results by the v1 field.
func ByV1(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV1, opts...).ToFunc()
}
// ByV2 orders the results by the v2 field.
func ByV2(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV2, opts...).ToFunc()
}
// ByV3 orders the results by the v3 field.
func ByV3(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV3, opts...).ToFunc()
}
// ByV4 orders the results by the v4 field.
func ByV4(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV4, opts...).ToFunc()
}
// ByV5 orders the results by the v5 field.
func ByV5(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV5, opts...).ToFunc()
}

View File

@@ -1,629 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthpermissionrule
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
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 int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
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 ...int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
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 int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
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 int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldID, id))
}
// Ptype applies equality check predicate on the "ptype" field. It's identical to PtypeEQ.
func Ptype(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldPtype, v))
}
// V0 applies equality check predicate on the "v0" field. It's identical to V0EQ.
func V0(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV0, v))
}
// V1 applies equality check predicate on the "v1" field. It's identical to V1EQ.
func V1(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV1, v))
}
// V2 applies equality check predicate on the "v2" field. It's identical to V2EQ.
func V2(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV2, v))
}
// V3 applies equality check predicate on the "v3" field. It's identical to V3EQ.
func V3(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV3, v))
}
// V4 applies equality check predicate on the "v4" field. It's identical to V4EQ.
func V4(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV4, v))
}
// V5 applies equality check predicate on the "v5" field. It's identical to V5EQ.
func V5(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV5, v))
}
// PtypeEQ applies the EQ predicate on the "ptype" field.
func PtypeEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldPtype, v))
}
// PtypeNEQ applies the NEQ predicate on the "ptype" field.
func PtypeNEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldPtype, v))
}
// PtypeIn applies the In predicate on the "ptype" field.
func PtypeIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldPtype, vs...))
}
// PtypeNotIn applies the NotIn predicate on the "ptype" field.
func PtypeNotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldPtype, vs...))
}
// PtypeGT applies the GT predicate on the "ptype" field.
func PtypeGT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldPtype, v))
}
// PtypeGTE applies the GTE predicate on the "ptype" field.
func PtypeGTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldPtype, v))
}
// PtypeLT applies the LT predicate on the "ptype" field.
func PtypeLT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldPtype, v))
}
// PtypeLTE applies the LTE predicate on the "ptype" field.
func PtypeLTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldPtype, v))
}
// PtypeContains applies the Contains predicate on the "ptype" field.
func PtypeContains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldPtype, v))
}
// PtypeHasPrefix applies the HasPrefix predicate on the "ptype" field.
func PtypeHasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldPtype, v))
}
// PtypeHasSuffix applies the HasSuffix predicate on the "ptype" field.
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))
}
// PtypeContainsFold applies the ContainsFold predicate on the "ptype" field.
func PtypeContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldPtype, v))
}
// V0EQ applies the EQ predicate on the "v0" field.
func V0EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV0, v))
}
// V0NEQ applies the NEQ predicate on the "v0" field.
func V0NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV0, v))
}
// V0In applies the In predicate on the "v0" field.
func V0In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV0, vs...))
}
// V0NotIn applies the NotIn predicate on the "v0" field.
func V0NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV0, vs...))
}
// V0GT applies the GT predicate on the "v0" field.
func V0GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV0, v))
}
// V0GTE applies the GTE predicate on the "v0" field.
func V0GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV0, v))
}
// V0LT applies the LT predicate on the "v0" field.
func V0LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV0, v))
}
// V0LTE applies the LTE predicate on the "v0" field.
func V0LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV0, v))
}
// V0Contains applies the Contains predicate on the "v0" field.
func V0Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV0, v))
}
// V0HasPrefix applies the HasPrefix predicate on the "v0" field.
func V0HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV0, v))
}
// V0HasSuffix applies the HasSuffix predicate on the "v0" field.
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))
}
// V0ContainsFold applies the ContainsFold predicate on the "v0" field.
func V0ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV0, v))
}
// V1EQ applies the EQ predicate on the "v1" field.
func V1EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV1, v))
}
// V1NEQ applies the NEQ predicate on the "v1" field.
func V1NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV1, v))
}
// V1In applies the In predicate on the "v1" field.
func V1In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV1, vs...))
}
// V1NotIn applies the NotIn predicate on the "v1" field.
func V1NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV1, vs...))
}
// V1GT applies the GT predicate on the "v1" field.
func V1GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV1, v))
}
// V1GTE applies the GTE predicate on the "v1" field.
func V1GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV1, v))
}
// V1LT applies the LT predicate on the "v1" field.
func V1LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV1, v))
}
// V1LTE applies the LTE predicate on the "v1" field.
func V1LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV1, v))
}
// V1Contains applies the Contains predicate on the "v1" field.
func V1Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV1, v))
}
// V1HasPrefix applies the HasPrefix predicate on the "v1" field.
func V1HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV1, v))
}
// V1HasSuffix applies the HasSuffix predicate on the "v1" field.
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))
}
// V1ContainsFold applies the ContainsFold predicate on the "v1" field.
func V1ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV1, v))
}
// V2EQ applies the EQ predicate on the "v2" field.
func V2EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV2, v))
}
// V2NEQ applies the NEQ predicate on the "v2" field.
func V2NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV2, v))
}
// V2In applies the In predicate on the "v2" field.
func V2In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV2, vs...))
}
// V2NotIn applies the NotIn predicate on the "v2" field.
func V2NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV2, vs...))
}
// V2GT applies the GT predicate on the "v2" field.
func V2GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV2, v))
}
// V2GTE applies the GTE predicate on the "v2" field.
func V2GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV2, v))
}
// V2LT applies the LT predicate on the "v2" field.
func V2LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV2, v))
}
// V2LTE applies the LTE predicate on the "v2" field.
func V2LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV2, v))
}
// V2Contains applies the Contains predicate on the "v2" field.
func V2Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV2, v))
}
// V2HasPrefix applies the HasPrefix predicate on the "v2" field.
func V2HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV2, v))
}
// V2HasSuffix applies the HasSuffix predicate on the "v2" field.
func V2HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV2, v))
}
// V2IsNil applies the IsNil predicate on the "v2" field.
func V2IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV2))
}
// V2NotNil applies the NotNil predicate on the "v2" field.
func V2NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV2))
}
// V2EqualFold applies the EqualFold predicate on the "v2" field.
func V2EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV2, v))
}
// V2ContainsFold applies the ContainsFold predicate on the "v2" field.
func V2ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV2, v))
}
// V3EQ applies the EQ predicate on the "v3" field.
func V3EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV3, v))
}
// V3NEQ applies the NEQ predicate on the "v3" field.
func V3NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV3, v))
}
// V3In applies the In predicate on the "v3" field.
func V3In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV3, vs...))
}
// V3NotIn applies the NotIn predicate on the "v3" field.
func V3NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV3, vs...))
}
// V3GT applies the GT predicate on the "v3" field.
func V3GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV3, v))
}
// V3GTE applies the GTE predicate on the "v3" field.
func V3GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV3, v))
}
// V3LT applies the LT predicate on the "v3" field.
func V3LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV3, v))
}
// V3LTE applies the LTE predicate on the "v3" field.
func V3LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV3, v))
}
// V3Contains applies the Contains predicate on the "v3" field.
func V3Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV3, v))
}
// V3HasPrefix applies the HasPrefix predicate on the "v3" field.
func V3HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV3, v))
}
// V3HasSuffix applies the HasSuffix predicate on the "v3" field.
func V3HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV3, v))
}
// V3IsNil applies the IsNil predicate on the "v3" field.
func V3IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV3))
}
// V3NotNil applies the NotNil predicate on the "v3" field.
func V3NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV3))
}
// V3EqualFold applies the EqualFold predicate on the "v3" field.
func V3EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV3, v))
}
// V3ContainsFold applies the ContainsFold predicate on the "v3" field.
func V3ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV3, v))
}
// V4EQ applies the EQ predicate on the "v4" field.
func V4EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV4, v))
}
// V4NEQ applies the NEQ predicate on the "v4" field.
func V4NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV4, v))
}
// V4In applies the In predicate on the "v4" field.
func V4In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV4, vs...))
}
// V4NotIn applies the NotIn predicate on the "v4" field.
func V4NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV4, vs...))
}
// V4GT applies the GT predicate on the "v4" field.
func V4GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV4, v))
}
// V4GTE applies the GTE predicate on the "v4" field.
func V4GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV4, v))
}
// V4LT applies the LT predicate on the "v4" field.
func V4LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV4, v))
}
// V4LTE applies the LTE predicate on the "v4" field.
func V4LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV4, v))
}
// V4Contains applies the Contains predicate on the "v4" field.
func V4Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV4, v))
}
// V4HasPrefix applies the HasPrefix predicate on the "v4" field.
func V4HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV4, v))
}
// V4HasSuffix applies the HasSuffix predicate on the "v4" field.
func V4HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV4, v))
}
// V4IsNil applies the IsNil predicate on the "v4" field.
func V4IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV4))
}
// V4NotNil applies the NotNil predicate on the "v4" field.
func V4NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV4))
}
// V4EqualFold applies the EqualFold predicate on the "v4" field.
func V4EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV4, v))
}
// V4ContainsFold applies the ContainsFold predicate on the "v4" field.
func V4ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV4, v))
}
// V5EQ applies the EQ predicate on the "v5" field.
func V5EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV5, v))
}
// V5NEQ applies the NEQ predicate on the "v5" field.
func V5NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV5, v))
}
// V5In applies the In predicate on the "v5" field.
func V5In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV5, vs...))
}
// V5NotIn applies the NotIn predicate on the "v5" field.
func V5NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV5, vs...))
}
// V5GT applies the GT predicate on the "v5" field.
func V5GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV5, v))
}
// V5GTE applies the GTE predicate on the "v5" field.
func V5GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV5, v))
}
// V5LT applies the LT predicate on the "v5" field.
func V5LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV5, v))
}
// V5LTE applies the LTE predicate on the "v5" field.
func V5LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV5, v))
}
// V5Contains applies the Contains predicate on the "v5" field.
func V5Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV5, v))
}
// V5HasPrefix applies the HasPrefix predicate on the "v5" field.
func V5HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV5, v))
}
// V5HasSuffix applies the HasSuffix predicate on the "v5" field.
func V5HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV5, v))
}
// V5IsNil applies the IsNil predicate on the "v5" field.
func V5IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV5))
}
// V5NotNil applies the NotNil predicate on the "v5" field.
func V5NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV5))
}
// V5EqualFold applies the EqualFold predicate on the "v5" field.
func V5EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV5, v))
}
// V5ContainsFold applies the ContainsFold predicate on the "v5" field.
func V5ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV5, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.NotPredicates(p))
}

View File

@@ -1,342 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleCreate is the builder for creating a ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleCreate struct {
config
mutation *ScaAuthPermissionRuleMutation
hooks []Hook
}
// SetPtype sets the "ptype" field.
func (saprc *ScaAuthPermissionRuleCreate) SetPtype(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetPtype(s)
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)
return saprc
}
// SetNillableV2 sets the "v2" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV2(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV2(*s)
}
return saprc
}
// SetV3 sets the "v3" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV3(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV3(s)
return saprc
}
// SetNillableV3 sets the "v3" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV3(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV3(*s)
}
return saprc
}
// SetV4 sets the "v4" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV4(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV4(s)
return saprc
}
// SetNillableV4 sets the "v4" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV4(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV4(*s)
}
return saprc
}
// SetV5 sets the "v5" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV5(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV5(s)
return saprc
}
// SetNillableV5 sets the "v5" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV5(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV5(*s)
}
return saprc
}
// SetID sets the "id" field.
func (saprc *ScaAuthPermissionRuleCreate) SetID(i int) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetID(i)
return saprc
}
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
func (saprc *ScaAuthPermissionRuleCreate) Mutation() *ScaAuthPermissionRuleMutation {
return saprc.mutation
}
// Save creates the ScaAuthPermissionRule in the database.
func (saprc *ScaAuthPermissionRuleCreate) Save(ctx context.Context) (*ScaAuthPermissionRule, error) {
return withHooks(ctx, saprc.sqlSave, saprc.mutation, saprc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (saprc *ScaAuthPermissionRuleCreate) SaveX(ctx context.Context) *ScaAuthPermissionRule {
v, err := saprc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saprc *ScaAuthPermissionRuleCreate) Exec(ctx context.Context) error {
_, err := saprc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saprc *ScaAuthPermissionRuleCreate) ExecX(ctx context.Context) {
if err := saprc.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (saprc *ScaAuthPermissionRuleCreate) check() error {
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 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 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)}
}
}
if v, ok := saprc.mutation.V2(); ok {
if err := scaauthpermissionrule.V2Validator(v); err != nil {
return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)}
}
}
if v, ok := saprc.mutation.V3(); ok {
if err := scaauthpermissionrule.V3Validator(v); err != nil {
return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)}
}
}
if v, ok := saprc.mutation.V4(); ok {
if err := scaauthpermissionrule.V4Validator(v); err != nil {
return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)}
}
}
if v, ok := saprc.mutation.V5(); ok {
if err := scaauthpermissionrule.V5Validator(v); err != nil {
return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)}
}
}
return nil
}
func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuthPermissionRule, error) {
if err := saprc.check(); err != nil {
return nil, err
}
_node, _spec := saprc.createSpec()
if err := sqlgraph.CreateNode(ctx, saprc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int(id)
}
saprc.mutation.id = &_node.ID
saprc.mutation.done = true
return _node, nil
}
func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthPermissionRule{config: saprc.config}
_spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
)
if id, ok := saprc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := saprc.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
_node.Ptype = value
}
if value, ok := saprc.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
_node.V0 = value
}
if value, ok := saprc.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
_node.V1 = value
}
if value, ok := saprc.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
_node.V2 = value
}
if value, ok := saprc.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
_node.V3 = value
}
if value, ok := saprc.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
_node.V4 = value
}
if value, ok := saprc.mutation.V5(); ok {
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
_node.V5 = value
}
return _node, _spec
}
// ScaAuthPermissionRuleCreateBulk is the builder for creating many ScaAuthPermissionRule entities in bulk.
type ScaAuthPermissionRuleCreateBulk struct {
config
err error
builders []*ScaAuthPermissionRuleCreate
}
// Save creates the ScaAuthPermissionRule entities in the database.
func (saprcb *ScaAuthPermissionRuleCreateBulk) Save(ctx context.Context) ([]*ScaAuthPermissionRule, error) {
if saprcb.err != nil {
return nil, saprcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(saprcb.builders))
nodes := make([]*ScaAuthPermissionRule, len(saprcb.builders))
mutators := make([]Mutator, len(saprcb.builders))
for i := range saprcb.builders {
func(i int, root context.Context) {
builder := saprcb.builders[i]
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthPermissionRuleMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, saprcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, saprcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, saprcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (saprcb *ScaAuthPermissionRuleCreateBulk) SaveX(ctx context.Context) []*ScaAuthPermissionRule {
v, err := saprcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saprcb *ScaAuthPermissionRuleCreateBulk) Exec(ctx context.Context) error {
_, err := saprcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saprcb *ScaAuthPermissionRuleCreateBulk) ExecX(ctx context.Context) {
if err := saprcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleDelete is the builder for deleting a ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleDelete struct {
config
hooks []Hook
mutation *ScaAuthPermissionRuleMutation
}
// Where appends a list predicates to the ScaAuthPermissionRuleDelete builder.
func (saprd *ScaAuthPermissionRuleDelete) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleDelete {
saprd.mutation.Where(ps...)
return saprd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (saprd *ScaAuthPermissionRuleDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, saprd.sqlExec, saprd.mutation, saprd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (saprd *ScaAuthPermissionRuleDelete) ExecX(ctx context.Context) int {
n, err := saprd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (saprd *ScaAuthPermissionRuleDelete) sqlExec(ctx context.Context) (int, error) {
_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 {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, saprd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
saprd.mutation.done = true
return affected, err
}
// ScaAuthPermissionRuleDeleteOne is the builder for deleting a single ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleDeleteOne struct {
saprd *ScaAuthPermissionRuleDelete
}
// Where appends a list predicates to the ScaAuthPermissionRuleDelete builder.
func (saprdo *ScaAuthPermissionRuleDeleteOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleDeleteOne {
saprdo.saprd.mutation.Where(ps...)
return saprdo
}
// Exec executes the deletion query.
func (saprdo *ScaAuthPermissionRuleDeleteOne) Exec(ctx context.Context) error {
n, err := saprdo.saprd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthpermissionrule.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (saprdo *ScaAuthPermissionRuleDeleteOne) ExecX(ctx context.Context) {
if err := saprdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleQuery is the builder for querying ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleQuery struct {
config
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)
}
// Where adds a new predicate for the ScaAuthPermissionRuleQuery builder.
func (saprq *ScaAuthPermissionRuleQuery) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleQuery {
saprq.predicates = append(saprq.predicates, ps...)
return saprq
}
// Limit the number of records to be returned by this query.
func (saprq *ScaAuthPermissionRuleQuery) Limit(limit int) *ScaAuthPermissionRuleQuery {
saprq.ctx.Limit = &limit
return saprq
}
// Offset to start from.
func (saprq *ScaAuthPermissionRuleQuery) Offset(offset int) *ScaAuthPermissionRuleQuery {
saprq.ctx.Offset = &offset
return saprq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (saprq *ScaAuthPermissionRuleQuery) Unique(unique bool) *ScaAuthPermissionRuleQuery {
saprq.ctx.Unique = &unique
return saprq
}
// Order specifies how the records should be ordered.
func (saprq *ScaAuthPermissionRuleQuery) Order(o ...scaauthpermissionrule.OrderOption) *ScaAuthPermissionRuleQuery {
saprq.order = append(saprq.order, o...)
return saprq
}
// 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) {
nodes, err := saprq.Limit(1).All(setContextOp(ctx, saprq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthpermissionrule.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) FirstX(ctx context.Context) *ScaAuthPermissionRule {
node, err := saprq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// 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 int, err error) {
var ids []int
if ids, err = saprq.Limit(1).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthpermissionrule.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int {
id, err := saprq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthPermissionRule entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthPermissionRule entity is found.
// Returns a *NotFoundError when no ScaAuthPermissionRule entities are found.
func (saprq *ScaAuthPermissionRuleQuery) Only(ctx context.Context) (*ScaAuthPermissionRule, error) {
nodes, err := saprq.Limit(2).All(setContextOp(ctx, saprq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthpermissionrule.Label}
default:
return nil, &NotSingularError{scaauthpermissionrule.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) OnlyX(ctx context.Context) *ScaAuthPermissionRule {
node, err := saprq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// 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 int, err error) {
var ids []int
if ids, err = saprq.Limit(2).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthpermissionrule.Label}
default:
err = &NotSingularError{scaauthpermissionrule.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int {
id, err := saprq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthPermissionRules.
func (saprq *ScaAuthPermissionRuleQuery) All(ctx context.Context) ([]*ScaAuthPermissionRule, error) {
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryAll)
if err := saprq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthPermissionRule, *ScaAuthPermissionRuleQuery]()
return withInterceptors[[]*ScaAuthPermissionRule](ctx, saprq, qr, saprq.inters)
}
// AllX is like All, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) AllX(ctx context.Context) []*ScaAuthPermissionRule {
nodes, err := saprq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthPermissionRule IDs.
func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int, err error) {
if saprq.ctx.Unique == nil && saprq.path != nil {
saprq.Unique(true)
}
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryIDs)
if err = saprq.Select(scaauthpermissionrule.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int {
ids, err := saprq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (saprq *ScaAuthPermissionRuleQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryCount)
if err := saprq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, saprq, querierCount[*ScaAuthPermissionRuleQuery](), saprq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) CountX(ctx context.Context) int {
count, err := saprq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (saprq *ScaAuthPermissionRuleQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryExist)
switch _, err := saprq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) ExistX(ctx context.Context) bool {
exist, err := saprq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthPermissionRuleQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (saprq *ScaAuthPermissionRuleQuery) Clone() *ScaAuthPermissionRuleQuery {
if saprq == nil {
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...),
// clone intermediate query.
sql: saprq.sql.Clone(),
path: saprq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// Ptype string `json:"ptype,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthPermissionRule.Query().
// GroupBy(scaauthpermissionrule.FieldPtype).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (saprq *ScaAuthPermissionRuleQuery) GroupBy(field string, fields ...string) *ScaAuthPermissionRuleGroupBy {
saprq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthPermissionRuleGroupBy{build: saprq}
grbuild.flds = &saprq.ctx.Fields
grbuild.label = scaauthpermissionrule.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// Ptype string `json:"ptype,omitempty"`
// }
//
// client.ScaAuthPermissionRule.Query().
// Select(scaauthpermissionrule.FieldPtype).
// Scan(ctx, &v)
func (saprq *ScaAuthPermissionRuleQuery) Select(fields ...string) *ScaAuthPermissionRuleSelect {
saprq.ctx.Fields = append(saprq.ctx.Fields, fields...)
sbuild := &ScaAuthPermissionRuleSelect{ScaAuthPermissionRuleQuery: saprq}
sbuild.label = scaauthpermissionrule.Label
sbuild.flds, sbuild.scan = &saprq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthPermissionRuleSelect configured with the given aggregations.
func (saprq *ScaAuthPermissionRuleQuery) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleSelect {
return saprq.Select().Aggregate(fns...)
}
func (saprq *ScaAuthPermissionRuleQuery) prepareQuery(ctx context.Context) error {
for _, inter := range saprq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, saprq); err != nil {
return err
}
}
}
for _, f := range saprq.ctx.Fields {
if !scaauthpermissionrule.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if saprq.path != nil {
prev, err := saprq.path(ctx)
if err != nil {
return err
}
saprq.sql = prev
}
return nil
}
func (saprq *ScaAuthPermissionRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthPermissionRule, error) {
var (
nodes = []*ScaAuthPermissionRule{}
_spec = saprq.querySpec()
)
_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)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, saprq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (saprq *ScaAuthPermissionRuleQuery) sqlCount(ctx context.Context) (int, error) {
_spec := saprq.querySpec()
_spec.Node.Columns = saprq.ctx.Fields
if len(saprq.ctx.Fields) > 0 {
_spec.Unique = saprq.ctx.Unique != nil && *saprq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, saprq.driver, _spec)
}
func (saprq *ScaAuthPermissionRuleQuery) querySpec() *sqlgraph.QuerySpec {
_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
} else if saprq.path != nil {
_spec.Unique = true
}
if fields := saprq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.FieldID)
for i := range fields {
if fields[i] != scaauthpermissionrule.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := saprq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := saprq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := saprq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := saprq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (saprq *ScaAuthPermissionRuleQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(saprq.driver.Dialect())
t1 := builder.Table(scaauthpermissionrule.Table)
columns := saprq.ctx.Fields
if len(columns) == 0 {
columns = scaauthpermissionrule.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if saprq.sql != nil {
selector = saprq.sql
selector.Select(selector.Columns(columns...)...)
}
if saprq.ctx.Unique != nil && *saprq.ctx.Unique {
selector.Distinct()
}
for _, p := range saprq.predicates {
p(selector)
}
for _, p := range saprq.order {
p(selector)
}
if offset := saprq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := saprq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthPermissionRuleGroupBy is the group-by builder for ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleGroupBy struct {
selector
build *ScaAuthPermissionRuleQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (saprgb *ScaAuthPermissionRuleGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleGroupBy {
saprgb.fns = append(saprgb.fns, fns...)
return saprgb
}
// Scan applies the selector query and scans the result into the given value.
func (saprgb *ScaAuthPermissionRuleGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saprgb.build.ctx, ent.OpQueryGroupBy)
if err := saprgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthPermissionRuleQuery, *ScaAuthPermissionRuleGroupBy](ctx, saprgb.build, saprgb, saprgb.build.inters, v)
}
func (saprgb *ScaAuthPermissionRuleGroupBy) sqlScan(ctx context.Context, root *ScaAuthPermissionRuleQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(saprgb.fns))
for _, fn := range saprgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*saprgb.flds)+len(saprgb.fns))
for _, f := range *saprgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*saprgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saprgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthPermissionRuleSelect is the builder for selecting fields of ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleSelect struct {
*ScaAuthPermissionRuleQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (saprs *ScaAuthPermissionRuleSelect) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleSelect {
saprs.fns = append(saprs.fns, fns...)
return saprs
}
// Scan applies the selector query and scans the result into the given value.
func (saprs *ScaAuthPermissionRuleSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saprs.ctx, ent.OpQuerySelect)
if err := saprs.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthPermissionRuleQuery, *ScaAuthPermissionRuleSelect](ctx, saprs.ScaAuthPermissionRuleQuery, saprs, saprs.inters, v)
}
func (saprs *ScaAuthPermissionRuleSelect) sqlScan(ctx context.Context, root *ScaAuthPermissionRuleQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(saprs.fns))
for _, fn := range saprs.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*saprs.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saprs.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,625 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleUpdate is the builder for updating ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleUpdate struct {
config
hooks []Hook
mutation *ScaAuthPermissionRuleMutation
}
// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder.
func (sapru *ScaAuthPermissionRuleUpdate) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdate {
sapru.mutation.Where(ps...)
return sapru
}
// SetPtype sets the "ptype" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetPtype(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetPtype(s)
return sapru
}
// SetNillablePtype sets the "ptype" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillablePtype(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetPtype(*s)
}
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)
return sapru
}
// SetNillableV0 sets the "v0" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV0(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV0(*s)
}
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)
return sapru
}
// SetNillableV1 sets the "v1" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV1(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV1(*s)
}
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)
return sapru
}
// SetNillableV2 sets the "v2" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV2(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV2(*s)
}
return sapru
}
// ClearV2 clears the value of the "v2" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV2() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV2()
return sapru
}
// SetV3 sets the "v3" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV3(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV3(s)
return sapru
}
// SetNillableV3 sets the "v3" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV3(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV3(*s)
}
return sapru
}
// ClearV3 clears the value of the "v3" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV3() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV3()
return sapru
}
// SetV4 sets the "v4" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV4(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV4(s)
return sapru
}
// SetNillableV4 sets the "v4" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV4(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV4(*s)
}
return sapru
}
// ClearV4 clears the value of the "v4" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV4() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV4()
return sapru
}
// SetV5 sets the "v5" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV5(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV5(s)
return sapru
}
// SetNillableV5 sets the "v5" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV5(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV5(*s)
}
return sapru
}
// ClearV5 clears the value of the "v5" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV5() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV5()
return sapru
}
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
func (sapru *ScaAuthPermissionRuleUpdate) Mutation() *ScaAuthPermissionRuleMutation {
return sapru.mutation
}
// 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)
}
// SaveX is like Save, but panics if an error occurs.
func (sapru *ScaAuthPermissionRuleUpdate) SaveX(ctx context.Context) int {
affected, err := sapru.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (sapru *ScaAuthPermissionRuleUpdate) Exec(ctx context.Context) error {
_, err := sapru.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sapru *ScaAuthPermissionRuleUpdate) ExecX(ctx context.Context) {
if err := sapru.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (sapru *ScaAuthPermissionRuleUpdate) check() error {
if v, ok := sapru.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 v, ok := sapru.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 v, ok := sapru.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)}
}
}
if v, ok := sapru.mutation.V2(); ok {
if err := scaauthpermissionrule.V2Validator(v); err != nil {
return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)}
}
}
if v, ok := sapru.mutation.V3(); ok {
if err := scaauthpermissionrule.V3Validator(v); err != nil {
return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)}
}
}
if v, ok := sapru.mutation.V4(); ok {
if err := scaauthpermissionrule.V4Validator(v); err != nil {
return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)}
}
}
if v, ok := sapru.mutation.V5(); ok {
if err := scaauthpermissionrule.V5Validator(v); err != nil {
return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)}
}
}
return nil
}
func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := sapru.check(); err != nil {
return n, err
}
_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 {
ps[i](selector)
}
}
}
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)
}
if sapru.mutation.V2Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV2, field.TypeString)
}
if value, ok := sapru.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
}
if sapru.mutation.V3Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV3, field.TypeString)
}
if value, ok := sapru.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
}
if sapru.mutation.V4Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV4, field.TypeString)
}
if value, ok := sapru.mutation.V5(); ok {
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
}
if sapru.mutation.V5Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString)
}
if n, err = sqlgraph.UpdateNodes(ctx, sapru.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthpermissionrule.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
sapru.mutation.done = true
return n, nil
}
// ScaAuthPermissionRuleUpdateOne is the builder for updating a single ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthPermissionRuleMutation
}
// SetPtype sets the "ptype" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetPtype(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetPtype(s)
return sapruo
}
// SetNillablePtype sets the "ptype" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillablePtype(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetPtype(*s)
}
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)
return sapruo
}
// SetNillableV0 sets the "v0" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV0(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV0(*s)
}
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)
return sapruo
}
// SetNillableV1 sets the "v1" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV1(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV1(*s)
}
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)
return sapruo
}
// SetNillableV2 sets the "v2" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV2(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV2(*s)
}
return sapruo
}
// ClearV2 clears the value of the "v2" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV2() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV2()
return sapruo
}
// SetV3 sets the "v3" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV3(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV3(s)
return sapruo
}
// SetNillableV3 sets the "v3" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV3(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV3(*s)
}
return sapruo
}
// ClearV3 clears the value of the "v3" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV3() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV3()
return sapruo
}
// SetV4 sets the "v4" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV4(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV4(s)
return sapruo
}
// SetNillableV4 sets the "v4" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV4(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV4(*s)
}
return sapruo
}
// ClearV4 clears the value of the "v4" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV4() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV4()
return sapruo
}
// SetV5 sets the "v5" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV5(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV5(s)
return sapruo
}
// SetNillableV5 sets the "v5" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV5(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV5(*s)
}
return sapruo
}
// ClearV5 clears the value of the "v5" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV5() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV5()
return sapruo
}
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Mutation() *ScaAuthPermissionRuleMutation {
return sapruo.mutation
}
// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.Where(ps...)
return sapruo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Select(field string, fields ...string) *ScaAuthPermissionRuleUpdateOne {
sapruo.fields = append([]string{field}, fields...)
return sapruo
}
// Save executes the query and returns the updated ScaAuthPermissionRule entity.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Save(ctx context.Context) (*ScaAuthPermissionRule, error) {
return withHooks(ctx, sapruo.sqlSave, sapruo.mutation, sapruo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SaveX(ctx context.Context) *ScaAuthPermissionRule {
node, err := sapruo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Exec(ctx context.Context) error {
_, err := sapruo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ExecX(ctx context.Context) {
if err := sapruo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (sapruo *ScaAuthPermissionRuleUpdateOne) check() error {
if v, ok := sapruo.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 v, ok := sapruo.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 v, ok := sapruo.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)}
}
}
if v, ok := sapruo.mutation.V2(); ok {
if err := scaauthpermissionrule.V2Validator(v); err != nil {
return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)}
}
}
if v, ok := sapruo.mutation.V3(); ok {
if err := scaauthpermissionrule.V3Validator(v); err != nil {
return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)}
}
}
if v, ok := sapruo.mutation.V4(); ok {
if err := scaauthpermissionrule.V4Validator(v); err != nil {
return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)}
}
}
if v, ok := sapruo.mutation.V5(); ok {
if err := scaauthpermissionrule.V5Validator(v); err != nil {
return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)}
}
}
return nil
}
func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthPermissionRule, err error) {
if err := sapruo.check(); err != nil {
return _node, err
}
_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`)}
}
_spec.Node.ID.Value = id
if fields := sapruo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.FieldID)
for _, f := range fields {
if !scaauthpermissionrule.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthpermissionrule.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := sapruo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
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)
}
if sapruo.mutation.V2Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV2, field.TypeString)
}
if value, ok := sapruo.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
}
if sapruo.mutation.V3Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV3, field.TypeString)
}
if value, ok := sapruo.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
}
if sapruo.mutation.V4Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV4, field.TypeString)
}
if value, ok := sapruo.mutation.V5(); ok {
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
}
if sapruo.mutation.V5Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString)
}
_node = &ScaAuthPermissionRule{config: sapruo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, sapruo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthpermissionrule.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
sapruo.mutation.done = true
return _node, nil
}

View File

@@ -1,151 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 角色表
type ScaAuthRole struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 角色名称
RoleName string `json:"role_name,omitempty"`
// 角色关键字
RoleKey string `json:"role_key,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthRole) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthrole.FieldID, scaauthrole.FieldDeleted:
values[i] = new(sql.NullInt64)
case scaauthrole.FieldRoleName, scaauthrole.FieldRoleKey:
values[i] = new(sql.NullString)
case scaauthrole.FieldCreatedAt, scaauthrole.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthRole fields.
func (sar *ScaAuthRole) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthrole.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
sar.ID = int64(value.Int64)
case scaauthrole.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
sar.CreatedAt = value.Time
}
case scaauthrole.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
sar.UpdatedAt = value.Time
}
case scaauthrole.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
sar.Deleted = int8(value.Int64)
}
case scaauthrole.FieldRoleName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field role_name", values[i])
} else if value.Valid {
sar.RoleName = value.String
}
case scaauthrole.FieldRoleKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field role_key", values[i])
} else if value.Valid {
sar.RoleKey = value.String
}
default:
sar.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthRole.
// This includes values selected through modifiers, order, etc.
func (sar *ScaAuthRole) Value(name string) (ent.Value, error) {
return sar.selectValues.Get(name)
}
// 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.
func (sar *ScaAuthRole) Update() *ScaAuthRoleUpdateOne {
return NewScaAuthRoleClient(sar.config).UpdateOne(sar)
}
// Unwrap unwraps the ScaAuthRole entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sar *ScaAuthRole) Unwrap() *ScaAuthRole {
_tx, ok := sar.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthRole is not a transactional entity")
}
sar.config.driver = _tx.drv
return sar
}
// String implements the fmt.Stringer.
func (sar *ScaAuthRole) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthRole(")
builder.WriteString(fmt.Sprintf("id=%v, ", sar.ID))
builder.WriteString("created_at=")
builder.WriteString(sar.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(sar.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", sar.Deleted))
builder.WriteString(", ")
builder.WriteString("role_name=")
builder.WriteString(sar.RoleName)
builder.WriteString(", ")
builder.WriteString("role_key=")
builder.WriteString(sar.RoleKey)
builder.WriteByte(')')
return builder.String()
}
// ScaAuthRoles is a parsable slice of ScaAuthRole.
type ScaAuthRoles []*ScaAuthRole

View File

@@ -1,96 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthrole
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scaauthrole type in the database.
Label = "sca_auth_role"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldRoleName holds the string denoting the role_name field in the database.
FieldRoleName = "role_name"
// FieldRoleKey holds the string denoting the role_key field in the database.
FieldRoleKey = "role_key"
// Table holds the table name of the scaauthrole in the database.
Table = "sca_auth_role"
)
// Columns holds all SQL columns for scaauthrole fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldRoleName,
FieldRoleKey,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// RoleNameValidator is a validator for the "role_name" field. It is called by the builders before save.
RoleNameValidator func(string) error
// RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save.
RoleKeyValidator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthRole queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByRoleName orders the results by the role_name field.
func ByRoleName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRoleName, opts...).ToFunc()
}
// ByRoleKey orders the results by the role_key field.
func ByRoleKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRoleKey, opts...).ToFunc()
}

View File

@@ -1,355 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthrole
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldUpdatedAt, v))
}
// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ.
func Deleted(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldDeleted, v))
}
// RoleName applies equality check predicate on the "role_name" field. It's identical to RoleNameEQ.
func RoleName(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleName, v))
}
// RoleKey applies equality check predicate on the "role_key" field. It's identical to RoleKeyEQ.
func RoleKey(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleKey, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldUpdatedAt, v))
}
// UpdatedAtIsNil applies the IsNil predicate on the "updated_at" field.
func UpdatedAtIsNil() predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIsNull(FieldUpdatedAt))
}
// UpdatedAtNotNil applies the NotNil predicate on the "updated_at" field.
func UpdatedAtNotNil() predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotNull(FieldUpdatedAt))
}
// DeletedEQ applies the EQ predicate on the "deleted" field.
func DeletedEQ(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldDeleted, v))
}
// DeletedNEQ applies the NEQ predicate on the "deleted" field.
func DeletedNEQ(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldDeleted, v))
}
// DeletedIn applies the In predicate on the "deleted" field.
func DeletedIn(vs ...int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldDeleted, vs...))
}
// DeletedNotIn applies the NotIn predicate on the "deleted" field.
func DeletedNotIn(vs ...int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldDeleted, vs...))
}
// DeletedGT applies the GT predicate on the "deleted" field.
func DeletedGT(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldDeleted, v))
}
// DeletedGTE applies the GTE predicate on the "deleted" field.
func DeletedGTE(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldDeleted, v))
}
// DeletedLT applies the LT predicate on the "deleted" field.
func DeletedLT(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldDeleted, v))
}
// DeletedLTE applies the LTE predicate on the "deleted" field.
func DeletedLTE(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldDeleted, v))
}
// RoleNameEQ applies the EQ predicate on the "role_name" field.
func RoleNameEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleName, v))
}
// RoleNameNEQ applies the NEQ predicate on the "role_name" field.
func RoleNameNEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldRoleName, v))
}
// RoleNameIn applies the In predicate on the "role_name" field.
func RoleNameIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldRoleName, vs...))
}
// RoleNameNotIn applies the NotIn predicate on the "role_name" field.
func RoleNameNotIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldRoleName, vs...))
}
// RoleNameGT applies the GT predicate on the "role_name" field.
func RoleNameGT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldRoleName, v))
}
// RoleNameGTE applies the GTE predicate on the "role_name" field.
func RoleNameGTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldRoleName, v))
}
// RoleNameLT applies the LT predicate on the "role_name" field.
func RoleNameLT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldRoleName, v))
}
// RoleNameLTE applies the LTE predicate on the "role_name" field.
func RoleNameLTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldRoleName, v))
}
// RoleNameContains applies the Contains predicate on the "role_name" field.
func RoleNameContains(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContains(FieldRoleName, v))
}
// RoleNameHasPrefix applies the HasPrefix predicate on the "role_name" field.
func RoleNameHasPrefix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasPrefix(FieldRoleName, v))
}
// RoleNameHasSuffix applies the HasSuffix predicate on the "role_name" field.
func RoleNameHasSuffix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasSuffix(FieldRoleName, v))
}
// RoleNameEqualFold applies the EqualFold predicate on the "role_name" field.
func RoleNameEqualFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEqualFold(FieldRoleName, v))
}
// RoleNameContainsFold applies the ContainsFold predicate on the "role_name" field.
func RoleNameContainsFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleName, v))
}
// RoleKeyEQ applies the EQ predicate on the "role_key" field.
func RoleKeyEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleKey, v))
}
// RoleKeyNEQ applies the NEQ predicate on the "role_key" field.
func RoleKeyNEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldRoleKey, v))
}
// RoleKeyIn applies the In predicate on the "role_key" field.
func RoleKeyIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldRoleKey, vs...))
}
// RoleKeyNotIn applies the NotIn predicate on the "role_key" field.
func RoleKeyNotIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldRoleKey, vs...))
}
// RoleKeyGT applies the GT predicate on the "role_key" field.
func RoleKeyGT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldRoleKey, v))
}
// RoleKeyGTE applies the GTE predicate on the "role_key" field.
func RoleKeyGTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldRoleKey, v))
}
// RoleKeyLT applies the LT predicate on the "role_key" field.
func RoleKeyLT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldRoleKey, v))
}
// RoleKeyLTE applies the LTE predicate on the "role_key" field.
func RoleKeyLTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldRoleKey, v))
}
// RoleKeyContains applies the Contains predicate on the "role_key" field.
func RoleKeyContains(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContains(FieldRoleKey, v))
}
// RoleKeyHasPrefix applies the HasPrefix predicate on the "role_key" field.
func RoleKeyHasPrefix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasPrefix(FieldRoleKey, v))
}
// RoleKeyHasSuffix applies the HasSuffix predicate on the "role_key" field.
func RoleKeyHasSuffix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasSuffix(FieldRoleKey, v))
}
// RoleKeyEqualFold applies the EqualFold predicate on the "role_key" field.
func RoleKeyEqualFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEqualFold(FieldRoleKey, v))
}
// RoleKeyContainsFold applies the ContainsFold predicate on the "role_key" field.
func RoleKeyContainsFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleKey, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaAuthRole) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.NotPredicates(p))
}

View File

@@ -1,298 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleCreate is the builder for creating a ScaAuthRole entity.
type ScaAuthRoleCreate struct {
config
mutation *ScaAuthRoleMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (sarc *ScaAuthRoleCreate) SetCreatedAt(t time.Time) *ScaAuthRoleCreate {
sarc.mutation.SetCreatedAt(t)
return sarc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sarc *ScaAuthRoleCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthRoleCreate {
if t != nil {
sarc.SetCreatedAt(*t)
}
return sarc
}
// SetUpdatedAt sets the "updated_at" field.
func (sarc *ScaAuthRoleCreate) SetUpdatedAt(t time.Time) *ScaAuthRoleCreate {
sarc.mutation.SetUpdatedAt(t)
return sarc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sarc *ScaAuthRoleCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthRoleCreate {
if t != nil {
sarc.SetUpdatedAt(*t)
}
return sarc
}
// SetDeleted sets the "deleted" field.
func (sarc *ScaAuthRoleCreate) SetDeleted(i int8) *ScaAuthRoleCreate {
sarc.mutation.SetDeleted(i)
return sarc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sarc *ScaAuthRoleCreate) SetNillableDeleted(i *int8) *ScaAuthRoleCreate {
if i != nil {
sarc.SetDeleted(*i)
}
return sarc
}
// SetRoleName sets the "role_name" field.
func (sarc *ScaAuthRoleCreate) SetRoleName(s string) *ScaAuthRoleCreate {
sarc.mutation.SetRoleName(s)
return sarc
}
// SetRoleKey sets the "role_key" field.
func (sarc *ScaAuthRoleCreate) SetRoleKey(s string) *ScaAuthRoleCreate {
sarc.mutation.SetRoleKey(s)
return sarc
}
// SetID sets the "id" field.
func (sarc *ScaAuthRoleCreate) SetID(i int64) *ScaAuthRoleCreate {
sarc.mutation.SetID(i)
return sarc
}
// Mutation returns the ScaAuthRoleMutation object of the builder.
func (sarc *ScaAuthRoleCreate) Mutation() *ScaAuthRoleMutation {
return sarc.mutation
}
// Save creates the ScaAuthRole in the database.
func (sarc *ScaAuthRoleCreate) Save(ctx context.Context) (*ScaAuthRole, error) {
sarc.defaults()
return withHooks(ctx, sarc.sqlSave, sarc.mutation, sarc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sarc *ScaAuthRoleCreate) SaveX(ctx context.Context) *ScaAuthRole {
v, err := sarc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sarc *ScaAuthRoleCreate) Exec(ctx context.Context) error {
_, err := sarc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sarc *ScaAuthRoleCreate) ExecX(ctx context.Context) {
if err := sarc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sarc *ScaAuthRoleCreate) defaults() {
if _, ok := sarc.mutation.CreatedAt(); !ok {
v := scaauthrole.DefaultCreatedAt()
sarc.mutation.SetCreatedAt(v)
}
if _, ok := sarc.mutation.Deleted(); !ok {
v := scaauthrole.DefaultDeleted
sarc.mutation.SetDeleted(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sarc *ScaAuthRoleCreate) check() error {
if _, ok := sarc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthRole.created_at"`)}
}
if _, ok := sarc.mutation.Deleted(); !ok {
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthRole.deleted"`)}
}
if v, ok := sarc.mutation.Deleted(); ok {
if err := scaauthrole.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.deleted": %w`, err)}
}
}
if _, ok := sarc.mutation.RoleName(); !ok {
return &ValidationError{Name: "role_name", err: errors.New(`ent: missing required field "ScaAuthRole.role_name"`)}
}
if v, ok := sarc.mutation.RoleName(); ok {
if err := scaauthrole.RoleNameValidator(v); err != nil {
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
}
}
if _, ok := sarc.mutation.RoleKey(); !ok {
return &ValidationError{Name: "role_key", err: errors.New(`ent: missing required field "ScaAuthRole.role_key"`)}
}
if v, ok := sarc.mutation.RoleKey(); ok {
if err := scaauthrole.RoleKeyValidator(v); err != nil {
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
}
}
return nil
}
func (sarc *ScaAuthRoleCreate) sqlSave(ctx context.Context) (*ScaAuthRole, error) {
if err := sarc.check(); err != nil {
return nil, err
}
_node, _spec := sarc.createSpec()
if err := sqlgraph.CreateNode(ctx, sarc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sarc.mutation.id = &_node.ID
sarc.mutation.done = true
return _node, nil
}
func (sarc *ScaAuthRoleCreate) createSpec() (*ScaAuthRole, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthRole{config: sarc.config}
_spec = sqlgraph.NewCreateSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
)
if id, ok := sarc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sarc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthrole.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sarc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthrole.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sarc.mutation.Deleted(); ok {
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := sarc.mutation.RoleName(); ok {
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
_node.RoleName = value
}
if value, ok := sarc.mutation.RoleKey(); ok {
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
_node.RoleKey = value
}
return _node, _spec
}
// ScaAuthRoleCreateBulk is the builder for creating many ScaAuthRole entities in bulk.
type ScaAuthRoleCreateBulk struct {
config
err error
builders []*ScaAuthRoleCreate
}
// Save creates the ScaAuthRole entities in the database.
func (sarcb *ScaAuthRoleCreateBulk) Save(ctx context.Context) ([]*ScaAuthRole, error) {
if sarcb.err != nil {
return nil, sarcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sarcb.builders))
nodes := make([]*ScaAuthRole, len(sarcb.builders))
mutators := make([]Mutator, len(sarcb.builders))
for i := range sarcb.builders {
func(i int, root context.Context) {
builder := sarcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthRoleMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sarcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sarcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sarcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sarcb *ScaAuthRoleCreateBulk) SaveX(ctx context.Context) []*ScaAuthRole {
v, err := sarcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sarcb *ScaAuthRoleCreateBulk) Exec(ctx context.Context) error {
_, err := sarcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sarcb *ScaAuthRoleCreateBulk) ExecX(ctx context.Context) {
if err := sarcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleDelete is the builder for deleting a ScaAuthRole entity.
type ScaAuthRoleDelete struct {
config
hooks []Hook
mutation *ScaAuthRoleMutation
}
// Where appends a list predicates to the ScaAuthRoleDelete builder.
func (sard *ScaAuthRoleDelete) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDelete {
sard.mutation.Where(ps...)
return sard
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (sard *ScaAuthRoleDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, sard.sqlExec, sard.mutation, sard.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (sard *ScaAuthRoleDelete) ExecX(ctx context.Context) int {
n, err := sard.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (sard *ScaAuthRoleDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
if ps := sard.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, sard.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
sard.mutation.done = true
return affected, err
}
// ScaAuthRoleDeleteOne is the builder for deleting a single ScaAuthRole entity.
type ScaAuthRoleDeleteOne struct {
sard *ScaAuthRoleDelete
}
// Where appends a list predicates to the ScaAuthRoleDelete builder.
func (sardo *ScaAuthRoleDeleteOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDeleteOne {
sardo.sard.mutation.Where(ps...)
return sardo
}
// Exec executes the deletion query.
func (sardo *ScaAuthRoleDeleteOne) Exec(ctx context.Context) error {
n, err := sardo.sard.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthrole.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sardo *ScaAuthRoleDeleteOne) ExecX(ctx context.Context) {
if err := sardo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleQuery is the builder for querying ScaAuthRole entities.
type ScaAuthRoleQuery struct {
config
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)
}
// Where adds a new predicate for the ScaAuthRoleQuery builder.
func (sarq *ScaAuthRoleQuery) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleQuery {
sarq.predicates = append(sarq.predicates, ps...)
return sarq
}
// Limit the number of records to be returned by this query.
func (sarq *ScaAuthRoleQuery) Limit(limit int) *ScaAuthRoleQuery {
sarq.ctx.Limit = &limit
return sarq
}
// Offset to start from.
func (sarq *ScaAuthRoleQuery) Offset(offset int) *ScaAuthRoleQuery {
sarq.ctx.Offset = &offset
return sarq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sarq *ScaAuthRoleQuery) Unique(unique bool) *ScaAuthRoleQuery {
sarq.ctx.Unique = &unique
return sarq
}
// Order specifies how the records should be ordered.
func (sarq *ScaAuthRoleQuery) Order(o ...scaauthrole.OrderOption) *ScaAuthRoleQuery {
sarq.order = append(sarq.order, o...)
return sarq
}
// 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) {
nodes, err := sarq.Limit(1).All(setContextOp(ctx, sarq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthrole.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) FirstX(ctx context.Context) *ScaAuthRole {
node, err := sarq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthRole ID from the query.
// Returns a *NotFoundError when no ScaAuthRole ID was found.
func (sarq *ScaAuthRoleQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sarq.Limit(1).IDs(setContextOp(ctx, sarq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthrole.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) FirstIDX(ctx context.Context) int64 {
id, err := sarq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthRole entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthRole entity is found.
// Returns a *NotFoundError when no ScaAuthRole entities are found.
func (sarq *ScaAuthRoleQuery) Only(ctx context.Context) (*ScaAuthRole, error) {
nodes, err := sarq.Limit(2).All(setContextOp(ctx, sarq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthrole.Label}
default:
return nil, &NotSingularError{scaauthrole.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) OnlyX(ctx context.Context) *ScaAuthRole {
node, err := sarq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthRole ID in the query.
// Returns a *NotSingularError when more than one ScaAuthRole ID is found.
// Returns a *NotFoundError when no entities are found.
func (sarq *ScaAuthRoleQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sarq.Limit(2).IDs(setContextOp(ctx, sarq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthrole.Label}
default:
err = &NotSingularError{scaauthrole.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sarq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthRoles.
func (sarq *ScaAuthRoleQuery) All(ctx context.Context) ([]*ScaAuthRole, error) {
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryAll)
if err := sarq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthRole, *ScaAuthRoleQuery]()
return withInterceptors[[]*ScaAuthRole](ctx, sarq, qr, sarq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) AllX(ctx context.Context) []*ScaAuthRole {
nodes, err := sarq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthRole IDs.
func (sarq *ScaAuthRoleQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sarq.ctx.Unique == nil && sarq.path != nil {
sarq.Unique(true)
}
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryIDs)
if err = sarq.Select(scaauthrole.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) IDsX(ctx context.Context) []int64 {
ids, err := sarq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sarq *ScaAuthRoleQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryCount)
if err := sarq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sarq, querierCount[*ScaAuthRoleQuery](), sarq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) CountX(ctx context.Context) int {
count, err := sarq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sarq *ScaAuthRoleQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryExist)
switch _, err := sarq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) ExistX(ctx context.Context) bool {
exist, err := sarq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthRoleQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sarq *ScaAuthRoleQuery) Clone() *ScaAuthRoleQuery {
if sarq == nil {
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...),
// clone intermediate query.
sql: sarq.sql.Clone(),
path: sarq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthRole.Query().
// GroupBy(scaauthrole.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sarq *ScaAuthRoleQuery) GroupBy(field string, fields ...string) *ScaAuthRoleGroupBy {
sarq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthRoleGroupBy{build: sarq}
grbuild.flds = &sarq.ctx.Fields
grbuild.label = scaauthrole.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthRole.Query().
// Select(scaauthrole.FieldCreatedAt).
// Scan(ctx, &v)
func (sarq *ScaAuthRoleQuery) Select(fields ...string) *ScaAuthRoleSelect {
sarq.ctx.Fields = append(sarq.ctx.Fields, fields...)
sbuild := &ScaAuthRoleSelect{ScaAuthRoleQuery: sarq}
sbuild.label = scaauthrole.Label
sbuild.flds, sbuild.scan = &sarq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthRoleSelect configured with the given aggregations.
func (sarq *ScaAuthRoleQuery) Aggregate(fns ...AggregateFunc) *ScaAuthRoleSelect {
return sarq.Select().Aggregate(fns...)
}
func (sarq *ScaAuthRoleQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sarq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sarq); err != nil {
return err
}
}
}
for _, f := range sarq.ctx.Fields {
if !scaauthrole.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sarq.path != nil {
prev, err := sarq.path(ctx)
if err != nil {
return err
}
sarq.sql = prev
}
return nil
}
func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthRole, error) {
var (
nodes = []*ScaAuthRole{}
_spec = sarq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthRole).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthRole{config: sarq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sarq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (sarq *ScaAuthRoleQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sarq.querySpec()
_spec.Node.Columns = sarq.ctx.Fields
if len(sarq.ctx.Fields) > 0 {
_spec.Unique = sarq.ctx.Unique != nil && *sarq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sarq.driver, _spec)
}
func (sarq *ScaAuthRoleQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
_spec.From = sarq.sql
if unique := sarq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sarq.path != nil {
_spec.Unique = true
}
if fields := sarq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID)
for i := range fields {
if fields[i] != scaauthrole.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sarq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sarq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sarq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sarq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sarq *ScaAuthRoleQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sarq.driver.Dialect())
t1 := builder.Table(scaauthrole.Table)
columns := sarq.ctx.Fields
if len(columns) == 0 {
columns = scaauthrole.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sarq.sql != nil {
selector = sarq.sql
selector.Select(selector.Columns(columns...)...)
}
if sarq.ctx.Unique != nil && *sarq.ctx.Unique {
selector.Distinct()
}
for _, p := range sarq.predicates {
p(selector)
}
for _, p := range sarq.order {
p(selector)
}
if offset := sarq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sarq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthRoleGroupBy is the group-by builder for ScaAuthRole entities.
type ScaAuthRoleGroupBy struct {
selector
build *ScaAuthRoleQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sargb *ScaAuthRoleGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthRoleGroupBy {
sargb.fns = append(sargb.fns, fns...)
return sargb
}
// Scan applies the selector query and scans the result into the given value.
func (sargb *ScaAuthRoleGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sargb.build.ctx, ent.OpQueryGroupBy)
if err := sargb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthRoleQuery, *ScaAuthRoleGroupBy](ctx, sargb.build, sargb, sargb.build.inters, v)
}
func (sargb *ScaAuthRoleGroupBy) sqlScan(ctx context.Context, root *ScaAuthRoleQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sargb.fns))
for _, fn := range sargb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sargb.flds)+len(sargb.fns))
for _, f := range *sargb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sargb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sargb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthRoleSelect is the builder for selecting fields of ScaAuthRole entities.
type ScaAuthRoleSelect struct {
*ScaAuthRoleQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sars *ScaAuthRoleSelect) Aggregate(fns ...AggregateFunc) *ScaAuthRoleSelect {
sars.fns = append(sars.fns, fns...)
return sars
}
// Scan applies the selector query and scans the result into the given value.
func (sars *ScaAuthRoleSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sars.ctx, ent.OpQuerySelect)
if err := sars.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthRoleQuery, *ScaAuthRoleSelect](ctx, sars.ScaAuthRoleQuery, sars, sars.inters, v)
}
func (sars *ScaAuthRoleSelect) sqlScan(ctx context.Context, root *ScaAuthRoleQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sars.fns))
for _, fn := range sars.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sars.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sars.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,398 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleUpdate is the builder for updating ScaAuthRole entities.
type ScaAuthRoleUpdate struct {
config
hooks []Hook
mutation *ScaAuthRoleMutation
}
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
func (saru *ScaAuthRoleUpdate) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdate {
saru.mutation.Where(ps...)
return saru
}
// SetUpdatedAt sets the "updated_at" field.
func (saru *ScaAuthRoleUpdate) SetUpdatedAt(t time.Time) *ScaAuthRoleUpdate {
saru.mutation.SetUpdatedAt(t)
return saru
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (saru *ScaAuthRoleUpdate) ClearUpdatedAt() *ScaAuthRoleUpdate {
saru.mutation.ClearUpdatedAt()
return saru
}
// SetDeleted sets the "deleted" field.
func (saru *ScaAuthRoleUpdate) SetDeleted(i int8) *ScaAuthRoleUpdate {
saru.mutation.ResetDeleted()
saru.mutation.SetDeleted(i)
return saru
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saru *ScaAuthRoleUpdate) SetNillableDeleted(i *int8) *ScaAuthRoleUpdate {
if i != nil {
saru.SetDeleted(*i)
}
return saru
}
// AddDeleted adds i to the "deleted" field.
func (saru *ScaAuthRoleUpdate) AddDeleted(i int8) *ScaAuthRoleUpdate {
saru.mutation.AddDeleted(i)
return saru
}
// SetRoleName sets the "role_name" field.
func (saru *ScaAuthRoleUpdate) SetRoleName(s string) *ScaAuthRoleUpdate {
saru.mutation.SetRoleName(s)
return saru
}
// SetNillableRoleName sets the "role_name" field if the given value is not nil.
func (saru *ScaAuthRoleUpdate) SetNillableRoleName(s *string) *ScaAuthRoleUpdate {
if s != nil {
saru.SetRoleName(*s)
}
return saru
}
// SetRoleKey sets the "role_key" field.
func (saru *ScaAuthRoleUpdate) SetRoleKey(s string) *ScaAuthRoleUpdate {
saru.mutation.SetRoleKey(s)
return saru
}
// SetNillableRoleKey sets the "role_key" field if the given value is not nil.
func (saru *ScaAuthRoleUpdate) SetNillableRoleKey(s *string) *ScaAuthRoleUpdate {
if s != nil {
saru.SetRoleKey(*s)
}
return saru
}
// Mutation returns the ScaAuthRoleMutation object of the builder.
func (saru *ScaAuthRoleUpdate) Mutation() *ScaAuthRoleMutation {
return saru.mutation
}
// 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()
return withHooks(ctx, saru.sqlSave, saru.mutation, saru.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (saru *ScaAuthRoleUpdate) SaveX(ctx context.Context) int {
affected, err := saru.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (saru *ScaAuthRoleUpdate) Exec(ctx context.Context) error {
_, err := saru.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saru *ScaAuthRoleUpdate) ExecX(ctx context.Context) {
if err := saru.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saru *ScaAuthRoleUpdate) defaults() {
if _, ok := saru.mutation.UpdatedAt(); !ok && !saru.mutation.UpdatedAtCleared() {
v := scaauthrole.UpdateDefaultUpdatedAt()
saru.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saru *ScaAuthRoleUpdate) check() error {
if v, ok := saru.mutation.Deleted(); ok {
if err := scaauthrole.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.deleted": %w`, err)}
}
}
if v, ok := saru.mutation.RoleName(); ok {
if err := scaauthrole.RoleNameValidator(v); err != nil {
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
}
}
if v, ok := saru.mutation.RoleKey(); ok {
if err := scaauthrole.RoleKeyValidator(v); err != nil {
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
}
}
return nil
}
func (saru *ScaAuthRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := saru.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
if ps := saru.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := saru.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthrole.FieldUpdatedAt, field.TypeTime, value)
}
if saru.mutation.UpdatedAtCleared() {
_spec.ClearField(scaauthrole.FieldUpdatedAt, field.TypeTime)
}
if value, ok := saru.mutation.Deleted(); ok {
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saru.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saru.mutation.RoleName(); ok {
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
}
if value, ok := saru.mutation.RoleKey(); ok {
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
}
if n, err = sqlgraph.UpdateNodes(ctx, saru.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthrole.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
saru.mutation.done = true
return n, nil
}
// ScaAuthRoleUpdateOne is the builder for updating a single ScaAuthRole entity.
type ScaAuthRoleUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthRoleMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (saruo *ScaAuthRoleUpdateOne) SetUpdatedAt(t time.Time) *ScaAuthRoleUpdateOne {
saruo.mutation.SetUpdatedAt(t)
return saruo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (saruo *ScaAuthRoleUpdateOne) ClearUpdatedAt() *ScaAuthRoleUpdateOne {
saruo.mutation.ClearUpdatedAt()
return saruo
}
// SetDeleted sets the "deleted" field.
func (saruo *ScaAuthRoleUpdateOne) SetDeleted(i int8) *ScaAuthRoleUpdateOne {
saruo.mutation.ResetDeleted()
saruo.mutation.SetDeleted(i)
return saruo
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saruo *ScaAuthRoleUpdateOne) SetNillableDeleted(i *int8) *ScaAuthRoleUpdateOne {
if i != nil {
saruo.SetDeleted(*i)
}
return saruo
}
// AddDeleted adds i to the "deleted" field.
func (saruo *ScaAuthRoleUpdateOne) AddDeleted(i int8) *ScaAuthRoleUpdateOne {
saruo.mutation.AddDeleted(i)
return saruo
}
// SetRoleName sets the "role_name" field.
func (saruo *ScaAuthRoleUpdateOne) SetRoleName(s string) *ScaAuthRoleUpdateOne {
saruo.mutation.SetRoleName(s)
return saruo
}
// SetNillableRoleName sets the "role_name" field if the given value is not nil.
func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleName(s *string) *ScaAuthRoleUpdateOne {
if s != nil {
saruo.SetRoleName(*s)
}
return saruo
}
// SetRoleKey sets the "role_key" field.
func (saruo *ScaAuthRoleUpdateOne) SetRoleKey(s string) *ScaAuthRoleUpdateOne {
saruo.mutation.SetRoleKey(s)
return saruo
}
// SetNillableRoleKey sets the "role_key" field if the given value is not nil.
func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleKey(s *string) *ScaAuthRoleUpdateOne {
if s != nil {
saruo.SetRoleKey(*s)
}
return saruo
}
// Mutation returns the ScaAuthRoleMutation object of the builder.
func (saruo *ScaAuthRoleUpdateOne) Mutation() *ScaAuthRoleMutation {
return saruo.mutation
}
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
func (saruo *ScaAuthRoleUpdateOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdateOne {
saruo.mutation.Where(ps...)
return saruo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (saruo *ScaAuthRoleUpdateOne) Select(field string, fields ...string) *ScaAuthRoleUpdateOne {
saruo.fields = append([]string{field}, fields...)
return saruo
}
// Save executes the query and returns the updated ScaAuthRole entity.
func (saruo *ScaAuthRoleUpdateOne) Save(ctx context.Context) (*ScaAuthRole, error) {
saruo.defaults()
return withHooks(ctx, saruo.sqlSave, saruo.mutation, saruo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (saruo *ScaAuthRoleUpdateOne) SaveX(ctx context.Context) *ScaAuthRole {
node, err := saruo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (saruo *ScaAuthRoleUpdateOne) Exec(ctx context.Context) error {
_, err := saruo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saruo *ScaAuthRoleUpdateOne) ExecX(ctx context.Context) {
if err := saruo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saruo *ScaAuthRoleUpdateOne) defaults() {
if _, ok := saruo.mutation.UpdatedAt(); !ok && !saruo.mutation.UpdatedAtCleared() {
v := scaauthrole.UpdateDefaultUpdatedAt()
saruo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saruo *ScaAuthRoleUpdateOne) check() error {
if v, ok := saruo.mutation.Deleted(); ok {
if err := scaauthrole.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.deleted": %w`, err)}
}
}
if v, ok := saruo.mutation.RoleName(); ok {
if err := scaauthrole.RoleNameValidator(v); err != nil {
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
}
}
if v, ok := saruo.mutation.RoleKey(); ok {
if err := scaauthrole.RoleKeyValidator(v); err != nil {
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
}
}
return nil
}
func (saruo *ScaAuthRoleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthRole, err error) {
if err := saruo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
id, ok := saruo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthRole.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := saruo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID)
for _, f := range fields {
if !scaauthrole.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthrole.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := saruo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := saruo.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthrole.FieldUpdatedAt, field.TypeTime, value)
}
if saruo.mutation.UpdatedAtCleared() {
_spec.ClearField(scaauthrole.FieldUpdatedAt, field.TypeTime)
}
if value, ok := saruo.mutation.Deleted(); ok {
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saruo.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saruo.mutation.RoleName(); ok {
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
}
if value, ok := saruo.mutation.RoleKey(); ok {
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
}
_node = &ScaAuthRole{config: saruo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, saruo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthrole.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
saruo.mutation.done = true
return _node, nil
}

View File

@@ -1,280 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户表
type ScaAuthUser struct {
config `json:"-"`
// ID of the ent.
// 自增ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 唯一ID
UID string `json:"uid,omitempty"`
// 用户名
Username string `json:"username,omitempty"`
// 昵称
Nickname string `json:"nickname,omitempty"`
// 邮箱
Email string `json:"email,omitempty"`
// 电话
Phone string `json:"phone,omitempty"`
// 密码
Password string `json:"-"`
// 性别
Gender int8 `json:"gender,omitempty"`
// 头像
Avatar string `json:"avatar,omitempty"`
// 状态 0 正常 1 封禁
Status int8 `json:"status,omitempty"`
// 介绍
Introduce string `json:"introduce,omitempty"`
// 博客
Blog *string `json:"blog,omitempty"`
// 地址
Location *string `json:"location,omitempty"`
// 公司
Company *string `json:"company,omitempty"`
selectValues sql.SelectValues
}
// 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.FieldGender, scaauthuser.FieldStatus:
values[i] = new(sql.NullInt64)
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)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUser fields.
func (sau *ScaAuthUser) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthuser.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
sau.ID = int64(value.Int64)
case scaauthuser.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
sau.CreatedAt = value.Time
}
case scaauthuser.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
sau.UpdatedAt = value.Time
}
case scaauthuser.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
sau.Deleted = int8(value.Int64)
}
case scaauthuser.FieldUID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uid", values[i])
} else if value.Valid {
sau.UID = value.String
}
case scaauthuser.FieldUsername:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field username", values[i])
} else if value.Valid {
sau.Username = value.String
}
case scaauthuser.FieldNickname:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field nickname", values[i])
} else if value.Valid {
sau.Nickname = value.String
}
case scaauthuser.FieldEmail:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field email", values[i])
} else if value.Valid {
sau.Email = value.String
}
case scaauthuser.FieldPhone:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field phone", values[i])
} else if value.Valid {
sau.Phone = value.String
}
case scaauthuser.FieldPassword:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field password", values[i])
} else if value.Valid {
sau.Password = value.String
}
case scaauthuser.FieldGender:
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 = int8(value.Int64)
}
case scaauthuser.FieldAvatar:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field avatar", values[i])
} else if value.Valid {
sau.Avatar = value.String
}
case scaauthuser.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
sau.Status = int8(value.Int64)
}
case scaauthuser.FieldIntroduce:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field introduce", values[i])
} else if value.Valid {
sau.Introduce = value.String
}
case scaauthuser.FieldBlog:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field blog", values[i])
} else if value.Valid {
sau.Blog = new(string)
*sau.Blog = value.String
}
case scaauthuser.FieldLocation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field location", values[i])
} else if value.Valid {
sau.Location = new(string)
*sau.Location = value.String
}
case scaauthuser.FieldCompany:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field company", values[i])
} else if value.Valid {
sau.Company = new(string)
*sau.Company = value.String
}
default:
sau.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUser.
// This includes values selected through modifiers, order, etc.
func (sau *ScaAuthUser) Value(name string) (ent.Value, error) {
return sau.selectValues.Get(name)
}
// 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.
func (sau *ScaAuthUser) Update() *ScaAuthUserUpdateOne {
return NewScaAuthUserClient(sau.config).UpdateOne(sau)
}
// Unwrap unwraps the ScaAuthUser entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sau *ScaAuthUser) Unwrap() *ScaAuthUser {
_tx, ok := sau.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUser is not a transactional entity")
}
sau.config.driver = _tx.drv
return sau
}
// String implements the fmt.Stringer.
func (sau *ScaAuthUser) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUser(")
builder.WriteString(fmt.Sprintf("id=%v, ", sau.ID))
builder.WriteString("created_at=")
builder.WriteString(sau.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(sau.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", sau.Deleted))
builder.WriteString(", ")
builder.WriteString("uid=")
builder.WriteString(sau.UID)
builder.WriteString(", ")
builder.WriteString("username=")
builder.WriteString(sau.Username)
builder.WriteString(", ")
builder.WriteString("nickname=")
builder.WriteString(sau.Nickname)
builder.WriteString(", ")
builder.WriteString("email=")
builder.WriteString(sau.Email)
builder.WriteString(", ")
builder.WriteString("phone=")
builder.WriteString(sau.Phone)
builder.WriteString(", ")
builder.WriteString("password=<sensitive>")
builder.WriteString(", ")
builder.WriteString("gender=")
builder.WriteString(fmt.Sprintf("%v", sau.Gender))
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(sau.Avatar)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", sau.Status))
builder.WriteString(", ")
builder.WriteString("introduce=")
builder.WriteString(sau.Introduce)
builder.WriteString(", ")
if v := sau.Blog; v != nil {
builder.WriteString("blog=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sau.Location; v != nil {
builder.WriteString("location=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sau.Company; v != nil {
builder.WriteString("company=")
builder.WriteString(*v)
}
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUsers is a parsable slice of ScaAuthUser.
type ScaAuthUsers []*ScaAuthUser

View File

@@ -1,202 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthuser
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scaauthuser type in the database.
Label = "sca_auth_user"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUID holds the string denoting the uid field in the database.
FieldUID = "uid"
// FieldUsername holds the string denoting the username field in the database.
FieldUsername = "username"
// FieldNickname holds the string denoting the nickname field in the database.
FieldNickname = "nickname"
// FieldEmail holds the string denoting the email field in the database.
FieldEmail = "email"
// FieldPhone holds the string denoting the phone field in the database.
FieldPhone = "phone"
// FieldPassword holds the string denoting the password field in the database.
FieldPassword = "password"
// FieldGender holds the string denoting the gender field in the database.
FieldGender = "gender"
// FieldAvatar holds the string denoting the avatar field in the database.
FieldAvatar = "avatar"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldIntroduce holds the string denoting the introduce field in the database.
FieldIntroduce = "introduce"
// FieldBlog holds the string denoting the blog field in the database.
FieldBlog = "blog"
// FieldLocation holds the string denoting the location field in the database.
FieldLocation = "location"
// FieldCompany holds the string denoting the company field in the database.
FieldCompany = "company"
// Table holds the table name of the scaauthuser in the database.
Table = "sca_auth_user"
)
// Columns holds all SQL columns for scaauthuser fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUID,
FieldUsername,
FieldNickname,
FieldEmail,
FieldPhone,
FieldPassword,
FieldGender,
FieldAvatar,
FieldStatus,
FieldIntroduce,
FieldBlog,
FieldLocation,
FieldCompany,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// UIDValidator is a validator for the "uid" field. It is called by the builders before save.
UIDValidator func(string) error
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
UsernameValidator func(string) error
// NicknameValidator is a validator for the "nickname" field. It is called by the builders before save.
NicknameValidator func(string) error
// EmailValidator is a validator for the "email" field. It is called by the builders before save.
EmailValidator func(string) error
// PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
PhoneValidator func(string) error
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
PasswordValidator 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.
IntroduceValidator func(string) error
// BlogValidator is a validator for the "blog" field. It is called by the builders before save.
BlogValidator func(string) error
// LocationValidator is a validator for the "location" field. It is called by the builders before save.
LocationValidator func(string) error
// CompanyValidator is a validator for the "company" field. It is called by the builders before save.
CompanyValidator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthUser queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUID orders the results by the uid field.
func ByUID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUID, opts...).ToFunc()
}
// ByUsername orders the results by the username field.
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUsername, opts...).ToFunc()
}
// ByNickname orders the results by the nickname field.
func ByNickname(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNickname, opts...).ToFunc()
}
// ByEmail orders the results by the email field.
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEmail, opts...).ToFunc()
}
// ByPhone orders the results by the phone field.
func ByPhone(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPhone, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByGender orders the results by the gender field.
func ByGender(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGender, opts...).ToFunc()
}
// ByAvatar orders the results by the avatar field.
func ByAvatar(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAvatar, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByIntroduce orders the results by the introduce field.
func ByIntroduce(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIntroduce, opts...).ToFunc()
}
// ByBlog orders the results by the blog field.
func ByBlog(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBlog, opts...).ToFunc()
}
// ByLocation orders the results by the location field.
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocation, opts...).ToFunc()
}
// ByCompany orders the results by the company field.
func ByCompany(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCompany, opts...).ToFunc()
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,545 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserCreate is the builder for creating a ScaAuthUser entity.
type ScaAuthUserCreate struct {
config
mutation *ScaAuthUserMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (sauc *ScaAuthUserCreate) SetCreatedAt(t time.Time) *ScaAuthUserCreate {
sauc.mutation.SetCreatedAt(t)
return sauc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserCreate {
if t != nil {
sauc.SetCreatedAt(*t)
}
return sauc
}
// SetUpdatedAt sets the "updated_at" field.
func (sauc *ScaAuthUserCreate) SetUpdatedAt(t time.Time) *ScaAuthUserCreate {
sauc.mutation.SetUpdatedAt(t)
return sauc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthUserCreate {
if t != nil {
sauc.SetUpdatedAt(*t)
}
return sauc
}
// SetDeleted sets the "deleted" field.
func (sauc *ScaAuthUserCreate) SetDeleted(i int8) *ScaAuthUserCreate {
sauc.mutation.SetDeleted(i)
return sauc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableDeleted(i *int8) *ScaAuthUserCreate {
if i != nil {
sauc.SetDeleted(*i)
}
return sauc
}
// SetUID sets the "uid" field.
func (sauc *ScaAuthUserCreate) SetUID(s string) *ScaAuthUserCreate {
sauc.mutation.SetUID(s)
return sauc
}
// SetUsername sets the "username" field.
func (sauc *ScaAuthUserCreate) SetUsername(s string) *ScaAuthUserCreate {
sauc.mutation.SetUsername(s)
return sauc
}
// SetNillableUsername sets the "username" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableUsername(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetUsername(*s)
}
return sauc
}
// SetNickname sets the "nickname" field.
func (sauc *ScaAuthUserCreate) SetNickname(s string) *ScaAuthUserCreate {
sauc.mutation.SetNickname(s)
return sauc
}
// SetNillableNickname sets the "nickname" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableNickname(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetNickname(*s)
}
return sauc
}
// SetEmail sets the "email" field.
func (sauc *ScaAuthUserCreate) SetEmail(s string) *ScaAuthUserCreate {
sauc.mutation.SetEmail(s)
return sauc
}
// SetNillableEmail sets the "email" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableEmail(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetEmail(*s)
}
return sauc
}
// SetPhone sets the "phone" field.
func (sauc *ScaAuthUserCreate) SetPhone(s string) *ScaAuthUserCreate {
sauc.mutation.SetPhone(s)
return sauc
}
// SetNillablePhone sets the "phone" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillablePhone(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetPhone(*s)
}
return sauc
}
// SetPassword sets the "password" field.
func (sauc *ScaAuthUserCreate) SetPassword(s string) *ScaAuthUserCreate {
sauc.mutation.SetPassword(s)
return sauc
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillablePassword(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetPassword(*s)
}
return sauc
}
// SetGender sets the "gender" field.
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(i *int8) *ScaAuthUserCreate {
if i != nil {
sauc.SetGender(*i)
}
return sauc
}
// SetAvatar sets the "avatar" field.
func (sauc *ScaAuthUserCreate) SetAvatar(s string) *ScaAuthUserCreate {
sauc.mutation.SetAvatar(s)
return sauc
}
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableAvatar(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetAvatar(*s)
}
return sauc
}
// SetStatus sets the "status" field.
func (sauc *ScaAuthUserCreate) SetStatus(i int8) *ScaAuthUserCreate {
sauc.mutation.SetStatus(i)
return sauc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableStatus(i *int8) *ScaAuthUserCreate {
if i != nil {
sauc.SetStatus(*i)
}
return sauc
}
// SetIntroduce sets the "introduce" field.
func (sauc *ScaAuthUserCreate) SetIntroduce(s string) *ScaAuthUserCreate {
sauc.mutation.SetIntroduce(s)
return sauc
}
// SetNillableIntroduce sets the "introduce" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableIntroduce(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetIntroduce(*s)
}
return sauc
}
// SetBlog sets the "blog" field.
func (sauc *ScaAuthUserCreate) SetBlog(s string) *ScaAuthUserCreate {
sauc.mutation.SetBlog(s)
return sauc
}
// SetNillableBlog sets the "blog" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableBlog(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetBlog(*s)
}
return sauc
}
// SetLocation sets the "location" field.
func (sauc *ScaAuthUserCreate) SetLocation(s string) *ScaAuthUserCreate {
sauc.mutation.SetLocation(s)
return sauc
}
// SetNillableLocation sets the "location" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableLocation(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetLocation(*s)
}
return sauc
}
// SetCompany sets the "company" field.
func (sauc *ScaAuthUserCreate) SetCompany(s string) *ScaAuthUserCreate {
sauc.mutation.SetCompany(s)
return sauc
}
// SetNillableCompany sets the "company" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableCompany(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetCompany(*s)
}
return sauc
}
// SetID sets the "id" field.
func (sauc *ScaAuthUserCreate) SetID(i int64) *ScaAuthUserCreate {
sauc.mutation.SetID(i)
return sauc
}
// Mutation returns the ScaAuthUserMutation object of the builder.
func (sauc *ScaAuthUserCreate) Mutation() *ScaAuthUserMutation {
return sauc.mutation
}
// Save creates the ScaAuthUser in the database.
func (sauc *ScaAuthUserCreate) Save(ctx context.Context) (*ScaAuthUser, error) {
sauc.defaults()
return withHooks(ctx, sauc.sqlSave, sauc.mutation, sauc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sauc *ScaAuthUserCreate) SaveX(ctx context.Context) *ScaAuthUser {
v, err := sauc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sauc *ScaAuthUserCreate) Exec(ctx context.Context) error {
_, err := sauc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sauc *ScaAuthUserCreate) ExecX(ctx context.Context) {
if err := sauc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sauc *ScaAuthUserCreate) defaults() {
if _, ok := sauc.mutation.CreatedAt(); !ok {
v := scaauthuser.DefaultCreatedAt()
sauc.mutation.SetCreatedAt(v)
}
if _, ok := sauc.mutation.Deleted(); !ok {
v := scaauthuser.DefaultDeleted
sauc.mutation.SetDeleted(v)
}
if _, ok := sauc.mutation.Status(); !ok {
v := scaauthuser.DefaultStatus
sauc.mutation.SetStatus(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sauc *ScaAuthUserCreate) check() error {
if _, ok := sauc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUser.created_at"`)}
}
if _, ok := sauc.mutation.Deleted(); !ok {
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthUser.deleted"`)}
}
if v, ok := sauc.mutation.Deleted(); ok {
if err := scaauthuser.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.deleted": %w`, err)}
}
}
if _, ok := sauc.mutation.UID(); !ok {
return &ValidationError{Name: "uid", err: errors.New(`ent: missing required field "ScaAuthUser.uid"`)}
}
if v, ok := sauc.mutation.UID(); ok {
if err := scaauthuser.UIDValidator(v); err != nil {
return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)}
}
}
if v, ok := sauc.mutation.Username(); ok {
if err := scaauthuser.UsernameValidator(v); err != nil {
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)}
}
}
if v, ok := sauc.mutation.Nickname(); ok {
if err := scaauthuser.NicknameValidator(v); err != nil {
return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)}
}
}
if v, ok := sauc.mutation.Email(); ok {
if err := scaauthuser.EmailValidator(v); err != nil {
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)}
}
}
if v, ok := sauc.mutation.Phone(); ok {
if err := scaauthuser.PhoneValidator(v); err != nil {
return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)}
}
}
if v, ok := sauc.mutation.Password(); ok {
if err := scaauthuser.PasswordValidator(v); err != nil {
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %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)}
}
}
if v, ok := sauc.mutation.Blog(); ok {
if err := scaauthuser.BlogValidator(v); err != nil {
return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)}
}
}
if v, ok := sauc.mutation.Location(); ok {
if err := scaauthuser.LocationValidator(v); err != nil {
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)}
}
}
if v, ok := sauc.mutation.Company(); ok {
if err := scaauthuser.CompanyValidator(v); err != nil {
return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)}
}
}
return nil
}
func (sauc *ScaAuthUserCreate) sqlSave(ctx context.Context) (*ScaAuthUser, error) {
if err := sauc.check(); err != nil {
return nil, err
}
_node, _spec := sauc.createSpec()
if err := sqlgraph.CreateNode(ctx, sauc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sauc.mutation.id = &_node.ID
sauc.mutation.done = true
return _node, nil
}
func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthUser{config: sauc.config}
_spec = sqlgraph.NewCreateSpec(scaauthuser.Table, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64))
)
if id, ok := sauc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sauc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthuser.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sauc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthuser.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sauc.mutation.Deleted(); ok {
_spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := sauc.mutation.UID(); ok {
_spec.SetField(scaauthuser.FieldUID, field.TypeString, value)
_node.UID = value
}
if value, ok := sauc.mutation.Username(); ok {
_spec.SetField(scaauthuser.FieldUsername, field.TypeString, value)
_node.Username = value
}
if value, ok := sauc.mutation.Nickname(); ok {
_spec.SetField(scaauthuser.FieldNickname, field.TypeString, value)
_node.Nickname = value
}
if value, ok := sauc.mutation.Email(); ok {
_spec.SetField(scaauthuser.FieldEmail, field.TypeString, value)
_node.Email = value
}
if value, ok := sauc.mutation.Phone(); ok {
_spec.SetField(scaauthuser.FieldPhone, field.TypeString, value)
_node.Phone = value
}
if value, ok := sauc.mutation.Password(); ok {
_spec.SetField(scaauthuser.FieldPassword, field.TypeString, value)
_node.Password = value
}
if value, ok := sauc.mutation.Gender(); ok {
_spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
_node.Gender = value
}
if value, ok := sauc.mutation.Avatar(); ok {
_spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value)
_node.Avatar = value
}
if value, ok := sauc.mutation.Status(); ok {
_spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value)
_node.Status = value
}
if value, ok := sauc.mutation.Introduce(); ok {
_spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value)
_node.Introduce = value
}
if value, ok := sauc.mutation.Blog(); ok {
_spec.SetField(scaauthuser.FieldBlog, field.TypeString, value)
_node.Blog = &value
}
if value, ok := sauc.mutation.Location(); ok {
_spec.SetField(scaauthuser.FieldLocation, field.TypeString, value)
_node.Location = &value
}
if value, ok := sauc.mutation.Company(); ok {
_spec.SetField(scaauthuser.FieldCompany, field.TypeString, value)
_node.Company = &value
}
return _node, _spec
}
// ScaAuthUserCreateBulk is the builder for creating many ScaAuthUser entities in bulk.
type ScaAuthUserCreateBulk struct {
config
err error
builders []*ScaAuthUserCreate
}
// Save creates the ScaAuthUser entities in the database.
func (saucb *ScaAuthUserCreateBulk) Save(ctx context.Context) ([]*ScaAuthUser, error) {
if saucb.err != nil {
return nil, saucb.err
}
specs := make([]*sqlgraph.CreateSpec, len(saucb.builders))
nodes := make([]*ScaAuthUser, len(saucb.builders))
mutators := make([]Mutator, len(saucb.builders))
for i := range saucb.builders {
func(i int, root context.Context) {
builder := saucb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthUserMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, saucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, saucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, saucb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (saucb *ScaAuthUserCreateBulk) SaveX(ctx context.Context) []*ScaAuthUser {
v, err := saucb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saucb *ScaAuthUserCreateBulk) Exec(ctx context.Context) error {
_, err := saucb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saucb *ScaAuthUserCreateBulk) ExecX(ctx context.Context) {
if err := saucb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDelete is the builder for deleting a ScaAuthUser entity.
type ScaAuthUserDelete struct {
config
hooks []Hook
mutation *ScaAuthUserMutation
}
// Where appends a list predicates to the ScaAuthUserDelete builder.
func (saud *ScaAuthUserDelete) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserDelete {
saud.mutation.Where(ps...)
return saud
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (saud *ScaAuthUserDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, saud.sqlExec, saud.mutation, saud.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (saud *ScaAuthUserDelete) ExecX(ctx context.Context) int {
n, err := saud.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (saud *ScaAuthUserDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthuser.Table, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64))
if ps := saud.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, saud.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
saud.mutation.done = true
return affected, err
}
// ScaAuthUserDeleteOne is the builder for deleting a single ScaAuthUser entity.
type ScaAuthUserDeleteOne struct {
saud *ScaAuthUserDelete
}
// Where appends a list predicates to the ScaAuthUserDelete builder.
func (saudo *ScaAuthUserDeleteOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserDeleteOne {
saudo.saud.mutation.Where(ps...)
return saudo
}
// Exec executes the deletion query.
func (saudo *ScaAuthUserDeleteOne) Exec(ctx context.Context) error {
n, err := saudo.saud.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthuser.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (saudo *ScaAuthUserDeleteOne) ExecX(ctx context.Context) {
if err := saudo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserQuery is the builder for querying ScaAuthUser entities.
type ScaAuthUserQuery struct {
config
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)
}
// Where adds a new predicate for the ScaAuthUserQuery builder.
func (sauq *ScaAuthUserQuery) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserQuery {
sauq.predicates = append(sauq.predicates, ps...)
return sauq
}
// Limit the number of records to be returned by this query.
func (sauq *ScaAuthUserQuery) Limit(limit int) *ScaAuthUserQuery {
sauq.ctx.Limit = &limit
return sauq
}
// Offset to start from.
func (sauq *ScaAuthUserQuery) Offset(offset int) *ScaAuthUserQuery {
sauq.ctx.Offset = &offset
return sauq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sauq *ScaAuthUserQuery) Unique(unique bool) *ScaAuthUserQuery {
sauq.ctx.Unique = &unique
return sauq
}
// Order specifies how the records should be ordered.
func (sauq *ScaAuthUserQuery) Order(o ...scaauthuser.OrderOption) *ScaAuthUserQuery {
sauq.order = append(sauq.order, o...)
return sauq
}
// 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) {
nodes, err := sauq.Limit(1).All(setContextOp(ctx, sauq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthuser.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) FirstX(ctx context.Context) *ScaAuthUser {
node, err := sauq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthUser ID from the query.
// Returns a *NotFoundError when no ScaAuthUser ID was found.
func (sauq *ScaAuthUserQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sauq.Limit(1).IDs(setContextOp(ctx, sauq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthuser.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) FirstIDX(ctx context.Context) int64 {
id, err := sauq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthUser entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthUser entity is found.
// Returns a *NotFoundError when no ScaAuthUser entities are found.
func (sauq *ScaAuthUserQuery) Only(ctx context.Context) (*ScaAuthUser, error) {
nodes, err := sauq.Limit(2).All(setContextOp(ctx, sauq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthuser.Label}
default:
return nil, &NotSingularError{scaauthuser.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) OnlyX(ctx context.Context) *ScaAuthUser {
node, err := sauq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthUser ID in the query.
// Returns a *NotSingularError when more than one ScaAuthUser ID is found.
// Returns a *NotFoundError when no entities are found.
func (sauq *ScaAuthUserQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sauq.Limit(2).IDs(setContextOp(ctx, sauq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthuser.Label}
default:
err = &NotSingularError{scaauthuser.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sauq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthUsers.
func (sauq *ScaAuthUserQuery) All(ctx context.Context) ([]*ScaAuthUser, error) {
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryAll)
if err := sauq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthUser, *ScaAuthUserQuery]()
return withInterceptors[[]*ScaAuthUser](ctx, sauq, qr, sauq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) AllX(ctx context.Context) []*ScaAuthUser {
nodes, err := sauq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthUser IDs.
func (sauq *ScaAuthUserQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sauq.ctx.Unique == nil && sauq.path != nil {
sauq.Unique(true)
}
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryIDs)
if err = sauq.Select(scaauthuser.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) IDsX(ctx context.Context) []int64 {
ids, err := sauq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sauq *ScaAuthUserQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryCount)
if err := sauq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sauq, querierCount[*ScaAuthUserQuery](), sauq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) CountX(ctx context.Context) int {
count, err := sauq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sauq *ScaAuthUserQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryExist)
switch _, err := sauq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) ExistX(ctx context.Context) bool {
exist, err := sauq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthUserQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sauq *ScaAuthUserQuery) Clone() *ScaAuthUserQuery {
if sauq == nil {
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...),
// clone intermediate query.
sql: sauq.sql.Clone(),
path: sauq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthUser.Query().
// GroupBy(scaauthuser.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sauq *ScaAuthUserQuery) GroupBy(field string, fields ...string) *ScaAuthUserGroupBy {
sauq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthUserGroupBy{build: sauq}
grbuild.flds = &sauq.ctx.Fields
grbuild.label = scaauthuser.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthUser.Query().
// Select(scaauthuser.FieldCreatedAt).
// Scan(ctx, &v)
func (sauq *ScaAuthUserQuery) Select(fields ...string) *ScaAuthUserSelect {
sauq.ctx.Fields = append(sauq.ctx.Fields, fields...)
sbuild := &ScaAuthUserSelect{ScaAuthUserQuery: sauq}
sbuild.label = scaauthuser.Label
sbuild.flds, sbuild.scan = &sauq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthUserSelect configured with the given aggregations.
func (sauq *ScaAuthUserQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSelect {
return sauq.Select().Aggregate(fns...)
}
func (sauq *ScaAuthUserQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sauq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sauq); err != nil {
return err
}
}
}
for _, f := range sauq.ctx.Fields {
if !scaauthuser.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sauq.path != nil {
prev, err := sauq.path(ctx)
if err != nil {
return err
}
sauq.sql = prev
}
return nil
}
func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUser, error) {
var (
nodes = []*ScaAuthUser{}
_spec = sauq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthUser).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaAuthUser{config: sauq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sauq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (sauq *ScaAuthUserQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sauq.querySpec()
_spec.Node.Columns = sauq.ctx.Fields
if len(sauq.ctx.Fields) > 0 {
_spec.Unique = sauq.ctx.Unique != nil && *sauq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sauq.driver, _spec)
}
func (sauq *ScaAuthUserQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64))
_spec.From = sauq.sql
if unique := sauq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sauq.path != nil {
_spec.Unique = true
}
if fields := sauq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthuser.FieldID)
for i := range fields {
if fields[i] != scaauthuser.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sauq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sauq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sauq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sauq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sauq *ScaAuthUserQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sauq.driver.Dialect())
t1 := builder.Table(scaauthuser.Table)
columns := sauq.ctx.Fields
if len(columns) == 0 {
columns = scaauthuser.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sauq.sql != nil {
selector = sauq.sql
selector.Select(selector.Columns(columns...)...)
}
if sauq.ctx.Unique != nil && *sauq.ctx.Unique {
selector.Distinct()
}
for _, p := range sauq.predicates {
p(selector)
}
for _, p := range sauq.order {
p(selector)
}
if offset := sauq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sauq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthUserGroupBy is the group-by builder for ScaAuthUser entities.
type ScaAuthUserGroupBy struct {
selector
build *ScaAuthUserQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (saugb *ScaAuthUserGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserGroupBy {
saugb.fns = append(saugb.fns, fns...)
return saugb
}
// Scan applies the selector query and scans the result into the given value.
func (saugb *ScaAuthUserGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saugb.build.ctx, ent.OpQueryGroupBy)
if err := saugb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserQuery, *ScaAuthUserGroupBy](ctx, saugb.build, saugb, saugb.build.inters, v)
}
func (saugb *ScaAuthUserGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(saugb.fns))
for _, fn := range saugb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*saugb.flds)+len(saugb.fns))
for _, f := range *saugb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*saugb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saugb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthUserSelect is the builder for selecting fields of ScaAuthUser entities.
type ScaAuthUserSelect struct {
*ScaAuthUserQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (saus *ScaAuthUserSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSelect {
saus.fns = append(saus.fns, fns...)
return saus
}
// Scan applies the selector query and scans the result into the given value.
func (saus *ScaAuthUserSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saus.ctx, ent.OpQuerySelect)
if err := saus.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserQuery, *ScaAuthUserSelect](ctx, saus.ScaAuthUserQuery, saus, saus.inters, v)
}
func (saus *ScaAuthUserSelect) sqlScan(ctx context.Context, root *ScaAuthUserQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(saus.fns))
for _, fn := range saus.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*saus.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saus.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,274 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户设备表
type ScaAuthUserDevice struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 用户ID
UserID string `json:"user_id,omitempty"`
// 登录IP
IP string `json:"ip,omitempty"`
// 地址
Location string `json:"location,omitempty"`
// 设备信息
Agent string `json:"agent,omitempty"`
// 浏览器
Browser string `json:"browser,omitempty"`
// 操作系统
OperatingSystem string `json:"operating_system,omitempty"`
// 浏览器版本
BrowserVersion string `json:"browser_version,omitempty"`
// 是否为手机 0否1是
Mobile bool `json:"mobile,omitempty"`
// 是否为bot 0否1是
Bot bool `json:"bot,omitempty"`
// 火狐版本
Mozilla string `json:"mozilla,omitempty"`
// 平台
Platform string `json:"platform,omitempty"`
// 引擎名称
EngineName string `json:"engine_name,omitempty"`
// 引擎版本
EngineVersion string `json:"engine_version,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthUserDevice) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthuserdevice.FieldMobile, scaauthuserdevice.FieldBot:
values[i] = new(sql.NullBool)
case scaauthuserdevice.FieldID, scaauthuserdevice.FieldDeleted:
values[i] = new(sql.NullInt64)
case scaauthuserdevice.FieldUserID, scaauthuserdevice.FieldIP, scaauthuserdevice.FieldLocation, scaauthuserdevice.FieldAgent, scaauthuserdevice.FieldBrowser, scaauthuserdevice.FieldOperatingSystem, scaauthuserdevice.FieldBrowserVersion, scaauthuserdevice.FieldMozilla, scaauthuserdevice.FieldPlatform, scaauthuserdevice.FieldEngineName, scaauthuserdevice.FieldEngineVersion:
values[i] = new(sql.NullString)
case scaauthuserdevice.FieldCreatedAt, scaauthuserdevice.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUserDevice fields.
func (saud *ScaAuthUserDevice) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthuserdevice.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
saud.ID = int64(value.Int64)
case scaauthuserdevice.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
saud.CreatedAt = value.Time
}
case scaauthuserdevice.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
saud.UpdatedAt = value.Time
}
case scaauthuserdevice.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
saud.Deleted = int8(value.Int64)
}
case scaauthuserdevice.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
saud.UserID = value.String
}
case scaauthuserdevice.FieldIP:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field ip", values[i])
} else if value.Valid {
saud.IP = value.String
}
case scaauthuserdevice.FieldLocation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field location", values[i])
} else if value.Valid {
saud.Location = value.String
}
case scaauthuserdevice.FieldAgent:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field agent", values[i])
} else if value.Valid {
saud.Agent = value.String
}
case scaauthuserdevice.FieldBrowser:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field browser", values[i])
} else if value.Valid {
saud.Browser = value.String
}
case scaauthuserdevice.FieldOperatingSystem:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field operating_system", values[i])
} else if value.Valid {
saud.OperatingSystem = value.String
}
case scaauthuserdevice.FieldBrowserVersion:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field browser_version", values[i])
} else if value.Valid {
saud.BrowserVersion = value.String
}
case scaauthuserdevice.FieldMobile:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field mobile", values[i])
} else if value.Valid {
saud.Mobile = value.Bool
}
case scaauthuserdevice.FieldBot:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field bot", values[i])
} else if value.Valid {
saud.Bot = value.Bool
}
case scaauthuserdevice.FieldMozilla:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field mozilla", values[i])
} else if value.Valid {
saud.Mozilla = value.String
}
case scaauthuserdevice.FieldPlatform:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field platform", values[i])
} else if value.Valid {
saud.Platform = value.String
}
case scaauthuserdevice.FieldEngineName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field engine_name", values[i])
} else if value.Valid {
saud.EngineName = value.String
}
case scaauthuserdevice.FieldEngineVersion:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field engine_version", values[i])
} else if value.Valid {
saud.EngineVersion = value.String
}
default:
saud.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserDevice.
// This includes values selected through modifiers, order, etc.
func (saud *ScaAuthUserDevice) Value(name string) (ent.Value, error) {
return saud.selectValues.Get(name)
}
// 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.
func (saud *ScaAuthUserDevice) Update() *ScaAuthUserDeviceUpdateOne {
return NewScaAuthUserDeviceClient(saud.config).UpdateOne(saud)
}
// Unwrap unwraps the ScaAuthUserDevice entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (saud *ScaAuthUserDevice) Unwrap() *ScaAuthUserDevice {
_tx, ok := saud.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUserDevice is not a transactional entity")
}
saud.config.driver = _tx.drv
return saud
}
// String implements the fmt.Stringer.
func (saud *ScaAuthUserDevice) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUserDevice(")
builder.WriteString(fmt.Sprintf("id=%v, ", saud.ID))
builder.WriteString("created_at=")
builder.WriteString(saud.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(saud.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", saud.Deleted))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(saud.UserID)
builder.WriteString(", ")
builder.WriteString("ip=")
builder.WriteString(saud.IP)
builder.WriteString(", ")
builder.WriteString("location=")
builder.WriteString(saud.Location)
builder.WriteString(", ")
builder.WriteString("agent=")
builder.WriteString(saud.Agent)
builder.WriteString(", ")
builder.WriteString("browser=")
builder.WriteString(saud.Browser)
builder.WriteString(", ")
builder.WriteString("operating_system=")
builder.WriteString(saud.OperatingSystem)
builder.WriteString(", ")
builder.WriteString("browser_version=")
builder.WriteString(saud.BrowserVersion)
builder.WriteString(", ")
builder.WriteString("mobile=")
builder.WriteString(fmt.Sprintf("%v", saud.Mobile))
builder.WriteString(", ")
builder.WriteString("bot=")
builder.WriteString(fmt.Sprintf("%v", saud.Bot))
builder.WriteString(", ")
builder.WriteString("mozilla=")
builder.WriteString(saud.Mozilla)
builder.WriteString(", ")
builder.WriteString("platform=")
builder.WriteString(saud.Platform)
builder.WriteString(", ")
builder.WriteString("engine_name=")
builder.WriteString(saud.EngineName)
builder.WriteString(", ")
builder.WriteString("engine_version=")
builder.WriteString(saud.EngineVersion)
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUserDevices is a parsable slice of ScaAuthUserDevice.
type ScaAuthUserDevices []*ScaAuthUserDevice

View File

@@ -1,202 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthuserdevice
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scaauthuserdevice type in the database.
Label = "sca_auth_user_device"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldIP holds the string denoting the ip field in the database.
FieldIP = "ip"
// FieldLocation holds the string denoting the location field in the database.
FieldLocation = "location"
// FieldAgent holds the string denoting the agent field in the database.
FieldAgent = "agent"
// FieldBrowser holds the string denoting the browser field in the database.
FieldBrowser = "browser"
// FieldOperatingSystem holds the string denoting the operating_system field in the database.
FieldOperatingSystem = "operating_system"
// FieldBrowserVersion holds the string denoting the browser_version field in the database.
FieldBrowserVersion = "browser_version"
// FieldMobile holds the string denoting the mobile field in the database.
FieldMobile = "mobile"
// FieldBot holds the string denoting the bot field in the database.
FieldBot = "bot"
// FieldMozilla holds the string denoting the mozilla field in the database.
FieldMozilla = "mozilla"
// FieldPlatform holds the string denoting the platform field in the database.
FieldPlatform = "platform"
// FieldEngineName holds the string denoting the engine_name field in the database.
FieldEngineName = "engine_name"
// FieldEngineVersion holds the string denoting the engine_version field in the database.
FieldEngineVersion = "engine_version"
// Table holds the table name of the scaauthuserdevice in the database.
Table = "sca_auth_user_device"
)
// Columns holds all SQL columns for scaauthuserdevice fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUserID,
FieldIP,
FieldLocation,
FieldAgent,
FieldBrowser,
FieldOperatingSystem,
FieldBrowserVersion,
FieldMobile,
FieldBot,
FieldMozilla,
FieldPlatform,
FieldEngineName,
FieldEngineVersion,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
UserIDValidator func(string) error
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
IPValidator func(string) error
// LocationValidator is a validator for the "location" field. It is called by the builders before save.
LocationValidator func(string) error
// AgentValidator is a validator for the "agent" field. It is called by the builders before save.
AgentValidator func(string) error
// BrowserValidator is a validator for the "browser" field. It is called by the builders before save.
BrowserValidator func(string) error
// OperatingSystemValidator is a validator for the "operating_system" field. It is called by the builders before save.
OperatingSystemValidator func(string) error
// BrowserVersionValidator is a validator for the "browser_version" field. It is called by the builders before save.
BrowserVersionValidator func(string) error
// MozillaValidator is a validator for the "mozilla" field. It is called by the builders before save.
MozillaValidator func(string) error
// PlatformValidator is a validator for the "platform" field. It is called by the builders before save.
PlatformValidator func(string) error
// EngineNameValidator is a validator for the "engine_name" field. It is called by the builders before save.
EngineNameValidator func(string) error
// EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save.
EngineVersionValidator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthUserDevice queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByIP orders the results by the ip field.
func ByIP(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIP, opts...).ToFunc()
}
// ByLocation orders the results by the location field.
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocation, opts...).ToFunc()
}
// ByAgent orders the results by the agent field.
func ByAgent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAgent, opts...).ToFunc()
}
// ByBrowser orders the results by the browser field.
func ByBrowser(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBrowser, opts...).ToFunc()
}
// ByOperatingSystem orders the results by the operating_system field.
func ByOperatingSystem(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperatingSystem, opts...).ToFunc()
}
// ByBrowserVersion orders the results by the browser_version field.
func ByBrowserVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBrowserVersion, opts...).ToFunc()
}
// ByMobile orders the results by the mobile field.
func ByMobile(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMobile, opts...).ToFunc()
}
// ByBot orders the results by the bot field.
func ByBot(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBot, opts...).ToFunc()
}
// ByMozilla orders the results by the mozilla field.
func ByMozilla(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMozilla, opts...).ToFunc()
}
// ByPlatform orders the results by the platform field.
func ByPlatform(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlatform, opts...).ToFunc()
}
// ByEngineName orders the results by the engine_name field.
func ByEngineName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEngineName, opts...).ToFunc()
}
// ByEngineVersion orders the results by the engine_version field.
func ByEngineVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEngineVersion, opts...).ToFunc()
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,486 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDeviceCreate is the builder for creating a ScaAuthUserDevice entity.
type ScaAuthUserDeviceCreate struct {
config
mutation *ScaAuthUserDeviceMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (saudc *ScaAuthUserDeviceCreate) SetCreatedAt(t time.Time) *ScaAuthUserDeviceCreate {
saudc.mutation.SetCreatedAt(t)
return saudc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (saudc *ScaAuthUserDeviceCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserDeviceCreate {
if t != nil {
saudc.SetCreatedAt(*t)
}
return saudc
}
// SetUpdatedAt sets the "updated_at" field.
func (saudc *ScaAuthUserDeviceCreate) SetUpdatedAt(t time.Time) *ScaAuthUserDeviceCreate {
saudc.mutation.SetUpdatedAt(t)
return saudc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (saudc *ScaAuthUserDeviceCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthUserDeviceCreate {
if t != nil {
saudc.SetUpdatedAt(*t)
}
return saudc
}
// SetDeleted sets the "deleted" field.
func (saudc *ScaAuthUserDeviceCreate) SetDeleted(i int8) *ScaAuthUserDeviceCreate {
saudc.mutation.SetDeleted(i)
return saudc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saudc *ScaAuthUserDeviceCreate) SetNillableDeleted(i *int8) *ScaAuthUserDeviceCreate {
if i != nil {
saudc.SetDeleted(*i)
}
return saudc
}
// SetUserID sets the "user_id" field.
func (saudc *ScaAuthUserDeviceCreate) SetUserID(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetUserID(s)
return saudc
}
// SetIP sets the "ip" field.
func (saudc *ScaAuthUserDeviceCreate) SetIP(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetIP(s)
return saudc
}
// SetLocation sets the "location" field.
func (saudc *ScaAuthUserDeviceCreate) SetLocation(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetLocation(s)
return saudc
}
// SetAgent sets the "agent" field.
func (saudc *ScaAuthUserDeviceCreate) SetAgent(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetAgent(s)
return saudc
}
// SetBrowser sets the "browser" field.
func (saudc *ScaAuthUserDeviceCreate) SetBrowser(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBrowser(s)
return saudc
}
// SetOperatingSystem sets the "operating_system" field.
func (saudc *ScaAuthUserDeviceCreate) SetOperatingSystem(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetOperatingSystem(s)
return saudc
}
// SetBrowserVersion sets the "browser_version" field.
func (saudc *ScaAuthUserDeviceCreate) SetBrowserVersion(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBrowserVersion(s)
return saudc
}
// SetMobile sets the "mobile" field.
func (saudc *ScaAuthUserDeviceCreate) SetMobile(b bool) *ScaAuthUserDeviceCreate {
saudc.mutation.SetMobile(b)
return saudc
}
// SetBot sets the "bot" field.
func (saudc *ScaAuthUserDeviceCreate) SetBot(b bool) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBot(b)
return saudc
}
// SetMozilla sets the "mozilla" field.
func (saudc *ScaAuthUserDeviceCreate) SetMozilla(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetMozilla(s)
return saudc
}
// SetPlatform sets the "platform" field.
func (saudc *ScaAuthUserDeviceCreate) SetPlatform(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetPlatform(s)
return saudc
}
// SetEngineName sets the "engine_name" field.
func (saudc *ScaAuthUserDeviceCreate) SetEngineName(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetEngineName(s)
return saudc
}
// SetEngineVersion sets the "engine_version" field.
func (saudc *ScaAuthUserDeviceCreate) SetEngineVersion(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetEngineVersion(s)
return saudc
}
// SetID sets the "id" field.
func (saudc *ScaAuthUserDeviceCreate) SetID(i int64) *ScaAuthUserDeviceCreate {
saudc.mutation.SetID(i)
return saudc
}
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
func (saudc *ScaAuthUserDeviceCreate) Mutation() *ScaAuthUserDeviceMutation {
return saudc.mutation
}
// Save creates the ScaAuthUserDevice in the database.
func (saudc *ScaAuthUserDeviceCreate) Save(ctx context.Context) (*ScaAuthUserDevice, error) {
saudc.defaults()
return withHooks(ctx, saudc.sqlSave, saudc.mutation, saudc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (saudc *ScaAuthUserDeviceCreate) SaveX(ctx context.Context) *ScaAuthUserDevice {
v, err := saudc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saudc *ScaAuthUserDeviceCreate) Exec(ctx context.Context) error {
_, err := saudc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saudc *ScaAuthUserDeviceCreate) ExecX(ctx context.Context) {
if err := saudc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saudc *ScaAuthUserDeviceCreate) defaults() {
if _, ok := saudc.mutation.CreatedAt(); !ok {
v := scaauthuserdevice.DefaultCreatedAt()
saudc.mutation.SetCreatedAt(v)
}
if _, ok := saudc.mutation.Deleted(); !ok {
v := scaauthuserdevice.DefaultDeleted
saudc.mutation.SetDeleted(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saudc *ScaAuthUserDeviceCreate) check() error {
if _, ok := saudc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUserDevice.created_at"`)}
}
if _, ok := saudc.mutation.Deleted(); !ok {
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthUserDevice.deleted"`)}
}
if v, ok := saudc.mutation.Deleted(); ok {
if err := scaauthuserdevice.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.deleted": %w`, err)}
}
}
if _, ok := saudc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaAuthUserDevice.user_id"`)}
}
if v, ok := saudc.mutation.UserID(); ok {
if err := scaauthuserdevice.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)}
}
}
if _, ok := saudc.mutation.IP(); !ok {
return &ValidationError{Name: "ip", err: errors.New(`ent: missing required field "ScaAuthUserDevice.ip"`)}
}
if v, ok := saudc.mutation.IP(); ok {
if err := scaauthuserdevice.IPValidator(v); err != nil {
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)}
}
}
if _, ok := saudc.mutation.Location(); !ok {
return &ValidationError{Name: "location", err: errors.New(`ent: missing required field "ScaAuthUserDevice.location"`)}
}
if v, ok := saudc.mutation.Location(); ok {
if err := scaauthuserdevice.LocationValidator(v); err != nil {
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)}
}
}
if _, ok := saudc.mutation.Agent(); !ok {
return &ValidationError{Name: "agent", err: errors.New(`ent: missing required field "ScaAuthUserDevice.agent"`)}
}
if v, ok := saudc.mutation.Agent(); ok {
if err := scaauthuserdevice.AgentValidator(v); err != nil {
return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)}
}
}
if _, ok := saudc.mutation.Browser(); !ok {
return &ValidationError{Name: "browser", err: errors.New(`ent: missing required field "ScaAuthUserDevice.browser"`)}
}
if v, ok := saudc.mutation.Browser(); ok {
if err := scaauthuserdevice.BrowserValidator(v); err != nil {
return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)}
}
}
if _, ok := saudc.mutation.OperatingSystem(); !ok {
return &ValidationError{Name: "operating_system", err: errors.New(`ent: missing required field "ScaAuthUserDevice.operating_system"`)}
}
if v, ok := saudc.mutation.OperatingSystem(); ok {
if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil {
return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)}
}
}
if _, ok := saudc.mutation.BrowserVersion(); !ok {
return &ValidationError{Name: "browser_version", err: errors.New(`ent: missing required field "ScaAuthUserDevice.browser_version"`)}
}
if v, ok := saudc.mutation.BrowserVersion(); ok {
if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil {
return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)}
}
}
if _, ok := saudc.mutation.Mobile(); !ok {
return &ValidationError{Name: "mobile", err: errors.New(`ent: missing required field "ScaAuthUserDevice.mobile"`)}
}
if _, ok := saudc.mutation.Bot(); !ok {
return &ValidationError{Name: "bot", err: errors.New(`ent: missing required field "ScaAuthUserDevice.bot"`)}
}
if _, ok := saudc.mutation.Mozilla(); !ok {
return &ValidationError{Name: "mozilla", err: errors.New(`ent: missing required field "ScaAuthUserDevice.mozilla"`)}
}
if v, ok := saudc.mutation.Mozilla(); ok {
if err := scaauthuserdevice.MozillaValidator(v); err != nil {
return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)}
}
}
if _, ok := saudc.mutation.Platform(); !ok {
return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "ScaAuthUserDevice.platform"`)}
}
if v, ok := saudc.mutation.Platform(); ok {
if err := scaauthuserdevice.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)}
}
}
if _, ok := saudc.mutation.EngineName(); !ok {
return &ValidationError{Name: "engine_name", err: errors.New(`ent: missing required field "ScaAuthUserDevice.engine_name"`)}
}
if v, ok := saudc.mutation.EngineName(); ok {
if err := scaauthuserdevice.EngineNameValidator(v); err != nil {
return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)}
}
}
if _, ok := saudc.mutation.EngineVersion(); !ok {
return &ValidationError{Name: "engine_version", err: errors.New(`ent: missing required field "ScaAuthUserDevice.engine_version"`)}
}
if v, ok := saudc.mutation.EngineVersion(); ok {
if err := scaauthuserdevice.EngineVersionValidator(v); err != nil {
return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)}
}
}
return nil
}
func (saudc *ScaAuthUserDeviceCreate) sqlSave(ctx context.Context) (*ScaAuthUserDevice, error) {
if err := saudc.check(); err != nil {
return nil, err
}
_node, _spec := saudc.createSpec()
if err := sqlgraph.CreateNode(ctx, saudc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
saudc.mutation.id = &_node.ID
saudc.mutation.done = true
return _node, nil
}
func (saudc *ScaAuthUserDeviceCreate) createSpec() (*ScaAuthUserDevice, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthUserDevice{config: saudc.config}
_spec = sqlgraph.NewCreateSpec(scaauthuserdevice.Table, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
)
if id, ok := saudc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := saudc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthuserdevice.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := saudc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthuserdevice.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := saudc.mutation.Deleted(); ok {
_spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := saudc.mutation.UserID(); ok {
_spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := saudc.mutation.IP(); ok {
_spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value)
_node.IP = value
}
if value, ok := saudc.mutation.Location(); ok {
_spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value)
_node.Location = value
}
if value, ok := saudc.mutation.Agent(); ok {
_spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value)
_node.Agent = value
}
if value, ok := saudc.mutation.Browser(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value)
_node.Browser = value
}
if value, ok := saudc.mutation.OperatingSystem(); ok {
_spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value)
_node.OperatingSystem = value
}
if value, ok := saudc.mutation.BrowserVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value)
_node.BrowserVersion = value
}
if value, ok := saudc.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeBool, value)
_node.Mobile = value
}
if value, ok := saudc.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeBool, value)
_node.Bot = value
}
if value, ok := saudc.mutation.Mozilla(); ok {
_spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value)
_node.Mozilla = value
}
if value, ok := saudc.mutation.Platform(); ok {
_spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value)
_node.Platform = value
}
if value, ok := saudc.mutation.EngineName(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value)
_node.EngineName = value
}
if value, ok := saudc.mutation.EngineVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
_node.EngineVersion = value
}
return _node, _spec
}
// ScaAuthUserDeviceCreateBulk is the builder for creating many ScaAuthUserDevice entities in bulk.
type ScaAuthUserDeviceCreateBulk struct {
config
err error
builders []*ScaAuthUserDeviceCreate
}
// Save creates the ScaAuthUserDevice entities in the database.
func (saudcb *ScaAuthUserDeviceCreateBulk) Save(ctx context.Context) ([]*ScaAuthUserDevice, error) {
if saudcb.err != nil {
return nil, saudcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(saudcb.builders))
nodes := make([]*ScaAuthUserDevice, len(saudcb.builders))
mutators := make([]Mutator, len(saudcb.builders))
for i := range saudcb.builders {
func(i int, root context.Context) {
builder := saudcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthUserDeviceMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, saudcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, saudcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, saudcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (saudcb *ScaAuthUserDeviceCreateBulk) SaveX(ctx context.Context) []*ScaAuthUserDevice {
v, err := saudcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saudcb *ScaAuthUserDeviceCreateBulk) Exec(ctx context.Context) error {
_, err := saudcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saudcb *ScaAuthUserDeviceCreateBulk) ExecX(ctx context.Context) {
if err := saudcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDeviceDelete is the builder for deleting a ScaAuthUserDevice entity.
type ScaAuthUserDeviceDelete struct {
config
hooks []Hook
mutation *ScaAuthUserDeviceMutation
}
// Where appends a list predicates to the ScaAuthUserDeviceDelete builder.
func (saudd *ScaAuthUserDeviceDelete) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceDelete {
saudd.mutation.Where(ps...)
return saudd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (saudd *ScaAuthUserDeviceDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, saudd.sqlExec, saudd.mutation, saudd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (saudd *ScaAuthUserDeviceDelete) ExecX(ctx context.Context) int {
n, err := saudd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (saudd *ScaAuthUserDeviceDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthuserdevice.Table, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
if ps := saudd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, saudd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
saudd.mutation.done = true
return affected, err
}
// ScaAuthUserDeviceDeleteOne is the builder for deleting a single ScaAuthUserDevice entity.
type ScaAuthUserDeviceDeleteOne struct {
saudd *ScaAuthUserDeviceDelete
}
// Where appends a list predicates to the ScaAuthUserDeviceDelete builder.
func (sauddo *ScaAuthUserDeviceDeleteOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceDeleteOne {
sauddo.saudd.mutation.Where(ps...)
return sauddo
}
// Exec executes the deletion query.
func (sauddo *ScaAuthUserDeviceDeleteOne) Exec(ctx context.Context) error {
n, err := sauddo.saudd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthuserdevice.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sauddo *ScaAuthUserDeviceDeleteOne) ExecX(ctx context.Context) {
if err := sauddo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDeviceQuery is the builder for querying ScaAuthUserDevice entities.
type ScaAuthUserDeviceQuery struct {
config
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)
}
// Where adds a new predicate for the ScaAuthUserDeviceQuery builder.
func (saudq *ScaAuthUserDeviceQuery) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceQuery {
saudq.predicates = append(saudq.predicates, ps...)
return saudq
}
// Limit the number of records to be returned by this query.
func (saudq *ScaAuthUserDeviceQuery) Limit(limit int) *ScaAuthUserDeviceQuery {
saudq.ctx.Limit = &limit
return saudq
}
// Offset to start from.
func (saudq *ScaAuthUserDeviceQuery) Offset(offset int) *ScaAuthUserDeviceQuery {
saudq.ctx.Offset = &offset
return saudq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (saudq *ScaAuthUserDeviceQuery) Unique(unique bool) *ScaAuthUserDeviceQuery {
saudq.ctx.Unique = &unique
return saudq
}
// Order specifies how the records should be ordered.
func (saudq *ScaAuthUserDeviceQuery) Order(o ...scaauthuserdevice.OrderOption) *ScaAuthUserDeviceQuery {
saudq.order = append(saudq.order, o...)
return saudq
}
// 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) {
nodes, err := saudq.Limit(1).All(setContextOp(ctx, saudq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthuserdevice.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) FirstX(ctx context.Context) *ScaAuthUserDevice {
node, err := saudq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthUserDevice ID from the query.
// Returns a *NotFoundError when no ScaAuthUserDevice ID was found.
func (saudq *ScaAuthUserDeviceQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = saudq.Limit(1).IDs(setContextOp(ctx, saudq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthuserdevice.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) FirstIDX(ctx context.Context) int64 {
id, err := saudq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthUserDevice entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthUserDevice entity is found.
// Returns a *NotFoundError when no ScaAuthUserDevice entities are found.
func (saudq *ScaAuthUserDeviceQuery) Only(ctx context.Context) (*ScaAuthUserDevice, error) {
nodes, err := saudq.Limit(2).All(setContextOp(ctx, saudq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthuserdevice.Label}
default:
return nil, &NotSingularError{scaauthuserdevice.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) OnlyX(ctx context.Context) *ScaAuthUserDevice {
node, err := saudq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthUserDevice ID in the query.
// Returns a *NotSingularError when more than one ScaAuthUserDevice ID is found.
// Returns a *NotFoundError when no entities are found.
func (saudq *ScaAuthUserDeviceQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = saudq.Limit(2).IDs(setContextOp(ctx, saudq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthuserdevice.Label}
default:
err = &NotSingularError{scaauthuserdevice.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) OnlyIDX(ctx context.Context) int64 {
id, err := saudq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthUserDevices.
func (saudq *ScaAuthUserDeviceQuery) All(ctx context.Context) ([]*ScaAuthUserDevice, error) {
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryAll)
if err := saudq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthUserDevice, *ScaAuthUserDeviceQuery]()
return withInterceptors[[]*ScaAuthUserDevice](ctx, saudq, qr, saudq.inters)
}
// AllX is like All, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) AllX(ctx context.Context) []*ScaAuthUserDevice {
nodes, err := saudq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthUserDevice IDs.
func (saudq *ScaAuthUserDeviceQuery) IDs(ctx context.Context) (ids []int64, err error) {
if saudq.ctx.Unique == nil && saudq.path != nil {
saudq.Unique(true)
}
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryIDs)
if err = saudq.Select(scaauthuserdevice.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) IDsX(ctx context.Context) []int64 {
ids, err := saudq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (saudq *ScaAuthUserDeviceQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryCount)
if err := saudq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, saudq, querierCount[*ScaAuthUserDeviceQuery](), saudq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) CountX(ctx context.Context) int {
count, err := saudq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (saudq *ScaAuthUserDeviceQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryExist)
switch _, err := saudq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) ExistX(ctx context.Context) bool {
exist, err := saudq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthUserDeviceQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (saudq *ScaAuthUserDeviceQuery) Clone() *ScaAuthUserDeviceQuery {
if saudq == nil {
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...),
// clone intermediate query.
sql: saudq.sql.Clone(),
path: saudq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthUserDevice.Query().
// GroupBy(scaauthuserdevice.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (saudq *ScaAuthUserDeviceQuery) GroupBy(field string, fields ...string) *ScaAuthUserDeviceGroupBy {
saudq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthUserDeviceGroupBy{build: saudq}
grbuild.flds = &saudq.ctx.Fields
grbuild.label = scaauthuserdevice.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthUserDevice.Query().
// Select(scaauthuserdevice.FieldCreatedAt).
// Scan(ctx, &v)
func (saudq *ScaAuthUserDeviceQuery) Select(fields ...string) *ScaAuthUserDeviceSelect {
saudq.ctx.Fields = append(saudq.ctx.Fields, fields...)
sbuild := &ScaAuthUserDeviceSelect{ScaAuthUserDeviceQuery: saudq}
sbuild.label = scaauthuserdevice.Label
sbuild.flds, sbuild.scan = &saudq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthUserDeviceSelect configured with the given aggregations.
func (saudq *ScaAuthUserDeviceQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceSelect {
return saudq.Select().Aggregate(fns...)
}
func (saudq *ScaAuthUserDeviceQuery) prepareQuery(ctx context.Context) error {
for _, inter := range saudq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, saudq); err != nil {
return err
}
}
}
for _, f := range saudq.ctx.Fields {
if !scaauthuserdevice.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if saudq.path != nil {
prev, err := saudq.path(ctx)
if err != nil {
return err
}
saudq.sql = prev
}
return nil
}
func (saudq *ScaAuthUserDeviceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserDevice, error) {
var (
nodes = []*ScaAuthUserDevice{}
_spec = saudq.querySpec()
)
_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)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, saudq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (saudq *ScaAuthUserDeviceQuery) sqlCount(ctx context.Context) (int, error) {
_spec := saudq.querySpec()
_spec.Node.Columns = saudq.ctx.Fields
if len(saudq.ctx.Fields) > 0 {
_spec.Unique = saudq.ctx.Unique != nil && *saudq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, saudq.driver, _spec)
}
func (saudq *ScaAuthUserDeviceQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
_spec.From = saudq.sql
if unique := saudq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if saudq.path != nil {
_spec.Unique = true
}
if fields := saudq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.FieldID)
for i := range fields {
if fields[i] != scaauthuserdevice.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := saudq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := saudq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := saudq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := saudq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (saudq *ScaAuthUserDeviceQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(saudq.driver.Dialect())
t1 := builder.Table(scaauthuserdevice.Table)
columns := saudq.ctx.Fields
if len(columns) == 0 {
columns = scaauthuserdevice.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if saudq.sql != nil {
selector = saudq.sql
selector.Select(selector.Columns(columns...)...)
}
if saudq.ctx.Unique != nil && *saudq.ctx.Unique {
selector.Distinct()
}
for _, p := range saudq.predicates {
p(selector)
}
for _, p := range saudq.order {
p(selector)
}
if offset := saudq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := saudq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthUserDeviceGroupBy is the group-by builder for ScaAuthUserDevice entities.
type ScaAuthUserDeviceGroupBy struct {
selector
build *ScaAuthUserDeviceQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (saudgb *ScaAuthUserDeviceGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceGroupBy {
saudgb.fns = append(saudgb.fns, fns...)
return saudgb
}
// Scan applies the selector query and scans the result into the given value.
func (saudgb *ScaAuthUserDeviceGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saudgb.build.ctx, ent.OpQueryGroupBy)
if err := saudgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserDeviceQuery, *ScaAuthUserDeviceGroupBy](ctx, saudgb.build, saudgb, saudgb.build.inters, v)
}
func (saudgb *ScaAuthUserDeviceGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserDeviceQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(saudgb.fns))
for _, fn := range saudgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*saudgb.flds)+len(saudgb.fns))
for _, f := range *saudgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*saudgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saudgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthUserDeviceSelect is the builder for selecting fields of ScaAuthUserDevice entities.
type ScaAuthUserDeviceSelect struct {
*ScaAuthUserDeviceQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sauds *ScaAuthUserDeviceSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceSelect {
sauds.fns = append(sauds.fns, fns...)
return sauds
}
// Scan applies the selector query and scans the result into the given value.
func (sauds *ScaAuthUserDeviceSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sauds.ctx, ent.OpQuerySelect)
if err := sauds.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserDeviceQuery, *ScaAuthUserDeviceSelect](ctx, sauds.ScaAuthUserDeviceQuery, sauds, sauds.inters, v)
}
func (sauds *ScaAuthUserDeviceSelect) sqlScan(ctx context.Context, root *ScaAuthUserDeviceQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sauds.fns))
for _, fn := range sauds.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sauds.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sauds.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,862 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDeviceUpdate is the builder for updating ScaAuthUserDevice entities.
type ScaAuthUserDeviceUpdate struct {
config
hooks []Hook
mutation *ScaAuthUserDeviceMutation
}
// Where appends a list predicates to the ScaAuthUserDeviceUpdate builder.
func (saudu *ScaAuthUserDeviceUpdate) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceUpdate {
saudu.mutation.Where(ps...)
return saudu
}
// SetUpdatedAt sets the "updated_at" field.
func (saudu *ScaAuthUserDeviceUpdate) SetUpdatedAt(t time.Time) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetUpdatedAt(t)
return saudu
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (saudu *ScaAuthUserDeviceUpdate) ClearUpdatedAt() *ScaAuthUserDeviceUpdate {
saudu.mutation.ClearUpdatedAt()
return saudu
}
// SetDeleted sets the "deleted" field.
func (saudu *ScaAuthUserDeviceUpdate) SetDeleted(i int8) *ScaAuthUserDeviceUpdate {
saudu.mutation.ResetDeleted()
saudu.mutation.SetDeleted(i)
return saudu
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableDeleted(i *int8) *ScaAuthUserDeviceUpdate {
if i != nil {
saudu.SetDeleted(*i)
}
return saudu
}
// AddDeleted adds i to the "deleted" field.
func (saudu *ScaAuthUserDeviceUpdate) AddDeleted(i int8) *ScaAuthUserDeviceUpdate {
saudu.mutation.AddDeleted(i)
return saudu
}
// SetUserID sets the "user_id" field.
func (saudu *ScaAuthUserDeviceUpdate) SetUserID(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetUserID(s)
return saudu
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableUserID(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetUserID(*s)
}
return saudu
}
// SetIP sets the "ip" field.
func (saudu *ScaAuthUserDeviceUpdate) SetIP(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetIP(s)
return saudu
}
// SetNillableIP sets the "ip" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableIP(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetIP(*s)
}
return saudu
}
// SetLocation sets the "location" field.
func (saudu *ScaAuthUserDeviceUpdate) SetLocation(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetLocation(s)
return saudu
}
// SetNillableLocation sets the "location" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableLocation(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetLocation(*s)
}
return saudu
}
// SetAgent sets the "agent" field.
func (saudu *ScaAuthUserDeviceUpdate) SetAgent(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetAgent(s)
return saudu
}
// SetNillableAgent sets the "agent" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableAgent(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetAgent(*s)
}
return saudu
}
// SetBrowser sets the "browser" field.
func (saudu *ScaAuthUserDeviceUpdate) SetBrowser(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetBrowser(s)
return saudu
}
// SetNillableBrowser sets the "browser" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableBrowser(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetBrowser(*s)
}
return saudu
}
// SetOperatingSystem sets the "operating_system" field.
func (saudu *ScaAuthUserDeviceUpdate) SetOperatingSystem(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetOperatingSystem(s)
return saudu
}
// SetNillableOperatingSystem sets the "operating_system" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableOperatingSystem(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetOperatingSystem(*s)
}
return saudu
}
// SetBrowserVersion sets the "browser_version" field.
func (saudu *ScaAuthUserDeviceUpdate) SetBrowserVersion(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetBrowserVersion(s)
return saudu
}
// SetNillableBrowserVersion sets the "browser_version" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableBrowserVersion(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetBrowserVersion(*s)
}
return saudu
}
// SetMobile sets the "mobile" field.
func (saudu *ScaAuthUserDeviceUpdate) SetMobile(b bool) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetMobile(b)
return saudu
}
// SetNillableMobile sets the "mobile" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableMobile(b *bool) *ScaAuthUserDeviceUpdate {
if b != nil {
saudu.SetMobile(*b)
}
return saudu
}
// SetBot sets the "bot" field.
func (saudu *ScaAuthUserDeviceUpdate) SetBot(b bool) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetBot(b)
return saudu
}
// SetNillableBot sets the "bot" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableBot(b *bool) *ScaAuthUserDeviceUpdate {
if b != nil {
saudu.SetBot(*b)
}
return saudu
}
// SetMozilla sets the "mozilla" field.
func (saudu *ScaAuthUserDeviceUpdate) SetMozilla(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetMozilla(s)
return saudu
}
// SetNillableMozilla sets the "mozilla" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableMozilla(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetMozilla(*s)
}
return saudu
}
// SetPlatform sets the "platform" field.
func (saudu *ScaAuthUserDeviceUpdate) SetPlatform(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetPlatform(s)
return saudu
}
// SetNillablePlatform sets the "platform" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillablePlatform(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetPlatform(*s)
}
return saudu
}
// SetEngineName sets the "engine_name" field.
func (saudu *ScaAuthUserDeviceUpdate) SetEngineName(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetEngineName(s)
return saudu
}
// SetNillableEngineName sets the "engine_name" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableEngineName(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetEngineName(*s)
}
return saudu
}
// SetEngineVersion sets the "engine_version" field.
func (saudu *ScaAuthUserDeviceUpdate) SetEngineVersion(s string) *ScaAuthUserDeviceUpdate {
saudu.mutation.SetEngineVersion(s)
return saudu
}
// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil.
func (saudu *ScaAuthUserDeviceUpdate) SetNillableEngineVersion(s *string) *ScaAuthUserDeviceUpdate {
if s != nil {
saudu.SetEngineVersion(*s)
}
return saudu
}
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
func (saudu *ScaAuthUserDeviceUpdate) Mutation() *ScaAuthUserDeviceMutation {
return saudu.mutation
}
// 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()
return withHooks(ctx, saudu.sqlSave, saudu.mutation, saudu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (saudu *ScaAuthUserDeviceUpdate) SaveX(ctx context.Context) int {
affected, err := saudu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (saudu *ScaAuthUserDeviceUpdate) Exec(ctx context.Context) error {
_, err := saudu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saudu *ScaAuthUserDeviceUpdate) ExecX(ctx context.Context) {
if err := saudu.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saudu *ScaAuthUserDeviceUpdate) defaults() {
if _, ok := saudu.mutation.UpdatedAt(); !ok && !saudu.mutation.UpdatedAtCleared() {
v := scaauthuserdevice.UpdateDefaultUpdatedAt()
saudu.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saudu *ScaAuthUserDeviceUpdate) check() error {
if v, ok := saudu.mutation.Deleted(); ok {
if err := scaauthuserdevice.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.deleted": %w`, err)}
}
}
if v, ok := saudu.mutation.UserID(); ok {
if err := scaauthuserdevice.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)}
}
}
if v, ok := saudu.mutation.IP(); ok {
if err := scaauthuserdevice.IPValidator(v); err != nil {
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)}
}
}
if v, ok := saudu.mutation.Location(); ok {
if err := scaauthuserdevice.LocationValidator(v); err != nil {
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)}
}
}
if v, ok := saudu.mutation.Agent(); ok {
if err := scaauthuserdevice.AgentValidator(v); err != nil {
return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)}
}
}
if v, ok := saudu.mutation.Browser(); ok {
if err := scaauthuserdevice.BrowserValidator(v); err != nil {
return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)}
}
}
if v, ok := saudu.mutation.OperatingSystem(); ok {
if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil {
return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)}
}
}
if v, ok := saudu.mutation.BrowserVersion(); ok {
if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil {
return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)}
}
}
if v, ok := saudu.mutation.Mozilla(); ok {
if err := scaauthuserdevice.MozillaValidator(v); err != nil {
return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)}
}
}
if v, ok := saudu.mutation.Platform(); ok {
if err := scaauthuserdevice.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)}
}
}
if v, ok := saudu.mutation.EngineName(); ok {
if err := scaauthuserdevice.EngineNameValidator(v); err != nil {
return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)}
}
}
if v, ok := saudu.mutation.EngineVersion(); ok {
if err := scaauthuserdevice.EngineVersionValidator(v); err != nil {
return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)}
}
}
return nil
}
func (saudu *ScaAuthUserDeviceUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := saudu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
if ps := saudu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := saudu.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthuserdevice.FieldUpdatedAt, field.TypeTime, value)
}
if saudu.mutation.UpdatedAtCleared() {
_spec.ClearField(scaauthuserdevice.FieldUpdatedAt, field.TypeTime)
}
if value, ok := saudu.mutation.Deleted(); ok {
_spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saudu.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthuserdevice.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saudu.mutation.UserID(); ok {
_spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value)
}
if value, ok := saudu.mutation.IP(); ok {
_spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value)
}
if value, ok := saudu.mutation.Location(); ok {
_spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value)
}
if value, ok := saudu.mutation.Agent(); ok {
_spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value)
}
if value, ok := saudu.mutation.Browser(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value)
}
if value, ok := saudu.mutation.OperatingSystem(); ok {
_spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value)
}
if value, ok := saudu.mutation.BrowserVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value)
}
if value, ok := saudu.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeBool, value)
}
if value, ok := saudu.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeBool, value)
}
if value, ok := saudu.mutation.Mozilla(); ok {
_spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value)
}
if value, ok := saudu.mutation.Platform(); ok {
_spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value)
}
if value, ok := saudu.mutation.EngineName(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value)
}
if value, ok := saudu.mutation.EngineVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
}
if n, err = sqlgraph.UpdateNodes(ctx, saudu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthuserdevice.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
saudu.mutation.done = true
return n, nil
}
// ScaAuthUserDeviceUpdateOne is the builder for updating a single ScaAuthUserDevice entity.
type ScaAuthUserDeviceUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthUserDeviceMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetUpdatedAt(t time.Time) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetUpdatedAt(t)
return sauduo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) ClearUpdatedAt() *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.ClearUpdatedAt()
return sauduo
}
// SetDeleted sets the "deleted" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetDeleted(i int8) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.ResetDeleted()
sauduo.mutation.SetDeleted(i)
return sauduo
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableDeleted(i *int8) *ScaAuthUserDeviceUpdateOne {
if i != nil {
sauduo.SetDeleted(*i)
}
return sauduo
}
// AddDeleted adds i to the "deleted" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) AddDeleted(i int8) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.AddDeleted(i)
return sauduo
}
// SetUserID sets the "user_id" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetUserID(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetUserID(s)
return sauduo
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableUserID(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetUserID(*s)
}
return sauduo
}
// SetIP sets the "ip" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetIP(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetIP(s)
return sauduo
}
// SetNillableIP sets the "ip" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableIP(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetIP(*s)
}
return sauduo
}
// SetLocation sets the "location" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetLocation(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetLocation(s)
return sauduo
}
// SetNillableLocation sets the "location" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableLocation(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetLocation(*s)
}
return sauduo
}
// SetAgent sets the "agent" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetAgent(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetAgent(s)
return sauduo
}
// SetNillableAgent sets the "agent" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableAgent(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetAgent(*s)
}
return sauduo
}
// SetBrowser sets the "browser" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetBrowser(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetBrowser(s)
return sauduo
}
// SetNillableBrowser sets the "browser" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBrowser(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetBrowser(*s)
}
return sauduo
}
// SetOperatingSystem sets the "operating_system" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetOperatingSystem(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetOperatingSystem(s)
return sauduo
}
// SetNillableOperatingSystem sets the "operating_system" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableOperatingSystem(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetOperatingSystem(*s)
}
return sauduo
}
// SetBrowserVersion sets the "browser_version" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetBrowserVersion(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetBrowserVersion(s)
return sauduo
}
// SetNillableBrowserVersion sets the "browser_version" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBrowserVersion(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetBrowserVersion(*s)
}
return sauduo
}
// SetMobile sets the "mobile" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetMobile(b bool) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetMobile(b)
return sauduo
}
// SetNillableMobile sets the "mobile" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableMobile(b *bool) *ScaAuthUserDeviceUpdateOne {
if b != nil {
sauduo.SetMobile(*b)
}
return sauduo
}
// SetBot sets the "bot" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetBot(b bool) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetBot(b)
return sauduo
}
// SetNillableBot sets the "bot" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableBot(b *bool) *ScaAuthUserDeviceUpdateOne {
if b != nil {
sauduo.SetBot(*b)
}
return sauduo
}
// SetMozilla sets the "mozilla" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetMozilla(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetMozilla(s)
return sauduo
}
// SetNillableMozilla sets the "mozilla" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableMozilla(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetMozilla(*s)
}
return sauduo
}
// SetPlatform sets the "platform" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetPlatform(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetPlatform(s)
return sauduo
}
// SetNillablePlatform sets the "platform" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillablePlatform(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetPlatform(*s)
}
return sauduo
}
// SetEngineName sets the "engine_name" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetEngineName(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetEngineName(s)
return sauduo
}
// SetNillableEngineName sets the "engine_name" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableEngineName(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetEngineName(*s)
}
return sauduo
}
// SetEngineVersion sets the "engine_version" field.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetEngineVersion(s string) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.SetEngineVersion(s)
return sauduo
}
// SetNillableEngineVersion sets the "engine_version" field if the given value is not nil.
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableEngineVersion(s *string) *ScaAuthUserDeviceUpdateOne {
if s != nil {
sauduo.SetEngineVersion(*s)
}
return sauduo
}
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
func (sauduo *ScaAuthUserDeviceUpdateOne) Mutation() *ScaAuthUserDeviceMutation {
return sauduo.mutation
}
// Where appends a list predicates to the ScaAuthUserDeviceUpdate builder.
func (sauduo *ScaAuthUserDeviceUpdateOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceUpdateOne {
sauduo.mutation.Where(ps...)
return sauduo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (sauduo *ScaAuthUserDeviceUpdateOne) Select(field string, fields ...string) *ScaAuthUserDeviceUpdateOne {
sauduo.fields = append([]string{field}, fields...)
return sauduo
}
// Save executes the query and returns the updated ScaAuthUserDevice entity.
func (sauduo *ScaAuthUserDeviceUpdateOne) Save(ctx context.Context) (*ScaAuthUserDevice, error) {
sauduo.defaults()
return withHooks(ctx, sauduo.sqlSave, sauduo.mutation, sauduo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sauduo *ScaAuthUserDeviceUpdateOne) SaveX(ctx context.Context) *ScaAuthUserDevice {
node, err := sauduo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (sauduo *ScaAuthUserDeviceUpdateOne) Exec(ctx context.Context) error {
_, err := sauduo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sauduo *ScaAuthUserDeviceUpdateOne) ExecX(ctx context.Context) {
if err := sauduo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sauduo *ScaAuthUserDeviceUpdateOne) defaults() {
if _, ok := sauduo.mutation.UpdatedAt(); !ok && !sauduo.mutation.UpdatedAtCleared() {
v := scaauthuserdevice.UpdateDefaultUpdatedAt()
sauduo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sauduo *ScaAuthUserDeviceUpdateOne) check() error {
if v, ok := sauduo.mutation.Deleted(); ok {
if err := scaauthuserdevice.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.deleted": %w`, err)}
}
}
if v, ok := sauduo.mutation.UserID(); ok {
if err := scaauthuserdevice.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)}
}
}
if v, ok := sauduo.mutation.IP(); ok {
if err := scaauthuserdevice.IPValidator(v); err != nil {
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)}
}
}
if v, ok := sauduo.mutation.Location(); ok {
if err := scaauthuserdevice.LocationValidator(v); err != nil {
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)}
}
}
if v, ok := sauduo.mutation.Agent(); ok {
if err := scaauthuserdevice.AgentValidator(v); err != nil {
return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)}
}
}
if v, ok := sauduo.mutation.Browser(); ok {
if err := scaauthuserdevice.BrowserValidator(v); err != nil {
return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)}
}
}
if v, ok := sauduo.mutation.OperatingSystem(); ok {
if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil {
return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)}
}
}
if v, ok := sauduo.mutation.BrowserVersion(); ok {
if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil {
return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)}
}
}
if v, ok := sauduo.mutation.Mozilla(); ok {
if err := scaauthuserdevice.MozillaValidator(v); err != nil {
return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)}
}
}
if v, ok := sauduo.mutation.Platform(); ok {
if err := scaauthuserdevice.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)}
}
}
if v, ok := sauduo.mutation.EngineName(); ok {
if err := scaauthuserdevice.EngineNameValidator(v); err != nil {
return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)}
}
}
if v, ok := sauduo.mutation.EngineVersion(); ok {
if err := scaauthuserdevice.EngineVersionValidator(v); err != nil {
return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)}
}
}
return nil
}
func (sauduo *ScaAuthUserDeviceUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUserDevice, err error) {
if err := sauduo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
id, ok := sauduo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUserDevice.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := sauduo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.FieldID)
for _, f := range fields {
if !scaauthuserdevice.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthuserdevice.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := sauduo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sauduo.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthuserdevice.FieldUpdatedAt, field.TypeTime, value)
}
if sauduo.mutation.UpdatedAtCleared() {
_spec.ClearField(scaauthuserdevice.FieldUpdatedAt, field.TypeTime)
}
if value, ok := sauduo.mutation.Deleted(); ok {
_spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sauduo.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthuserdevice.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sauduo.mutation.UserID(); ok {
_spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value)
}
if value, ok := sauduo.mutation.IP(); ok {
_spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value)
}
if value, ok := sauduo.mutation.Location(); ok {
_spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value)
}
if value, ok := sauduo.mutation.Agent(); ok {
_spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value)
}
if value, ok := sauduo.mutation.Browser(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value)
}
if value, ok := sauduo.mutation.OperatingSystem(); ok {
_spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value)
}
if value, ok := sauduo.mutation.BrowserVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value)
}
if value, ok := sauduo.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeBool, value)
}
if value, ok := sauduo.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeBool, value)
}
if value, ok := sauduo.mutation.Mozilla(); ok {
_spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value)
}
if value, ok := sauduo.mutation.Platform(); ok {
_spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value)
}
if value, ok := sauduo.mutation.EngineName(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value)
}
if value, ok := sauduo.mutation.EngineVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
}
_node = &ScaAuthUserDevice{config: sauduo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, sauduo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthuserdevice.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
sauduo.mutation.done = true
return _node, nil
}

View File

@@ -1,173 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户第三方登录信息
type ScaAuthUserSocial struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 用户ID
UserID string `json:"user_id,omitempty"`
// 第三方用户的 open id
OpenID string `json:"open_id,omitempty"`
// 第三方用户来源
Source string `json:"source,omitempty"`
// 状态 0正常 1 封禁
Status int `json:"status,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthUserSocial) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthusersocial.FieldID, scaauthusersocial.FieldDeleted, scaauthusersocial.FieldStatus:
values[i] = new(sql.NullInt64)
case scaauthusersocial.FieldUserID, scaauthusersocial.FieldOpenID, scaauthusersocial.FieldSource:
values[i] = new(sql.NullString)
case scaauthusersocial.FieldCreatedAt, scaauthusersocial.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUserSocial fields.
func (saus *ScaAuthUserSocial) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthusersocial.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
saus.ID = int64(value.Int64)
case scaauthusersocial.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
saus.CreatedAt = value.Time
}
case scaauthusersocial.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
saus.UpdatedAt = value.Time
}
case scaauthusersocial.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
saus.Deleted = int8(value.Int64)
}
case scaauthusersocial.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
saus.UserID = value.String
}
case scaauthusersocial.FieldOpenID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field open_id", values[i])
} else if value.Valid {
saus.OpenID = value.String
}
case scaauthusersocial.FieldSource:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field source", values[i])
} else if value.Valid {
saus.Source = value.String
}
case scaauthusersocial.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
saus.Status = int(value.Int64)
}
default:
saus.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserSocial.
// This includes values selected through modifiers, order, etc.
func (saus *ScaAuthUserSocial) Value(name string) (ent.Value, error) {
return saus.selectValues.Get(name)
}
// 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.
func (saus *ScaAuthUserSocial) Update() *ScaAuthUserSocialUpdateOne {
return NewScaAuthUserSocialClient(saus.config).UpdateOne(saus)
}
// Unwrap unwraps the ScaAuthUserSocial entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (saus *ScaAuthUserSocial) Unwrap() *ScaAuthUserSocial {
_tx, ok := saus.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUserSocial is not a transactional entity")
}
saus.config.driver = _tx.drv
return saus
}
// String implements the fmt.Stringer.
func (saus *ScaAuthUserSocial) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUserSocial(")
builder.WriteString(fmt.Sprintf("id=%v, ", saus.ID))
builder.WriteString("created_at=")
builder.WriteString(saus.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(saus.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", saus.Deleted))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(saus.UserID)
builder.WriteString(", ")
builder.WriteString("open_id=")
builder.WriteString(saus.OpenID)
builder.WriteString(", ")
builder.WriteString("source=")
builder.WriteString(saus.Source)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", saus.Status))
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUserSocials is a parsable slice of ScaAuthUserSocial.
type ScaAuthUserSocials []*ScaAuthUserSocial

View File

@@ -1,116 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthusersocial
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scaauthusersocial type in the database.
Label = "sca_auth_user_social"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldOpenID holds the string denoting the open_id field in the database.
FieldOpenID = "open_id"
// FieldSource holds the string denoting the source field in the database.
FieldSource = "source"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// Table holds the table name of the scaauthusersocial in the database.
Table = "sca_auth_user_social"
)
// Columns holds all SQL columns for scaauthusersocial fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUserID,
FieldOpenID,
FieldSource,
FieldStatus,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
UserIDValidator func(string) error
// OpenIDValidator is a validator for the "open_id" field. It is called by the builders before save.
OpenIDValidator func(string) error
// SourceValidator is a validator for the "source" field. It is called by the builders before save.
SourceValidator func(string) error
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus int
)
// OrderOption defines the ordering options for the ScaAuthUserSocial queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByOpenID orders the results by the open_id field.
func ByOpenID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOpenID, opts...).ToFunc()
}
// BySource orders the results by the source field.
func BySource(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSource, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

View File

@@ -1,470 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthusersocial
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUpdatedAt, v))
}
// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ.
func Deleted(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldDeleted, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUserID, v))
}
// OpenID applies equality check predicate on the "open_id" field. It's identical to OpenIDEQ.
func OpenID(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldOpenID, v))
}
// Source applies equality check predicate on the "source" field. It's identical to SourceEQ.
func Source(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldSource, v))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldStatus, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldUpdatedAt, v))
}
// UpdatedAtIsNil applies the IsNil predicate on the "updated_at" field.
func UpdatedAtIsNil() predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIsNull(FieldUpdatedAt))
}
// UpdatedAtNotNil applies the NotNil predicate on the "updated_at" field.
func UpdatedAtNotNil() predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotNull(FieldUpdatedAt))
}
// DeletedEQ applies the EQ predicate on the "deleted" field.
func DeletedEQ(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldDeleted, v))
}
// DeletedNEQ applies the NEQ predicate on the "deleted" field.
func DeletedNEQ(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldDeleted, v))
}
// DeletedIn applies the In predicate on the "deleted" field.
func DeletedIn(vs ...int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldDeleted, vs...))
}
// DeletedNotIn applies the NotIn predicate on the "deleted" field.
func DeletedNotIn(vs ...int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldDeleted, vs...))
}
// DeletedGT applies the GT predicate on the "deleted" field.
func DeletedGT(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldDeleted, v))
}
// DeletedGTE applies the GTE predicate on the "deleted" field.
func DeletedGTE(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldDeleted, v))
}
// DeletedLT applies the LT predicate on the "deleted" field.
func DeletedLT(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldDeleted, v))
}
// DeletedLTE applies the LTE predicate on the "deleted" field.
func DeletedLTE(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldDeleted, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldUserID, v))
}
// UserIDContains applies the Contains predicate on the "user_id" field.
func UserIDContains(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContains(FieldUserID, v))
}
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
func UserIDHasPrefix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldUserID, v))
}
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
func UserIDHasSuffix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldUserID, v))
}
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
func UserIDEqualFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldUserID, v))
}
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
func UserIDContainsFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldUserID, v))
}
// OpenIDEQ applies the EQ predicate on the "open_id" field.
func OpenIDEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldOpenID, v))
}
// OpenIDNEQ applies the NEQ predicate on the "open_id" field.
func OpenIDNEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldOpenID, v))
}
// OpenIDIn applies the In predicate on the "open_id" field.
func OpenIDIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldOpenID, vs...))
}
// OpenIDNotIn applies the NotIn predicate on the "open_id" field.
func OpenIDNotIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldOpenID, vs...))
}
// OpenIDGT applies the GT predicate on the "open_id" field.
func OpenIDGT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldOpenID, v))
}
// OpenIDGTE applies the GTE predicate on the "open_id" field.
func OpenIDGTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldOpenID, v))
}
// OpenIDLT applies the LT predicate on the "open_id" field.
func OpenIDLT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldOpenID, v))
}
// OpenIDLTE applies the LTE predicate on the "open_id" field.
func OpenIDLTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldOpenID, v))
}
// OpenIDContains applies the Contains predicate on the "open_id" field.
func OpenIDContains(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContains(FieldOpenID, v))
}
// OpenIDHasPrefix applies the HasPrefix predicate on the "open_id" field.
func OpenIDHasPrefix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldOpenID, v))
}
// OpenIDHasSuffix applies the HasSuffix predicate on the "open_id" field.
func OpenIDHasSuffix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldOpenID, v))
}
// OpenIDEqualFold applies the EqualFold predicate on the "open_id" field.
func OpenIDEqualFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldOpenID, v))
}
// OpenIDContainsFold applies the ContainsFold predicate on the "open_id" field.
func OpenIDContainsFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldOpenID, v))
}
// SourceEQ applies the EQ predicate on the "source" field.
func SourceEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldSource, v))
}
// SourceNEQ applies the NEQ predicate on the "source" field.
func SourceNEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldSource, v))
}
// SourceIn applies the In predicate on the "source" field.
func SourceIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldSource, vs...))
}
// SourceNotIn applies the NotIn predicate on the "source" field.
func SourceNotIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldSource, vs...))
}
// SourceGT applies the GT predicate on the "source" field.
func SourceGT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldSource, v))
}
// SourceGTE applies the GTE predicate on the "source" field.
func SourceGTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldSource, v))
}
// SourceLT applies the LT predicate on the "source" field.
func SourceLT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldSource, v))
}
// SourceLTE applies the LTE predicate on the "source" field.
func SourceLTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldSource, v))
}
// SourceContains applies the Contains predicate on the "source" field.
func SourceContains(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContains(FieldSource, v))
}
// SourceHasPrefix applies the HasPrefix predicate on the "source" field.
func SourceHasPrefix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldSource, v))
}
// SourceHasSuffix applies the HasSuffix predicate on the "source" field.
func SourceHasSuffix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldSource, v))
}
// SourceEqualFold applies the EqualFold predicate on the "source" field.
func SourceEqualFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldSource, v))
}
// SourceContainsFold applies the ContainsFold predicate on the "source" field.
func SourceContainsFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldSource, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldStatus, vs...))
}
// StatusGT applies the GT predicate on the "status" field.
func StatusGT(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldStatus, v))
}
// StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldStatus, v))
}
// StatusLT applies the LT predicate on the "status" field.
func StatusLT(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldStatus, v))
}
// StatusLTE applies the LTE predicate on the "status" field.
func StatusLTE(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldStatus, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.NotPredicates(p))
}

View File

@@ -1,341 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialCreate is the builder for creating a ScaAuthUserSocial entity.
type ScaAuthUserSocialCreate struct {
config
mutation *ScaAuthUserSocialMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (sausc *ScaAuthUserSocialCreate) SetCreatedAt(t time.Time) *ScaAuthUserSocialCreate {
sausc.mutation.SetCreatedAt(t)
return sausc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserSocialCreate {
if t != nil {
sausc.SetCreatedAt(*t)
}
return sausc
}
// SetUpdatedAt sets the "updated_at" field.
func (sausc *ScaAuthUserSocialCreate) SetUpdatedAt(t time.Time) *ScaAuthUserSocialCreate {
sausc.mutation.SetUpdatedAt(t)
return sausc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthUserSocialCreate {
if t != nil {
sausc.SetUpdatedAt(*t)
}
return sausc
}
// SetDeleted sets the "deleted" field.
func (sausc *ScaAuthUserSocialCreate) SetDeleted(i int8) *ScaAuthUserSocialCreate {
sausc.mutation.SetDeleted(i)
return sausc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableDeleted(i *int8) *ScaAuthUserSocialCreate {
if i != nil {
sausc.SetDeleted(*i)
}
return sausc
}
// SetUserID sets the "user_id" field.
func (sausc *ScaAuthUserSocialCreate) SetUserID(s string) *ScaAuthUserSocialCreate {
sausc.mutation.SetUserID(s)
return sausc
}
// SetOpenID sets the "open_id" field.
func (sausc *ScaAuthUserSocialCreate) SetOpenID(s string) *ScaAuthUserSocialCreate {
sausc.mutation.SetOpenID(s)
return sausc
}
// SetSource sets the "source" field.
func (sausc *ScaAuthUserSocialCreate) SetSource(s string) *ScaAuthUserSocialCreate {
sausc.mutation.SetSource(s)
return sausc
}
// SetStatus sets the "status" field.
func (sausc *ScaAuthUserSocialCreate) SetStatus(i int) *ScaAuthUserSocialCreate {
sausc.mutation.SetStatus(i)
return sausc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableStatus(i *int) *ScaAuthUserSocialCreate {
if i != nil {
sausc.SetStatus(*i)
}
return sausc
}
// SetID sets the "id" field.
func (sausc *ScaAuthUserSocialCreate) SetID(i int64) *ScaAuthUserSocialCreate {
sausc.mutation.SetID(i)
return sausc
}
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
func (sausc *ScaAuthUserSocialCreate) Mutation() *ScaAuthUserSocialMutation {
return sausc.mutation
}
// Save creates the ScaAuthUserSocial in the database.
func (sausc *ScaAuthUserSocialCreate) Save(ctx context.Context) (*ScaAuthUserSocial, error) {
sausc.defaults()
return withHooks(ctx, sausc.sqlSave, sausc.mutation, sausc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sausc *ScaAuthUserSocialCreate) SaveX(ctx context.Context) *ScaAuthUserSocial {
v, err := sausc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sausc *ScaAuthUserSocialCreate) Exec(ctx context.Context) error {
_, err := sausc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sausc *ScaAuthUserSocialCreate) ExecX(ctx context.Context) {
if err := sausc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sausc *ScaAuthUserSocialCreate) defaults() {
if _, ok := sausc.mutation.CreatedAt(); !ok {
v := scaauthusersocial.DefaultCreatedAt()
sausc.mutation.SetCreatedAt(v)
}
if _, ok := sausc.mutation.Deleted(); !ok {
v := scaauthusersocial.DefaultDeleted
sausc.mutation.SetDeleted(v)
}
if _, ok := sausc.mutation.Status(); !ok {
v := scaauthusersocial.DefaultStatus
sausc.mutation.SetStatus(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sausc *ScaAuthUserSocialCreate) check() error {
if _, ok := sausc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUserSocial.created_at"`)}
}
if _, ok := sausc.mutation.Deleted(); !ok {
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaAuthUserSocial.deleted"`)}
}
if v, ok := sausc.mutation.Deleted(); ok {
if err := scaauthusersocial.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.deleted": %w`, err)}
}
}
if _, ok := sausc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaAuthUserSocial.user_id"`)}
}
if v, ok := sausc.mutation.UserID(); ok {
if err := scaauthusersocial.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
}
}
if _, ok := sausc.mutation.OpenID(); !ok {
return &ValidationError{Name: "open_id", err: errors.New(`ent: missing required field "ScaAuthUserSocial.open_id"`)}
}
if v, ok := sausc.mutation.OpenID(); ok {
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
}
}
if _, ok := sausc.mutation.Source(); !ok {
return &ValidationError{Name: "source", err: errors.New(`ent: missing required field "ScaAuthUserSocial.source"`)}
}
if v, ok := sausc.mutation.Source(); ok {
if err := scaauthusersocial.SourceValidator(v); err != nil {
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
}
}
if _, ok := sausc.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "ScaAuthUserSocial.status"`)}
}
return nil
}
func (sausc *ScaAuthUserSocialCreate) sqlSave(ctx context.Context) (*ScaAuthUserSocial, error) {
if err := sausc.check(); err != nil {
return nil, err
}
_node, _spec := sausc.createSpec()
if err := sqlgraph.CreateNode(ctx, sausc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sausc.mutation.id = &_node.ID
sausc.mutation.done = true
return _node, nil
}
func (sausc *ScaAuthUserSocialCreate) createSpec() (*ScaAuthUserSocial, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthUserSocial{config: sausc.config}
_spec = sqlgraph.NewCreateSpec(scaauthusersocial.Table, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
)
if id, ok := sausc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sausc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sausc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sausc.mutation.Deleted(); ok {
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := sausc.mutation.UserID(); ok {
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := sausc.mutation.OpenID(); ok {
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
_node.OpenID = value
}
if value, ok := sausc.mutation.Source(); ok {
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
_node.Source = value
}
if value, ok := sausc.mutation.Status(); ok {
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
_node.Status = value
}
return _node, _spec
}
// ScaAuthUserSocialCreateBulk is the builder for creating many ScaAuthUserSocial entities in bulk.
type ScaAuthUserSocialCreateBulk struct {
config
err error
builders []*ScaAuthUserSocialCreate
}
// Save creates the ScaAuthUserSocial entities in the database.
func (sauscb *ScaAuthUserSocialCreateBulk) Save(ctx context.Context) ([]*ScaAuthUserSocial, error) {
if sauscb.err != nil {
return nil, sauscb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sauscb.builders))
nodes := make([]*ScaAuthUserSocial, len(sauscb.builders))
mutators := make([]Mutator, len(sauscb.builders))
for i := range sauscb.builders {
func(i int, root context.Context) {
builder := sauscb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthUserSocialMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sauscb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sauscb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sauscb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sauscb *ScaAuthUserSocialCreateBulk) SaveX(ctx context.Context) []*ScaAuthUserSocial {
v, err := sauscb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sauscb *ScaAuthUserSocialCreateBulk) Exec(ctx context.Context) error {
_, err := sauscb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sauscb *ScaAuthUserSocialCreateBulk) ExecX(ctx context.Context) {
if err := sauscb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialDelete is the builder for deleting a ScaAuthUserSocial entity.
type ScaAuthUserSocialDelete struct {
config
hooks []Hook
mutation *ScaAuthUserSocialMutation
}
// Where appends a list predicates to the ScaAuthUserSocialDelete builder.
func (sausd *ScaAuthUserSocialDelete) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialDelete {
sausd.mutation.Where(ps...)
return sausd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (sausd *ScaAuthUserSocialDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, sausd.sqlExec, sausd.mutation, sausd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (sausd *ScaAuthUserSocialDelete) ExecX(ctx context.Context) int {
n, err := sausd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (sausd *ScaAuthUserSocialDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthusersocial.Table, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
if ps := sausd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, sausd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
sausd.mutation.done = true
return affected, err
}
// ScaAuthUserSocialDeleteOne is the builder for deleting a single ScaAuthUserSocial entity.
type ScaAuthUserSocialDeleteOne struct {
sausd *ScaAuthUserSocialDelete
}
// Where appends a list predicates to the ScaAuthUserSocialDelete builder.
func (sausdo *ScaAuthUserSocialDeleteOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialDeleteOne {
sausdo.sausd.mutation.Where(ps...)
return sausdo
}
// Exec executes the deletion query.
func (sausdo *ScaAuthUserSocialDeleteOne) Exec(ctx context.Context) error {
n, err := sausdo.sausd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthusersocial.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sausdo *ScaAuthUserSocialDeleteOne) ExecX(ctx context.Context) {
if err := sausdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialQuery is the builder for querying ScaAuthUserSocial entities.
type ScaAuthUserSocialQuery struct {
config
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)
}
// Where adds a new predicate for the ScaAuthUserSocialQuery builder.
func (sausq *ScaAuthUserSocialQuery) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialQuery {
sausq.predicates = append(sausq.predicates, ps...)
return sausq
}
// Limit the number of records to be returned by this query.
func (sausq *ScaAuthUserSocialQuery) Limit(limit int) *ScaAuthUserSocialQuery {
sausq.ctx.Limit = &limit
return sausq
}
// Offset to start from.
func (sausq *ScaAuthUserSocialQuery) Offset(offset int) *ScaAuthUserSocialQuery {
sausq.ctx.Offset = &offset
return sausq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sausq *ScaAuthUserSocialQuery) Unique(unique bool) *ScaAuthUserSocialQuery {
sausq.ctx.Unique = &unique
return sausq
}
// Order specifies how the records should be ordered.
func (sausq *ScaAuthUserSocialQuery) Order(o ...scaauthusersocial.OrderOption) *ScaAuthUserSocialQuery {
sausq.order = append(sausq.order, o...)
return sausq
}
// 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) {
nodes, err := sausq.Limit(1).All(setContextOp(ctx, sausq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthusersocial.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) FirstX(ctx context.Context) *ScaAuthUserSocial {
node, err := sausq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthUserSocial ID from the query.
// Returns a *NotFoundError when no ScaAuthUserSocial ID was found.
func (sausq *ScaAuthUserSocialQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sausq.Limit(1).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthusersocial.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) FirstIDX(ctx context.Context) int64 {
id, err := sausq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthUserSocial entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthUserSocial entity is found.
// Returns a *NotFoundError when no ScaAuthUserSocial entities are found.
func (sausq *ScaAuthUserSocialQuery) Only(ctx context.Context) (*ScaAuthUserSocial, error) {
nodes, err := sausq.Limit(2).All(setContextOp(ctx, sausq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthusersocial.Label}
default:
return nil, &NotSingularError{scaauthusersocial.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) OnlyX(ctx context.Context) *ScaAuthUserSocial {
node, err := sausq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthUserSocial ID in the query.
// Returns a *NotSingularError when more than one ScaAuthUserSocial ID is found.
// Returns a *NotFoundError when no entities are found.
func (sausq *ScaAuthUserSocialQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sausq.Limit(2).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthusersocial.Label}
default:
err = &NotSingularError{scaauthusersocial.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sausq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthUserSocials.
func (sausq *ScaAuthUserSocialQuery) All(ctx context.Context) ([]*ScaAuthUserSocial, error) {
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryAll)
if err := sausq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthUserSocial, *ScaAuthUserSocialQuery]()
return withInterceptors[[]*ScaAuthUserSocial](ctx, sausq, qr, sausq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) AllX(ctx context.Context) []*ScaAuthUserSocial {
nodes, err := sausq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthUserSocial IDs.
func (sausq *ScaAuthUserSocialQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sausq.ctx.Unique == nil && sausq.path != nil {
sausq.Unique(true)
}
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryIDs)
if err = sausq.Select(scaauthusersocial.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) IDsX(ctx context.Context) []int64 {
ids, err := sausq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sausq *ScaAuthUserSocialQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryCount)
if err := sausq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sausq, querierCount[*ScaAuthUserSocialQuery](), sausq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) CountX(ctx context.Context) int {
count, err := sausq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sausq *ScaAuthUserSocialQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryExist)
switch _, err := sausq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) ExistX(ctx context.Context) bool {
exist, err := sausq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthUserSocialQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sausq *ScaAuthUserSocialQuery) Clone() *ScaAuthUserSocialQuery {
if sausq == nil {
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...),
// clone intermediate query.
sql: sausq.sql.Clone(),
path: sausq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthUserSocial.Query().
// GroupBy(scaauthusersocial.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sausq *ScaAuthUserSocialQuery) GroupBy(field string, fields ...string) *ScaAuthUserSocialGroupBy {
sausq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthUserSocialGroupBy{build: sausq}
grbuild.flds = &sausq.ctx.Fields
grbuild.label = scaauthusersocial.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthUserSocial.Query().
// Select(scaauthusersocial.FieldCreatedAt).
// Scan(ctx, &v)
func (sausq *ScaAuthUserSocialQuery) Select(fields ...string) *ScaAuthUserSocialSelect {
sausq.ctx.Fields = append(sausq.ctx.Fields, fields...)
sbuild := &ScaAuthUserSocialSelect{ScaAuthUserSocialQuery: sausq}
sbuild.label = scaauthusersocial.Label
sbuild.flds, sbuild.scan = &sausq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthUserSocialSelect configured with the given aggregations.
func (sausq *ScaAuthUserSocialQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect {
return sausq.Select().Aggregate(fns...)
}
func (sausq *ScaAuthUserSocialQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sausq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sausq); err != nil {
return err
}
}
}
for _, f := range sausq.ctx.Fields {
if !scaauthusersocial.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sausq.path != nil {
prev, err := sausq.path(ctx)
if err != nil {
return err
}
sausq.sql = prev
}
return nil
}
func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserSocial, error) {
var (
nodes = []*ScaAuthUserSocial{}
_spec = sausq.querySpec()
)
_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)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sausq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (sausq *ScaAuthUserSocialQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sausq.querySpec()
_spec.Node.Columns = sausq.ctx.Fields
if len(sausq.ctx.Fields) > 0 {
_spec.Unique = sausq.ctx.Unique != nil && *sausq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sausq.driver, _spec)
}
func (sausq *ScaAuthUserSocialQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
_spec.From = sausq.sql
if unique := sausq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sausq.path != nil {
_spec.Unique = true
}
if fields := sausq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID)
for i := range fields {
if fields[i] != scaauthusersocial.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sausq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sausq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sausq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sausq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sausq *ScaAuthUserSocialQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sausq.driver.Dialect())
t1 := builder.Table(scaauthusersocial.Table)
columns := sausq.ctx.Fields
if len(columns) == 0 {
columns = scaauthusersocial.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sausq.sql != nil {
selector = sausq.sql
selector.Select(selector.Columns(columns...)...)
}
if sausq.ctx.Unique != nil && *sausq.ctx.Unique {
selector.Distinct()
}
for _, p := range sausq.predicates {
p(selector)
}
for _, p := range sausq.order {
p(selector)
}
if offset := sausq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sausq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthUserSocialGroupBy is the group-by builder for ScaAuthUserSocial entities.
type ScaAuthUserSocialGroupBy struct {
selector
build *ScaAuthUserSocialQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sausgb *ScaAuthUserSocialGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialGroupBy {
sausgb.fns = append(sausgb.fns, fns...)
return sausgb
}
// Scan applies the selector query and scans the result into the given value.
func (sausgb *ScaAuthUserSocialGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sausgb.build.ctx, ent.OpQueryGroupBy)
if err := sausgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialGroupBy](ctx, sausgb.build, sausgb, sausgb.build.inters, v)
}
func (sausgb *ScaAuthUserSocialGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sausgb.fns))
for _, fn := range sausgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sausgb.flds)+len(sausgb.fns))
for _, f := range *sausgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sausgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sausgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthUserSocialSelect is the builder for selecting fields of ScaAuthUserSocial entities.
type ScaAuthUserSocialSelect struct {
*ScaAuthUserSocialQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sauss *ScaAuthUserSocialSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect {
sauss.fns = append(sauss.fns, fns...)
return sauss
}
// Scan applies the selector query and scans the result into the given value.
func (sauss *ScaAuthUserSocialSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sauss.ctx, ent.OpQuerySelect)
if err := sauss.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialSelect](ctx, sauss.ScaAuthUserSocialQuery, sauss, sauss.inters, v)
}
func (sauss *ScaAuthUserSocialSelect) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sauss.fns))
for _, fn := range sauss.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sauss.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sauss.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,496 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialUpdate is the builder for updating ScaAuthUserSocial entities.
type ScaAuthUserSocialUpdate struct {
config
hooks []Hook
mutation *ScaAuthUserSocialMutation
}
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
func (sausu *ScaAuthUserSocialUpdate) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdate {
sausu.mutation.Where(ps...)
return sausu
}
// SetUpdatedAt sets the "updated_at" field.
func (sausu *ScaAuthUserSocialUpdate) SetUpdatedAt(t time.Time) *ScaAuthUserSocialUpdate {
sausu.mutation.SetUpdatedAt(t)
return sausu
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (sausu *ScaAuthUserSocialUpdate) ClearUpdatedAt() *ScaAuthUserSocialUpdate {
sausu.mutation.ClearUpdatedAt()
return sausu
}
// SetDeleted sets the "deleted" field.
func (sausu *ScaAuthUserSocialUpdate) SetDeleted(i int8) *ScaAuthUserSocialUpdate {
sausu.mutation.ResetDeleted()
sausu.mutation.SetDeleted(i)
return sausu
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableDeleted(i *int8) *ScaAuthUserSocialUpdate {
if i != nil {
sausu.SetDeleted(*i)
}
return sausu
}
// AddDeleted adds i to the "deleted" field.
func (sausu *ScaAuthUserSocialUpdate) AddDeleted(i int8) *ScaAuthUserSocialUpdate {
sausu.mutation.AddDeleted(i)
return sausu
}
// SetUserID sets the "user_id" field.
func (sausu *ScaAuthUserSocialUpdate) SetUserID(s string) *ScaAuthUserSocialUpdate {
sausu.mutation.SetUserID(s)
return sausu
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableUserID(s *string) *ScaAuthUserSocialUpdate {
if s != nil {
sausu.SetUserID(*s)
}
return sausu
}
// SetOpenID sets the "open_id" field.
func (sausu *ScaAuthUserSocialUpdate) SetOpenID(s string) *ScaAuthUserSocialUpdate {
sausu.mutation.SetOpenID(s)
return sausu
}
// SetNillableOpenID sets the "open_id" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdate {
if s != nil {
sausu.SetOpenID(*s)
}
return sausu
}
// SetSource sets the "source" field.
func (sausu *ScaAuthUserSocialUpdate) SetSource(s string) *ScaAuthUserSocialUpdate {
sausu.mutation.SetSource(s)
return sausu
}
// SetNillableSource sets the "source" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableSource(s *string) *ScaAuthUserSocialUpdate {
if s != nil {
sausu.SetSource(*s)
}
return sausu
}
// SetStatus sets the "status" field.
func (sausu *ScaAuthUserSocialUpdate) SetStatus(i int) *ScaAuthUserSocialUpdate {
sausu.mutation.ResetStatus()
sausu.mutation.SetStatus(i)
return sausu
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableStatus(i *int) *ScaAuthUserSocialUpdate {
if i != nil {
sausu.SetStatus(*i)
}
return sausu
}
// AddStatus adds i to the "status" field.
func (sausu *ScaAuthUserSocialUpdate) AddStatus(i int) *ScaAuthUserSocialUpdate {
sausu.mutation.AddStatus(i)
return sausu
}
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
func (sausu *ScaAuthUserSocialUpdate) Mutation() *ScaAuthUserSocialMutation {
return sausu.mutation
}
// 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()
return withHooks(ctx, sausu.sqlSave, sausu.mutation, sausu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sausu *ScaAuthUserSocialUpdate) SaveX(ctx context.Context) int {
affected, err := sausu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (sausu *ScaAuthUserSocialUpdate) Exec(ctx context.Context) error {
_, err := sausu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sausu *ScaAuthUserSocialUpdate) ExecX(ctx context.Context) {
if err := sausu.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sausu *ScaAuthUserSocialUpdate) defaults() {
if _, ok := sausu.mutation.UpdatedAt(); !ok && !sausu.mutation.UpdatedAtCleared() {
v := scaauthusersocial.UpdateDefaultUpdatedAt()
sausu.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sausu *ScaAuthUserSocialUpdate) check() error {
if v, ok := sausu.mutation.Deleted(); ok {
if err := scaauthusersocial.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.deleted": %w`, err)}
}
}
if v, ok := sausu.mutation.UserID(); ok {
if err := scaauthusersocial.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
}
}
if v, ok := sausu.mutation.OpenID(); ok {
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
}
}
if v, ok := sausu.mutation.Source(); ok {
if err := scaauthusersocial.SourceValidator(v); err != nil {
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
}
}
return nil
}
func (sausu *ScaAuthUserSocialUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := sausu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
if ps := sausu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sausu.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldUpdatedAt, field.TypeTime, value)
}
if sausu.mutation.UpdatedAtCleared() {
_spec.ClearField(scaauthusersocial.FieldUpdatedAt, field.TypeTime)
}
if value, ok := sausu.mutation.Deleted(); ok {
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sausu.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sausu.mutation.UserID(); ok {
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
}
if value, ok := sausu.mutation.OpenID(); ok {
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
}
if value, ok := sausu.mutation.Source(); ok {
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
}
if value, ok := sausu.mutation.Status(); ok {
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
if value, ok := sausu.mutation.AddedStatus(); ok {
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
if n, err = sqlgraph.UpdateNodes(ctx, sausu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthusersocial.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
sausu.mutation.done = true
return n, nil
}
// ScaAuthUserSocialUpdateOne is the builder for updating a single ScaAuthUserSocial entity.
type ScaAuthUserSocialUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthUserSocialMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetUpdatedAt(t time.Time) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetUpdatedAt(t)
return sausuo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (sausuo *ScaAuthUserSocialUpdateOne) ClearUpdatedAt() *ScaAuthUserSocialUpdateOne {
sausuo.mutation.ClearUpdatedAt()
return sausuo
}
// SetDeleted sets the "deleted" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetDeleted(i int8) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.ResetDeleted()
sausuo.mutation.SetDeleted(i)
return sausuo
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableDeleted(i *int8) *ScaAuthUserSocialUpdateOne {
if i != nil {
sausuo.SetDeleted(*i)
}
return sausuo
}
// AddDeleted adds i to the "deleted" field.
func (sausuo *ScaAuthUserSocialUpdateOne) AddDeleted(i int8) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.AddDeleted(i)
return sausuo
}
// SetUserID sets the "user_id" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetUserID(s string) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetUserID(s)
return sausuo
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableUserID(s *string) *ScaAuthUserSocialUpdateOne {
if s != nil {
sausuo.SetUserID(*s)
}
return sausuo
}
// SetOpenID sets the "open_id" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetOpenID(s string) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetOpenID(s)
return sausuo
}
// SetNillableOpenID sets the "open_id" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdateOne {
if s != nil {
sausuo.SetOpenID(*s)
}
return sausuo
}
// SetSource sets the "source" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetSource(s string) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetSource(s)
return sausuo
}
// SetNillableSource sets the "source" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableSource(s *string) *ScaAuthUserSocialUpdateOne {
if s != nil {
sausuo.SetSource(*s)
}
return sausuo
}
// SetStatus sets the "status" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetStatus(i int) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.ResetStatus()
sausuo.mutation.SetStatus(i)
return sausuo
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableStatus(i *int) *ScaAuthUserSocialUpdateOne {
if i != nil {
sausuo.SetStatus(*i)
}
return sausuo
}
// AddStatus adds i to the "status" field.
func (sausuo *ScaAuthUserSocialUpdateOne) AddStatus(i int) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.AddStatus(i)
return sausuo
}
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
func (sausuo *ScaAuthUserSocialUpdateOne) Mutation() *ScaAuthUserSocialMutation {
return sausuo.mutation
}
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
func (sausuo *ScaAuthUserSocialUpdateOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.Where(ps...)
return sausuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (sausuo *ScaAuthUserSocialUpdateOne) Select(field string, fields ...string) *ScaAuthUserSocialUpdateOne {
sausuo.fields = append([]string{field}, fields...)
return sausuo
}
// Save executes the query and returns the updated ScaAuthUserSocial entity.
func (sausuo *ScaAuthUserSocialUpdateOne) Save(ctx context.Context) (*ScaAuthUserSocial, error) {
sausuo.defaults()
return withHooks(ctx, sausuo.sqlSave, sausuo.mutation, sausuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sausuo *ScaAuthUserSocialUpdateOne) SaveX(ctx context.Context) *ScaAuthUserSocial {
node, err := sausuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (sausuo *ScaAuthUserSocialUpdateOne) Exec(ctx context.Context) error {
_, err := sausuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sausuo *ScaAuthUserSocialUpdateOne) ExecX(ctx context.Context) {
if err := sausuo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sausuo *ScaAuthUserSocialUpdateOne) defaults() {
if _, ok := sausuo.mutation.UpdatedAt(); !ok && !sausuo.mutation.UpdatedAtCleared() {
v := scaauthusersocial.UpdateDefaultUpdatedAt()
sausuo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sausuo *ScaAuthUserSocialUpdateOne) check() error {
if v, ok := sausuo.mutation.Deleted(); ok {
if err := scaauthusersocial.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.deleted": %w`, err)}
}
}
if v, ok := sausuo.mutation.UserID(); ok {
if err := scaauthusersocial.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
}
}
if v, ok := sausuo.mutation.OpenID(); ok {
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
}
}
if v, ok := sausuo.mutation.Source(); ok {
if err := scaauthusersocial.SourceValidator(v); err != nil {
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
}
}
return nil
}
func (sausuo *ScaAuthUserSocialUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUserSocial, err error) {
if err := sausuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
id, ok := sausuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUserSocial.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := sausuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID)
for _, f := range fields {
if !scaauthusersocial.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthusersocial.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := sausuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sausuo.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldUpdatedAt, field.TypeTime, value)
}
if sausuo.mutation.UpdatedAtCleared() {
_spec.ClearField(scaauthusersocial.FieldUpdatedAt, field.TypeTime)
}
if value, ok := sausuo.mutation.Deleted(); ok {
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sausuo.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sausuo.mutation.UserID(); ok {
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
}
if value, ok := sausuo.mutation.OpenID(); ok {
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
}
if value, ok := sausuo.mutation.Source(); ok {
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
}
if value, ok := sausuo.mutation.Status(); ok {
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
if value, ok := sausuo.mutation.AddedStatus(); ok {
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
_node = &ScaAuthUserSocial{config: sausuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, sausuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthusersocial.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
sausuo.mutation.done = true
return _node, nil
}

View File

@@ -1,140 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 评论点赞表
type ScaCommentLikes struct {
config `json:"-"`
// ID of the ent.
// 主键id
ID int64 `json:"id,omitempty"`
// 话题ID
TopicID string `json:"topic_id,omitempty"`
// 用户ID
UserID string `json:"user_id,omitempty"`
// 评论ID
CommentID int64 `json:"comment_id,omitempty"`
// 点赞时间
LikeTime time.Time `json:"like_time,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaCommentLikes) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scacommentlikes.FieldID, scacommentlikes.FieldCommentID:
values[i] = new(sql.NullInt64)
case scacommentlikes.FieldTopicID, scacommentlikes.FieldUserID:
values[i] = new(sql.NullString)
case scacommentlikes.FieldLikeTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaCommentLikes fields.
func (scl *ScaCommentLikes) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scacommentlikes.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
scl.ID = int64(value.Int64)
case scacommentlikes.FieldTopicID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field topic_id", values[i])
} else if value.Valid {
scl.TopicID = value.String
}
case scacommentlikes.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
scl.UserID = value.String
}
case scacommentlikes.FieldCommentID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field comment_id", values[i])
} else if value.Valid {
scl.CommentID = value.Int64
}
case scacommentlikes.FieldLikeTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field like_time", values[i])
} else if value.Valid {
scl.LikeTime = value.Time
}
default:
scl.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaCommentLikes.
// This includes values selected through modifiers, order, etc.
func (scl *ScaCommentLikes) Value(name string) (ent.Value, error) {
return scl.selectValues.Get(name)
}
// Update returns a builder for updating this ScaCommentLikes.
// Note that you need to call ScaCommentLikes.Unwrap() before calling this method if this ScaCommentLikes
// was returned from a transaction, and the transaction was committed or rolled back.
func (scl *ScaCommentLikes) Update() *ScaCommentLikesUpdateOne {
return NewScaCommentLikesClient(scl.config).UpdateOne(scl)
}
// Unwrap unwraps the ScaCommentLikes entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (scl *ScaCommentLikes) Unwrap() *ScaCommentLikes {
_tx, ok := scl.config.driver.(*txDriver)
if !ok {
panic("ent: ScaCommentLikes is not a transactional entity")
}
scl.config.driver = _tx.drv
return scl
}
// String implements the fmt.Stringer.
func (scl *ScaCommentLikes) String() string {
var builder strings.Builder
builder.WriteString("ScaCommentLikes(")
builder.WriteString(fmt.Sprintf("id=%v, ", scl.ID))
builder.WriteString("topic_id=")
builder.WriteString(scl.TopicID)
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(scl.UserID)
builder.WriteString(", ")
builder.WriteString("comment_id=")
builder.WriteString(fmt.Sprintf("%v", scl.CommentID))
builder.WriteString(", ")
builder.WriteString("like_time=")
builder.WriteString(scl.LikeTime.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// ScaCommentLikesSlice is a parsable slice of ScaCommentLikes.
type ScaCommentLikesSlice []*ScaCommentLikes

View File

@@ -1,78 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scacommentlikes
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scacommentlikes type in the database.
Label = "sca_comment_likes"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTopicID holds the string denoting the topic_id field in the database.
FieldTopicID = "topic_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldCommentID holds the string denoting the comment_id field in the database.
FieldCommentID = "comment_id"
// FieldLikeTime holds the string denoting the like_time field in the database.
FieldLikeTime = "like_time"
// Table holds the table name of the scacommentlikes in the database.
Table = "sca_comment_likes"
)
// Columns holds all SQL columns for scacommentlikes fields.
var Columns = []string{
FieldID,
FieldTopicID,
FieldUserID,
FieldCommentID,
FieldLikeTime,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultLikeTime holds the default value on creation for the "like_time" field.
DefaultLikeTime func() time.Time
)
// OrderOption defines the ordering options for the ScaCommentLikes queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByTopicID orders the results by the topic_id field.
func ByTopicID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTopicID, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByCommentID orders the results by the comment_id field.
func ByCommentID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCommentID, opts...).ToFunc()
}
// ByLikeTime orders the results by the like_time field.
func ByLikeTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLikeTime, opts...).ToFunc()
}

View File

@@ -1,300 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scacommentlikes
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLTE(FieldID, id))
}
// TopicID applies equality check predicate on the "topic_id" field. It's identical to TopicIDEQ.
func TopicID(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldTopicID, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldUserID, v))
}
// CommentID applies equality check predicate on the "comment_id" field. It's identical to CommentIDEQ.
func CommentID(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldCommentID, v))
}
// LikeTime applies equality check predicate on the "like_time" field. It's identical to LikeTimeEQ.
func LikeTime(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldLikeTime, v))
}
// TopicIDEQ applies the EQ predicate on the "topic_id" field.
func TopicIDEQ(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldTopicID, v))
}
// TopicIDNEQ applies the NEQ predicate on the "topic_id" field.
func TopicIDNEQ(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNEQ(FieldTopicID, v))
}
// TopicIDIn applies the In predicate on the "topic_id" field.
func TopicIDIn(vs ...string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldIn(FieldTopicID, vs...))
}
// TopicIDNotIn applies the NotIn predicate on the "topic_id" field.
func TopicIDNotIn(vs ...string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNotIn(FieldTopicID, vs...))
}
// TopicIDGT applies the GT predicate on the "topic_id" field.
func TopicIDGT(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGT(FieldTopicID, v))
}
// TopicIDGTE applies the GTE predicate on the "topic_id" field.
func TopicIDGTE(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGTE(FieldTopicID, v))
}
// TopicIDLT applies the LT predicate on the "topic_id" field.
func TopicIDLT(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLT(FieldTopicID, v))
}
// TopicIDLTE applies the LTE predicate on the "topic_id" field.
func TopicIDLTE(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLTE(FieldTopicID, v))
}
// TopicIDContains applies the Contains predicate on the "topic_id" field.
func TopicIDContains(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldContains(FieldTopicID, v))
}
// TopicIDHasPrefix applies the HasPrefix predicate on the "topic_id" field.
func TopicIDHasPrefix(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldHasPrefix(FieldTopicID, v))
}
// TopicIDHasSuffix applies the HasSuffix predicate on the "topic_id" field.
func TopicIDHasSuffix(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldHasSuffix(FieldTopicID, v))
}
// TopicIDEqualFold applies the EqualFold predicate on the "topic_id" field.
func TopicIDEqualFold(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEqualFold(FieldTopicID, v))
}
// TopicIDContainsFold applies the ContainsFold predicate on the "topic_id" field.
func TopicIDContainsFold(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldContainsFold(FieldTopicID, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLTE(FieldUserID, v))
}
// UserIDContains applies the Contains predicate on the "user_id" field.
func UserIDContains(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldContains(FieldUserID, v))
}
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
func UserIDHasPrefix(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldHasPrefix(FieldUserID, v))
}
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
func UserIDHasSuffix(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldHasSuffix(FieldUserID, v))
}
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
func UserIDEqualFold(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEqualFold(FieldUserID, v))
}
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
func UserIDContainsFold(v string) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldContainsFold(FieldUserID, v))
}
// CommentIDEQ applies the EQ predicate on the "comment_id" field.
func CommentIDEQ(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldCommentID, v))
}
// CommentIDNEQ applies the NEQ predicate on the "comment_id" field.
func CommentIDNEQ(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNEQ(FieldCommentID, v))
}
// CommentIDIn applies the In predicate on the "comment_id" field.
func CommentIDIn(vs ...int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldIn(FieldCommentID, vs...))
}
// CommentIDNotIn applies the NotIn predicate on the "comment_id" field.
func CommentIDNotIn(vs ...int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNotIn(FieldCommentID, vs...))
}
// CommentIDGT applies the GT predicate on the "comment_id" field.
func CommentIDGT(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGT(FieldCommentID, v))
}
// CommentIDGTE applies the GTE predicate on the "comment_id" field.
func CommentIDGTE(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGTE(FieldCommentID, v))
}
// CommentIDLT applies the LT predicate on the "comment_id" field.
func CommentIDLT(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLT(FieldCommentID, v))
}
// CommentIDLTE applies the LTE predicate on the "comment_id" field.
func CommentIDLTE(v int64) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLTE(FieldCommentID, v))
}
// LikeTimeEQ applies the EQ predicate on the "like_time" field.
func LikeTimeEQ(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldEQ(FieldLikeTime, v))
}
// LikeTimeNEQ applies the NEQ predicate on the "like_time" field.
func LikeTimeNEQ(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNEQ(FieldLikeTime, v))
}
// LikeTimeIn applies the In predicate on the "like_time" field.
func LikeTimeIn(vs ...time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldIn(FieldLikeTime, vs...))
}
// LikeTimeNotIn applies the NotIn predicate on the "like_time" field.
func LikeTimeNotIn(vs ...time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldNotIn(FieldLikeTime, vs...))
}
// LikeTimeGT applies the GT predicate on the "like_time" field.
func LikeTimeGT(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGT(FieldLikeTime, v))
}
// LikeTimeGTE applies the GTE predicate on the "like_time" field.
func LikeTimeGTE(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldGTE(FieldLikeTime, v))
}
// LikeTimeLT applies the LT predicate on the "like_time" field.
func LikeTimeLT(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLT(FieldLikeTime, v))
}
// LikeTimeLTE applies the LTE predicate on the "like_time" field.
func LikeTimeLTE(v time.Time) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.FieldLTE(FieldLikeTime, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaCommentLikes) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaCommentLikes) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaCommentLikes) predicate.ScaCommentLikes {
return predicate.ScaCommentLikes(sql.NotPredicates(p))
}

View File

@@ -1,253 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentLikesCreate is the builder for creating a ScaCommentLikes entity.
type ScaCommentLikesCreate struct {
config
mutation *ScaCommentLikesMutation
hooks []Hook
}
// SetTopicID sets the "topic_id" field.
func (sclc *ScaCommentLikesCreate) SetTopicID(s string) *ScaCommentLikesCreate {
sclc.mutation.SetTopicID(s)
return sclc
}
// SetUserID sets the "user_id" field.
func (sclc *ScaCommentLikesCreate) SetUserID(s string) *ScaCommentLikesCreate {
sclc.mutation.SetUserID(s)
return sclc
}
// SetCommentID sets the "comment_id" field.
func (sclc *ScaCommentLikesCreate) SetCommentID(i int64) *ScaCommentLikesCreate {
sclc.mutation.SetCommentID(i)
return sclc
}
// SetLikeTime sets the "like_time" field.
func (sclc *ScaCommentLikesCreate) SetLikeTime(t time.Time) *ScaCommentLikesCreate {
sclc.mutation.SetLikeTime(t)
return sclc
}
// SetNillableLikeTime sets the "like_time" field if the given value is not nil.
func (sclc *ScaCommentLikesCreate) SetNillableLikeTime(t *time.Time) *ScaCommentLikesCreate {
if t != nil {
sclc.SetLikeTime(*t)
}
return sclc
}
// SetID sets the "id" field.
func (sclc *ScaCommentLikesCreate) SetID(i int64) *ScaCommentLikesCreate {
sclc.mutation.SetID(i)
return sclc
}
// Mutation returns the ScaCommentLikesMutation object of the builder.
func (sclc *ScaCommentLikesCreate) Mutation() *ScaCommentLikesMutation {
return sclc.mutation
}
// Save creates the ScaCommentLikes in the database.
func (sclc *ScaCommentLikesCreate) Save(ctx context.Context) (*ScaCommentLikes, error) {
sclc.defaults()
return withHooks(ctx, sclc.sqlSave, sclc.mutation, sclc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sclc *ScaCommentLikesCreate) SaveX(ctx context.Context) *ScaCommentLikes {
v, err := sclc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sclc *ScaCommentLikesCreate) Exec(ctx context.Context) error {
_, err := sclc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sclc *ScaCommentLikesCreate) ExecX(ctx context.Context) {
if err := sclc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sclc *ScaCommentLikesCreate) defaults() {
if _, ok := sclc.mutation.LikeTime(); !ok {
v := scacommentlikes.DefaultLikeTime()
sclc.mutation.SetLikeTime(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sclc *ScaCommentLikesCreate) check() error {
if _, ok := sclc.mutation.TopicID(); !ok {
return &ValidationError{Name: "topic_id", err: errors.New(`ent: missing required field "ScaCommentLikes.topic_id"`)}
}
if _, ok := sclc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaCommentLikes.user_id"`)}
}
if _, ok := sclc.mutation.CommentID(); !ok {
return &ValidationError{Name: "comment_id", err: errors.New(`ent: missing required field "ScaCommentLikes.comment_id"`)}
}
if _, ok := sclc.mutation.LikeTime(); !ok {
return &ValidationError{Name: "like_time", err: errors.New(`ent: missing required field "ScaCommentLikes.like_time"`)}
}
return nil
}
func (sclc *ScaCommentLikesCreate) sqlSave(ctx context.Context) (*ScaCommentLikes, error) {
if err := sclc.check(); err != nil {
return nil, err
}
_node, _spec := sclc.createSpec()
if err := sqlgraph.CreateNode(ctx, sclc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sclc.mutation.id = &_node.ID
sclc.mutation.done = true
return _node, nil
}
func (sclc *ScaCommentLikesCreate) createSpec() (*ScaCommentLikes, *sqlgraph.CreateSpec) {
var (
_node = &ScaCommentLikes{config: sclc.config}
_spec = sqlgraph.NewCreateSpec(scacommentlikes.Table, sqlgraph.NewFieldSpec(scacommentlikes.FieldID, field.TypeInt64))
)
if id, ok := sclc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sclc.mutation.TopicID(); ok {
_spec.SetField(scacommentlikes.FieldTopicID, field.TypeString, value)
_node.TopicID = value
}
if value, ok := sclc.mutation.UserID(); ok {
_spec.SetField(scacommentlikes.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := sclc.mutation.CommentID(); ok {
_spec.SetField(scacommentlikes.FieldCommentID, field.TypeInt64, value)
_node.CommentID = value
}
if value, ok := sclc.mutation.LikeTime(); ok {
_spec.SetField(scacommentlikes.FieldLikeTime, field.TypeTime, value)
_node.LikeTime = value
}
return _node, _spec
}
// ScaCommentLikesCreateBulk is the builder for creating many ScaCommentLikes entities in bulk.
type ScaCommentLikesCreateBulk struct {
config
err error
builders []*ScaCommentLikesCreate
}
// Save creates the ScaCommentLikes entities in the database.
func (sclcb *ScaCommentLikesCreateBulk) Save(ctx context.Context) ([]*ScaCommentLikes, error) {
if sclcb.err != nil {
return nil, sclcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sclcb.builders))
nodes := make([]*ScaCommentLikes, len(sclcb.builders))
mutators := make([]Mutator, len(sclcb.builders))
for i := range sclcb.builders {
func(i int, root context.Context) {
builder := sclcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaCommentLikesMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sclcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sclcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sclcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sclcb *ScaCommentLikesCreateBulk) SaveX(ctx context.Context) []*ScaCommentLikes {
v, err := sclcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sclcb *ScaCommentLikesCreateBulk) Exec(ctx context.Context) error {
_, err := sclcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sclcb *ScaCommentLikesCreateBulk) ExecX(ctx context.Context) {
if err := sclcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentLikesDelete is the builder for deleting a ScaCommentLikes entity.
type ScaCommentLikesDelete struct {
config
hooks []Hook
mutation *ScaCommentLikesMutation
}
// Where appends a list predicates to the ScaCommentLikesDelete builder.
func (scld *ScaCommentLikesDelete) Where(ps ...predicate.ScaCommentLikes) *ScaCommentLikesDelete {
scld.mutation.Where(ps...)
return scld
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (scld *ScaCommentLikesDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, scld.sqlExec, scld.mutation, scld.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (scld *ScaCommentLikesDelete) ExecX(ctx context.Context) int {
n, err := scld.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (scld *ScaCommentLikesDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scacommentlikes.Table, sqlgraph.NewFieldSpec(scacommentlikes.FieldID, field.TypeInt64))
if ps := scld.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, scld.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
scld.mutation.done = true
return affected, err
}
// ScaCommentLikesDeleteOne is the builder for deleting a single ScaCommentLikes entity.
type ScaCommentLikesDeleteOne struct {
scld *ScaCommentLikesDelete
}
// Where appends a list predicates to the ScaCommentLikesDelete builder.
func (scldo *ScaCommentLikesDeleteOne) Where(ps ...predicate.ScaCommentLikes) *ScaCommentLikesDeleteOne {
scldo.scld.mutation.Where(ps...)
return scldo
}
// Exec executes the deletion query.
func (scldo *ScaCommentLikesDeleteOne) Exec(ctx context.Context) error {
n, err := scldo.scld.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scacommentlikes.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (scldo *ScaCommentLikesDeleteOne) ExecX(ctx context.Context) {
if err := scldo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentLikesQuery is the builder for querying ScaCommentLikes entities.
type ScaCommentLikesQuery struct {
config
ctx *QueryContext
order []scacommentlikes.OrderOption
inters []Interceptor
predicates []predicate.ScaCommentLikes
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaCommentLikesQuery builder.
func (sclq *ScaCommentLikesQuery) Where(ps ...predicate.ScaCommentLikes) *ScaCommentLikesQuery {
sclq.predicates = append(sclq.predicates, ps...)
return sclq
}
// Limit the number of records to be returned by this query.
func (sclq *ScaCommentLikesQuery) Limit(limit int) *ScaCommentLikesQuery {
sclq.ctx.Limit = &limit
return sclq
}
// Offset to start from.
func (sclq *ScaCommentLikesQuery) Offset(offset int) *ScaCommentLikesQuery {
sclq.ctx.Offset = &offset
return sclq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sclq *ScaCommentLikesQuery) Unique(unique bool) *ScaCommentLikesQuery {
sclq.ctx.Unique = &unique
return sclq
}
// Order specifies how the records should be ordered.
func (sclq *ScaCommentLikesQuery) Order(o ...scacommentlikes.OrderOption) *ScaCommentLikesQuery {
sclq.order = append(sclq.order, o...)
return sclq
}
// First returns the first ScaCommentLikes entity from the query.
// Returns a *NotFoundError when no ScaCommentLikes was found.
func (sclq *ScaCommentLikesQuery) First(ctx context.Context) (*ScaCommentLikes, error) {
nodes, err := sclq.Limit(1).All(setContextOp(ctx, sclq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scacommentlikes.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) FirstX(ctx context.Context) *ScaCommentLikes {
node, err := sclq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaCommentLikes ID from the query.
// Returns a *NotFoundError when no ScaCommentLikes ID was found.
func (sclq *ScaCommentLikesQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sclq.Limit(1).IDs(setContextOp(ctx, sclq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scacommentlikes.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) FirstIDX(ctx context.Context) int64 {
id, err := sclq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaCommentLikes entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaCommentLikes entity is found.
// Returns a *NotFoundError when no ScaCommentLikes entities are found.
func (sclq *ScaCommentLikesQuery) Only(ctx context.Context) (*ScaCommentLikes, error) {
nodes, err := sclq.Limit(2).All(setContextOp(ctx, sclq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scacommentlikes.Label}
default:
return nil, &NotSingularError{scacommentlikes.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) OnlyX(ctx context.Context) *ScaCommentLikes {
node, err := sclq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaCommentLikes ID in the query.
// Returns a *NotSingularError when more than one ScaCommentLikes ID is found.
// Returns a *NotFoundError when no entities are found.
func (sclq *ScaCommentLikesQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sclq.Limit(2).IDs(setContextOp(ctx, sclq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scacommentlikes.Label}
default:
err = &NotSingularError{scacommentlikes.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sclq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaCommentLikesSlice.
func (sclq *ScaCommentLikesQuery) All(ctx context.Context) ([]*ScaCommentLikes, error) {
ctx = setContextOp(ctx, sclq.ctx, ent.OpQueryAll)
if err := sclq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaCommentLikes, *ScaCommentLikesQuery]()
return withInterceptors[[]*ScaCommentLikes](ctx, sclq, qr, sclq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) AllX(ctx context.Context) []*ScaCommentLikes {
nodes, err := sclq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaCommentLikes IDs.
func (sclq *ScaCommentLikesQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sclq.ctx.Unique == nil && sclq.path != nil {
sclq.Unique(true)
}
ctx = setContextOp(ctx, sclq.ctx, ent.OpQueryIDs)
if err = sclq.Select(scacommentlikes.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) IDsX(ctx context.Context) []int64 {
ids, err := sclq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sclq *ScaCommentLikesQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sclq.ctx, ent.OpQueryCount)
if err := sclq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sclq, querierCount[*ScaCommentLikesQuery](), sclq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) CountX(ctx context.Context) int {
count, err := sclq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sclq *ScaCommentLikesQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sclq.ctx, ent.OpQueryExist)
switch _, err := sclq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sclq *ScaCommentLikesQuery) ExistX(ctx context.Context) bool {
exist, err := sclq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaCommentLikesQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sclq *ScaCommentLikesQuery) Clone() *ScaCommentLikesQuery {
if sclq == nil {
return nil
}
return &ScaCommentLikesQuery{
config: sclq.config,
ctx: sclq.ctx.Clone(),
order: append([]scacommentlikes.OrderOption{}, sclq.order...),
inters: append([]Interceptor{}, sclq.inters...),
predicates: append([]predicate.ScaCommentLikes{}, sclq.predicates...),
// clone intermediate query.
sql: sclq.sql.Clone(),
path: sclq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// TopicID string `json:"topic_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaCommentLikes.Query().
// GroupBy(scacommentlikes.FieldTopicID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sclq *ScaCommentLikesQuery) GroupBy(field string, fields ...string) *ScaCommentLikesGroupBy {
sclq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaCommentLikesGroupBy{build: sclq}
grbuild.flds = &sclq.ctx.Fields
grbuild.label = scacommentlikes.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// TopicID string `json:"topic_id,omitempty"`
// }
//
// client.ScaCommentLikes.Query().
// Select(scacommentlikes.FieldTopicID).
// Scan(ctx, &v)
func (sclq *ScaCommentLikesQuery) Select(fields ...string) *ScaCommentLikesSelect {
sclq.ctx.Fields = append(sclq.ctx.Fields, fields...)
sbuild := &ScaCommentLikesSelect{ScaCommentLikesQuery: sclq}
sbuild.label = scacommentlikes.Label
sbuild.flds, sbuild.scan = &sclq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaCommentLikesSelect configured with the given aggregations.
func (sclq *ScaCommentLikesQuery) Aggregate(fns ...AggregateFunc) *ScaCommentLikesSelect {
return sclq.Select().Aggregate(fns...)
}
func (sclq *ScaCommentLikesQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sclq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sclq); err != nil {
return err
}
}
}
for _, f := range sclq.ctx.Fields {
if !scacommentlikes.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sclq.path != nil {
prev, err := sclq.path(ctx)
if err != nil {
return err
}
sclq.sql = prev
}
return nil
}
func (sclq *ScaCommentLikesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaCommentLikes, error) {
var (
nodes = []*ScaCommentLikes{}
_spec = sclq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaCommentLikes).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaCommentLikes{config: sclq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sclq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (sclq *ScaCommentLikesQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sclq.querySpec()
_spec.Node.Columns = sclq.ctx.Fields
if len(sclq.ctx.Fields) > 0 {
_spec.Unique = sclq.ctx.Unique != nil && *sclq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sclq.driver, _spec)
}
func (sclq *ScaCommentLikesQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scacommentlikes.Table, scacommentlikes.Columns, sqlgraph.NewFieldSpec(scacommentlikes.FieldID, field.TypeInt64))
_spec.From = sclq.sql
if unique := sclq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sclq.path != nil {
_spec.Unique = true
}
if fields := sclq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scacommentlikes.FieldID)
for i := range fields {
if fields[i] != scacommentlikes.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sclq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sclq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sclq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sclq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sclq *ScaCommentLikesQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sclq.driver.Dialect())
t1 := builder.Table(scacommentlikes.Table)
columns := sclq.ctx.Fields
if len(columns) == 0 {
columns = scacommentlikes.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sclq.sql != nil {
selector = sclq.sql
selector.Select(selector.Columns(columns...)...)
}
if sclq.ctx.Unique != nil && *sclq.ctx.Unique {
selector.Distinct()
}
for _, p := range sclq.predicates {
p(selector)
}
for _, p := range sclq.order {
p(selector)
}
if offset := sclq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sclq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaCommentLikesGroupBy is the group-by builder for ScaCommentLikes entities.
type ScaCommentLikesGroupBy struct {
selector
build *ScaCommentLikesQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sclgb *ScaCommentLikesGroupBy) Aggregate(fns ...AggregateFunc) *ScaCommentLikesGroupBy {
sclgb.fns = append(sclgb.fns, fns...)
return sclgb
}
// Scan applies the selector query and scans the result into the given value.
func (sclgb *ScaCommentLikesGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sclgb.build.ctx, ent.OpQueryGroupBy)
if err := sclgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaCommentLikesQuery, *ScaCommentLikesGroupBy](ctx, sclgb.build, sclgb, sclgb.build.inters, v)
}
func (sclgb *ScaCommentLikesGroupBy) sqlScan(ctx context.Context, root *ScaCommentLikesQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sclgb.fns))
for _, fn := range sclgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sclgb.flds)+len(sclgb.fns))
for _, f := range *sclgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sclgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sclgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaCommentLikesSelect is the builder for selecting fields of ScaCommentLikes entities.
type ScaCommentLikesSelect struct {
*ScaCommentLikesQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (scls *ScaCommentLikesSelect) Aggregate(fns ...AggregateFunc) *ScaCommentLikesSelect {
scls.fns = append(scls.fns, fns...)
return scls
}
// Scan applies the selector query and scans the result into the given value.
func (scls *ScaCommentLikesSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, scls.ctx, ent.OpQuerySelect)
if err := scls.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaCommentLikesQuery, *ScaCommentLikesSelect](ctx, scls.ScaCommentLikesQuery, scls, scls.inters, v)
}
func (scls *ScaCommentLikesSelect) sqlScan(ctx context.Context, root *ScaCommentLikesQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(scls.fns))
for _, fn := range scls.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*scls.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := scls.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,332 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentlikes"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentLikesUpdate is the builder for updating ScaCommentLikes entities.
type ScaCommentLikesUpdate struct {
config
hooks []Hook
mutation *ScaCommentLikesMutation
}
// Where appends a list predicates to the ScaCommentLikesUpdate builder.
func (sclu *ScaCommentLikesUpdate) Where(ps ...predicate.ScaCommentLikes) *ScaCommentLikesUpdate {
sclu.mutation.Where(ps...)
return sclu
}
// SetTopicID sets the "topic_id" field.
func (sclu *ScaCommentLikesUpdate) SetTopicID(s string) *ScaCommentLikesUpdate {
sclu.mutation.SetTopicID(s)
return sclu
}
// SetNillableTopicID sets the "topic_id" field if the given value is not nil.
func (sclu *ScaCommentLikesUpdate) SetNillableTopicID(s *string) *ScaCommentLikesUpdate {
if s != nil {
sclu.SetTopicID(*s)
}
return sclu
}
// SetUserID sets the "user_id" field.
func (sclu *ScaCommentLikesUpdate) SetUserID(s string) *ScaCommentLikesUpdate {
sclu.mutation.SetUserID(s)
return sclu
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (sclu *ScaCommentLikesUpdate) SetNillableUserID(s *string) *ScaCommentLikesUpdate {
if s != nil {
sclu.SetUserID(*s)
}
return sclu
}
// SetCommentID sets the "comment_id" field.
func (sclu *ScaCommentLikesUpdate) SetCommentID(i int64) *ScaCommentLikesUpdate {
sclu.mutation.ResetCommentID()
sclu.mutation.SetCommentID(i)
return sclu
}
// SetNillableCommentID sets the "comment_id" field if the given value is not nil.
func (sclu *ScaCommentLikesUpdate) SetNillableCommentID(i *int64) *ScaCommentLikesUpdate {
if i != nil {
sclu.SetCommentID(*i)
}
return sclu
}
// AddCommentID adds i to the "comment_id" field.
func (sclu *ScaCommentLikesUpdate) AddCommentID(i int64) *ScaCommentLikesUpdate {
sclu.mutation.AddCommentID(i)
return sclu
}
// SetLikeTime sets the "like_time" field.
func (sclu *ScaCommentLikesUpdate) SetLikeTime(t time.Time) *ScaCommentLikesUpdate {
sclu.mutation.SetLikeTime(t)
return sclu
}
// SetNillableLikeTime sets the "like_time" field if the given value is not nil.
func (sclu *ScaCommentLikesUpdate) SetNillableLikeTime(t *time.Time) *ScaCommentLikesUpdate {
if t != nil {
sclu.SetLikeTime(*t)
}
return sclu
}
// Mutation returns the ScaCommentLikesMutation object of the builder.
func (sclu *ScaCommentLikesUpdate) Mutation() *ScaCommentLikesMutation {
return sclu.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (sclu *ScaCommentLikesUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, sclu.sqlSave, sclu.mutation, sclu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sclu *ScaCommentLikesUpdate) SaveX(ctx context.Context) int {
affected, err := sclu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (sclu *ScaCommentLikesUpdate) Exec(ctx context.Context) error {
_, err := sclu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sclu *ScaCommentLikesUpdate) ExecX(ctx context.Context) {
if err := sclu.Exec(ctx); err != nil {
panic(err)
}
}
func (sclu *ScaCommentLikesUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(scacommentlikes.Table, scacommentlikes.Columns, sqlgraph.NewFieldSpec(scacommentlikes.FieldID, field.TypeInt64))
if ps := sclu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sclu.mutation.TopicID(); ok {
_spec.SetField(scacommentlikes.FieldTopicID, field.TypeString, value)
}
if value, ok := sclu.mutation.UserID(); ok {
_spec.SetField(scacommentlikes.FieldUserID, field.TypeString, value)
}
if value, ok := sclu.mutation.CommentID(); ok {
_spec.SetField(scacommentlikes.FieldCommentID, field.TypeInt64, value)
}
if value, ok := sclu.mutation.AddedCommentID(); ok {
_spec.AddField(scacommentlikes.FieldCommentID, field.TypeInt64, value)
}
if value, ok := sclu.mutation.LikeTime(); ok {
_spec.SetField(scacommentlikes.FieldLikeTime, field.TypeTime, value)
}
if n, err = sqlgraph.UpdateNodes(ctx, sclu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scacommentlikes.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
sclu.mutation.done = true
return n, nil
}
// ScaCommentLikesUpdateOne is the builder for updating a single ScaCommentLikes entity.
type ScaCommentLikesUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaCommentLikesMutation
}
// SetTopicID sets the "topic_id" field.
func (scluo *ScaCommentLikesUpdateOne) SetTopicID(s string) *ScaCommentLikesUpdateOne {
scluo.mutation.SetTopicID(s)
return scluo
}
// SetNillableTopicID sets the "topic_id" field if the given value is not nil.
func (scluo *ScaCommentLikesUpdateOne) SetNillableTopicID(s *string) *ScaCommentLikesUpdateOne {
if s != nil {
scluo.SetTopicID(*s)
}
return scluo
}
// SetUserID sets the "user_id" field.
func (scluo *ScaCommentLikesUpdateOne) SetUserID(s string) *ScaCommentLikesUpdateOne {
scluo.mutation.SetUserID(s)
return scluo
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (scluo *ScaCommentLikesUpdateOne) SetNillableUserID(s *string) *ScaCommentLikesUpdateOne {
if s != nil {
scluo.SetUserID(*s)
}
return scluo
}
// SetCommentID sets the "comment_id" field.
func (scluo *ScaCommentLikesUpdateOne) SetCommentID(i int64) *ScaCommentLikesUpdateOne {
scluo.mutation.ResetCommentID()
scluo.mutation.SetCommentID(i)
return scluo
}
// SetNillableCommentID sets the "comment_id" field if the given value is not nil.
func (scluo *ScaCommentLikesUpdateOne) SetNillableCommentID(i *int64) *ScaCommentLikesUpdateOne {
if i != nil {
scluo.SetCommentID(*i)
}
return scluo
}
// AddCommentID adds i to the "comment_id" field.
func (scluo *ScaCommentLikesUpdateOne) AddCommentID(i int64) *ScaCommentLikesUpdateOne {
scluo.mutation.AddCommentID(i)
return scluo
}
// SetLikeTime sets the "like_time" field.
func (scluo *ScaCommentLikesUpdateOne) SetLikeTime(t time.Time) *ScaCommentLikesUpdateOne {
scluo.mutation.SetLikeTime(t)
return scluo
}
// SetNillableLikeTime sets the "like_time" field if the given value is not nil.
func (scluo *ScaCommentLikesUpdateOne) SetNillableLikeTime(t *time.Time) *ScaCommentLikesUpdateOne {
if t != nil {
scluo.SetLikeTime(*t)
}
return scluo
}
// Mutation returns the ScaCommentLikesMutation object of the builder.
func (scluo *ScaCommentLikesUpdateOne) Mutation() *ScaCommentLikesMutation {
return scluo.mutation
}
// Where appends a list predicates to the ScaCommentLikesUpdate builder.
func (scluo *ScaCommentLikesUpdateOne) Where(ps ...predicate.ScaCommentLikes) *ScaCommentLikesUpdateOne {
scluo.mutation.Where(ps...)
return scluo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (scluo *ScaCommentLikesUpdateOne) Select(field string, fields ...string) *ScaCommentLikesUpdateOne {
scluo.fields = append([]string{field}, fields...)
return scluo
}
// Save executes the query and returns the updated ScaCommentLikes entity.
func (scluo *ScaCommentLikesUpdateOne) Save(ctx context.Context) (*ScaCommentLikes, error) {
return withHooks(ctx, scluo.sqlSave, scluo.mutation, scluo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (scluo *ScaCommentLikesUpdateOne) SaveX(ctx context.Context) *ScaCommentLikes {
node, err := scluo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (scluo *ScaCommentLikesUpdateOne) Exec(ctx context.Context) error {
_, err := scluo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scluo *ScaCommentLikesUpdateOne) ExecX(ctx context.Context) {
if err := scluo.Exec(ctx); err != nil {
panic(err)
}
}
func (scluo *ScaCommentLikesUpdateOne) sqlSave(ctx context.Context) (_node *ScaCommentLikes, err error) {
_spec := sqlgraph.NewUpdateSpec(scacommentlikes.Table, scacommentlikes.Columns, sqlgraph.NewFieldSpec(scacommentlikes.FieldID, field.TypeInt64))
id, ok := scluo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaCommentLikes.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := scluo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scacommentlikes.FieldID)
for _, f := range fields {
if !scacommentlikes.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scacommentlikes.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := scluo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := scluo.mutation.TopicID(); ok {
_spec.SetField(scacommentlikes.FieldTopicID, field.TypeString, value)
}
if value, ok := scluo.mutation.UserID(); ok {
_spec.SetField(scacommentlikes.FieldUserID, field.TypeString, value)
}
if value, ok := scluo.mutation.CommentID(); ok {
_spec.SetField(scacommentlikes.FieldCommentID, field.TypeInt64, value)
}
if value, ok := scluo.mutation.AddedCommentID(); ok {
_spec.AddField(scacommentlikes.FieldCommentID, field.TypeInt64, value)
}
if value, ok := scluo.mutation.LikeTime(); ok {
_spec.SetField(scacommentlikes.FieldLikeTime, field.TypeTime, value)
}
_node = &ScaCommentLikes{config: scluo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, scluo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scacommentlikes.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
scluo.mutation.done = true
return _node, nil
}

View File

@@ -1,184 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 评论消息表
type ScaCommentMessage struct {
config `json:"-"`
// ID of the ent.
// 主键
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 话题Id
TopicID string `json:"topic_id,omitempty"`
// 来自人
FromID string `json:"from_id,omitempty"`
// 送达人
ToID string `json:"to_id,omitempty"`
// 消息内容
Content string `json:"content,omitempty"`
// 是否已读
IsRead int `json:"is_read,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaCommentMessage) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scacommentmessage.FieldID, scacommentmessage.FieldDeleted, scacommentmessage.FieldIsRead:
values[i] = new(sql.NullInt64)
case scacommentmessage.FieldTopicID, scacommentmessage.FieldFromID, scacommentmessage.FieldToID, scacommentmessage.FieldContent:
values[i] = new(sql.NullString)
case scacommentmessage.FieldCreatedAt, scacommentmessage.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaCommentMessage fields.
func (scm *ScaCommentMessage) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scacommentmessage.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
scm.ID = int64(value.Int64)
case scacommentmessage.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
scm.CreatedAt = value.Time
}
case scacommentmessage.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
scm.UpdatedAt = value.Time
}
case scacommentmessage.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
scm.Deleted = int8(value.Int64)
}
case scacommentmessage.FieldTopicID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field topic_id", values[i])
} else if value.Valid {
scm.TopicID = value.String
}
case scacommentmessage.FieldFromID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field from_id", values[i])
} else if value.Valid {
scm.FromID = value.String
}
case scacommentmessage.FieldToID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field to_id", values[i])
} else if value.Valid {
scm.ToID = value.String
}
case scacommentmessage.FieldContent:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field content", values[i])
} else if value.Valid {
scm.Content = value.String
}
case scacommentmessage.FieldIsRead:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field is_read", values[i])
} else if value.Valid {
scm.IsRead = int(value.Int64)
}
default:
scm.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaCommentMessage.
// This includes values selected through modifiers, order, etc.
func (scm *ScaCommentMessage) Value(name string) (ent.Value, error) {
return scm.selectValues.Get(name)
}
// Update returns a builder for updating this ScaCommentMessage.
// Note that you need to call ScaCommentMessage.Unwrap() before calling this method if this ScaCommentMessage
// was returned from a transaction, and the transaction was committed or rolled back.
func (scm *ScaCommentMessage) Update() *ScaCommentMessageUpdateOne {
return NewScaCommentMessageClient(scm.config).UpdateOne(scm)
}
// Unwrap unwraps the ScaCommentMessage entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (scm *ScaCommentMessage) Unwrap() *ScaCommentMessage {
_tx, ok := scm.config.driver.(*txDriver)
if !ok {
panic("ent: ScaCommentMessage is not a transactional entity")
}
scm.config.driver = _tx.drv
return scm
}
// String implements the fmt.Stringer.
func (scm *ScaCommentMessage) String() string {
var builder strings.Builder
builder.WriteString("ScaCommentMessage(")
builder.WriteString(fmt.Sprintf("id=%v, ", scm.ID))
builder.WriteString("created_at=")
builder.WriteString(scm.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(scm.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", scm.Deleted))
builder.WriteString(", ")
builder.WriteString("topic_id=")
builder.WriteString(scm.TopicID)
builder.WriteString(", ")
builder.WriteString("from_id=")
builder.WriteString(scm.FromID)
builder.WriteString(", ")
builder.WriteString("to_id=")
builder.WriteString(scm.ToID)
builder.WriteString(", ")
builder.WriteString("content=")
builder.WriteString(scm.Content)
builder.WriteString(", ")
builder.WriteString("is_read=")
builder.WriteString(fmt.Sprintf("%v", scm.IsRead))
builder.WriteByte(')')
return builder.String()
}
// ScaCommentMessages is a parsable slice of ScaCommentMessage.
type ScaCommentMessages []*ScaCommentMessage

View File

@@ -1,116 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scacommentmessage
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scacommentmessage type in the database.
Label = "sca_comment_message"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldTopicID holds the string denoting the topic_id field in the database.
FieldTopicID = "topic_id"
// FieldFromID holds the string denoting the from_id field in the database.
FieldFromID = "from_id"
// FieldToID holds the string denoting the to_id field in the database.
FieldToID = "to_id"
// FieldContent holds the string denoting the content field in the database.
FieldContent = "content"
// FieldIsRead holds the string denoting the is_read field in the database.
FieldIsRead = "is_read"
// Table holds the table name of the scacommentmessage in the database.
Table = "sca_comment_message"
)
// Columns holds all SQL columns for scacommentmessage fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldTopicID,
FieldFromID,
FieldToID,
FieldContent,
FieldIsRead,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
)
// OrderOption defines the ordering options for the ScaCommentMessage queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByTopicID orders the results by the topic_id field.
func ByTopicID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTopicID, opts...).ToFunc()
}
// ByFromID orders the results by the from_id field.
func ByFromID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFromID, opts...).ToFunc()
}
// ByToID orders the results by the to_id field.
func ByToID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldToID, opts...).ToFunc()
}
// ByContent orders the results by the content field.
func ByContent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldContent, opts...).ToFunc()
}
// ByIsRead orders the results by the is_read field.
func ByIsRead(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIsRead, opts...).ToFunc()
}

View File

@@ -1,550 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scacommentmessage
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldUpdatedAt, v))
}
// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ.
func Deleted(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldDeleted, v))
}
// TopicID applies equality check predicate on the "topic_id" field. It's identical to TopicIDEQ.
func TopicID(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldTopicID, v))
}
// FromID applies equality check predicate on the "from_id" field. It's identical to FromIDEQ.
func FromID(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldFromID, v))
}
// ToID applies equality check predicate on the "to_id" field. It's identical to ToIDEQ.
func ToID(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldToID, v))
}
// Content applies equality check predicate on the "content" field. It's identical to ContentEQ.
func Content(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldContent, v))
}
// IsRead applies equality check predicate on the "is_read" field. It's identical to IsReadEQ.
func IsRead(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldIsRead, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldUpdatedAt, v))
}
// UpdatedAtIsNil applies the IsNil predicate on the "updated_at" field.
func UpdatedAtIsNil() predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIsNull(FieldUpdatedAt))
}
// UpdatedAtNotNil applies the NotNil predicate on the "updated_at" field.
func UpdatedAtNotNil() predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotNull(FieldUpdatedAt))
}
// DeletedEQ applies the EQ predicate on the "deleted" field.
func DeletedEQ(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldDeleted, v))
}
// DeletedNEQ applies the NEQ predicate on the "deleted" field.
func DeletedNEQ(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldDeleted, v))
}
// DeletedIn applies the In predicate on the "deleted" field.
func DeletedIn(vs ...int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldDeleted, vs...))
}
// DeletedNotIn applies the NotIn predicate on the "deleted" field.
func DeletedNotIn(vs ...int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldDeleted, vs...))
}
// DeletedGT applies the GT predicate on the "deleted" field.
func DeletedGT(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldDeleted, v))
}
// DeletedGTE applies the GTE predicate on the "deleted" field.
func DeletedGTE(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldDeleted, v))
}
// DeletedLT applies the LT predicate on the "deleted" field.
func DeletedLT(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldDeleted, v))
}
// DeletedLTE applies the LTE predicate on the "deleted" field.
func DeletedLTE(v int8) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldDeleted, v))
}
// TopicIDEQ applies the EQ predicate on the "topic_id" field.
func TopicIDEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldTopicID, v))
}
// TopicIDNEQ applies the NEQ predicate on the "topic_id" field.
func TopicIDNEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldTopicID, v))
}
// TopicIDIn applies the In predicate on the "topic_id" field.
func TopicIDIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldTopicID, vs...))
}
// TopicIDNotIn applies the NotIn predicate on the "topic_id" field.
func TopicIDNotIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldTopicID, vs...))
}
// TopicIDGT applies the GT predicate on the "topic_id" field.
func TopicIDGT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldTopicID, v))
}
// TopicIDGTE applies the GTE predicate on the "topic_id" field.
func TopicIDGTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldTopicID, v))
}
// TopicIDLT applies the LT predicate on the "topic_id" field.
func TopicIDLT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldTopicID, v))
}
// TopicIDLTE applies the LTE predicate on the "topic_id" field.
func TopicIDLTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldTopicID, v))
}
// TopicIDContains applies the Contains predicate on the "topic_id" field.
func TopicIDContains(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContains(FieldTopicID, v))
}
// TopicIDHasPrefix applies the HasPrefix predicate on the "topic_id" field.
func TopicIDHasPrefix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasPrefix(FieldTopicID, v))
}
// TopicIDHasSuffix applies the HasSuffix predicate on the "topic_id" field.
func TopicIDHasSuffix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasSuffix(FieldTopicID, v))
}
// TopicIDEqualFold applies the EqualFold predicate on the "topic_id" field.
func TopicIDEqualFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEqualFold(FieldTopicID, v))
}
// TopicIDContainsFold applies the ContainsFold predicate on the "topic_id" field.
func TopicIDContainsFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContainsFold(FieldTopicID, v))
}
// FromIDEQ applies the EQ predicate on the "from_id" field.
func FromIDEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldFromID, v))
}
// FromIDNEQ applies the NEQ predicate on the "from_id" field.
func FromIDNEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldFromID, v))
}
// FromIDIn applies the In predicate on the "from_id" field.
func FromIDIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldFromID, vs...))
}
// FromIDNotIn applies the NotIn predicate on the "from_id" field.
func FromIDNotIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldFromID, vs...))
}
// FromIDGT applies the GT predicate on the "from_id" field.
func FromIDGT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldFromID, v))
}
// FromIDGTE applies the GTE predicate on the "from_id" field.
func FromIDGTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldFromID, v))
}
// FromIDLT applies the LT predicate on the "from_id" field.
func FromIDLT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldFromID, v))
}
// FromIDLTE applies the LTE predicate on the "from_id" field.
func FromIDLTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldFromID, v))
}
// FromIDContains applies the Contains predicate on the "from_id" field.
func FromIDContains(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContains(FieldFromID, v))
}
// FromIDHasPrefix applies the HasPrefix predicate on the "from_id" field.
func FromIDHasPrefix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasPrefix(FieldFromID, v))
}
// FromIDHasSuffix applies the HasSuffix predicate on the "from_id" field.
func FromIDHasSuffix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasSuffix(FieldFromID, v))
}
// FromIDEqualFold applies the EqualFold predicate on the "from_id" field.
func FromIDEqualFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEqualFold(FieldFromID, v))
}
// FromIDContainsFold applies the ContainsFold predicate on the "from_id" field.
func FromIDContainsFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContainsFold(FieldFromID, v))
}
// ToIDEQ applies the EQ predicate on the "to_id" field.
func ToIDEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldToID, v))
}
// ToIDNEQ applies the NEQ predicate on the "to_id" field.
func ToIDNEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldToID, v))
}
// ToIDIn applies the In predicate on the "to_id" field.
func ToIDIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldToID, vs...))
}
// ToIDNotIn applies the NotIn predicate on the "to_id" field.
func ToIDNotIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldToID, vs...))
}
// ToIDGT applies the GT predicate on the "to_id" field.
func ToIDGT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldToID, v))
}
// ToIDGTE applies the GTE predicate on the "to_id" field.
func ToIDGTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldToID, v))
}
// ToIDLT applies the LT predicate on the "to_id" field.
func ToIDLT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldToID, v))
}
// ToIDLTE applies the LTE predicate on the "to_id" field.
func ToIDLTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldToID, v))
}
// ToIDContains applies the Contains predicate on the "to_id" field.
func ToIDContains(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContains(FieldToID, v))
}
// ToIDHasPrefix applies the HasPrefix predicate on the "to_id" field.
func ToIDHasPrefix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasPrefix(FieldToID, v))
}
// ToIDHasSuffix applies the HasSuffix predicate on the "to_id" field.
func ToIDHasSuffix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasSuffix(FieldToID, v))
}
// ToIDEqualFold applies the EqualFold predicate on the "to_id" field.
func ToIDEqualFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEqualFold(FieldToID, v))
}
// ToIDContainsFold applies the ContainsFold predicate on the "to_id" field.
func ToIDContainsFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContainsFold(FieldToID, v))
}
// ContentEQ applies the EQ predicate on the "content" field.
func ContentEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldContent, v))
}
// ContentNEQ applies the NEQ predicate on the "content" field.
func ContentNEQ(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldContent, v))
}
// ContentIn applies the In predicate on the "content" field.
func ContentIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldContent, vs...))
}
// ContentNotIn applies the NotIn predicate on the "content" field.
func ContentNotIn(vs ...string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldContent, vs...))
}
// ContentGT applies the GT predicate on the "content" field.
func ContentGT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldContent, v))
}
// ContentGTE applies the GTE predicate on the "content" field.
func ContentGTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldContent, v))
}
// ContentLT applies the LT predicate on the "content" field.
func ContentLT(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldContent, v))
}
// ContentLTE applies the LTE predicate on the "content" field.
func ContentLTE(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldContent, v))
}
// ContentContains applies the Contains predicate on the "content" field.
func ContentContains(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContains(FieldContent, v))
}
// ContentHasPrefix applies the HasPrefix predicate on the "content" field.
func ContentHasPrefix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasPrefix(FieldContent, v))
}
// ContentHasSuffix applies the HasSuffix predicate on the "content" field.
func ContentHasSuffix(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldHasSuffix(FieldContent, v))
}
// ContentEqualFold applies the EqualFold predicate on the "content" field.
func ContentEqualFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEqualFold(FieldContent, v))
}
// ContentContainsFold applies the ContainsFold predicate on the "content" field.
func ContentContainsFold(v string) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldContainsFold(FieldContent, v))
}
// IsReadEQ applies the EQ predicate on the "is_read" field.
func IsReadEQ(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldEQ(FieldIsRead, v))
}
// IsReadNEQ applies the NEQ predicate on the "is_read" field.
func IsReadNEQ(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNEQ(FieldIsRead, v))
}
// IsReadIn applies the In predicate on the "is_read" field.
func IsReadIn(vs ...int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIn(FieldIsRead, vs...))
}
// IsReadNotIn applies the NotIn predicate on the "is_read" field.
func IsReadNotIn(vs ...int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotIn(FieldIsRead, vs...))
}
// IsReadGT applies the GT predicate on the "is_read" field.
func IsReadGT(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGT(FieldIsRead, v))
}
// IsReadGTE applies the GTE predicate on the "is_read" field.
func IsReadGTE(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldGTE(FieldIsRead, v))
}
// IsReadLT applies the LT predicate on the "is_read" field.
func IsReadLT(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLT(FieldIsRead, v))
}
// IsReadLTE applies the LTE predicate on the "is_read" field.
func IsReadLTE(v int) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldLTE(FieldIsRead, v))
}
// IsReadIsNil applies the IsNil predicate on the "is_read" field.
func IsReadIsNil() predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldIsNull(FieldIsRead))
}
// IsReadNotNil applies the NotNil predicate on the "is_read" field.
func IsReadNotNil() predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.FieldNotNull(FieldIsRead))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaCommentMessage) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaCommentMessage) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaCommentMessage) predicate.ScaCommentMessage {
return predicate.ScaCommentMessage(sql.NotPredicates(p))
}

View File

@@ -1,332 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentMessageCreate is the builder for creating a ScaCommentMessage entity.
type ScaCommentMessageCreate struct {
config
mutation *ScaCommentMessageMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (scmc *ScaCommentMessageCreate) SetCreatedAt(t time.Time) *ScaCommentMessageCreate {
scmc.mutation.SetCreatedAt(t)
return scmc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (scmc *ScaCommentMessageCreate) SetNillableCreatedAt(t *time.Time) *ScaCommentMessageCreate {
if t != nil {
scmc.SetCreatedAt(*t)
}
return scmc
}
// SetUpdatedAt sets the "updated_at" field.
func (scmc *ScaCommentMessageCreate) SetUpdatedAt(t time.Time) *ScaCommentMessageCreate {
scmc.mutation.SetUpdatedAt(t)
return scmc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (scmc *ScaCommentMessageCreate) SetNillableUpdatedAt(t *time.Time) *ScaCommentMessageCreate {
if t != nil {
scmc.SetUpdatedAt(*t)
}
return scmc
}
// SetDeleted sets the "deleted" field.
func (scmc *ScaCommentMessageCreate) SetDeleted(i int8) *ScaCommentMessageCreate {
scmc.mutation.SetDeleted(i)
return scmc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (scmc *ScaCommentMessageCreate) SetNillableDeleted(i *int8) *ScaCommentMessageCreate {
if i != nil {
scmc.SetDeleted(*i)
}
return scmc
}
// SetTopicID sets the "topic_id" field.
func (scmc *ScaCommentMessageCreate) SetTopicID(s string) *ScaCommentMessageCreate {
scmc.mutation.SetTopicID(s)
return scmc
}
// SetFromID sets the "from_id" field.
func (scmc *ScaCommentMessageCreate) SetFromID(s string) *ScaCommentMessageCreate {
scmc.mutation.SetFromID(s)
return scmc
}
// SetToID sets the "to_id" field.
func (scmc *ScaCommentMessageCreate) SetToID(s string) *ScaCommentMessageCreate {
scmc.mutation.SetToID(s)
return scmc
}
// SetContent sets the "content" field.
func (scmc *ScaCommentMessageCreate) SetContent(s string) *ScaCommentMessageCreate {
scmc.mutation.SetContent(s)
return scmc
}
// SetIsRead sets the "is_read" field.
func (scmc *ScaCommentMessageCreate) SetIsRead(i int) *ScaCommentMessageCreate {
scmc.mutation.SetIsRead(i)
return scmc
}
// SetNillableIsRead sets the "is_read" field if the given value is not nil.
func (scmc *ScaCommentMessageCreate) SetNillableIsRead(i *int) *ScaCommentMessageCreate {
if i != nil {
scmc.SetIsRead(*i)
}
return scmc
}
// SetID sets the "id" field.
func (scmc *ScaCommentMessageCreate) SetID(i int64) *ScaCommentMessageCreate {
scmc.mutation.SetID(i)
return scmc
}
// Mutation returns the ScaCommentMessageMutation object of the builder.
func (scmc *ScaCommentMessageCreate) Mutation() *ScaCommentMessageMutation {
return scmc.mutation
}
// Save creates the ScaCommentMessage in the database.
func (scmc *ScaCommentMessageCreate) Save(ctx context.Context) (*ScaCommentMessage, error) {
scmc.defaults()
return withHooks(ctx, scmc.sqlSave, scmc.mutation, scmc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (scmc *ScaCommentMessageCreate) SaveX(ctx context.Context) *ScaCommentMessage {
v, err := scmc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (scmc *ScaCommentMessageCreate) Exec(ctx context.Context) error {
_, err := scmc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scmc *ScaCommentMessageCreate) ExecX(ctx context.Context) {
if err := scmc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (scmc *ScaCommentMessageCreate) defaults() {
if _, ok := scmc.mutation.CreatedAt(); !ok {
v := scacommentmessage.DefaultCreatedAt()
scmc.mutation.SetCreatedAt(v)
}
if _, ok := scmc.mutation.Deleted(); !ok {
v := scacommentmessage.DefaultDeleted
scmc.mutation.SetDeleted(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (scmc *ScaCommentMessageCreate) check() error {
if _, ok := scmc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaCommentMessage.created_at"`)}
}
if _, ok := scmc.mutation.Deleted(); !ok {
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaCommentMessage.deleted"`)}
}
if v, ok := scmc.mutation.Deleted(); ok {
if err := scacommentmessage.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaCommentMessage.deleted": %w`, err)}
}
}
if _, ok := scmc.mutation.TopicID(); !ok {
return &ValidationError{Name: "topic_id", err: errors.New(`ent: missing required field "ScaCommentMessage.topic_id"`)}
}
if _, ok := scmc.mutation.FromID(); !ok {
return &ValidationError{Name: "from_id", err: errors.New(`ent: missing required field "ScaCommentMessage.from_id"`)}
}
if _, ok := scmc.mutation.ToID(); !ok {
return &ValidationError{Name: "to_id", err: errors.New(`ent: missing required field "ScaCommentMessage.to_id"`)}
}
if _, ok := scmc.mutation.Content(); !ok {
return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "ScaCommentMessage.content"`)}
}
return nil
}
func (scmc *ScaCommentMessageCreate) sqlSave(ctx context.Context) (*ScaCommentMessage, error) {
if err := scmc.check(); err != nil {
return nil, err
}
_node, _spec := scmc.createSpec()
if err := sqlgraph.CreateNode(ctx, scmc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
scmc.mutation.id = &_node.ID
scmc.mutation.done = true
return _node, nil
}
func (scmc *ScaCommentMessageCreate) createSpec() (*ScaCommentMessage, *sqlgraph.CreateSpec) {
var (
_node = &ScaCommentMessage{config: scmc.config}
_spec = sqlgraph.NewCreateSpec(scacommentmessage.Table, sqlgraph.NewFieldSpec(scacommentmessage.FieldID, field.TypeInt64))
)
if id, ok := scmc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := scmc.mutation.CreatedAt(); ok {
_spec.SetField(scacommentmessage.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := scmc.mutation.UpdatedAt(); ok {
_spec.SetField(scacommentmessage.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := scmc.mutation.Deleted(); ok {
_spec.SetField(scacommentmessage.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := scmc.mutation.TopicID(); ok {
_spec.SetField(scacommentmessage.FieldTopicID, field.TypeString, value)
_node.TopicID = value
}
if value, ok := scmc.mutation.FromID(); ok {
_spec.SetField(scacommentmessage.FieldFromID, field.TypeString, value)
_node.FromID = value
}
if value, ok := scmc.mutation.ToID(); ok {
_spec.SetField(scacommentmessage.FieldToID, field.TypeString, value)
_node.ToID = value
}
if value, ok := scmc.mutation.Content(); ok {
_spec.SetField(scacommentmessage.FieldContent, field.TypeString, value)
_node.Content = value
}
if value, ok := scmc.mutation.IsRead(); ok {
_spec.SetField(scacommentmessage.FieldIsRead, field.TypeInt, value)
_node.IsRead = value
}
return _node, _spec
}
// ScaCommentMessageCreateBulk is the builder for creating many ScaCommentMessage entities in bulk.
type ScaCommentMessageCreateBulk struct {
config
err error
builders []*ScaCommentMessageCreate
}
// Save creates the ScaCommentMessage entities in the database.
func (scmcb *ScaCommentMessageCreateBulk) Save(ctx context.Context) ([]*ScaCommentMessage, error) {
if scmcb.err != nil {
return nil, scmcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(scmcb.builders))
nodes := make([]*ScaCommentMessage, len(scmcb.builders))
mutators := make([]Mutator, len(scmcb.builders))
for i := range scmcb.builders {
func(i int, root context.Context) {
builder := scmcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaCommentMessageMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, scmcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, scmcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, scmcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (scmcb *ScaCommentMessageCreateBulk) SaveX(ctx context.Context) []*ScaCommentMessage {
v, err := scmcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (scmcb *ScaCommentMessageCreateBulk) Exec(ctx context.Context) error {
_, err := scmcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scmcb *ScaCommentMessageCreateBulk) ExecX(ctx context.Context) {
if err := scmcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentMessageDelete is the builder for deleting a ScaCommentMessage entity.
type ScaCommentMessageDelete struct {
config
hooks []Hook
mutation *ScaCommentMessageMutation
}
// Where appends a list predicates to the ScaCommentMessageDelete builder.
func (scmd *ScaCommentMessageDelete) Where(ps ...predicate.ScaCommentMessage) *ScaCommentMessageDelete {
scmd.mutation.Where(ps...)
return scmd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (scmd *ScaCommentMessageDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, scmd.sqlExec, scmd.mutation, scmd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (scmd *ScaCommentMessageDelete) ExecX(ctx context.Context) int {
n, err := scmd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (scmd *ScaCommentMessageDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scacommentmessage.Table, sqlgraph.NewFieldSpec(scacommentmessage.FieldID, field.TypeInt64))
if ps := scmd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, scmd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
scmd.mutation.done = true
return affected, err
}
// ScaCommentMessageDeleteOne is the builder for deleting a single ScaCommentMessage entity.
type ScaCommentMessageDeleteOne struct {
scmd *ScaCommentMessageDelete
}
// Where appends a list predicates to the ScaCommentMessageDelete builder.
func (scmdo *ScaCommentMessageDeleteOne) Where(ps ...predicate.ScaCommentMessage) *ScaCommentMessageDeleteOne {
scmdo.scmd.mutation.Where(ps...)
return scmdo
}
// Exec executes the deletion query.
func (scmdo *ScaCommentMessageDeleteOne) Exec(ctx context.Context) error {
n, err := scmdo.scmd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scacommentmessage.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (scmdo *ScaCommentMessageDeleteOne) ExecX(ctx context.Context) {
if err := scmdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentMessageQuery is the builder for querying ScaCommentMessage entities.
type ScaCommentMessageQuery struct {
config
ctx *QueryContext
order []scacommentmessage.OrderOption
inters []Interceptor
predicates []predicate.ScaCommentMessage
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaCommentMessageQuery builder.
func (scmq *ScaCommentMessageQuery) Where(ps ...predicate.ScaCommentMessage) *ScaCommentMessageQuery {
scmq.predicates = append(scmq.predicates, ps...)
return scmq
}
// Limit the number of records to be returned by this query.
func (scmq *ScaCommentMessageQuery) Limit(limit int) *ScaCommentMessageQuery {
scmq.ctx.Limit = &limit
return scmq
}
// Offset to start from.
func (scmq *ScaCommentMessageQuery) Offset(offset int) *ScaCommentMessageQuery {
scmq.ctx.Offset = &offset
return scmq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (scmq *ScaCommentMessageQuery) Unique(unique bool) *ScaCommentMessageQuery {
scmq.ctx.Unique = &unique
return scmq
}
// Order specifies how the records should be ordered.
func (scmq *ScaCommentMessageQuery) Order(o ...scacommentmessage.OrderOption) *ScaCommentMessageQuery {
scmq.order = append(scmq.order, o...)
return scmq
}
// First returns the first ScaCommentMessage entity from the query.
// Returns a *NotFoundError when no ScaCommentMessage was found.
func (scmq *ScaCommentMessageQuery) First(ctx context.Context) (*ScaCommentMessage, error) {
nodes, err := scmq.Limit(1).All(setContextOp(ctx, scmq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scacommentmessage.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) FirstX(ctx context.Context) *ScaCommentMessage {
node, err := scmq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaCommentMessage ID from the query.
// Returns a *NotFoundError when no ScaCommentMessage ID was found.
func (scmq *ScaCommentMessageQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = scmq.Limit(1).IDs(setContextOp(ctx, scmq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scacommentmessage.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) FirstIDX(ctx context.Context) int64 {
id, err := scmq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaCommentMessage entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaCommentMessage entity is found.
// Returns a *NotFoundError when no ScaCommentMessage entities are found.
func (scmq *ScaCommentMessageQuery) Only(ctx context.Context) (*ScaCommentMessage, error) {
nodes, err := scmq.Limit(2).All(setContextOp(ctx, scmq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scacommentmessage.Label}
default:
return nil, &NotSingularError{scacommentmessage.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) OnlyX(ctx context.Context) *ScaCommentMessage {
node, err := scmq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaCommentMessage ID in the query.
// Returns a *NotSingularError when more than one ScaCommentMessage ID is found.
// Returns a *NotFoundError when no entities are found.
func (scmq *ScaCommentMessageQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = scmq.Limit(2).IDs(setContextOp(ctx, scmq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scacommentmessage.Label}
default:
err = &NotSingularError{scacommentmessage.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) OnlyIDX(ctx context.Context) int64 {
id, err := scmq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaCommentMessages.
func (scmq *ScaCommentMessageQuery) All(ctx context.Context) ([]*ScaCommentMessage, error) {
ctx = setContextOp(ctx, scmq.ctx, ent.OpQueryAll)
if err := scmq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaCommentMessage, *ScaCommentMessageQuery]()
return withInterceptors[[]*ScaCommentMessage](ctx, scmq, qr, scmq.inters)
}
// AllX is like All, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) AllX(ctx context.Context) []*ScaCommentMessage {
nodes, err := scmq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaCommentMessage IDs.
func (scmq *ScaCommentMessageQuery) IDs(ctx context.Context) (ids []int64, err error) {
if scmq.ctx.Unique == nil && scmq.path != nil {
scmq.Unique(true)
}
ctx = setContextOp(ctx, scmq.ctx, ent.OpQueryIDs)
if err = scmq.Select(scacommentmessage.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) IDsX(ctx context.Context) []int64 {
ids, err := scmq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (scmq *ScaCommentMessageQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, scmq.ctx, ent.OpQueryCount)
if err := scmq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, scmq, querierCount[*ScaCommentMessageQuery](), scmq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) CountX(ctx context.Context) int {
count, err := scmq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (scmq *ScaCommentMessageQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, scmq.ctx, ent.OpQueryExist)
switch _, err := scmq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (scmq *ScaCommentMessageQuery) ExistX(ctx context.Context) bool {
exist, err := scmq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaCommentMessageQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (scmq *ScaCommentMessageQuery) Clone() *ScaCommentMessageQuery {
if scmq == nil {
return nil
}
return &ScaCommentMessageQuery{
config: scmq.config,
ctx: scmq.ctx.Clone(),
order: append([]scacommentmessage.OrderOption{}, scmq.order...),
inters: append([]Interceptor{}, scmq.inters...),
predicates: append([]predicate.ScaCommentMessage{}, scmq.predicates...),
// clone intermediate query.
sql: scmq.sql.Clone(),
path: scmq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaCommentMessage.Query().
// GroupBy(scacommentmessage.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (scmq *ScaCommentMessageQuery) GroupBy(field string, fields ...string) *ScaCommentMessageGroupBy {
scmq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaCommentMessageGroupBy{build: scmq}
grbuild.flds = &scmq.ctx.Fields
grbuild.label = scacommentmessage.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaCommentMessage.Query().
// Select(scacommentmessage.FieldCreatedAt).
// Scan(ctx, &v)
func (scmq *ScaCommentMessageQuery) Select(fields ...string) *ScaCommentMessageSelect {
scmq.ctx.Fields = append(scmq.ctx.Fields, fields...)
sbuild := &ScaCommentMessageSelect{ScaCommentMessageQuery: scmq}
sbuild.label = scacommentmessage.Label
sbuild.flds, sbuild.scan = &scmq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaCommentMessageSelect configured with the given aggregations.
func (scmq *ScaCommentMessageQuery) Aggregate(fns ...AggregateFunc) *ScaCommentMessageSelect {
return scmq.Select().Aggregate(fns...)
}
func (scmq *ScaCommentMessageQuery) prepareQuery(ctx context.Context) error {
for _, inter := range scmq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, scmq); err != nil {
return err
}
}
}
for _, f := range scmq.ctx.Fields {
if !scacommentmessage.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if scmq.path != nil {
prev, err := scmq.path(ctx)
if err != nil {
return err
}
scmq.sql = prev
}
return nil
}
func (scmq *ScaCommentMessageQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaCommentMessage, error) {
var (
nodes = []*ScaCommentMessage{}
_spec = scmq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaCommentMessage).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaCommentMessage{config: scmq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, scmq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (scmq *ScaCommentMessageQuery) sqlCount(ctx context.Context) (int, error) {
_spec := scmq.querySpec()
_spec.Node.Columns = scmq.ctx.Fields
if len(scmq.ctx.Fields) > 0 {
_spec.Unique = scmq.ctx.Unique != nil && *scmq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, scmq.driver, _spec)
}
func (scmq *ScaCommentMessageQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scacommentmessage.Table, scacommentmessage.Columns, sqlgraph.NewFieldSpec(scacommentmessage.FieldID, field.TypeInt64))
_spec.From = scmq.sql
if unique := scmq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if scmq.path != nil {
_spec.Unique = true
}
if fields := scmq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scacommentmessage.FieldID)
for i := range fields {
if fields[i] != scacommentmessage.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := scmq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := scmq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := scmq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := scmq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (scmq *ScaCommentMessageQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(scmq.driver.Dialect())
t1 := builder.Table(scacommentmessage.Table)
columns := scmq.ctx.Fields
if len(columns) == 0 {
columns = scacommentmessage.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if scmq.sql != nil {
selector = scmq.sql
selector.Select(selector.Columns(columns...)...)
}
if scmq.ctx.Unique != nil && *scmq.ctx.Unique {
selector.Distinct()
}
for _, p := range scmq.predicates {
p(selector)
}
for _, p := range scmq.order {
p(selector)
}
if offset := scmq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := scmq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaCommentMessageGroupBy is the group-by builder for ScaCommentMessage entities.
type ScaCommentMessageGroupBy struct {
selector
build *ScaCommentMessageQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (scmgb *ScaCommentMessageGroupBy) Aggregate(fns ...AggregateFunc) *ScaCommentMessageGroupBy {
scmgb.fns = append(scmgb.fns, fns...)
return scmgb
}
// Scan applies the selector query and scans the result into the given value.
func (scmgb *ScaCommentMessageGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, scmgb.build.ctx, ent.OpQueryGroupBy)
if err := scmgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaCommentMessageQuery, *ScaCommentMessageGroupBy](ctx, scmgb.build, scmgb, scmgb.build.inters, v)
}
func (scmgb *ScaCommentMessageGroupBy) sqlScan(ctx context.Context, root *ScaCommentMessageQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(scmgb.fns))
for _, fn := range scmgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*scmgb.flds)+len(scmgb.fns))
for _, f := range *scmgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*scmgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := scmgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaCommentMessageSelect is the builder for selecting fields of ScaCommentMessage entities.
type ScaCommentMessageSelect struct {
*ScaCommentMessageQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (scms *ScaCommentMessageSelect) Aggregate(fns ...AggregateFunc) *ScaCommentMessageSelect {
scms.fns = append(scms.fns, fns...)
return scms
}
// Scan applies the selector query and scans the result into the given value.
func (scms *ScaCommentMessageSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, scms.ctx, ent.OpQuerySelect)
if err := scms.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaCommentMessageQuery, *ScaCommentMessageSelect](ctx, scms.ScaCommentMessageQuery, scms, scms.inters, v)
}
func (scms *ScaCommentMessageSelect) sqlScan(ctx context.Context, root *ScaCommentMessageQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(scms.fns))
for _, fn := range scms.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*scms.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := scms.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,518 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentmessage"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentMessageUpdate is the builder for updating ScaCommentMessage entities.
type ScaCommentMessageUpdate struct {
config
hooks []Hook
mutation *ScaCommentMessageMutation
}
// Where appends a list predicates to the ScaCommentMessageUpdate builder.
func (scmu *ScaCommentMessageUpdate) Where(ps ...predicate.ScaCommentMessage) *ScaCommentMessageUpdate {
scmu.mutation.Where(ps...)
return scmu
}
// SetUpdatedAt sets the "updated_at" field.
func (scmu *ScaCommentMessageUpdate) SetUpdatedAt(t time.Time) *ScaCommentMessageUpdate {
scmu.mutation.SetUpdatedAt(t)
return scmu
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (scmu *ScaCommentMessageUpdate) ClearUpdatedAt() *ScaCommentMessageUpdate {
scmu.mutation.ClearUpdatedAt()
return scmu
}
// SetDeleted sets the "deleted" field.
func (scmu *ScaCommentMessageUpdate) SetDeleted(i int8) *ScaCommentMessageUpdate {
scmu.mutation.ResetDeleted()
scmu.mutation.SetDeleted(i)
return scmu
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (scmu *ScaCommentMessageUpdate) SetNillableDeleted(i *int8) *ScaCommentMessageUpdate {
if i != nil {
scmu.SetDeleted(*i)
}
return scmu
}
// AddDeleted adds i to the "deleted" field.
func (scmu *ScaCommentMessageUpdate) AddDeleted(i int8) *ScaCommentMessageUpdate {
scmu.mutation.AddDeleted(i)
return scmu
}
// SetTopicID sets the "topic_id" field.
func (scmu *ScaCommentMessageUpdate) SetTopicID(s string) *ScaCommentMessageUpdate {
scmu.mutation.SetTopicID(s)
return scmu
}
// SetNillableTopicID sets the "topic_id" field if the given value is not nil.
func (scmu *ScaCommentMessageUpdate) SetNillableTopicID(s *string) *ScaCommentMessageUpdate {
if s != nil {
scmu.SetTopicID(*s)
}
return scmu
}
// SetFromID sets the "from_id" field.
func (scmu *ScaCommentMessageUpdate) SetFromID(s string) *ScaCommentMessageUpdate {
scmu.mutation.SetFromID(s)
return scmu
}
// SetNillableFromID sets the "from_id" field if the given value is not nil.
func (scmu *ScaCommentMessageUpdate) SetNillableFromID(s *string) *ScaCommentMessageUpdate {
if s != nil {
scmu.SetFromID(*s)
}
return scmu
}
// SetToID sets the "to_id" field.
func (scmu *ScaCommentMessageUpdate) SetToID(s string) *ScaCommentMessageUpdate {
scmu.mutation.SetToID(s)
return scmu
}
// SetNillableToID sets the "to_id" field if the given value is not nil.
func (scmu *ScaCommentMessageUpdate) SetNillableToID(s *string) *ScaCommentMessageUpdate {
if s != nil {
scmu.SetToID(*s)
}
return scmu
}
// SetContent sets the "content" field.
func (scmu *ScaCommentMessageUpdate) SetContent(s string) *ScaCommentMessageUpdate {
scmu.mutation.SetContent(s)
return scmu
}
// SetNillableContent sets the "content" field if the given value is not nil.
func (scmu *ScaCommentMessageUpdate) SetNillableContent(s *string) *ScaCommentMessageUpdate {
if s != nil {
scmu.SetContent(*s)
}
return scmu
}
// SetIsRead sets the "is_read" field.
func (scmu *ScaCommentMessageUpdate) SetIsRead(i int) *ScaCommentMessageUpdate {
scmu.mutation.ResetIsRead()
scmu.mutation.SetIsRead(i)
return scmu
}
// SetNillableIsRead sets the "is_read" field if the given value is not nil.
func (scmu *ScaCommentMessageUpdate) SetNillableIsRead(i *int) *ScaCommentMessageUpdate {
if i != nil {
scmu.SetIsRead(*i)
}
return scmu
}
// AddIsRead adds i to the "is_read" field.
func (scmu *ScaCommentMessageUpdate) AddIsRead(i int) *ScaCommentMessageUpdate {
scmu.mutation.AddIsRead(i)
return scmu
}
// ClearIsRead clears the value of the "is_read" field.
func (scmu *ScaCommentMessageUpdate) ClearIsRead() *ScaCommentMessageUpdate {
scmu.mutation.ClearIsRead()
return scmu
}
// Mutation returns the ScaCommentMessageMutation object of the builder.
func (scmu *ScaCommentMessageUpdate) Mutation() *ScaCommentMessageMutation {
return scmu.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (scmu *ScaCommentMessageUpdate) Save(ctx context.Context) (int, error) {
scmu.defaults()
return withHooks(ctx, scmu.sqlSave, scmu.mutation, scmu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (scmu *ScaCommentMessageUpdate) SaveX(ctx context.Context) int {
affected, err := scmu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (scmu *ScaCommentMessageUpdate) Exec(ctx context.Context) error {
_, err := scmu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scmu *ScaCommentMessageUpdate) ExecX(ctx context.Context) {
if err := scmu.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (scmu *ScaCommentMessageUpdate) defaults() {
if _, ok := scmu.mutation.UpdatedAt(); !ok && !scmu.mutation.UpdatedAtCleared() {
v := scacommentmessage.UpdateDefaultUpdatedAt()
scmu.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (scmu *ScaCommentMessageUpdate) check() error {
if v, ok := scmu.mutation.Deleted(); ok {
if err := scacommentmessage.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaCommentMessage.deleted": %w`, err)}
}
}
return nil
}
func (scmu *ScaCommentMessageUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := scmu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scacommentmessage.Table, scacommentmessage.Columns, sqlgraph.NewFieldSpec(scacommentmessage.FieldID, field.TypeInt64))
if ps := scmu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := scmu.mutation.UpdatedAt(); ok {
_spec.SetField(scacommentmessage.FieldUpdatedAt, field.TypeTime, value)
}
if scmu.mutation.UpdatedAtCleared() {
_spec.ClearField(scacommentmessage.FieldUpdatedAt, field.TypeTime)
}
if value, ok := scmu.mutation.Deleted(); ok {
_spec.SetField(scacommentmessage.FieldDeleted, field.TypeInt8, value)
}
if value, ok := scmu.mutation.AddedDeleted(); ok {
_spec.AddField(scacommentmessage.FieldDeleted, field.TypeInt8, value)
}
if value, ok := scmu.mutation.TopicID(); ok {
_spec.SetField(scacommentmessage.FieldTopicID, field.TypeString, value)
}
if value, ok := scmu.mutation.FromID(); ok {
_spec.SetField(scacommentmessage.FieldFromID, field.TypeString, value)
}
if value, ok := scmu.mutation.ToID(); ok {
_spec.SetField(scacommentmessage.FieldToID, field.TypeString, value)
}
if value, ok := scmu.mutation.Content(); ok {
_spec.SetField(scacommentmessage.FieldContent, field.TypeString, value)
}
if value, ok := scmu.mutation.IsRead(); ok {
_spec.SetField(scacommentmessage.FieldIsRead, field.TypeInt, value)
}
if value, ok := scmu.mutation.AddedIsRead(); ok {
_spec.AddField(scacommentmessage.FieldIsRead, field.TypeInt, value)
}
if scmu.mutation.IsReadCleared() {
_spec.ClearField(scacommentmessage.FieldIsRead, field.TypeInt)
}
if n, err = sqlgraph.UpdateNodes(ctx, scmu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scacommentmessage.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
scmu.mutation.done = true
return n, nil
}
// ScaCommentMessageUpdateOne is the builder for updating a single ScaCommentMessage entity.
type ScaCommentMessageUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaCommentMessageMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (scmuo *ScaCommentMessageUpdateOne) SetUpdatedAt(t time.Time) *ScaCommentMessageUpdateOne {
scmuo.mutation.SetUpdatedAt(t)
return scmuo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (scmuo *ScaCommentMessageUpdateOne) ClearUpdatedAt() *ScaCommentMessageUpdateOne {
scmuo.mutation.ClearUpdatedAt()
return scmuo
}
// SetDeleted sets the "deleted" field.
func (scmuo *ScaCommentMessageUpdateOne) SetDeleted(i int8) *ScaCommentMessageUpdateOne {
scmuo.mutation.ResetDeleted()
scmuo.mutation.SetDeleted(i)
return scmuo
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (scmuo *ScaCommentMessageUpdateOne) SetNillableDeleted(i *int8) *ScaCommentMessageUpdateOne {
if i != nil {
scmuo.SetDeleted(*i)
}
return scmuo
}
// AddDeleted adds i to the "deleted" field.
func (scmuo *ScaCommentMessageUpdateOne) AddDeleted(i int8) *ScaCommentMessageUpdateOne {
scmuo.mutation.AddDeleted(i)
return scmuo
}
// SetTopicID sets the "topic_id" field.
func (scmuo *ScaCommentMessageUpdateOne) SetTopicID(s string) *ScaCommentMessageUpdateOne {
scmuo.mutation.SetTopicID(s)
return scmuo
}
// SetNillableTopicID sets the "topic_id" field if the given value is not nil.
func (scmuo *ScaCommentMessageUpdateOne) SetNillableTopicID(s *string) *ScaCommentMessageUpdateOne {
if s != nil {
scmuo.SetTopicID(*s)
}
return scmuo
}
// SetFromID sets the "from_id" field.
func (scmuo *ScaCommentMessageUpdateOne) SetFromID(s string) *ScaCommentMessageUpdateOne {
scmuo.mutation.SetFromID(s)
return scmuo
}
// SetNillableFromID sets the "from_id" field if the given value is not nil.
func (scmuo *ScaCommentMessageUpdateOne) SetNillableFromID(s *string) *ScaCommentMessageUpdateOne {
if s != nil {
scmuo.SetFromID(*s)
}
return scmuo
}
// SetToID sets the "to_id" field.
func (scmuo *ScaCommentMessageUpdateOne) SetToID(s string) *ScaCommentMessageUpdateOne {
scmuo.mutation.SetToID(s)
return scmuo
}
// SetNillableToID sets the "to_id" field if the given value is not nil.
func (scmuo *ScaCommentMessageUpdateOne) SetNillableToID(s *string) *ScaCommentMessageUpdateOne {
if s != nil {
scmuo.SetToID(*s)
}
return scmuo
}
// SetContent sets the "content" field.
func (scmuo *ScaCommentMessageUpdateOne) SetContent(s string) *ScaCommentMessageUpdateOne {
scmuo.mutation.SetContent(s)
return scmuo
}
// SetNillableContent sets the "content" field if the given value is not nil.
func (scmuo *ScaCommentMessageUpdateOne) SetNillableContent(s *string) *ScaCommentMessageUpdateOne {
if s != nil {
scmuo.SetContent(*s)
}
return scmuo
}
// SetIsRead sets the "is_read" field.
func (scmuo *ScaCommentMessageUpdateOne) SetIsRead(i int) *ScaCommentMessageUpdateOne {
scmuo.mutation.ResetIsRead()
scmuo.mutation.SetIsRead(i)
return scmuo
}
// SetNillableIsRead sets the "is_read" field if the given value is not nil.
func (scmuo *ScaCommentMessageUpdateOne) SetNillableIsRead(i *int) *ScaCommentMessageUpdateOne {
if i != nil {
scmuo.SetIsRead(*i)
}
return scmuo
}
// AddIsRead adds i to the "is_read" field.
func (scmuo *ScaCommentMessageUpdateOne) AddIsRead(i int) *ScaCommentMessageUpdateOne {
scmuo.mutation.AddIsRead(i)
return scmuo
}
// ClearIsRead clears the value of the "is_read" field.
func (scmuo *ScaCommentMessageUpdateOne) ClearIsRead() *ScaCommentMessageUpdateOne {
scmuo.mutation.ClearIsRead()
return scmuo
}
// Mutation returns the ScaCommentMessageMutation object of the builder.
func (scmuo *ScaCommentMessageUpdateOne) Mutation() *ScaCommentMessageMutation {
return scmuo.mutation
}
// Where appends a list predicates to the ScaCommentMessageUpdate builder.
func (scmuo *ScaCommentMessageUpdateOne) Where(ps ...predicate.ScaCommentMessage) *ScaCommentMessageUpdateOne {
scmuo.mutation.Where(ps...)
return scmuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (scmuo *ScaCommentMessageUpdateOne) Select(field string, fields ...string) *ScaCommentMessageUpdateOne {
scmuo.fields = append([]string{field}, fields...)
return scmuo
}
// Save executes the query and returns the updated ScaCommentMessage entity.
func (scmuo *ScaCommentMessageUpdateOne) Save(ctx context.Context) (*ScaCommentMessage, error) {
scmuo.defaults()
return withHooks(ctx, scmuo.sqlSave, scmuo.mutation, scmuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (scmuo *ScaCommentMessageUpdateOne) SaveX(ctx context.Context) *ScaCommentMessage {
node, err := scmuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (scmuo *ScaCommentMessageUpdateOne) Exec(ctx context.Context) error {
_, err := scmuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scmuo *ScaCommentMessageUpdateOne) ExecX(ctx context.Context) {
if err := scmuo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (scmuo *ScaCommentMessageUpdateOne) defaults() {
if _, ok := scmuo.mutation.UpdatedAt(); !ok && !scmuo.mutation.UpdatedAtCleared() {
v := scacommentmessage.UpdateDefaultUpdatedAt()
scmuo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (scmuo *ScaCommentMessageUpdateOne) check() error {
if v, ok := scmuo.mutation.Deleted(); ok {
if err := scacommentmessage.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaCommentMessage.deleted": %w`, err)}
}
}
return nil
}
func (scmuo *ScaCommentMessageUpdateOne) sqlSave(ctx context.Context) (_node *ScaCommentMessage, err error) {
if err := scmuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scacommentmessage.Table, scacommentmessage.Columns, sqlgraph.NewFieldSpec(scacommentmessage.FieldID, field.TypeInt64))
id, ok := scmuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaCommentMessage.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := scmuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scacommentmessage.FieldID)
for _, f := range fields {
if !scacommentmessage.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scacommentmessage.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := scmuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := scmuo.mutation.UpdatedAt(); ok {
_spec.SetField(scacommentmessage.FieldUpdatedAt, field.TypeTime, value)
}
if scmuo.mutation.UpdatedAtCleared() {
_spec.ClearField(scacommentmessage.FieldUpdatedAt, field.TypeTime)
}
if value, ok := scmuo.mutation.Deleted(); ok {
_spec.SetField(scacommentmessage.FieldDeleted, field.TypeInt8, value)
}
if value, ok := scmuo.mutation.AddedDeleted(); ok {
_spec.AddField(scacommentmessage.FieldDeleted, field.TypeInt8, value)
}
if value, ok := scmuo.mutation.TopicID(); ok {
_spec.SetField(scacommentmessage.FieldTopicID, field.TypeString, value)
}
if value, ok := scmuo.mutation.FromID(); ok {
_spec.SetField(scacommentmessage.FieldFromID, field.TypeString, value)
}
if value, ok := scmuo.mutation.ToID(); ok {
_spec.SetField(scacommentmessage.FieldToID, field.TypeString, value)
}
if value, ok := scmuo.mutation.Content(); ok {
_spec.SetField(scacommentmessage.FieldContent, field.TypeString, value)
}
if value, ok := scmuo.mutation.IsRead(); ok {
_spec.SetField(scacommentmessage.FieldIsRead, field.TypeInt, value)
}
if value, ok := scmuo.mutation.AddedIsRead(); ok {
_spec.AddField(scacommentmessage.FieldIsRead, field.TypeInt, value)
}
if scmuo.mutation.IsReadCleared() {
_spec.ClearField(scacommentmessage.FieldIsRead, field.TypeInt)
}
_node = &ScaCommentMessage{config: scmuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, scmuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scacommentmessage.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
scmuo.mutation.done = true
return _node, nil
}

View File

@@ -1,305 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentreply"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 评论回复表
type ScaCommentReply struct {
config `json:"-"`
// ID of the ent.
// 主键id
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 评论用户id
UserID string `json:"user_id,omitempty"`
// 评论话题id
TopicID string `json:"topic_id,omitempty"`
// 话题类型
TopicType int `json:"topic_type,omitempty"`
// 评论内容
Content string `json:"content,omitempty"`
// 评论类型 0评论 1 回复
CommentType int `json:"comment_type,omitempty"`
// 回复子评论ID
ReplyTo int64 `json:"reply_to,omitempty"`
// 回复父评论Id
ReplyID int64 `json:"reply_id,omitempty"`
// 回复人id
ReplyUser string `json:"reply_user,omitempty"`
// 评论回复是否作者 0否 1是
Author int `json:"author,omitempty"`
// 点赞数
Likes int64 `json:"likes,omitempty"`
// 回复数量
ReplyCount int64 `json:"reply_count,omitempty"`
// 浏览器
Browser string `json:"browser,omitempty"`
// 操作系统
OperatingSystem string `json:"operating_system,omitempty"`
// IP地址
CommentIP string `json:"comment_ip,omitempty"`
// 地址
Location string `json:"location,omitempty"`
// 设备信息
Agent string `json:"agent,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaCommentReply) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scacommentreply.FieldID, scacommentreply.FieldDeleted, scacommentreply.FieldTopicType, scacommentreply.FieldCommentType, scacommentreply.FieldReplyTo, scacommentreply.FieldReplyID, scacommentreply.FieldAuthor, scacommentreply.FieldLikes, scacommentreply.FieldReplyCount:
values[i] = new(sql.NullInt64)
case scacommentreply.FieldUserID, scacommentreply.FieldTopicID, scacommentreply.FieldContent, scacommentreply.FieldReplyUser, scacommentreply.FieldBrowser, scacommentreply.FieldOperatingSystem, scacommentreply.FieldCommentIP, scacommentreply.FieldLocation, scacommentreply.FieldAgent:
values[i] = new(sql.NullString)
case scacommentreply.FieldCreatedAt, scacommentreply.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaCommentReply fields.
func (scr *ScaCommentReply) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scacommentreply.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
scr.ID = int64(value.Int64)
case scacommentreply.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
scr.CreatedAt = value.Time
}
case scacommentreply.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
scr.UpdatedAt = value.Time
}
case scacommentreply.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
scr.Deleted = int8(value.Int64)
}
case scacommentreply.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
scr.UserID = value.String
}
case scacommentreply.FieldTopicID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field topic_id", values[i])
} else if value.Valid {
scr.TopicID = value.String
}
case scacommentreply.FieldTopicType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field topic_type", values[i])
} else if value.Valid {
scr.TopicType = int(value.Int64)
}
case scacommentreply.FieldContent:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field content", values[i])
} else if value.Valid {
scr.Content = value.String
}
case scacommentreply.FieldCommentType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field comment_type", values[i])
} else if value.Valid {
scr.CommentType = int(value.Int64)
}
case scacommentreply.FieldReplyTo:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field reply_to", values[i])
} else if value.Valid {
scr.ReplyTo = value.Int64
}
case scacommentreply.FieldReplyID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field reply_id", values[i])
} else if value.Valid {
scr.ReplyID = value.Int64
}
case scacommentreply.FieldReplyUser:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reply_user", values[i])
} else if value.Valid {
scr.ReplyUser = value.String
}
case scacommentreply.FieldAuthor:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field author", values[i])
} else if value.Valid {
scr.Author = int(value.Int64)
}
case scacommentreply.FieldLikes:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field likes", values[i])
} else if value.Valid {
scr.Likes = value.Int64
}
case scacommentreply.FieldReplyCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field reply_count", values[i])
} else if value.Valid {
scr.ReplyCount = value.Int64
}
case scacommentreply.FieldBrowser:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field browser", values[i])
} else if value.Valid {
scr.Browser = value.String
}
case scacommentreply.FieldOperatingSystem:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field operating_system", values[i])
} else if value.Valid {
scr.OperatingSystem = value.String
}
case scacommentreply.FieldCommentIP:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field comment_ip", values[i])
} else if value.Valid {
scr.CommentIP = value.String
}
case scacommentreply.FieldLocation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field location", values[i])
} else if value.Valid {
scr.Location = value.String
}
case scacommentreply.FieldAgent:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field agent", values[i])
} else if value.Valid {
scr.Agent = value.String
}
default:
scr.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaCommentReply.
// This includes values selected through modifiers, order, etc.
func (scr *ScaCommentReply) Value(name string) (ent.Value, error) {
return scr.selectValues.Get(name)
}
// Update returns a builder for updating this ScaCommentReply.
// Note that you need to call ScaCommentReply.Unwrap() before calling this method if this ScaCommentReply
// was returned from a transaction, and the transaction was committed or rolled back.
func (scr *ScaCommentReply) Update() *ScaCommentReplyUpdateOne {
return NewScaCommentReplyClient(scr.config).UpdateOne(scr)
}
// Unwrap unwraps the ScaCommentReply entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (scr *ScaCommentReply) Unwrap() *ScaCommentReply {
_tx, ok := scr.config.driver.(*txDriver)
if !ok {
panic("ent: ScaCommentReply is not a transactional entity")
}
scr.config.driver = _tx.drv
return scr
}
// String implements the fmt.Stringer.
func (scr *ScaCommentReply) String() string {
var builder strings.Builder
builder.WriteString("ScaCommentReply(")
builder.WriteString(fmt.Sprintf("id=%v, ", scr.ID))
builder.WriteString("created_at=")
builder.WriteString(scr.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(scr.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", scr.Deleted))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(scr.UserID)
builder.WriteString(", ")
builder.WriteString("topic_id=")
builder.WriteString(scr.TopicID)
builder.WriteString(", ")
builder.WriteString("topic_type=")
builder.WriteString(fmt.Sprintf("%v", scr.TopicType))
builder.WriteString(", ")
builder.WriteString("content=")
builder.WriteString(scr.Content)
builder.WriteString(", ")
builder.WriteString("comment_type=")
builder.WriteString(fmt.Sprintf("%v", scr.CommentType))
builder.WriteString(", ")
builder.WriteString("reply_to=")
builder.WriteString(fmt.Sprintf("%v", scr.ReplyTo))
builder.WriteString(", ")
builder.WriteString("reply_id=")
builder.WriteString(fmt.Sprintf("%v", scr.ReplyID))
builder.WriteString(", ")
builder.WriteString("reply_user=")
builder.WriteString(scr.ReplyUser)
builder.WriteString(", ")
builder.WriteString("author=")
builder.WriteString(fmt.Sprintf("%v", scr.Author))
builder.WriteString(", ")
builder.WriteString("likes=")
builder.WriteString(fmt.Sprintf("%v", scr.Likes))
builder.WriteString(", ")
builder.WriteString("reply_count=")
builder.WriteString(fmt.Sprintf("%v", scr.ReplyCount))
builder.WriteString(", ")
builder.WriteString("browser=")
builder.WriteString(scr.Browser)
builder.WriteString(", ")
builder.WriteString("operating_system=")
builder.WriteString(scr.OperatingSystem)
builder.WriteString(", ")
builder.WriteString("comment_ip=")
builder.WriteString(scr.CommentIP)
builder.WriteString(", ")
builder.WriteString("location=")
builder.WriteString(scr.Location)
builder.WriteString(", ")
builder.WriteString("agent=")
builder.WriteString(scr.Agent)
builder.WriteByte(')')
return builder.String()
}
// ScaCommentReplies is a parsable slice of ScaCommentReply.
type ScaCommentReplies []*ScaCommentReply

View File

@@ -1,212 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scacommentreply
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scacommentreply type in the database.
Label = "sca_comment_reply"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldTopicID holds the string denoting the topic_id field in the database.
FieldTopicID = "topic_id"
// FieldTopicType holds the string denoting the topic_type field in the database.
FieldTopicType = "topic_type"
// FieldContent holds the string denoting the content field in the database.
FieldContent = "content"
// FieldCommentType holds the string denoting the comment_type field in the database.
FieldCommentType = "comment_type"
// FieldReplyTo holds the string denoting the reply_to field in the database.
FieldReplyTo = "reply_to"
// FieldReplyID holds the string denoting the reply_id field in the database.
FieldReplyID = "reply_id"
// FieldReplyUser holds the string denoting the reply_user field in the database.
FieldReplyUser = "reply_user"
// FieldAuthor holds the string denoting the author field in the database.
FieldAuthor = "author"
// FieldLikes holds the string denoting the likes field in the database.
FieldLikes = "likes"
// FieldReplyCount holds the string denoting the reply_count field in the database.
FieldReplyCount = "reply_count"
// FieldBrowser holds the string denoting the browser field in the database.
FieldBrowser = "browser"
// FieldOperatingSystem holds the string denoting the operating_system field in the database.
FieldOperatingSystem = "operating_system"
// FieldCommentIP holds the string denoting the comment_ip field in the database.
FieldCommentIP = "comment_ip"
// FieldLocation holds the string denoting the location field in the database.
FieldLocation = "location"
// FieldAgent holds the string denoting the agent field in the database.
FieldAgent = "agent"
// Table holds the table name of the scacommentreply in the database.
Table = "sca_comment_reply"
)
// Columns holds all SQL columns for scacommentreply fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUserID,
FieldTopicID,
FieldTopicType,
FieldContent,
FieldCommentType,
FieldReplyTo,
FieldReplyID,
FieldReplyUser,
FieldAuthor,
FieldLikes,
FieldReplyCount,
FieldBrowser,
FieldOperatingSystem,
FieldCommentIP,
FieldLocation,
FieldAgent,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// DefaultAuthor holds the default value on creation for the "author" field.
DefaultAuthor int
// DefaultLikes holds the default value on creation for the "likes" field.
DefaultLikes int64
// DefaultReplyCount holds the default value on creation for the "reply_count" field.
DefaultReplyCount int64
// AgentValidator is a validator for the "agent" field. It is called by the builders before save.
AgentValidator func(string) error
)
// OrderOption defines the ordering options for the ScaCommentReply queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByTopicID orders the results by the topic_id field.
func ByTopicID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTopicID, opts...).ToFunc()
}
// ByTopicType orders the results by the topic_type field.
func ByTopicType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTopicType, opts...).ToFunc()
}
// ByContent orders the results by the content field.
func ByContent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldContent, opts...).ToFunc()
}
// ByCommentType orders the results by the comment_type field.
func ByCommentType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCommentType, opts...).ToFunc()
}
// ByReplyTo orders the results by the reply_to field.
func ByReplyTo(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReplyTo, opts...).ToFunc()
}
// ByReplyID orders the results by the reply_id field.
func ByReplyID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReplyID, opts...).ToFunc()
}
// ByReplyUser orders the results by the reply_user field.
func ByReplyUser(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReplyUser, opts...).ToFunc()
}
// ByAuthor orders the results by the author field.
func ByAuthor(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAuthor, opts...).ToFunc()
}
// ByLikes orders the results by the likes field.
func ByLikes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLikes, opts...).ToFunc()
}
// ByReplyCount orders the results by the reply_count field.
func ByReplyCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReplyCount, opts...).ToFunc()
}
// ByBrowser orders the results by the browser field.
func ByBrowser(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBrowser, opts...).ToFunc()
}
// ByOperatingSystem orders the results by the operating_system field.
func ByOperatingSystem(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperatingSystem, opts...).ToFunc()
}
// ByCommentIP orders the results by the comment_ip field.
func ByCommentIP(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCommentIP, opts...).ToFunc()
}
// ByLocation orders the results by the location field.
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocation, opts...).ToFunc()
}
// ByAgent orders the results by the agent field.
func ByAgent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAgent, opts...).ToFunc()
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,520 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentreply"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentReplyCreate is the builder for creating a ScaCommentReply entity.
type ScaCommentReplyCreate struct {
config
mutation *ScaCommentReplyMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (scrc *ScaCommentReplyCreate) SetCreatedAt(t time.Time) *ScaCommentReplyCreate {
scrc.mutation.SetCreatedAt(t)
return scrc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableCreatedAt(t *time.Time) *ScaCommentReplyCreate {
if t != nil {
scrc.SetCreatedAt(*t)
}
return scrc
}
// SetUpdatedAt sets the "updated_at" field.
func (scrc *ScaCommentReplyCreate) SetUpdatedAt(t time.Time) *ScaCommentReplyCreate {
scrc.mutation.SetUpdatedAt(t)
return scrc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableUpdatedAt(t *time.Time) *ScaCommentReplyCreate {
if t != nil {
scrc.SetUpdatedAt(*t)
}
return scrc
}
// SetDeleted sets the "deleted" field.
func (scrc *ScaCommentReplyCreate) SetDeleted(i int8) *ScaCommentReplyCreate {
scrc.mutation.SetDeleted(i)
return scrc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableDeleted(i *int8) *ScaCommentReplyCreate {
if i != nil {
scrc.SetDeleted(*i)
}
return scrc
}
// SetUserID sets the "user_id" field.
func (scrc *ScaCommentReplyCreate) SetUserID(s string) *ScaCommentReplyCreate {
scrc.mutation.SetUserID(s)
return scrc
}
// SetTopicID sets the "topic_id" field.
func (scrc *ScaCommentReplyCreate) SetTopicID(s string) *ScaCommentReplyCreate {
scrc.mutation.SetTopicID(s)
return scrc
}
// SetTopicType sets the "topic_type" field.
func (scrc *ScaCommentReplyCreate) SetTopicType(i int) *ScaCommentReplyCreate {
scrc.mutation.SetTopicType(i)
return scrc
}
// SetContent sets the "content" field.
func (scrc *ScaCommentReplyCreate) SetContent(s string) *ScaCommentReplyCreate {
scrc.mutation.SetContent(s)
return scrc
}
// SetCommentType sets the "comment_type" field.
func (scrc *ScaCommentReplyCreate) SetCommentType(i int) *ScaCommentReplyCreate {
scrc.mutation.SetCommentType(i)
return scrc
}
// SetReplyTo sets the "reply_to" field.
func (scrc *ScaCommentReplyCreate) SetReplyTo(i int64) *ScaCommentReplyCreate {
scrc.mutation.SetReplyTo(i)
return scrc
}
// SetNillableReplyTo sets the "reply_to" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableReplyTo(i *int64) *ScaCommentReplyCreate {
if i != nil {
scrc.SetReplyTo(*i)
}
return scrc
}
// SetReplyID sets the "reply_id" field.
func (scrc *ScaCommentReplyCreate) SetReplyID(i int64) *ScaCommentReplyCreate {
scrc.mutation.SetReplyID(i)
return scrc
}
// SetNillableReplyID sets the "reply_id" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableReplyID(i *int64) *ScaCommentReplyCreate {
if i != nil {
scrc.SetReplyID(*i)
}
return scrc
}
// SetReplyUser sets the "reply_user" field.
func (scrc *ScaCommentReplyCreate) SetReplyUser(s string) *ScaCommentReplyCreate {
scrc.mutation.SetReplyUser(s)
return scrc
}
// SetNillableReplyUser sets the "reply_user" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableReplyUser(s *string) *ScaCommentReplyCreate {
if s != nil {
scrc.SetReplyUser(*s)
}
return scrc
}
// SetAuthor sets the "author" field.
func (scrc *ScaCommentReplyCreate) SetAuthor(i int) *ScaCommentReplyCreate {
scrc.mutation.SetAuthor(i)
return scrc
}
// SetNillableAuthor sets the "author" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableAuthor(i *int) *ScaCommentReplyCreate {
if i != nil {
scrc.SetAuthor(*i)
}
return scrc
}
// SetLikes sets the "likes" field.
func (scrc *ScaCommentReplyCreate) SetLikes(i int64) *ScaCommentReplyCreate {
scrc.mutation.SetLikes(i)
return scrc
}
// SetNillableLikes sets the "likes" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableLikes(i *int64) *ScaCommentReplyCreate {
if i != nil {
scrc.SetLikes(*i)
}
return scrc
}
// SetReplyCount sets the "reply_count" field.
func (scrc *ScaCommentReplyCreate) SetReplyCount(i int64) *ScaCommentReplyCreate {
scrc.mutation.SetReplyCount(i)
return scrc
}
// SetNillableReplyCount sets the "reply_count" field if the given value is not nil.
func (scrc *ScaCommentReplyCreate) SetNillableReplyCount(i *int64) *ScaCommentReplyCreate {
if i != nil {
scrc.SetReplyCount(*i)
}
return scrc
}
// SetBrowser sets the "browser" field.
func (scrc *ScaCommentReplyCreate) SetBrowser(s string) *ScaCommentReplyCreate {
scrc.mutation.SetBrowser(s)
return scrc
}
// SetOperatingSystem sets the "operating_system" field.
func (scrc *ScaCommentReplyCreate) SetOperatingSystem(s string) *ScaCommentReplyCreate {
scrc.mutation.SetOperatingSystem(s)
return scrc
}
// SetCommentIP sets the "comment_ip" field.
func (scrc *ScaCommentReplyCreate) SetCommentIP(s string) *ScaCommentReplyCreate {
scrc.mutation.SetCommentIP(s)
return scrc
}
// SetLocation sets the "location" field.
func (scrc *ScaCommentReplyCreate) SetLocation(s string) *ScaCommentReplyCreate {
scrc.mutation.SetLocation(s)
return scrc
}
// SetAgent sets the "agent" field.
func (scrc *ScaCommentReplyCreate) SetAgent(s string) *ScaCommentReplyCreate {
scrc.mutation.SetAgent(s)
return scrc
}
// SetID sets the "id" field.
func (scrc *ScaCommentReplyCreate) SetID(i int64) *ScaCommentReplyCreate {
scrc.mutation.SetID(i)
return scrc
}
// Mutation returns the ScaCommentReplyMutation object of the builder.
func (scrc *ScaCommentReplyCreate) Mutation() *ScaCommentReplyMutation {
return scrc.mutation
}
// Save creates the ScaCommentReply in the database.
func (scrc *ScaCommentReplyCreate) Save(ctx context.Context) (*ScaCommentReply, error) {
scrc.defaults()
return withHooks(ctx, scrc.sqlSave, scrc.mutation, scrc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (scrc *ScaCommentReplyCreate) SaveX(ctx context.Context) *ScaCommentReply {
v, err := scrc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (scrc *ScaCommentReplyCreate) Exec(ctx context.Context) error {
_, err := scrc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scrc *ScaCommentReplyCreate) ExecX(ctx context.Context) {
if err := scrc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (scrc *ScaCommentReplyCreate) defaults() {
if _, ok := scrc.mutation.CreatedAt(); !ok {
v := scacommentreply.DefaultCreatedAt()
scrc.mutation.SetCreatedAt(v)
}
if _, ok := scrc.mutation.Deleted(); !ok {
v := scacommentreply.DefaultDeleted
scrc.mutation.SetDeleted(v)
}
if _, ok := scrc.mutation.Author(); !ok {
v := scacommentreply.DefaultAuthor
scrc.mutation.SetAuthor(v)
}
if _, ok := scrc.mutation.Likes(); !ok {
v := scacommentreply.DefaultLikes
scrc.mutation.SetLikes(v)
}
if _, ok := scrc.mutation.ReplyCount(); !ok {
v := scacommentreply.DefaultReplyCount
scrc.mutation.SetReplyCount(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (scrc *ScaCommentReplyCreate) check() error {
if _, ok := scrc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaCommentReply.created_at"`)}
}
if _, ok := scrc.mutation.Deleted(); !ok {
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "ScaCommentReply.deleted"`)}
}
if v, ok := scrc.mutation.Deleted(); ok {
if err := scacommentreply.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaCommentReply.deleted": %w`, err)}
}
}
if _, ok := scrc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaCommentReply.user_id"`)}
}
if _, ok := scrc.mutation.TopicID(); !ok {
return &ValidationError{Name: "topic_id", err: errors.New(`ent: missing required field "ScaCommentReply.topic_id"`)}
}
if _, ok := scrc.mutation.TopicType(); !ok {
return &ValidationError{Name: "topic_type", err: errors.New(`ent: missing required field "ScaCommentReply.topic_type"`)}
}
if _, ok := scrc.mutation.Content(); !ok {
return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "ScaCommentReply.content"`)}
}
if _, ok := scrc.mutation.CommentType(); !ok {
return &ValidationError{Name: "comment_type", err: errors.New(`ent: missing required field "ScaCommentReply.comment_type"`)}
}
if _, ok := scrc.mutation.Author(); !ok {
return &ValidationError{Name: "author", err: errors.New(`ent: missing required field "ScaCommentReply.author"`)}
}
if _, ok := scrc.mutation.Browser(); !ok {
return &ValidationError{Name: "browser", err: errors.New(`ent: missing required field "ScaCommentReply.browser"`)}
}
if _, ok := scrc.mutation.OperatingSystem(); !ok {
return &ValidationError{Name: "operating_system", err: errors.New(`ent: missing required field "ScaCommentReply.operating_system"`)}
}
if _, ok := scrc.mutation.CommentIP(); !ok {
return &ValidationError{Name: "comment_ip", err: errors.New(`ent: missing required field "ScaCommentReply.comment_ip"`)}
}
if _, ok := scrc.mutation.Location(); !ok {
return &ValidationError{Name: "location", err: errors.New(`ent: missing required field "ScaCommentReply.location"`)}
}
if _, ok := scrc.mutation.Agent(); !ok {
return &ValidationError{Name: "agent", err: errors.New(`ent: missing required field "ScaCommentReply.agent"`)}
}
if v, ok := scrc.mutation.Agent(); ok {
if err := scacommentreply.AgentValidator(v); err != nil {
return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaCommentReply.agent": %w`, err)}
}
}
return nil
}
func (scrc *ScaCommentReplyCreate) sqlSave(ctx context.Context) (*ScaCommentReply, error) {
if err := scrc.check(); err != nil {
return nil, err
}
_node, _spec := scrc.createSpec()
if err := sqlgraph.CreateNode(ctx, scrc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
scrc.mutation.id = &_node.ID
scrc.mutation.done = true
return _node, nil
}
func (scrc *ScaCommentReplyCreate) createSpec() (*ScaCommentReply, *sqlgraph.CreateSpec) {
var (
_node = &ScaCommentReply{config: scrc.config}
_spec = sqlgraph.NewCreateSpec(scacommentreply.Table, sqlgraph.NewFieldSpec(scacommentreply.FieldID, field.TypeInt64))
)
if id, ok := scrc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := scrc.mutation.CreatedAt(); ok {
_spec.SetField(scacommentreply.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := scrc.mutation.UpdatedAt(); ok {
_spec.SetField(scacommentreply.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := scrc.mutation.Deleted(); ok {
_spec.SetField(scacommentreply.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := scrc.mutation.UserID(); ok {
_spec.SetField(scacommentreply.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := scrc.mutation.TopicID(); ok {
_spec.SetField(scacommentreply.FieldTopicID, field.TypeString, value)
_node.TopicID = value
}
if value, ok := scrc.mutation.TopicType(); ok {
_spec.SetField(scacommentreply.FieldTopicType, field.TypeInt, value)
_node.TopicType = value
}
if value, ok := scrc.mutation.Content(); ok {
_spec.SetField(scacommentreply.FieldContent, field.TypeString, value)
_node.Content = value
}
if value, ok := scrc.mutation.CommentType(); ok {
_spec.SetField(scacommentreply.FieldCommentType, field.TypeInt, value)
_node.CommentType = value
}
if value, ok := scrc.mutation.ReplyTo(); ok {
_spec.SetField(scacommentreply.FieldReplyTo, field.TypeInt64, value)
_node.ReplyTo = value
}
if value, ok := scrc.mutation.ReplyID(); ok {
_spec.SetField(scacommentreply.FieldReplyID, field.TypeInt64, value)
_node.ReplyID = value
}
if value, ok := scrc.mutation.ReplyUser(); ok {
_spec.SetField(scacommentreply.FieldReplyUser, field.TypeString, value)
_node.ReplyUser = value
}
if value, ok := scrc.mutation.Author(); ok {
_spec.SetField(scacommentreply.FieldAuthor, field.TypeInt, value)
_node.Author = value
}
if value, ok := scrc.mutation.Likes(); ok {
_spec.SetField(scacommentreply.FieldLikes, field.TypeInt64, value)
_node.Likes = value
}
if value, ok := scrc.mutation.ReplyCount(); ok {
_spec.SetField(scacommentreply.FieldReplyCount, field.TypeInt64, value)
_node.ReplyCount = value
}
if value, ok := scrc.mutation.Browser(); ok {
_spec.SetField(scacommentreply.FieldBrowser, field.TypeString, value)
_node.Browser = value
}
if value, ok := scrc.mutation.OperatingSystem(); ok {
_spec.SetField(scacommentreply.FieldOperatingSystem, field.TypeString, value)
_node.OperatingSystem = value
}
if value, ok := scrc.mutation.CommentIP(); ok {
_spec.SetField(scacommentreply.FieldCommentIP, field.TypeString, value)
_node.CommentIP = value
}
if value, ok := scrc.mutation.Location(); ok {
_spec.SetField(scacommentreply.FieldLocation, field.TypeString, value)
_node.Location = value
}
if value, ok := scrc.mutation.Agent(); ok {
_spec.SetField(scacommentreply.FieldAgent, field.TypeString, value)
_node.Agent = value
}
return _node, _spec
}
// ScaCommentReplyCreateBulk is the builder for creating many ScaCommentReply entities in bulk.
type ScaCommentReplyCreateBulk struct {
config
err error
builders []*ScaCommentReplyCreate
}
// Save creates the ScaCommentReply entities in the database.
func (scrcb *ScaCommentReplyCreateBulk) Save(ctx context.Context) ([]*ScaCommentReply, error) {
if scrcb.err != nil {
return nil, scrcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(scrcb.builders))
nodes := make([]*ScaCommentReply, len(scrcb.builders))
mutators := make([]Mutator, len(scrcb.builders))
for i := range scrcb.builders {
func(i int, root context.Context) {
builder := scrcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaCommentReplyMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, scrcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, scrcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, scrcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (scrcb *ScaCommentReplyCreateBulk) SaveX(ctx context.Context) []*ScaCommentReply {
v, err := scrcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (scrcb *ScaCommentReplyCreateBulk) Exec(ctx context.Context) error {
_, err := scrcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (scrcb *ScaCommentReplyCreateBulk) ExecX(ctx context.Context) {
if err := scrcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentreply"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentReplyDelete is the builder for deleting a ScaCommentReply entity.
type ScaCommentReplyDelete struct {
config
hooks []Hook
mutation *ScaCommentReplyMutation
}
// Where appends a list predicates to the ScaCommentReplyDelete builder.
func (scrd *ScaCommentReplyDelete) Where(ps ...predicate.ScaCommentReply) *ScaCommentReplyDelete {
scrd.mutation.Where(ps...)
return scrd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (scrd *ScaCommentReplyDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, scrd.sqlExec, scrd.mutation, scrd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (scrd *ScaCommentReplyDelete) ExecX(ctx context.Context) int {
n, err := scrd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (scrd *ScaCommentReplyDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scacommentreply.Table, sqlgraph.NewFieldSpec(scacommentreply.FieldID, field.TypeInt64))
if ps := scrd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, scrd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
scrd.mutation.done = true
return affected, err
}
// ScaCommentReplyDeleteOne is the builder for deleting a single ScaCommentReply entity.
type ScaCommentReplyDeleteOne struct {
scrd *ScaCommentReplyDelete
}
// Where appends a list predicates to the ScaCommentReplyDelete builder.
func (scrdo *ScaCommentReplyDeleteOne) Where(ps ...predicate.ScaCommentReply) *ScaCommentReplyDeleteOne {
scrdo.scrd.mutation.Where(ps...)
return scrdo
}
// Exec executes the deletion query.
func (scrdo *ScaCommentReplyDeleteOne) Exec(ctx context.Context) error {
n, err := scrdo.scrd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scacommentreply.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (scrdo *ScaCommentReplyDeleteOne) ExecX(ctx context.Context) {
if err := scrdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scacommentreply"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaCommentReplyQuery is the builder for querying ScaCommentReply entities.
type ScaCommentReplyQuery struct {
config
ctx *QueryContext
order []scacommentreply.OrderOption
inters []Interceptor
predicates []predicate.ScaCommentReply
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaCommentReplyQuery builder.
func (scrq *ScaCommentReplyQuery) Where(ps ...predicate.ScaCommentReply) *ScaCommentReplyQuery {
scrq.predicates = append(scrq.predicates, ps...)
return scrq
}
// Limit the number of records to be returned by this query.
func (scrq *ScaCommentReplyQuery) Limit(limit int) *ScaCommentReplyQuery {
scrq.ctx.Limit = &limit
return scrq
}
// Offset to start from.
func (scrq *ScaCommentReplyQuery) Offset(offset int) *ScaCommentReplyQuery {
scrq.ctx.Offset = &offset
return scrq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (scrq *ScaCommentReplyQuery) Unique(unique bool) *ScaCommentReplyQuery {
scrq.ctx.Unique = &unique
return scrq
}
// Order specifies how the records should be ordered.
func (scrq *ScaCommentReplyQuery) Order(o ...scacommentreply.OrderOption) *ScaCommentReplyQuery {
scrq.order = append(scrq.order, o...)
return scrq
}
// First returns the first ScaCommentReply entity from the query.
// Returns a *NotFoundError when no ScaCommentReply was found.
func (scrq *ScaCommentReplyQuery) First(ctx context.Context) (*ScaCommentReply, error) {
nodes, err := scrq.Limit(1).All(setContextOp(ctx, scrq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scacommentreply.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) FirstX(ctx context.Context) *ScaCommentReply {
node, err := scrq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaCommentReply ID from the query.
// Returns a *NotFoundError when no ScaCommentReply ID was found.
func (scrq *ScaCommentReplyQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = scrq.Limit(1).IDs(setContextOp(ctx, scrq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scacommentreply.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) FirstIDX(ctx context.Context) int64 {
id, err := scrq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaCommentReply entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaCommentReply entity is found.
// Returns a *NotFoundError when no ScaCommentReply entities are found.
func (scrq *ScaCommentReplyQuery) Only(ctx context.Context) (*ScaCommentReply, error) {
nodes, err := scrq.Limit(2).All(setContextOp(ctx, scrq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scacommentreply.Label}
default:
return nil, &NotSingularError{scacommentreply.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) OnlyX(ctx context.Context) *ScaCommentReply {
node, err := scrq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaCommentReply ID in the query.
// Returns a *NotSingularError when more than one ScaCommentReply ID is found.
// Returns a *NotFoundError when no entities are found.
func (scrq *ScaCommentReplyQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = scrq.Limit(2).IDs(setContextOp(ctx, scrq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scacommentreply.Label}
default:
err = &NotSingularError{scacommentreply.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) OnlyIDX(ctx context.Context) int64 {
id, err := scrq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaCommentReplies.
func (scrq *ScaCommentReplyQuery) All(ctx context.Context) ([]*ScaCommentReply, error) {
ctx = setContextOp(ctx, scrq.ctx, ent.OpQueryAll)
if err := scrq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaCommentReply, *ScaCommentReplyQuery]()
return withInterceptors[[]*ScaCommentReply](ctx, scrq, qr, scrq.inters)
}
// AllX is like All, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) AllX(ctx context.Context) []*ScaCommentReply {
nodes, err := scrq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaCommentReply IDs.
func (scrq *ScaCommentReplyQuery) IDs(ctx context.Context) (ids []int64, err error) {
if scrq.ctx.Unique == nil && scrq.path != nil {
scrq.Unique(true)
}
ctx = setContextOp(ctx, scrq.ctx, ent.OpQueryIDs)
if err = scrq.Select(scacommentreply.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) IDsX(ctx context.Context) []int64 {
ids, err := scrq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (scrq *ScaCommentReplyQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, scrq.ctx, ent.OpQueryCount)
if err := scrq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, scrq, querierCount[*ScaCommentReplyQuery](), scrq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) CountX(ctx context.Context) int {
count, err := scrq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (scrq *ScaCommentReplyQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, scrq.ctx, ent.OpQueryExist)
switch _, err := scrq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (scrq *ScaCommentReplyQuery) ExistX(ctx context.Context) bool {
exist, err := scrq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaCommentReplyQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (scrq *ScaCommentReplyQuery) Clone() *ScaCommentReplyQuery {
if scrq == nil {
return nil
}
return &ScaCommentReplyQuery{
config: scrq.config,
ctx: scrq.ctx.Clone(),
order: append([]scacommentreply.OrderOption{}, scrq.order...),
inters: append([]Interceptor{}, scrq.inters...),
predicates: append([]predicate.ScaCommentReply{}, scrq.predicates...),
// clone intermediate query.
sql: scrq.sql.Clone(),
path: scrq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaCommentReply.Query().
// GroupBy(scacommentreply.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (scrq *ScaCommentReplyQuery) GroupBy(field string, fields ...string) *ScaCommentReplyGroupBy {
scrq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaCommentReplyGroupBy{build: scrq}
grbuild.flds = &scrq.ctx.Fields
grbuild.label = scacommentreply.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaCommentReply.Query().
// Select(scacommentreply.FieldCreatedAt).
// Scan(ctx, &v)
func (scrq *ScaCommentReplyQuery) Select(fields ...string) *ScaCommentReplySelect {
scrq.ctx.Fields = append(scrq.ctx.Fields, fields...)
sbuild := &ScaCommentReplySelect{ScaCommentReplyQuery: scrq}
sbuild.label = scacommentreply.Label
sbuild.flds, sbuild.scan = &scrq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaCommentReplySelect configured with the given aggregations.
func (scrq *ScaCommentReplyQuery) Aggregate(fns ...AggregateFunc) *ScaCommentReplySelect {
return scrq.Select().Aggregate(fns...)
}
func (scrq *ScaCommentReplyQuery) prepareQuery(ctx context.Context) error {
for _, inter := range scrq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, scrq); err != nil {
return err
}
}
}
for _, f := range scrq.ctx.Fields {
if !scacommentreply.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if scrq.path != nil {
prev, err := scrq.path(ctx)
if err != nil {
return err
}
scrq.sql = prev
}
return nil
}
func (scrq *ScaCommentReplyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaCommentReply, error) {
var (
nodes = []*ScaCommentReply{}
_spec = scrq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaCommentReply).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaCommentReply{config: scrq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, scrq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (scrq *ScaCommentReplyQuery) sqlCount(ctx context.Context) (int, error) {
_spec := scrq.querySpec()
_spec.Node.Columns = scrq.ctx.Fields
if len(scrq.ctx.Fields) > 0 {
_spec.Unique = scrq.ctx.Unique != nil && *scrq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, scrq.driver, _spec)
}
func (scrq *ScaCommentReplyQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scacommentreply.Table, scacommentreply.Columns, sqlgraph.NewFieldSpec(scacommentreply.FieldID, field.TypeInt64))
_spec.From = scrq.sql
if unique := scrq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if scrq.path != nil {
_spec.Unique = true
}
if fields := scrq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scacommentreply.FieldID)
for i := range fields {
if fields[i] != scacommentreply.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := scrq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := scrq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := scrq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := scrq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (scrq *ScaCommentReplyQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(scrq.driver.Dialect())
t1 := builder.Table(scacommentreply.Table)
columns := scrq.ctx.Fields
if len(columns) == 0 {
columns = scacommentreply.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if scrq.sql != nil {
selector = scrq.sql
selector.Select(selector.Columns(columns...)...)
}
if scrq.ctx.Unique != nil && *scrq.ctx.Unique {
selector.Distinct()
}
for _, p := range scrq.predicates {
p(selector)
}
for _, p := range scrq.order {
p(selector)
}
if offset := scrq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := scrq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaCommentReplyGroupBy is the group-by builder for ScaCommentReply entities.
type ScaCommentReplyGroupBy struct {
selector
build *ScaCommentReplyQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (scrgb *ScaCommentReplyGroupBy) Aggregate(fns ...AggregateFunc) *ScaCommentReplyGroupBy {
scrgb.fns = append(scrgb.fns, fns...)
return scrgb
}
// Scan applies the selector query and scans the result into the given value.
func (scrgb *ScaCommentReplyGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, scrgb.build.ctx, ent.OpQueryGroupBy)
if err := scrgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaCommentReplyQuery, *ScaCommentReplyGroupBy](ctx, scrgb.build, scrgb, scrgb.build.inters, v)
}
func (scrgb *ScaCommentReplyGroupBy) sqlScan(ctx context.Context, root *ScaCommentReplyQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(scrgb.fns))
for _, fn := range scrgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*scrgb.flds)+len(scrgb.fns))
for _, f := range *scrgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*scrgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := scrgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaCommentReplySelect is the builder for selecting fields of ScaCommentReply entities.
type ScaCommentReplySelect struct {
*ScaCommentReplyQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (scrs *ScaCommentReplySelect) Aggregate(fns ...AggregateFunc) *ScaCommentReplySelect {
scrs.fns = append(scrs.fns, fns...)
return scrs
}
// Scan applies the selector query and scans the result into the given value.
func (scrs *ScaCommentReplySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, scrs.ctx, ent.OpQuerySelect)
if err := scrs.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaCommentReplyQuery, *ScaCommentReplySelect](ctx, scrs.ScaCommentReplyQuery, scrs, scrs.inters, v)
}
func (scrs *ScaCommentReplySelect) sqlScan(ctx context.Context, root *ScaCommentReplyQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(scrs.fns))
for _, fn := range scrs.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*scrs.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := scrs.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,125 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户关注表
type ScaUserFollows struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 关注者
FollowerID string `json:"follower_id,omitempty"`
// 被关注者
FolloweeID string `json:"followee_id,omitempty"`
// 关注状态0 未互关 1 互关)
Status uint8 `json:"status,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaUserFollows) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scauserfollows.FieldID, scauserfollows.FieldStatus:
values[i] = new(sql.NullInt64)
case scauserfollows.FieldFollowerID, scauserfollows.FieldFolloweeID:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaUserFollows fields.
func (suf *ScaUserFollows) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scauserfollows.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
suf.ID = int(value.Int64)
case scauserfollows.FieldFollowerID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field follower_id", values[i])
} else if value.Valid {
suf.FollowerID = value.String
}
case scauserfollows.FieldFolloweeID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field followee_id", values[i])
} else if value.Valid {
suf.FolloweeID = value.String
}
case scauserfollows.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
suf.Status = uint8(value.Int64)
}
default:
suf.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaUserFollows.
// This includes values selected through modifiers, order, etc.
func (suf *ScaUserFollows) Value(name string) (ent.Value, error) {
return suf.selectValues.Get(name)
}
// Update returns a builder for updating this ScaUserFollows.
// Note that you need to call ScaUserFollows.Unwrap() before calling this method if this ScaUserFollows
// was returned from a transaction, and the transaction was committed or rolled back.
func (suf *ScaUserFollows) Update() *ScaUserFollowsUpdateOne {
return NewScaUserFollowsClient(suf.config).UpdateOne(suf)
}
// Unwrap unwraps the ScaUserFollows entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (suf *ScaUserFollows) Unwrap() *ScaUserFollows {
_tx, ok := suf.config.driver.(*txDriver)
if !ok {
panic("ent: ScaUserFollows is not a transactional entity")
}
suf.config.driver = _tx.drv
return suf
}
// String implements the fmt.Stringer.
func (suf *ScaUserFollows) String() string {
var builder strings.Builder
builder.WriteString("ScaUserFollows(")
builder.WriteString(fmt.Sprintf("id=%v, ", suf.ID))
builder.WriteString("follower_id=")
builder.WriteString(suf.FollowerID)
builder.WriteString(", ")
builder.WriteString("followee_id=")
builder.WriteString(suf.FolloweeID)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", suf.Status))
builder.WriteByte(')')
return builder.String()
}
// ScaUserFollowsSlice is a parsable slice of ScaUserFollows.
type ScaUserFollowsSlice []*ScaUserFollows

View File

@@ -1,68 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scauserfollows
import (
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scauserfollows type in the database.
Label = "sca_user_follows"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldFollowerID holds the string denoting the follower_id field in the database.
FieldFollowerID = "follower_id"
// FieldFolloweeID holds the string denoting the followee_id field in the database.
FieldFolloweeID = "followee_id"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// Table holds the table name of the scauserfollows in the database.
Table = "sca_user_follows"
)
// Columns holds all SQL columns for scauserfollows fields.
var Columns = []string{
FieldID,
FieldFollowerID,
FieldFolloweeID,
FieldStatus,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus uint8
)
// OrderOption defines the ordering options for the ScaUserFollows queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByFollowerID orders the results by the follower_id field.
func ByFollowerID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFollowerID, opts...).ToFunc()
}
// ByFolloweeID orders the results by the followee_id field.
func ByFolloweeID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFolloweeID, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

View File

@@ -1,254 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scauserfollows
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLTE(FieldID, id))
}
// FollowerID applies equality check predicate on the "follower_id" field. It's identical to FollowerIDEQ.
func FollowerID(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldFollowerID, v))
}
// FolloweeID applies equality check predicate on the "followee_id" field. It's identical to FolloweeIDEQ.
func FolloweeID(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldFolloweeID, v))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldStatus, v))
}
// FollowerIDEQ applies the EQ predicate on the "follower_id" field.
func FollowerIDEQ(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldFollowerID, v))
}
// FollowerIDNEQ applies the NEQ predicate on the "follower_id" field.
func FollowerIDNEQ(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNEQ(FieldFollowerID, v))
}
// FollowerIDIn applies the In predicate on the "follower_id" field.
func FollowerIDIn(vs ...string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldIn(FieldFollowerID, vs...))
}
// FollowerIDNotIn applies the NotIn predicate on the "follower_id" field.
func FollowerIDNotIn(vs ...string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNotIn(FieldFollowerID, vs...))
}
// FollowerIDGT applies the GT predicate on the "follower_id" field.
func FollowerIDGT(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGT(FieldFollowerID, v))
}
// FollowerIDGTE applies the GTE predicate on the "follower_id" field.
func FollowerIDGTE(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGTE(FieldFollowerID, v))
}
// FollowerIDLT applies the LT predicate on the "follower_id" field.
func FollowerIDLT(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLT(FieldFollowerID, v))
}
// FollowerIDLTE applies the LTE predicate on the "follower_id" field.
func FollowerIDLTE(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLTE(FieldFollowerID, v))
}
// FollowerIDContains applies the Contains predicate on the "follower_id" field.
func FollowerIDContains(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldContains(FieldFollowerID, v))
}
// FollowerIDHasPrefix applies the HasPrefix predicate on the "follower_id" field.
func FollowerIDHasPrefix(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldHasPrefix(FieldFollowerID, v))
}
// FollowerIDHasSuffix applies the HasSuffix predicate on the "follower_id" field.
func FollowerIDHasSuffix(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldHasSuffix(FieldFollowerID, v))
}
// FollowerIDEqualFold applies the EqualFold predicate on the "follower_id" field.
func FollowerIDEqualFold(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEqualFold(FieldFollowerID, v))
}
// FollowerIDContainsFold applies the ContainsFold predicate on the "follower_id" field.
func FollowerIDContainsFold(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldContainsFold(FieldFollowerID, v))
}
// FolloweeIDEQ applies the EQ predicate on the "followee_id" field.
func FolloweeIDEQ(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldFolloweeID, v))
}
// FolloweeIDNEQ applies the NEQ predicate on the "followee_id" field.
func FolloweeIDNEQ(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNEQ(FieldFolloweeID, v))
}
// FolloweeIDIn applies the In predicate on the "followee_id" field.
func FolloweeIDIn(vs ...string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldIn(FieldFolloweeID, vs...))
}
// FolloweeIDNotIn applies the NotIn predicate on the "followee_id" field.
func FolloweeIDNotIn(vs ...string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNotIn(FieldFolloweeID, vs...))
}
// FolloweeIDGT applies the GT predicate on the "followee_id" field.
func FolloweeIDGT(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGT(FieldFolloweeID, v))
}
// FolloweeIDGTE applies the GTE predicate on the "followee_id" field.
func FolloweeIDGTE(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGTE(FieldFolloweeID, v))
}
// FolloweeIDLT applies the LT predicate on the "followee_id" field.
func FolloweeIDLT(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLT(FieldFolloweeID, v))
}
// FolloweeIDLTE applies the LTE predicate on the "followee_id" field.
func FolloweeIDLTE(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLTE(FieldFolloweeID, v))
}
// FolloweeIDContains applies the Contains predicate on the "followee_id" field.
func FolloweeIDContains(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldContains(FieldFolloweeID, v))
}
// FolloweeIDHasPrefix applies the HasPrefix predicate on the "followee_id" field.
func FolloweeIDHasPrefix(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldHasPrefix(FieldFolloweeID, v))
}
// FolloweeIDHasSuffix applies the HasSuffix predicate on the "followee_id" field.
func FolloweeIDHasSuffix(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldHasSuffix(FieldFolloweeID, v))
}
// FolloweeIDEqualFold applies the EqualFold predicate on the "followee_id" field.
func FolloweeIDEqualFold(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEqualFold(FieldFolloweeID, v))
}
// FolloweeIDContainsFold applies the ContainsFold predicate on the "followee_id" field.
func FolloweeIDContainsFold(v string) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldContainsFold(FieldFolloweeID, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldNotIn(FieldStatus, vs...))
}
// StatusGT applies the GT predicate on the "status" field.
func StatusGT(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGT(FieldStatus, v))
}
// StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldGTE(FieldStatus, v))
}
// StatusLT applies the LT predicate on the "status" field.
func StatusLT(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLT(FieldStatus, v))
}
// StatusLTE applies the LTE predicate on the "status" field.
func StatusLTE(v uint8) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.FieldLTE(FieldStatus, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaUserFollows) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaUserFollows) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaUserFollows) predicate.ScaUserFollows {
return predicate.ScaUserFollows(sql.NotPredicates(p))
}

View File

@@ -1,227 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserFollowsCreate is the builder for creating a ScaUserFollows entity.
type ScaUserFollowsCreate struct {
config
mutation *ScaUserFollowsMutation
hooks []Hook
}
// SetFollowerID sets the "follower_id" field.
func (sufc *ScaUserFollowsCreate) SetFollowerID(s string) *ScaUserFollowsCreate {
sufc.mutation.SetFollowerID(s)
return sufc
}
// SetFolloweeID sets the "followee_id" field.
func (sufc *ScaUserFollowsCreate) SetFolloweeID(s string) *ScaUserFollowsCreate {
sufc.mutation.SetFolloweeID(s)
return sufc
}
// SetStatus sets the "status" field.
func (sufc *ScaUserFollowsCreate) SetStatus(u uint8) *ScaUserFollowsCreate {
sufc.mutation.SetStatus(u)
return sufc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sufc *ScaUserFollowsCreate) SetNillableStatus(u *uint8) *ScaUserFollowsCreate {
if u != nil {
sufc.SetStatus(*u)
}
return sufc
}
// Mutation returns the ScaUserFollowsMutation object of the builder.
func (sufc *ScaUserFollowsCreate) Mutation() *ScaUserFollowsMutation {
return sufc.mutation
}
// Save creates the ScaUserFollows in the database.
func (sufc *ScaUserFollowsCreate) Save(ctx context.Context) (*ScaUserFollows, error) {
sufc.defaults()
return withHooks(ctx, sufc.sqlSave, sufc.mutation, sufc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sufc *ScaUserFollowsCreate) SaveX(ctx context.Context) *ScaUserFollows {
v, err := sufc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sufc *ScaUserFollowsCreate) Exec(ctx context.Context) error {
_, err := sufc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sufc *ScaUserFollowsCreate) ExecX(ctx context.Context) {
if err := sufc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sufc *ScaUserFollowsCreate) defaults() {
if _, ok := sufc.mutation.Status(); !ok {
v := scauserfollows.DefaultStatus
sufc.mutation.SetStatus(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sufc *ScaUserFollowsCreate) check() error {
if _, ok := sufc.mutation.FollowerID(); !ok {
return &ValidationError{Name: "follower_id", err: errors.New(`ent: missing required field "ScaUserFollows.follower_id"`)}
}
if _, ok := sufc.mutation.FolloweeID(); !ok {
return &ValidationError{Name: "followee_id", err: errors.New(`ent: missing required field "ScaUserFollows.followee_id"`)}
}
if _, ok := sufc.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "ScaUserFollows.status"`)}
}
return nil
}
func (sufc *ScaUserFollowsCreate) sqlSave(ctx context.Context) (*ScaUserFollows, error) {
if err := sufc.check(); err != nil {
return nil, err
}
_node, _spec := sufc.createSpec()
if err := sqlgraph.CreateNode(ctx, sufc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
sufc.mutation.id = &_node.ID
sufc.mutation.done = true
return _node, nil
}
func (sufc *ScaUserFollowsCreate) createSpec() (*ScaUserFollows, *sqlgraph.CreateSpec) {
var (
_node = &ScaUserFollows{config: sufc.config}
_spec = sqlgraph.NewCreateSpec(scauserfollows.Table, sqlgraph.NewFieldSpec(scauserfollows.FieldID, field.TypeInt))
)
if value, ok := sufc.mutation.FollowerID(); ok {
_spec.SetField(scauserfollows.FieldFollowerID, field.TypeString, value)
_node.FollowerID = value
}
if value, ok := sufc.mutation.FolloweeID(); ok {
_spec.SetField(scauserfollows.FieldFolloweeID, field.TypeString, value)
_node.FolloweeID = value
}
if value, ok := sufc.mutation.Status(); ok {
_spec.SetField(scauserfollows.FieldStatus, field.TypeUint8, value)
_node.Status = value
}
return _node, _spec
}
// ScaUserFollowsCreateBulk is the builder for creating many ScaUserFollows entities in bulk.
type ScaUserFollowsCreateBulk struct {
config
err error
builders []*ScaUserFollowsCreate
}
// Save creates the ScaUserFollows entities in the database.
func (sufcb *ScaUserFollowsCreateBulk) Save(ctx context.Context) ([]*ScaUserFollows, error) {
if sufcb.err != nil {
return nil, sufcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sufcb.builders))
nodes := make([]*ScaUserFollows, len(sufcb.builders))
mutators := make([]Mutator, len(sufcb.builders))
for i := range sufcb.builders {
func(i int, root context.Context) {
builder := sufcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaUserFollowsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sufcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sufcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sufcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sufcb *ScaUserFollowsCreateBulk) SaveX(ctx context.Context) []*ScaUserFollows {
v, err := sufcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sufcb *ScaUserFollowsCreateBulk) Exec(ctx context.Context) error {
_, err := sufcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sufcb *ScaUserFollowsCreateBulk) ExecX(ctx context.Context) {
if err := sufcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserFollowsDelete is the builder for deleting a ScaUserFollows entity.
type ScaUserFollowsDelete struct {
config
hooks []Hook
mutation *ScaUserFollowsMutation
}
// Where appends a list predicates to the ScaUserFollowsDelete builder.
func (sufd *ScaUserFollowsDelete) Where(ps ...predicate.ScaUserFollows) *ScaUserFollowsDelete {
sufd.mutation.Where(ps...)
return sufd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (sufd *ScaUserFollowsDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, sufd.sqlExec, sufd.mutation, sufd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (sufd *ScaUserFollowsDelete) ExecX(ctx context.Context) int {
n, err := sufd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (sufd *ScaUserFollowsDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scauserfollows.Table, sqlgraph.NewFieldSpec(scauserfollows.FieldID, field.TypeInt))
if ps := sufd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, sufd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
sufd.mutation.done = true
return affected, err
}
// ScaUserFollowsDeleteOne is the builder for deleting a single ScaUserFollows entity.
type ScaUserFollowsDeleteOne struct {
sufd *ScaUserFollowsDelete
}
// Where appends a list predicates to the ScaUserFollowsDelete builder.
func (sufdo *ScaUserFollowsDeleteOne) Where(ps ...predicate.ScaUserFollows) *ScaUserFollowsDeleteOne {
sufdo.sufd.mutation.Where(ps...)
return sufdo
}
// Exec executes the deletion query.
func (sufdo *ScaUserFollowsDeleteOne) Exec(ctx context.Context) error {
n, err := sufdo.sufd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scauserfollows.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sufdo *ScaUserFollowsDeleteOne) ExecX(ctx context.Context) {
if err := sufdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserFollowsQuery is the builder for querying ScaUserFollows entities.
type ScaUserFollowsQuery struct {
config
ctx *QueryContext
order []scauserfollows.OrderOption
inters []Interceptor
predicates []predicate.ScaUserFollows
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaUserFollowsQuery builder.
func (sufq *ScaUserFollowsQuery) Where(ps ...predicate.ScaUserFollows) *ScaUserFollowsQuery {
sufq.predicates = append(sufq.predicates, ps...)
return sufq
}
// Limit the number of records to be returned by this query.
func (sufq *ScaUserFollowsQuery) Limit(limit int) *ScaUserFollowsQuery {
sufq.ctx.Limit = &limit
return sufq
}
// Offset to start from.
func (sufq *ScaUserFollowsQuery) Offset(offset int) *ScaUserFollowsQuery {
sufq.ctx.Offset = &offset
return sufq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sufq *ScaUserFollowsQuery) Unique(unique bool) *ScaUserFollowsQuery {
sufq.ctx.Unique = &unique
return sufq
}
// Order specifies how the records should be ordered.
func (sufq *ScaUserFollowsQuery) Order(o ...scauserfollows.OrderOption) *ScaUserFollowsQuery {
sufq.order = append(sufq.order, o...)
return sufq
}
// First returns the first ScaUserFollows entity from the query.
// Returns a *NotFoundError when no ScaUserFollows was found.
func (sufq *ScaUserFollowsQuery) First(ctx context.Context) (*ScaUserFollows, error) {
nodes, err := sufq.Limit(1).All(setContextOp(ctx, sufq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scauserfollows.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) FirstX(ctx context.Context) *ScaUserFollows {
node, err := sufq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaUserFollows ID from the query.
// Returns a *NotFoundError when no ScaUserFollows ID was found.
func (sufq *ScaUserFollowsQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = sufq.Limit(1).IDs(setContextOp(ctx, sufq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scauserfollows.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) FirstIDX(ctx context.Context) int {
id, err := sufq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaUserFollows entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaUserFollows entity is found.
// Returns a *NotFoundError when no ScaUserFollows entities are found.
func (sufq *ScaUserFollowsQuery) Only(ctx context.Context) (*ScaUserFollows, error) {
nodes, err := sufq.Limit(2).All(setContextOp(ctx, sufq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scauserfollows.Label}
default:
return nil, &NotSingularError{scauserfollows.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) OnlyX(ctx context.Context) *ScaUserFollows {
node, err := sufq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaUserFollows ID in the query.
// Returns a *NotSingularError when more than one ScaUserFollows ID is found.
// Returns a *NotFoundError when no entities are found.
func (sufq *ScaUserFollowsQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = sufq.Limit(2).IDs(setContextOp(ctx, sufq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scauserfollows.Label}
default:
err = &NotSingularError{scauserfollows.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) OnlyIDX(ctx context.Context) int {
id, err := sufq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaUserFollowsSlice.
func (sufq *ScaUserFollowsQuery) All(ctx context.Context) ([]*ScaUserFollows, error) {
ctx = setContextOp(ctx, sufq.ctx, ent.OpQueryAll)
if err := sufq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaUserFollows, *ScaUserFollowsQuery]()
return withInterceptors[[]*ScaUserFollows](ctx, sufq, qr, sufq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) AllX(ctx context.Context) []*ScaUserFollows {
nodes, err := sufq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaUserFollows IDs.
func (sufq *ScaUserFollowsQuery) IDs(ctx context.Context) (ids []int, err error) {
if sufq.ctx.Unique == nil && sufq.path != nil {
sufq.Unique(true)
}
ctx = setContextOp(ctx, sufq.ctx, ent.OpQueryIDs)
if err = sufq.Select(scauserfollows.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) IDsX(ctx context.Context) []int {
ids, err := sufq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sufq *ScaUserFollowsQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sufq.ctx, ent.OpQueryCount)
if err := sufq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sufq, querierCount[*ScaUserFollowsQuery](), sufq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) CountX(ctx context.Context) int {
count, err := sufq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sufq *ScaUserFollowsQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sufq.ctx, ent.OpQueryExist)
switch _, err := sufq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sufq *ScaUserFollowsQuery) ExistX(ctx context.Context) bool {
exist, err := sufq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaUserFollowsQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sufq *ScaUserFollowsQuery) Clone() *ScaUserFollowsQuery {
if sufq == nil {
return nil
}
return &ScaUserFollowsQuery{
config: sufq.config,
ctx: sufq.ctx.Clone(),
order: append([]scauserfollows.OrderOption{}, sufq.order...),
inters: append([]Interceptor{}, sufq.inters...),
predicates: append([]predicate.ScaUserFollows{}, sufq.predicates...),
// clone intermediate query.
sql: sufq.sql.Clone(),
path: sufq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// FollowerID string `json:"follower_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaUserFollows.Query().
// GroupBy(scauserfollows.FieldFollowerID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sufq *ScaUserFollowsQuery) GroupBy(field string, fields ...string) *ScaUserFollowsGroupBy {
sufq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaUserFollowsGroupBy{build: sufq}
grbuild.flds = &sufq.ctx.Fields
grbuild.label = scauserfollows.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// FollowerID string `json:"follower_id,omitempty"`
// }
//
// client.ScaUserFollows.Query().
// Select(scauserfollows.FieldFollowerID).
// Scan(ctx, &v)
func (sufq *ScaUserFollowsQuery) Select(fields ...string) *ScaUserFollowsSelect {
sufq.ctx.Fields = append(sufq.ctx.Fields, fields...)
sbuild := &ScaUserFollowsSelect{ScaUserFollowsQuery: sufq}
sbuild.label = scauserfollows.Label
sbuild.flds, sbuild.scan = &sufq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaUserFollowsSelect configured with the given aggregations.
func (sufq *ScaUserFollowsQuery) Aggregate(fns ...AggregateFunc) *ScaUserFollowsSelect {
return sufq.Select().Aggregate(fns...)
}
func (sufq *ScaUserFollowsQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sufq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sufq); err != nil {
return err
}
}
}
for _, f := range sufq.ctx.Fields {
if !scauserfollows.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sufq.path != nil {
prev, err := sufq.path(ctx)
if err != nil {
return err
}
sufq.sql = prev
}
return nil
}
func (sufq *ScaUserFollowsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaUserFollows, error) {
var (
nodes = []*ScaUserFollows{}
_spec = sufq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaUserFollows).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaUserFollows{config: sufq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sufq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (sufq *ScaUserFollowsQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sufq.querySpec()
_spec.Node.Columns = sufq.ctx.Fields
if len(sufq.ctx.Fields) > 0 {
_spec.Unique = sufq.ctx.Unique != nil && *sufq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sufq.driver, _spec)
}
func (sufq *ScaUserFollowsQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scauserfollows.Table, scauserfollows.Columns, sqlgraph.NewFieldSpec(scauserfollows.FieldID, field.TypeInt))
_spec.From = sufq.sql
if unique := sufq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sufq.path != nil {
_spec.Unique = true
}
if fields := sufq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scauserfollows.FieldID)
for i := range fields {
if fields[i] != scauserfollows.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sufq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sufq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sufq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sufq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sufq *ScaUserFollowsQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sufq.driver.Dialect())
t1 := builder.Table(scauserfollows.Table)
columns := sufq.ctx.Fields
if len(columns) == 0 {
columns = scauserfollows.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sufq.sql != nil {
selector = sufq.sql
selector.Select(selector.Columns(columns...)...)
}
if sufq.ctx.Unique != nil && *sufq.ctx.Unique {
selector.Distinct()
}
for _, p := range sufq.predicates {
p(selector)
}
for _, p := range sufq.order {
p(selector)
}
if offset := sufq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sufq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaUserFollowsGroupBy is the group-by builder for ScaUserFollows entities.
type ScaUserFollowsGroupBy struct {
selector
build *ScaUserFollowsQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sufgb *ScaUserFollowsGroupBy) Aggregate(fns ...AggregateFunc) *ScaUserFollowsGroupBy {
sufgb.fns = append(sufgb.fns, fns...)
return sufgb
}
// Scan applies the selector query and scans the result into the given value.
func (sufgb *ScaUserFollowsGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sufgb.build.ctx, ent.OpQueryGroupBy)
if err := sufgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaUserFollowsQuery, *ScaUserFollowsGroupBy](ctx, sufgb.build, sufgb, sufgb.build.inters, v)
}
func (sufgb *ScaUserFollowsGroupBy) sqlScan(ctx context.Context, root *ScaUserFollowsQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sufgb.fns))
for _, fn := range sufgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sufgb.flds)+len(sufgb.fns))
for _, f := range *sufgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sufgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sufgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaUserFollowsSelect is the builder for selecting fields of ScaUserFollows entities.
type ScaUserFollowsSelect struct {
*ScaUserFollowsQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sufs *ScaUserFollowsSelect) Aggregate(fns ...AggregateFunc) *ScaUserFollowsSelect {
sufs.fns = append(sufs.fns, fns...)
return sufs
}
// Scan applies the selector query and scans the result into the given value.
func (sufs *ScaUserFollowsSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sufs.ctx, ent.OpQuerySelect)
if err := sufs.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaUserFollowsQuery, *ScaUserFollowsSelect](ctx, sufs.ScaUserFollowsQuery, sufs, sufs.inters, v)
}
func (sufs *ScaUserFollowsSelect) sqlScan(ctx context.Context, root *ScaUserFollowsQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sufs.fns))
for _, fn := range sufs.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sufs.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sufs.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,297 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserfollows"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserFollowsUpdate is the builder for updating ScaUserFollows entities.
type ScaUserFollowsUpdate struct {
config
hooks []Hook
mutation *ScaUserFollowsMutation
}
// Where appends a list predicates to the ScaUserFollowsUpdate builder.
func (sufu *ScaUserFollowsUpdate) Where(ps ...predicate.ScaUserFollows) *ScaUserFollowsUpdate {
sufu.mutation.Where(ps...)
return sufu
}
// SetFollowerID sets the "follower_id" field.
func (sufu *ScaUserFollowsUpdate) SetFollowerID(s string) *ScaUserFollowsUpdate {
sufu.mutation.SetFollowerID(s)
return sufu
}
// SetNillableFollowerID sets the "follower_id" field if the given value is not nil.
func (sufu *ScaUserFollowsUpdate) SetNillableFollowerID(s *string) *ScaUserFollowsUpdate {
if s != nil {
sufu.SetFollowerID(*s)
}
return sufu
}
// SetFolloweeID sets the "followee_id" field.
func (sufu *ScaUserFollowsUpdate) SetFolloweeID(s string) *ScaUserFollowsUpdate {
sufu.mutation.SetFolloweeID(s)
return sufu
}
// SetNillableFolloweeID sets the "followee_id" field if the given value is not nil.
func (sufu *ScaUserFollowsUpdate) SetNillableFolloweeID(s *string) *ScaUserFollowsUpdate {
if s != nil {
sufu.SetFolloweeID(*s)
}
return sufu
}
// SetStatus sets the "status" field.
func (sufu *ScaUserFollowsUpdate) SetStatus(u uint8) *ScaUserFollowsUpdate {
sufu.mutation.ResetStatus()
sufu.mutation.SetStatus(u)
return sufu
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sufu *ScaUserFollowsUpdate) SetNillableStatus(u *uint8) *ScaUserFollowsUpdate {
if u != nil {
sufu.SetStatus(*u)
}
return sufu
}
// AddStatus adds u to the "status" field.
func (sufu *ScaUserFollowsUpdate) AddStatus(u int8) *ScaUserFollowsUpdate {
sufu.mutation.AddStatus(u)
return sufu
}
// Mutation returns the ScaUserFollowsMutation object of the builder.
func (sufu *ScaUserFollowsUpdate) Mutation() *ScaUserFollowsMutation {
return sufu.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (sufu *ScaUserFollowsUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, sufu.sqlSave, sufu.mutation, sufu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sufu *ScaUserFollowsUpdate) SaveX(ctx context.Context) int {
affected, err := sufu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (sufu *ScaUserFollowsUpdate) Exec(ctx context.Context) error {
_, err := sufu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sufu *ScaUserFollowsUpdate) ExecX(ctx context.Context) {
if err := sufu.Exec(ctx); err != nil {
panic(err)
}
}
func (sufu *ScaUserFollowsUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(scauserfollows.Table, scauserfollows.Columns, sqlgraph.NewFieldSpec(scauserfollows.FieldID, field.TypeInt))
if ps := sufu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sufu.mutation.FollowerID(); ok {
_spec.SetField(scauserfollows.FieldFollowerID, field.TypeString, value)
}
if value, ok := sufu.mutation.FolloweeID(); ok {
_spec.SetField(scauserfollows.FieldFolloweeID, field.TypeString, value)
}
if value, ok := sufu.mutation.Status(); ok {
_spec.SetField(scauserfollows.FieldStatus, field.TypeUint8, value)
}
if value, ok := sufu.mutation.AddedStatus(); ok {
_spec.AddField(scauserfollows.FieldStatus, field.TypeUint8, value)
}
if n, err = sqlgraph.UpdateNodes(ctx, sufu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scauserfollows.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
sufu.mutation.done = true
return n, nil
}
// ScaUserFollowsUpdateOne is the builder for updating a single ScaUserFollows entity.
type ScaUserFollowsUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaUserFollowsMutation
}
// SetFollowerID sets the "follower_id" field.
func (sufuo *ScaUserFollowsUpdateOne) SetFollowerID(s string) *ScaUserFollowsUpdateOne {
sufuo.mutation.SetFollowerID(s)
return sufuo
}
// SetNillableFollowerID sets the "follower_id" field if the given value is not nil.
func (sufuo *ScaUserFollowsUpdateOne) SetNillableFollowerID(s *string) *ScaUserFollowsUpdateOne {
if s != nil {
sufuo.SetFollowerID(*s)
}
return sufuo
}
// SetFolloweeID sets the "followee_id" field.
func (sufuo *ScaUserFollowsUpdateOne) SetFolloweeID(s string) *ScaUserFollowsUpdateOne {
sufuo.mutation.SetFolloweeID(s)
return sufuo
}
// SetNillableFolloweeID sets the "followee_id" field if the given value is not nil.
func (sufuo *ScaUserFollowsUpdateOne) SetNillableFolloweeID(s *string) *ScaUserFollowsUpdateOne {
if s != nil {
sufuo.SetFolloweeID(*s)
}
return sufuo
}
// SetStatus sets the "status" field.
func (sufuo *ScaUserFollowsUpdateOne) SetStatus(u uint8) *ScaUserFollowsUpdateOne {
sufuo.mutation.ResetStatus()
sufuo.mutation.SetStatus(u)
return sufuo
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sufuo *ScaUserFollowsUpdateOne) SetNillableStatus(u *uint8) *ScaUserFollowsUpdateOne {
if u != nil {
sufuo.SetStatus(*u)
}
return sufuo
}
// AddStatus adds u to the "status" field.
func (sufuo *ScaUserFollowsUpdateOne) AddStatus(u int8) *ScaUserFollowsUpdateOne {
sufuo.mutation.AddStatus(u)
return sufuo
}
// Mutation returns the ScaUserFollowsMutation object of the builder.
func (sufuo *ScaUserFollowsUpdateOne) Mutation() *ScaUserFollowsMutation {
return sufuo.mutation
}
// Where appends a list predicates to the ScaUserFollowsUpdate builder.
func (sufuo *ScaUserFollowsUpdateOne) Where(ps ...predicate.ScaUserFollows) *ScaUserFollowsUpdateOne {
sufuo.mutation.Where(ps...)
return sufuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (sufuo *ScaUserFollowsUpdateOne) Select(field string, fields ...string) *ScaUserFollowsUpdateOne {
sufuo.fields = append([]string{field}, fields...)
return sufuo
}
// Save executes the query and returns the updated ScaUserFollows entity.
func (sufuo *ScaUserFollowsUpdateOne) Save(ctx context.Context) (*ScaUserFollows, error) {
return withHooks(ctx, sufuo.sqlSave, sufuo.mutation, sufuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sufuo *ScaUserFollowsUpdateOne) SaveX(ctx context.Context) *ScaUserFollows {
node, err := sufuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (sufuo *ScaUserFollowsUpdateOne) Exec(ctx context.Context) error {
_, err := sufuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sufuo *ScaUserFollowsUpdateOne) ExecX(ctx context.Context) {
if err := sufuo.Exec(ctx); err != nil {
panic(err)
}
}
func (sufuo *ScaUserFollowsUpdateOne) sqlSave(ctx context.Context) (_node *ScaUserFollows, err error) {
_spec := sqlgraph.NewUpdateSpec(scauserfollows.Table, scauserfollows.Columns, sqlgraph.NewFieldSpec(scauserfollows.FieldID, field.TypeInt))
id, ok := sufuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaUserFollows.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := sufuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scauserfollows.FieldID)
for _, f := range fields {
if !scauserfollows.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scauserfollows.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := sufuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sufuo.mutation.FollowerID(); ok {
_spec.SetField(scauserfollows.FieldFollowerID, field.TypeString, value)
}
if value, ok := sufuo.mutation.FolloweeID(); ok {
_spec.SetField(scauserfollows.FieldFolloweeID, field.TypeString, value)
}
if value, ok := sufuo.mutation.Status(); ok {
_spec.SetField(scauserfollows.FieldStatus, field.TypeUint8, value)
}
if value, ok := sufuo.mutation.AddedStatus(); ok {
_spec.AddField(scauserfollows.FieldStatus, field.TypeUint8, value)
}
_node = &ScaUserFollows{config: sufuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, sufuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scauserfollows.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
sufuo.mutation.done = true
return _node, nil
}

View File

@@ -1,170 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserlevel"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户等级表
type ScaUserLevel struct {
config `json:"-"`
// ID of the ent.
// 主键
ID int64 `json:"id,omitempty"`
// 用户Id
UserID string `json:"user_id,omitempty"`
// 等级类型
LevelType uint8 `json:"level_type,omitempty"`
// 等级
Level int `json:"level,omitempty"`
// 等级名称
LevelName string `json:"level_name,omitempty"`
// 开始经验值
ExpStart int64 `json:"exp_start,omitempty"`
// 结束经验值
ExpEnd int64 `json:"exp_end,omitempty"`
// 等级描述
LevelDescription string `json:"level_description,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaUserLevel) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scauserlevel.FieldID, scauserlevel.FieldLevelType, scauserlevel.FieldLevel, scauserlevel.FieldExpStart, scauserlevel.FieldExpEnd:
values[i] = new(sql.NullInt64)
case scauserlevel.FieldUserID, scauserlevel.FieldLevelName, scauserlevel.FieldLevelDescription:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaUserLevel fields.
func (sul *ScaUserLevel) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scauserlevel.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
sul.ID = int64(value.Int64)
case scauserlevel.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
sul.UserID = value.String
}
case scauserlevel.FieldLevelType:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field level_type", values[i])
} else if value.Valid {
sul.LevelType = uint8(value.Int64)
}
case scauserlevel.FieldLevel:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field level", values[i])
} else if value.Valid {
sul.Level = int(value.Int64)
}
case scauserlevel.FieldLevelName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field level_name", values[i])
} else if value.Valid {
sul.LevelName = value.String
}
case scauserlevel.FieldExpStart:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field exp_start", values[i])
} else if value.Valid {
sul.ExpStart = value.Int64
}
case scauserlevel.FieldExpEnd:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field exp_end", values[i])
} else if value.Valid {
sul.ExpEnd = value.Int64
}
case scauserlevel.FieldLevelDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field level_description", values[i])
} else if value.Valid {
sul.LevelDescription = value.String
}
default:
sul.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaUserLevel.
// This includes values selected through modifiers, order, etc.
func (sul *ScaUserLevel) Value(name string) (ent.Value, error) {
return sul.selectValues.Get(name)
}
// Update returns a builder for updating this ScaUserLevel.
// Note that you need to call ScaUserLevel.Unwrap() before calling this method if this ScaUserLevel
// was returned from a transaction, and the transaction was committed or rolled back.
func (sul *ScaUserLevel) Update() *ScaUserLevelUpdateOne {
return NewScaUserLevelClient(sul.config).UpdateOne(sul)
}
// Unwrap unwraps the ScaUserLevel entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sul *ScaUserLevel) Unwrap() *ScaUserLevel {
_tx, ok := sul.config.driver.(*txDriver)
if !ok {
panic("ent: ScaUserLevel is not a transactional entity")
}
sul.config.driver = _tx.drv
return sul
}
// String implements the fmt.Stringer.
func (sul *ScaUserLevel) String() string {
var builder strings.Builder
builder.WriteString("ScaUserLevel(")
builder.WriteString(fmt.Sprintf("id=%v, ", sul.ID))
builder.WriteString("user_id=")
builder.WriteString(sul.UserID)
builder.WriteString(", ")
builder.WriteString("level_type=")
builder.WriteString(fmt.Sprintf("%v", sul.LevelType))
builder.WriteString(", ")
builder.WriteString("level=")
builder.WriteString(fmt.Sprintf("%v", sul.Level))
builder.WriteString(", ")
builder.WriteString("level_name=")
builder.WriteString(sul.LevelName)
builder.WriteString(", ")
builder.WriteString("exp_start=")
builder.WriteString(fmt.Sprintf("%v", sul.ExpStart))
builder.WriteString(", ")
builder.WriteString("exp_end=")
builder.WriteString(fmt.Sprintf("%v", sul.ExpEnd))
builder.WriteString(", ")
builder.WriteString("level_description=")
builder.WriteString(sul.LevelDescription)
builder.WriteByte(')')
return builder.String()
}
// ScaUserLevels is a parsable slice of ScaUserLevel.
type ScaUserLevels []*ScaUserLevel

View File

@@ -1,100 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scauserlevel
import (
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the scauserlevel type in the database.
Label = "sca_user_level"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldLevelType holds the string denoting the level_type field in the database.
FieldLevelType = "level_type"
// FieldLevel holds the string denoting the level field in the database.
FieldLevel = "level"
// FieldLevelName holds the string denoting the level_name field in the database.
FieldLevelName = "level_name"
// FieldExpStart holds the string denoting the exp_start field in the database.
FieldExpStart = "exp_start"
// FieldExpEnd holds the string denoting the exp_end field in the database.
FieldExpEnd = "exp_end"
// FieldLevelDescription holds the string denoting the level_description field in the database.
FieldLevelDescription = "level_description"
// Table holds the table name of the scauserlevel in the database.
Table = "sca_user_level"
)
// Columns holds all SQL columns for scauserlevel fields.
var Columns = []string{
FieldID,
FieldUserID,
FieldLevelType,
FieldLevel,
FieldLevelName,
FieldExpStart,
FieldExpEnd,
FieldLevelDescription,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// LevelNameValidator is a validator for the "level_name" field. It is called by the builders before save.
LevelNameValidator func(string) error
)
// OrderOption defines the ordering options for the ScaUserLevel queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByLevelType orders the results by the level_type field.
func ByLevelType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLevelType, opts...).ToFunc()
}
// ByLevel orders the results by the level field.
func ByLevel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLevel, opts...).ToFunc()
}
// ByLevelName orders the results by the level_name field.
func ByLevelName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLevelName, opts...).ToFunc()
}
// ByExpStart orders the results by the exp_start field.
func ByExpStart(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExpStart, opts...).ToFunc()
}
// ByExpEnd orders the results by the exp_end field.
func ByExpEnd(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExpEnd, opts...).ToFunc()
}
// ByLevelDescription orders the results by the level_description field.
func ByLevelDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLevelDescription, opts...).ToFunc()
}

View File

@@ -1,469 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scauserlevel
import (
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldID, id))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldUserID, v))
}
// LevelType applies equality check predicate on the "level_type" field. It's identical to LevelTypeEQ.
func LevelType(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevelType, v))
}
// Level applies equality check predicate on the "level" field. It's identical to LevelEQ.
func Level(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevel, v))
}
// LevelName applies equality check predicate on the "level_name" field. It's identical to LevelNameEQ.
func LevelName(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevelName, v))
}
// ExpStart applies equality check predicate on the "exp_start" field. It's identical to ExpStartEQ.
func ExpStart(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldExpStart, v))
}
// ExpEnd applies equality check predicate on the "exp_end" field. It's identical to ExpEndEQ.
func ExpEnd(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldExpEnd, v))
}
// LevelDescription applies equality check predicate on the "level_description" field. It's identical to LevelDescriptionEQ.
func LevelDescription(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevelDescription, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldUserID, v))
}
// UserIDContains applies the Contains predicate on the "user_id" field.
func UserIDContains(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldContains(FieldUserID, v))
}
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
func UserIDHasPrefix(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldHasPrefix(FieldUserID, v))
}
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
func UserIDHasSuffix(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldHasSuffix(FieldUserID, v))
}
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
func UserIDEqualFold(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEqualFold(FieldUserID, v))
}
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
func UserIDContainsFold(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldContainsFold(FieldUserID, v))
}
// LevelTypeEQ applies the EQ predicate on the "level_type" field.
func LevelTypeEQ(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevelType, v))
}
// LevelTypeNEQ applies the NEQ predicate on the "level_type" field.
func LevelTypeNEQ(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldLevelType, v))
}
// LevelTypeIn applies the In predicate on the "level_type" field.
func LevelTypeIn(vs ...uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldLevelType, vs...))
}
// LevelTypeNotIn applies the NotIn predicate on the "level_type" field.
func LevelTypeNotIn(vs ...uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldLevelType, vs...))
}
// LevelTypeGT applies the GT predicate on the "level_type" field.
func LevelTypeGT(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldLevelType, v))
}
// LevelTypeGTE applies the GTE predicate on the "level_type" field.
func LevelTypeGTE(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldLevelType, v))
}
// LevelTypeLT applies the LT predicate on the "level_type" field.
func LevelTypeLT(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldLevelType, v))
}
// LevelTypeLTE applies the LTE predicate on the "level_type" field.
func LevelTypeLTE(v uint8) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldLevelType, v))
}
// LevelEQ applies the EQ predicate on the "level" field.
func LevelEQ(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevel, v))
}
// LevelNEQ applies the NEQ predicate on the "level" field.
func LevelNEQ(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldLevel, v))
}
// LevelIn applies the In predicate on the "level" field.
func LevelIn(vs ...int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldLevel, vs...))
}
// LevelNotIn applies the NotIn predicate on the "level" field.
func LevelNotIn(vs ...int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldLevel, vs...))
}
// LevelGT applies the GT predicate on the "level" field.
func LevelGT(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldLevel, v))
}
// LevelGTE applies the GTE predicate on the "level" field.
func LevelGTE(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldLevel, v))
}
// LevelLT applies the LT predicate on the "level" field.
func LevelLT(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldLevel, v))
}
// LevelLTE applies the LTE predicate on the "level" field.
func LevelLTE(v int) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldLevel, v))
}
// LevelNameEQ applies the EQ predicate on the "level_name" field.
func LevelNameEQ(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevelName, v))
}
// LevelNameNEQ applies the NEQ predicate on the "level_name" field.
func LevelNameNEQ(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldLevelName, v))
}
// LevelNameIn applies the In predicate on the "level_name" field.
func LevelNameIn(vs ...string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldLevelName, vs...))
}
// LevelNameNotIn applies the NotIn predicate on the "level_name" field.
func LevelNameNotIn(vs ...string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldLevelName, vs...))
}
// LevelNameGT applies the GT predicate on the "level_name" field.
func LevelNameGT(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldLevelName, v))
}
// LevelNameGTE applies the GTE predicate on the "level_name" field.
func LevelNameGTE(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldLevelName, v))
}
// LevelNameLT applies the LT predicate on the "level_name" field.
func LevelNameLT(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldLevelName, v))
}
// LevelNameLTE applies the LTE predicate on the "level_name" field.
func LevelNameLTE(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldLevelName, v))
}
// LevelNameContains applies the Contains predicate on the "level_name" field.
func LevelNameContains(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldContains(FieldLevelName, v))
}
// LevelNameHasPrefix applies the HasPrefix predicate on the "level_name" field.
func LevelNameHasPrefix(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldHasPrefix(FieldLevelName, v))
}
// LevelNameHasSuffix applies the HasSuffix predicate on the "level_name" field.
func LevelNameHasSuffix(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldHasSuffix(FieldLevelName, v))
}
// LevelNameEqualFold applies the EqualFold predicate on the "level_name" field.
func LevelNameEqualFold(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEqualFold(FieldLevelName, v))
}
// LevelNameContainsFold applies the ContainsFold predicate on the "level_name" field.
func LevelNameContainsFold(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldContainsFold(FieldLevelName, v))
}
// ExpStartEQ applies the EQ predicate on the "exp_start" field.
func ExpStartEQ(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldExpStart, v))
}
// ExpStartNEQ applies the NEQ predicate on the "exp_start" field.
func ExpStartNEQ(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldExpStart, v))
}
// ExpStartIn applies the In predicate on the "exp_start" field.
func ExpStartIn(vs ...int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldExpStart, vs...))
}
// ExpStartNotIn applies the NotIn predicate on the "exp_start" field.
func ExpStartNotIn(vs ...int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldExpStart, vs...))
}
// ExpStartGT applies the GT predicate on the "exp_start" field.
func ExpStartGT(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldExpStart, v))
}
// ExpStartGTE applies the GTE predicate on the "exp_start" field.
func ExpStartGTE(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldExpStart, v))
}
// ExpStartLT applies the LT predicate on the "exp_start" field.
func ExpStartLT(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldExpStart, v))
}
// ExpStartLTE applies the LTE predicate on the "exp_start" field.
func ExpStartLTE(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldExpStart, v))
}
// ExpEndEQ applies the EQ predicate on the "exp_end" field.
func ExpEndEQ(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldExpEnd, v))
}
// ExpEndNEQ applies the NEQ predicate on the "exp_end" field.
func ExpEndNEQ(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldExpEnd, v))
}
// ExpEndIn applies the In predicate on the "exp_end" field.
func ExpEndIn(vs ...int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldExpEnd, vs...))
}
// ExpEndNotIn applies the NotIn predicate on the "exp_end" field.
func ExpEndNotIn(vs ...int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldExpEnd, vs...))
}
// ExpEndGT applies the GT predicate on the "exp_end" field.
func ExpEndGT(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldExpEnd, v))
}
// ExpEndGTE applies the GTE predicate on the "exp_end" field.
func ExpEndGTE(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldExpEnd, v))
}
// ExpEndLT applies the LT predicate on the "exp_end" field.
func ExpEndLT(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldExpEnd, v))
}
// ExpEndLTE applies the LTE predicate on the "exp_end" field.
func ExpEndLTE(v int64) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldExpEnd, v))
}
// LevelDescriptionEQ applies the EQ predicate on the "level_description" field.
func LevelDescriptionEQ(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEQ(FieldLevelDescription, v))
}
// LevelDescriptionNEQ applies the NEQ predicate on the "level_description" field.
func LevelDescriptionNEQ(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNEQ(FieldLevelDescription, v))
}
// LevelDescriptionIn applies the In predicate on the "level_description" field.
func LevelDescriptionIn(vs ...string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIn(FieldLevelDescription, vs...))
}
// LevelDescriptionNotIn applies the NotIn predicate on the "level_description" field.
func LevelDescriptionNotIn(vs ...string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotIn(FieldLevelDescription, vs...))
}
// LevelDescriptionGT applies the GT predicate on the "level_description" field.
func LevelDescriptionGT(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGT(FieldLevelDescription, v))
}
// LevelDescriptionGTE applies the GTE predicate on the "level_description" field.
func LevelDescriptionGTE(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldGTE(FieldLevelDescription, v))
}
// LevelDescriptionLT applies the LT predicate on the "level_description" field.
func LevelDescriptionLT(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLT(FieldLevelDescription, v))
}
// LevelDescriptionLTE applies the LTE predicate on the "level_description" field.
func LevelDescriptionLTE(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldLTE(FieldLevelDescription, v))
}
// LevelDescriptionContains applies the Contains predicate on the "level_description" field.
func LevelDescriptionContains(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldContains(FieldLevelDescription, v))
}
// LevelDescriptionHasPrefix applies the HasPrefix predicate on the "level_description" field.
func LevelDescriptionHasPrefix(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldHasPrefix(FieldLevelDescription, v))
}
// LevelDescriptionHasSuffix applies the HasSuffix predicate on the "level_description" field.
func LevelDescriptionHasSuffix(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldHasSuffix(FieldLevelDescription, v))
}
// LevelDescriptionIsNil applies the IsNil predicate on the "level_description" field.
func LevelDescriptionIsNil() predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldIsNull(FieldLevelDescription))
}
// LevelDescriptionNotNil applies the NotNil predicate on the "level_description" field.
func LevelDescriptionNotNil() predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldNotNull(FieldLevelDescription))
}
// LevelDescriptionEqualFold applies the EqualFold predicate on the "level_description" field.
func LevelDescriptionEqualFold(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldEqualFold(FieldLevelDescription, v))
}
// LevelDescriptionContainsFold applies the ContainsFold predicate on the "level_description" field.
func LevelDescriptionContainsFold(v string) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.FieldContainsFold(FieldLevelDescription, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ScaUserLevel) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaUserLevel) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaUserLevel) predicate.ScaUserLevel {
return predicate.ScaUserLevel(sql.NotPredicates(p))
}

View File

@@ -1,283 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserlevel"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserLevelCreate is the builder for creating a ScaUserLevel entity.
type ScaUserLevelCreate struct {
config
mutation *ScaUserLevelMutation
hooks []Hook
}
// SetUserID sets the "user_id" field.
func (sulc *ScaUserLevelCreate) SetUserID(s string) *ScaUserLevelCreate {
sulc.mutation.SetUserID(s)
return sulc
}
// SetLevelType sets the "level_type" field.
func (sulc *ScaUserLevelCreate) SetLevelType(u uint8) *ScaUserLevelCreate {
sulc.mutation.SetLevelType(u)
return sulc
}
// SetLevel sets the "level" field.
func (sulc *ScaUserLevelCreate) SetLevel(i int) *ScaUserLevelCreate {
sulc.mutation.SetLevel(i)
return sulc
}
// SetLevelName sets the "level_name" field.
func (sulc *ScaUserLevelCreate) SetLevelName(s string) *ScaUserLevelCreate {
sulc.mutation.SetLevelName(s)
return sulc
}
// SetExpStart sets the "exp_start" field.
func (sulc *ScaUserLevelCreate) SetExpStart(i int64) *ScaUserLevelCreate {
sulc.mutation.SetExpStart(i)
return sulc
}
// SetExpEnd sets the "exp_end" field.
func (sulc *ScaUserLevelCreate) SetExpEnd(i int64) *ScaUserLevelCreate {
sulc.mutation.SetExpEnd(i)
return sulc
}
// SetLevelDescription sets the "level_description" field.
func (sulc *ScaUserLevelCreate) SetLevelDescription(s string) *ScaUserLevelCreate {
sulc.mutation.SetLevelDescription(s)
return sulc
}
// SetNillableLevelDescription sets the "level_description" field if the given value is not nil.
func (sulc *ScaUserLevelCreate) SetNillableLevelDescription(s *string) *ScaUserLevelCreate {
if s != nil {
sulc.SetLevelDescription(*s)
}
return sulc
}
// SetID sets the "id" field.
func (sulc *ScaUserLevelCreate) SetID(i int64) *ScaUserLevelCreate {
sulc.mutation.SetID(i)
return sulc
}
// Mutation returns the ScaUserLevelMutation object of the builder.
func (sulc *ScaUserLevelCreate) Mutation() *ScaUserLevelMutation {
return sulc.mutation
}
// Save creates the ScaUserLevel in the database.
func (sulc *ScaUserLevelCreate) Save(ctx context.Context) (*ScaUserLevel, error) {
return withHooks(ctx, sulc.sqlSave, sulc.mutation, sulc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sulc *ScaUserLevelCreate) SaveX(ctx context.Context) *ScaUserLevel {
v, err := sulc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sulc *ScaUserLevelCreate) Exec(ctx context.Context) error {
_, err := sulc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sulc *ScaUserLevelCreate) ExecX(ctx context.Context) {
if err := sulc.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (sulc *ScaUserLevelCreate) check() error {
if _, ok := sulc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaUserLevel.user_id"`)}
}
if _, ok := sulc.mutation.LevelType(); !ok {
return &ValidationError{Name: "level_type", err: errors.New(`ent: missing required field "ScaUserLevel.level_type"`)}
}
if _, ok := sulc.mutation.Level(); !ok {
return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "ScaUserLevel.level"`)}
}
if _, ok := sulc.mutation.LevelName(); !ok {
return &ValidationError{Name: "level_name", err: errors.New(`ent: missing required field "ScaUserLevel.level_name"`)}
}
if v, ok := sulc.mutation.LevelName(); ok {
if err := scauserlevel.LevelNameValidator(v); err != nil {
return &ValidationError{Name: "level_name", err: fmt.Errorf(`ent: validator failed for field "ScaUserLevel.level_name": %w`, err)}
}
}
if _, ok := sulc.mutation.ExpStart(); !ok {
return &ValidationError{Name: "exp_start", err: errors.New(`ent: missing required field "ScaUserLevel.exp_start"`)}
}
if _, ok := sulc.mutation.ExpEnd(); !ok {
return &ValidationError{Name: "exp_end", err: errors.New(`ent: missing required field "ScaUserLevel.exp_end"`)}
}
return nil
}
func (sulc *ScaUserLevelCreate) sqlSave(ctx context.Context) (*ScaUserLevel, error) {
if err := sulc.check(); err != nil {
return nil, err
}
_node, _spec := sulc.createSpec()
if err := sqlgraph.CreateNode(ctx, sulc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sulc.mutation.id = &_node.ID
sulc.mutation.done = true
return _node, nil
}
func (sulc *ScaUserLevelCreate) createSpec() (*ScaUserLevel, *sqlgraph.CreateSpec) {
var (
_node = &ScaUserLevel{config: sulc.config}
_spec = sqlgraph.NewCreateSpec(scauserlevel.Table, sqlgraph.NewFieldSpec(scauserlevel.FieldID, field.TypeInt64))
)
if id, ok := sulc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sulc.mutation.UserID(); ok {
_spec.SetField(scauserlevel.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := sulc.mutation.LevelType(); ok {
_spec.SetField(scauserlevel.FieldLevelType, field.TypeUint8, value)
_node.LevelType = value
}
if value, ok := sulc.mutation.Level(); ok {
_spec.SetField(scauserlevel.FieldLevel, field.TypeInt, value)
_node.Level = value
}
if value, ok := sulc.mutation.LevelName(); ok {
_spec.SetField(scauserlevel.FieldLevelName, field.TypeString, value)
_node.LevelName = value
}
if value, ok := sulc.mutation.ExpStart(); ok {
_spec.SetField(scauserlevel.FieldExpStart, field.TypeInt64, value)
_node.ExpStart = value
}
if value, ok := sulc.mutation.ExpEnd(); ok {
_spec.SetField(scauserlevel.FieldExpEnd, field.TypeInt64, value)
_node.ExpEnd = value
}
if value, ok := sulc.mutation.LevelDescription(); ok {
_spec.SetField(scauserlevel.FieldLevelDescription, field.TypeString, value)
_node.LevelDescription = value
}
return _node, _spec
}
// ScaUserLevelCreateBulk is the builder for creating many ScaUserLevel entities in bulk.
type ScaUserLevelCreateBulk struct {
config
err error
builders []*ScaUserLevelCreate
}
// Save creates the ScaUserLevel entities in the database.
func (sulcb *ScaUserLevelCreateBulk) Save(ctx context.Context) ([]*ScaUserLevel, error) {
if sulcb.err != nil {
return nil, sulcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sulcb.builders))
nodes := make([]*ScaUserLevel, len(sulcb.builders))
mutators := make([]Mutator, len(sulcb.builders))
for i := range sulcb.builders {
func(i int, root context.Context) {
builder := sulcb.builders[i]
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaUserLevelMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sulcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sulcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sulcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sulcb *ScaUserLevelCreateBulk) SaveX(ctx context.Context) []*ScaUserLevel {
v, err := sulcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sulcb *ScaUserLevelCreateBulk) Exec(ctx context.Context) error {
_, err := sulcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sulcb *ScaUserLevelCreateBulk) ExecX(ctx context.Context) {
if err := sulcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserlevel"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserLevelDelete is the builder for deleting a ScaUserLevel entity.
type ScaUserLevelDelete struct {
config
hooks []Hook
mutation *ScaUserLevelMutation
}
// Where appends a list predicates to the ScaUserLevelDelete builder.
func (suld *ScaUserLevelDelete) Where(ps ...predicate.ScaUserLevel) *ScaUserLevelDelete {
suld.mutation.Where(ps...)
return suld
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (suld *ScaUserLevelDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, suld.sqlExec, suld.mutation, suld.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (suld *ScaUserLevelDelete) ExecX(ctx context.Context) int {
n, err := suld.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (suld *ScaUserLevelDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scauserlevel.Table, sqlgraph.NewFieldSpec(scauserlevel.FieldID, field.TypeInt64))
if ps := suld.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, suld.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
suld.mutation.done = true
return affected, err
}
// ScaUserLevelDeleteOne is the builder for deleting a single ScaUserLevel entity.
type ScaUserLevelDeleteOne struct {
suld *ScaUserLevelDelete
}
// Where appends a list predicates to the ScaUserLevelDelete builder.
func (suldo *ScaUserLevelDeleteOne) Where(ps ...predicate.ScaUserLevel) *ScaUserLevelDeleteOne {
suldo.suld.mutation.Where(ps...)
return suldo
}
// Exec executes the deletion query.
func (suldo *ScaUserLevelDeleteOne) Exec(ctx context.Context) error {
n, err := suldo.suld.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scauserlevel.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (suldo *ScaUserLevelDeleteOne) ExecX(ctx context.Context) {
if err := suldo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scauserlevel"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaUserLevelQuery is the builder for querying ScaUserLevel entities.
type ScaUserLevelQuery struct {
config
ctx *QueryContext
order []scauserlevel.OrderOption
inters []Interceptor
predicates []predicate.ScaUserLevel
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaUserLevelQuery builder.
func (sulq *ScaUserLevelQuery) Where(ps ...predicate.ScaUserLevel) *ScaUserLevelQuery {
sulq.predicates = append(sulq.predicates, ps...)
return sulq
}
// Limit the number of records to be returned by this query.
func (sulq *ScaUserLevelQuery) Limit(limit int) *ScaUserLevelQuery {
sulq.ctx.Limit = &limit
return sulq
}
// Offset to start from.
func (sulq *ScaUserLevelQuery) Offset(offset int) *ScaUserLevelQuery {
sulq.ctx.Offset = &offset
return sulq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sulq *ScaUserLevelQuery) Unique(unique bool) *ScaUserLevelQuery {
sulq.ctx.Unique = &unique
return sulq
}
// Order specifies how the records should be ordered.
func (sulq *ScaUserLevelQuery) Order(o ...scauserlevel.OrderOption) *ScaUserLevelQuery {
sulq.order = append(sulq.order, o...)
return sulq
}
// First returns the first ScaUserLevel entity from the query.
// Returns a *NotFoundError when no ScaUserLevel was found.
func (sulq *ScaUserLevelQuery) First(ctx context.Context) (*ScaUserLevel, error) {
nodes, err := sulq.Limit(1).All(setContextOp(ctx, sulq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scauserlevel.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) FirstX(ctx context.Context) *ScaUserLevel {
node, err := sulq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaUserLevel ID from the query.
// Returns a *NotFoundError when no ScaUserLevel ID was found.
func (sulq *ScaUserLevelQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sulq.Limit(1).IDs(setContextOp(ctx, sulq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scauserlevel.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) FirstIDX(ctx context.Context) int64 {
id, err := sulq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaUserLevel entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaUserLevel entity is found.
// Returns a *NotFoundError when no ScaUserLevel entities are found.
func (sulq *ScaUserLevelQuery) Only(ctx context.Context) (*ScaUserLevel, error) {
nodes, err := sulq.Limit(2).All(setContextOp(ctx, sulq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scauserlevel.Label}
default:
return nil, &NotSingularError{scauserlevel.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) OnlyX(ctx context.Context) *ScaUserLevel {
node, err := sulq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaUserLevel ID in the query.
// Returns a *NotSingularError when more than one ScaUserLevel ID is found.
// Returns a *NotFoundError when no entities are found.
func (sulq *ScaUserLevelQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sulq.Limit(2).IDs(setContextOp(ctx, sulq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scauserlevel.Label}
default:
err = &NotSingularError{scauserlevel.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sulq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaUserLevels.
func (sulq *ScaUserLevelQuery) All(ctx context.Context) ([]*ScaUserLevel, error) {
ctx = setContextOp(ctx, sulq.ctx, ent.OpQueryAll)
if err := sulq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaUserLevel, *ScaUserLevelQuery]()
return withInterceptors[[]*ScaUserLevel](ctx, sulq, qr, sulq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) AllX(ctx context.Context) []*ScaUserLevel {
nodes, err := sulq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaUserLevel IDs.
func (sulq *ScaUserLevelQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sulq.ctx.Unique == nil && sulq.path != nil {
sulq.Unique(true)
}
ctx = setContextOp(ctx, sulq.ctx, ent.OpQueryIDs)
if err = sulq.Select(scauserlevel.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) IDsX(ctx context.Context) []int64 {
ids, err := sulq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sulq *ScaUserLevelQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sulq.ctx, ent.OpQueryCount)
if err := sulq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sulq, querierCount[*ScaUserLevelQuery](), sulq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) CountX(ctx context.Context) int {
count, err := sulq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sulq *ScaUserLevelQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sulq.ctx, ent.OpQueryExist)
switch _, err := sulq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sulq *ScaUserLevelQuery) ExistX(ctx context.Context) bool {
exist, err := sulq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaUserLevelQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sulq *ScaUserLevelQuery) Clone() *ScaUserLevelQuery {
if sulq == nil {
return nil
}
return &ScaUserLevelQuery{
config: sulq.config,
ctx: sulq.ctx.Clone(),
order: append([]scauserlevel.OrderOption{}, sulq.order...),
inters: append([]Interceptor{}, sulq.inters...),
predicates: append([]predicate.ScaUserLevel{}, sulq.predicates...),
// clone intermediate query.
sql: sulq.sql.Clone(),
path: sulq.path,
}
}
// 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.
//
// Example:
//
// var v []struct {
// UserID string `json:"user_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaUserLevel.Query().
// GroupBy(scauserlevel.FieldUserID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sulq *ScaUserLevelQuery) GroupBy(field string, fields ...string) *ScaUserLevelGroupBy {
sulq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaUserLevelGroupBy{build: sulq}
grbuild.flds = &sulq.ctx.Fields
grbuild.label = scauserlevel.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// UserID string `json:"user_id,omitempty"`
// }
//
// client.ScaUserLevel.Query().
// Select(scauserlevel.FieldUserID).
// Scan(ctx, &v)
func (sulq *ScaUserLevelQuery) Select(fields ...string) *ScaUserLevelSelect {
sulq.ctx.Fields = append(sulq.ctx.Fields, fields...)
sbuild := &ScaUserLevelSelect{ScaUserLevelQuery: sulq}
sbuild.label = scauserlevel.Label
sbuild.flds, sbuild.scan = &sulq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaUserLevelSelect configured with the given aggregations.
func (sulq *ScaUserLevelQuery) Aggregate(fns ...AggregateFunc) *ScaUserLevelSelect {
return sulq.Select().Aggregate(fns...)
}
func (sulq *ScaUserLevelQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sulq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sulq); err != nil {
return err
}
}
}
for _, f := range sulq.ctx.Fields {
if !scauserlevel.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sulq.path != nil {
prev, err := sulq.path(ctx)
if err != nil {
return err
}
sulq.sql = prev
}
return nil
}
func (sulq *ScaUserLevelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaUserLevel, error) {
var (
nodes = []*ScaUserLevel{}
_spec = sulq.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaUserLevel).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ScaUserLevel{config: sulq.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sulq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (sulq *ScaUserLevelQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sulq.querySpec()
_spec.Node.Columns = sulq.ctx.Fields
if len(sulq.ctx.Fields) > 0 {
_spec.Unique = sulq.ctx.Unique != nil && *sulq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sulq.driver, _spec)
}
func (sulq *ScaUserLevelQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scauserlevel.Table, scauserlevel.Columns, sqlgraph.NewFieldSpec(scauserlevel.FieldID, field.TypeInt64))
_spec.From = sulq.sql
if unique := sulq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sulq.path != nil {
_spec.Unique = true
}
if fields := sulq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scauserlevel.FieldID)
for i := range fields {
if fields[i] != scauserlevel.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sulq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sulq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sulq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sulq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sulq *ScaUserLevelQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sulq.driver.Dialect())
t1 := builder.Table(scauserlevel.Table)
columns := sulq.ctx.Fields
if len(columns) == 0 {
columns = scauserlevel.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sulq.sql != nil {
selector = sulq.sql
selector.Select(selector.Columns(columns...)...)
}
if sulq.ctx.Unique != nil && *sulq.ctx.Unique {
selector.Distinct()
}
for _, p := range sulq.predicates {
p(selector)
}
for _, p := range sulq.order {
p(selector)
}
if offset := sulq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sulq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaUserLevelGroupBy is the group-by builder for ScaUserLevel entities.
type ScaUserLevelGroupBy struct {
selector
build *ScaUserLevelQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sulgb *ScaUserLevelGroupBy) Aggregate(fns ...AggregateFunc) *ScaUserLevelGroupBy {
sulgb.fns = append(sulgb.fns, fns...)
return sulgb
}
// Scan applies the selector query and scans the result into the given value.
func (sulgb *ScaUserLevelGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sulgb.build.ctx, ent.OpQueryGroupBy)
if err := sulgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaUserLevelQuery, *ScaUserLevelGroupBy](ctx, sulgb.build, sulgb, sulgb.build.inters, v)
}
func (sulgb *ScaUserLevelGroupBy) sqlScan(ctx context.Context, root *ScaUserLevelQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sulgb.fns))
for _, fn := range sulgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sulgb.flds)+len(sulgb.fns))
for _, f := range *sulgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sulgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sulgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaUserLevelSelect is the builder for selecting fields of ScaUserLevel entities.
type ScaUserLevelSelect struct {
*ScaUserLevelQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (suls *ScaUserLevelSelect) Aggregate(fns ...AggregateFunc) *ScaUserLevelSelect {
suls.fns = append(suls.fns, fns...)
return suls
}
// Scan applies the selector query and scans the result into the given value.
func (suls *ScaUserLevelSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, suls.ctx, ent.OpQuerySelect)
if err := suls.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaUserLevelQuery, *ScaUserLevelSelect](ctx, suls.ScaUserLevelQuery, suls, suls.inters, v)
}
func (suls *ScaUserLevelSelect) sqlScan(ctx context.Context, root *ScaUserLevelQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(suls.fns))
for _, fn := range suls.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*suls.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := suls.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

Some files were not shown because too many files have changed in this diff Show More