mirror of
https://github.com/weloe/token-go.git
synced 2025-09-27 11:52:12 +08:00
fix: refactor device filter logic
This commit is contained in:
@@ -49,9 +49,6 @@ func NewSession(id string, sessionType string, loginId string) *Session {
|
|||||||
|
|
||||||
// GetFilterTokenSign filter by TokenSign.Device from all TokenSign
|
// GetFilterTokenSign filter by TokenSign.Device from all TokenSign
|
||||||
func (s *Session) GetFilterTokenSign(device string) *list.List {
|
func (s *Session) GetFilterTokenSign(device string) *list.List {
|
||||||
if device == "" {
|
|
||||||
return s.GetTokenSignListCopy()
|
|
||||||
}
|
|
||||||
copyList := list.New()
|
copyList := list.New()
|
||||||
for _, tokenSign := range s.TokenSignList {
|
for _, tokenSign := range s.TokenSignList {
|
||||||
if tokenSign.Device == device {
|
if tokenSign.Device == device {
|
||||||
@@ -113,11 +110,8 @@ func (s *Session) RemoveTokenSignByIndex(i int) {
|
|||||||
|
|
||||||
// GetLastTokenByDevice get TokenSign.Value by device
|
// GetLastTokenByDevice get TokenSign.Value by device
|
||||||
func (s *Session) GetLastTokenByDevice(device string) string {
|
func (s *Session) GetLastTokenByDevice(device string) string {
|
||||||
if device == "" {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
tokenSignList := s.GetFilterTokenSign(device)
|
tokenSignList := s.GetFilterTokenSign(device)
|
||||||
if tokenSign, ok := tokenSignList.Back().Value.(*TokenSign); ok && tokenSign.Device == device {
|
if tokenSign, ok := tokenSignList.Back().Value.(*TokenSign); ok {
|
||||||
return tokenSign.Value
|
return tokenSign.Value
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
Reference in New Issue
Block a user