作者 tangxvhui

bug 修复

@@ -197,6 +197,9 @@ func GetDepartmentByCompanyId(companyId int64) ([]Department, error) { @@ -197,6 +197,9 @@ func GetDepartmentByCompanyId(companyId int64) ([]Department, error) {
197 } 197 }
198 198
199 func GetDepartmentByIds(departmentIds []int64) ([]Department, error) { 199 func GetDepartmentByIds(departmentIds []int64) ([]Department, error) {
  200 + if len(departmentIds) == 0 {
  201 + return nil, nil
  202 + }
200 var ( 203 var (
201 result []Department 204 result []Department
202 err error 205 err error
@@ -84,6 +84,9 @@ func GetUserCompanyById(id int64) (v *UserCompany, err error) { @@ -84,6 +84,9 @@ func GetUserCompanyById(id int64) (v *UserCompany, err error) {
84 } 84 }
85 85
86 func GetUserCompanyByIds(ids []int64) (v []UserCompany, err error) { 86 func GetUserCompanyByIds(ids []int64) (v []UserCompany, err error) {
  87 + if len(ids) == 0 {
  88 + return nil, nil
  89 + }
87 o := orm.NewOrm() 90 o := orm.NewOrm()
88 _, err = o.QueryTable(&UserCompany{}). 91 _, err = o.QueryTable(&UserCompany{}).
89 Filter("id__in", ids). 92 Filter("id__in", ids).
@@ -189,13 +189,13 @@ func SelectCompanyUserList(pageIndex int, pageSize int, companyid int64, userNam @@ -189,13 +189,13 @@ func SelectCompanyUserList(pageIndex int, pageSize int, companyid int64, userNam
189 LEFT JOIN user_department AS b ON a.id = b.user_company_id AND b.enable_status=1 189 LEFT JOIN user_department AS b ON a.id = b.user_company_id AND b.enable_status=1
190 LEFT JOIN department AS c ON b.department_id = c.id 190 LEFT JOIN department AS c ON b.department_id = c.id
191 LEFT JOIN user AS d ON a.user_id = d.id 191 LEFT JOIN user AS d ON a.user_id = d.id
192 - WHERE a.delete_at = 0 AND c.company_id = ? ` 192 + WHERE a.delete_at = 0 AND a.enable=1 AND c.company_id = ? `
193 countsql := `SELECT count(*) 193 countsql := `SELECT count(*)
194 FROM user_company AS a 194 FROM user_company AS a
195 LEFT JOIN user_department AS b ON a.id = b.user_company_id AND b.enable_status=1 195 LEFT JOIN user_department AS b ON a.id = b.user_company_id AND b.enable_status=1
196 LEFT JOIN department AS c ON b.department_id = c.id 196 LEFT JOIN department AS c ON b.department_id = c.id
197 LEFT JOIN user AS d ON a.user_id = d.id 197 LEFT JOIN user AS d ON a.user_id = d.id
198 - WHERE a.delete_at = 0 AND c.company_id =? ` 198 + WHERE a.delete_at = 0 AND a.enable=1 AND c.company_id =? `
199 cond := []interface{}{companyid} 199 cond := []interface{}{companyid}
200 where := "" 200 where := ""
201 if len(userName) > 0 { 201 if len(userName) > 0 {
@@ -228,10 +228,11 @@ func AddDepartmentData(data []ModuleDeparmentData) error { @@ -228,10 +228,11 @@ func AddDepartmentData(data []ModuleDeparmentData) error {
228 o.Begin() 228 o.Begin()
229 for _, v := range data { 229 for _, v := range data {
230 departmentData := &models.Department{ 230 departmentData := &models.Department{
231 - Id: v.Id,  
232 - CompanyId: companyData.Id,  
233 - Name: v.Name,  
234 - Manages: "[]", 231 + Id: v.Id,
  232 + CompanyId: companyData.Id,
  233 + Name: v.Name,
  234 + Manages: "[]",
  235 + BusinessDepartmentId: v.Id,
235 } 236 }
236 if v.ParentId > 0 { 237 if v.ParentId > 0 {
237 parentDepart := &models.Department{} 238 parentDepart := &models.Department{}