model.go 1.1 KB

12345678910111213141516171819202122232425262728
  1. package research_group_relation
  2. import "hongze/hongze_yb/global"
  3. // GetResearchGroupRelationByAdminId 获取研究员研究方向分组
  4. func GetResearchGroupRelationByAdminId(adminId int) (items []*ResearchGroupRelation, err error) {
  5. err = global.DEFAULT_MYSQL.Model(ResearchGroupRelation{}).Where("admin_id = ?", adminId).Scan(&items).Error
  6. return
  7. }
  8. // ResearchGroupRelation 研究方向分组关系表
  9. type ResearchGroupRelationItem struct {
  10. ResearchGroupId int `json:"research_group_id" description:"研究方向分组ID"`
  11. AdminId int `json:"admin_id" description:"研究员ID"`
  12. AdminName string `json:"admin_name" description:"研究员姓名"`
  13. }
  14. // GetResearchGroupRelationList 获取研究方向分组关系列表
  15. func GetResearchGroupRelationList() (list []*ResearchGroupRelationItem, err error) {
  16. err = global.DEFAULT_MYSQL.
  17. Table("research_group_relation AS a ").
  18. Select("a.research_group_id, a.admin_id, b.real_name AS admin_name").
  19. Joins("INNER JOIN admin AS b ON a.admin_id = b.admin_id").
  20. Where("b.enabled = 1").
  21. Order("a.research_group_id ASC, a.admin_id ASC").
  22. Find(&list).Error
  23. return
  24. }