Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-10-26 18:34:29 +08:00
commit ba0d6b2525
16 changed files with 419 additions and 124 deletions

View File

@ -50,7 +50,29 @@ func (m *FsUserInfoModel) MergeMetadata(userId int64, meta any) error {
return fssql.MetadataModulePATCH(m.db, "profile", FsUserInfo{}, meta, "user_id = ?", userId)
}
func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId int64) (map[string]any, error) {
func (m *FsUserInfoModel) getDefaultProfile(ctx context.Context, tname string) (map[string]any, error) {
var baseinfo map[string]any
condUser := "user_id = 0 and guest_id = 0"
rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$') as query from %s where %s and module = 'profile' order by ctime DESC limit 1", tname, condUser)
err := m.db.WithContext(ctx).Raw(rawsql).Take(&baseinfo).Error
if err != nil {
return nil, err
}
v, ok := baseinfo["query"].(string)
if !ok {
return nil, fmt.Errorf("default userinfo profile is not exists")
}
var info map[string]any
err = json.Unmarshal([]byte(v), &info)
if err != nil {
return nil, err
}
return info, nil
}
func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId int64, guestId int64) (map[string]any, error) {
var baseinfo map[string]any
tname := fssql.GetGormTableName(m.db, FsUserInfo{})
@ -61,15 +83,22 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
pkey = "." + pkey
}
rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where user_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname)
err := m.db.WithContext(ctx).Raw(rawsql, userId).Take(&baseinfo).Error
var condUser string
if userId == 0 {
condUser = fmt.Sprintf("user_id = 0 and guest_id = %d", guestId)
} else {
condUser = fmt.Sprintf("user_id = %d", userId)
}
rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where %s and module = 'profile' order by ctime DESC limit 1", pkey, tname, condUser)
err := m.db.WithContext(ctx).Raw(rawsql).Take(&baseinfo).Error
if err != nil {
return nil, err
}
v, ok := baseinfo["query"].(string)
if !ok {
return nil, nil
return m.getDefaultProfile(ctx, tname)
}
var info map[string]any
@ -77,8 +106,19 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
if err != nil {
return nil, err
}
if len(info) == 0 {
return m.getDefaultProfile(ctx, tname)
}
return info, nil
}
func (m *FsUserInfoModel) GetDefaultProfile(ctx context.Context) (map[string]any, error) {
tname := fssql.GetGormTableName(m.db, FsUserInfo{})
return m.getDefaultProfile(ctx, tname)
}
func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int64, module string) (resp *FsUserInfo, err error) {
if userId > 0 {
err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ? and module = ?", userId, module).Take(&resp).Error
@ -87,32 +127,3 @@ func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int
}
return resp, err
}
func (m *FsUserInfoModel) GetProfileByUserIdGuestId(ctx context.Context, pkey string, userId, guestId int64) (map[string]any, error) {
var baseinfo map[string]any
tname := fssql.GetGormTableName(m.db, FsUserInfo{})
if pkey == "." {
pkey = ""
} else {
pkey = "." + pkey
}
rawsql := fmt.Sprintf("select JSON_EXTRACT(metadata,'$%s') as query from %s where user_id = ? and guest_id = ? and module = 'profile' order by ctime DESC limit 1", pkey, tname)
err := m.db.WithContext(ctx).Raw(rawsql, userId, guestId).Take(&baseinfo).Error
if err != nil {
return nil, err
}
v, ok := baseinfo["query"].(string)
if !ok {
return nil, nil
}
var info map[string]any
err = json.Unmarshal([]byte(v), &info)
if err != nil {
return nil, err
}
return info, nil
}

View File

@ -72,6 +72,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/api/user/logo-templatetag-set",
Handler: UserLogoTemplateTagSetHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/user/logo-data-set",
Handler: UserLogoDataSetHandler(serverCtx),
},
},
)
}

View File

