作者 yangfu

公司审核 启用修改

@@ -20,7 +20,18 @@ type AuditCompanyCommand struct { @@ -20,7 +20,18 @@ type AuditCompanyCommand struct {
20 } 20 }
21 21
22 func (updateCompanyCommand *AuditCompanyCommand) Valid(validation *validation.Validation) { 22 func (updateCompanyCommand *AuditCompanyCommand) Valid(validation *validation.Validation) {
23 - //validation.SetError("CustomValid", "未实现的自定义认证") 23 + if !(updateCompanyCommand.Status == 1 || updateCompanyCommand.Status == 2) {
  24 + validation.Error("状态有误")
  25 + return
  26 + }
  27 + if updateCompanyCommand.Status == 1 {
  28 + updateCompanyCommand.Status = 2
  29 + return
  30 + }
  31 + if updateCompanyCommand.Status == 2 {
  32 + updateCompanyCommand.Status = 3
  33 + return
  34 + }
24 } 35 }
25 36
26 func (updateCompanyCommand *AuditCompanyCommand) ValidateCommand() error { 37 func (updateCompanyCommand *AuditCompanyCommand) ValidateCommand() error {
@@ -17,6 +17,18 @@ type EnableCompanyCommand struct { @@ -17,6 +17,18 @@ type EnableCompanyCommand struct {
17 17
18 func (updateCompanyCommand *EnableCompanyCommand) Valid(validation *validation.Validation) { 18 func (updateCompanyCommand *EnableCompanyCommand) Valid(validation *validation.Validation) {
19 //validation.SetError("CustomValid", "未实现的自定义认证") 19 //validation.SetError("CustomValid", "未实现的自定义认证")
  20 + if !(updateCompanyCommand.Status == 1 || updateCompanyCommand.Status == 2) {
  21 + validation.Error("状态有误")
  22 + return
  23 + }
  24 + if updateCompanyCommand.Status == 1 {
  25 + updateCompanyCommand.Status = 2
  26 + return
  27 + }
  28 + if updateCompanyCommand.Status == 2 {
  29 + updateCompanyCommand.Status = 4
  30 + return
  31 + }
20 } 32 }
21 33
22 func (updateCompanyCommand *EnableCompanyCommand) ValidateCommand() error { 34 func (updateCompanyCommand *EnableCompanyCommand) ValidateCommand() error {
@@ -46,6 +46,9 @@ func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompa @@ -46,6 +46,9 @@ func (companyService *CompanyService) GetCompany(getCompanyQuery *query.GetCompa
46 } 46 }
47 47
48 func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyCommand) (interface{}, error) { 48 func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyCommand) (interface{}, error) {
  49 + if err := cmd.ValidateCommand(); err != nil {
  50 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  51 + }
49 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 52 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
50 _, err := creationUserGateway.AuditCompany(allied_creation_user.ReqCompanyAudit{ 53 _, err := creationUserGateway.AuditCompany(allied_creation_user.ReqCompanyAudit{
51 CompanyId: int(cmd.CompanyId), 54 CompanyId: int(cmd.CompanyId),
@@ -72,6 +75,9 @@ func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyComm @@ -72,6 +75,9 @@ func (companyService *CompanyService) AuditCompany(cmd *command.AuditCompanyComm
72 } 75 }
73 76
74 func (companyService *CompanyService) EnableCompany(cmd *command.EnableCompanyCommand) (interface{}, error) { 77 func (companyService *CompanyService) EnableCompany(cmd *command.EnableCompanyCommand) (interface{}, error) {
  78 + if err := cmd.ValidateCommand(); err != nil {
  79 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  80 + }
75 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 81 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
76 _, err := creationUserGateway.EnableCompany(allied_creation_user.ReqCompanyEnable{ 82 _, err := creationUserGateway.EnableCompany(allied_creation_user.ReqCompanyEnable{
77 CompanyId: int(cmd.CompanyId), 83 CompanyId: int(cmd.CompanyId),
@@ -34,6 +34,9 @@ func (dto *UserBaseDto) LoadDto(detail allied_creation_user.UserBaseDetail) { @@ -34,6 +34,9 @@ func (dto *UserBaseDto) LoadDto(detail allied_creation_user.UserBaseDetail) {
34 dto.LastLogIn = detail.LastLogIn 34 dto.LastLogIn = detail.LastLogIn
35 var organizations []string 35 var organizations []string
36 for i := range detail.UserOrg { 36 for i := range detail.UserOrg {
  37 + if len(detail.UserOrg[i].OrgName) == 0 {
  38 + continue
  39 + }
37 organizations = append(organizations, detail.UserOrg[i].OrgName) 40 organizations = append(organizations, detail.UserOrg[i].OrgName)
38 } 41 }
39 dto.Organizations = strings.Join(organizations, ",") 42 dto.Organizations = strings.Join(organizations, ",")