作者 tangxvhui

bug 修复

... ... @@ -47,5 +47,13 @@ func (command CreatePartnerInfoCommand) ValidateCommand() error {
if len(command.Salesman) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "关联业务员必填")
}
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
}
... ...
... ... @@ -15,5 +15,8 @@ func (command *StatusPartnerInfoCommand) ValidateCommand() error {
if !(command.Status == domain.PARTNER_STATUS_NO || command.Status == domain.PARTNER_STATUS_YES) {
return lib.ThrowError(lib.ARG_ERROR, "合伙人状态错误")
}
if command.Id == 0 {
return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误")
}
return nil
}
... ...
... ... @@ -31,5 +31,22 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error {
command.PartnerCategory == domain.PARTNER_CATEGORY_3) {
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
}
... ...
... ... @@ -37,15 +37,14 @@ func (controller BaseController) ResponseError(err error) {
return
}
} else {
controller.Data["json"] = protocol.ResponseData{
Code: -1,
Msg: err.Error(),
Data: struct{}{},
}
controller.ServeJSON()
logs.Error(err)
}
controller.Data["json"] = protocol.ResponseData{
Code: -1,
Msg: err.Error(),
Data: struct{}{},
}
controller.ServeJSON()
logs.Error(err)
return
}
... ...
... ... @@ -68,9 +68,6 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
Status: param.State,
PartnerCategory: param.PartnerType,
CooperateTime: cooperateTime,
RegionInfo: &domain.RegionInfo{
RegionName: param.Area,
},
Salesman: []domain.Salesman{
domain.Salesman{
Name: param.SalesmanName,
... ... @@ -78,6 +75,11 @@ func (c *PartnerInfoController) CreatePartnerInfo() {
},
},
}
if len(param.Area) > 0 {
cmd.RegionInfo = &domain.RegionInfo{
RegionName: param.Area,
}
}
serve := partnerInfoService.NewPartnerInfoService(nil)
_, err = serve.CreatePartnerInfo(&cmd)
if err != nil {
... ...