Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Aug 3, 2023
1 parent eb509db commit 84d52b5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ func (h TargetHandler) Create(ctx *gin.Context) {
m := target.Model()
m.CreateUser = h.CurrentUser(ctx)
if target.RuleSet != nil {
rh := RuleSetHandler{}
ruleset := target.RuleSet
uuid, _ := uuid2.NewUUID()
ruleset.Name = fmt.Sprintf("__Target(%s)-%s", m.Name, uuid.String())
err := (&RuleSetHandler{}).create(ctx, ruleset)
err := rh.create(ctx, ruleset)
if err != nil {
_ = ctx.Error(err)
return
Expand Down Expand Up @@ -166,7 +167,8 @@ func (h TargetHandler) Delete(ctx *gin.Context) {
return
}
if target.RuleSetID != nil {
err := (&RuleSetHandler{}).delete(ctx, *target.RuleSetID)
rh := RuleSetHandler{}
err := rh.delete(ctx, *target.RuleSetID)
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
_ = ctx.Error(result.Error)
Expand Down Expand Up @@ -214,8 +216,9 @@ func (h TargetHandler) Update(ctx *gin.Context) {
m.ID = id
m.UpdateUser = h.CurrentUser(ctx)
if r.RuleSet != nil {
rh := RuleSetHandler{}
m.RuleSetID = &r.RuleSet.ID
err := (&RuleSetHandler{}).update(ctx, r.RuleSet)
err := rh.update(ctx, r.RuleSet)
if err != nil {
_ = ctx.Error(err)
return
Expand Down

0 comments on commit 84d52b5

Please sign in to comment.