common_controller.go
1.8 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
package controllers
import (
categoryQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/query"
categoryService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/service"
partnerQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query"
partnerInfoService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/service"
)
type CommonController struct {
BaseController
}
////Prepare 重写 BaseController 的Prepare方法
func (c *CommonController) Prepare() {
c.BaseController.Prepare()
if ok := c.ValidJWTToken(); !ok {
return
}
}
// GetPartnerList 下拉选项数据通用接口,获取合伙人列表
func (c *CommonController) GetPartnerList() {
query := partnerQuery.ListPartnerInfoQuery{
Limit: 5000,
Offset: 0,
}
newPartnerService := partnerInfoService.NewPartnerInfoService(nil)
_, partners, err := newPartnerService.ListPartnerInfo(&query)
if err != nil {
c.ResponseError(err)
return
}
resp := []map[string]interface{}{}
for i := range partners {
m := map[string]interface{}{
"id": partners[i].Partner.Id,
"account": partners[i].Partner.Account,
"partnerName": partners[i].Partner.PartnerName,
}
resp = append(resp, m)
}
c.ResponseData(resp)
}
// GetPartnerCategory 下拉选项数据通用接口,获取合伙人分类列表
func (c *CommonController) GetPartnerCategory() {
newService := categoryService.NewPartnerCategoryService(nil)
_, categorys, err := newService.ListPartnerCategory(categoryQuery.ListPartnerCategoryCommand{})
if err != nil {
c.ResponseError(err)
return
}
resp := []map[string]interface{}{}
for i := range categorys {
m := map[string]interface{}{
"id": categorys[i].Id,
"name": categorys[i].Name,
}
resp = append(resp, m)
}
c.ResponseData(resp)
}