소스 검색

Merge branch 'sync_sci' into debug

Roc 2 주 전
부모
커밋
125f362dfe
3개의 변경된 파일52개의 추가작업 그리고 35개의 파일을 삭제
  1. 12 12
      controllers/data_manage/excel/excel_info.go
  2. 33 16
      controllers/sys_department.go
  3. 7 7
      models/system/sys_group.go

+ 12 - 12
controllers/data_manage/excel/excel_info.go

@@ -109,18 +109,18 @@ func (c *ExcelInfoController) Add() {
 		Text string `json:"text"`
 	}
 
-	if req.SourcesFrom != "" && len(req.SourcesFrom) > 0 {
-		var sourcesFrom SourcesFrom
-		err = json.Unmarshal([]byte(req.SourcesFrom), &sourcesFrom)
-		if err != nil {
-			return
-		}
-		if len(sourcesFrom.Text) > 50 {
-			br.Msg = "字数已达上限!"
-			br.ErrMsg = "来源文本字数已达上限,请修改!"
-			return
-		}
-	}
+	//if req.SourcesFrom != "" && len(req.SourcesFrom) > 0 {
+	//	var sourcesFrom SourcesFrom
+	//	err = json.Unmarshal([]byte(req.SourcesFrom), &sourcesFrom)
+	//	if err != nil {
+	//		return
+	//	}
+	//	if len(sourcesFrom.Text) > 50 {
+	//		br.Msg = "字数已达上限!"
+	//		br.ErrMsg = "来源文本字数已达上限,请修改!"
+	//		return
+	//	}
+	//}
 
 	if req.ParentId > 0 {
 		parentExcelInfo, e := excel3.GetExcelInfoById(req.ParentId)

+ 33 - 16
controllers/sys_department.go

@@ -208,7 +208,7 @@ func (this *SysDepartmentController) ListDepartment() {
 		return
 	}
 	departmentGroup := make(map[int][]*system.SysGroupList)
-	groupTeam := make(map[int][]*system.SysTeamList)
+	groupTeam := make(map[int][]*system.SysGroupList)
 	for _, v := range groups {
 		if departmentGroup[v.DepartmentId] == nil {
 			departmentGroup[v.DepartmentId] = make([]*system.SysGroupList, 0)
@@ -218,28 +218,33 @@ func (this *SysDepartmentController) ListDepartment() {
 		}
 		if v.ParentId > 0 {
 			if groupTeam[v.ParentId] == nil {
-				groupTeam[v.ParentId] = make([]*system.SysTeamList, 0)
+				groupTeam[v.ParentId] = make([]*system.SysGroupList, 0)
 			}
-			groupTeam[v.ParentId] = append(groupTeam[v.ParentId], &system.SysTeamList{
-				GroupId:    v.GroupId,
-				ParentId:   v.ParentId,
-				GroupName:  v.GroupName,
-				CreateTime: v.CreateTime,
+			groupTeam[v.ParentId] = append(groupTeam[v.ParentId], &system.SysGroupList{
+				GroupId:      v.GroupId,
+				DepartmentId: v.DepartmentId,
+				ParentId:     v.ParentId,
+				GroupName:    v.GroupName,
+				CreateTime:   v.CreateTime,
+				IsGroup:      true,
+				Child:        make([]*system.SysGroupList, 0),
 			})
 		}
 	}
 
 	// 数据重组
-	for _, groups := range departmentGroup {
-		for _, g := range groups {
-			g.IsGroup = true
-			if groupTeam[g.GroupId] != nil {
-				g.Child = groupTeam[g.GroupId]
-			} else {
-				g.Child = make([]*system.SysTeamList, 0)
-			}
-		}
+	for departmentId, groups := range departmentGroup {
+		//for _, g := range groups {
+		//	g.IsGroup = true
+		//	if groupTeam[g.GroupId] != nil {
+		//		g.Child = groupTeam[g.GroupId]
+		//	} else {
+		//		g.Child = make([]*system.SysTeamList, 0)
+		//	}
+		//}
+		departmentGroup[departmentId] = buildTree(groups, groupTeam)
 	}
+
 	for _, v := range departments {
 		v.IsDepartment = true
 		if departmentGroup[v.DepartmentId] != nil {
@@ -280,6 +285,18 @@ func (this *SysDepartmentController) ListDepartment() {
 	br.Data = resp
 }
 
+func buildTree(groups []*system.SysGroupList, groupTeam map[int][]*system.SysGroupList) []*system.SysGroupList {
+	for _, g := range groups {
+		g.IsGroup = true
+		if children, ok := groupTeam[g.GroupId]; ok {
+			g.Child = buildTree(children, groupTeam)
+		} else {
+			g.Child = make([]*system.SysGroupList, 0)
+		}
+	}
+	return groups
+}
+
 // DepartmentUserTree
 // @Title 获取部门及分组用户树
 // @Description 获取部门列表接口

+ 7 - 7
models/system/sys_group.go

@@ -79,13 +79,13 @@ func DeleteSysGroup(groupId int) (err error) {
 
 // 因前端显示需要,TopId字段用来当做一级部门id,DepartmentId为当前分组id
 type SysGroupList struct {
-	GroupId      int            `orm:"column(group_id);pk" json:"DepartmentId" description:"分组ID"`
-	ParentId     int            `json:"ParentId" description:"父级ID"`
-	DepartmentId int            `json:"TopId" description:"部门Id"`
-	GroupName    string         `json:"DepartmentName" description:"分组名称"`
-	Child        []*SysTeamList `gorm:"-" description:"小组"`
-	CreateTime   time.Time      `description:"创建时间"`
-	IsGroup      bool           `description:"是否为二级部门"`
+	GroupId      int             `orm:"column(group_id);pk" json:"DepartmentId" description:"分组ID"`
+	ParentId     int             `json:"ParentId" description:"父级ID"`
+	DepartmentId int             `json:"TopId" description:"部门Id"`
+	GroupName    string          `json:"DepartmentName" description:"分组名称"`
+	Child        []*SysGroupList `gorm:"-" description:"小组"`
+	CreateTime   time.Time       `description:"创建时间"`
+	IsGroup      bool            `description:"是否为二级部门"`
 }
 
 func GetSysGroupList() (items []*SysGroupList, err error) {