1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.talentcard.server.service;
 
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.talentcard.server.entity.AdminApprovalOrganization;
import com.talentcard.server.mapper.AdminApprovalOrganizationMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
@Service
public class AdminApprovalInfoService {
    private final AdminApprovalOrganizationMapper organizationMapper;
 
    public AdminApprovalInfoService(AdminApprovalOrganizationMapper organizationMapper) {
        this.organizationMapper = organizationMapper;
    }
 
    @Transactional(readOnly = true)
    public List<Map<String, Object>> list() {
        return organizationMapper.selectList(new QueryWrapper<AdminApprovalOrganization>()
                        .select("id", "organization_name", "address", "latitude", "longitude", "rights_text",
                                "consultation_phone", "office_hours", "target_talent", "pdf_file", "is_pdf_visible")
                        .eq("deleted", 0)
                        .eq("enabled", 1)
                        .orderByAsc("sort_no", "id"))
                .stream()
                .map(this::view)
                .toList();
    }
 
    private Map<String, Object> view(AdminApprovalOrganization organization) {
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("id", organization.getId());
        result.put("organization_name", text(organization.getOrganizationName()));
        result.put("address", text(organization.getAddress()));
        result.put("latitude", organization.getLatitude());
        result.put("longitude", organization.getLongitude());
        result.put("rights_text", text(organization.getRightsText()));
        result.put("consultation_phone", text(organization.getConsultationPhone()));
        result.put("office_hours", text(organization.getOfficeHours()));
        result.put("target_talent", text(organization.getTargetTalent()));
        boolean pdfVisible = organization.getIsPdfVisible() != null && organization.getIsPdfVisible() == 1;
        result.put("is_pdf_visible", pdfVisible ? 1 : 0);
        if (pdfVisible && organization.getPdfFile() != null && !organization.getPdfFile().isBlank()) {
            result.put("pdf_file", organization.getPdfFile());
        }
        return result;
    }
 
    private String text(String value) {
        return value == null ? "" : value.trim();
    }
}