|
|
@ -237,9 +237,16 @@ func (r *projectRepository) Insert(ctx context.Context, project entities.Project |
|
|
|
} |
|
|
|
|
|
|
|
func (r *projectRepository) Update(ctx context.Context, project entities.Project, update models.ProjectUpdate) error { |
|
|
|
tx, err := r.db.BeginTx(ctx, nil) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
defer tx.Rollback() |
|
|
|
q := r.q.WithTx(tx) |
|
|
|
|
|
|
|
project.Update(update) |
|
|
|
|
|
|
|
return r.q.UpdateProject(ctx, mysqlcore.UpdateProjectParams{ |
|
|
|
err = q.UpdateProject(ctx, mysqlcore.UpdateProjectParams{ |
|
|
|
OwnerID: project.OwnerID, |
|
|
|
Name: project.Name, |
|
|
|
Status: int(project.Status), |
|
|
@ -248,6 +255,33 @@ func (r *projectRepository) Update(ctx context.Context, project entities.Project |
|
|
|
ID: project.ID, |
|
|
|
ScopeID: project.ScopeID, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
for _, tag := range update.RemoveTags { |
|
|
|
err := q.DeleteTag(ctx, mysqlcore.DeleteTagParams{ |
|
|
|
ObjectKind: tagObjectKindProject, |
|
|
|
ObjectID: project.ID, |
|
|
|
TagName: tag, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, tag := range update.AddTags { |
|
|
|
err = q.InsertTag(ctx, mysqlcore.InsertTagParams{ |
|
|
|
ObjectKind: tagObjectKindProject, |
|
|
|
ObjectID: project.ID, |
|
|
|
TagName: tag, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return tx.Commit() |
|
|
|
} |
|
|
|
|
|
|
|
func (r *projectRepository) Delete(ctx context.Context, project entities.Project) error { |
|
|
@ -488,9 +522,16 @@ func (r *projectRepository) CreateRequirement(ctx context.Context, requirement e |
|
|
|
} |
|
|
|
|
|
|
|
func (r *projectRepository) UpdateRequirement(ctx context.Context, requirement entities.Requirement, update models.RequirementUpdate) error { |
|
|
|
tx, err := r.db.BeginTx(ctx, nil) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
defer tx.Rollback() |
|
|
|
q := r.q.WithTx(tx) |
|
|
|
|
|
|
|
requirement.Update(update) |
|
|
|
|
|
|
|
return r.q.UpdateProjectRequirement(ctx, mysqlcore.UpdateProjectRequirementParams{ |
|
|
|
_ = q.UpdateProjectRequirement(ctx, mysqlcore.UpdateProjectRequirementParams{ |
|
|
|
Name: requirement.Name, |
|
|
|
Status: int(requirement.Status), |
|
|
|
Description: requirement.Description, |
|
|
@ -499,6 +540,30 @@ func (r *projectRepository) UpdateRequirement(ctx context.Context, requirement e |
|
|
|
ScopeID: requirement.ScopeID, |
|
|
|
AggregateRequired: requirement.AggregateRequired, |
|
|
|
}) |
|
|
|
|
|
|
|
for _, tag := range update.RemoveTags { |
|
|
|
err := q.DeleteTag(ctx, mysqlcore.DeleteTagParams{ |
|
|
|
ObjectKind: tagObjectKindRequirement, |
|
|
|
ObjectID: requirement.ID, |
|
|
|
TagName: tag, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, tag := range update.AddTags { |
|
|
|
err = q.InsertTag(ctx, mysqlcore.InsertTagParams{ |
|
|
|
ObjectKind: tagObjectKindRequirement, |
|
|
|
ObjectID: requirement.ID, |
|
|
|
TagName: tag, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return tx.Commit() |
|
|
|
} |
|
|
|
|
|
|
|
func (r *projectRepository) DeleteRequirement(ctx context.Context, requirement entities.Requirement) error { |
|
|
|