作者 tangxuhui

更新禁用用户,删除用户的逻辑

@@ -59,15 +59,15 @@ type ModuleEmployee struct { @@ -59,15 +59,15 @@ type ModuleEmployee struct {
59 59
60 //DeleteUserData 删除用户 60 //DeleteUserData 删除用户
61 type DeleteUserData struct { 61 type DeleteUserData struct {
62 - CompanyId int64 `json:"companyId"`  
63 - Ids []int64 `json:"ids"` 62 + // CompanyId int64 `json:"companyId"`
  63 + Ids []int64 `json:"ids"`
64 } 64 }
65 65
66 //ForbidAllowUserData 启用禁用用户 66 //ForbidAllowUserData 启用禁用用户
67 type ForbidAllowUserData struct { 67 type ForbidAllowUserData struct {
68 - CompanyId int64 `json:"companyId"`  
69 - Ids []int64 `json:"ids"`  
70 - Status int8 `json:"status"` 68 + // CompanyId int64 `json:"companyId"`
  69 + Ids []int64 `json:"ids"`
  70 + Status int8 `json:"status"`
71 } 71 }
72 72
73 //RemoveUserDepartmentData 移动通讯录用户部门 73 //RemoveUserDepartmentData 移动通讯录用户部门
@@ -559,12 +559,13 @@ func editUserPosition(usercompanyid int64, companyid int64, userPosition []UserP @@ -559,12 +559,13 @@ func editUserPosition(usercompanyid int64, companyid int64, userPosition []UserP
559 559
560 // DeleteEmployeeData ... 560 // DeleteEmployeeData ...
561 func DeleteEmployeeData(data DeleteUserData) error { 561 func DeleteEmployeeData(data DeleteUserData) error {
562 - companyData, err := models.GetCompanyByUCenter(data.CompanyId)  
563 - if err != nil {  
564 - log.Error("h获取公司数据失败,user_center_id=%d,err:%s", data.CompanyId, err)  
565 - return errors.New("获取公司数据失败")  
566 - } 562 + // companyData, err := models.GetCompanyByUCenter(data.CompanyId)
  563 + // if err != nil {
  564 + // log.Error("h获取公司数据失败,user_center_id=%d,err:%s", data.CompanyId, err)
  565 + // return errors.New("获取公司数据失败")
  566 + // }
567 var ( 567 var (
  568 + err error
568 userCompanyDatas []models.UserCompany 569 userCompanyDatas []models.UserCompany
569 userIdMap = make(map[int64]int64) 570 userIdMap = make(map[int64]int64)
570 ) 571 )
@@ -572,7 +573,6 @@ func DeleteEmployeeData(data DeleteUserData) error { @@ -572,7 +573,6 @@ func DeleteEmployeeData(data DeleteUserData) error {
572 o.Begin() 573 o.Begin()
573 _, err = o.QueryTable(&models.UserCompany{}). 574 _, err = o.QueryTable(&models.UserCompany{}).
574 Filter("id__in", data.Ids). 575 Filter("id__in", data.Ids).
575 - Filter("company_id", companyData.Id).  
576 Filter("delete_at", 0). 576 Filter("delete_at", 0).
577 All(&userCompanyDatas) 577 All(&userCompanyDatas)
578 if err != nil { 578 if err != nil {
@@ -586,7 +586,6 @@ func DeleteEmployeeData(data DeleteUserData) error { @@ -586,7 +586,6 @@ func DeleteEmployeeData(data DeleteUserData) error {
586 } 586 }
587 _, err = o.QueryTable(&models.UserCompany{}). 587 _, err = o.QueryTable(&models.UserCompany{}).
588 Filter("id__in", data.Ids). 588 Filter("id__in", data.Ids).
589 - Filter("company_id", companyData.Id).  
590 Update(orm.Params{ 589 Update(orm.Params{
591 "delete_at": time.Now().Format("2006-01-02 15:04:05"), 590 "delete_at": time.Now().Format("2006-01-02 15:04:05"),
592 "enable": models.USERCOMPANY_ENABLE_NO, 591 "enable": models.USERCOMPANY_ENABLE_NO,
@@ -626,12 +625,15 @@ func DeleteEmployeeData(data DeleteUserData) error { @@ -626,12 +625,15 @@ func DeleteEmployeeData(data DeleteUserData) error {
626 } 625 }
627 626
628 func ForbidAllowEmployeeData(data ForbidAllowUserData) error { 627 func ForbidAllowEmployeeData(data ForbidAllowUserData) error {
629 - companyData, err := models.GetCompanyByUCenter(data.CompanyId)  
630 - if err != nil {  
631 - log.Error("h获取公司数据失败,user_center_id=%d,err:%s", data.CompanyId, err)  
632 - return errors.New("获取公司数据失败")  
633 - }  
634 - var status int8 628 + // companyData, err := models.GetCompanyByUCenter(data.CompanyId)
  629 + // if err != nil {
  630 + // log.Error("h获取公司数据失败,user_center_id=%d,err:%s", data.CompanyId, err)
  631 + // return errors.New("获取公司数据失败")
  632 + // }
  633 + var (
  634 + status int8
  635 + err error
  636 + )
635 switch data.Status { 637 switch data.Status {
636 case 1: 638 case 1:
637 status = models.USERCOMPANY_ENABLE_YES 639 status = models.USERCOMPANY_ENABLE_YES
@@ -641,7 +643,6 @@ func ForbidAllowEmployeeData(data ForbidAllowUserData) error { @@ -641,7 +643,6 @@ func ForbidAllowEmployeeData(data ForbidAllowUserData) error {
641 o := orm.NewOrm() 643 o := orm.NewOrm()
642 _, err = o.QueryTable(&models.UserCompany{}). 644 _, err = o.QueryTable(&models.UserCompany{}).
643 Filter("id__in", data.Ids). 645 Filter("id__in", data.Ids).
644 - Filter("company_id", companyData.Id).  
645 Update(orm.Params{ 646 Update(orm.Params{
646 "enable": status, 647 "enable": status,
647 "update_at": time.Now().Format("2006-01-02 15:04:05"), 648 "update_at": time.Now().Format("2006-01-02 15:04:05"),