🚧 developing...
This commit is contained in:
@@ -771,6 +771,32 @@ type (
|
||||
CoordinateListResponse {
|
||||
Records []CoordinateMeta `json:"records"`
|
||||
}
|
||||
RecoverImageRequest {
|
||||
ID int64 `json:"id"`
|
||||
Provider string `json:"provider"`
|
||||
Bucket string `json:"bucket"`
|
||||
}
|
||||
ImageBedUploadResponse {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
ImageBedUploadListRequest {
|
||||
Provider string `json:"provider"`
|
||||
Bucket string `json:"bucket"`
|
||||
}
|
||||
ImageBedUploadMeta {
|
||||
ID int64 `json:"id"`
|
||||
FileName string `json:"file_name"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
FileType string `json:"file_type"`
|
||||
Path string `json:"path"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
Width int64 `json:"width"`
|
||||
Height int64 `json:"height"`
|
||||
}
|
||||
ImageBedUploadListResponse {
|
||||
Records []ImageBedUploadMeta `json:"records"`
|
||||
}
|
||||
)
|
||||
|
||||
// 文件上传
|
||||
@@ -921,6 +947,18 @@ service auth {
|
||||
// 获取图像经纬度列表
|
||||
@handler getCoordinateList
|
||||
post /coordinate/list returns (CoordinateListResponse)
|
||||
|
||||
// 恢复删除图片
|
||||
@handler recoverImage
|
||||
post /image/recover (RecoverImageRequest) returns (string)
|
||||
|
||||
// 图床上传图片
|
||||
@handler imageBedUpload
|
||||
post /image/bed/upload returns (ImageBedUploadResponse)
|
||||
|
||||
// 获取图床上传的图片列表
|
||||
@handler getImageBedUploadList
|
||||
post /image/bed/upload/list (ImageBedUploadListRequest) returns (ImageBedUploadListResponse)
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -1073,18 +1111,115 @@ service auth {
|
||||
|
||||
type (
|
||||
UserMeta {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Status int64 `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
UID string `json:"uid"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Gender string `json:"gender"`
|
||||
Introduce string `json:"introduce"`
|
||||
Blog string `json:"blog"`
|
||||
Location string `json:"location"`
|
||||
Company string `json:"company"`
|
||||
Status int64 `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpadatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
UserInfoListResponse {
|
||||
Records []UserMeta `json:"records"`
|
||||
}
|
||||
RoleMeta {
|
||||
ID int64 `json:"id"`
|
||||
RoleName string `json:"role_name"`
|
||||
RoleKey string `json:"role_key"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
RoleListResponse {
|
||||
Records []RoleMeta `json:"records"`
|
||||
}
|
||||
PermissionRuleMeta {
|
||||
ID int64 `json:"id"`
|
||||
Ptype string `json:"ptype"`
|
||||
V0 string `json:"v0"`
|
||||
V1 string `json:"v1"`
|
||||
V2 string `json:"v2"`
|
||||
V3 string `json:"v3"`
|
||||
V4 string `json:"v4"`
|
||||
V5 string `json:"v5"`
|
||||
}
|
||||
PermissionRuleListResponse {
|
||||
Records []PermissionRuleMeta `json:"records"`
|
||||
}
|
||||
UserLoginLogMeta {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
IP string `json:"ip"`
|
||||
Location string `json:"location"`
|
||||
Agent string `json:"agent"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
Browser string `json:"browser"`
|
||||
OperatingSystem string `json:"operating_system"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
Mobile string `json:"mobile"`
|
||||
Bot int64 `json:"bot"`
|
||||
Mozilla string `json:"mozilla"`
|
||||
Platform string `json:"platform"`
|
||||
EngineName string `json:"engine_name"`
|
||||
EngineVersion string `json:"engine_version"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
UserLoginLogListResponse {
|
||||
Records []UserLoginLogMeta `json:"records"`
|
||||
}
|
||||
UserThirdPartyLoginMeta {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
OpenID string `json:"open_id"`
|
||||
Source string `json:"source"`
|
||||
Status int64 `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
UserThirdPartyLoginListResponse {
|
||||
Records []UserThirdPartyLoginMeta `json:"records"`
|
||||
}
|
||||
AllStorageListResponse {
|
||||
Records []StorageConfigMeta `json:"records"`
|
||||
}
|
||||
CommentReplyMeta {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
TopicID int64 `json:"topic_id"`
|
||||
TopicType string `json:"topic_type"`
|
||||
Content string `json:"content"`
|
||||
CommentType string `json:"comment_type"`
|
||||
ReplyTo int64 `json:"reply_to"`
|
||||
ReplyID int64 `json:"reply_id"`
|
||||
ReplyUser string `json:"reply_user"`
|
||||
Author string `json:"author"`
|
||||
Likes int64 `json:"likes"`
|
||||
ReplyCount int64 `json:"reply_count"`
|
||||
ImagePath string `json:"image_path"`
|
||||
Browser string `json:"browser"`
|
||||
OperatingSystem string `json:"operating_system"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
CommentIP string `json:"comment_ip"`
|
||||
Loaction string `json:"loaction"`
|
||||
Agent string `json:"agent"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
AllCommentListResponse {
|
||||
Records []CommentReplyMeta `json:"records"`
|
||||
}
|
||||
)
|
||||
|
||||
// 系统服务
|
||||
@@ -1103,5 +1238,29 @@ service auth {
|
||||
// 获取用户列表
|
||||
@handler getUserList
|
||||
post /user/list returns (UserInfoListResponse)
|
||||
|
||||
// 获取所有角色列表
|
||||
@handler getAllRoleList
|
||||
post /role/list returns (RoleListResponse)
|
||||
|
||||
// 获取去权限规则表
|
||||
@handler getPermissionRuleList
|
||||
post /permission/rule/list returns (PermissionRuleListResponse)
|
||||
|
||||
// 获取用户登录日志列表
|
||||
@handler getUserLoginLogList
|
||||
post /user/login/log/list returns (UserLoginLogListResponse)
|
||||
|
||||
// 获取用户第三方登录列表
|
||||
@handler getUserThirdPartyLoginList
|
||||
post /user/third/party/login/list returns (UserThirdPartyLoginListResponse)
|
||||
|
||||
// 获取用户存储配置列表
|
||||
@handler getAllStorageList
|
||||
post /user/storage/config/list returns (AllStorageListResponse)
|
||||
|
||||
// 获取所有评论列表
|
||||
@handler getAllCommentList
|
||||
post /comment/list returns (AllCommentListResponse)
|
||||
}
|
||||
|
||||
|
@@ -381,6 +381,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/image/all/list",
|
||||
Handler: storage.QueryAllImageListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/image/bed/upload",
|
||||
Handler: storage.ImageBedUploadHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/image/bed/upload/list",
|
||||
Handler: storage.GetImageBedUploadListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/image/delete",
|
||||
@@ -411,6 +421,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/image/recent/list",
|
||||
Handler: storage.QueryRecentImageListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/image/recover",
|
||||
Handler: storage.RecoverImageHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/image/search",
|
||||
@@ -468,11 +483,41 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware, serverCtx.CasbinVerifyMiddleware, serverCtx.NonceMiddleware, serverCtx.AuthMiddleware},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/comment/list",
|
||||
Handler: system.GetAllCommentListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/permission/rule/list",
|
||||
Handler: system.GetPermissionRuleListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/role/list",
|
||||
Handler: system.GetAllRoleListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/user/list",
|
||||
Handler: system.GetUserListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/user/login/log/list",
|
||||
Handler: system.GetUserLoginLogListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/user/storage/config/list",
|
||||
Handler: system.GetAllStorageListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/user/third/party/login/list",
|
||||
Handler: system.GetUserThirdPartyLoginListHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
|
@@ -0,0 +1,29 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/storage"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetImageBedUploadListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ImageBedUploadListRequest
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := storage.NewGetImageBedUploadListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetImageBedUploadList(&req)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/storage"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func ImageBedUploadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := storage.NewImageBedUploadLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ImageBedUpload(r)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/storage"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func RecoverImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RecoverImageRequest
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := storage.NewRecoverImageLogic(r.Context(), svcCtx)
|
||||
resp, err := l.RecoverImage(&req)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/system"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetAllCommentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := system.NewGetAllCommentListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAllCommentList()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/system"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetAllRoleListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := system.NewGetAllRoleListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAllRoleList()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/system"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetAllStorageListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := system.NewGetAllStorageListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAllStorageList()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/system"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetPermissionRuleListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := system.NewGetPermissionRuleListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetPermissionRuleList()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/system"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetUserLoginLogListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := system.NewGetUserLoginLogListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetUserLoginLogList()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/system"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/common/xhttp"
|
||||
)
|
||||
|
||||
func GetUserThirdPartyLoginListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := system.NewGetUserThirdPartyLoginListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetUserThirdPartyLoginList()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
|
||||
"schisandra-album-cloud-microservices/common/constant"
|
||||
"schisandra-album-cloud-microservices/common/encrypt"
|
||||
"schisandra-album-cloud-microservices/common/storage/config"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetImageBedUploadListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetImageBedUploadListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImageBedUploadListLogic {
|
||||
return &GetImageBedUploadListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetImageBedUploadListLogic) GetImageBedUploadList(req *types.ImageBedUploadListRequest) (resp *types.ImageBedUploadListResponse, err error) {
|
||||
uid, ok := l.ctx.Value("user_id").(string)
|
||||
if !ok {
|
||||
return nil, errors.New("user_id not found")
|
||||
}
|
||||
storageImgBed := l.svcCtx.DB.ScaStorageImgBed
|
||||
imgBeds, err := storageImgBed.Where(
|
||||
storageImgBed.UserID.Eq(uid),
|
||||
storageImgBed.Provider.Eq(req.Provider),
|
||||
storageImgBed.Bucket.Eq(req.Bucket)).Find()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cacheKey := constant.UserOssConfigPrefix + uid + ":" + req.Provider
|
||||
ossConfig, err := l.getOssConfigFromCacheOrDb(cacheKey, uid, req.Provider)
|
||||
if err != nil {
|
||||
return nil, errors.New("get oss config failed")
|
||||
}
|
||||
//service, err := l.svcCtx.StorageManager.GetStorage(uid, ossConfig)
|
||||
//if err != nil {
|
||||
// return nil, errors.New("get storage failed")
|
||||
//}
|
||||
var records []types.ImageBedUploadMeta
|
||||
for _, imgBed := range imgBeds {
|
||||
|
||||
records = append(records, types.ImageBedUploadMeta{
|
||||
ID: imgBed.ID,
|
||||
FileName: imgBed.FileName,
|
||||
FileSize: imgBed.FileSize,
|
||||
FileType: imgBed.FileType,
|
||||
Path: ossConfig.Endpoint + "/" + ossConfig.BucketName + "/" + imgBed.Path,
|
||||
Thumbnail: ossConfig.Endpoint + "/" + ossConfig.BucketName + "/" + imgBed.ThumbPath,
|
||||
CreatedAt: imgBed.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
Width: int64(imgBed.Width),
|
||||
Height: int64(imgBed.Height),
|
||||
})
|
||||
}
|
||||
return &types.ImageBedUploadListResponse{
|
||||
Records: records,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 提取解密操作为函数
|
||||
func (l *GetImageBedUploadListLogic) decryptConfig(dbConfig *model.ScaStorageConfig) (*config.StorageConfig, error) {
|
||||
accessKey, err := encrypt.Decrypt(dbConfig.AccessKey, l.svcCtx.Config.Encrypt.Key)
|
||||
if err != nil {
|
||||
return nil, errors.New("decrypt access key failed")
|
||||
}
|
||||
secretKey, err := encrypt.Decrypt(dbConfig.SecretKey, l.svcCtx.Config.Encrypt.Key)
|
||||
if err != nil {
|
||||
return nil, errors.New("decrypt secret key failed")
|
||||
}
|
||||
return &config.StorageConfig{
|
||||
Provider: dbConfig.Provider,
|
||||
Endpoint: dbConfig.Endpoint,
|
||||
AccessKey: accessKey,
|
||||
SecretKey: secretKey,
|
||||
BucketName: dbConfig.Bucket,
|
||||
Region: dbConfig.Region,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 从缓存或数据库中获取 OSS 配置
|
||||
func (l *GetImageBedUploadListLogic) getOssConfigFromCacheOrDb(cacheKey, uid, provider string) (*config.StorageConfig, error) {
|
||||
result, err := l.svcCtx.RedisClient.Get(l.ctx, cacheKey).Result()
|
||||
if err != nil && !errors.Is(err, redis.Nil) {
|
||||
return nil, errors.New("get oss config failed")
|
||||
}
|
||||
|
||||
var ossConfig *config.StorageConfig
|
||||
if result != "" {
|
||||
var redisOssConfig model.ScaStorageConfig
|
||||
if err = json.Unmarshal([]byte(result), &redisOssConfig); err != nil {
|
||||
return nil, errors.New("unmarshal oss config failed")
|
||||
}
|
||||
return l.decryptConfig(&redisOssConfig)
|
||||
}
|
||||
|
||||
// 缓存未命中,从数据库中加载
|
||||
scaOssConfig := l.svcCtx.DB.ScaStorageConfig
|
||||
dbOssConfig, err := scaOssConfig.Where(scaOssConfig.UserID.Eq(uid), scaOssConfig.Provider.Eq(provider)).First()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 缓存数据库配置
|
||||
ossConfig, err = l.decryptConfig(dbOssConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
marshalData, err := json.Marshal(dbOssConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("marshal oss config failed")
|
||||
}
|
||||
err = l.svcCtx.RedisClient.Set(l.ctx, cacheKey, marshalData, 0).Err()
|
||||
if err != nil {
|
||||
return nil, errors.New("set oss config failed")
|
||||
}
|
||||
|
||||
return ossConfig, nil
|
||||
}
|
177
app/auth/api/internal/logic/storage/image_bed_upload_logic.go
Normal file
177
app/auth/api/internal/logic/storage/image_bed_upload_logic.go
Normal file
@@ -0,0 +1,177 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ccpwcn/kgo"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
|
||||
"schisandra-album-cloud-microservices/common/constant"
|
||||
"schisandra-album-cloud-microservices/common/encrypt"
|
||||
"schisandra-album-cloud-microservices/common/storage/config"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ImageBedUploadLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewImageBedUploadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ImageBedUploadLogic {
|
||||
return &ImageBedUploadLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ImageBedUploadLogic) ImageBedUpload(r *http.Request) (resp *types.ImageBedUploadResponse, err error) {
|
||||
uid, ok := l.ctx.Value("user_id").(string)
|
||||
if !ok {
|
||||
return nil, errors.New("user_id not found")
|
||||
}
|
||||
formValue := r.PostFormValue("data")
|
||||
var result types.ImageBedMeta
|
||||
if err := json.Unmarshal([]byte(formValue), &result); err != nil {
|
||||
return nil, errors.New("invalid result")
|
||||
}
|
||||
file, header, err := r.FormFile("file")
|
||||
if err != nil {
|
||||
return nil, errors.New("file not found")
|
||||
}
|
||||
defer file.Close()
|
||||
// 解析缩略图
|
||||
thumbFile, _, err := r.FormFile("thumbnail")
|
||||
if err != nil {
|
||||
return nil, errors.New("thumbnail not found")
|
||||
}
|
||||
defer thumbFile.Close()
|
||||
|
||||
// 上传文件到OSS
|
||||
|
||||
cacheKey := constant.UserOssConfigPrefix + uid + ":" + result.Provider
|
||||
ossConfig, err := l.getOssConfigFromCacheOrDb(cacheKey, uid, result.Provider)
|
||||
if err != nil {
|
||||
return nil, errors.New("get oss config failed")
|
||||
}
|
||||
service, err := l.svcCtx.StorageManager.GetStorage(uid, ossConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("get storage failed")
|
||||
}
|
||||
filePath := path.Join(
|
||||
constant.ImageBedSpace,
|
||||
constant.ImageSpace,
|
||||
uid,
|
||||
time.Now().Format("2006/01"), // 按年/月划分目录
|
||||
fmt.Sprintf("%s_%s%s", strings.TrimSuffix(header.Filename, filepath.Ext(header.Filename)), kgo.SimpleUuid(), filepath.Ext(header.Filename)),
|
||||
)
|
||||
_, err = service.UploadFileSimple(l.ctx, ossConfig.BucketName, filePath, file, map[string]string{
|
||||
"Content-Type": header.Header.Get("Content-Type")})
|
||||
// 上传缩略图到OSS
|
||||
if err != nil {
|
||||
return nil, errors.New("upload file failed")
|
||||
}
|
||||
thumbFilePath := path.Join(
|
||||
constant.ImageBedSpace,
|
||||
constant.ThumbnailSpace,
|
||||
uid,
|
||||
time.Now().Format("2006/01"), // 按年/月划分目录
|
||||
fmt.Sprintf("%s_%s%s", strings.TrimSuffix(header.Filename, filepath.Ext(header.Filename)), kgo.SimpleUuid(), filepath.Ext(header.Filename)),
|
||||
)
|
||||
_, err = service.UploadFileSimple(l.ctx, ossConfig.BucketName, thumbFilePath, thumbFile, map[string]string{
|
||||
"Content-Type": header.Header.Get("Content-Type")})
|
||||
if err != nil {
|
||||
return nil, errors.New("upload file failed")
|
||||
}
|
||||
|
||||
imgBed := model.ScaStorageImgBed{
|
||||
UserID: uid,
|
||||
Provider: result.Provider,
|
||||
Bucket: ossConfig.BucketName,
|
||||
Path: filePath,
|
||||
ThumbPath: thumbFilePath,
|
||||
FileSize: header.Size,
|
||||
FileType: header.Header.Get("Content-Type"),
|
||||
FileName: header.Filename,
|
||||
Width: float64(result.Width),
|
||||
Height: float64(result.Height),
|
||||
}
|
||||
err = l.svcCtx.DB.ScaStorageImgBed.Create(&imgBed)
|
||||
if err != nil {
|
||||
return nil, errors.New("create image bed failed")
|
||||
}
|
||||
|
||||
return &types.ImageBedUploadResponse{ID: imgBed.ID}, nil
|
||||
}
|
||||
|
||||
// 提取解密操作为函数
|
||||
func (l *ImageBedUploadLogic) decryptConfig(dbConfig *model.ScaStorageConfig) (*config.StorageConfig, error) {
|
||||
accessKey, err := encrypt.Decrypt(dbConfig.AccessKey, l.svcCtx.Config.Encrypt.Key)
|
||||
if err != nil {
|
||||
return nil, errors.New("decrypt access key failed")
|
||||
}
|
||||
secretKey, err := encrypt.Decrypt(dbConfig.SecretKey, l.svcCtx.Config.Encrypt.Key)
|
||||
if err != nil {
|
||||
return nil, errors.New("decrypt secret key failed")
|
||||
}
|
||||
return &config.StorageConfig{
|
||||
Provider: dbConfig.Provider,
|
||||
Endpoint: dbConfig.Endpoint,
|
||||
AccessKey: accessKey,
|
||||
SecretKey: secretKey,
|
||||
BucketName: dbConfig.Bucket,
|
||||
Region: dbConfig.Region,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 从缓存或数据库中获取 OSS 配置
|
||||
func (l *ImageBedUploadLogic) getOssConfigFromCacheOrDb(cacheKey, uid, provider string) (*config.StorageConfig, error) {
|
||||
result, err := l.svcCtx.RedisClient.Get(l.ctx, cacheKey).Result()
|
||||
if err != nil && !errors.Is(err, redis.Nil) {
|
||||
return nil, errors.New("get oss config failed")
|
||||
}
|
||||
|
||||
var ossConfig *config.StorageConfig
|
||||
if result != "" {
|
||||
var redisOssConfig model.ScaStorageConfig
|
||||
if err = json.Unmarshal([]byte(result), &redisOssConfig); err != nil {
|
||||
return nil, errors.New("unmarshal oss config failed")
|
||||
}
|
||||
return l.decryptConfig(&redisOssConfig)
|
||||
}
|
||||
|
||||
// 缓存未命中,从数据库中加载
|
||||
scaOssConfig := l.svcCtx.DB.ScaStorageConfig
|
||||
dbOssConfig, err := scaOssConfig.Where(scaOssConfig.UserID.Eq(uid), scaOssConfig.Provider.Eq(provider)).First()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 缓存数据库配置
|
||||
ossConfig, err = l.decryptConfig(dbOssConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
marshalData, err := json.Marshal(dbOssConfig)
|
||||
if err != nil {
|
||||
return nil, errors.New("marshal oss config failed")
|
||||
}
|
||||
err = l.svcCtx.RedisClient.Set(l.ctx, cacheKey, marshalData, 0).Err()
|
||||
if err != nil {
|
||||
return nil, errors.New("set oss config failed")
|
||||
}
|
||||
|
||||
return ossConfig, nil
|
||||
}
|
48
app/auth/api/internal/logic/storage/recover_image_logic.go
Normal file
48
app/auth/api/internal/logic/storage/recover_image_logic.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RecoverImageLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewRecoverImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RecoverImageLogic {
|
||||
return &RecoverImageLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *RecoverImageLogic) RecoverImage(req *types.RecoverImageRequest) (resp string, err error) {
|
||||
uid, ok := l.ctx.Value("user_id").(string)
|
||||
if !ok {
|
||||
return "", errors.New("user_id not found")
|
||||
}
|
||||
storageInfo := l.svcCtx.DB.ScaStorageInfo
|
||||
|
||||
info, err := storageInfo.Where(
|
||||
storageInfo.UserID.Eq(uid),
|
||||
storageInfo.ID.Eq(req.ID),
|
||||
storageInfo.Provider.Eq(req.Provider),
|
||||
storageInfo.Bucket.Eq(req.Bucket),
|
||||
).Update(storageInfo.DeletedAt, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if info.RowsAffected == 0 {
|
||||
return "", errors.New("image not found")
|
||||
}
|
||||
|
||||
return "success", nil
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAllCommentListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetAllCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAllCommentListLogic {
|
||||
return &GetAllCommentListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAllCommentListLogic) GetAllCommentList() (resp *types.AllCommentListResponse, err error) {
|
||||
commentReply := l.svcCtx.DB.ScaCommentReply
|
||||
var records []types.CommentReplyMeta
|
||||
err = commentReply.Scan(&records)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.AllCommentListResponse{
|
||||
Records: records,
|
||||
}, nil
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAllRoleListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetAllRoleListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAllRoleListLogic {
|
||||
return &GetAllRoleListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAllRoleListLogic) GetAllRoleList() (resp *types.RoleListResponse, err error) {
|
||||
authRole := l.svcCtx.DB.ScaAuthRole
|
||||
var roles []types.RoleMeta
|
||||
err = authRole.Scan(&roles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.RoleListResponse{Records: roles}, nil
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAllStorageListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetAllStorageListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAllStorageListLogic {
|
||||
return &GetAllStorageListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAllStorageListLogic) GetAllStorageList() (resp *types.AllStorageListResponse, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPermissionRuleListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetPermissionRuleListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPermissionRuleListLogic {
|
||||
return &GetPermissionRuleListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPermissionRuleListLogic) GetPermissionRuleList() (resp *types.PermissionRuleListResponse, err error) {
|
||||
|
||||
permissionRule := l.svcCtx.DB.ScaAuthPermissionRule
|
||||
var permissionRuleList []types.PermissionRuleMeta
|
||||
err = permissionRule.Scan(&permissionRuleList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.PermissionRuleListResponse{Records: permissionRuleList}, nil
|
||||
}
|
@@ -2,7 +2,6 @@ package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
@@ -24,7 +23,28 @@ func NewGetUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
|
||||
}
|
||||
|
||||
func (l *GetUserListLogic) GetUserList() (resp *types.UserInfoListResponse, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
authUser := l.svcCtx.DB.ScaAuthUser
|
||||
var userMetaList []types.UserMeta
|
||||
err = authUser.Select(
|
||||
authUser.ID,
|
||||
authUser.UID,
|
||||
authUser.Username,
|
||||
authUser.Nickname,
|
||||
authUser.Email,
|
||||
authUser.Phone,
|
||||
authUser.Gender,
|
||||
authUser.Avatar,
|
||||
authUser.Location,
|
||||
authUser.Company,
|
||||
authUser.Blog,
|
||||
authUser.Introduce,
|
||||
authUser.Status,
|
||||
authUser.CreatedAt,
|
||||
authUser.UpdatedAt,
|
||||
authUser.DeletedAt,
|
||||
).Scan(&userMetaList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.UserInfoListResponse{Records: userMetaList}, nil
|
||||
}
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetUserLoginLogListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetUserLoginLogListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserLoginLogListLogic {
|
||||
return &GetUserLoginLogListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetUserLoginLogListLogic) GetUserLoginLogList() (resp *types.UserLoginLogListResponse, err error) {
|
||||
userDevice := l.svcCtx.DB.ScaAuthUserDevice
|
||||
var userLoginLogs []types.UserLoginLogMeta
|
||||
err = userDevice.Scan(&userLoginLogs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UserLoginLogListResponse{Records: userLoginLogs}, nil
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetUserThirdPartyLoginListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetUserThirdPartyLoginListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserThirdPartyLoginListLogic {
|
||||
return &GetUserThirdPartyLoginListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetUserThirdPartyLoginListLogic) GetUserThirdPartyLoginList() (resp *types.UserThirdPartyLoginListResponse, err error) {
|
||||
|
||||
userSocial := l.svcCtx.DB.ScaAuthUserSocial
|
||||
var userSocialList []types.UserThirdPartyLoginMeta
|
||||
err = userSocial.Scan(&userSocialList)
|
||||
if err != nil {
|
||||
}
|
||||
return &types.UserThirdPartyLoginListResponse{Records: userSocialList}, nil
|
||||
}
|
@@ -116,3 +116,10 @@ type ZincFileInfo struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
}
|
||||
|
||||
type ImageBedMeta struct {
|
||||
Provider string `json:"provider"`
|
||||
Bucket string `json:"bucket"`
|
||||
Width int64 `json:"width"`
|
||||
Height int64 `json:"height"`
|
||||
}
|
||||
|
@@ -75,6 +75,10 @@ type AlbumRenameResponse struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type AllCommentListResponse struct {
|
||||
Records []CommentReplyMeta `json:"records"`
|
||||
}
|
||||
|
||||
type AllImageDetail struct {
|
||||
Date string `json:"date"`
|
||||
List []ImageMeta `json:"list"`
|
||||
@@ -91,6 +95,10 @@ type AllImageListResponse struct {
|
||||
Records []AllImageDetail `json:"records"`
|
||||
}
|
||||
|
||||
type AllStorageListResponse struct {
|
||||
Records []StorageConfigMeta `json:"records"`
|
||||
}
|
||||
|
||||
type BucketCapacityRequest struct {
|
||||
Provider string `json:"provider"`
|
||||
Bucket string `json:"bucket"`
|
||||
@@ -149,6 +157,31 @@ type CommentListRequest struct {
|
||||
IsHot bool `json:"is_hot,default=true,optional"`
|
||||
}
|
||||
|
||||
type CommentReplyMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
TopicID int64 `json:"topic_id"`
|
||||
TopicType string `json:"topic_type"`
|
||||
Content string `json:"content"`
|
||||
CommentType string `json:"comment_type"`
|
||||
ReplyTo int64 `json:"reply_to"`
|
||||
ReplyID int64 `json:"reply_id"`
|
||||
ReplyUser string `json:"reply_user"`
|
||||
Author string `json:"author"`
|
||||
Likes int64 `json:"likes"`
|
||||
ReplyCount int64 `json:"reply_count"`
|
||||
ImagePath string `json:"image_path"`
|
||||
Browser string `json:"browser"`
|
||||
OperatingSystem string `json:"operating_system"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
CommentIP string `json:"comment_ip"`
|
||||
Loaction string `json:"loaction"`
|
||||
Agent string `json:"agent"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type CommentRequest struct {
|
||||
Content string `json:"content"`
|
||||
Images string `json:"images,optional"`
|
||||
@@ -248,6 +281,31 @@ type HeatmapMeta struct {
|
||||
Count int64 `json:"count"`
|
||||
}
|
||||
|
||||
type ImageBedUploadListRequest struct {
|
||||
Provider string `json:"provider"`
|
||||
Bucket string `json:"bucket"`
|
||||
}
|
||||
|
||||
type ImageBedUploadListResponse struct {
|
||||
Records []ImageBedUploadMeta `json:"records"`
|
||||
}
|
||||
|
||||
type ImageBedUploadMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
FileName string `json:"file_name"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
FileType string `json:"file_type"`
|
||||
Path string `json:"path"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
Width int64 `json:"width"`
|
||||
Height int64 `json:"height"`
|
||||
}
|
||||
|
||||
type ImageBedUploadResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type ImageMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
FileName string `json:"file_name"`
|
||||
@@ -325,6 +383,21 @@ type OAuthWechatRequest struct {
|
||||
ClientId string `json:"client_id"`
|
||||
}
|
||||
|
||||
type PermissionRuleListResponse struct {
|
||||
Records []PermissionRuleMeta `json:"records"`
|
||||
}
|
||||
|
||||
type PermissionRuleMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
Ptype string `json:"ptype"`
|
||||
V0 string `json:"v0"`
|
||||
V1 string `json:"v1"`
|
||||
V2 string `json:"v2"`
|
||||
V3 string `json:"v3"`
|
||||
V4 string `json:"v4"`
|
||||
V5 string `json:"v5"`
|
||||
}
|
||||
|
||||
type PhoneLoginRequest struct {
|
||||
Phone string `json:"phone"`
|
||||
Captcha string `json:"captcha"`
|
||||
@@ -367,6 +440,12 @@ type RecentListResponse struct {
|
||||
Records []AllImageDetail `json:"records"`
|
||||
}
|
||||
|
||||
type RecoverImageRequest struct {
|
||||
ID int64 `json:"id"`
|
||||
Provider string `json:"provider"`
|
||||
Bucket string `json:"bucket"`
|
||||
}
|
||||
|
||||
type RefreshTokenResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
ExpireAt int64 `json:"expire_at"`
|
||||
@@ -409,6 +488,19 @@ type ResetPasswordRequest struct {
|
||||
Repassword string `json:"repassword"`
|
||||
}
|
||||
|
||||
type RoleListResponse struct {
|
||||
Records []RoleMeta `json:"records"`
|
||||
}
|
||||
|
||||
type RoleMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
RoleName string `json:"role_name"`
|
||||
RoleKey string `json:"role_key"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type RotateCaptchaResponse struct {
|
||||
Key string `json:"key"`
|
||||
Image string `json:"image"`
|
||||
@@ -638,15 +730,47 @@ type UserInfoListResponse struct {
|
||||
Records []UserMeta `json:"records"`
|
||||
}
|
||||
|
||||
type UserLoginLogListResponse struct {
|
||||
Records []UserLoginLogMeta `json:"records"`
|
||||
}
|
||||
|
||||
type UserLoginLogMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
IP string `json:"ip"`
|
||||
Location string `json:"location"`
|
||||
Agent string `json:"agent"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
Browser string `json:"browser"`
|
||||
OperatingSystem string `json:"operating_system"`
|
||||
BrowserVersion string `json:"browser_version"`
|
||||
Mobile string `json:"mobile"`
|
||||
Bot int64 `json:"bot"`
|
||||
Mozilla string `json:"mozilla"`
|
||||
Platform string `json:"platform"`
|
||||
EngineName string `json:"engine_name"`
|
||||
EngineVersion string `json:"engine_version"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type UserMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Status int64 `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
UID string `json:"uid"`
|
||||
Username string `json:"username"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Gender string `json:"gender"`
|
||||
Introduce string `json:"introduce"`
|
||||
Blog string `json:"blog"`
|
||||
Location string `json:"location"`
|
||||
Company string `json:"company"`
|
||||
Status int64 `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpadatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type UserSecuritySettingResponse struct {
|
||||
@@ -659,6 +783,21 @@ type UserSecuritySettingResponse struct {
|
||||
SetPassword bool `json:"set_password,default=false"`
|
||||
}
|
||||
|
||||
type UserThirdPartyLoginListResponse struct {
|
||||
Records []UserThirdPartyLoginMeta `json:"records"`
|
||||
}
|
||||
|
||||
type UserThirdPartyLoginMeta struct {
|
||||
ID int64 `json:"id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
OpenID string `json:"open_id"`
|
||||
Source string `json:"source"`
|
||||
Status int64 `json:"status"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
DeletedAt string `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type UserUploadInfoResponse struct {
|
||||
ImageCount int64 `json:"image_count"`
|
||||
TodayUploadCount int64 `json:"today_upload_count"`
|
||||
@@ -673,8 +812,3 @@ type WechatOffiaccountLoginRequest struct {
|
||||
Openid string `json:"openid"`
|
||||
ClientId string `json:"client_id"`
|
||||
}
|
||||
|
||||
type ImageStreamResponse struct {
|
||||
ContentType string `json:"content_type"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
@@ -119,6 +119,7 @@ func main() {
|
||||
scaStorageShare := g.GenerateModel("sca_storage_share", fieldOpts...)
|
||||
scaStorageShareVisit := g.GenerateModel("sca_storage_share_visit", fieldOpts...)
|
||||
scaStorageExtra := g.GenerateModel("sca_storage_extra", fieldOpts...)
|
||||
scaStorageImgBed := g.GenerateModel("sca_storage_img_bed", fieldOpts...)
|
||||
|
||||
g.ApplyBasic(
|
||||
scaAuthMenu,
|
||||
@@ -141,6 +142,7 @@ func main() {
|
||||
scaStorageShare,
|
||||
scaStorageShareVisit,
|
||||
scaStorageExtra,
|
||||
scaStorageImgBed,
|
||||
)
|
||||
|
||||
g.Execute()
|
||||
|
36
app/auth/model/mysql/model/sca_storage_img_bed.gen.go
Normal file
36
app/auth/model/mysql/model/sca_storage_img_bed.gen.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameScaStorageImgBed = "sca_storage_img_bed"
|
||||
|
||||
// ScaStorageImgBed mapped from table <sca_storage_img_bed>
|
||||
type ScaStorageImgBed struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键;primary_key" json:"id,string"` // 主键
|
||||
UserID string `gorm:"column:user_id;type:varchar(50);comment:用户ID" json:"user_id"` // 用户ID
|
||||
Provider string `gorm:"column:provider;type:varchar(50);comment:供应商" json:"provider"` // 供应商
|
||||
Bucket string `gorm:"column:bucket;type:varchar(100);comment:存储桶" json:"bucket"` // 存储桶
|
||||
Path string `gorm:"column:path;type:text;comment:路径" json:"path"` // 路径
|
||||
ThumbPath string `gorm:"column:thumb_path;type:text;comment:缩略图路径" json:"thumb_path"` // 缩略图路径
|
||||
FileName string `gorm:"column:file_name;type:varchar(100);comment:文件名称" json:"file_name"` // 文件名称
|
||||
FileSize int64 `gorm:"column:file_size;type:bigint(20);comment:文件大小" json:"file_size"` // 文件大小
|
||||
FileType string `gorm:"column:file_type;type:varchar(50);comment:文件类型" json:"file_type"` // 文件类型
|
||||
Width float64 `gorm:"column:width;type:double;comment:宽" json:"width"` // 宽
|
||||
Height float64 `gorm:"column:height;type:double;comment:高" json:"height"` // 高
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;autoUpdateTime;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp;comment:删除时间" json:"deleted_at"` // 删除时间
|
||||
}
|
||||
|
||||
// TableName ScaStorageImgBed's table name
|
||||
func (*ScaStorageImgBed) TableName() string {
|
||||
return TableNameScaStorageImgBed
|
||||
}
|
@@ -29,6 +29,7 @@ var (
|
||||
ScaStorageAlbum *scaStorageAlbum
|
||||
ScaStorageConfig *scaStorageConfig
|
||||
ScaStorageExtra *scaStorageExtra
|
||||
ScaStorageImgBed *scaStorageImgBed
|
||||
ScaStorageInfo *scaStorageInfo
|
||||
ScaStorageLocation *scaStorageLocation
|
||||
ScaStorageShare *scaStorageShare
|
||||
@@ -53,6 +54,7 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
ScaStorageAlbum = &Q.ScaStorageAlbum
|
||||
ScaStorageConfig = &Q.ScaStorageConfig
|
||||
ScaStorageExtra = &Q.ScaStorageExtra
|
||||
ScaStorageImgBed = &Q.ScaStorageImgBed
|
||||
ScaStorageInfo = &Q.ScaStorageInfo
|
||||
ScaStorageLocation = &Q.ScaStorageLocation
|
||||
ScaStorageShare = &Q.ScaStorageShare
|
||||
@@ -78,6 +80,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
ScaStorageAlbum: newScaStorageAlbum(db, opts...),
|
||||
ScaStorageConfig: newScaStorageConfig(db, opts...),
|
||||
ScaStorageExtra: newScaStorageExtra(db, opts...),
|
||||
ScaStorageImgBed: newScaStorageImgBed(db, opts...),
|
||||
ScaStorageInfo: newScaStorageInfo(db, opts...),
|
||||
ScaStorageLocation: newScaStorageLocation(db, opts...),
|
||||
ScaStorageShare: newScaStorageShare(db, opts...),
|
||||
@@ -104,6 +107,7 @@ type Query struct {
|
||||
ScaStorageAlbum scaStorageAlbum
|
||||
ScaStorageConfig scaStorageConfig
|
||||
ScaStorageExtra scaStorageExtra
|
||||
ScaStorageImgBed scaStorageImgBed
|
||||
ScaStorageInfo scaStorageInfo
|
||||
ScaStorageLocation scaStorageLocation
|
||||
ScaStorageShare scaStorageShare
|
||||
@@ -131,6 +135,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
||||
ScaStorageAlbum: q.ScaStorageAlbum.clone(db),
|
||||
ScaStorageConfig: q.ScaStorageConfig.clone(db),
|
||||
ScaStorageExtra: q.ScaStorageExtra.clone(db),
|
||||
ScaStorageImgBed: q.ScaStorageImgBed.clone(db),
|
||||
ScaStorageInfo: q.ScaStorageInfo.clone(db),
|
||||
ScaStorageLocation: q.ScaStorageLocation.clone(db),
|
||||
ScaStorageShare: q.ScaStorageShare.clone(db),
|
||||
@@ -165,6 +170,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
ScaStorageAlbum: q.ScaStorageAlbum.replaceDB(db),
|
||||
ScaStorageConfig: q.ScaStorageConfig.replaceDB(db),
|
||||
ScaStorageExtra: q.ScaStorageExtra.replaceDB(db),
|
||||
ScaStorageImgBed: q.ScaStorageImgBed.replaceDB(db),
|
||||
ScaStorageInfo: q.ScaStorageInfo.replaceDB(db),
|
||||
ScaStorageLocation: q.ScaStorageLocation.replaceDB(db),
|
||||
ScaStorageShare: q.ScaStorageShare.replaceDB(db),
|
||||
@@ -189,6 +195,7 @@ type queryCtx struct {
|
||||
ScaStorageAlbum IScaStorageAlbumDo
|
||||
ScaStorageConfig IScaStorageConfigDo
|
||||
ScaStorageExtra IScaStorageExtraDo
|
||||
ScaStorageImgBed IScaStorageImgBedDo
|
||||
ScaStorageInfo IScaStorageInfoDo
|
||||
ScaStorageLocation IScaStorageLocationDo
|
||||
ScaStorageShare IScaStorageShareDo
|
||||
@@ -213,6 +220,7 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
ScaStorageAlbum: q.ScaStorageAlbum.WithContext(ctx),
|
||||
ScaStorageConfig: q.ScaStorageConfig.WithContext(ctx),
|
||||
ScaStorageExtra: q.ScaStorageExtra.WithContext(ctx),
|
||||
ScaStorageImgBed: q.ScaStorageImgBed.WithContext(ctx),
|
||||
ScaStorageInfo: q.ScaStorageInfo.WithContext(ctx),
|
||||
ScaStorageLocation: q.ScaStorageLocation.WithContext(ctx),
|
||||
ScaStorageShare: q.ScaStorageShare.WithContext(ctx),
|
||||
|
432
app/auth/model/mysql/query/sca_storage_img_bed.gen.go
Normal file
432
app/auth/model/mysql/query/sca_storage_img_bed.gen.go
Normal file
@@ -0,0 +1,432 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
|
||||
)
|
||||
|
||||
func newScaStorageImgBed(db *gorm.DB, opts ...gen.DOOption) scaStorageImgBed {
|
||||
_scaStorageImgBed := scaStorageImgBed{}
|
||||
|
||||
_scaStorageImgBed.scaStorageImgBedDo.UseDB(db, opts...)
|
||||
_scaStorageImgBed.scaStorageImgBedDo.UseModel(&model.ScaStorageImgBed{})
|
||||
|
||||
tableName := _scaStorageImgBed.scaStorageImgBedDo.TableName()
|
||||
_scaStorageImgBed.ALL = field.NewAsterisk(tableName)
|
||||
_scaStorageImgBed.ID = field.NewInt64(tableName, "id")
|
||||
_scaStorageImgBed.UserID = field.NewString(tableName, "user_id")
|
||||
_scaStorageImgBed.Provider = field.NewString(tableName, "provider")
|
||||
_scaStorageImgBed.Bucket = field.NewString(tableName, "bucket")
|
||||
_scaStorageImgBed.Path = field.NewString(tableName, "path")
|
||||
_scaStorageImgBed.ThumbPath = field.NewString(tableName, "thumb_path")
|
||||
_scaStorageImgBed.FileName = field.NewString(tableName, "file_name")
|
||||
_scaStorageImgBed.FileSize = field.NewInt64(tableName, "file_size")
|
||||
_scaStorageImgBed.FileType = field.NewString(tableName, "file_type")
|
||||
_scaStorageImgBed.Width = field.NewFloat64(tableName, "width")
|
||||
_scaStorageImgBed.Height = field.NewFloat64(tableName, "height")
|
||||
_scaStorageImgBed.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_scaStorageImgBed.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_scaStorageImgBed.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_scaStorageImgBed.fillFieldMap()
|
||||
|
||||
return _scaStorageImgBed
|
||||
}
|
||||
|
||||
type scaStorageImgBed struct {
|
||||
scaStorageImgBedDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // 主键
|
||||
UserID field.String // 用户ID
|
||||
Provider field.String // 供应商
|
||||
Bucket field.String // 存储桶
|
||||
Path field.String // 路径
|
||||
ThumbPath field.String // 缩略图路径
|
||||
FileName field.String // 文件名称
|
||||
FileSize field.Int64 // 文件大小
|
||||
FileType field.String // 文件类型
|
||||
Width field.Float64 // 宽
|
||||
Height field.Float64 // 高
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (s scaStorageImgBed) Table(newTableName string) *scaStorageImgBed {
|
||||
s.scaStorageImgBedDo.UseTable(newTableName)
|
||||
return s.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBed) As(alias string) *scaStorageImgBed {
|
||||
s.scaStorageImgBedDo.DO = *(s.scaStorageImgBedDo.As(alias).(*gen.DO))
|
||||
return s.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (s *scaStorageImgBed) updateTableName(table string) *scaStorageImgBed {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewInt64(table, "id")
|
||||
s.UserID = field.NewString(table, "user_id")
|
||||
s.Provider = field.NewString(table, "provider")
|
||||
s.Bucket = field.NewString(table, "bucket")
|
||||
s.Path = field.NewString(table, "path")
|
||||
s.ThumbPath = field.NewString(table, "thumb_path")
|
||||
s.FileName = field.NewString(table, "file_name")
|
||||
s.FileSize = field.NewInt64(table, "file_size")
|
||||
s.FileType = field.NewString(table, "file_type")
|
||||
s.Width = field.NewFloat64(table, "width")
|
||||
s.Height = field.NewFloat64(table, "height")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
s.fillFieldMap()
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *scaStorageImgBed) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := s.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (s *scaStorageImgBed) fillFieldMap() {
|
||||
s.fieldMap = make(map[string]field.Expr, 14)
|
||||
s.fieldMap["id"] = s.ID
|
||||
s.fieldMap["user_id"] = s.UserID
|
||||
s.fieldMap["provider"] = s.Provider
|
||||
s.fieldMap["bucket"] = s.Bucket
|
||||
s.fieldMap["path"] = s.Path
|
||||
s.fieldMap["thumb_path"] = s.ThumbPath
|
||||
s.fieldMap["file_name"] = s.FileName
|
||||
s.fieldMap["file_size"] = s.FileSize
|
||||
s.fieldMap["file_type"] = s.FileType
|
||||
s.fieldMap["width"] = s.Width
|
||||
s.fieldMap["height"] = s.Height
|
||||
s.fieldMap["created_at"] = s.CreatedAt
|
||||
s.fieldMap["updated_at"] = s.UpdatedAt
|
||||
s.fieldMap["deleted_at"] = s.DeletedAt
|
||||
}
|
||||
|
||||
func (s scaStorageImgBed) clone(db *gorm.DB) scaStorageImgBed {
|
||||
s.scaStorageImgBedDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s scaStorageImgBed) replaceDB(db *gorm.DB) scaStorageImgBed {
|
||||
s.scaStorageImgBedDo.ReplaceDB(db)
|
||||
return s
|
||||
}
|
||||
|
||||
type scaStorageImgBedDo struct{ gen.DO }
|
||||
|
||||
type IScaStorageImgBedDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IScaStorageImgBedDo
|
||||
WithContext(ctx context.Context) IScaStorageImgBedDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IScaStorageImgBedDo
|
||||
WriteDB() IScaStorageImgBedDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IScaStorageImgBedDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IScaStorageImgBedDo
|
||||
Not(conds ...gen.Condition) IScaStorageImgBedDo
|
||||
Or(conds ...gen.Condition) IScaStorageImgBedDo
|
||||
Select(conds ...field.Expr) IScaStorageImgBedDo
|
||||
Where(conds ...gen.Condition) IScaStorageImgBedDo
|
||||
Order(conds ...field.Expr) IScaStorageImgBedDo
|
||||
Distinct(cols ...field.Expr) IScaStorageImgBedDo
|
||||
Omit(cols ...field.Expr) IScaStorageImgBedDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IScaStorageImgBedDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageImgBedDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageImgBedDo
|
||||
Group(cols ...field.Expr) IScaStorageImgBedDo
|
||||
Having(conds ...gen.Condition) IScaStorageImgBedDo
|
||||
Limit(limit int) IScaStorageImgBedDo
|
||||
Offset(offset int) IScaStorageImgBedDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageImgBedDo
|
||||
Unscoped() IScaStorageImgBedDo
|
||||
Create(values ...*model.ScaStorageImgBed) error
|
||||
CreateInBatches(values []*model.ScaStorageImgBed, batchSize int) error
|
||||
Save(values ...*model.ScaStorageImgBed) error
|
||||
First() (*model.ScaStorageImgBed, error)
|
||||
Take() (*model.ScaStorageImgBed, error)
|
||||
Last() (*model.ScaStorageImgBed, error)
|
||||
Find() ([]*model.ScaStorageImgBed, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageImgBed, err error)
|
||||
FindInBatches(result *[]*model.ScaStorageImgBed, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.ScaStorageImgBed) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IScaStorageImgBedDo
|
||||
Assign(attrs ...field.AssignExpr) IScaStorageImgBedDo
|
||||
Joins(fields ...field.RelationField) IScaStorageImgBedDo
|
||||
Preload(fields ...field.RelationField) IScaStorageImgBedDo
|
||||
FirstOrInit() (*model.ScaStorageImgBed, error)
|
||||
FirstOrCreate() (*model.ScaStorageImgBed, error)
|
||||
FindByPage(offset int, limit int) (result []*model.ScaStorageImgBed, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IScaStorageImgBedDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Debug() IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Debug())
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) WithContext(ctx context.Context) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) ReadDB() IScaStorageImgBedDo {
|
||||
return s.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) WriteDB() IScaStorageImgBedDo {
|
||||
return s.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Session(config *gorm.Session) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Session(config))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Clauses(conds ...clause.Expression) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Returning(value interface{}, columns ...string) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Not(conds ...gen.Condition) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Or(conds ...gen.Condition) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Select(conds ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Where(conds ...gen.Condition) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Order(conds ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Distinct(cols ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Omit(cols ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Join(table schema.Tabler, on ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Group(cols ...field.Expr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Having(conds ...gen.Condition) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Limit(limit int) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Offset(offset int) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Unscoped() IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Create(values ...*model.ScaStorageImgBed) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Create(values)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) CreateInBatches(values []*model.ScaStorageImgBed, batchSize int) error {
|
||||
return s.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (s scaStorageImgBedDo) Save(values ...*model.ScaStorageImgBed) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Save(values)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) First() (*model.ScaStorageImgBed, error) {
|
||||
if result, err := s.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ScaStorageImgBed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Take() (*model.ScaStorageImgBed, error) {
|
||||
if result, err := s.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ScaStorageImgBed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Last() (*model.ScaStorageImgBed, error) {
|
||||
if result, err := s.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ScaStorageImgBed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Find() ([]*model.ScaStorageImgBed, error) {
|
||||
result, err := s.DO.Find()
|
||||
return result.([]*model.ScaStorageImgBed), err
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageImgBed, err error) {
|
||||
buf := make([]*model.ScaStorageImgBed, 0, batchSize)
|
||||
err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) FindInBatches(result *[]*model.ScaStorageImgBed, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return s.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Attrs(attrs ...field.AssignExpr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Assign(attrs ...field.AssignExpr) IScaStorageImgBedDo {
|
||||
return s.withDO(s.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Joins(fields ...field.RelationField) IScaStorageImgBedDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Joins(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Preload(fields ...field.RelationField) IScaStorageImgBedDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Preload(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) FirstOrInit() (*model.ScaStorageImgBed, error) {
|
||||
if result, err := s.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ScaStorageImgBed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) FirstOrCreate() (*model.ScaStorageImgBed, error) {
|
||||
if result, err := s.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ScaStorageImgBed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) FindByPage(offset int, limit int) (result []*model.ScaStorageImgBed, count int64, err error) {
|
||||
result, err = s.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = s.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = s.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = s.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Scan(result interface{}) (err error) {
|
||||
return s.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (s scaStorageImgBedDo) Delete(models ...*model.ScaStorageImgBed) (result gen.ResultInfo, err error) {
|
||||
return s.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (s *scaStorageImgBedDo) withDO(do gen.Dao) *scaStorageImgBedDo {
|
||||
s.DO = *do.(*gen.DO)
|
||||
return s
|
||||
}
|
Reference in New Issue
Block a user