正在显示
5 个修改的文件
包含
34 行增加
和
5 行删除
| @@ -47,5 +47,13 @@ func (command CreatePartnerInfoCommand) ValidateCommand() error { | @@ -47,5 +47,13 @@ func (command CreatePartnerInfoCommand) ValidateCommand() error { | ||
| 47 | if len(command.Salesman) == 0 { | 47 | if len(command.Salesman) == 0 { |
| 48 | return lib.ThrowError(lib.ARG_ERROR, "关联业务员必填") | 48 | return lib.ThrowError(lib.ARG_ERROR, "关联业务员必填") |
| 49 | } | 49 | } |
| 50 | + for i := range command.Salesman { | ||
| 51 | + if len(command.Salesman[i].Name) == 0 { | ||
| 52 | + return lib.ThrowError(lib.ARG_ERROR, "关联业务员名称必填") | ||
| 53 | + } | ||
| 54 | + if len(command.Salesman[i].Telephone) == 0 { | ||
| 55 | + return lib.ThrowError(lib.ARG_ERROR, "关联业务员电话必填") | ||
| 56 | + } | ||
| 57 | + } | ||
| 50 | return nil | 58 | return nil |
| 51 | } | 59 | } |
| @@ -15,5 +15,8 @@ func (command *StatusPartnerInfoCommand) ValidateCommand() error { | @@ -15,5 +15,8 @@ func (command *StatusPartnerInfoCommand) ValidateCommand() error { | ||
| 15 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { | 15 | if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) { |
| 16 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") | 16 | return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误") |
| 17 | } | 17 | } |
| 18 | + if command.Id == 0 { | ||
| 19 | + return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误") | ||
| 20 | + } | ||
| 18 | return nil | 21 | return nil |
| 19 | } | 22 | } |
| @@ -31,5 +31,22 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error { | @@ -31,5 +31,22 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error { | ||
| 31 | command.PartnerCategory == domain.PARTNER_CATEGORY_3) { | 31 | command.PartnerCategory == domain.PARTNER_CATEGORY_3) { |
| 32 | return lib.ThrowError(lib.ARG_ERROR, "合伙类别错误") | 32 | return lib.ThrowError(lib.ARG_ERROR, "合伙类别错误") |
| 33 | } | 33 | } |
| 34 | + if command.RegionInfo == nil { | ||
| 35 | + return lib.ThrowError(lib.ARG_ERROR, "区域必填") | ||
| 36 | + } | ||
| 37 | + if len(command.Salesman) == 0 { | ||
| 38 | + return lib.ThrowError(lib.ARG_ERROR, "关联业务员必填") | ||
| 39 | + } | ||
| 40 | + if command.Id == 0 { | ||
| 41 | + return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误") | ||
| 42 | + } | ||
| 43 | + for i := range command.Salesman { | ||
| 44 | + if len(command.Salesman[i].Name) == 0 { | ||
| 45 | + return lib.ThrowError(lib.ARG_ERROR, "关联业务员名称必填") | ||
| 46 | + } | ||
| 47 | + if len(command.Salesman[i].Telephone) == 0 { | ||
| 48 | + return lib.ThrowError(lib.ARG_ERROR, "关联业务员电话必填") | ||
| 49 | + } | ||
| 50 | + } | ||
| 34 | return nil | 51 | return nil |
| 35 | } | 52 | } |
| @@ -37,7 +37,7 @@ func (controller BaseController) ResponseError(err error) { | @@ -37,7 +37,7 @@ func (controller BaseController) ResponseError(err error) { | ||
| 37 | return | 37 | return |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | - } else { | 40 | + } |
| 41 | controller.Data["json"] = protocol.ResponseData{ | 41 | controller.Data["json"] = protocol.ResponseData{ |
| 42 | Code: -1, | 42 | Code: -1, |
| 43 | Msg: err.Error(), | 43 | Msg: err.Error(), |
| @@ -45,7 +45,6 @@ func (controller BaseController) ResponseError(err error) { | @@ -45,7 +45,6 @@ func (controller BaseController) ResponseError(err error) { | ||
| 45 | } | 45 | } |
| 46 | controller.ServeJSON() | 46 | controller.ServeJSON() |
| 47 | logs.Error(err) | 47 | logs.Error(err) |
| 48 | - } | ||
| 49 | return | 48 | return |
| 50 | } | 49 | } |
| 51 | 50 |
| @@ -68,9 +68,6 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | @@ -68,9 +68,6 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | ||
| 68 | Status: param.State, | 68 | Status: param.State, |
| 69 | PartnerCategory: param.PartnerType, | 69 | PartnerCategory: param.PartnerType, |
| 70 | CooperateTime: cooperateTime, | 70 | CooperateTime: cooperateTime, |
| 71 | - RegionInfo: &domain.RegionInfo{ | ||
| 72 | - RegionName: param.Area, | ||
| 73 | - }, | ||
| 74 | Salesman: []domain.Salesman{ | 71 | Salesman: []domain.Salesman{ |
| 75 | domain.Salesman{ | 72 | domain.Salesman{ |
| 76 | Name: param.SalesmanName, | 73 | Name: param.SalesmanName, |
| @@ -78,6 +75,11 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | @@ -78,6 +75,11 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | ||
| 78 | }, | 75 | }, |
| 79 | }, | 76 | }, |
| 80 | } | 77 | } |
| 78 | + if len(param.Area) > 0 { | ||
| 79 | + cmd.RegionInfo = &domain.RegionInfo{ | ||
| 80 | + RegionName: param.Area, | ||
| 81 | + } | ||
| 82 | + } | ||
| 81 | serve := partnerInfoService.NewPartnerInfoService(nil) | 83 | serve := partnerInfoService.NewPartnerInfoService(nil) |
| 82 | _, err = serve.CreatePartnerInfo(&cmd) | 84 | _, err = serve.CreatePartnerInfo(&cmd) |
| 83 | if err != nil { | 85 | if err != nil { |
-
请 注册 或 登录 后发表评论