11 changed files with 244 additions and 35 deletions
@ -0,0 +1,46 @@ |
|||
package api |
|||
|
|||
import ( |
|||
"sync" |
|||
"time" |
|||
) |
|||
|
|||
type SessionStore struct { |
|||
sessions map[string]*Session |
|||
mu sync.RWMutex |
|||
} |
|||
|
|||
func NewSessionStore() *SessionStore { |
|||
return &SessionStore{ |
|||
sessions: make(map[string]*Session), |
|||
} |
|||
} |
|||
|
|||
func (store *SessionStore) Set(sessionID string, session *Session) { |
|||
store.mu.Lock() |
|||
defer store.mu.Unlock() |
|||
store.sessions[sessionID] = session |
|||
} |
|||
|
|||
func (store *SessionStore) Get(sessionID string) (*Session, bool) { |
|||
store.mu.RLock() |
|||
defer store.mu.RUnlock() |
|||
session, ok := store.sessions[sessionID] |
|||
return session, ok |
|||
} |
|||
|
|||
func (store *SessionStore) Delete(sessionID string) { |
|||
store.mu.Lock() |
|||
defer store.mu.Unlock() |
|||
delete(store.sessions, sessionID) |
|||
} |
|||
|
|||
func (store *SessionStore) CleanupSessions() { |
|||
store.mu.Lock() |
|||
defer store.mu.Unlock() |
|||
for id, session := range store.sessions { |
|||
if time.Since(session.LastAccessed) > 24*time.Hour { |
|||
delete(store.sessions, id) |
|||
} |
|||
} |
|||
} |
|||
@ -1,8 +1,23 @@ |
|||
{{define "invoice_search_results"}} {{if .Error}} |
|||
<p class="error">Error: {{.Error}}</p> |
|||
{{else if .invoiceNumber}} |
|||
<h3>Invoice Details</h3> |
|||
<p>Invoice Number: {{.invoiceNumber}}</p> |
|||
<p>Total Price: ${{.totalPrice}}</p> |
|||
<p>Status: {{.status}}</p> |
|||
{{with .customer}} |
|||
<p>Customer: {{.name}}</p> |
|||
{{end}} {{with .job}} |
|||
<p>Job: {{.name}}</p> |
|||
{{end}} {{with .location}} |
|||
<p>Location: {{.name}}</p> |
|||
{{end}} {{if .items}} |
|||
<h4>Items:</h4> |
|||
<ul> |
|||
{{range .}} |
|||
<li> |
|||
<!-- Customize this based on your invoice data structure --> |
|||
Invoice: {{.Number}} - Amount: {{.Amount}} |
|||
</li> |
|||
{{range .items}} |
|||
<li>{{.description}} - ${{.totalPrice}}</li> |
|||
{{end}} |
|||
</ul> |
|||
{{end}} {{else}} |
|||
<p>No invoice found with the given identifier.</p> |
|||
{{end}} {{end}} |
|||
|
|||
Loading…
Reference in new issue