research_group.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package services
  2. // ResearchGroup 研究方向分组表
  3. //type ResearchGroupItem struct {
  4. // ResearchGroupId int `json:"research_group_id" description:"研究方向分组ID"`
  5. // ResearchGroupName string `json:"research_group_name" description:"研究方向分组名称"`
  6. // ParentId int `json:"parent_id" description:"父类ID"`
  7. // ChartPermissionId int `json:"chart_permission_id" description:"品种权限ID"`
  8. // Sort int `json:"sort" description:"排序"`
  9. // Members []*ResearchGroupMember `json:"members"`
  10. // Children []*ResearchGroupItem `json:"children"`
  11. //}
  12. // ResearchGroupMember 研究方向组员信息
  13. //type ResearchGroupMember struct {
  14. // AdminId int `json:"admin_id"`
  15. // AdminName string `json:"admin_name"`
  16. //}
  17. // GetResearchGroupTree 获取研究方向分组及组员列表
  18. //func GetResearchGroupTree(include int) (respList []*ResearchGroupItem, err error) {
  19. // respList = make([]*ResearchGroupItem, 0)
  20. // list, e := system.GetResearchGroupList()
  21. // if e != nil {
  22. // err = errors.New("获取研究方向分组失败, Err:" + e.Error())
  23. // return
  24. // }
  25. // listLen := len(list)
  26. // if listLen == 0 {
  27. // return
  28. // }
  29. // // 分类
  30. // firstList := make([]*ResearchGroupItem, 0)
  31. // secondList := make([]*ResearchGroupItem, 0)
  32. // for i := 0; i < listLen; i++ {
  33. // item := new(ResearchGroupItem)
  34. // item.ResearchGroupId = list[i].ResearchGroupId
  35. // item.ResearchGroupName = list[i].ResearchGroupName
  36. // item.ParentId = list[i].ParentId
  37. // item.ChartPermissionId = list[i].ChartPermissionId
  38. // item.Sort = list[i].Sort
  39. // if list[i].ParentId == 0 {
  40. // firstList = append(firstList, item)
  41. // } else {
  42. // secondList = append(secondList, item)
  43. // }
  44. // }
  45. // if len(firstList) == 0 {
  46. // return
  47. // }
  48. // // 匹配成员
  49. // relationList, e := system.GetResearchGroupRelationList(include)
  50. // if e != nil {
  51. // err = errors.New("获取研究方向关系失败, Err:" + e.Error())
  52. // return
  53. // }
  54. // for _, v := range secondList {
  55. // members := make([]*ResearchGroupMember, 0)
  56. // for _, r := range relationList {
  57. // if v.ResearchGroupId == r.ResearchGroupId {
  58. // members = append(members, &ResearchGroupMember{
  59. // AdminId: r.AdminId,
  60. // AdminName: r.AdminName,
  61. // })
  62. // }
  63. // }
  64. // v.Members = members
  65. // }
  66. // // 匹配子分类
  67. // for _, p := range firstList {
  68. // children := make([]*ResearchGroupItem, 0)
  69. // for _, child := range secondList {
  70. // if p.ResearchGroupId == child.ParentId {
  71. // children = append(children, child)
  72. // }
  73. // }
  74. // p.Children = children
  75. // }
  76. // respList = firstList
  77. // return
  78. //}
  79. // UpdateAdminResearchGroup 更新研究员研究方向分组
  80. //func UpdateAdminResearchGroup(adminId int, groupIds string) (err error) {
  81. // if adminId == 0 {
  82. // return
  83. // }
  84. // items := make([]*system.ResearchGroupRelation, 0)
  85. // groupIdArr := strings.Split(groupIds, ",")
  86. // if groupIds != "" {
  87. // for _, v := range groupIdArr {
  88. // groupId, e := strconv.Atoi(v)
  89. // if e != nil {
  90. // err = errors.New("分组ID有误")
  91. // return
  92. // }
  93. // items = append(items, &system.ResearchGroupRelation{
  94. // ResearchGroupId: groupId,
  95. // AdminId: adminId,
  96. // })
  97. // }
  98. // }
  99. // if e := system.UpdateAdminResearchGroup(adminId, items); e != nil {
  100. // err = errors.New("更新研究方向分组失败, Err:" + e.Error())
  101. // }
  102. // return
  103. //}