Merge branch 'feat-hjj-ReportsManage' into dev
This commit is contained in:
commit
dd71b69618
@ -248,3 +248,53 @@ func (membersDao) EditCommitteeAppointments(req *members.EditCommitteeAppointmen
|
|||||||
}
|
}
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
@ -72,43 +72,63 @@ func (membersLogic) GetMemberList(req *members.GetMemberListReq) (result *member
|
|||||||
Operator: member.Operator,
|
Operator: member.Operator,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, v := range result.Data {
|
|
||||||
management, err := dao.MembersDao.GetManagementByUuid(v.Uuid)
|
if len(result.Data) > 0 {
|
||||||
if err != nil {
|
// 收集所有UUID
|
||||||
return nil, errors.New("查询成员管理失败")
|
uuids := make([]string, len(result.Data))
|
||||||
}
|
for i, member := range result.Data {
|
||||||
v.Management = &members.Management{
|
uuids[i] = member.Uuid
|
||||||
Name: management.Name,
|
|
||||||
Image: management.Image,
|
|
||||||
Brief: management.Brief,
|
|
||||||
Introduction: management.Introduction,
|
|
||||||
Status: management.Status,
|
|
||||||
IsSetting: management.IsSetting,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boardOfDirectors, err := dao.MembersDao.GetBoardOfDirectorsByUuid(v.Uuid)
|
// 批量查询所有关联数据
|
||||||
|
managementMap, err := dao.MembersDao.GetManagementByUuids(uuids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("查询董事会失败")
|
return nil, errors.New("批量查询成员管理失败")
|
||||||
}
|
|
||||||
v.BoardOfDirectors = &members.BoardOfDirectors{
|
|
||||||
Name: boardOfDirectors.Name,
|
|
||||||
Status: boardOfDirectors.Status,
|
|
||||||
Brief: boardOfDirectors.Brief,
|
|
||||||
Introduction: boardOfDirectors.Introduction,
|
|
||||||
IsSetting: boardOfDirectors.IsSetting,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
committeeAppointments, err := dao.MembersDao.GetCommitteeAppointmentsByUuid(v.Uuid)
|
boardOfDirectorsMap, err := dao.MembersDao.GetBoardOfDirectorsByUuids(uuids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("查询委员会失败")
|
return nil, errors.New("批量查询董事会失败")
|
||||||
}
|
}
|
||||||
v.CommitteeAppointments = &members.CommitteeAppointments{
|
|
||||||
Name: committeeAppointments.Name,
|
committeeAppointmentsMap, err := dao.MembersDao.GetCommitteeAppointmentsByUuids(uuids)
|
||||||
Status: committeeAppointments.Status,
|
if err != nil {
|
||||||
AuditCommittee: committeeAppointments.AuditCommittee,
|
return nil, errors.New("批量查询委员会失败")
|
||||||
CompensationCommittee: committeeAppointments.CompensationCommittee,
|
}
|
||||||
NominatingCommittee: committeeAppointments.NominatingCommittee,
|
|
||||||
IsSetting: committeeAppointments.IsSetting,
|
// 批量赋值
|
||||||
|
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
|
return result, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user