正在显示
23 个修改的文件
包含
403 行增加
和
136 行删除
@@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" |
8 | ) | 8 | ) |
9 | 9 | ||
10 | -//AdminUserService 管理员相关服务 | 10 | +//AdminPermissionService 管理员权限 |
11 | type AdminPermissionService struct { | 11 | type AdminPermissionService struct { |
12 | } | 12 | } |
13 | 13 | ||
@@ -43,5 +43,6 @@ func (adminPermissionSrv AdminPermissionService) ListAdminPermission(queryOption | @@ -43,5 +43,6 @@ func (adminPermissionSrv AdminPermissionService) ListAdminPermission(queryOption | ||
43 | if err != nil { | 43 | if err != nil { |
44 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 44 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
45 | } | 45 | } |
46 | + err = transactionContext.CommitTransaction() | ||
46 | return permissions, nil | 47 | return permissions, nil |
47 | } | 48 | } |
@@ -68,3 +68,12 @@ func CreateCompanyRepository(options map[string]interface{}) (domain.CompanyRepo | @@ -68,3 +68,12 @@ func CreateCompanyRepository(options map[string]interface{}) (domain.CompanyRepo | ||
68 | } | 68 | } |
69 | return repository.NewCompanyRepository(transactionContext) | 69 | return repository.NewCompanyRepository(transactionContext) |
70 | } | 70 | } |
71 | + | ||
72 | +// CreatePartnerCategoryRepository 合伙人分类数据 | ||
73 | +func CreatePartnerCategoryRepository(options map[string]interface{}) (domain.PartnerCategoryRepository, error) { | ||
74 | + var transactionContext *transaction.TransactionContext | ||
75 | + if value, ok := options["transactionContext"]; ok { | ||
76 | + transactionContext = value.(*transaction.TransactionContext) | ||
77 | + } | ||
78 | + return repository.NewPartnerCategoryRepository(transactionContext) | ||
79 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/query" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | ||
8 | +) | ||
9 | + | ||
10 | +type PartnerCategoryService struct { | ||
11 | +} | ||
12 | + | ||
13 | +func NewPartnerCategoryService(option map[string]interface{}) *PartnerCategoryService { | ||
14 | + newService := new(PartnerCategoryService) | ||
15 | + return newService | ||
16 | +} | ||
17 | + | ||
18 | +func (srv PartnerCategoryService) ListPartnerCategory(q query.ListPartnerCategoryCommand) (int, []domain.PartnerCategory, error) { | ||
19 | + //实际业务 | ||
20 | + var err error | ||
21 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
22 | + if err != nil { | ||
23 | + return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
24 | + } | ||
25 | + if err := transactionContext.StartTransaction(); err != nil { | ||
26 | + return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
27 | + } | ||
28 | + defer func() { | ||
29 | + transactionContext.RollbackTransaction() | ||
30 | + }() | ||
31 | + var ( | ||
32 | + categoryRepository domain.PartnerCategoryRepository | ||
33 | + categorys []domain.PartnerCategory | ||
34 | + cnt int | ||
35 | + ) | ||
36 | + if categoryRepository, err = factory.CreatePartnerCategoryRepository(map[string]interface{}{ | ||
37 | + "transactionContext": transactionContext, | ||
38 | + }); err != nil { | ||
39 | + return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
40 | + } | ||
41 | + cnt, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{}) | ||
42 | + if err != nil { | ||
43 | + return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
44 | + } | ||
45 | + err = transactionContext.CommitTransaction() | ||
46 | + return cnt, categorys, nil | ||
47 | +} |
@@ -16,25 +16,24 @@ type CreatePartnerInfoCommand struct { | @@ -16,25 +16,24 @@ type CreatePartnerInfoCommand struct { | ||
16 | Password string `json:"password,omitempty"` | 16 | Password string `json:"password,omitempty"` |
17 | // 状态(1:启用或者0:禁用) | 17 | // 状态(1:启用或者0:禁用) |
18 | Status int `json:"status"` | 18 | Status int `json:"status"` |
19 | - // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) | ||
20 | - PartnerCategory int `json:"partnerCategory,omitempty"` | 19 | + // 合伙类别 |
20 | + PartnerCategory []int64 `json:"partnerCategory,omitempty"` | ||
21 | //合作时间 | 21 | //合作时间 |
22 | CooperateTime time.Time `json:"cooperateTime"` | 22 | CooperateTime time.Time `json:"cooperateTime"` |
23 | // 区域 | 23 | // 区域 |
24 | RegionInfo *domain.RegionInfo `json:"regionInfo"` | 24 | RegionInfo *domain.RegionInfo `json:"regionInfo"` |
25 | //关联业务员 | 25 | //关联业务员 |
26 | Salesman []domain.Salesman `json:"salesman,omitempty"` | 26 | Salesman []domain.Salesman `json:"salesman,omitempty"` |
27 | + //公司id | ||
28 | + CompanyId int64 `json:"companyId"` | ||
27 | } | 29 | } |
28 | 30 | ||
29 | func (command CreatePartnerInfoCommand) ValidateCommand() error { | 31 | func (command CreatePartnerInfoCommand) ValidateCommand() error { |
30 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { | 32 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { |
31 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") | 33 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") |
32 | } | 34 | } |
33 | - if !(command.PartnerCategory == domain.PARTNER_CATEGORY_1 || | ||
34 | - command.PartnerCategory == domain.PARTNER_CATEGORY_2 || | ||
35 | - command.PartnerCategory == domain.PARTNER_CATEGORY_3 || | ||
36 | - command.PartnerCategory == domain.PARTNER_CATEGORY_4) { | ||
37 | - return lib.ThrowError(lib.ARG_ERROR, "合伙类别错误") | 35 | + if len(command.PartnerCategory) == 0 { |
36 | + return lib.ThrowError(lib.ARG_ERROR, "合伙类别必填") | ||
38 | } | 37 | } |
39 | if len(command.PartnerName) == 0 { | 38 | if len(command.PartnerName) == 0 { |
40 | return lib.ThrowError(lib.ARG_ERROR, "合伙人名称必填") | 39 | return lib.ThrowError(lib.ARG_ERROR, "合伙人名称必填") |
@@ -7,16 +7,14 @@ import ( | @@ -7,16 +7,14 @@ import ( | ||
7 | 7 | ||
8 | type StatusPartnerInfoCommand struct { | 8 | type StatusPartnerInfoCommand struct { |
9 | // 合伙人ID | 9 | // 合伙人ID |
10 | - Id int64 `json:"id"` | 10 | + Ids []int64 `json:"id"` |
11 | Status int `json:"status"` | 11 | Status int `json:"status"` |
12 | + CompanyId int64 `json:"companyId"` | ||
12 | } | 13 | } |
13 | 14 | ||
14 | func (command *StatusPartnerInfoCommand) ValidateCommand() error { | 15 | func (command *StatusPartnerInfoCommand) ValidateCommand() error { |
15 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { | 16 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { |
16 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") | 17 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") |
17 | } | 18 | } |
18 | - if command.Id == 0 { | ||
19 | - return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误") | ||
20 | - } | ||
21 | return nil | 19 | return nil |
22 | } | 20 | } |
@@ -13,25 +13,21 @@ type UpdatePartnerInfoCommand struct { | @@ -13,25 +13,21 @@ type UpdatePartnerInfoCommand struct { | ||
13 | // 状态(1:启用或者0:禁用) | 13 | // 状态(1:启用或者0:禁用) |
14 | Status int `json:"status"` | 14 | Status int `json:"status"` |
15 | // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) | 15 | // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) |
16 | - PartnerCategory int `json:"partnerCategory,omitempty"` | 16 | + PartnerCategory []int64 `json:"partnerCategory,omitempty"` |
17 | // 区域 | 17 | // 区域 |
18 | RegionInfo *domain.RegionInfo `json:"regionInfo"` | 18 | RegionInfo *domain.RegionInfo `json:"regionInfo"` |
19 | //关联业务员 | 19 | //关联业务员 |
20 | Salesman []domain.Salesman `json:"salesman,omitempty"` | 20 | Salesman []domain.Salesman `json:"salesman,omitempty"` |
21 | //合作时间 | 21 | //合作时间 |
22 | CooperateTime time.Time `json:"cooperateTime"` | 22 | CooperateTime time.Time `json:"cooperateTime"` |
23 | + //公司id | ||
24 | + CompanyId int64 `json:"companyId"` | ||
23 | } | 25 | } |
24 | 26 | ||
25 | func (command *UpdatePartnerInfoCommand) ValidateCommand() error { | 27 | func (command *UpdatePartnerInfoCommand) ValidateCommand() error { |
26 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { | 28 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { |
27 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") | 29 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") |
28 | } | 30 | } |
29 | - if !(command.PartnerCategory == domain.PARTNER_CATEGORY_1 || | ||
30 | - command.PartnerCategory == domain.PARTNER_CATEGORY_2 || | ||
31 | - command.PartnerCategory == domain.PARTNER_CATEGORY_3 || | ||
32 | - command.PartnerCategory == domain.PARTNER_CATEGORY_4) { | ||
33 | - return lib.ThrowError(lib.ARG_ERROR, "合伙类别错误") | ||
34 | - } | ||
35 | if command.RegionInfo == nil { | 31 | if command.RegionInfo == nil { |
36 | return lib.ThrowError(lib.ARG_ERROR, "区域必填") | 32 | return lib.ThrowError(lib.ARG_ERROR, "区域必填") |
37 | } | 33 | } |
@@ -3,6 +3,7 @@ package query | @@ -3,6 +3,7 @@ package query | ||
3 | type GetPartnerInfoQuery struct { | 3 | type GetPartnerInfoQuery struct { |
4 | // 合伙人ID | 4 | // 合伙人ID |
5 | Id int64 `json:"id" ` | 5 | Id int64 `json:"id" ` |
6 | + CompanyId int64 `json:"companyId"` | ||
6 | } | 7 | } |
7 | 8 | ||
8 | func (q *GetPartnerInfoQuery) ValidateQuery() error { | 9 | func (q *GetPartnerInfoQuery) ValidateQuery() error { |
@@ -7,6 +7,7 @@ type ListPartnerInfoQuery struct { | @@ -7,6 +7,7 @@ type ListPartnerInfoQuery struct { | ||
7 | RegionInfo string `json:"regionInfo"` | 7 | RegionInfo string `json:"regionInfo"` |
8 | // 合伙人姓名 | 8 | // 合伙人姓名 |
9 | PartnerName string `json:"partnerName"` | 9 | PartnerName string `json:"partnerName"` |
10 | + CompanyId int64 `json:"companyId"` | ||
10 | // 查询偏离量 | 11 | // 查询偏离量 |
11 | Offset int `json:"offset"` | 12 | Offset int `json:"offset"` |
12 | // 查询限制 | 13 | // 查询限制 |
1 | package service | 1 | package service |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
5 | + | ||
4 | "github.com/linmadan/egglib-go/core/application" | 6 | "github.com/linmadan/egglib-go/core/application" |
5 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/command" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/command" |
@@ -19,12 +21,12 @@ func NewPartnerInfoService(options map[string]interface{}) *PartnerInfoService { | @@ -19,12 +21,12 @@ func NewPartnerInfoService(options map[string]interface{}) *PartnerInfoService { | ||
19 | return newPartnerInfoService | 21 | return newPartnerInfoService |
20 | } | 22 | } |
21 | 23 | ||
22 | -// 创建客户价值 | ||
23 | -func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command.CreatePartnerInfoCommand) (data interface{}, err error) { | 24 | +// CreatePartnerInfo 创建合伙人 |
25 | +func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.CreatePartnerInfoCommand) (data interface{}, err error) { | ||
24 | var ( | 26 | var ( |
25 | transactionContext, _ = factory.CreateTransactionContext(nil) | 27 | transactionContext, _ = factory.CreateTransactionContext(nil) |
26 | ) | 28 | ) |
27 | - if err = command.ValidateCommand(); err != nil { | 29 | + if err = cmd.ValidateCommand(); err != nil { |
28 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 30 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
29 | } | 31 | } |
30 | if err = transactionContext.StartTransaction(); err != nil { | 32 | if err = transactionContext.StartTransaction(); err != nil { |
@@ -37,14 +39,12 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command | @@ -37,14 +39,12 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command | ||
37 | var ( | 39 | var ( |
38 | partnerinfoDao *dao.PartnerInfoDao | 40 | partnerinfoDao *dao.PartnerInfoDao |
39 | ) | 41 | ) |
40 | - if v, err := factory.CreatePartnerInfoDao(map[string]interface{}{ | 42 | + if partnerinfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{ |
41 | "transactionContext": transactionContext, | 43 | "transactionContext": transactionContext, |
42 | }); err != nil { | 44 | }); err != nil { |
43 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 45 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
44 | - } else { | ||
45 | - partnerinfoDao = v | ||
46 | } | 46 | } |
47 | - ok, err := partnerinfoDao.PartnerAccountExist(command.Account) | 47 | + ok, err := partnerinfoDao.PartnerAccountExist(cmd.Account) |
48 | if err != nil { | 48 | if err != nil { |
49 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 49 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
50 | } | 50 | } |
@@ -52,37 +52,55 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command | @@ -52,37 +52,55 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(command *command | ||
52 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "账号已存在") | 52 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "账号已存在") |
53 | } | 53 | } |
54 | 54 | ||
55 | - var PartnerInfoRepository domain.PartnerInfoRepository | ||
56 | - if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 55 | + var ( |
56 | + partnerInfoRepository domain.PartnerInfoRepository | ||
57 | + categoryRepository domain.PartnerCategoryRepository | ||
58 | + categorys []domain.PartnerCategory | ||
59 | + ) | ||
60 | + if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | ||
57 | "transactionContext": transactionContext, | 61 | "transactionContext": transactionContext, |
58 | }); err != nil { | 62 | }); err != nil { |
59 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 63 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
60 | } | 64 | } |
65 | + if categoryRepository, err = factory.CreatePartnerCategoryRepository(map[string]interface{}{ | ||
66 | + "transactionContext": transactionContext, | ||
67 | + }); err != nil { | ||
68 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
69 | + } | ||
70 | + _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ | ||
71 | + Ids: cmd.PartnerCategory, | ||
72 | + }) | ||
73 | + if err != nil { | ||
74 | + e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) | ||
75 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
76 | + } | ||
61 | newPartnerInfo := domain.PartnerInfo{ | 77 | newPartnerInfo := domain.PartnerInfo{ |
62 | Partner: domain.Partner{ | 78 | Partner: domain.Partner{ |
63 | - Account: command.Account, | ||
64 | - PartnerName: command.PartnerName, | 79 | + Account: cmd.Account, |
80 | + PartnerName: cmd.PartnerName, | ||
65 | }, | 81 | }, |
66 | - PartnerCategory: command.PartnerCategory, | ||
67 | - Password: command.Password, | ||
68 | - Status: command.Status, | ||
69 | - RegionInfo: command.RegionInfo, | ||
70 | - Salesman: command.Salesman, | ||
71 | - CooperateTime: command.CooperateTime, | ||
72 | - } | ||
73 | - if data, err = PartnerInfoRepository.Save(newPartnerInfo); err != nil { | 82 | + PartnerCategory: 0, |
83 | + Password: cmd.Password, | ||
84 | + Status: cmd.Status, | ||
85 | + RegionInfo: cmd.RegionInfo, | ||
86 | + Salesman: cmd.Salesman, | ||
87 | + CooperateTime: cmd.CooperateTime, | ||
88 | + CompanyId: cmd.CompanyId, | ||
89 | + PartnerCategoryInfos: categorys, | ||
90 | + } | ||
91 | + if err = partnerInfoRepository.Save(&newPartnerInfo); err != nil { | ||
74 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 92 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
75 | } | 93 | } |
76 | err = transactionContext.CommitTransaction() | 94 | err = transactionContext.CommitTransaction() |
77 | - return | 95 | + return newPartnerInfo, nil |
78 | } | 96 | } |
79 | 97 | ||
80 | // GetPartnerInfo 返回合伙人 | 98 | // GetPartnerInfo 返回合伙人 |
81 | -func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command query.GetPartnerInfoQuery) (data *domain.PartnerInfo, err error) { | 99 | +func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerInfoQuery) (data *domain.PartnerInfo, err error) { |
82 | var ( | 100 | var ( |
83 | transactionContext, _ = factory.CreateTransactionContext(nil) | 101 | transactionContext, _ = factory.CreateTransactionContext(nil) |
84 | ) | 102 | ) |
85 | - if err = command.ValidateQuery(); err != nil { | 103 | + if err = q.ValidateQuery(); err != nil { |
86 | return nil, lib.ThrowError(lib.ARG_ERROR, err.Error()) | 104 | return nil, lib.ThrowError(lib.ARG_ERROR, err.Error()) |
87 | } | 105 | } |
88 | if err := transactionContext.StartTransaction(); err != nil { | 106 | if err := transactionContext.StartTransaction(); err != nil { |
@@ -91,26 +109,52 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command query.GetPa | @@ -91,26 +109,52 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(command query.GetPa | ||
91 | defer func() { | 109 | defer func() { |
92 | transactionContext.RollbackTransaction() | 110 | transactionContext.RollbackTransaction() |
93 | }() | 111 | }() |
94 | - var PartnerInfoRepository domain.PartnerInfoRepository | 112 | + var ( |
113 | + PartnerInfoRepository domain.PartnerInfoRepository | ||
114 | + categoryRepository domain.PartnerCategoryRepository | ||
115 | + categorys []domain.PartnerCategory | ||
116 | + partnerData *domain.PartnerInfo | ||
117 | + ) | ||
95 | if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 118 | if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ |
96 | "transactionContext": transactionContext, | 119 | "transactionContext": transactionContext, |
97 | }); err != nil { | 120 | }); err != nil { |
98 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 121 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
99 | } | 122 | } |
100 | - data, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: command.Id}) | 123 | + partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: q.Id}) |
101 | if err != nil { | 124 | if err != nil { |
102 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 125 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
103 | } | 126 | } |
127 | + if !partnerData.IsCompany(q.CompanyId) { | ||
128 | + return nil, lib.ThrowError(lib.BUSINESS_ERROR, "企业信息异常操作") | ||
129 | + } | ||
130 | + if categoryRepository, err = factory.CreatePartnerCategoryRepository(map[string]interface{}{ | ||
131 | + "transactionContext": transactionContext, | ||
132 | + }); err != nil { | ||
133 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
134 | + } | ||
135 | + categoryIds := []int64{} | ||
136 | + for _, v := range partnerData.PartnerCategoryInfos { | ||
137 | + categoryIds = append(categoryIds, v.Id) | ||
138 | + } | ||
139 | + if len(categoryIds) > 0 { | ||
140 | + _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ | ||
141 | + Ids: categoryIds, | ||
142 | + }) | ||
143 | + if err != nil { | ||
144 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
145 | + } | ||
146 | + } | ||
147 | + partnerData.PartnerCategoryInfos = categorys | ||
104 | err = transactionContext.CommitTransaction() | 148 | err = transactionContext.CommitTransaction() |
105 | - return | 149 | + return partnerData, nil |
106 | } | 150 | } |
107 | 151 | ||
108 | //UpdatePartnerInfo 更新合伙人 | 152 | //UpdatePartnerInfo 更新合伙人 |
109 | -func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInfoCommand *command.UpdatePartnerInfoCommand) (err error) { | 153 | +func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.UpdatePartnerInfoCommand) (err error) { |
110 | var ( | 154 | var ( |
111 | transactionContext, _ = factory.CreateTransactionContext(nil) | 155 | transactionContext, _ = factory.CreateTransactionContext(nil) |
112 | ) | 156 | ) |
113 | - if err = updatePartnerInfoCommand.ValidateCommand(); err != nil { | 157 | + if err = cmd.ValidateCommand(); err != nil { |
114 | return application.ThrowError(application.ARG_ERROR, err.Error()) | 158 | return application.ThrowError(application.ARG_ERROR, err.Error()) |
115 | } | 159 | } |
116 | if err := transactionContext.StartTransaction(); err != nil { | 160 | if err := transactionContext.StartTransaction(); err != nil { |
@@ -119,24 +163,43 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInf | @@ -119,24 +163,43 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(updatePartnerInf | ||
119 | defer func() { | 163 | defer func() { |
120 | transactionContext.RollbackTransaction() | 164 | transactionContext.RollbackTransaction() |
121 | }() | 165 | }() |
122 | - var partnerInfoRepository domain.PartnerInfoRepository | 166 | + var ( |
167 | + partnerInfoRepository domain.PartnerInfoRepository | ||
168 | + categoryRepository domain.PartnerCategoryRepository | ||
169 | + categorys []domain.PartnerCategory | ||
170 | + ) | ||
123 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 171 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ |
124 | "transactionContext": transactionContext, | 172 | "transactionContext": transactionContext, |
125 | }); err != nil { | 173 | }); err != nil { |
126 | return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 174 | return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
127 | } | 175 | } |
176 | + if categoryRepository, err = factory.CreatePartnerCategoryRepository(map[string]interface{}{ | ||
177 | + "transactionContext": transactionContext, | ||
178 | + }); err != nil { | ||
179 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
180 | + } | ||
181 | + _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ | ||
182 | + Ids: cmd.PartnerCategory, | ||
183 | + }) | ||
184 | + if err != nil { | ||
185 | + e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) | ||
186 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
187 | + } | ||
128 | partnerInfo, err := partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{ | 188 | partnerInfo, err := partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{ |
129 | - UserId: updatePartnerInfoCommand.Id, | 189 | + UserId: cmd.Id, |
130 | }) | 190 | }) |
131 | if err != nil { | 191 | if err != nil { |
132 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 192 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
133 | } | 193 | } |
134 | - partnerInfo.PartnerCategory = updatePartnerInfoCommand.PartnerCategory | ||
135 | - partnerInfo.Salesman = updatePartnerInfoCommand.Salesman | ||
136 | - partnerInfo.Status = updatePartnerInfoCommand.Status | ||
137 | - partnerInfo.RegionInfo = updatePartnerInfoCommand.RegionInfo | ||
138 | - partnerInfo.CooperateTime = updatePartnerInfoCommand.CooperateTime | ||
139 | - if _, err = partnerInfoRepository.Save(*partnerInfo); err != nil { | 194 | + if !partnerInfo.IsCompany(cmd.CompanyId) { |
195 | + return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作") | ||
196 | + } | ||
197 | + partnerInfo.Salesman = cmd.Salesman | ||
198 | + partnerInfo.Status = cmd.Status | ||
199 | + partnerInfo.RegionInfo = cmd.RegionInfo | ||
200 | + partnerInfo.CooperateTime = cmd.CooperateTime | ||
201 | + partnerInfo.PartnerCategoryInfos = categorys | ||
202 | + if err = partnerInfoRepository.Save(partnerInfo); err != nil { | ||
140 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 203 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
141 | } | 204 | } |
142 | transactionContext.CommitTransaction() | 205 | transactionContext.CommitTransaction() |
@@ -162,16 +225,24 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | @@ -162,16 +225,24 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | ||
162 | transactionContext.RollbackTransaction() | 225 | transactionContext.RollbackTransaction() |
163 | } | 226 | } |
164 | }() | 227 | }() |
165 | - var partnerInfoRepository domain.PartnerInfoRepository | 228 | + var ( |
229 | + partnerInfoRepository domain.PartnerInfoRepository | ||
230 | + categoryRepository domain.PartnerCategoryRepository | ||
231 | + categorys []domain.PartnerCategory | ||
232 | + ) | ||
166 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 233 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ |
167 | "transactionContext": transactionContext, | 234 | "transactionContext": transactionContext, |
168 | }); err != nil { | 235 | }); err != nil { |
169 | return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 236 | return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
170 | } | 237 | } |
238 | + if categoryRepository, err = factory.CreatePartnerCategoryRepository(map[string]interface{}{ | ||
239 | + "transactionContext": transactionContext, | ||
240 | + }); err != nil { | ||
241 | + return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
242 | + } | ||
171 | queryOption := domain.PartnerFindQuery{ | 243 | queryOption := domain.PartnerFindQuery{ |
172 | Offset: listPartnerInfoQuery.Offset, | 244 | Offset: listPartnerInfoQuery.Offset, |
173 | Limit: listPartnerInfoQuery.Limit, | 245 | Limit: listPartnerInfoQuery.Limit, |
174 | - | ||
175 | PartnerName: listPartnerInfoQuery.PartnerName, | 246 | PartnerName: listPartnerInfoQuery.PartnerName, |
176 | } | 247 | } |
177 | if listPartnerInfoQuery.Partnertype > 0 { | 248 | if listPartnerInfoQuery.Partnertype > 0 { |
@@ -187,17 +258,37 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | @@ -187,17 +258,37 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | ||
187 | if count, err = partnerInfoRepository.CountAll(queryOption); err != nil { | 258 | if count, err = partnerInfoRepository.CountAll(queryOption); err != nil { |
188 | return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 259 | return 0, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
189 | } | 260 | } |
261 | + _, categorys, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{}) | ||
262 | + if err != nil { | ||
263 | + return count, partnerInfos, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
264 | + } | ||
265 | + categorysMap := make(map[int64]domain.PartnerCategory) | ||
266 | + for i := range categorys { | ||
267 | + categorysMap[categorys[i].Id] = categorys[i] | ||
268 | + } | ||
269 | + for i := range partnerInfos { | ||
270 | + categoryInPartner := []domain.PartnerCategory{} | ||
271 | + for _, vv := range partnerInfos[i].PartnerCategoryInfos { | ||
272 | + if categoryData, ok := categorysMap[vv.Id]; ok { | ||
273 | + categoryInPartner = append(categoryInPartner, categoryData) | ||
274 | + } | ||
275 | + } | ||
276 | + partnerInfos[i].PartnerCategoryInfos = categoryInPartner | ||
277 | + } | ||
190 | if err = transactionContext.CommitTransaction(); err != nil { | 278 | if err = transactionContext.CommitTransaction(); err != nil { |
191 | return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 279 | return 0, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
192 | } | 280 | } |
193 | return count, partnerInfos, nil | 281 | return count, partnerInfos, nil |
194 | } | 282 | } |
195 | 283 | ||
196 | -func (PartnerInfoService *PartnerInfoService) UpdateStatus(command command.StatusPartnerInfoCommand) (err error) { | 284 | +func (PartnerInfoService *PartnerInfoService) UpdateStatus(cmd command.StatusPartnerInfoCommand) (err error) { |
285 | + if len(cmd.Ids) == 0 { | ||
286 | + return nil | ||
287 | + } | ||
197 | var ( | 288 | var ( |
198 | transactionContext, _ = factory.CreateTransactionContext(nil) | 289 | transactionContext, _ = factory.CreateTransactionContext(nil) |
199 | ) | 290 | ) |
200 | - if err = command.ValidateCommand(); err != nil { | 291 | + if err = cmd.ValidateCommand(); err != nil { |
201 | return application.ThrowError(application.ARG_ERROR, err.Error()) | 292 | return application.ThrowError(application.ARG_ERROR, err.Error()) |
202 | } | 293 | } |
203 | if err := transactionContext.StartTransaction(); err != nil { | 294 | if err := transactionContext.StartTransaction(); err != nil { |
@@ -206,21 +297,18 @@ func (PartnerInfoService *PartnerInfoService) UpdateStatus(command command.Statu | @@ -206,21 +297,18 @@ func (PartnerInfoService *PartnerInfoService) UpdateStatus(command command.Statu | ||
206 | defer func() { | 297 | defer func() { |
207 | transactionContext.RollbackTransaction() | 298 | transactionContext.RollbackTransaction() |
208 | }() | 299 | }() |
209 | - var partnerInfoRepository domain.PartnerInfoRepository | ||
210 | - if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 300 | + var ( |
301 | + partnerinfoDao *dao.PartnerInfoDao | ||
302 | + ) | ||
303 | + if partnerinfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{ | ||
211 | "transactionContext": transactionContext, | 304 | "transactionContext": transactionContext, |
212 | }); err != nil { | 305 | }); err != nil { |
213 | return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 306 | return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
214 | } | 307 | } |
215 | - partnerInfo, err := partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{ | ||
216 | - UserId: command.Id, | ||
217 | - }) | 308 | + err = partnerinfoDao.UpdatePartnerStatus(cmd.Ids, cmd.CompanyId, cmd.Status) |
218 | if err != nil { | 309 | if err != nil { |
219 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
220 | - } | ||
221 | - partnerInfo.Status = command.Status | ||
222 | - if _, err = partnerInfoRepository.Save(*partnerInfo); err != nil { | ||
223 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 310 | + e := fmt.Sprintf("更新合伙人(id=%v)的数据失败;%s", cmd.Ids, err) |
311 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
224 | } | 312 | } |
225 | transactionContext.CommitTransaction() | 313 | transactionContext.CommitTransaction() |
226 | return | 314 | return |
@@ -142,7 +142,7 @@ func (service UsersService) GetUserPofile(userId int64) (interface{}, error) { | @@ -142,7 +142,7 @@ func (service UsersService) GetUserPofile(userId int64) (interface{}, error) { | ||
142 | 142 | ||
143 | //buildUserPofile 组装前端需要的数据 ,用户登录后获取的配置 | 143 | //buildUserPofile 组装前端需要的数据 ,用户登录后获取的配置 |
144 | func (service UsersService) buildUserPofile(userData domain.Users, permissionList []domain.AdminPermission) map[string]interface{} { | 144 | func (service UsersService) buildUserPofile(userData domain.Users, permissionList []domain.AdminPermission) map[string]interface{} { |
145 | - menus := make([]map[string]interface{}, len(permissionList)) | 145 | + menus := make([]map[string]interface{}, 0, len(permissionList)) |
146 | for _, v := range permissionList { | 146 | for _, v := range permissionList { |
147 | m := map[string]interface{}{ | 147 | m := map[string]interface{}{ |
148 | "code": v.Code, | 148 | "code": v.Code, |
@@ -263,7 +263,7 @@ func (service UsersService) GetUserList(queryOption query.UserListQuery) (int, [ | @@ -263,7 +263,7 @@ func (service UsersService) GetUserList(queryOption query.UserListQuery) (int, [ | ||
263 | 263 | ||
264 | //buildGetUserList 组装构建前端需要的用户列表数据 | 264 | //buildGetUserList 组装构建前端需要的用户列表数据 |
265 | func (service UsersService) buildGetUserList(usersData []domain.Users, permissionData []domain.AdminPermission) []map[string]interface{} { | 265 | func (service UsersService) buildGetUserList(usersData []domain.Users, permissionData []domain.AdminPermission) []map[string]interface{} { |
266 | - result := make([]map[string]interface{}, len(usersData)) | 266 | + result := make([]map[string]interface{}, 0, len(usersData)) |
267 | permissionMap := map[int64]domain.AdminPermission{} | 267 | permissionMap := map[int64]domain.AdminPermission{} |
268 | for i := range permissionData { | 268 | for i := range permissionData { |
269 | permissionMap[permissionData[i].Id] = permissionData[i] | 269 | permissionMap[permissionData[i].Id] = permissionData[i] |
@@ -366,12 +366,12 @@ func (service UsersService) buildGetUserData(userData *domain.Users, partnerList | @@ -366,12 +366,12 @@ func (service UsersService) buildGetUserData(userData *domain.Users, partnerList | ||
366 | if userData.IsUsable() { | 366 | if userData.IsUsable() { |
367 | result["status"] = 1 | 367 | result["status"] = 1 |
368 | } | 368 | } |
369 | - permissionIds := make([]int64, len(userData.Permission)) | 369 | + permissionIds := make([]int64, 0, len(userData.Permission)) |
370 | for _, v := range userData.Permission { | 370 | for _, v := range userData.Permission { |
371 | permissionIds = append(permissionIds, v.Id) | 371 | permissionIds = append(permissionIds, v.Id) |
372 | } | 372 | } |
373 | result["permissionType"] = permissionIds | 373 | result["permissionType"] = permissionIds |
374 | - checkedPartner := make([]map[string]interface{}, len(partnerList)) | 374 | + checkedPartner := make([]map[string]interface{}, 0, len(partnerList)) |
375 | for i := range partnerList { | 375 | for i := range partnerList { |
376 | m := map[string]interface{}{ | 376 | m := map[string]interface{}{ |
377 | "id": partnerList[i].Partner.Id, | 377 | "id": partnerList[i].Partner.Id, |
@@ -452,8 +452,8 @@ func (service UsersService) EditUserPermission(cmd command.EditUserPermissionCom | @@ -452,8 +452,8 @@ func (service UsersService) EditUserPermission(cmd command.EditUserPermissionCom | ||
452 | } | 452 | } |
453 | } | 453 | } |
454 | var ( | 454 | var ( |
455 | - partners = make([]domain.Partner, len(partnerList)) | ||
456 | - permissionsBase = make([]domain.AdminPermissionBase, len(permissionList)) | 455 | + partners = make([]domain.Partner, 0, len(partnerList)) |
456 | + permissionsBase = make([]domain.AdminPermissionBase, 0) | ||
457 | ) | 457 | ) |
458 | for i := range partnerList { | 458 | for i := range partnerList { |
459 | p := partnerList[i].Partner | 459 | p := partnerList[i].Partner |
@@ -4,9 +4,9 @@ import "os" | @@ -4,9 +4,9 @@ import "os" | ||
4 | 4 | ||
5 | var POSTGRESQL_DB_NAME = "partner_dev" | 5 | var POSTGRESQL_DB_NAME = "partner_dev" |
6 | var POSTGRESQL_USER = "postgres" | 6 | var POSTGRESQL_USER = "postgres" |
7 | -var POSTGRESQL_PASSWORD = "postgres_15432" | ||
8 | -var POSTGRESQL_HOST = "101.37.68.23" | ||
9 | -var POSTGRESQL_PORT = "15432" | 7 | +var POSTGRESQL_PASSWORD = "eagle1010" |
8 | +var POSTGRESQL_HOST = "114.55.200.59" | ||
9 | +var POSTGRESQL_PORT = "31543" | ||
10 | var DISABLE_CREATE_TABLE = true | 10 | var DISABLE_CREATE_TABLE = true |
11 | var DISABLE_SQL_GENERATE_PRINT = false | 11 | var DISABLE_SQL_GENERATE_PRINT = false |
12 | 12 |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | // 合伙人分类信息 | 3 | // 合伙人分类信息 |
4 | -type PartnerCategoryInfo struct { | 4 | +type PartnerCategory struct { |
5 | // 唯一标识 | 5 | // 唯一标识 |
6 | Id int64 `json:"id"` | 6 | Id int64 `json:"id"` |
7 | // 名称 | 7 | // 名称 |
8 | Name string `json:"name"` | 8 | Name string `json:"name"` |
9 | } | 9 | } |
10 | 10 | ||
11 | -type PartnerCategoryInfoRepository interface { | ||
12 | - Find(queryOptions map[string]interface{}) (int64, []*PartnerCategoryInfo, error) | 11 | +type PartnerCategoryFindQuery struct { |
12 | + Ids []int64 | ||
13 | +} | ||
14 | +type PartnerCategoryRepository interface { | ||
15 | + Find(PartnerCategoryFindQuery) (int, []PartnerCategory, error) | ||
13 | } | 16 | } |
@@ -11,20 +11,20 @@ const ( | @@ -11,20 +11,20 @@ const ( | ||
11 | ) | 11 | ) |
12 | 12 | ||
13 | //合伙类别 (1.事业合伙人 2.业务合伙人 3.研发合伙人) | 13 | //合伙类别 (1.事业合伙人 2.业务合伙人 3.研发合伙人) |
14 | -const ( | ||
15 | - PARTNER_CATEGORY_1 int = 1 | ||
16 | - PARTNER_CATEGORY_2 int = 2 | ||
17 | - PARTNER_CATEGORY_3 int = 3 | ||
18 | - PARTNER_CATEGORY_4 int = 4 | ||
19 | -) | 14 | +// const ( |
15 | +// PARTNER_CATEGORY_1 int = 1 | ||
16 | +// PARTNER_CATEGORY_2 int = 2 | ||
17 | +// PARTNER_CATEGORY_3 int = 3 | ||
18 | +// PARTNER_CATEGORY_4 int = 4 | ||
19 | +// ) | ||
20 | 20 | ||
21 | -//partnerCategoryMap 合伙类别键值对 (只读,请勿在运行时修改) | ||
22 | -var partnerCategoryMap = map[int]string{ | ||
23 | - PARTNER_CATEGORY_1: "事业合伙人", | ||
24 | - PARTNER_CATEGORY_2: "业务合伙人", | ||
25 | - PARTNER_CATEGORY_3: "研发合伙人", | ||
26 | - PARTNER_CATEGORY_4: "业务-产品应用合伙人", | ||
27 | -} | 21 | +// //partnerCategoryMap 合伙类别键值对 (只读,请勿在运行时修改) |
22 | +// var partnerCategoryMap = map[int]string{ | ||
23 | +// PARTNER_CATEGORY_1: "事业合伙人", | ||
24 | +// PARTNER_CATEGORY_2: "业务合伙人", | ||
25 | +// PARTNER_CATEGORY_3: "研发合伙人", | ||
26 | +// PARTNER_CATEGORY_4: "业务-产品应用合伙人", | ||
27 | +// } | ||
28 | 28 | ||
29 | type PartnerInfo struct { | 29 | type PartnerInfo struct { |
30 | Partner Partner `json:"partner"` | 30 | Partner Partner `json:"partner"` |
@@ -43,25 +43,21 @@ type PartnerInfo struct { | @@ -43,25 +43,21 @@ type PartnerInfo struct { | ||
43 | //关联业务员 | 43 | //关联业务员 |
44 | Salesman []Salesman `json:"salesman"` | 44 | Salesman []Salesman `json:"salesman"` |
45 | //合伙人分类 | 45 | //合伙人分类 |
46 | - PartnerCategoryInfos []PartnerCategoryInfo `json:"partnerCategoryInfos"` | 46 | + PartnerCategoryInfos []PartnerCategory `json:"partnerCategoryInfos"` |
47 | //合伙类别 | 47 | //合伙类别 |
48 | PartnerCategory int `json:"partnerCategory"` | 48 | PartnerCategory int `json:"partnerCategory"` |
49 | //公司id | 49 | //公司id |
50 | CompanyId int64 `json:"companyId"` | 50 | CompanyId int64 `json:"companyId"` |
51 | } | 51 | } |
52 | 52 | ||
53 | -func (p *PartnerInfo) GetPartnerCategory() map[int]string { | ||
54 | - categoryMap := map[int]string{} | ||
55 | - if v, ok := partnerCategoryMap[p.PartnerCategory]; ok { | ||
56 | - categoryMap[p.PartnerCategory] = v | ||
57 | - } | ||
58 | - return categoryMap | ||
59 | -} | ||
60 | - | ||
61 | func (p *PartnerInfo) IsUsable() bool { | 53 | func (p *PartnerInfo) IsUsable() bool { |
62 | return p.Status == PARTNER_STATUS_YES | 54 | return p.Status == PARTNER_STATUS_YES |
63 | } | 55 | } |
64 | 56 | ||
57 | +func (p *PartnerInfo) IsCompany(companyId int64) bool { | ||
58 | + return p.CompanyId == companyId | ||
59 | +} | ||
60 | + | ||
65 | type PartnerFindOneQuery struct { | 61 | type PartnerFindOneQuery struct { |
66 | UserId int64 | 62 | UserId int64 |
67 | AccountEqual string | 63 | AccountEqual string |
@@ -79,7 +75,7 @@ type PartnerFindQuery struct { | @@ -79,7 +75,7 @@ type PartnerFindQuery struct { | ||
79 | } | 75 | } |
80 | 76 | ||
81 | type PartnerInfoRepository interface { | 77 | type PartnerInfoRepository interface { |
82 | - Save(dm PartnerInfo) (*PartnerInfo, error) | 78 | + Save(dm *PartnerInfo) error |
83 | FindOne(queryOptions PartnerFindOneQuery) (*PartnerInfo, error) | 79 | FindOne(queryOptions PartnerFindOneQuery) (*PartnerInfo, error) |
84 | Find(queryOptions PartnerFindQuery) ([]PartnerInfo, error) | 80 | Find(queryOptions PartnerFindQuery) ([]PartnerInfo, error) |
85 | CountAll(queryOptions PartnerFindQuery) (int, error) | 81 | CountAll(queryOptions PartnerFindQuery) (int, error) |
@@ -30,3 +30,14 @@ func (dao PartnerInfoDao) PartnerAccountExist(account string) (bool, error) { | @@ -30,3 +30,14 @@ func (dao PartnerInfoDao) PartnerAccountExist(account string) (bool, error) { | ||
30 | 30 | ||
31 | return ok, err | 31 | return ok, err |
32 | } | 32 | } |
33 | + | ||
34 | +func (dao PartnerInfoDao) UpdatePartnerStatus(ids []int64, companyId int64, status int) error { | ||
35 | + tx := dao.transactionContext.PgDd | ||
36 | + m := &models.PartnerInfo{} | ||
37 | + _, err := tx.Model(m). | ||
38 | + WhereIn("id in (?)", ids). | ||
39 | + Where("company_id=?", companyId). | ||
40 | + Set("status=?", status). | ||
41 | + Update() | ||
42 | + return err | ||
43 | +} |
@@ -33,7 +33,7 @@ type PartnerInfo struct { | @@ -33,7 +33,7 @@ type PartnerInfo struct { | ||
33 | // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) | 33 | // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) |
34 | PartnerCategory int `pg:",default:1"` //partner_category | 34 | PartnerCategory int `pg:",default:1"` //partner_category |
35 | //合伙类别 | 35 | //合伙类别 |
36 | - PartnerCategoryInfos []PartnerCategoryInfo | 36 | + PartnerCategoryInfos []struct{ Id int64 } |
37 | //公司id | 37 | //公司id |
38 | CompanyId int64 | 38 | CompanyId int64 |
39 | } | 39 | } |
1 | +package repository | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" | ||
8 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | ||
9 | +) | ||
10 | + | ||
11 | +type PartnerCategoryRepository struct { | ||
12 | + transactionContext *transaction.TransactionContext | ||
13 | +} | ||
14 | + | ||
15 | +func (repository PartnerCategoryRepository) transformPgModelToDomainModel(m *models.PartnerCategoryInfo) (domain.PartnerCategory, error) { | ||
16 | + pc := domain.PartnerCategory{ | ||
17 | + Id: m.Id, | ||
18 | + Name: m.Name, | ||
19 | + } | ||
20 | + return pc, nil | ||
21 | +} | ||
22 | + | ||
23 | +func NewPartnerCategoryRepository(transactionContext *transaction.TransactionContext) (*PartnerCategoryRepository, error) { | ||
24 | + if transactionContext == nil { | ||
25 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
26 | + } | ||
27 | + return &PartnerCategoryRepository{transactionContext: transactionContext}, nil | ||
28 | +} | ||
29 | + | ||
30 | +func (repository PartnerCategoryRepository) Find(queryOptions domain.PartnerCategoryFindQuery) (int, []domain.PartnerCategory, error) { | ||
31 | + tx := repository.transactionContext.PgTx | ||
32 | + var ( | ||
33 | + PartnerCategoryInfoModels []models.PartnerCategoryInfo | ||
34 | + cnt int | ||
35 | + err error | ||
36 | + ) | ||
37 | + query := tx.Model(&PartnerCategoryInfoModels) | ||
38 | + if len(queryOptions.Ids) > 0 { | ||
39 | + query = query.WhereIn("id in(?)", queryOptions.Ids) | ||
40 | + } | ||
41 | + if cnt, err = query.SelectAndCount(); err != nil { | ||
42 | + return 0, nil, err | ||
43 | + } | ||
44 | + partnerCategoryInfos := make([]domain.PartnerCategory, 0, len(PartnerCategoryInfoModels)) | ||
45 | + for i := range PartnerCategoryInfoModels { | ||
46 | + m, _ := repository.transformPgModelToDomainModel(&PartnerCategoryInfoModels[i]) | ||
47 | + partnerCategoryInfos = append(partnerCategoryInfos, m) | ||
48 | + } | ||
49 | + return cnt, partnerCategoryInfos, nil | ||
50 | +} |
@@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | 5 | ||
6 | + "github.com/go-pg/pg/v10/orm" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" |
@@ -32,6 +33,14 @@ func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerIn | @@ -32,6 +33,14 @@ func (repository *PartnerInfoRepository) transformPgModelToDomainModel(partnerIn | ||
32 | CooperateTime: partnerInfoModel.CooperateTime, | 33 | CooperateTime: partnerInfoModel.CooperateTime, |
33 | CompanyId: partnerInfoModel.CompanyId, | 34 | CompanyId: partnerInfoModel.CompanyId, |
34 | } | 35 | } |
36 | + p := []domain.PartnerCategory{} | ||
37 | + for _, v := range partnerInfoModel.PartnerCategoryInfos { | ||
38 | + catagory := domain.PartnerCategory{ | ||
39 | + Id: v.Id, | ||
40 | + } | ||
41 | + p = append(p, catagory) | ||
42 | + } | ||
43 | + m.PartnerCategoryInfos = p | ||
35 | return m, nil | 44 | return m, nil |
36 | } | 45 | } |
37 | 46 | ||
@@ -42,7 +51,7 @@ func NewPartnerInfoRepository(transactionContext *transaction.TransactionContext | @@ -42,7 +51,7 @@ func NewPartnerInfoRepository(transactionContext *transaction.TransactionContext | ||
42 | return &PartnerInfoRepository{transactionContext: transactionContext}, nil | 51 | return &PartnerInfoRepository{transactionContext: transactionContext}, nil |
43 | } | 52 | } |
44 | 53 | ||
45 | -func (repository *PartnerInfoRepository) Save(dm domain.PartnerInfo) (*domain.PartnerInfo, error) { | 54 | +func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) error { |
46 | var ( | 55 | var ( |
47 | err error | 56 | err error |
48 | tx = repository.transactionContext.PgTx | 57 | tx = repository.transactionContext.PgTx |
@@ -58,23 +67,32 @@ func (repository *PartnerInfoRepository) Save(dm domain.PartnerInfo) (*domain.Pa | @@ -58,23 +67,32 @@ func (repository *PartnerInfoRepository) Save(dm domain.PartnerInfo) (*domain.Pa | ||
58 | RegionInfo: dm.RegionInfo, | 67 | RegionInfo: dm.RegionInfo, |
59 | CooperateTime: dm.CooperateTime, | 68 | CooperateTime: dm.CooperateTime, |
60 | CompanyId: dm.CompanyId, | 69 | CompanyId: dm.CompanyId, |
70 | + // PartnerCategoryInfos: dm.PartnerCategoryInfos, | ||
71 | + } | ||
72 | + categorys := []struct{ Id int64 }{} | ||
73 | + for _, v := range dm.PartnerCategoryInfos { | ||
74 | + temp := struct{ Id int64 }{ | ||
75 | + Id: v.Id, | ||
61 | } | 76 | } |
77 | + categorys = append(categorys, temp) | ||
78 | + } | ||
79 | + m.PartnerCategoryInfos = categorys | ||
62 | if m.Id == 0 { | 80 | if m.Id == 0 { |
63 | err = tx.Insert(m) | 81 | err = tx.Insert(m) |
64 | dm.Partner.Id = m.Id | 82 | dm.Partner.Id = m.Id |
65 | if err != nil { | 83 | if err != nil { |
66 | - return nil, err | 84 | + return err |
67 | } | 85 | } |
68 | } else { | 86 | } else { |
69 | _, err = tx.Model(m).WherePK(). | 87 | _, err = tx.Model(m).WherePK(). |
70 | Column("partner_name", "account", "password", "status", "partner_category", "salesman", | 88 | Column("partner_name", "account", "password", "status", "partner_category", "salesman", |
71 | - "region_info", "cooperate_time", "update_at"). | 89 | + "region_info", "cooperate_time", "update_at", "partner_category_infos"). |
72 | Update() | 90 | Update() |
73 | if err != nil { | 91 | if err != nil { |
74 | - return nil, err | 92 | + return err |
75 | } | 93 | } |
76 | } | 94 | } |
77 | - return &dm, nil | 95 | + return nil |
78 | } | 96 | } |
79 | 97 | ||
80 | func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFindOneQuery) (*domain.PartnerInfo, error) { | 98 | func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFindOneQuery) (*domain.PartnerInfo, error) { |
@@ -107,8 +125,14 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer | @@ -107,8 +125,14 @@ func (repository *PartnerInfoRepository) Find(queryOption domain.PartnerFindQuer | ||
107 | if queryOption.RegionInfo != nil { | 125 | if queryOption.RegionInfo != nil { |
108 | query = query.Where("region_info::jsonb->>'regionName' like ?", "%"+queryOption.RegionInfo.RegionName+"%") | 126 | query = query.Where("region_info::jsonb->>'regionName' like ?", "%"+queryOption.RegionInfo.RegionName+"%") |
109 | } | 127 | } |
128 | + //合伙人类型 | ||
110 | if len(queryOption.PartnerCategory) > 0 { | 129 | if len(queryOption.PartnerCategory) > 0 { |
111 | - query = query.WhereIn("partner_category in(?)", queryOption.PartnerCategory) | 130 | + query = query.WhereGroup(func(q *orm.Query) (*orm.Query, error) { |
131 | + for _, value := range queryOption.PartnerCategory { | ||
132 | + q = q.WhereOr(`partner_category_infos@> '{"id":?}'`, value) | ||
133 | + } | ||
134 | + return q, nil | ||
135 | + }) | ||
112 | } | 136 | } |
113 | if queryOption.CompanyId > 0 { | 137 | if queryOption.CompanyId > 0 { |
114 | query = query.Where("company_id=?", queryOption.CompanyId) | 138 | query = query.Where("company_id=?", queryOption.CompanyId) |
@@ -159,6 +183,9 @@ func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQ | @@ -159,6 +183,9 @@ func (repository PartnerInfoRepository) CountAll(queryOption domain.PartnerFindQ | ||
159 | if queryOption.CompanyId > 0 { | 183 | if queryOption.CompanyId > 0 { |
160 | query = query.Where("company_id=?", queryOption.CompanyId) | 184 | query = query.Where("company_id=?", queryOption.CompanyId) |
161 | } | 185 | } |
186 | + if len(queryOption.Ids) > 0 { | ||
187 | + query = query.WhereIn("id in(?)", queryOption.Ids) | ||
188 | + } | ||
162 | cnt, err := query.Count() | 189 | cnt, err := query.Count() |
163 | return cnt, err | 190 | return cnt, err |
164 | } | 191 | } |
@@ -45,6 +45,7 @@ func (repository UsersRepository) transformPgModelToDomainModel(m *models.Users) | @@ -45,6 +45,7 @@ func (repository UsersRepository) transformPgModelToDomainModel(m *models.Users) | ||
45 | CreateAt: m.CreateAt, | 45 | CreateAt: m.CreateAt, |
46 | UpdateAt: m.UpdateAt, | 46 | UpdateAt: m.UpdateAt, |
47 | Permission: m.Permission, | 47 | Permission: m.Permission, |
48 | + AccessPartners: m.AccessPartners, | ||
48 | }, nil | 49 | }, nil |
49 | } | 50 | } |
50 | 51 | ||
@@ -117,7 +118,7 @@ func (reponsitory UsersRepository) FindOne(queryOptions domain.UsersFindOneQuery | @@ -117,7 +118,7 @@ func (reponsitory UsersRepository) FindOne(queryOptions domain.UsersFindOneQuery | ||
117 | m models.Users | 118 | m models.Users |
118 | ) | 119 | ) |
119 | query := tx.Model(&m) | 120 | query := tx.Model(&m) |
120 | - query.Where("deleted_at ISNULL") | 121 | + query.Where("delete_at ISNULL") |
121 | if queryOptions.Id > 0 { | 122 | if queryOptions.Id > 0 { |
122 | query = query.Where("id=?", queryOptions.Id) | 123 | query = query.Where("id=?", queryOptions.Id) |
123 | } | 124 | } |
@@ -141,7 +142,7 @@ func (reponsitory UsersRepository) Find(queryOption domain.UsersFindQuery) (int, | @@ -141,7 +142,7 @@ func (reponsitory UsersRepository) Find(queryOption domain.UsersFindQuery) (int, | ||
141 | db := reponsitory.transactionContext.PgTx | 142 | db := reponsitory.transactionContext.PgTx |
142 | usersModels := []models.Users{} | 143 | usersModels := []models.Users{} |
143 | query := db.Model(&usersModels) | 144 | query := db.Model(&usersModels) |
144 | - query.Where("deleted_at ISNULL") | 145 | + query.Where("delete_at ISNULL") |
145 | if queryOption.CompanyId > 0 { | 146 | if queryOption.CompanyId > 0 { |
146 | query = query.Where("company_id=?", queryOption.CompanyId) | 147 | query = query.Where("company_id=?", queryOption.CompanyId) |
147 | } | 148 | } |
1 | package controllers | 1 | package controllers |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + categoryQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/query" | ||
5 | + categoryService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/service" | ||
4 | partnerQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query" | 6 | partnerQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query" |
5 | partnerInfoService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/service" | 7 | partnerInfoService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/service" |
6 | ) | 8 | ) |
@@ -41,3 +43,22 @@ func (c *CommonController) GetPartnerList() { | @@ -41,3 +43,22 @@ func (c *CommonController) GetPartnerList() { | ||
41 | } | 43 | } |
42 | c.ResponseData(resp) | 44 | c.ResponseData(resp) |
43 | } | 45 | } |
46 | + | ||
47 | +// GetPartnerCategory 下拉选项数据通用接口,获取合伙人分类列表 | ||
48 | +func (c *CommonController) GetPartnerCategory() { | ||
49 | + newService := categoryService.NewPartnerCategoryService(nil) | ||
50 | + _, categorys, err := newService.ListPartnerCategory(categoryQuery.ListPartnerCategoryCommand{}) | ||
51 | + if err != nil { | ||
52 | + c.ResponseError(err) | ||
53 | + return | ||
54 | + } | ||
55 | + resp := []map[string]interface{}{} | ||
56 | + for i := range categorys { | ||
57 | + m := map[string]interface{}{ | ||
58 | + "id": categorys[i].Id, | ||
59 | + "name": categorys[i].Name, | ||
60 | + } | ||
61 | + resp = append(resp, m) | ||
62 | + } | ||
63 | + c.ResponseData(resp) | ||
64 | +} |
@@ -36,7 +36,7 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | @@ -36,7 +36,7 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | ||
36 | //用与适配前端定义的数据结构 | 36 | //用与适配前端定义的数据结构 |
37 | type Parameter struct { | 37 | type Parameter struct { |
38 | PartnerName string `json:"partnerName"` | 38 | PartnerName string `json:"partnerName"` |
39 | - PartnerType int `json:"partnerType"` | 39 | + PartnerType []int64 `json:"partnerType"` |
40 | Area string `json:"area"` | 40 | Area string `json:"area"` |
41 | Account string `json:"account"` | 41 | Account string `json:"account"` |
42 | State int `json:"state"` | 42 | State int `json:"state"` |
@@ -94,7 +94,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { | @@ -94,7 +94,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { | ||
94 | //用与适配前端定义的数据结构 | 94 | //用与适配前端定义的数据结构 |
95 | type Parameter struct { | 95 | type Parameter struct { |
96 | ID int64 `json:"id"` | 96 | ID int64 `json:"id"` |
97 | - PartnerType int `json:"partnerType"` | 97 | + PartnerType []int64 `json:"partnerType"` |
98 | Area string `json:"area"` | 98 | Area string `json:"area"` |
99 | State int `json:"state"` | 99 | State int `json:"state"` |
100 | CooperationTime string `json:"cooperationTime"` | 100 | CooperationTime string `json:"cooperationTime"` |
@@ -156,9 +156,11 @@ func (c *PartnerInfoController) GetPartnerInfo() { | @@ -156,9 +156,11 @@ func (c *PartnerInfoController) GetPartnerInfo() { | ||
156 | c.ResponseError(errors.New("json数据解析失败")) | 156 | c.ResponseError(errors.New("json数据解析失败")) |
157 | return | 157 | return |
158 | } | 158 | } |
159 | + companyId := c.GetUserCompany() | ||
159 | newPartnerService := partnerInfoService.NewPartnerInfoService(nil) | 160 | newPartnerService := partnerInfoService.NewPartnerInfoService(nil) |
160 | partnerInfo, err := newPartnerService.GetPartnerInfo(partnerQuery.GetPartnerInfoQuery{ | 161 | partnerInfo, err := newPartnerService.GetPartnerInfo(partnerQuery.GetPartnerInfoQuery{ |
161 | Id: param.Id, | 162 | Id: param.Id, |
163 | + CompanyId: companyId, | ||
162 | }) | 164 | }) |
163 | if err != nil { | 165 | if err != nil { |
164 | c.ResponseError(err) | 166 | c.ResponseError(err) |
@@ -168,7 +170,7 @@ func (c *PartnerInfoController) GetPartnerInfo() { | @@ -168,7 +170,7 @@ func (c *PartnerInfoController) GetPartnerInfo() { | ||
168 | rspResult := map[string]interface{}{ | 170 | rspResult := map[string]interface{}{ |
169 | "account": partnerInfo.Partner.Account, | 171 | "account": partnerInfo.Partner.Account, |
170 | "partnerName": partnerInfo.Partner.PartnerName, | 172 | "partnerName": partnerInfo.Partner.PartnerName, |
171 | - "partnerType": partnerInfo.PartnerCategory, | 173 | + // "partnerType": []map[string]interface{}{}, |
172 | "area": partnerInfo.RegionInfo.RegionName, | 174 | "area": partnerInfo.RegionInfo.RegionName, |
173 | "salesmanName": "", | 175 | "salesmanName": "", |
174 | "phone": "", | 176 | "phone": "", |
@@ -181,16 +183,24 @@ func (c *PartnerInfoController) GetPartnerInfo() { | @@ -181,16 +183,24 @@ func (c *PartnerInfoController) GetPartnerInfo() { | ||
181 | rspResult["salesmanName"] = partnerInfo.Salesman[0].Name | 183 | rspResult["salesmanName"] = partnerInfo.Salesman[0].Name |
182 | rspResult["phone"] = partnerInfo.Salesman[0].Telephone | 184 | rspResult["phone"] = partnerInfo.Salesman[0].Telephone |
183 | } | 185 | } |
186 | + partnerTypes := []map[string]interface{}{} | ||
187 | + for _, v := range partnerInfo.PartnerCategoryInfos { | ||
188 | + m := map[string]interface{}{ | ||
189 | + "id": v.Id, | ||
190 | + "name": v.Name, | ||
191 | + } | ||
192 | + partnerTypes = append(partnerTypes, m) | ||
193 | + } | ||
194 | + rspResult["partnerType"] = partnerTypes | ||
184 | c.ResponseData(rspResult) | 195 | c.ResponseData(rspResult) |
185 | return | 196 | return |
186 | } | 197 | } |
187 | 198 | ||
188 | -//PartnerInfoSetState 合伙人禁用启用 | 199 | +//PartnerInfoSetState 合伙人批量禁用 |
189 | func (c *PartnerInfoController) PartnerInfoSetState() { | 200 | func (c *PartnerInfoController) PartnerInfoSetState() { |
190 | //用与适配前端定义的数据结构 | 201 | //用与适配前端定义的数据结构 |
191 | type Parameter struct { | 202 | type Parameter struct { |
192 | - Id int64 `json:"id"` | ||
193 | - Status int `json:"status"` | 203 | + Id []int64 `json:"id"` |
194 | } | 204 | } |
195 | var ( | 205 | var ( |
196 | param Parameter | 206 | param Parameter |
@@ -201,20 +211,11 @@ func (c *PartnerInfoController) PartnerInfoSetState() { | @@ -201,20 +211,11 @@ func (c *PartnerInfoController) PartnerInfoSetState() { | ||
201 | c.ResponseError(errors.New("json数据解析失败")) | 211 | c.ResponseError(errors.New("json数据解析失败")) |
202 | return | 212 | return |
203 | } | 213 | } |
204 | - | 214 | + comanyId := c.GetUserCompany() |
205 | cmd := partnerInfoCmd.StatusPartnerInfoCommand{ | 215 | cmd := partnerInfoCmd.StatusPartnerInfoCommand{ |
206 | - Id: param.Id, | ||
207 | - } | ||
208 | - if param.Status == 1 { | ||
209 | - //禁用操作 | ||
210 | - cmd.Status = domain.PARTNER_STATUS_NO | ||
211 | - } else if param.Status == 2 { | ||
212 | - //启用操作 | ||
213 | - cmd.Status = domain.PARTNER_STATUS_YES | ||
214 | - } else { | ||
215 | - //错误 | ||
216 | - c.ResponseError(lib.ThrowError(lib.ARG_ERROR, "状态错误")) | ||
217 | - return | 216 | + Ids: param.Id, |
217 | + CompanyId: comanyId, | ||
218 | + Status: domain.PARTNER_STATUS_NO, | ||
218 | } | 219 | } |
219 | newPartnerService := partnerInfoService.NewPartnerInfoService(nil) | 220 | newPartnerService := partnerInfoService.NewPartnerInfoService(nil) |
220 | err = newPartnerService.UpdateStatus(cmd) | 221 | err = newPartnerService.UpdateStatus(cmd) |
@@ -275,7 +276,7 @@ func (c *PartnerInfoController) ListPartnerInfo() { | @@ -275,7 +276,7 @@ func (c *PartnerInfoController) ListPartnerInfo() { | ||
275 | "createTime": partners[i].CreateAt.Local().Format("2006-01-02 15:04:05"), | 276 | "createTime": partners[i].CreateAt.Local().Format("2006-01-02 15:04:05"), |
276 | "cooperationTime": partners[i].CooperateTime.Local().Format("2006-01-02"), | 277 | "cooperationTime": partners[i].CooperateTime.Local().Format("2006-01-02"), |
277 | "state": partners[i].Status, | 278 | "state": partners[i].Status, |
278 | - "partnerType": partners[i].PartnerCategory, | 279 | + "partnerType": partners[i].PartnerCategoryInfos, |
279 | "salesmanName": "", | 280 | "salesmanName": "", |
280 | "phone": "", | 281 | "phone": "", |
281 | } | 282 | } |
@@ -17,7 +17,6 @@ func init() { | @@ -17,7 +17,6 @@ func init() { | ||
17 | beego.NSRouter("/update", &controllers.UserController{}, "POST:EditUserPermission"), | 17 | beego.NSRouter("/update", &controllers.UserController{}, "POST:EditUserPermission"), |
18 | beego.NSRouter("/detail", &controllers.UserController{}, "POST:GetUserData"), | 18 | beego.NSRouter("/detail", &controllers.UserController{}, "POST:GetUserData"), |
19 | beego.NSRouter("/list", &controllers.UserController{}, "POST:ListUser"), | 19 | beego.NSRouter("/list", &controllers.UserController{}, "POST:ListUser"), |
20 | - // beego.NSRouter("/forbidden", &controllers.UserController{}, "POST:ForbiddenAdminUser"), | ||
21 | beego.NSRouter("/permission", &controllers.UserController{}, "POST:BeforeEditUser"), | 20 | beego.NSRouter("/permission", &controllers.UserController{}, "POST:BeforeEditUser"), |
22 | ), | 21 | ), |
23 | beego.NSNamespace("/partners", | 22 | beego.NSNamespace("/partners", |
@@ -25,7 +24,8 @@ func init() { | @@ -25,7 +24,8 @@ func init() { | ||
25 | beego.NSRouter("/add", &controllers.PartnerInfoController{}, "POST:CreatePartnerInfo"), | 24 | beego.NSRouter("/add", &controllers.PartnerInfoController{}, "POST:CreatePartnerInfo"), |
26 | beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"), | 25 | beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"), |
27 | beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"), | 26 | beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"), |
28 | - beego.NSRouter("/set-status", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), | 27 | + //beego.NSRouter("/set-status", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), |
28 | + beego.NSRouter("/batchDisabled", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), | ||
29 | ), | 29 | ), |
30 | beego.NSNamespace("/dividends", | 30 | beego.NSNamespace("/dividends", |
31 | beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), | 31 | beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), |
@@ -41,13 +41,13 @@ func init() { | @@ -41,13 +41,13 @@ func init() { | ||
41 | beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), | 41 | beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), |
42 | beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), | 42 | beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), |
43 | beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), | 43 | beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), |
44 | - | ||
45 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), | 44 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), |
46 | beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), | 45 | beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), |
47 | ), | 46 | ), |
48 | 47 | ||
49 | beego.NSNamespace("/common", | 48 | beego.NSNamespace("/common", |
50 | beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"), | 49 | beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"), |
50 | + beego.NSRouter("/partnerType", &controllers.CommonController{}, "POST:GetPartnerCategory"), | ||
51 | ), | 51 | ), |
52 | ) | 52 | ) |
53 | 53 |
1 | package routers | 1 | package routers |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "net/http" | ||
5 | + | ||
4 | "github.com/astaxie/beego" | 6 | "github.com/astaxie/beego" |
7 | + "github.com/astaxie/beego/context" | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant" |
6 | ) | 9 | ) |
7 | 10 | ||
8 | func init() { | 11 | func init() { |
9 | - beego.SetStaticPath("/log", constant.LOG_File) | 12 | + //beego.SetStaticPath("/log", constant.LOG_File) |
13 | + beego.Get("/log", func(ctx *context.Context) { | ||
14 | + var s string | ||
15 | + ctx.Input.Bind(&s, "id") | ||
16 | + if s != "12345" { | ||
17 | + ctx.Output.SetStatus(http.StatusBadRequest) | ||
18 | + return | ||
19 | + } | ||
20 | + http.ServeFile(ctx.ResponseWriter, ctx.Request, constant.LOG_File) | ||
21 | + return | ||
22 | + }) | ||
10 | } | 23 | } |
-
请 注册 或 登录 后发表评论