-
Notifications
You must be signed in to change notification settings - Fork 301
/
service.go
51 lines (43 loc) · 1.34 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package channel
import "github.com/TangSengDaoDao/TangSengDaoDaoServerLib/config"
type IService interface {
// 获取频道设置集合
GetChannelSettings(channelIDs []string) ([]*ChannelSettingResp, error)
}
type service struct {
ctx *config.Context
channelSettingDB *channelSettingDB
}
func NewService(ctx *config.Context) IService {
return &service{
ctx: ctx,
channelSettingDB: newChannelSettingDB(ctx),
}
}
func (s *service) GetChannelSettings(channelIDs []string) ([]*ChannelSettingResp, error) {
channelSettingModels, err := s.channelSettingDB.queryWithChannelIDs(channelIDs)
if err != nil {
return nil, err
}
channelSettingResps := make([]*ChannelSettingResp, 0, len(channelSettingModels))
if len(channelSettingModels) > 0 {
for _, channelSettingM := range channelSettingModels {
channelSettingResps = append(channelSettingResps, newChannelSettingResp(channelSettingM))
}
}
return channelSettingResps, nil
}
type ChannelSettingResp struct {
ChannelID string
ChannelType uint8
ParentChannelID string
ParentChannelType uint8
}
func newChannelSettingResp(m *channelSettingModel) *ChannelSettingResp {
return &ChannelSettingResp{
ChannelID: m.ChannelID,
ChannelType: m.ChannelType,
ParentChannelID: m.ParentChannelID,
ParentChannelType: m.ParentChannelType,
}
}