-
Notifications
You must be signed in to change notification settings - Fork 1
/
dict.go
35 lines (30 loc) · 866 Bytes
/
dict.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
package controller_public
import (
"github.com/anden007/afocus-godf/src/interfaces/interface_manage"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/mvc"
)
type DictController struct {
Ctx iris.Context
Service interface_manage.IDictService
}
func (m *DictController) BeforeActivation(b mvc.BeforeActivation) {
b.Handle("GET", "/getDataByType/{dictType}", "GetDataByType")
}
func (m *DictController) AfterActivation(a mvc.AfterActivation) {
if m.Service == nil {
panic("DictController中的Service尚未注册!")
}
}
func (m *DictController) GetDataByType(dictType string) mvc.Result {
success := true
message := ""
result, err := m.Service.GetDataByType(dictType)
if err != nil {
success = false
message = err.Error()
}
return mvc.Response{
Object: iris.Map{"success": success, "message": message, "result": result},
}
}