GetSession 获取会话
(sessionID string)
| 201 | |
| 202 | // GetSession 获取会话 |
| 203 | func (w *Workflow) GetSession(sessionID string) (*WorkflowSession, error) { |
| 204 | if sessionID == "" { |
| 205 | sessionID = w.SessionID |
| 206 | } |
| 207 | |
| 208 | if sessionID == "" { |
| 209 | return nil, errors.New("no session_id provided") |
| 210 | } |
| 211 | |
| 212 | // 从缓存获取 |
| 213 | if w.workflowSession != nil && w.workflowSession.ID == sessionID { |
| 214 | return w.workflowSession, nil |
| 215 | } |
| 216 | |
| 217 | // 从数据库获取(TODO: 实现从数据库读取会话) |
| 218 | _ = w.DB // 数据库功能待实现 |
| 219 | |
| 220 | return nil, fmt.Errorf("session %s not found", sessionID) |
| 221 | } |
| 222 | |
| 223 | // CreateSession 创建会话 |
| 224 | func (w *Workflow) CreateSession(sessionID, userID string) *WorkflowSession { |