2024-01-23 19:30:28 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"mayfly-go/internal/machine/application"
|
|
|
|
|
tagapp "mayfly-go/internal/tag/application"
|
2024-04-09 12:55:51 +08:00
|
|
|
tagentity "mayfly-go/internal/tag/domain/entity"
|
2024-01-23 19:30:28 +08:00
|
|
|
"mayfly-go/pkg/req"
|
|
|
|
|
"mayfly-go/pkg/utils/collx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Dashbord struct {
|
2024-04-09 12:55:51 +08:00
|
|
|
ResourceAuthCertApp tagapp.ResourceAuthCert `inject:""`
|
|
|
|
|
MachineApp application.Machine `inject:""`
|
2024-01-23 19:30:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *Dashbord) Dashbord(rc *req.Ctx) {
|
|
|
|
|
accountId := rc.GetLoginAccount().Id
|
2024-04-09 12:55:51 +08:00
|
|
|
|
|
|
|
|
machienAuthCerts := m.ResourceAuthCertApp.GetAccountAuthCert(accountId, tagentity.TagTypeMachineAuthCert)
|
|
|
|
|
machineCodes := collx.ArrayMap(machienAuthCerts, func(ac *tagentity.ResourceAuthCert) string {
|
|
|
|
|
return ac.ResourceCode
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
machienNum := len(collx.ArrayDeduplicate(machineCodes))
|
2024-01-23 19:30:28 +08:00
|
|
|
|
|
|
|
|
rc.ResData = collx.M{
|
|
|
|
|
"machineNum": machienNum,
|
|
|
|
|
}
|
|
|
|
|
}
|