作者 yangfu

组织启用、禁用

@@ -73,10 +73,21 @@ func (orgService *OrgService) EnableOrg(enableOrgCommand *command.EnableOrgComma @@ -73,10 +73,21 @@ func (orgService *OrgService) EnableOrg(enableOrgCommand *command.EnableOrgComma
73 defer func() { 73 defer func() {
74 transactionContext.RollbackTransaction() 74 transactionContext.RollbackTransaction()
75 }() 75 }()
  76 +
  77 + orgRepository, org, err := factory.FastPgOrg(transactionContext, enableOrgCommand.OrgId)
  78 + if err != nil {
  79 + return nil, err
  80 + }
  81 + if err = org.SetOrgStatus(enableOrgCommand.OrgStatus); err != nil {
  82 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  83 + }
  84 + if org, err = orgRepository.Save(org); err != nil {
  85 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  86 + }
76 if err := transactionContext.CommitTransaction(); err != nil { 87 if err := transactionContext.CommitTransaction(); err != nil {
77 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 88 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
78 } 89 }
79 - return nil, nil 90 + return org, nil
80 } 91 }
81 92
82 // 返回组织 93 // 返回组织
@@ -21,12 +21,14 @@ type ListUserQuery struct { @@ -21,12 +21,14 @@ type ListUserQuery struct {
21 DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"` 21 DepartmentId int64 `cname:"部门编号" json:"departmentId,omitempty"`
22 // 用户姓名 22 // 用户姓名
23 UserName string `cname:"用户姓名" json:"userName,omitempty"` 23 UserName string `cname:"用户姓名" json:"userName,omitempty"`
  24 + // 用户姓名
  25 + CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"`
24 // 部门名称 26 // 部门名称
25 DepName string `cname:"部门名称" json:"depName,omitempty"` 27 DepName string `cname:"部门名称" json:"depName,omitempty"`
26 // 手机号码 28 // 手机号码
27 Phone string `cname:"手机号码" json:"phone,omitempty"` 29 Phone string `cname:"手机号码" json:"phone,omitempty"`
28 // 实时拉取数据 (获取最新的) 30 // 实时拉取数据 (获取最新的)
29 - PullRealTime bool `cname:"拉最新数据" json:"pullRealTime,omitempty"` 31 + PullRealTime bool `cname:"拉最新数据" json:"pullRealTime,omitempty"`
30 } 32 }
31 33
32 func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) { 34 func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) {
@@ -117,16 +117,19 @@ type Department struct { @@ -117,16 +117,19 @@ type Department struct {
117 // 部门编号 117 // 部门编号
118 DepartmentNumber string `json:"departmentNumber"` 118 DepartmentNumber string `json:"departmentNumber"`
119 } 119 }
120 -type SampleOrg struct {  
121 - // 组织ID  
122 - OrgId int64 `json:"orgId,omitempty"`  
123 - // 企业id  
124 - CompanyId int64 `json:"companyId,omitempty"`  
125 - // 组织名称  
126 - OrgName string `json:"orgName,omitempty"`  
127 - // 组织编码  
128 - OrgCode string `json:"orgCode,omitempty"`  
129 -} 120 +
  121 +//type SampleOrg struct {
  122 +// // 组织ID
  123 +// OrgId int64 `json:"orgId,omitempty"`
  124 +// // 企业id
  125 +// CompanyId int64 `json:"companyId,omitempty"`
  126 +// // 组织名称
  127 +// OrgName string `json:"orgName,omitempty"`
  128 +// // 组织编码
  129 +// OrgCode string `json:"orgCode,omitempty"`
  130 +//}
  131 +
  132 +/***** 0.基础函数模块 *****/
130 133
131 // 通过组织获取当前部门信息 134 // 通过组织获取当前部门信息
132 func (org *Org) ConvDep() *Department { 135 func (org *Org) ConvDep() *Department {
@@ -145,6 +148,21 @@ func (org *Org) CloneSample() *Org { @@ -145,6 +148,21 @@ func (org *Org) CloneSample() *Org {
145 } 148 }
146 } 149 }
147 150
  151 +func (org *Org) SetOrgStatus(orgStatus int) error {
  152 + if !(orgStatus == OrgStatusEnable || orgStatus == OrgStatusDisable) {
  153 + return fmt.Errorf("非法组织状态")
  154 + }
  155 + if org.OrgStatus == orgStatus {
  156 + return nil
  157 + }
  158 + if !org.DeletedAt.IsZero() {
  159 + return fmt.Errorf("组织不存在")
  160 + }
  161 + org.UpdatedAt = time.Now()
  162 + org.OrgStatus = orgStatus
  163 + return nil
  164 +}
  165 +
148 /***** 1.实现树 *****/ 166 /***** 1.实现树 *****/
149 /*1.1 实现树的方法*/ 167 /*1.1 实现树的方法*/
150 // GetParentPath 获取菜单路径 168 // GetParentPath 获取菜单路径