This commit is contained in:
2025-12-09 18:55:28 +08:00
parent 8d00d67540
commit c23ab8338b
209 changed files with 5445 additions and 3963 deletions

View File

@@ -1,17 +1,18 @@
package admin_feature
import (
"context"
"encoding/hex"
"context"
"encoding/hex"
"ycc-server/app/main/api/internal/svc"
"ycc-server/app/main/api/internal/types"
"ycc-server/app/main/model"
"ycc-server/common/xerr"
"ycc-server/pkg/lzkit/crypto"
"ycc-server/app/main/api/internal/svc"
"ycc-server/app/main/api/internal/types"
"ycc-server/app/main/model"
"ycc-server/common/xerr"
"ycc-server/pkg/lzkit/crypto"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"github.com/google/uuid"
)
type AdminConfigFeatureExampleLogic struct {
@@ -62,11 +63,12 @@ func (l *AdminConfigFeatureExampleLogic) AdminConfigFeatureExample(req *types.Ad
}
// 4. 准备示例数据
exampleData := &model.Example{
ApiId: feature.ApiId,
FeatureId: req.FeatureId,
Content: encryptedData,
}
exampleData := &model.Example{
Id: uuid.NewString(),
ApiId: feature.ApiId,
FeatureId: req.FeatureId,
Content: encryptedData,
}
// 4. 根据是否存在决定新增或更新
if existingExample == nil {

View File

@@ -8,6 +8,7 @@ import (
"ycc-server/app/main/model"
"ycc-server/common/xerr"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -29,6 +30,7 @@ func NewAdminCreateFeatureLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatureReq) (resp *types.AdminCreateFeatureResp, err error) {
// 1. 数据转换
data := &model.Feature{
Id: uuid.NewString(),
ApiId: req.ApiId,
Name: req.Name,
}
@@ -41,6 +43,6 @@ func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatu
}
// 3. 返回结果
id, _ := result.LastInsertId()
return &types.AdminCreateFeatureResp{Id: id}, nil
_ = result
return &types.AdminCreateFeatureResp{Id: data.Id}, nil
}

View File

@@ -35,7 +35,7 @@ func (l *AdminGetFeatureExampleLogic) AdminGetFeatureExample(req *types.AdminGet
if errors.Is(err, model.ErrNotFound) {
// 示例数据不存在,返回空数据
return &types.AdminGetFeatureExampleResp{
Id: 0,
Id: "",
FeatureId: req.FeatureId,
ApiId: "",
Data: "",

View File

@@ -27,9 +27,9 @@ func NewAdminUpdateFeatureLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatureReq) (resp *types.AdminUpdateFeatureResp, err error) {
// 1. 参数验证
if req.Id <= 0 {
if req.Id == "" {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.PARAM_VERIFICATION_ERROR),
"功能ID必须大于0, id: %d", req.Id)
"功能ID不能为空, id: %s", req.Id)
}
// 2. 查询记录是否存在