@@ -10,7 +10,7 @@ import (
1010
1111type EnvironmentTagRepo interface {
1212 CreateEnvironmentTag (ctx context.Context , environmentTag * EnvironmentTag ) error
13- UpdateEnvironmentTag (ctx context.Context , environmentTagName , environmentTagUID string ) error
13+ UpdateEnvironmentTag (ctx context.Context , environmentTagUID , environmentTagName , color string ) error
1414 DeleteEnvironmentTag (ctx context.Context , environmentTagUID string ) error
1515 GetEnvironmentTagByName (ctx context.Context , projectUid , name string ) (bool , * EnvironmentTag , error )
1616 GetEnvironmentTagByUID (ctx context.Context , uid string ) (* EnvironmentTag , error )
@@ -39,9 +39,10 @@ type EnvironmentTag struct {
3939 UID string
4040 Name string
4141 ProjectUID string
42+ Color string
4243}
4344
44- func (uc * EnvironmentTagUsecase ) newEnvironmentTag (projectUid , tagName string ) (* EnvironmentTag , error ) {
45+ func (uc * EnvironmentTagUsecase ) newEnvironmentTag (projectUid , tagName , color string ) (* EnvironmentTag , error ) {
4546 uid , err := pkgRand .GenStrUid ()
4647 if err != nil {
4748 return nil , err
@@ -53,6 +54,7 @@ func (uc *EnvironmentTagUsecase) newEnvironmentTag(projectUid, tagName string) (
5354 UID : uid ,
5455 Name : tagName ,
5556 ProjectUID : projectUid ,
57+ Color : color ,
5658 }, nil
5759}
5860
@@ -66,7 +68,7 @@ func (uc *EnvironmentTagUsecase) InitDefaultEnvironmentTags(ctx context.Context,
6668 }
6769
6870 for _ , environmentTag := range defaultEnvironmentTags {
69- err = uc .CreateEnvironmentTag (ctx , projectUid , currentUserUid , environmentTag )
71+ err = uc .CreateEnvironmentTag (ctx , projectUid , currentUserUid , environmentTag , "" )
7072 if err != nil {
7173 uc .log .Errorf ("create environment tag failed: %v" , err )
7274 return fmt .Errorf ("create environment tag failed: %w" , err )
@@ -75,7 +77,7 @@ func (uc *EnvironmentTagUsecase) InitDefaultEnvironmentTags(ctx context.Context,
7577 return nil
7678}
7779
78- func (uc * EnvironmentTagUsecase ) CreateEnvironmentTag (ctx context.Context , projectUid , currentUserUid , tagName string ) error {
80+ func (uc * EnvironmentTagUsecase ) CreateEnvironmentTag (ctx context.Context , projectUid , currentUserUid , tagName , color string ) error {
7981 // 检查项目是否归档/删除
8082 if err := uc .projectUsecase .isProjectActive (ctx , projectUid ); err != nil {
8183 return fmt .Errorf ("update db service error: %v" , err )
@@ -96,7 +98,7 @@ func (uc *EnvironmentTagUsecase) CreateEnvironmentTag(ctx context.Context, proje
9698 if exist {
9799 return fmt .Errorf ("the tag %s already exists in the current project" , tagName )
98100 }
99- environmentTag , err := uc .newEnvironmentTag (projectUid , tagName )
101+ environmentTag , err := uc .newEnvironmentTag (projectUid , tagName , color )
100102 if err != nil {
101103 uc .log .Errorf ("new environment tag failed: %v" , err )
102104 return err
@@ -109,7 +111,7 @@ func (uc *EnvironmentTagUsecase) CreateEnvironmentTag(ctx context.Context, proje
109111 return nil
110112}
111113
112- func (uc * EnvironmentTagUsecase ) UpdateEnvironmentTag (ctx context.Context , projectUid , currentUserUid , environmentTagUID , environmentTagName string ) error {
114+ func (uc * EnvironmentTagUsecase ) UpdateEnvironmentTag (ctx context.Context , projectUid , currentUserUid , environmentTagUID , environmentTagName , color string ) error {
113115 // 检查项目是否归档/删除
114116 if err := uc .projectUsecase .isProjectActive (ctx , projectUid ); err != nil {
115117 return fmt .Errorf ("update db service error: %v" , err )
@@ -130,7 +132,7 @@ func (uc *EnvironmentTagUsecase) UpdateEnvironmentTag(ctx context.Context, proje
130132 uc .log .Errorf ("get environment tag failed: %v" , err )
131133 return err
132134 }
133- err = uc .environmentTagRepo .UpdateEnvironmentTag (ctx , environmentTagUID , environmentTagName )
135+ err = uc .environmentTagRepo .UpdateEnvironmentTag (ctx , environmentTagUID , environmentTagName , color )
134136 if err != nil {
135137 uc .log .Errorf ("update environment tag failed: %v" , err )
136138 return err
@@ -206,7 +208,7 @@ func (uc *EnvironmentTagUsecase) GetOrCreateEnvironmentTag(ctx context.Context,
206208 if exist {
207209 return environmentTag , nil
208210 }
209- newTag , err := uc .newEnvironmentTag (projectUid , tagName )
211+ newTag , err := uc .newEnvironmentTag (projectUid , tagName , "" )
210212 if err != nil {
211213 uc .log .Errorf ("new environment tag failed: %v" , err )
212214 return nil , err
0 commit comments