update_partner_info.go
1.7 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
package command
import (
"time"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
type UpdatePartnerInfoCommand struct {
// 合伙人Id
Id int64 `json:"id"`
// 状态(1:启用或者0:禁用)
Status int `json:"status"`
// 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业)
PartnerCategory int `json:"partnerCategory,omitempty"`
// 区域
RegionInfo *domain.RegionInfo `json:"regionInfo"`
//关联业务员
Salesman []domain.Salesman `json:"salesman,omitempty"`
//合作时间
CooperateTime time.Time `json:"cooperateTime"`
}
func (command *UpdatePartnerInfoCommand) ValidateCommand() error {
if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) {
return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误")
}
if !(command.PartnerCategory == domain.PARTNER_CATEGORY_1 ||
command.PartnerCategory == domain.PARTNER_CATEGORY_2 ||
command.PartnerCategory == domain.PARTNER_CATEGORY_3 ||
command.PartnerCategory == domain.PARTNER_CATEGORY_4) {
return lib.ThrowError(lib.ARG_ERROR, "合伙类别错误")
}
if command.RegionInfo == nil {
return lib.ThrowError(lib.ARG_ERROR, "区域必填")
}
if len(command.Salesman) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "关联业务员必填")
}
if command.Id == 0 {
return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误")
}
for i := range command.Salesman {
if len(command.Salesman[i].Name) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "关联业务员名称必填")
}
if len(command.Salesman[i].Telephone) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "关联业务员电话必填")
}
}
return nil
}