mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
api文档完成
This commit is contained in:
@@ -52,3 +52,9 @@ func ToTeam(model *team.Team, serviceNum int64, appNum int64) *Team {
|
||||
CanDelete: serviceNum == 0 && appNum == 0,
|
||||
}
|
||||
}
|
||||
|
||||
type ExportTeam struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
+29
-15
@@ -3,26 +3,26 @@ package team
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/eolinker/go-common/utils"
|
||||
|
||||
|
||||
"github.com/eolinker/ap-account/service/role"
|
||||
|
||||
|
||||
"github.com/eolinker/go-common/store"
|
||||
|
||||
|
||||
"github.com/eolinker/ap-account/service/user"
|
||||
|
||||
|
||||
"github.com/APIParkLab/APIPark/service/service"
|
||||
team_member "github.com/APIParkLab/APIPark/service/team-member"
|
||||
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
|
||||
team_dto "github.com/APIParkLab/APIPark/module/team/dto"
|
||||
"github.com/APIParkLab/APIPark/service/team"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ITeamModule = (*imlTeamModule)(nil)
|
||||
_ ITeamModule = (*imlTeamModule)(nil)
|
||||
_ ITeamExportModule = (*imlTeamModule)(nil)
|
||||
)
|
||||
|
||||
type imlTeamModule struct {
|
||||
@@ -35,6 +35,20 @@ type imlTeamModule struct {
|
||||
transaction store.ITransaction `autowired:""`
|
||||
}
|
||||
|
||||
func (m *imlTeamModule) ExportAll(ctx context.Context) ([]*team_dto.ExportTeam, error) {
|
||||
teams, err := m.service.List(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.SliceToSlice(teams, func(t *team.Team) *team_dto.ExportTeam {
|
||||
return &team_dto.ExportTeam{
|
||||
Id: t.Id,
|
||||
Name: t.Name,
|
||||
Description: t.Description,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (m *imlTeamModule) GetTeam(ctx context.Context, id string) (*team_dto.Team, error) {
|
||||
tv, err := m.service.Get(ctx, id)
|
||||
if err != nil {
|
||||
@@ -48,9 +62,9 @@ func (m *imlTeamModule) GetTeam(ctx context.Context, id string) (*team_dto.Team,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return team_dto.ToTeam(tv, serviceCountMap[id], appCountMap[id]), nil
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (m *imlTeamModule) Search(ctx context.Context, keyword string) ([]*team_dto.Item, error) {
|
||||
@@ -58,7 +72,7 @@ func (m *imlTeamModule) Search(ctx context.Context, keyword string) ([]*team_dto
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
serviceCountMap, err := m.serviceService.ServiceCountByTeam(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -78,7 +92,7 @@ func (m *imlTeamModule) Create(ctx context.Context, input *team_dto.CreateTeam)
|
||||
if input.Id == "" {
|
||||
input.Id = uuid.New().String()
|
||||
}
|
||||
|
||||
|
||||
err := m.transaction.Transaction(ctx, func(ctx context.Context) error {
|
||||
if input.Master == "" {
|
||||
input.Master = utils.UserId(ctx)
|
||||
@@ -91,7 +105,7 @@ func (m *imlTeamModule) Create(ctx context.Context, input *team_dto.CreateTeam)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
err = m.memberService.AddMemberTo(ctx, input.Id, input.Master)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -100,7 +114,7 @@ func (m *imlTeamModule) Create(ctx context.Context, input *team_dto.CreateTeam)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
return m.roleMemberService.Add(ctx, &role.AddMember{
|
||||
Role: supperRole.Id,
|
||||
User: input.Master,
|
||||
@@ -120,7 +134,7 @@ func (m *imlTeamModule) Edit(ctx context.Context, id string, input *team_dto.Edi
|
||||
Description: input.Description,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+14
-3
@@ -2,8 +2,9 @@ package team
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/APIParkLab/APIPark/module/system"
|
||||
"reflect"
|
||||
|
||||
|
||||
team_dto "github.com/APIParkLab/APIPark/module/team/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
)
|
||||
@@ -13,17 +14,27 @@ type ITeamModule interface {
|
||||
GetTeam(ctx context.Context, id string) (*team_dto.Team, error)
|
||||
// Search 搜索团队
|
||||
Search(ctx context.Context, keyword string) ([]*team_dto.Item, error)
|
||||
|
||||
|
||||
// Create 创建团队
|
||||
Create(ctx context.Context, input *team_dto.CreateTeam) (*team_dto.Team, error)
|
||||
// Edit 编辑团队
|
||||
Edit(ctx context.Context, id string, input *team_dto.EditTeam) (*team_dto.Team, error)
|
||||
// Delete 删除团队
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
//ExportAll(ctx context.Context) ([]*team_dto.ExportTeam, error)
|
||||
}
|
||||
|
||||
type ITeamExportModule interface {
|
||||
system.IExportModule[team_dto.ExportTeam]
|
||||
}
|
||||
|
||||
func init() {
|
||||
teamModule := new(imlTeamModule)
|
||||
autowire.Auto[ITeamModule](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlTeamModule))
|
||||
return reflect.ValueOf(teamModule)
|
||||
})
|
||||
autowire.Auto[ITeamExportModule](func() reflect.Value {
|
||||
return reflect.ValueOf(teamModule)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user