@@ -4,24 +4,25 @@ import (
44 "encoding/json"
55
66 "gorm.io/gorm"
7+ "github.com/masx200/go_ws_sh/types"
78)
89
910// ReadAllSessions 从 sessiondb 中读取所有的 SessionStore 并转换为 Session 结构体切片
10- func ReadAllSessions (sessiondb * gorm.DB ) ([]Session , error ) {
11+ func ReadAllSessions (sessiondb * gorm.DB ) ([]types. Session , error ) {
1112 var sessionStores []SessionStore
1213 // 查询 sessiondb 中的所有 SessionStore 记录
1314 if err := sessiondb .Find (& sessionStores ).Error ; err != nil {
1415 return nil , err
1516 }
1617
17- sessions := make ([]Session , 0 , len (sessionStores ))
18+ sessions := make ([]types. Session , 0 , len (sessionStores ))
1819 for _ , store := range sessionStores {
1920 var args []string
2021 // 将 Args 字段(字符串形式)反序列化为字符串切片
2122 if err := json .Unmarshal ([]byte (store .Args ), & args ); err != nil {
2223 return nil , err
2324 }
24- session := Session {
25+ session := types. Session {
2526 Name : store .Name ,
2627 Cmd : store .Cmd ,
2728 Args : args ,
@@ -35,7 +36,7 @@ func ReadAllSessions(sessiondb *gorm.DB) ([]Session, error) {
3536}
3637
3738// ReadAllSessions 从 sessiondb 中读取所有的 SessionStore 并转换为 Session 结构体切片
38- func ReadAllSessionsWithName (sessiondb * gorm.DB , name string ) ([]Session , error ) {
39+ func ReadAllSessionsWithName (sessiondb * gorm.DB , name string ) ([]types. Session , error ) {
3940 var sessionStores []SessionStore
4041 // 查询 sessiondb 中的所有 SessionStore 记录
4142 if err := sessiondb .Where (
@@ -44,14 +45,14 @@ func ReadAllSessionsWithName(sessiondb *gorm.DB, name string) ([]Session, error)
4445 return nil , err
4546 }
4647
47- sessions := make ([]Session , 0 , len (sessionStores ))
48+ sessions := make ([]types. Session , 0 , len (sessionStores ))
4849 for _ , store := range sessionStores {
4950 var args []string
5051 // 将 Args 字段(字符串形式)反序列化为字符串切片
5152 if err := json .Unmarshal ([]byte (store .Args ), & args ); err != nil {
5253 return nil , err
5354 }
54- session := Session {
55+ session := types. Session {
5556 Name : store .Name ,
5657 Cmd : store .Cmd ,
5758 Args : args ,
0 commit comments