@ -0,0 +1,35 @@
package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/home-user-auth/internal/logic"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/server/home-user-auth/internal/types"
)
func UserLogoDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.UserLogoDataSetReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewUserLogoDataSetLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.UserLogoDataSet(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@ -0,0 +1,130 @@
package logic
import (
"errors"
"fmt"
"fusenapi/model/gmodel"
"fusenapi/service/repositories"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/s3url_to_s3id"
"time"
"context"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/server/home-user-auth/internal/types"
"github.com/zeromicro/go-zero/core/logc"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
type UserLogoDataSetLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUserLogoDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLogoDataSetLogic {
return &UserLogoDataSetLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *UserLogoDataSetLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
if userinfo.IsOnlooker() {
// 如果是,返回未授权的错误码
return resp.SetStatus(basic.CodeUnAuth)
}
var userId int64
var guestId int64
// 检查用户是否是游客
if userinfo.IsGuest() {
// 如果是使用游客ID和游客键名格式
guestId = userinfo.GuestId
} else {
// 否则使用用户ID和用户键名格式
userId = userinfo.UserId
}
var logoData = gmodel.FsPreprocessLogo{}
result := l.svcCtx.MysqlConn.Model(&gmodel.FsPreprocessLogo{}).Where("id = ?", req.LogoDataId).Take(&logoData)
err := result.Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
logc.Errorf(l.ctx, "UserLogoDataSet logoData find err%+v", err)
basic.CodeApiErr.Message = "logo data not find"
return resp.SetStatus(basic.CodeApiErr)
}
return resp.SetStatus(basic.CodeApiErr)
}
var userMaterialMetadata []byte
if logoData.Metadata == nil {
var resultStr string
resLogoStandard, err := l.svcCtx.Repositories.ImageHandle.LogoInfoSet(l.ctx, &repositories.LogoInfoSetReq{
LogoUrl: *logoData.ResourceUrl,
Version: l.svcCtx.Config.BLMService.Version,
Debug: userinfo.Debug,
})
if err != nil {
logx.Error(err)
basic.CodeServiceErr.Message = fmt.Sprintf("算法请求--LOGO信息--错误:%+v", err)
return resp.SetStatus(basic.CodeServiceErr, fmt.Sprintf("算法请求--LOGO信息--错误:%+v", err))
}
resultStr = resLogoStandard.Res
userMaterialMetadata = []byte(resultStr)
} else {
userMaterialMetadata = *logoData.Metadata
}
// 新增素材
var module = "logo"
var nowTime = time.Now().UTC()
var resourceId = s3url_to_s3id.GetS3ResourceIdFormUrl(*logoData.ResourceUrl)
// 新增素材记录
materialInfo := gmodel.FsUserMaterial{
Module: &module,
UserId: &userId,
GuestId: &guestId,
ResourceId: &resourceId,
ResourceUrl: logoData.ResourceUrl,
Metadata: &userMaterialMetadata,
Ctime: &nowTime,
}
resCreate := l.svcCtx.MysqlConn.Create(&materialInfo)
err = resCreate.Error
if err != nil {
logc.Errorf(l.ctx, "UserLogoDataSet logoData find err%+v", err)
return resp.SetStatus(basic.CodeApiErr)
}
// 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"id": materialInfo.Id,
"module": materialInfo.Module,
"user_id": materialInfo.UserId,
"guest_id": materialInfo.GuestId,
"resource_id": materialInfo.ResourceId,
"resource_url": materialInfo.ResourceUrl,
"metadata": materialInfo.Metadata,
"ctime": materialInfo.Ctime,
"resource_info": nil,
})
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *UserLogoDataSetLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@ -106,6 +106,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
return err
}
}
var logoCategoryId int64
// 更新merchant_category
if req.SetLogoCategory == 1 {
var metadataChildUserMaterial = make(map[string]interface{}, 1)
@ -121,7 +122,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
return err
}
userMaterialInfo.Metadata = &metadataBUserMaterial
resUpdates := tx.Select("metadata").Where("id = ?", req.LogoSelectedId).Updates(&userMaterialInfo)
resUpdates := tx.Model(&gmodel.FsUserMaterial{}).Select("metadata", "utime").Where("id = ?", req.LogoSelectedId).Updates(&userMaterialInfo)
err = resUpdates.Error
if err != nil {
if err != gorm.ErrRecordNotFound {
@ -129,7 +130,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
return err
}
}
logoCategoryId = req.CategoryId
}
var module = "profile"
if req.SetLogoSelected == 1 {
@ -182,11 +183,16 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
templateTagSelected["template_tag"] = userMaterialTemplateIdTagId
templateTagSelected["selected_index"] = 0
metadataChildUserInfo["logo_selected"] = map[string]interface{}{
var logoSelectedMap = map[string]interface{}{
"logo_selected_id": req.LogoSelectedId,
"logo_url": userMaterialInfo.ResourceUrl,
"template_tag_selected": templateTagSelected,
}
if logoCategoryId != 0 {
logoSelectedMap["merchant_category"] = logoCategoryId
}
metadataChildUserInfo["logo_selected"] = logoSelectedMap
metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo)
if err != nil {
@ -212,7 +218,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
} else {
// 更新
userInfo.Utime = &nowTime
resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo)
resUpdates := tx.Model(&gmodel.FsUserInfo{}).Select("metadata", "utime").Where("id = ?", userInfo.Id).Updates(&userInfo)
err = resUpdates.Error
}

