Skip to content

Commit 8f10fff

Browse files
committed
版本认证中增加公司/组织名
1 parent 5718271 commit 8f10fff

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

internal/db/models/authority/authority_key_dao.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func init() {
3030
}
3131

3232
// UpdateKey 设置Key
33-
func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string, dayTo string, hostname string, macAddresses []string) error {
33+
func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string, dayTo string, hostname string, macAddresses []string, company string) error {
3434
one, err := this.Query(tx).
3535
AscPk().
3636
Find()
@@ -55,6 +55,7 @@ func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string,
5555
}
5656

5757
op.MacAddresses = macAddressesJSON
58+
op.Company = company
5859
op.UpdatedAt = time.Now().Unix()
5960

6061
return this.Save(tx, op)

internal/db/models/authority/authority_key_model.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type AuthorityKey struct {
99
Hostname string `field:"hostname"` // Hostname
1010
MacAddresses string `field:"macAddresses"` // MAC地址
1111
UpdatedAt uint64 `field:"updatedAt"` // 创建/修改时间
12+
Company string `field:"company"` // 公司组织
1213
}
1314

1415
type AuthorityKeyOperator struct {
@@ -19,6 +20,7 @@ type AuthorityKeyOperator struct {
1920
Hostname interface{} // Hostname
2021
MacAddresses interface{} // MAC地址
2122
UpdatedAt interface{} // 创建/修改时间
23+
Company interface{} // 公司组织
2224
}
2325

2426
func NewAuthorityKeyOperator() *AuthorityKeyOperator {

internal/rpc/services/service_authority_key.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (this *AuthorityKeyService) UpdateAuthorityKey(ctx context.Context, req *pb
2222
return nil, err
2323
}
2424
var tx = this.NullTx()
25-
err = authority.SharedAuthorityKeyDAO.UpdateKey(tx, req.Value, req.DayFrom, req.DayTo, req.Hostname, req.MacAddresses)
25+
err = authority.SharedAuthorityKeyDAO.UpdateKey(tx, req.Value, req.DayFrom, req.DayTo, req.Hostname, req.MacAddresses, req.Company)
2626
if err != nil {
2727
return nil, err
2828
}
@@ -58,6 +58,7 @@ func (this *AuthorityKeyService) ReadAuthorityKey(ctx context.Context, req *pb.R
5858
DayTo: key.DayTo,
5959
Hostname: key.Hostname,
6060
MacAddresses: macAddresses,
61+
Company: key.Company,
6162
UpdatedAt: int64(key.UpdatedAt),
6263
}}, nil
6364
}

internal/rpc/services/service_base.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
88
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
9+
"github.com/TeaOSLab/EdgeAPI/internal/db/models/authority"
910
"github.com/TeaOSLab/EdgeAPI/internal/encrypt"
1011
"github.com/TeaOSLab/EdgeAPI/internal/errors"
1112
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
@@ -184,6 +185,8 @@ func (this *BaseService) ValidateNodeId(ctx context.Context, roles ...rpcutils.U
184185
nodeIntId = 0
185186
case rpcutils.UserTypeMonitor:
186187
nodeIntId, err = models.SharedMonitorNodeDAO.FindEnabledMonitorNodeIdWithUniqueId(nil, nodeId)
188+
case rpcutils.UserTypeAuthority:
189+
nodeIntId, err = authority.SharedAuthorityNodeDAO.FindEnabledAuthorityNodeIdWithUniqueId(nil, nodeId)
187190
default:
188191
err = errors.New("unsupported user role '" + apiToken.Role + "'")
189192
}

0 commit comments

Comments
 (0)