作者 tangxvhui

bug 修复

@@ -52,6 +52,14 @@ const ( @@ -52,6 +52,14 @@ const (
52 USERCOMPANY_CHARGE_NO int8 = 2 52 USERCOMPANY_CHARGE_NO int8 = 2
53 ) 53 )
54 54
  55 +//
  56 +
  57 +// 1普通用户 2主管理员
  58 +const (
  59 + USERCOMPANY_ADMIN_SUBSET int8 = 1
  60 + USERCOMPANY_ADMIN_MAIN int8 = 2
  61 +)
  62 +
55 func (t *UserCompany) IsEnable() bool { 63 func (t *UserCompany) IsEnable() bool {
56 switch t.Enable { 64 switch t.Enable {
57 case USERCOMPANY_ENABLE_YES: 65 case USERCOMPANY_ENABLE_YES:
@@ -344,7 +344,7 @@ func AddUserCompanyData(centerCompany *ModuleCompanytData, newcompany *models.Co @@ -344,7 +344,7 @@ func AddUserCompanyData(centerCompany *ModuleCompanytData, newcompany *models.Co
344 uc = &models.UserCompany{ 344 uc = &models.UserCompany{
345 UserId: newuser.Id, 345 UserId: newuser.Id,
346 CompanyId: newcompany.Id, 346 CompanyId: newcompany.Id,
347 - Enable: adminUserData.Status, 347 + Enable: models.USERCOMPANY_ENABLE_YES,
348 ChargeStatus: adminUserData.ChargeStatus, 348 ChargeStatus: adminUserData.ChargeStatus,
349 Id: adminUserData.Id, 349 Id: adminUserData.Id,
350 NickName: adminUserData.Name, 350 NickName: adminUserData.Name,
@@ -206,6 +206,11 @@ func departmentRelationUpdate(departmentUpdate models.Department, newparent mode @@ -206,6 +206,11 @@ func departmentRelationUpdate(departmentUpdate models.Department, newparent mode
206 return nil 206 return nil
207 } 207 }
208 208
  209 +func setDepartmentLevel(relation string) int {
  210 + s := strings.Split(relation, ",")
  211 + return len(s) - 3
  212 +}
  213 +
209 //AddDepartmentData ... 214 //AddDepartmentData ...
210 func AddDepartmentData(data []ModuleDeparmentData) error { 215 func AddDepartmentData(data []ModuleDeparmentData) error {
211 if len(data) == 0 { 216 if len(data) == 0 {
@@ -238,6 +243,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { @@ -238,6 +243,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error {
238 BusinessDepartmentId: v.Id, 243 BusinessDepartmentId: v.Id,
239 DeleteAt: time.Unix(0, 0), 244 DeleteAt: time.Unix(0, 0),
240 CreateAt: time.Now(), 245 CreateAt: time.Now(),
  246 + Level: v.Level,
241 } 247 }
242 if v.ParentId > 0 { 248 if v.ParentId > 0 {
243 parentDepart := &models.Department{} 249 parentDepart := &models.Department{}
@@ -257,7 +263,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { @@ -257,7 +263,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error {
257 departmentData.SetRelation(topDepartment) 263 departmentData.SetRelation(topDepartment)
258 } 264 }
259 265
260 - departmentData.Level = setDepartmentLevel(departmentData.Relation) 266 + // departmentData.Level = setDepartmentLevel(departmentData.Relation)
261 _, err = models.AddDepartment(departmentData, o) 267 _, err = models.AddDepartment(departmentData, o)
262 if err != nil { 268 if err != nil {
263 e := fmt.Errorf("存储部门数据失败,err:%s", err) 269 e := fmt.Errorf("存储部门数据失败,err:%s", err)
@@ -270,11 +276,6 @@ func AddDepartmentData(data []ModuleDeparmentData) error { @@ -270,11 +276,6 @@ func AddDepartmentData(data []ModuleDeparmentData) error {
270 return nil 276 return nil
271 } 277 }
272 278
273 -func setDepartmentLevel(relation string) int {  
274 - s := strings.Split(relation, ",")  
275 - return len(s) - 3  
276 -}  
277 -  
278 //DeleteDepartmentData ... 279 //DeleteDepartmentData ...
279 func DeleteDepartmentData(ids []int64) error { 280 func DeleteDepartmentData(ids []int64) error {
280 o := orm.NewOrm() 281 o := orm.NewOrm()