作者 tangxvhui

暂存

@@ -1592,36 +1592,37 @@ func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.T @@ -1592,36 +1592,37 @@ func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.T
1592 log.Logger.Error("获取公司信息," + err.Error()) 1592 log.Logger.Error("获取公司信息," + err.Error())
1593 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error()) 1593 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
1594 } 1594 }
1595 - departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{  
1596 - "transactionContext": transactionContext,  
1597 - }) 1595 + // departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  1596 + // "transactionContext": transactionContext,
  1597 + // })
1598 // //查找员工的部门 1598 // //查找员工的部门
1599 // var departmentList []*domain.Department 1599 // var departmentList []*domain.Department
1600 // if len(userData.DepartmentId) > 0 { 1600 // if len(userData.DepartmentId) > 0 {
1601 1601
1602 // } 1602 // }
1603 1603
1604 - var supperUserList []*domain.User  
1605 - if len(userData.DepartmentId) > 0 {  
1606 - _, departmentList, err := departmentRepo.Find(map[string]interface{}{  
1607 - "ids": userData.DepartmentId,  
1608 - })  
1609 - if err != nil {  
1610 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())  
1611 - }  
1612 - var chargeUserIds []int64  
1613 - for _, v := range departmentList {  
1614 - chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)  
1615 - }  
1616 - if len(chargeUserIds) > 0 {  
1617 - _, supperUserList, err = userRepo.Find(map[string]interface{}{  
1618 - "ids": chargeUserIds,  
1619 - })  
1620 - if err != nil {  
1621 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())  
1622 - }  
1623 - }  
1624 - } 1604 + // var supperUserList []*domain.User
  1605 + // if len(userData.DepartmentId) > 0 {
  1606 + // _, departmentList, err := departmentRepo.Find(map[string]interface{}{
  1607 + // "ids": userData.DepartmentId,
  1608 + // })
  1609 + // if err != nil {
  1610 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
  1611 + // }
  1612 + // var chargeUserIds []int64
  1613 + // for _, v := range departmentList {
  1614 + // chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
  1615 + // }
  1616 + // if len(chargeUserIds) > 0 {
  1617 + // _, supperUserList, err = userRepo.Find(map[string]interface{}{
  1618 + // "ids": chargeUserIds,
  1619 + // })
  1620 + // if err != nil {
  1621 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
  1622 + // }
  1623 + // }
  1624 + // }
  1625 + supperUserList, _ := srv.getStaffSuper(transactionContext, *userData)
1625 userInfo := adapter.StaffInfo{ 1626 userInfo := adapter.StaffInfo{
1626 UserName: userData.Name, 1627 UserName: userData.Name,
1627 CompanyName: companyData.Name, 1628 CompanyName: companyData.Name,
@@ -1719,7 +1720,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1719,7 +1720,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1719 } 1720 }
1720 1721
1721 } 1722 }
1722 -  
1723 //保存信息 1723 //保存信息
1724 for i := range assessContentList { 1724 for i := range assessContentList {
1725 _, err = assessContentRepo.Save(assessContentList[i]) 1725 _, err = assessContentRepo.Save(assessContentList[i])
@@ -1774,7 +1774,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA @@ -1774,7 +1774,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA
1774 } 1774 }
1775 1775
1776 //获取员工的上级是谁 ,TODO 1776 //获取员工的上级是谁 ,TODO
1777 -func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]domain.User, error) { 1777 +func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
1778 departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ 1778 departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
1779 "transactionContext": transactionContext, 1779 "transactionContext": transactionContext,
1780 }) 1780 })
@@ -1793,6 +1793,28 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran @@ -1793,6 +1793,28 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran
1793 } 1793 }
1794 } 1794 }
1795 if len(departmemtList) == 0 { 1795 if len(departmemtList) == 0 {
  1796 + companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
  1797 + "transactionContext": transactionContext,
  1798 + })
  1799 + companyData, err := companyRepo.FindOne(map[string]interface{}{
  1800 + "id": targetUser.CompanyId,
  1801 + })
  1802 + if err != nil {
  1803 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
  1804 + }
  1805 + //公司作为最顶级
  1806 + departmemtList = append(departmemtList, &domain.Department{
  1807 + Id: 0,
  1808 + CompanyId: companyData.Id,
  1809 + Level: 0,
  1810 + Name: companyData.Name,
  1811 + ParentId: 0,
  1812 + ChargeUserIds: companyData.ChargeUserIds,
  1813 + Path: "",
  1814 + CreatedAt: time.Time{},
  1815 + UpdatedAt: time.Time{},
  1816 + DeletedAt: &time.Time{},
  1817 + })
1796 1818
1797 } 1819 }
1798 //获取部门管理员 1820 //获取部门管理员
@@ -1836,14 +1858,5 @@ loop: @@ -1836,14 +1858,5 @@ loop:
1836 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error()) 1858 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
1837 } 1859 }
1838 } 1860 }
1839 - if len(chargeUserList) == 0 {  
1840 - //如果都找不到数据  
1841 -  
1842 - }  
1843 -  
1844 - // _, chargeUserList, err := userRepo.Find(map[string]interface{}{  
1845 - // "ids": chargeUserIds,  
1846 - // })  
1847 -  
1848 - return nil, nil 1861 + return chargeUserList, nil
1849 } 1862 }