初始化项目
This commit is contained in:
@@ -58,7 +58,6 @@ func (s *strategyService) CreateStrategy(ctx context.Context, req *dto.CreateStr
|
||||
strategy := &entity.Strategy{
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
TenantLevel: req.TenantLevel,
|
||||
MinConversion: req.MinConversion,
|
||||
MaxConversion: req.MaxConversion,
|
||||
SourceWeights: string(weightsJson),
|
||||
@@ -69,13 +68,24 @@ func (s *strategyService) CreateStrategy(ctx context.Context, req *dto.CreateStr
|
||||
UpdatedBy: userId,
|
||||
}
|
||||
|
||||
return dao.Strategy.Create(ctx, strategy)
|
||||
idStr, err := dao.Strategy.Create(ctx, strategy)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 将字符串ID转换为int64
|
||||
parsedId, err := strconv.ParseInt(idStr, 10, 64)
|
||||
if err != nil {
|
||||
return 0, gerror.Wrap(err, "ID转换失败")
|
||||
}
|
||||
|
||||
return parsedId, nil
|
||||
}
|
||||
|
||||
// UpdateStrategy 更新策略
|
||||
func (s *strategyService) UpdateStrategy(ctx context.Context, req *dto.UpdateStrategyReq) (affected int64, err error) {
|
||||
// 检查策略是否存在
|
||||
existingStrategy, err := dao.Strategy.GetByID(ctx, req.Id)
|
||||
existingStrategy, err := dao.Strategy.GetByID(ctx, strconv.FormatInt(req.Id, 10))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -123,7 +133,6 @@ func (s *strategyService) UpdateStrategy(ctx context.Context, req *dto.UpdateStr
|
||||
Id: req.Id,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
TenantLevel: req.TenantLevel,
|
||||
MinConversion: req.MinConversion,
|
||||
MaxConversion: req.MaxConversion,
|
||||
SourceWeights: string(weightsJson),
|
||||
@@ -139,7 +148,7 @@ func (s *strategyService) UpdateStrategy(ctx context.Context, req *dto.UpdateStr
|
||||
// DeleteStrategy 删除策略
|
||||
func (s *strategyService) DeleteStrategy(ctx context.Context, id int64) (affected int64, err error) {
|
||||
// 检查策略是否存在
|
||||
existingStrategy, err := dao.Strategy.GetByID(ctx, id)
|
||||
existingStrategy, err := dao.Strategy.GetByID(ctx, strconv.FormatInt(id, 10))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -147,12 +156,12 @@ func (s *strategyService) DeleteStrategy(ctx context.Context, id int64) (affecte
|
||||
return 0, gerror.New("策略不存在")
|
||||
}
|
||||
|
||||
return dao.Strategy.Delete(ctx, id)
|
||||
return dao.Strategy.Delete(ctx, strconv.FormatInt(id, 10))
|
||||
}
|
||||
|
||||
// GetStrategyByID 根据ID获取策略
|
||||
func (s *strategyService) GetStrategyByID(ctx context.Context, id int64) (strategy *dto.StrategyRes, err error) {
|
||||
entity, err := dao.Strategy.GetByID(ctx, id)
|
||||
entity, err := dao.Strategy.GetByID(ctx, strconv.FormatInt(id, 10))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -173,7 +182,7 @@ func (s *strategyService) GetStrategyByID(ctx context.Context, id int64) (strate
|
||||
Id: entity.Id,
|
||||
Name: entity.Name,
|
||||
Description: entity.Description,
|
||||
TenantLevel: entity.TenantLevel,
|
||||
TenantLevel: "", // Strategy实体中没有TenantLevel字段,暂时设为空字符串
|
||||
MinConversion: entity.MinConversion,
|
||||
MaxConversion: entity.MaxConversion,
|
||||
SourceWeights: weights,
|
||||
@@ -210,7 +219,7 @@ func (s *strategyService) GetStrategyList(ctx context.Context, req *dto.GetStrat
|
||||
Id: entity.Id,
|
||||
Name: entity.Name,
|
||||
Description: entity.Description,
|
||||
TenantLevel: entity.TenantLevel,
|
||||
TenantLevel: "", // Strategy实体中没有TenantLevel字段,暂时设为空字符串
|
||||
MinConversion: entity.MinConversion,
|
||||
MaxConversion: entity.MaxConversion,
|
||||
SourceWeights: weights,
|
||||
|
||||
Reference in New Issue
Block a user