mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-09 14:09:52 +00:00
32 lines
612 B
Go
32 lines
612 B
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type Setting struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
Created time.Time `json:"created"`
|
|
Updated time.Time `json:"updated"`
|
|
}
|
|
|
|
type ChannelsConfig map[string]map[string]any
|
|
|
|
func (s *Setting) GetChannelContent(channel string) (map[string]any, error) {
|
|
conf := &ChannelsConfig{}
|
|
if err := json.Unmarshal([]byte(s.Content), conf); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
v, ok := (*conf)[channel]
|
|
if !ok {
|
|
return nil, fmt.Errorf("channel %s not found", channel)
|
|
}
|
|
|
|
return v, nil
|
|
}
|