View File

@ -5,6 +5,10 @@ import (
"fusenapi/utils/basic"
)
type UserLogoDataSetReq struct {
LogoDataId int64 `form:"logo_data_id"`
}
type UserLogoTemplateTagSetReq struct {
TemplateTag string `form:"template_tag"`
TemplateTagColorIndex int64 `form:"template_tag_color_index"`

View File

@ -22,6 +22,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/api/info/user/profile",
Handler: UserGetProfileHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/api/info/user/profile/default",
Handler: UserGetDefaultProfileHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/info/user/profile/base/update",

View File

@ -0,0 +1,35 @@
package handler
import (
"net/http"
"reflect"
"fusenapi/utils/basic"
"fusenapi/server/info/internal/logic"
"fusenapi/server/info/internal/svc"
"fusenapi/server/info/internal/types"
)
func UserGetDefaultProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.Request
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
// 创建一个业务逻辑层实例
l := logic.NewUserGetDefaultProfileLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl)
resp := l.UserGetDefaultProfile(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}
}

View File

@ -0,0 +1,47 @@
package logic
import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"context"
"fusenapi/server/info/internal/svc"
"fusenapi/server/info/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type UserGetDefaultProfileLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUserGetDefaultProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserGetDefaultProfileLogic {
return &UserGetDefaultProfileLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 处理进入前逻辑w,r
// func (l *UserGetDefaultProfileLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *UserGetDefaultProfileLogic) UserGetDefaultProfile(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
defaultProfile, err := l.svcCtx.AllModels.FsUserInfo.GetDefaultProfile(l.ctx)
if err != nil {
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
}
return resp.SetStatus(basic.CodeOK, defaultProfile)
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *UserGetDefaultProfileLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@ -34,7 +34,7 @@ func (l *UserGetProfileLogic) UserGetProfile(req *types.QueryProfileRequest, use
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
profileBase, err := l.svcCtx.AllModels.FsUserInfo.GetProfile(l.ctx, req.TopKey, userinfo.UserId)
profileBase, err := l.svcCtx.AllModels.FsUserInfo.GetProfile(l.ctx, req.TopKey, userinfo.UserId, userinfo.GuestId)
if err != nil {
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
}

View File

@ -14,16 +14,16 @@ type UploadLogoStandardReq struct {
}
type UploadFileBaseReq struct {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
FileKey string `form:"file_key"` // 上传唯一标识信息
FileData string `form:"file_data"` // 上传文件额外信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
UserId int64 `form:"user_id,optional"` // 上传文件额外信息
GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
FileKey string `form:"file_key"` // 上传唯一标识信息
FileData string `form:"file_data"` // 上传文件额外信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
UserId int64 `form:"user_id,optional"` // 上传文件额外信息
GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
}
type UploadLogoReq struct {
@ -34,33 +34,33 @@ type UploadLogoReq struct {
}
type UploadFileBackendReq struct {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
FileKey string `form:"file_key"` // 上传唯一标识信息
FileSize int64 `form:"file_size,optional"` // 上传唯一标识信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
FileKey string `form:"file_key"` // 上传唯一标识信息
FileSize int64 `form:"file_size,optional"` // 上传唯一标识信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
}
type UploadFilesReq struct {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
UploadInfo string `form:"upload_info"` // 上传信息 json
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
UploadInfo string `form:"upload_info"` // 上传信息 json
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
}
type UploadCallbackReq struct {
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
ResourceId string `form:"resource_id"` // 资源ID
ResourceType string `form:"resource_type"` // 资源类型
ResourceUrl string `form:"resource_url"` // 资源URL
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
Source string `form:"source"` // 上传来源
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
ResourceId string `form:"resource_id"` // 资源ID
ResourceType string `form:"resource_type"` // 资源类型
ResourceUrl string `form:"resource_url"` // 资源URL
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
Source string `form:"source"` // 上传来源
}
type RequestUpFile struct {
@ -114,10 +114,10 @@ type File struct {
}
type Meta struct {
TotalCount int64 `json:"totalCount"`
PageCount int64 `json:"pageCount"`
CurrentPage int `json:"currentPage"`
PerPage int `json:"perPage"`
TotalCount int64 `json:"total_count"`
PageCount int64 `json:"page_count"`
CurrentPage int `json:"current_page"`
PerPage int `json:"per_page"`
}
// Set 设置Response的Code和Message值

View File

@ -10,60 +10,70 @@ info (
import "basic.api"
service home-user-auth {
// @handler UserRegisterHandler
// post /api/user/register(RequestUserRegister) returns (response);
//用户字体
@handler UserFontsHandler
get /api/user/fonts(request) returns (response);
//状态配置
@handler UserStatusConfigHandler
get /api/user/status-config(request) returns (response);
//联系服务
@handler UserContactServiceHandler
post /api/user/contact-service (RequestContactService) returns (response);
// @handler UserOderListHandler
// get /api/user/order-list(RequestOrderId) returns (response);
//删除订单
@handler UserOderDeleteHandler
post /api/user/order-delete(RequestOrderId) returns (response);
//订单列表
@handler UserOrderListHandler
get /api/user/order-list (UserOrderListReq) returns (response);
//删除订单
@handler UserOrderDeleteHandler
get /api/user/order-delete (UserOrderDeleteReq) returns (response);
//取消订单
@handler UserOrderCancelHandler
get /api/user/order-cancel (UserOrderCancelReq) returns (response);
// 用户logo列表
@handler UserLogoListHandler
get /api/user/logo-list (UserLogoListReq) returns (response);
// 再来一单
@handler UserAgainOrderHandler
get /api/user/one-more-order (UserAgainOrderReq) returns (response);
// 保存商户信息
@handler UserInfoSetHandler
post /api/user/set_user_info (UserInfoSetReq) returns (response);
// 用户logo设置当前
@handler UserLogoSetHandler
post /api/user/logo-set (UserLogoSetReq) returns (response);
// 用户logo模版信息
@handler UserLogoTemplateTagSetHandler
post /api/user/logo-templatetag-set (UserLogoTemplateTagSetReq) returns (response);
// 用户logo数据设置用户logo素材
@handler UserLogoDataSetHandler
post /api/user/logo-data-set (UserLogoDataSetReq) returns (response);
}
type (
UserLogoDataSetReq {
LogoDataId int64 `form:"logo_data_id"`
}
)
type (
UserLogoTemplateTagSetReq {
TemplateTag string `form:"template_tag"`

View File

@ -16,6 +16,9 @@ service info {
@handler UserGetProfileHandler
post /api/info/user/profile(QueryProfileRequest) returns (response);
@handler UserGetDefaultProfileHandler
get /api/info/user/profile/default(request) returns (response);
@handler UpdateProfileBaseHandler
post /api/info/user/profile/base/update(ProfileRequest) returns (response);

View File

@ -59,16 +59,16 @@ type (
type (
UploadFileBaseReq {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
FileKey string `form:"file_key"` // 上传唯一标识信息
FileData string `form:"file_data"` // 上传文件额外信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
UserId int64 `form:"user_id,optional"` // 上传文件额外信息
GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
FileKey string `form:"file_key"` // 上传唯一标识信息
FileData string `form:"file_data"` // 上传文件额外信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
UserId int64 `form:"user_id,optional"` // 上传文件额外信息
GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
}
)
@ -83,32 +83,32 @@ type (
type (
UploadFileBackendReq {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
FileKey string `form:"file_key"` // 上传唯一标识信息
FileSize int64 `form:"file_size,optional"` // 上传唯一标识信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
FileKey string `form:"file_key"` // 上传唯一标识信息
FileSize int64 `form:"file_size,optional"` // 上传唯一标识信息
Metadata string `form:"meta_data,optional"` // 上传文件额外信息
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
}
UploadFilesReq {
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
UploadInfo string `form:"upload_info"` // 上传信息 json
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
UploadInfo string `form:"upload_info"` // 上传信息 json
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
}
UploadCallbackReq {
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
ResourceId string `form:"resource_id"` // 资源ID
ResourceType string `form:"resource_type"` // 资源类型
ResourceUrl string `form:"resource_url"` // 资源URL
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
Source string `form:"source"` // 上传来源
UploadBucket int64 `form:"upload_bucket,options=[1,2,3],default=1"` // 上传桶名:1=缓存,2=持久
ResourceId string `form:"resource_id"` // 资源ID
ResourceType string `form:"resource_type"` // 资源类型
ResourceUrl string `form:"resource_url"` // 资源URL
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型1=对外2=对内
Source string `form:"source"` // 上传来源
}
)

View File

@ -11,10 +11,12 @@ import (
)
// 全局的BucketName
var StorageBucketName = aws.String("storage.fusenpack.com")
var StorageBucketName = aws.String("fusenstorage")
// 全局的BucketName 缓存使用
var TempfileBucketName = aws.String("tempfile.fusenpack.com")
var TempfileBucketName = aws.String("fusentempfile")
var FusenLogoDbBucketName = aws.String("fusenstorage")
const UploadFileLimitSize = 200 << 20

View File

@ -57,12 +57,13 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
switch req.UploadBucket {
case 2:
bucketName = basic.TempfileBucketName
case 3:
bucketName = basic.StorageBucketName
default:
bucketName = basic.StorageBucketName
}
// 设置AWS会话的区域
upload.AwsSession.Config.Region = aws.String("us-west-1")
upload.AwsSession.Config.Region = aws.String("us-east-2")
// 创建新的S3服务实例
svc := s3.New(upload.AwsSession)
@ -108,7 +109,7 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
&s3.PutObjectInput{
Bucket: bucketName,
Key: &resourceId,
CacheControl: aws.String("no-cache, must-revalidate"),
CacheControl: aws.String("no-cache"),
},
)
@ -192,12 +193,13 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro
switch req.UploadBucket {
case 2:
bucketName = basic.TempfileBucketName
case 3:
bucketName = basic.StorageBucketName
default:
bucketName = basic.StorageBucketName
}
// 设置AWS会话的区域
upload.AwsSession.Config.Region = aws.String("us-west-1")
upload.AwsSession.Config.Region = aws.String("us-east-2")
// 创建新的S3服务实例
svc := s3.New(upload.AwsSession)
@ -237,7 +239,7 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro
&s3.PutObjectInput{
Bucket: bucketName,
Key: &resourceId,
CacheControl: aws.String("no-cache, must-revalidate"),
CacheControl: aws.String("no-cache"),
},
)