♻️ use minio instead of mongodb

This commit is contained in:
2025-02-05 18:08:29 +08:00
parent a3d4f2c8d1
commit d2b0d7b42e
53 changed files with 2446 additions and 702 deletions

View File

@@ -19,7 +19,7 @@ type ScaStorageFace struct {
FaceName string `gorm:"column:face_name;type:varchar(255);comment:人脸名称" json:"face_name"` // 人脸名称
FaceVector string `gorm:"column:face_vector;type:json;comment:人脸特征向量" json:"face_vector"` // 人脸特征向量
FaceImagePath string `gorm:"column:face_image_path;type:varchar(255);comment:人脸图像路径" json:"face_image_path"` // 人脸图像路径
FaceType string `gorm:"column:face_type;type:varchar(50);comment:人脸类型标识" json:"face_type"` // 人脸类型标识
FaceType int64 `gorm:"column:face_type;type:int(10);comment:人脸类型标识" json:"face_type"` // 人脸类型标识
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"` // 删除时间

View File

@@ -32,7 +32,7 @@ func newScaStorageFace(db *gorm.DB, opts ...gen.DOOption) scaStorageFace {
_scaStorageFace.FaceName = field.NewString(tableName, "face_name")
_scaStorageFace.FaceVector = field.NewString(tableName, "face_vector")
_scaStorageFace.FaceImagePath = field.NewString(tableName, "face_image_path")
_scaStorageFace.FaceType = field.NewString(tableName, "face_type")
_scaStorageFace.FaceType = field.NewInt64(tableName, "face_type")
_scaStorageFace.CreatedAt = field.NewTime(tableName, "created_at")
_scaStorageFace.UpdatedAt = field.NewTime(tableName, "updated_at")
_scaStorageFace.DeletedAt = field.NewField(tableName, "deleted_at")
@@ -52,7 +52,7 @@ type scaStorageFace struct {
FaceName field.String // 人脸名称
FaceVector field.String // 人脸特征向量
FaceImagePath field.String // 人脸图像路径
FaceType field.String // 人脸类型标识
FaceType field.Int64 // 人脸类型标识
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
@@ -77,7 +77,7 @@ func (s *scaStorageFace) updateTableName(table string) *scaStorageFace {
s.FaceName = field.NewString(table, "face_name")
s.FaceVector = field.NewString(table, "face_vector")
s.FaceImagePath = field.NewString(table, "face_image_path")
s.FaceType = field.NewString(table, "face_type")
s.FaceType = field.NewInt64(table, "face_type")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")
s.DeletedAt = field.NewField(table, "deleted_at")

View File

@@ -28,6 +28,38 @@ message CaffeClassificationResponse {
string class_name = 2;
float score = 3;
}
// 查询人脸样本库
message QueryFaceLibraryRequest {
string user_id = 1;
int64 type = 2;
}
message FaceLibrary {
int64 id = 1;
string face_name = 2;
string face_image = 3;
}
message QueryFaceLibraryResponse {
repeated FaceLibrary faces = 1;
}
// 添加或修改人脸样本名称
message ModifyFaceNameRequest {
string user_id = 1;
int64 face_id = 2;
string face_name = 3;
}
message ModifyFaceNameResponse {
int64 face_id = 1;
string face_name = 2;
}
// 修改人脸类型
message ModifyFaceTypeRequest {
string user_id = 1;
repeated int64 face_id = 2;
int64 type = 3;
}
message ModifyFaceTypeResponse {
string result = 1;
}
service AiService {
// FaceRecognition
rpc FaceRecognition (FaceRecognitionRequest) returns (FaceRecognitionResponse);
@@ -35,4 +67,12 @@ service AiService {
rpc TfClassification (TfClassificationRequest) returns (TfClassificationResponse);
// CaffeClassification
rpc CaffeClassification (CaffeClassificationRequest) returns (CaffeClassificationResponse);
}
// QueryFaceLibrary
rpc QueryFaceLibrary (QueryFaceLibraryRequest) returns (QueryFaceLibraryResponse);
// ModifyFaceName
rpc ModifyFaceName (ModifyFaceNameRequest) returns (ModifyFaceNameResponse);
// ModifyFaceType
rpc ModifyFaceType (ModifyFaceTypeRequest) returns (ModifyFaceTypeResponse);
}

View File

@@ -16,8 +16,15 @@ import (
type (
CaffeClassificationRequest = pb.CaffeClassificationRequest
CaffeClassificationResponse = pb.CaffeClassificationResponse
FaceLibrary = pb.FaceLibrary
FaceRecognitionRequest = pb.FaceRecognitionRequest
FaceRecognitionResponse = pb.FaceRecognitionResponse
ModifyFaceNameRequest = pb.ModifyFaceNameRequest
ModifyFaceNameResponse = pb.ModifyFaceNameResponse
ModifyFaceTypeRequest = pb.ModifyFaceTypeRequest
ModifyFaceTypeResponse = pb.ModifyFaceTypeResponse
QueryFaceLibraryRequest = pb.QueryFaceLibraryRequest
QueryFaceLibraryResponse = pb.QueryFaceLibraryResponse
TfClassificationRequest = pb.TfClassificationRequest
TfClassificationResponse = pb.TfClassificationResponse
@@ -28,6 +35,12 @@ type (
TfClassification(ctx context.Context, in *TfClassificationRequest, opts ...grpc.CallOption) (*TfClassificationResponse, error)
// CaffeClassification
CaffeClassification(ctx context.Context, in *CaffeClassificationRequest, opts ...grpc.CallOption) (*CaffeClassificationResponse, error)
// QueryFaceLibrary
QueryFaceLibrary(ctx context.Context, in *QueryFaceLibraryRequest, opts ...grpc.CallOption) (*QueryFaceLibraryResponse, error)
// ModifyFaceName
ModifyFaceName(ctx context.Context, in *ModifyFaceNameRequest, opts ...grpc.CallOption) (*ModifyFaceNameResponse, error)
// ModifyFaceType
ModifyFaceType(ctx context.Context, in *ModifyFaceTypeRequest, opts ...grpc.CallOption) (*ModifyFaceTypeResponse, error)
}
defaultAiService struct {
@@ -58,3 +71,21 @@ func (m *defaultAiService) CaffeClassification(ctx context.Context, in *CaffeCla
client := pb.NewAiServiceClient(m.cli.Conn())
return client.CaffeClassification(ctx, in, opts...)
}
// QueryFaceLibrary
func (m *defaultAiService) QueryFaceLibrary(ctx context.Context, in *QueryFaceLibraryRequest, opts ...grpc.CallOption) (*QueryFaceLibraryResponse, error) {
client := pb.NewAiServiceClient(m.cli.Conn())
return client.QueryFaceLibrary(ctx, in, opts...)
}
// ModifyFaceName
func (m *defaultAiService) ModifyFaceName(ctx context.Context, in *ModifyFaceNameRequest, opts ...grpc.CallOption) (*ModifyFaceNameResponse, error) {
client := pb.NewAiServiceClient(m.cli.Conn())
return client.ModifyFaceName(ctx, in, opts...)
}
// ModifyFaceType
func (m *defaultAiService) ModifyFaceType(ctx context.Context, in *ModifyFaceTypeRequest, opts ...grpc.CallOption) (*ModifyFaceTypeResponse, error) {
client := pb.NewAiServiceClient(m.cli.Conn())
return client.ModifyFaceType(ctx, in, opts...)
}

View File

@@ -22,3 +22,13 @@ RedisConf:
Pass: LDQ20020618xxx
# Redis 数据库
DB: 0
# Minio配置
Minio:
# Minio 地址
Endpoint: 1.95.0.111:9000
# Minio 访问密钥
AccessKeyID: JNLVxMGro1XXwajodLBX
# Minio 访问密钥
SecretAccessKey: XEHkwExqQdAlEPfpRk36xpc0Sie8hZkcmlhXQJXw
# Minio 使用SSL
UseSSL: false

View File

@@ -15,4 +15,10 @@ type Config struct {
Pass string
DB int
}
Minio struct {
Endpoint string
AccessKeyID string
SecretAccessKey string
UseSSL bool
}
}

View File

@@ -7,12 +7,12 @@ import (
"fmt"
"github.com/Kagami/go-face"
"github.com/ccpwcn/kgo"
"github.com/minio/minio-go/v7"
"github.com/zeromicro/go-zero/core/logx"
"image"
"image/jpeg"
_ "image/png"
"os"
"path/filepath"
"path"
"schisandra-album-cloud-microservices/app/aisvc/model/mysql/model"
"schisandra-album-cloud-microservices/app/aisvc/rpc/internal/svc"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
@@ -60,7 +60,7 @@ func (l *FaceRecognitionLogic) FaceRecognition(in *pb.FaceRecognitionRequest) (*
return nil, nil
}
hashKey := fmt.Sprintf("user:%s:faces", in.GetUserId())
hashKey := constant.FaceVectorPrefix + in.GetUserId()
// 从 Redis 加载人脸数据
samples, ids, err := l.loadFacesFromRedisHash(hashKey)
if err != nil {
@@ -89,10 +89,10 @@ func (l *FaceRecognitionLogic) FaceRecognition(in *pb.FaceRecognitionRequest) (*
l.svcCtx.FaceRecognizer.SetSamples(samples, ids)
// 人脸分类
classify := l.svcCtx.FaceRecognizer.ClassifyThreshold(faceFeatures.Descriptor, 0.6)
if classify >= 0 && classify < len(ids) {
classify := l.svcCtx.FaceRecognizer.ClassifyThreshold(faceFeatures.Descriptor, 0.3)
if classify > 0 {
return &pb.FaceRecognitionResponse{
FaceId: int64(ids[classify]),
FaceId: int64(classify),
}, nil
}
@@ -131,7 +131,7 @@ func (l *FaceRecognitionLogic) saveNewFace(in *pb.FaceRecognitionRequest, faceFe
}
// 保存人脸图片到本地
faceImagePath, err := l.saveCroppedFaceToLocal(in.GetFace(), faceFeatures.Rectangle, "face_samples", in.GetUserId())
faceImagePath, err := l.saveCroppedFaceToLocal(in.GetFace(), faceFeatures.Rectangle, in.GetUserId())
if err != nil {
return nil, err
}
@@ -161,7 +161,7 @@ func (l *FaceRecognitionLogic) loadExistingFaces(userId string) ([]face.Descript
storageFace := l.svcCtx.DB.ScaStorageFace
existingFaces, err := storageFace.
Select(storageFace.FaceVector, storageFace.ID).
Where(storageFace.UserID.Eq(userId), storageFace.FaceType.Eq(constant.FaceTypeSample)).
Where(storageFace.UserID.Eq(userId)).
Find()
if err != nil {
return nil, nil, err
@@ -215,7 +215,6 @@ func (l *FaceRecognitionLogic) saveFaceToDatabase(userId string, descriptor face
storageFace := model.ScaStorageFace{
FaceVector: string(jsonBytes),
FaceImagePath: faceImagePath,
FaceType: constant.FaceTypeSample,
UserID: userId,
}
err = l.svcCtx.DB.ScaStorageFace.Create(&storageFace)
@@ -225,17 +224,12 @@ func (l *FaceRecognitionLogic) saveFaceToDatabase(userId string, descriptor face
return &storageFace, nil
}
func (l *FaceRecognitionLogic) saveCroppedFaceToLocal(faceImage []byte, rect image.Rectangle, baseSavePath string, userID string) (string, error) {
// 动态生成用户目录和时间分级目录
subDir := filepath.Join(baseSavePath, userID, time.Now().Format("2006/01")) // 格式:<baseSavePath>/<userID>/YYYY/MM
// 缓存目录检查,避免重复调用 os.MkdirAll
if !l.isDirectoryCached(subDir) {
if err := os.MkdirAll(subDir, os.ModePerm); err != nil {
return "", fmt.Errorf("failed to create directory: %w", err)
}
l.cacheDirectory(subDir) // 缓存已创建的目录路径
}
func (l *FaceRecognitionLogic) saveCroppedFaceToLocal(faceImage []byte, rect image.Rectangle, userID string) (string, error) {
objectKey := path.Join(
userID,
time.Now().Format("2006/01"), // 按年/月划分目录
fmt.Sprintf("%s_%s.jpg", time.Now().Format("20060102150405"), kgo.SimpleUuid()),
)
// 解码图像
img, _, err := image.Decode(bytes.NewReader(faceImage))
@@ -258,42 +252,35 @@ func (l *FaceRecognitionLogic) saveCroppedFaceToLocal(faceImage []byte, rect ima
SubImage(r image.Rectangle) image.Image
}).SubImage(extendedRect)
// 生成唯一文件名(时间戳 + UUID
fileName := fmt.Sprintf("%s_%s.jpg", time.Now().Format("20060102_150405"), kgo.SimpleUuid())
outputPath := filepath.Join(subDir, fileName)
// 写入文件
if err = l.writeImageToFile(outputPath, croppedImage); err != nil {
return "", err
// 将图像编码为JPEG字节流
var buf bytes.Buffer
if err = jpeg.Encode(&buf, croppedImage, nil); err != nil {
return "", fmt.Errorf("failed to encode image to JPEG: %w", err)
}
exists, err := l.svcCtx.MinioClient.BucketExists(l.ctx, constant.FaceBucketName)
if err != nil || !exists {
err = l.svcCtx.MinioClient.MakeBucket(l.ctx, constant.FaceBucketName, minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
if err != nil {
logx.Errorf("Failed to create MinIO bucket: %v", err)
return "", err
}
}
return outputPath, nil
}
// 判断目录是否已缓存
func (l *FaceRecognitionLogic) isDirectoryCached(dir string) bool {
_, exists := l.directoryCache.Load(dir)
return exists
}
// 缓存目录
func (l *FaceRecognitionLogic) cacheDirectory(dir string) {
l.directoryCache.Store(dir, struct{}{})
}
// 将图像写入文件
func (l *FaceRecognitionLogic) writeImageToFile(path string, img image.Image) error {
file, err := os.Create(path)
// 上传到MinIO
_, err = l.svcCtx.MinioClient.PutObject(
l.ctx,
constant.FaceBucketName,
objectKey,
bytes.NewReader(buf.Bytes()),
int64(buf.Len()),
minio.PutObjectOptions{
ContentType: "image/jpeg",
},
)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
return "", fmt.Errorf("failed to upload image to MinIO: %w", err)
}
defer func(file *os.File) {
_ = file.Close()
}(file)
if err = jpeg.Encode(file, img, nil); err != nil {
return fmt.Errorf("failed to encode and save image: %w", err)
}
return nil
return objectKey, nil
}
// 从 Redis 的 Hash 中加载人脸数据

View File

@@ -0,0 +1,40 @@
package aiservicelogic
import (
"context"
"errors"
"schisandra-album-cloud-microservices/app/aisvc/rpc/internal/svc"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type ModifyFaceNameLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewModifyFaceNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyFaceNameLogic {
return &ModifyFaceNameLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ModifyFaceNameLogic) ModifyFaceName(in *pb.ModifyFaceNameRequest) (*pb.ModifyFaceNameResponse, error) {
storageFace := l.svcCtx.DB.ScaStorageFace
affected, err := storageFace.Where(storageFace.ID.Eq(in.GetFaceId()), storageFace.UserID.Eq(in.GetUserId())).Update(storageFace.FaceName, in.GetFaceName())
if err != nil {
return nil, err
}
if affected.RowsAffected == 0 {
return nil, errors.New("update failed, no rows affected")
}
return &pb.ModifyFaceNameResponse{
FaceId: in.GetFaceId(),
FaceName: in.GetFaceName(),
}, nil
}

View File

@@ -0,0 +1,43 @@
package aiservicelogic
import (
"context"
"errors"
"schisandra-album-cloud-microservices/app/aisvc/rpc/internal/svc"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type ModifyFaceTypeLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewModifyFaceTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyFaceTypeLogic {
return &ModifyFaceTypeLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ModifyFaceType
func (l *ModifyFaceTypeLogic) ModifyFaceType(in *pb.ModifyFaceTypeRequest) (*pb.ModifyFaceTypeResponse, error) {
storageFace := l.svcCtx.DB.ScaStorageFace
faceIds := in.GetFaceId()
info, err := storageFace.Where(storageFace.ID.In(faceIds...), storageFace.UserID.Eq(in.GetUserId())).Update(storageFace.FaceType, in.GetType())
if err != nil {
return nil, err
}
if info.RowsAffected == 0 {
return &pb.ModifyFaceTypeResponse{
Result: "fail",
}, errors.New("face not found")
}
return &pb.ModifyFaceTypeResponse{
Result: "success",
}, nil
}

View File

@@ -0,0 +1,102 @@
package aiservicelogic
import (
"context"
"fmt"
"net/url"
"schisandra-album-cloud-microservices/app/aisvc/model/mysql/model"
"schisandra-album-cloud-microservices/common/constant"
"strconv"
"sync"
"time"
"schisandra-album-cloud-microservices/app/aisvc/rpc/internal/svc"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type QueryFaceLibraryLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
wg sync.WaitGroup
mu sync.Mutex
}
type FaceLibrary struct {
ID int64 `json:"id"`
FaceImage []byte `json:"face_image"`
FaceName string `json:"face_name"`
}
func NewQueryFaceLibraryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryFaceLibraryLogic {
return &QueryFaceLibraryLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
wg: sync.WaitGroup{},
mu: sync.Mutex{},
}
}
// QueryFaceLibrary queries the face library
func (l *QueryFaceLibraryLogic) QueryFaceLibrary(in *pb.QueryFaceLibraryRequest) (*pb.QueryFaceLibraryResponse, error) {
if in.GetUserId() == "" {
return nil, fmt.Errorf("user ID is required")
}
storageFace := l.svcCtx.DB.ScaStorageFace
samples, err := storageFace.Select(
storageFace.ID,
storageFace.FaceVector,
storageFace.FaceImagePath,
storageFace.FaceName).
Where(storageFace.UserID.Eq(in.GetUserId()), storageFace.FaceType.Eq(in.GetType())).
Find()
if err != nil {
return nil, fmt.Errorf("failed to query face library: %v", err)
}
if len(samples) == 0 {
return nil, nil
}
faceLibrary := make([]*pb.FaceLibrary, len(samples))
for i, sample := range samples {
l.wg.Add(1)
go func(i int, sample *model.ScaStorageFace) {
defer l.wg.Done()
redisKey := constant.FaceSamplePrefix + in.GetUserId() + ":" + strconv.FormatInt(sample.ID, 10)
file, err := l.svcCtx.RedisClient.Get(l.ctx, redisKey).Result()
if err == nil {
l.mu.Lock()
faceLibrary[i] = &pb.FaceLibrary{
Id: sample.ID,
FaceName: sample.FaceName,
FaceImage: file,
}
l.mu.Unlock()
return
}
reqParams := make(url.Values)
presignedURL, err := l.svcCtx.MinioClient.PresignedGetObject(l.ctx, constant.FaceBucketName, sample.FaceImagePath, time.Hour*24, reqParams)
err = l.svcCtx.RedisClient.Set(l.ctx, redisKey, presignedURL.String(), time.Hour*24).Err()
if err != nil {
return
}
l.mu.Lock()
faceLibrary[i] = &pb.FaceLibrary{
Id: sample.ID,
FaceName: sample.FaceName,
FaceImage: presignedURL.String(),
}
l.mu.Unlock()
}(i, sample)
}
l.wg.Wait()
return &pb.QueryFaceLibraryResponse{
Faces: faceLibrary,
}, nil
}

View File

@@ -40,3 +40,21 @@ func (s *AiServiceServer) CaffeClassification(ctx context.Context, in *pb.CaffeC
l := aiservicelogic.NewCaffeClassificationLogic(ctx, s.svcCtx)
return l.CaffeClassification(in)
}
// QueryFaceLibrary
func (s *AiServiceServer) QueryFaceLibrary(ctx context.Context, in *pb.QueryFaceLibraryRequest) (*pb.QueryFaceLibraryResponse, error) {
l := aiservicelogic.NewQueryFaceLibraryLogic(ctx, s.svcCtx)
return l.QueryFaceLibrary(in)
}
// ModifyFaceName
func (s *AiServiceServer) ModifyFaceName(ctx context.Context, in *pb.ModifyFaceNameRequest) (*pb.ModifyFaceNameResponse, error) {
l := aiservicelogic.NewModifyFaceNameLogic(ctx, s.svcCtx)
return l.ModifyFaceName(in)
}
// ModifyFaceType
func (s *AiServiceServer) ModifyFaceType(ctx context.Context, in *pb.ModifyFaceTypeRequest) (*pb.ModifyFaceTypeResponse, error) {
l := aiservicelogic.NewModifyFaceTypeLogic(ctx, s.svcCtx)
return l.ModifyFaceType(in)
}

View File

@@ -2,6 +2,7 @@ package svc
import (
"github.com/Kagami/go-face"
"github.com/minio/minio-go/v7"
"github.com/redis/go-redis/v9"
"gocv.io/x/gocv"
"schisandra-album-cloud-microservices/app/aisvc/model/mysql"
@@ -9,6 +10,7 @@ import (
"schisandra-album-cloud-microservices/app/aisvc/rpc/internal/config"
"schisandra-album-cloud-microservices/common/caffe_classifier"
"schisandra-album-cloud-microservices/common/face_recognizer"
"schisandra-album-cloud-microservices/common/miniox"
"schisandra-album-cloud-microservices/common/redisx"
"schisandra-album-cloud-microservices/common/tf_classifier"
)
@@ -22,6 +24,7 @@ type ServiceContext struct {
TfDesc []string
CaffeNet *gocv.Net
CaffeDesc []string
MinioClient *minio.Client
}
func NewServiceContext(c config.Config) *ServiceContext {
@@ -38,5 +41,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
TfDesc: tfDesc,
CaffeNet: caffeClassifier,
CaffeDesc: caffeDesc,
MinioClient: miniox.NewMinio(c.Minio.Endpoint, c.Minio.AccessKeyID, c.Minio.SecretAccessKey, c.Minio.UseSSL),
}
}

View File

@@ -317,6 +317,388 @@ func (x *CaffeClassificationResponse) GetScore() float32 {
return 0
}
// 查询人脸样本库
type QueryFaceLibraryRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Type int64 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"`
}
func (x *QueryFaceLibraryRequest) Reset() {
*x = QueryFaceLibraryRequest{}
mi := &file_aisvc_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *QueryFaceLibraryRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*QueryFaceLibraryRequest) ProtoMessage() {}
func (x *QueryFaceLibraryRequest) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use QueryFaceLibraryRequest.ProtoReflect.Descriptor instead.
func (*QueryFaceLibraryRequest) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{6}
}
func (x *QueryFaceLibraryRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *QueryFaceLibraryRequest) GetType() int64 {
if x != nil {
return x.Type
}
return 0
}
type FaceLibrary struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
FaceName string `protobuf:"bytes,2,opt,name=face_name,json=faceName,proto3" json:"face_name,omitempty"`
FaceImage string `protobuf:"bytes,3,opt,name=face_image,json=faceImage,proto3" json:"face_image,omitempty"`
}
func (x *FaceLibrary) Reset() {
*x = FaceLibrary{}
mi := &file_aisvc_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FaceLibrary) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FaceLibrary) ProtoMessage() {}
func (x *FaceLibrary) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FaceLibrary.ProtoReflect.Descriptor instead.
func (*FaceLibrary) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{7}
}
func (x *FaceLibrary) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *FaceLibrary) GetFaceName() string {
if x != nil {
return x.FaceName
}
return ""
}
func (x *FaceLibrary) GetFaceImage() string {
if x != nil {
return x.FaceImage
}
return ""
}
type QueryFaceLibraryResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Faces []*FaceLibrary `protobuf:"bytes,1,rep,name=faces,proto3" json:"faces,omitempty"`
}
func (x *QueryFaceLibraryResponse) Reset() {
*x = QueryFaceLibraryResponse{}
mi := &file_aisvc_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *QueryFaceLibraryResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*QueryFaceLibraryResponse) ProtoMessage() {}
func (x *QueryFaceLibraryResponse) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use QueryFaceLibraryResponse.ProtoReflect.Descriptor instead.
func (*QueryFaceLibraryResponse) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{8}
}
func (x *QueryFaceLibraryResponse) GetFaces() []*FaceLibrary {
if x != nil {
return x.Faces
}
return nil
}
// 添加或修改人脸样本名称
type ModifyFaceNameRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
FaceId int64 `protobuf:"varint,2,opt,name=face_id,json=faceId,proto3" json:"face_id,omitempty"`
FaceName string `protobuf:"bytes,3,opt,name=face_name,json=faceName,proto3" json:"face_name,omitempty"`
}
func (x *ModifyFaceNameRequest) Reset() {
*x = ModifyFaceNameRequest{}
mi := &file_aisvc_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ModifyFaceNameRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModifyFaceNameRequest) ProtoMessage() {}
func (x *ModifyFaceNameRequest) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ModifyFaceNameRequest.ProtoReflect.Descriptor instead.
func (*ModifyFaceNameRequest) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{9}
}
func (x *ModifyFaceNameRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *ModifyFaceNameRequest) GetFaceId() int64 {
if x != nil {
return x.FaceId
}
return 0
}
func (x *ModifyFaceNameRequest) GetFaceName() string {
if x != nil {
return x.FaceName
}
return ""
}
type ModifyFaceNameResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FaceId int64 `protobuf:"varint,1,opt,name=face_id,json=faceId,proto3" json:"face_id,omitempty"`
FaceName string `protobuf:"bytes,2,opt,name=face_name,json=faceName,proto3" json:"face_name,omitempty"`
}
func (x *ModifyFaceNameResponse) Reset() {
*x = ModifyFaceNameResponse{}
mi := &file_aisvc_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ModifyFaceNameResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModifyFaceNameResponse) ProtoMessage() {}
func (x *ModifyFaceNameResponse) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ModifyFaceNameResponse.ProtoReflect.Descriptor instead.
func (*ModifyFaceNameResponse) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{10}
}
func (x *ModifyFaceNameResponse) GetFaceId() int64 {
if x != nil {
return x.FaceId
}
return 0
}
func (x *ModifyFaceNameResponse) GetFaceName() string {
if x != nil {
return x.FaceName
}
return ""
}
// 修改人脸类型
type ModifyFaceTypeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
FaceId []int64 `protobuf:"varint,2,rep,packed,name=face_id,json=faceId,proto3" json:"face_id,omitempty"`
Type int64 `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"`
}
func (x *ModifyFaceTypeRequest) Reset() {
*x = ModifyFaceTypeRequest{}
mi := &file_aisvc_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ModifyFaceTypeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModifyFaceTypeRequest) ProtoMessage() {}
func (x *ModifyFaceTypeRequest) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ModifyFaceTypeRequest.ProtoReflect.Descriptor instead.
func (*ModifyFaceTypeRequest) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{11}
}
func (x *ModifyFaceTypeRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *ModifyFaceTypeRequest) GetFaceId() []int64 {
if x != nil {
return x.FaceId
}
return nil
}
func (x *ModifyFaceTypeRequest) GetType() int64 {
if x != nil {
return x.Type
}
return 0
}
type ModifyFaceTypeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
}
func (x *ModifyFaceTypeResponse) Reset() {
*x = ModifyFaceTypeResponse{}
mi := &file_aisvc_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ModifyFaceTypeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ModifyFaceTypeResponse) ProtoMessage() {}
func (x *ModifyFaceTypeResponse) ProtoReflect() protoreflect.Message {
mi := &file_aisvc_proto_msgTypes[12]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ModifyFaceTypeResponse.ProtoReflect.Descriptor instead.
func (*ModifyFaceTypeResponse) Descriptor() ([]byte, []int) {
return file_aisvc_proto_rawDescGZIP(), []int{12}
}
func (x *ModifyFaceTypeResponse) GetResult() string {
if x != nil {
return x.Result
}
return ""
}
var File_aisvc_proto protoreflect.FileDescriptor
var file_aisvc_proto_rawDesc = []byte{
@@ -345,22 +727,71 @@ var file_aisvc_proto_rawDesc = []byte{
0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x4e, 0x61, 0x6d, 0x65,
0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52,
0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x32, 0xfe, 0x01, 0x0a, 0x09, 0x41, 0x69, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x46, 0x61, 0x63, 0x65, 0x52, 0x65, 0x63, 0x6f,
0x67, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x2e, 0x61, 0x69, 0x2e, 0x46, 0x61, 0x63,
0x65, 0x52, 0x65, 0x63, 0x6f, 0x67, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x61, 0x69, 0x2e, 0x46, 0x61, 0x63, 0x65, 0x52, 0x65, 0x63,
0x6f, 0x67, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x4d, 0x0a, 0x10, 0x54, 0x66, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x61, 0x69, 0x2e, 0x54, 0x66, 0x43, 0x6c, 0x61, 0x73,
0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1c, 0x2e, 0x61, 0x69, 0x2e, 0x54, 0x66, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x56, 0x0a, 0x13, 0x43, 0x61, 0x66, 0x66, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x61, 0x69, 0x2e, 0x43, 0x61, 0x66, 0x66,
0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x61, 0x69, 0x2e, 0x43, 0x61, 0x66, 0x66,
0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x46, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46,
0x61, 0x63, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79,
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x59,
0x0a, 0x0b, 0x46, 0x61, 0x63, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a,
0x09, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x66, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x61,
0x63, 0x65, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x66, 0x61, 0x63, 0x65, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x22, 0x41, 0x0a, 0x18, 0x51, 0x75, 0x65,
0x72, 0x79, 0x46, 0x61, 0x63, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x69, 0x2e, 0x46, 0x61, 0x63, 0x65, 0x4c, 0x69,
0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x05, 0x66, 0x61, 0x63, 0x65, 0x73, 0x22, 0x66, 0x0a, 0x15,
0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x17,
0x0a, 0x07, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x06, 0x66, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x61, 0x63, 0x65, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x61, 0x63, 0x65,
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x4e, 0x0a, 0x16, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61,
0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17,
0x0a, 0x07, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x06, 0x66, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x61, 0x63, 0x65, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x61, 0x63, 0x65,
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x5d, 0x0a, 0x15, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61,
0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a,
0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x69,
0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x66, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12,
0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74,
0x79, 0x70, 0x65, 0x22, 0x30, 0x0a, 0x16, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61, 0x63,
0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a,
0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72,
0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0xdf, 0x03, 0x0a, 0x09, 0x41, 0x69, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x46, 0x61, 0x63, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x67,
0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x2e, 0x61, 0x69, 0x2e, 0x46, 0x61, 0x63, 0x65,
0x52, 0x65, 0x63, 0x6f, 0x67, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x61, 0x69, 0x2e, 0x46, 0x61, 0x63, 0x65, 0x52, 0x65, 0x63, 0x6f,
0x67, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x4d, 0x0a, 0x10, 0x54, 0x66, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x61, 0x69, 0x2e, 0x54, 0x66, 0x43, 0x6c, 0x61, 0x73, 0x73,
0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1c, 0x2e, 0x61, 0x69, 0x2e, 0x54, 0x66, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56,
0x0a, 0x13, 0x43, 0x61, 0x66, 0x66, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x61, 0x69, 0x2e, 0x43, 0x61, 0x66, 0x66, 0x65,
0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x61, 0x69, 0x2e, 0x43, 0x61, 0x66, 0x66, 0x65,
0x43, 0x6c, 0x61, 0x73, 0x73, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46,
0x61, 0x63, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x1b, 0x2e, 0x61, 0x69, 0x2e,
0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x61, 0x63, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x61, 0x69, 0x2e, 0x51, 0x75, 0x65,
0x72, 0x79, 0x46, 0x61, 0x63, 0x65, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46,
0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x2e, 0x61, 0x69, 0x2e, 0x4d, 0x6f, 0x64,
0x69, 0x66, 0x79, 0x46, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x69, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61,
0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47,
0x0a, 0x0e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65,
0x12, 0x19, 0x2e, 0x61, 0x69, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61, 0x63, 0x65,
0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x69,
0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
@@ -377,7 +808,7 @@ func file_aisvc_proto_rawDescGZIP() []byte {
return file_aisvc_proto_rawDescData
}
var file_aisvc_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_aisvc_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_aisvc_proto_goTypes = []any{
(*FaceRecognitionRequest)(nil), // 0: ai.FaceRecognitionRequest
(*FaceRecognitionResponse)(nil), // 1: ai.FaceRecognitionResponse
@@ -385,19 +816,33 @@ var file_aisvc_proto_goTypes = []any{
(*TfClassificationResponse)(nil), // 3: ai.TfClassificationResponse
(*CaffeClassificationRequest)(nil), // 4: ai.CaffeClassificationRequest
(*CaffeClassificationResponse)(nil), // 5: ai.CaffeClassificationResponse
(*QueryFaceLibraryRequest)(nil), // 6: ai.QueryFaceLibraryRequest
(*FaceLibrary)(nil), // 7: ai.FaceLibrary
(*QueryFaceLibraryResponse)(nil), // 8: ai.QueryFaceLibraryResponse
(*ModifyFaceNameRequest)(nil), // 9: ai.ModifyFaceNameRequest
(*ModifyFaceNameResponse)(nil), // 10: ai.ModifyFaceNameResponse
(*ModifyFaceTypeRequest)(nil), // 11: ai.ModifyFaceTypeRequest
(*ModifyFaceTypeResponse)(nil), // 12: ai.ModifyFaceTypeResponse
}
var file_aisvc_proto_depIdxs = []int32{
0, // 0: ai.AiService.FaceRecognition:input_type -> ai.FaceRecognitionRequest
2, // 1: ai.AiService.TfClassification:input_type -> ai.TfClassificationRequest
4, // 2: ai.AiService.CaffeClassification:input_type -> ai.CaffeClassificationRequest
1, // 3: ai.AiService.FaceRecognition:output_type -> ai.FaceRecognitionResponse
3, // 4: ai.AiService.TfClassification:output_type -> ai.TfClassificationResponse
5, // 5: ai.AiService.CaffeClassification:output_type -> ai.CaffeClassificationResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
7, // 0: ai.QueryFaceLibraryResponse.faces:type_name -> ai.FaceLibrary
0, // 1: ai.AiService.FaceRecognition:input_type -> ai.FaceRecognitionRequest
2, // 2: ai.AiService.TfClassification:input_type -> ai.TfClassificationRequest
4, // 3: ai.AiService.CaffeClassification:input_type -> ai.CaffeClassificationRequest
6, // 4: ai.AiService.QueryFaceLibrary:input_type -> ai.QueryFaceLibraryRequest
9, // 5: ai.AiService.ModifyFaceName:input_type -> ai.ModifyFaceNameRequest
11, // 6: ai.AiService.ModifyFaceType:input_type -> ai.ModifyFaceTypeRequest
1, // 7: ai.AiService.FaceRecognition:output_type -> ai.FaceRecognitionResponse
3, // 8: ai.AiService.TfClassification:output_type -> ai.TfClassificationResponse
5, // 9: ai.AiService.CaffeClassification:output_type -> ai.CaffeClassificationResponse
8, // 10: ai.AiService.QueryFaceLibrary:output_type -> ai.QueryFaceLibraryResponse
10, // 11: ai.AiService.ModifyFaceName:output_type -> ai.ModifyFaceNameResponse
12, // 12: ai.AiService.ModifyFaceType:output_type -> ai.ModifyFaceTypeResponse
7, // [7:13] is the sub-list for method output_type
1, // [1:7] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_aisvc_proto_init() }
@@ -411,7 +856,7 @@ func file_aisvc_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_aisvc_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumMessages: 13,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -22,6 +22,9 @@ const (
AiService_FaceRecognition_FullMethodName = "/ai.AiService/FaceRecognition"
AiService_TfClassification_FullMethodName = "/ai.AiService/TfClassification"
AiService_CaffeClassification_FullMethodName = "/ai.AiService/CaffeClassification"
AiService_QueryFaceLibrary_FullMethodName = "/ai.AiService/QueryFaceLibrary"
AiService_ModifyFaceName_FullMethodName = "/ai.AiService/ModifyFaceName"
AiService_ModifyFaceType_FullMethodName = "/ai.AiService/ModifyFaceType"
)
// AiServiceClient is the client API for AiService service.
@@ -34,6 +37,12 @@ type AiServiceClient interface {
TfClassification(ctx context.Context, in *TfClassificationRequest, opts ...grpc.CallOption) (*TfClassificationResponse, error)
// CaffeClassification
CaffeClassification(ctx context.Context, in *CaffeClassificationRequest, opts ...grpc.CallOption) (*CaffeClassificationResponse, error)
// QueryFaceLibrary
QueryFaceLibrary(ctx context.Context, in *QueryFaceLibraryRequest, opts ...grpc.CallOption) (*QueryFaceLibraryResponse, error)
// ModifyFaceName
ModifyFaceName(ctx context.Context, in *ModifyFaceNameRequest, opts ...grpc.CallOption) (*ModifyFaceNameResponse, error)
// ModifyFaceType
ModifyFaceType(ctx context.Context, in *ModifyFaceTypeRequest, opts ...grpc.CallOption) (*ModifyFaceTypeResponse, error)
}
type aiServiceClient struct {
@@ -74,6 +83,36 @@ func (c *aiServiceClient) CaffeClassification(ctx context.Context, in *CaffeClas
return out, nil
}
func (c *aiServiceClient) QueryFaceLibrary(ctx context.Context, in *QueryFaceLibraryRequest, opts ...grpc.CallOption) (*QueryFaceLibraryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(QueryFaceLibraryResponse)
err := c.cc.Invoke(ctx, AiService_QueryFaceLibrary_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *aiServiceClient) ModifyFaceName(ctx context.Context, in *ModifyFaceNameRequest, opts ...grpc.CallOption) (*ModifyFaceNameResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ModifyFaceNameResponse)
err := c.cc.Invoke(ctx, AiService_ModifyFaceName_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *aiServiceClient) ModifyFaceType(ctx context.Context, in *ModifyFaceTypeRequest, opts ...grpc.CallOption) (*ModifyFaceTypeResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ModifyFaceTypeResponse)
err := c.cc.Invoke(ctx, AiService_ModifyFaceType_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AiServiceServer is the server API for AiService service.
// All implementations must embed UnimplementedAiServiceServer
// for forward compatibility.
@@ -84,6 +123,12 @@ type AiServiceServer interface {
TfClassification(context.Context, *TfClassificationRequest) (*TfClassificationResponse, error)
// CaffeClassification
CaffeClassification(context.Context, *CaffeClassificationRequest) (*CaffeClassificationResponse, error)
// QueryFaceLibrary
QueryFaceLibrary(context.Context, *QueryFaceLibraryRequest) (*QueryFaceLibraryResponse, error)
// ModifyFaceName
ModifyFaceName(context.Context, *ModifyFaceNameRequest) (*ModifyFaceNameResponse, error)
// ModifyFaceType
ModifyFaceType(context.Context, *ModifyFaceTypeRequest) (*ModifyFaceTypeResponse, error)
mustEmbedUnimplementedAiServiceServer()
}
@@ -103,6 +148,15 @@ func (UnimplementedAiServiceServer) TfClassification(context.Context, *TfClassif
func (UnimplementedAiServiceServer) CaffeClassification(context.Context, *CaffeClassificationRequest) (*CaffeClassificationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CaffeClassification not implemented")
}
func (UnimplementedAiServiceServer) QueryFaceLibrary(context.Context, *QueryFaceLibraryRequest) (*QueryFaceLibraryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method QueryFaceLibrary not implemented")
}
func (UnimplementedAiServiceServer) ModifyFaceName(context.Context, *ModifyFaceNameRequest) (*ModifyFaceNameResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyFaceName not implemented")
}
func (UnimplementedAiServiceServer) ModifyFaceType(context.Context, *ModifyFaceTypeRequest) (*ModifyFaceTypeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ModifyFaceType not implemented")
}
func (UnimplementedAiServiceServer) mustEmbedUnimplementedAiServiceServer() {}
func (UnimplementedAiServiceServer) testEmbeddedByValue() {}
@@ -178,6 +232,60 @@ func _AiService_CaffeClassification_Handler(srv interface{}, ctx context.Context
return interceptor(ctx, in, info, handler)
}
func _AiService_QueryFaceLibrary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryFaceLibraryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AiServiceServer).QueryFaceLibrary(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AiService_QueryFaceLibrary_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AiServiceServer).QueryFaceLibrary(ctx, req.(*QueryFaceLibraryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AiService_ModifyFaceName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ModifyFaceNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AiServiceServer).ModifyFaceName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AiService_ModifyFaceName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AiServiceServer).ModifyFaceName(ctx, req.(*ModifyFaceNameRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AiService_ModifyFaceType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ModifyFaceTypeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AiServiceServer).ModifyFaceType(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AiService_ModifyFaceType_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AiServiceServer).ModifyFaceType(ctx, req.(*ModifyFaceTypeRequest))
}
return interceptor(ctx, in, info, handler)
}
// AiService_ServiceDesc is the grpc.ServiceDesc for AiService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -197,6 +305,18 @@ var AiService_ServiceDesc = grpc.ServiceDesc{
MethodName: "CaffeClassification",
Handler: _AiService_CaffeClassification_Handler,
},
{
MethodName: "QueryFaceLibrary",
Handler: _AiService_QueryFaceLibrary_Handler,
},
{
MethodName: "ModifyFaceName",
Handler: _AiService_ModifyFaceName_Handler,
},
{
MethodName: "ModifyFaceType",
Handler: _AiService_ModifyFaceType_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "aisvc.proto",

View File

@@ -255,35 +255,35 @@ service auth {
type (
// 评论提交请求参数
CommentRequest {
Content string `json:"content"`
Images []string `json:"images,optional"`
TopicId string `json:"topic_id"`
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
Content string `json:"content"`
Images string `json:"images,optional"`
TopicId string `json:"topic_id"`
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
}
// 回复评论提交请求参数
ReplyCommentRequest {
Content string `json:"content"`
Images []string `json:"images,optional"`
TopicId string `json:"topic_id" `
ReplyId int64 `json:"reply_id" `
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
Content string `json:"content"`
Images string `json:"images,optional"`
TopicId string `json:"topic_id" `
ReplyId int64 `json:"reply_id" `
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
}
// 回复回复请求参数
ReplyReplyRequest {
Content string `json:"content"`
Images []string `json:"images,optional"`
TopicId string `json:"topic_id"`
ReplyTo int64 `json:"reply_to"`
ReplyId int64 `json:"reply_id"`
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
Content string `json:"content"`
Images string `json:"images,optional"`
TopicId string `json:"topic_id"`
ReplyTo int64 `json:"reply_to"`
ReplyId int64 `json:"reply_id"`
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
}
// 评论列表请求参数
CommentListRequest {
@@ -314,26 +314,26 @@ type (
type (
// CommentContent 评论内容
CommentContent {
NickName string `json:"nickname"`
Avatar string `json:"avatar"`
Level int64 `json:"level,omitempty" default:"0"`
Id int64 `json:"id"`
UserId string `json:"user_id"`
TopicId string `json:"topic_id"`
Content string `json:"content"`
ReplyTo int64 `json:"reply_to,omitempty"`
ReplyId int64 `json:"reply_id,omitempty"`
ReplyUser string `json:"reply_user,omitempty"`
ReplyNickname string `json:"reply_nickname,omitempty"`
IsAuthor int64 `json:"is_author"`
Likes int64 `json:"likes"`
ReplyCount int64 `json:"reply_count"`
CreatedTime string `json:"created_time"`
Location string `json:"location"`
Browser string `json:"browser"`
OperatingSystem string `json:"operating_system"`
IsLiked bool `json:"is_liked" default:"false"`
Images []string `json:"images,omitempty"`
NickName string `json:"nickname"`
Avatar string `json:"avatar"`
Level int64 `json:"level,omitempty" default:"0"`
Id int64 `json:"id"`
UserId string `json:"user_id"`
TopicId string `json:"topic_id"`
Content string `json:"content"`
ReplyTo int64 `json:"reply_to,omitempty"`
ReplyId int64 `json:"reply_id,omitempty"`
ReplyUser string `json:"reply_user,omitempty"`
ReplyNickname string `json:"reply_nickname,omitempty"`
IsAuthor int64 `json:"is_author"`
Likes int64 `json:"likes"`
ReplyCount int64 `json:"reply_count"`
CreatedTime string `json:"created_time"`
Location string `json:"location"`
Browser string `json:"browser"`
OperatingSystem string `json:"operating_system"`
IsLiked bool `json:"is_liked" default:"false"`
Images string `json:"images,omitempty"`
}
// CommentListPageResponse 评论返回值
CommentListPageResponse {
@@ -365,7 +365,7 @@ type (
timeout: 10s // 超时时间
maxBytes: 1048576 // 最大请求大小
signature: false // 是否开启签名验证
middleware: SecurityHeadersMiddleware,CasbinVerifyMiddleware,AuthorizationMiddleware,NonceMiddleware // 注册中间件
middleware: SecurityHeadersMiddleware,CasbinVerifyMiddleware,NonceMiddleware // 注册中间件
MaxConns: true // 是否开启最大连接数限制
Recover: true // 是否开启自动恢复
jwt: Auth // 是否开启jwt验证
@@ -427,6 +427,28 @@ type (
Bucket string `json:"bucket"`
Region string `json:"region"`
}
FaceSampleLibrary {
ID int64 `json:"id"`
FaceName string `json:"face_name"`
FaceImage string `json:"face_image"`
}
FaceSampleLibraryListRequest {
Type int64 `json:"type"`
}
FaceSampleLibraryListResponse {
faces []FaceSampleLibrary `json:"faces"`
}
ModifyFaceNameRequestAndResponse {
ID int64 `json:"id"`
FaceName string `json:"face_name"`
}
ModifyFaceTypeRequest {
IDs []int64 `json:"ids"`
FaceType int64 `json:"face_type"`
}
ModifyFaceTypeResponse {
result string `json:"result"`
}
)
// 文件上传
@@ -436,7 +458,7 @@ type (
timeout: 20s // 超时时间
maxBytes: 104857600 // 最大请求大小
signature: false // 是否开启签名验证
middleware: SecurityHeadersMiddleware,CasbinVerifyMiddleware,AuthorizationMiddleware,NonceMiddleware // 注册中间件
middleware: SecurityHeadersMiddleware,CasbinVerifyMiddleware,NonceMiddleware // 注册中间件
MaxConns: true // 是否开启最大连接数限制
Recover: true // 是否开启自动恢复
jwt: Auth // 是否开启jwt验证
@@ -449,5 +471,17 @@ service auth {
// 设置存储配置
@handler setStorageConfig
post /config (StorageConfigRequest) returns (string)
// 获取人脸样本库列表
@handler getFaceSampleLibraryList
post /face/sample/list (FaceSampleLibraryListRequest) returns (FaceSampleLibraryListResponse)
// 修改人脸样本名称
@handler modifyFaceLibraryName
post /face/sample/modify/name (ModifyFaceNameRequestAndResponse) returns (ModifyFaceNameRequestAndResponse)
// 修改人脸样本类型
@handler modifyFaceLibraryType
post /face/sample/modify/type (ModifyFaceTypeRequest) returns (ModifyFaceTypeResponse)
}

View File

@@ -170,6 +170,17 @@ SMS:
Username: landaiqing
# 短信宝用户密码
Password: $LDQ20020618xxx$
# 高德地图配置
Map:
# 高德地图API Key
Key: 54823a494909959a9c8cd8af101bbc32
Key: 54823a494909959a9c8cd8af101bbc32
# Minio配置
Minio:
# Minio 地址
Endpoint: 1.95.0.111:9000
# Minio 访问密钥
AccessKeyID: JNLVxMGro1XXwajodLBX
# Minio 访问密钥
SecretAccessKey: XEHkwExqQdAlEPfpRk36xpc0Sie8hZkcmlhXQJXw
# Minio 使用SSL
UseSSL: false

View File

@@ -74,4 +74,10 @@ type Config struct {
Map struct {
Key string
}
Minio struct {
Endpoint string
AccessKeyID string
SecretAccessKey string
UseSSL bool
}
}

View File

@@ -62,7 +62,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware, serverCtx.CasbinVerifyMiddleware, serverCtx.AuthorizationMiddleware, serverCtx.NonceMiddleware},
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware, serverCtx.CasbinVerifyMiddleware, serverCtx.NonceMiddleware},
[]rest.Route{
{
Method: http.MethodPost,
@@ -186,13 +186,28 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware, serverCtx.CasbinVerifyMiddleware, serverCtx.AuthorizationMiddleware, serverCtx.NonceMiddleware},
[]rest.Middleware{serverCtx.SecurityHeadersMiddleware, serverCtx.CasbinVerifyMiddleware, serverCtx.NonceMiddleware},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/config",
Handler: storage.SetStorageConfigHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/face/sample/list",
Handler: storage.GetFaceSampleLibraryListHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/face/sample/modify/name",
Handler: storage.ModifyFaceLibraryNameHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/face/sample/modify/type",
Handler: storage.ModifyFaceLibraryTypeHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/uploads",

View File

@@ -0,0 +1,29 @@
package storage
import (
"github.com/zeromicro/go-zero/rest/httpx"
"net/http"
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
"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 GetFaceSampleLibraryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.FaceSampleLibraryListRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := storage.NewGetFaceSampleLibraryListLogic(r.Context(), svcCtx)
resp, err := l.GetFaceSampleLibraryList(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -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 ModifyFaceLibraryNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ModifyFaceNameRequestAndResponse
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := storage.NewModifyFaceLibraryNameLogic(r.Context(), svcCtx)
resp, err := l.ModifyFaceLibraryName(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -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 ModifyFaceLibraryTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ModifyFaceTypeRequest
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := storage.NewModifyFaceLibraryTypeLogic(r.Context(), svcCtx)
resp, err := l.ModifyFaceLibraryType(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -34,7 +34,7 @@ func (l *GenerateClientIdLogic) GenerateClientId(clientIP string) (resp string,
return clientId, nil
}
simpleUuid := kgo.SimpleUuid()
if err = l.svcCtx.RedisClient.SetEx(l.ctx, constant.UserClientPrefix+clientIP, simpleUuid, time.Hour*24*7).Err(); err != nil {
if err = l.svcCtx.RedisClient.SetEx(l.ctx, constant.UserClientPrefix+clientIP, simpleUuid, time.Hour*24*3).Err(); err != nil {
return "", errors.New(http.StatusInternalServerError, err.Error())
}
return simpleUuid, nil

View File

@@ -2,17 +2,14 @@ package comment
import (
"context"
"encoding/base64"
"errors"
"fmt"
"net/url"
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
"schisandra-album-cloud-microservices/app/auth/model/mongodb"
"schisandra-album-cloud-microservices/common/constant"
"schisandra-album-cloud-microservices/common/utils"
"sync"
"time"
"github.com/chenmingyong0423/go-mongox/v2/builder/query"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gen/field"
)
@@ -60,6 +57,7 @@ func (l *GetCommentListLogic) GetCommentList(req *types.CommentListRequest) (res
comment.Browser,
comment.OperatingSystem,
comment.Location,
comment.ImagePath,
user.Avatar,
user.Nickname,
).LeftJoin(user, comment.UserID.EqCol(user.UID)).
@@ -82,7 +80,7 @@ func (l *GetCommentListLogic) GetCommentList(req *types.CommentListRequest) (res
for _, commentList := range commentQueryList {
commentIds = append(commentIds, commentList.ID)
}
l.wg.Add(2)
l.wg.Add(1)
// *************** 获取评论点赞状态 **********
likeMap := make(map[int64]bool)
@@ -102,36 +100,22 @@ func (l *GetCommentListLogic) GetCommentList(req *types.CommentListRequest) (res
likeMap[like.CommentID] = true
}
}()
// ***************获取评论图片 **********
commentImageMap := make(map[int64][]string)
go func() {
defer l.wg.Done()
newCollection := mongodb.MustNewCollection[types.CommentImages](l.svcCtx.MongoClient, constant.COMMENT_IMAGES)
commentImages, err := newCollection.Finder().
Filter(query.Eq("topic_id", req.TopicId)).
Filter(query.In("comment_id", commentIds...)).
Find(l.ctx)
if err != nil {
logx.Error(err)
return
}
for _, image := range commentImages {
if len(image.Images) == 0 {
continue
}
imagesBase64 := make([]string, len(image.Images))
for i, img := range image.Images {
imagesBase64[i] = fmt.Sprintf("data:%s;base64,%s", utils.GetMimeType(img), base64.StdEncoding.EncodeToString(img))
}
commentImageMap[image.CommentId] = imagesBase64
}
}()
l.wg.Wait()
// *************** 组装数据 **********
result := make([]types.CommentContent, 0, len(commentQueryList))
for _, commentData := range commentQueryList {
var imagePath string
if commentData.ImagePath != "" {
reqParams := make(url.Values)
presignedURL, err := l.svcCtx.MinioClient.PresignedGetObject(l.ctx, constant.CommentImagesBucketName, commentData.ImagePath, time.Hour*24, reqParams)
if err != nil {
logx.Error(err)
continue
}
imagePath = presignedURL.String()
}
commentContent := types.CommentContent{
Avatar: commentData.Avatar,
NickName: commentData.Nickname,
@@ -148,7 +132,7 @@ func (l *GetCommentListLogic) GetCommentList(req *types.CommentListRequest) (res
Browser: commentData.Browser,
OperatingSystem: commentData.OperatingSystem,
IsLiked: likeMap[commentData.ID],
Images: commentImageMap[commentData.ID],
Images: imagePath,
}
result = append(result, commentContent)
}

View File

@@ -2,17 +2,13 @@ package comment
import (
"context"
"encoding/base64"
"errors"
"fmt"
"net/url"
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
"schisandra-album-cloud-microservices/app/auth/model/mongodb"
"schisandra-album-cloud-microservices/common/constant"
"schisandra-album-cloud-microservices/common/utils"
"sync"
"github.com/chenmingyong0423/go-mongox/v2/builder/query"
"time"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -59,6 +55,7 @@ func (l *GetReplyListLogic) GetReplyList(req *types.ReplyListRequest) (resp *typ
reply.ReplyUser,
reply.ReplyTo,
reply.ReplyID,
reply.ImagePath,
commentUser.Avatar,
commentUser.Nickname,
replyUser.Nickname.As("reply_nickname"),
@@ -82,7 +79,7 @@ func (l *GetReplyListLogic) GetReplyList(req *types.ReplyListRequest) (resp *typ
for _, commentList := range replyQueryList {
commentIds = append(commentIds, commentList.ID)
}
l.wg.Add(2)
l.wg.Add(1)
// *************** 获取评论点赞状态 **********
likeMap := make(map[int64]bool)
@@ -102,36 +99,22 @@ func (l *GetReplyListLogic) GetReplyList(req *types.ReplyListRequest) (resp *typ
likeMap[like.CommentID] = true
}
}()
// ***************获取评论图片 **********
commentImageMap := make(map[int64][]string)
go func() {
defer l.wg.Done()
newCollection := mongodb.MustNewCollection[types.CommentImages](l.svcCtx.MongoClient, constant.COMMENT_IMAGES)
commentImages, err := newCollection.Finder().
Filter(query.Eq("topic_id", req.TopicId)).
Filter(query.In("comment_id", commentIds...)).
Find(l.ctx)
if err != nil {
logx.Error(err)
return
}
for _, image := range commentImages {
if len(image.Images) == 0 {
continue
}
imagesBase64 := make([]string, len(image.Images))
for i, img := range image.Images {
imagesBase64[i] = fmt.Sprintf("data:%s;base64,%s", utils.GetMimeType(img), base64.StdEncoding.EncodeToString(img))
}
commentImageMap[image.CommentId] = imagesBase64
}
}()
l.wg.Wait()
// *************** 组装数据 **********
result := make([]types.CommentContent, 0, len(replyQueryList))
for _, replyData := range replyQueryList {
var imagePath string
if replyData.ImagePath != "" {
reqParams := make(url.Values)
presignedURL, err := l.svcCtx.MinioClient.PresignedGetObject(l.ctx, constant.CommentImagesBucketName, replyData.ImagePath, time.Hour*24, reqParams)
if err != nil {
logx.Error(err)
continue
}
imagePath = presignedURL.String()
}
commentContent := types.CommentContent{
Avatar: replyData.Avatar,
NickName: replyData.Nickname,
@@ -148,7 +131,7 @@ func (l *GetReplyListLogic) GetReplyList(req *types.ReplyListRequest) (resp *typ
Browser: replyData.Browser,
OperatingSystem: replyData.OperatingSystem,
IsLiked: likeMap[replyData.ID],
Images: commentImageMap[replyData.ID],
Images: imagePath,
ReplyUser: replyData.ReplyUser,
ReplyTo: replyData.ReplyTo,
ReplyId: replyData.ReplyId,

View File

@@ -1,13 +1,18 @@
package comment
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/ccpwcn/kgo"
"github.com/minio/minio-go/v7"
"net/http"
"path"
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
"schisandra-album-cloud-microservices/app/auth/model/mongodb"
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
"strconv"
"schisandra-album-cloud-microservices/common/captcha/verify"
"schisandra-album-cloud-microservices/common/constant"
@@ -41,9 +46,6 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
if !res {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "captcha.verificationFailure"))
}
if len(req.Images) > 3 {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "comment.tooManyImages"))
}
userAgent := r.Header.Get("User-Agent")
if userAgent == "" {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "comment.commentError"))
@@ -74,6 +76,7 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
commentContent := l.svcCtx.Sensitive.Replace(xssFilterContent, '*')
topicType := constant.CommentTopicType
commentType := constant.COMMENT
commentReply := l.svcCtx.DB.ScaCommentReply
comment := &model.ScaCommentReply{
Content: commentContent,
UserID: uid,
@@ -87,28 +90,52 @@ func (l *SubmitCommentLogic) SubmitComment(r *http.Request, req *types.CommentRe
OperatingSystem: operatingSystem,
Agent: userAgent,
}
err = l.svcCtx.DB.ScaCommentReply.Create(comment)
err = commentReply.Create(comment)
if err != nil {
return nil, err
}
if len(req.Images) > 0 {
imagesData, err := utils.ProcessImages(req.Images)
if req.Images != "" {
imagesData, err := utils.Base64ToBytes(req.Images)
if err != nil {
return nil, err
}
commentImages := &types.CommentImages{
UserId: uid,
TopicId: req.TopicId,
CommentId: comment.ID,
Images: imagesData,
objectKey := path.Join(
req.TopicId,
time.Now().Format("2006/01"), // 按年/月划分目录
strconv.FormatInt(comment.ID, 10),
fmt.Sprintf("%s_%s.jpg", uid, kgo.SimpleUuid()),
)
exists, err := l.svcCtx.MinioClient.BucketExists(l.ctx, constant.CommentImagesBucketName)
if err != nil || !exists {
err = l.svcCtx.MinioClient.MakeBucket(l.ctx, constant.CommentImagesBucketName, minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
if err != nil {
logx.Errorf("Failed to create MinIO bucket: %v", err)
return nil, err
}
}
newCollection := mongodb.MustNewCollection[types.CommentImages](l.svcCtx.MongoClient, constant.COMMENT_IMAGES)
_, err = newCollection.Creator().InsertOne(l.ctx, commentImages)
// 上传到MinIO
_, err = l.svcCtx.MinioClient.PutObject(
l.ctx,
constant.CommentImagesBucketName,
objectKey,
bytes.NewReader(imagesData),
int64(len(imagesData)),
minio.PutObjectOptions{
ContentType: "image/jpeg",
},
)
if err != nil {
logx.Errorf("Failed to upload image to MinIO: %v", err)
return nil, err
}
info, err := commentReply.Where(commentReply.ID.Eq(comment.ID)).Update(commentReply.ImagePath, objectKey)
if err != nil || info.RowsAffected == 0 {
return nil, errors.New("update image path failed")
}
}
commentResponse := &types.CommentResponse{
Id: comment.ID,

View File

@@ -1,18 +1,23 @@
package comment
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/ccpwcn/kgo"
"github.com/minio/minio-go/v7"
"net/http"
"path"
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
"schisandra-album-cloud-microservices/app/auth/model/mongodb"
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
"schisandra-album-cloud-microservices/common/captcha/verify"
"schisandra-album-cloud-microservices/common/constant"
errors2 "schisandra-album-cloud-microservices/common/errors"
"schisandra-album-cloud-microservices/common/i18n"
"schisandra-album-cloud-microservices/common/utils"
"strconv"
"time"
"github.com/mssola/useragent"
@@ -39,9 +44,6 @@ func (l *SubmitReplyCommentLogic) SubmitReplyComment(r *http.Request, req *types
if !res {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "captcha.verificationFailure"))
}
if len(req.Images) > 3 {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "comment.tooManyImages"))
}
userAgent := r.Header.Get("User-Agent")
if userAgent == "" {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "comment.commentError"))
@@ -105,24 +107,47 @@ func (l *SubmitReplyCommentLogic) SubmitReplyComment(r *http.Request, req *types
}
if len(req.Images) > 0 {
imagesData, err := utils.ProcessImages(req.Images)
if req.Images != "" {
imagesData, err := utils.Base64ToBytes(req.Images)
if err != nil {
return nil, err
}
objectKey := path.Join(
req.TopicId,
time.Now().Format("2006/01"), // 按年/月划分目录
strconv.FormatInt(reply.ID, 10),
fmt.Sprintf("%s_%s.jpg", uid, kgo.SimpleUuid()),
)
commentImages := &types.CommentImages{
UserId: uid,
TopicId: req.TopicId,
CommentId: reply.ID,
Images: imagesData,
exists, err := l.svcCtx.MinioClient.BucketExists(l.ctx, constant.CommentImagesBucketName)
if err != nil || !exists {
err = l.svcCtx.MinioClient.MakeBucket(l.ctx, constant.CommentImagesBucketName, minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
if err != nil {
logx.Errorf("Failed to create MinIO bucket: %v", err)
return nil, err
}
}
newCollection := mongodb.MustNewCollection[types.CommentImages](l.svcCtx.MongoClient, constant.COMMENT_IMAGES)
_, err = newCollection.Creator().InsertOne(l.ctx, commentImages)
// 上传到MinIO
_, err = l.svcCtx.MinioClient.PutObject(
l.ctx,
constant.CommentImagesBucketName,
objectKey,
bytes.NewReader(imagesData),
int64(len(imagesData)),
minio.PutObjectOptions{
ContentType: "image/jpeg",
},
)
if err != nil {
logx.Errorf("Failed to upload image to MinIO: %v", err)
return nil, err
}
info, err := commentReply.Where(commentReply.ID.Eq(reply.ID)).Update(commentReply.ImagePath, objectKey)
if err != nil || info.RowsAffected == 0 {
return nil, errors.New("update image path failed")
}
}
commentResponse := &types.CommentResponse{

View File

@@ -1,18 +1,23 @@
package comment
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/ccpwcn/kgo"
"github.com/minio/minio-go/v7"
"net/http"
"path"
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
"schisandra-album-cloud-microservices/app/auth/model/mongodb"
"schisandra-album-cloud-microservices/app/auth/model/mysql/model"
"schisandra-album-cloud-microservices/common/captcha/verify"
"schisandra-album-cloud-microservices/common/constant"
errors2 "schisandra-album-cloud-microservices/common/errors"
"schisandra-album-cloud-microservices/common/i18n"
"schisandra-album-cloud-microservices/common/utils"
"strconv"
"time"
"github.com/mssola/useragent"
@@ -39,9 +44,6 @@ func (l *SubmitReplyReplyLogic) SubmitReplyReply(r *http.Request, req *types.Rep
if !res {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "captcha.verificationFailure"))
}
if len(req.Images) > 3 {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "comment.tooManyImages"))
}
userAgent := r.Header.Get("User-Agent")
if userAgent == "" {
return nil, errors2.New(http.StatusInternalServerError, i18n.FormatText(l.ctx, "comment.commentError"))
@@ -112,24 +114,47 @@ func (l *SubmitReplyReplyLogic) SubmitReplyReply(r *http.Request, req *types.Rep
}
// 处理图片
if len(req.Images) > 0 {
imagesData, err := utils.ProcessImages(req.Images)
if req.Images != "" {
imagesData, err := utils.Base64ToBytes(req.Images)
if err != nil {
return nil, err
}
commentImages := &types.CommentImages{
UserId: uid,
TopicId: req.TopicId,
CommentId: replyReply.ID,
Images: imagesData,
objectKey := path.Join(
req.TopicId,
time.Now().Format("2006/01"), // 按年/月划分目录
strconv.FormatInt(replyReply.ID, 10),
fmt.Sprintf("%s_%s.jpg", uid, kgo.SimpleUuid()),
)
exists, err := l.svcCtx.MinioClient.BucketExists(l.ctx, constant.CommentImagesBucketName)
if err != nil || !exists {
err = l.svcCtx.MinioClient.MakeBucket(l.ctx, constant.CommentImagesBucketName, minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
if err != nil {
logx.Errorf("Failed to create MinIO bucket: %v", err)
return nil, err
}
}
newCollection := mongodb.MustNewCollection[types.CommentImages](l.svcCtx.MongoClient, constant.COMMENT_IMAGES)
_, err = newCollection.Creator().InsertOne(l.ctx, commentImages)
// 上传到MinIO
_, err = l.svcCtx.MinioClient.PutObject(
l.ctx,
constant.CommentImagesBucketName,
objectKey,
bytes.NewReader(imagesData),
int64(len(imagesData)),
minio.PutObjectOptions{
ContentType: "image/jpeg",
},
)
if err != nil {
logx.Errorf("Failed to upload image to MinIO: %v", err)
return nil, err
}
info, err := commentReply.Where(commentReply.ID.Eq(replyReply.ID)).Update(commentReply.ImagePath, objectKey)
if err != nil || info.RowsAffected == 0 {
return nil, errors.New("update image path failed")
}
}
// 构建响应

View File

@@ -0,0 +1,48 @@
package storage
import (
"context"
"errors"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
"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 GetFaceSampleLibraryListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetFaceSampleLibraryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetFaceSampleLibraryListLogic {
return &GetFaceSampleLibraryListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetFaceSampleLibraryListLogic) GetFaceSampleLibraryList(req *types.FaceSampleLibraryListRequest) (resp *types.FaceSampleLibraryListResponse, err error) {
uid, ok := l.ctx.Value("user_id").(string)
if !ok {
return nil, errors.New("user_id not found")
}
faceLibrary, err := l.svcCtx.AiSvcRpc.QueryFaceLibrary(l.ctx, &pb.QueryFaceLibraryRequest{UserId: uid, Type: req.Type})
if err != nil {
return nil, err
}
var faceSampleLibraries []types.FaceSampleLibrary
for _, face := range faceLibrary.GetFaces() {
faceSampleLibraries = append(faceSampleLibraries, types.FaceSampleLibrary{
ID: face.GetId(),
FaceName: face.GetFaceName(),
FaceImage: face.GetFaceImage(),
})
}
return &types.FaceSampleLibraryListResponse{
Faces: faceSampleLibraries,
}, nil
}

View File

@@ -0,0 +1,38 @@
package storage
import (
"context"
"errors"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
"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 ModifyFaceLibraryNameLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewModifyFaceLibraryNameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyFaceLibraryNameLogic {
return &ModifyFaceLibraryNameLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ModifyFaceLibraryNameLogic) ModifyFaceLibraryName(req *types.ModifyFaceNameRequestAndResponse) (resp *types.ModifyFaceNameRequestAndResponse, err error) {
uid, ok := l.ctx.Value("user_id").(string)
if !ok {
return nil, errors.New("user_id not found")
}
faceInfo, err := l.svcCtx.AiSvcRpc.ModifyFaceName(l.ctx, &pb.ModifyFaceNameRequest{UserId: uid, FaceId: req.ID, FaceName: req.FaceName})
if err != nil {
return nil, err
}
return &types.ModifyFaceNameRequestAndResponse{ID: faceInfo.GetFaceId(), FaceName: faceInfo.GetFaceName()}, nil
}

View File

@@ -0,0 +1,46 @@
package storage
import (
"context"
"errors"
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
"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 ModifyFaceLibraryTypeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewModifyFaceLibraryTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyFaceLibraryTypeLogic {
return &ModifyFaceLibraryTypeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ModifyFaceLibraryTypeLogic) ModifyFaceLibraryType(req *types.ModifyFaceTypeRequest) (resp *types.ModifyFaceTypeResponse, err error) {
uid, ok := l.ctx.Value("user_id").(string)
if !ok {
return nil, errors.New("user_id not found")
}
faceInfo, err := l.svcCtx.AiSvcRpc.ModifyFaceType(l.ctx, &pb.ModifyFaceTypeRequest{UserId: uid, FaceId: req.IDs, Type: req.FaceType})
if err != nil {
return nil, err
}
storageInfo := l.svcCtx.DB.ScaStorageInfo
resultInfo, err := storageInfo.Where(storageInfo.FaceID.In(req.IDs...)).Update(storageInfo.Hide, req.FaceType)
if err != nil {
return nil, err
}
if resultInfo.RowsAffected != int64(len(req.IDs)) {
return nil, errors.New("update failed")
}
return &types.ModifyFaceTypeResponse{Result: faceInfo.Result}, nil
}

View File

@@ -1,20 +0,0 @@
package middleware
import (
"net/http"
"schisandra-album-cloud-microservices/common/middleware"
)
type AuthorizationMiddleware struct {
}
func NewAuthorizationMiddleware() *AuthorizationMiddleware {
return &AuthorizationMiddleware{}
}
func (m *AuthorizationMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
middleware.AuthorizationMiddleware(w, r)
next(w, r)
}
}

View File

@@ -4,23 +4,23 @@ import (
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount"
"github.com/casbin/casbin/v2"
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
"github.com/minio/minio-go/v7"
"github.com/redis/go-redis/v9"
"github.com/wenlng/go-captcha/v2/rotate"
"github.com/wenlng/go-captcha/v2/slide"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
sensitive "github.com/zmexing/go-sensitive-word"
"go.mongodb.org/mongo-driver/v2/mongo"
"schisandra-album-cloud-microservices/app/aisvc/rpc/client/aiservice"
"schisandra-album-cloud-microservices/app/auth/api/internal/config"
"schisandra-album-cloud-microservices/app/auth/api/internal/middleware"
"schisandra-album-cloud-microservices/app/auth/model/mongodb"
"schisandra-album-cloud-microservices/app/auth/model/mysql"
"schisandra-album-cloud-microservices/app/auth/model/mysql/query"
"schisandra-album-cloud-microservices/common/captcha/initialize"
"schisandra-album-cloud-microservices/common/casbinx"
"schisandra-album-cloud-microservices/common/gao_map"
"schisandra-album-cloud-microservices/common/ip2region"
"schisandra-album-cloud-microservices/common/miniox"
"schisandra-album-cloud-microservices/common/redisx"
"schisandra-album-cloud-microservices/common/sensitivex"
"schisandra-album-cloud-microservices/common/storage"
@@ -33,19 +33,18 @@ type ServiceContext struct {
AiSvcRpc aiservice.AiService
SecurityHeadersMiddleware rest.Middleware
CasbinVerifyMiddleware rest.Middleware
AuthorizationMiddleware rest.Middleware
NonceMiddleware rest.Middleware
DB *query.Query
RedisClient *redis.Client
Ip2Region *xdb.Searcher
CasbinEnforcer *casbin.SyncedCachedEnforcer
WechatOfficial *officialAccount.OfficialAccount
MongoClient *mongo.Database
RotateCaptcha rotate.Captcha
SlideCaptcha slide.Captcha
Sensitive *sensitive.Manager
StorageManager *manager.Manager
GaoMap *gao_map.AmapClient
MinioClient *minio.Client
}
func NewServiceContext(c config.Config) *ServiceContext {
@@ -56,7 +55,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
Config: c,
SecurityHeadersMiddleware: middleware.NewSecurityHeadersMiddleware().Handle,
CasbinVerifyMiddleware: middleware.NewCasbinVerifyMiddleware(casbinEnforcer).Handle,
AuthorizationMiddleware: middleware.NewAuthorizationMiddleware().Handle,
NonceMiddleware: middleware.NewNonceMiddleware(redisClient).Handle,
DB: queryDB,
RedisClient: redisClient,
@@ -65,10 +63,10 @@ func NewServiceContext(c config.Config) *ServiceContext {
WechatOfficial: wechat_official.NewWechatPublic(c.Wechat.AppID, c.Wechat.AppSecret, c.Wechat.Token, c.Wechat.AESKey, c.Redis.Host, c.Redis.Pass, c.Redis.DB),
RotateCaptcha: initialize.NewRotateCaptcha(),
SlideCaptcha: initialize.NewSlideCaptcha(),
MongoClient: mongodb.NewMongoDB(c.Mongo.Uri, c.Mongo.Username, c.Mongo.Password, c.Mongo.AuthSource, c.Mongo.Database),
Sensitive: sensitivex.NewSensitive(),
StorageManager: storage.InitStorageManager(),
GaoMap: gao_map.NewAmapClient(c.Map.Key, ""),
AiSvcRpc: aiservice.NewAiService(zrpc.MustNewClient(c.AiSvcRpc)),
MinioClient: miniox.NewMinio(c.Minio.Endpoint, c.Minio.AccessKeyID, c.Minio.SecretAccessKey, c.Minio.UseSSL),
}
}

View File

@@ -2,19 +2,8 @@ package types
import (
"time"
"github.com/chenmingyong0423/go-mongox/v2"
)
// CommentImages 评论 图片
type CommentImages struct {
mongox.Model `bson:",inline"`
TopicId string `json:"topic_id" bson:"topic_id"`
CommentId int64 `json:"comment_id" bson:"comment_id"`
UserId string `json:"user_id" bson:"user_id"`
Images [][]byte `json:"images" bson:"images"`
}
// CommentListQueryResult 评论列表查询结果
type CommentListQueryResult struct {
ID int64 `json:"id"`
@@ -30,6 +19,7 @@ type CommentListQueryResult struct {
Location string `json:"location"`
Avatar string `json:"avatar"`
Nickname string `json:"nickname"`
ImagePath string `json:"image_path"`
}
// ReplyListQueryResult 回复列表查询结果
@@ -51,4 +41,5 @@ type ReplyListQueryResult struct {
ReplyId int64 `json:"reply_id"`
ReplyTo int64 `json:"reply_to"`
ReplyNickname string `json:"reply_nickname"`
ImagePath string `json:"image_path"`
}

View File

@@ -12,26 +12,26 @@ type AccountLoginRequest struct {
}
type CommentContent struct {
NickName string `json:"nickname"`
Avatar string `json:"avatar"`
Level int64 `json:"level,omitempty" default:"0"`
Id int64 `json:"id"`
UserId string `json:"user_id"`
TopicId string `json:"topic_id"`
Content string `json:"content"`
ReplyTo int64 `json:"reply_to,omitempty"`
ReplyId int64 `json:"reply_id,omitempty"`
ReplyUser string `json:"reply_user,omitempty"`
ReplyNickname string `json:"reply_nickname,omitempty"`
IsAuthor int64 `json:"is_author"`
Likes int64 `json:"likes"`
ReplyCount int64 `json:"reply_count"`
CreatedTime string `json:"created_time"`
Location string `json:"location"`
Browser string `json:"browser"`
OperatingSystem string `json:"operating_system"`
IsLiked bool `json:"is_liked" default:"false"`
Images []string `json:"images,omitempty"`
NickName string `json:"nickname"`
Avatar string `json:"avatar"`
Level int64 `json:"level,omitempty" default:"0"`
Id int64 `json:"id"`
UserId string `json:"user_id"`
TopicId string `json:"topic_id"`
Content string `json:"content"`
ReplyTo int64 `json:"reply_to,omitempty"`
ReplyId int64 `json:"reply_id,omitempty"`
ReplyUser string `json:"reply_user,omitempty"`
ReplyNickname string `json:"reply_nickname,omitempty"`
IsAuthor int64 `json:"is_author"`
Likes int64 `json:"likes"`
ReplyCount int64 `json:"reply_count"`
CreatedTime string `json:"created_time"`
Location string `json:"location"`
Browser string `json:"browser"`
OperatingSystem string `json:"operating_system"`
IsLiked bool `json:"is_liked" default:"false"`
Images string `json:"images,omitempty"`
}
type CommentDisLikeRequest struct {
@@ -59,12 +59,12 @@ type CommentListRequest struct {
}
type CommentRequest struct {
Content string `json:"content"`
Images []string `json:"images,optional"`
TopicId string `json:"topic_id"`
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
Content string `json:"content"`
Images string `json:"images,optional"`
TopicId string `json:"topic_id"`
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
}
type CommentResponse struct {
@@ -82,6 +82,20 @@ type CommentResponse struct {
ReplyTo int64 `json:"reply_to,omitempty"`
}
type FaceSampleLibrary struct {
ID int64 `json:"id"`
FaceName string `json:"face_name"`
FaceImage string `json:"face_image"`
}
type FaceSampleLibraryListRequest struct {
Type int64 `json:"type"`
}
type FaceSampleLibraryListResponse struct {
Faces []FaceSampleLibrary `json:"faces"`
}
type LoginResponse struct {
AccessToken string `json:"access_token"`
ExpireAt int64 `json:"expire_at"`
@@ -92,6 +106,20 @@ type LoginResponse struct {
Status int64 `json:"status"`
}
type ModifyFaceNameRequestAndResponse struct {
ID int64 `json:"id"`
FaceName string `json:"face_name"`
}
type ModifyFaceTypeRequest struct {
IDs []int64 `json:"ids"`
FaceType int64 `json:"face_type"`
}
type ModifyFaceTypeResponse struct {
Result string `json:"result"`
}
type OAuthCallbackRequest struct {
Code string `form:"code"`
}
@@ -116,14 +144,14 @@ type RefreshTokenResponse struct {
}
type ReplyCommentRequest struct {
Content string `json:"content"`
Images []string `json:"images,optional"`
TopicId string `json:"topic_id" `
ReplyId int64 `json:"reply_id" `
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
Content string `json:"content"`
Images string `json:"images,optional"`
TopicId string `json:"topic_id" `
ReplyId int64 `json:"reply_id" `
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
}
type ReplyListRequest struct {
@@ -134,15 +162,15 @@ type ReplyListRequest struct {
}
type ReplyReplyRequest struct {
Content string `json:"content"`
Images []string `json:"images,optional"`
TopicId string `json:"topic_id"`
ReplyTo int64 `json:"reply_to"`
ReplyId int64 `json:"reply_id"`
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
Content string `json:"content"`
Images string `json:"images,optional"`
TopicId string `json:"topic_id"`
ReplyTo int64 `json:"reply_to"`
ReplyId int64 `json:"reply_id"`
ReplyUser string `json:"reply_user" `
Author string `json:"author"`
Key string `json:"key"`
Point []int64 `json:"point"`
}
type ResetPasswordRequest struct {

View File

@@ -1,12 +0,0 @@
package mongodb
import (
"github.com/chenmingyong0423/go-mongox/v2"
"go.mongodb.org/mongo-driver/v2/mongo"
)
// MustNewCollection creates a new Collection instance with the given name.
func MustNewCollection[T any](mongoClient *mongo.Database, collectionName string) *mongox.Collection[T] {
collection := mongoClient.Collection(collectionName)
return mongox.NewCollection[T](collection)
}

View File

@@ -1,26 +0,0 @@
package mongodb
import (
"context"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
)
// NewMongoDB initializes the MongoDB connection and returns the database object
func NewMongoDB(uri string, username string, password string, authSource string, database string) *mongo.Database {
client, err := mongo.Connect(options.Client().ApplyURI(uri).SetAuth(options.Credential{
Username: username,
Password: password,
AuthSource: authSource,
}))
if err != nil {
panic(err)
}
err = client.Ping(context.Background(), readpref.Primary())
if err != nil {
panic(err)
}
db := client.Database(database)
return db
}

View File

@@ -115,6 +115,7 @@ func main() {
scaUserFollows := g.GenerateModel("sca_user_follows", fieldOpts...)
scaUserLevel := g.GenerateModel("sca_user_level", fieldOpts...)
scaUserMessage := g.GenerateModel("sca_user_message", fieldOpts...)
scaStorageAlbum := g.GenerateModel("sca_storage_album", fieldOpts...)
g.ApplyBasic(
scaAuthMenu,
@@ -133,6 +134,7 @@ func main() {
scaUserFollows,
scaUserLevel,
scaUserMessage,
scaStorageAlbum,
)
g.Execute()

View File

@@ -27,6 +27,7 @@ type ScaCommentReply struct {
Author int64 `gorm:"column:author;type:tinyint(4);comment:评论回复是否作者 0否 1是" json:"author"` // 评论回复是否作者 0否 1是
Likes int64 `gorm:"column:likes;type:bigint(20);comment:点赞数" json:"likes"` // 点赞数
ReplyCount int64 `gorm:"column:reply_count;type:bigint(20);comment:回复数量" json:"reply_count"` // 回复数量
ImagePath string `gorm:"column:image_path;type:text;comment:评论图片地址" json:"image_path"` // 评论图片地址
Browser string `gorm:"column:browser;type:varchar(50);comment:浏览器" json:"browser"` // 浏览器
OperatingSystem string `gorm:"column:operating_system;type:varchar(50);comment:操作系统" json:"operating_system"` // 操作系统
CommentIP string `gorm:"column:comment_ip;type:varchar(50);comment:IP地址" json:"comment_ip"` // IP地址

View File

@@ -0,0 +1,29 @@
// 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 TableNameScaStorageAlbum = "sca_storage_album"
// ScaStorageAlbum mapped from table <sca_storage_album>
type ScaStorageAlbum 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
AlbumName string `gorm:"column:album_name;type:varchar(50);comment:相册名称" json:"album_name"` // 相册名称
AlbumType string `gorm:"column:album_type;type:varchar(50);comment:相册类型" json:"album_type"` // 相册类型
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 ScaStorageAlbum's table name
func (*ScaStorageAlbum) TableName() string {
return TableNameScaStorageAlbum
}

View File

@@ -34,6 +34,8 @@ type ScaStorageInfo struct {
Gps string `gorm:"column:gps;type:varchar(255);comment:GPS" json:"gps"` // GPS
Screenshot string `gorm:"column:screenshot;type:varchar(50);comment:是否是截图" json:"screenshot"` // 是否是截图
Exif string `gorm:"column:exif;type:json;comment:exif 信息" json:"exif"` // exif 信息
Hide int64 `gorm:"column:hide;type:int(11) unsigned zerofill;comment:是否隐藏0 不隐藏 1 隐藏)" json:"hide"` // 是否隐藏0 不隐藏 1 隐藏)
AlbumID int64 `gorm:"column:album_id;type:bigint(20);comment:相册ID" json:"album_id"` // 相册ID
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"` // 删除时间

View File

@@ -26,6 +26,7 @@ var (
ScaCommentLike *scaCommentLike
ScaCommentReply *scaCommentReply
ScaMessageReport *scaMessageReport
ScaStorageAlbum *scaStorageAlbum
ScaStorageConfig *scaStorageConfig
ScaStorageInfo *scaStorageInfo
ScaStorageTag *scaStorageTag
@@ -46,6 +47,7 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
ScaCommentLike = &Q.ScaCommentLike
ScaCommentReply = &Q.ScaCommentReply
ScaMessageReport = &Q.ScaMessageReport
ScaStorageAlbum = &Q.ScaStorageAlbum
ScaStorageConfig = &Q.ScaStorageConfig
ScaStorageInfo = &Q.ScaStorageInfo
ScaStorageTag = &Q.ScaStorageTag
@@ -67,6 +69,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
ScaCommentLike: newScaCommentLike(db, opts...),
ScaCommentReply: newScaCommentReply(db, opts...),
ScaMessageReport: newScaMessageReport(db, opts...),
ScaStorageAlbum: newScaStorageAlbum(db, opts...),
ScaStorageConfig: newScaStorageConfig(db, opts...),
ScaStorageInfo: newScaStorageInfo(db, opts...),
ScaStorageTag: newScaStorageTag(db, opts...),
@@ -89,6 +92,7 @@ type Query struct {
ScaCommentLike scaCommentLike
ScaCommentReply scaCommentReply
ScaMessageReport scaMessageReport
ScaStorageAlbum scaStorageAlbum
ScaStorageConfig scaStorageConfig
ScaStorageInfo scaStorageInfo
ScaStorageTag scaStorageTag
@@ -112,6 +116,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
ScaCommentLike: q.ScaCommentLike.clone(db),
ScaCommentReply: q.ScaCommentReply.clone(db),
ScaMessageReport: q.ScaMessageReport.clone(db),
ScaStorageAlbum: q.ScaStorageAlbum.clone(db),
ScaStorageConfig: q.ScaStorageConfig.clone(db),
ScaStorageInfo: q.ScaStorageInfo.clone(db),
ScaStorageTag: q.ScaStorageTag.clone(db),
@@ -142,6 +147,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
ScaCommentLike: q.ScaCommentLike.replaceDB(db),
ScaCommentReply: q.ScaCommentReply.replaceDB(db),
ScaMessageReport: q.ScaMessageReport.replaceDB(db),
ScaStorageAlbum: q.ScaStorageAlbum.replaceDB(db),
ScaStorageConfig: q.ScaStorageConfig.replaceDB(db),
ScaStorageInfo: q.ScaStorageInfo.replaceDB(db),
ScaStorageTag: q.ScaStorageTag.replaceDB(db),
@@ -162,6 +168,7 @@ type queryCtx struct {
ScaCommentLike IScaCommentLikeDo
ScaCommentReply IScaCommentReplyDo
ScaMessageReport IScaMessageReportDo
ScaStorageAlbum IScaStorageAlbumDo
ScaStorageConfig IScaStorageConfigDo
ScaStorageInfo IScaStorageInfoDo
ScaStorageTag IScaStorageTagDo
@@ -182,6 +189,7 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
ScaCommentLike: q.ScaCommentLike.WithContext(ctx),
ScaCommentReply: q.ScaCommentReply.WithContext(ctx),
ScaMessageReport: q.ScaMessageReport.WithContext(ctx),
ScaStorageAlbum: q.ScaStorageAlbum.WithContext(ctx),
ScaStorageConfig: q.ScaStorageConfig.WithContext(ctx),
ScaStorageInfo: q.ScaStorageInfo.WithContext(ctx),
ScaStorageTag: q.ScaStorageTag.WithContext(ctx),

View File

@@ -39,6 +39,7 @@ func newScaCommentReply(db *gorm.DB, opts ...gen.DOOption) scaCommentReply {
_scaCommentReply.Author = field.NewInt64(tableName, "author")
_scaCommentReply.Likes = field.NewInt64(tableName, "likes")
_scaCommentReply.ReplyCount = field.NewInt64(tableName, "reply_count")
_scaCommentReply.ImagePath = field.NewString(tableName, "image_path")
_scaCommentReply.Browser = field.NewString(tableName, "browser")
_scaCommentReply.OperatingSystem = field.NewString(tableName, "operating_system")
_scaCommentReply.CommentIP = field.NewString(tableName, "comment_ip")
@@ -70,6 +71,7 @@ type scaCommentReply struct {
Author field.Int64 // 评论回复是否作者 0否 1是
Likes field.Int64 // 点赞数
ReplyCount field.Int64 // 回复数量
ImagePath field.String // 评论图片地址
Browser field.String // 浏览器
OperatingSystem field.String // 操作系统
CommentIP field.String // IP地址
@@ -107,6 +109,7 @@ func (s *scaCommentReply) updateTableName(table string) *scaCommentReply {
s.Author = field.NewInt64(table, "author")
s.Likes = field.NewInt64(table, "likes")
s.ReplyCount = field.NewInt64(table, "reply_count")
s.ImagePath = field.NewString(table, "image_path")
s.Browser = field.NewString(table, "browser")
s.OperatingSystem = field.NewString(table, "operating_system")
s.CommentIP = field.NewString(table, "comment_ip")
@@ -132,7 +135,7 @@ func (s *scaCommentReply) GetFieldByName(fieldName string) (field.OrderExpr, boo
}
func (s *scaCommentReply) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 21)
s.fieldMap = make(map[string]field.Expr, 22)
s.fieldMap["id"] = s.ID
s.fieldMap["user_id"] = s.UserID
s.fieldMap["topic_id"] = s.TopicID
@@ -145,6 +148,7 @@ func (s *scaCommentReply) fillFieldMap() {
s.fieldMap["author"] = s.Author
s.fieldMap["likes"] = s.Likes
s.fieldMap["reply_count"] = s.ReplyCount
s.fieldMap["image_path"] = s.ImagePath
s.fieldMap["browser"] = s.Browser
s.fieldMap["operating_system"] = s.OperatingSystem
s.fieldMap["comment_ip"] = s.CommentIP

View File

@@ -0,0 +1,404 @@
// 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 newScaStorageAlbum(db *gorm.DB, opts ...gen.DOOption) scaStorageAlbum {
_scaStorageAlbum := scaStorageAlbum{}
_scaStorageAlbum.scaStorageAlbumDo.UseDB(db, opts...)
_scaStorageAlbum.scaStorageAlbumDo.UseModel(&model.ScaStorageAlbum{})
tableName := _scaStorageAlbum.scaStorageAlbumDo.TableName()
_scaStorageAlbum.ALL = field.NewAsterisk(tableName)
_scaStorageAlbum.ID = field.NewInt64(tableName, "id")
_scaStorageAlbum.UserID = field.NewString(tableName, "user_id")
_scaStorageAlbum.AlbumName = field.NewString(tableName, "album_name")
_scaStorageAlbum.AlbumType = field.NewString(tableName, "album_type")
_scaStorageAlbum.CreatedAt = field.NewTime(tableName, "created_at")
_scaStorageAlbum.UpdatedAt = field.NewTime(tableName, "updated_at")
_scaStorageAlbum.DeletedAt = field.NewField(tableName, "deleted_at")
_scaStorageAlbum.fillFieldMap()
return _scaStorageAlbum
}
type scaStorageAlbum struct {
scaStorageAlbumDo
ALL field.Asterisk
ID field.Int64 // 主键
UserID field.String // 用户ID
AlbumName field.String // 相册名称
AlbumType field.String // 相册类型
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
fieldMap map[string]field.Expr
}
func (s scaStorageAlbum) Table(newTableName string) *scaStorageAlbum {
s.scaStorageAlbumDo.UseTable(newTableName)
return s.updateTableName(newTableName)
}
func (s scaStorageAlbum) As(alias string) *scaStorageAlbum {
s.scaStorageAlbumDo.DO = *(s.scaStorageAlbumDo.As(alias).(*gen.DO))
return s.updateTableName(alias)
}
func (s *scaStorageAlbum) updateTableName(table string) *scaStorageAlbum {
s.ALL = field.NewAsterisk(table)
s.ID = field.NewInt64(table, "id")
s.UserID = field.NewString(table, "user_id")
s.AlbumName = field.NewString(table, "album_name")
s.AlbumType = field.NewString(table, "album_type")
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 *scaStorageAlbum) 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 *scaStorageAlbum) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 7)
s.fieldMap["id"] = s.ID
s.fieldMap["user_id"] = s.UserID
s.fieldMap["album_name"] = s.AlbumName
s.fieldMap["album_type"] = s.AlbumType
s.fieldMap["created_at"] = s.CreatedAt
s.fieldMap["updated_at"] = s.UpdatedAt
s.fieldMap["deleted_at"] = s.DeletedAt
}
func (s scaStorageAlbum) clone(db *gorm.DB) scaStorageAlbum {
s.scaStorageAlbumDo.ReplaceConnPool(db.Statement.ConnPool)
return s
}
func (s scaStorageAlbum) replaceDB(db *gorm.DB) scaStorageAlbum {
s.scaStorageAlbumDo.ReplaceDB(db)
return s
}
type scaStorageAlbumDo struct{ gen.DO }
type IScaStorageAlbumDo interface {
gen.SubQuery
Debug() IScaStorageAlbumDo
WithContext(ctx context.Context) IScaStorageAlbumDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IScaStorageAlbumDo
WriteDB() IScaStorageAlbumDo
As(alias string) gen.Dao
Session(config *gorm.Session) IScaStorageAlbumDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IScaStorageAlbumDo
Not(conds ...gen.Condition) IScaStorageAlbumDo
Or(conds ...gen.Condition) IScaStorageAlbumDo
Select(conds ...field.Expr) IScaStorageAlbumDo
Where(conds ...gen.Condition) IScaStorageAlbumDo
Order(conds ...field.Expr) IScaStorageAlbumDo
Distinct(cols ...field.Expr) IScaStorageAlbumDo
Omit(cols ...field.Expr) IScaStorageAlbumDo
Join(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo
LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo
RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo
Group(cols ...field.Expr) IScaStorageAlbumDo
Having(conds ...gen.Condition) IScaStorageAlbumDo
Limit(limit int) IScaStorageAlbumDo
Offset(offset int) IScaStorageAlbumDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageAlbumDo
Unscoped() IScaStorageAlbumDo
Create(values ...*model.ScaStorageAlbum) error
CreateInBatches(values []*model.ScaStorageAlbum, batchSize int) error
Save(values ...*model.ScaStorageAlbum) error
First() (*model.ScaStorageAlbum, error)
Take() (*model.ScaStorageAlbum, error)
Last() (*model.ScaStorageAlbum, error)
Find() ([]*model.ScaStorageAlbum, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageAlbum, err error)
FindInBatches(result *[]*model.ScaStorageAlbum, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.ScaStorageAlbum) (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) IScaStorageAlbumDo
Assign(attrs ...field.AssignExpr) IScaStorageAlbumDo
Joins(fields ...field.RelationField) IScaStorageAlbumDo
Preload(fields ...field.RelationField) IScaStorageAlbumDo
FirstOrInit() (*model.ScaStorageAlbum, error)
FirstOrCreate() (*model.ScaStorageAlbum, error)
FindByPage(offset int, limit int) (result []*model.ScaStorageAlbum, 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) IScaStorageAlbumDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (s scaStorageAlbumDo) Debug() IScaStorageAlbumDo {
return s.withDO(s.DO.Debug())
}
func (s scaStorageAlbumDo) WithContext(ctx context.Context) IScaStorageAlbumDo {
return s.withDO(s.DO.WithContext(ctx))
}
func (s scaStorageAlbumDo) ReadDB() IScaStorageAlbumDo {
return s.Clauses(dbresolver.Read)
}
func (s scaStorageAlbumDo) WriteDB() IScaStorageAlbumDo {
return s.Clauses(dbresolver.Write)
}
func (s scaStorageAlbumDo) Session(config *gorm.Session) IScaStorageAlbumDo {
return s.withDO(s.DO.Session(config))
}
func (s scaStorageAlbumDo) Clauses(conds ...clause.Expression) IScaStorageAlbumDo {
return s.withDO(s.DO.Clauses(conds...))
}
func (s scaStorageAlbumDo) Returning(value interface{}, columns ...string) IScaStorageAlbumDo {
return s.withDO(s.DO.Returning(value, columns...))
}
func (s scaStorageAlbumDo) Not(conds ...gen.Condition) IScaStorageAlbumDo {
return s.withDO(s.DO.Not(conds...))
}
func (s scaStorageAlbumDo) Or(conds ...gen.Condition) IScaStorageAlbumDo {
return s.withDO(s.DO.Or(conds...))
}
func (s scaStorageAlbumDo) Select(conds ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.Select(conds...))
}
func (s scaStorageAlbumDo) Where(conds ...gen.Condition) IScaStorageAlbumDo {
return s.withDO(s.DO.Where(conds...))
}
func (s scaStorageAlbumDo) Order(conds ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.Order(conds...))
}
func (s scaStorageAlbumDo) Distinct(cols ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.Distinct(cols...))
}
func (s scaStorageAlbumDo) Omit(cols ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.Omit(cols...))
}
func (s scaStorageAlbumDo) Join(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.Join(table, on...))
}
func (s scaStorageAlbumDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.LeftJoin(table, on...))
}
func (s scaStorageAlbumDo) RightJoin(table schema.Tabler, on ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.RightJoin(table, on...))
}
func (s scaStorageAlbumDo) Group(cols ...field.Expr) IScaStorageAlbumDo {
return s.withDO(s.DO.Group(cols...))
}
func (s scaStorageAlbumDo) Having(conds ...gen.Condition) IScaStorageAlbumDo {
return s.withDO(s.DO.Having(conds...))
}
func (s scaStorageAlbumDo) Limit(limit int) IScaStorageAlbumDo {
return s.withDO(s.DO.Limit(limit))
}
func (s scaStorageAlbumDo) Offset(offset int) IScaStorageAlbumDo {
return s.withDO(s.DO.Offset(offset))
}
func (s scaStorageAlbumDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScaStorageAlbumDo {
return s.withDO(s.DO.Scopes(funcs...))
}
func (s scaStorageAlbumDo) Unscoped() IScaStorageAlbumDo {
return s.withDO(s.DO.Unscoped())
}
func (s scaStorageAlbumDo) Create(values ...*model.ScaStorageAlbum) error {
if len(values) == 0 {
return nil
}
return s.DO.Create(values)
}
func (s scaStorageAlbumDo) CreateInBatches(values []*model.ScaStorageAlbum, 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 scaStorageAlbumDo) Save(values ...*model.ScaStorageAlbum) error {
if len(values) == 0 {
return nil
}
return s.DO.Save(values)
}
func (s scaStorageAlbumDo) First() (*model.ScaStorageAlbum, error) {
if result, err := s.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageAlbum), nil
}
}
func (s scaStorageAlbumDo) Take() (*model.ScaStorageAlbum, error) {
if result, err := s.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageAlbum), nil
}
}
func (s scaStorageAlbumDo) Last() (*model.ScaStorageAlbum, error) {
if result, err := s.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageAlbum), nil
}
}
func (s scaStorageAlbumDo) Find() ([]*model.ScaStorageAlbum, error) {
result, err := s.DO.Find()
return result.([]*model.ScaStorageAlbum), err
}
func (s scaStorageAlbumDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ScaStorageAlbum, err error) {
buf := make([]*model.ScaStorageAlbum, 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 scaStorageAlbumDo) FindInBatches(result *[]*model.ScaStorageAlbum, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return s.DO.FindInBatches(result, batchSize, fc)
}
func (s scaStorageAlbumDo) Attrs(attrs ...field.AssignExpr) IScaStorageAlbumDo {
return s.withDO(s.DO.Attrs(attrs...))
}
func (s scaStorageAlbumDo) Assign(attrs ...field.AssignExpr) IScaStorageAlbumDo {
return s.withDO(s.DO.Assign(attrs...))
}
func (s scaStorageAlbumDo) Joins(fields ...field.RelationField) IScaStorageAlbumDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Joins(_f))
}
return &s
}
func (s scaStorageAlbumDo) Preload(fields ...field.RelationField) IScaStorageAlbumDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Preload(_f))
}
return &s
}
func (s scaStorageAlbumDo) FirstOrInit() (*model.ScaStorageAlbum, error) {
if result, err := s.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageAlbum), nil
}
}
func (s scaStorageAlbumDo) FirstOrCreate() (*model.ScaStorageAlbum, error) {
if result, err := s.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.ScaStorageAlbum), nil
}
}
func (s scaStorageAlbumDo) FindByPage(offset int, limit int) (result []*model.ScaStorageAlbum, 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 scaStorageAlbumDo) 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 scaStorageAlbumDo) Scan(result interface{}) (err error) {
return s.DO.Scan(result)
}
func (s scaStorageAlbumDo) Delete(models ...*model.ScaStorageAlbum) (result gen.ResultInfo, err error) {
return s.DO.Delete(models)
}
func (s *scaStorageAlbumDo) withDO(do gen.Dao) *scaStorageAlbumDo {
s.DO = *do.(*gen.DO)
return s
}

View File

@@ -47,6 +47,8 @@ func newScaStorageInfo(db *gorm.DB, opts ...gen.DOOption) scaStorageInfo {
_scaStorageInfo.Gps = field.NewString(tableName, "gps")
_scaStorageInfo.Screenshot = field.NewString(tableName, "screenshot")
_scaStorageInfo.Exif = field.NewString(tableName, "exif")
_scaStorageInfo.Hide = field.NewInt64(tableName, "hide")
_scaStorageInfo.AlbumID = field.NewInt64(tableName, "album_id")
_scaStorageInfo.CreatedAt = field.NewTime(tableName, "created_at")
_scaStorageInfo.UpdatedAt = field.NewTime(tableName, "updated_at")
_scaStorageInfo.DeletedAt = field.NewField(tableName, "deleted_at")
@@ -80,6 +82,8 @@ type scaStorageInfo struct {
Gps field.String // GPS
Screenshot field.String // 是否是截图
Exif field.String // exif 信息
Hide field.Int64 // 是否隐藏0 不隐藏 1 隐藏)
AlbumID field.Int64 // 相册ID
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
@@ -119,6 +123,8 @@ func (s *scaStorageInfo) updateTableName(table string) *scaStorageInfo {
s.Gps = field.NewString(table, "gps")
s.Screenshot = field.NewString(table, "screenshot")
s.Exif = field.NewString(table, "exif")
s.Hide = field.NewInt64(table, "hide")
s.AlbumID = field.NewInt64(table, "album_id")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")
s.DeletedAt = field.NewField(table, "deleted_at")
@@ -138,7 +144,7 @@ func (s *scaStorageInfo) GetFieldByName(fieldName string) (field.OrderExpr, bool
}
func (s *scaStorageInfo) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 23)
s.fieldMap = make(map[string]field.Expr, 25)
s.fieldMap["id"] = s.ID
s.fieldMap["user_id"] = s.UserID
s.fieldMap["provider"] = s.Provider
@@ -159,6 +165,8 @@ func (s *scaStorageInfo) fillFieldMap() {
s.fieldMap["gps"] = s.Gps
s.fieldMap["screenshot"] = s.Screenshot
s.fieldMap["exif"] = s.Exif
s.fieldMap["hide"] = s.Hide
s.fieldMap["album_id"] = s.AlbumID
s.fieldMap["created_at"] = s.CreatedAt
s.fieldMap["updated_at"] = s.UpdatedAt
s.fieldMap["deleted_at"] = s.DeletedAt