Merge branch 'feat-hjj-ReportsManage' into dev

This commit is contained in:
jiaji.H 2025-09-29 10:41:01 +08:00
commit dd71b69618
2 changed files with 100 additions and 30 deletions

View File

@ -248,3 +248,53 @@ func (membersDao) EditCommitteeAppointments(req *members.EditCommitteeAppointmen
}
return
}
// 批量查询成员管理,董事会,委员会接口
// 批量查询成员管理
func (membersDao) GetManagementByUuids(uuids []string) (map[string]model.Management, error) {
var managementList []model.Management
err := db.DocDB.Model(&model.Management{}).Where("uuid IN ?", uuids).Find(&managementList).Error
if err != nil {
return nil, err
}
// 转换为map
managementMap := make(map[string]model.Management)
for _, management := range managementList {
managementMap[management.Uuid] = management
}
return managementMap, nil
}
// 批量查询董事会
func (membersDao) GetBoardOfDirectorsByUuids(uuids []string) (map[string]model.BoardOfDirectors, error) {
var boardOfDirectorsList []model.BoardOfDirectors
err := db.DocDB.Model(&model.BoardOfDirectors{}).Where("uuid IN ?", uuids).Find(&boardOfDirectorsList).Error
if err != nil {
return nil, err
}
boardOfDirectorsMap := make(map[string]model.BoardOfDirectors)
for _, boardOfDirectors := range boardOfDirectorsList {
boardOfDirectorsMap[boardOfDirectors.Uuid] = boardOfDirectors
}
return boardOfDirectorsMap, nil
}
// 批量查询委员会
func (membersDao) GetCommitteeAppointmentsByUuids(uuids []string) (map[string]model.CommitteeAppointments, error) {
var committeeAppointmentsList []model.CommitteeAppointments
err := db.DocDB.Model(&model.CommitteeAppointments{}).Where("uuid IN ?", uuids).Find(&committeeAppointmentsList).Error
if err != nil {
return nil, err
}
committeeAppointmentsMap := make(map[string]model.CommitteeAppointments)
for _, committeeAppointments := range committeeAppointmentsList {
committeeAppointmentsMap[committeeAppointments.Uuid] = committeeAppointments
}
return committeeAppointmentsMap, nil
}

View File

@ -72,43 +72,63 @@ func (membersLogic) GetMemberList(req *members.GetMemberListReq) (result *member
Operator: member.Operator,
}
}
for _, v := range result.Data {
management, err := dao.MembersDao.GetManagementByUuid(v.Uuid)
if err != nil {
return nil, errors.New("查询成员管理失败")
}
v.Management = &members.Management{
Name: management.Name,
Image: management.Image,
Brief: management.Brief,
Introduction: management.Introduction,
Status: management.Status,
IsSetting: management.IsSetting,
if len(result.Data) > 0 {
// 收集所有UUID
uuids := make([]string, len(result.Data))
for i, member := range result.Data {
uuids[i] = member.Uuid
}
boardOfDirectors, err := dao.MembersDao.GetBoardOfDirectorsByUuid(v.Uuid)
// 批量查询所有关联数据
managementMap, err := dao.MembersDao.GetManagementByUuids(uuids)
if err != nil {
return nil, errors.New("查询董事会失败")
}
v.BoardOfDirectors = &members.BoardOfDirectors{
Name: boardOfDirectors.Name,
Status: boardOfDirectors.Status,
Brief: boardOfDirectors.Brief,
Introduction: boardOfDirectors.Introduction,
IsSetting: boardOfDirectors.IsSetting,
return nil, errors.New("批量查询成员管理失败")
}
committeeAppointments, err := dao.MembersDao.GetCommitteeAppointmentsByUuid(v.Uuid)
boardOfDirectorsMap, err := dao.MembersDao.GetBoardOfDirectorsByUuids(uuids)
if err != nil {
return nil, errors.New("查询委员会失败")
return nil, errors.New("批量查询董事会失败")
}
v.CommitteeAppointments = &members.CommitteeAppointments{
Name: committeeAppointments.Name,
Status: committeeAppointments.Status,
AuditCommittee: committeeAppointments.AuditCommittee,
CompensationCommittee: committeeAppointments.CompensationCommittee,
NominatingCommittee: committeeAppointments.NominatingCommittee,
IsSetting: committeeAppointments.IsSetting,
committeeAppointmentsMap, err := dao.MembersDao.GetCommitteeAppointmentsByUuids(uuids)
if err != nil {
return nil, errors.New("批量查询委员会失败")
}
// 批量赋值
for _, member := range result.Data {
if management, exists := managementMap[member.Uuid]; exists {
member.Management = &members.Management{
Name: management.Name,
Image: management.Image,
Brief: management.Brief,
Introduction: management.Introduction,
Status: management.Status,
IsSetting: management.IsSetting,
}
}
if boardOfDirectors, exists := boardOfDirectorsMap[member.Uuid]; exists {
member.BoardOfDirectors = &members.BoardOfDirectors{
Name: boardOfDirectors.Name,
Status: boardOfDirectors.Status,
Brief: boardOfDirectors.Brief,
Introduction: boardOfDirectors.Introduction,
IsSetting: boardOfDirectors.IsSetting,
}
}
if committeeAppointments, exists := committeeAppointmentsMap[member.Uuid]; exists {
member.CommitteeAppointments = &members.CommitteeAppointments{
Name: committeeAppointments.Name,
Status: committeeAppointments.Status,
AuditCommittee: committeeAppointments.AuditCommittee,
CompensationCommittee: committeeAppointments.CompensationCommittee,
NominatingCommittee: committeeAppointments.NominatingCommittee,
IsSetting: committeeAppointments.IsSetting,
}
}
}
}
return result, nil