package com.goldenwater.slgc.service.impl.pms;

import com.goldenwater.slgc.entity.efinder.DocFolder;
import com.goldenwater.slgc.mapper.efinder.DocFolderMapper;
import com.goldenwater.slgc.service.pms.IPmsUserProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class PmsUserProjectServiceImpl implements IPmsUserProjectService {
    @Autowired
    private DocFolderMapper docFolderMapper;

    @Override
    public List<Map<String, Object>> getUserProject() {
        List<DocFolder> folders = docFolderMapper.selectByParentId(null);
        List<Map<String, Object>> result = new ArrayList<>();
        for (DocFolder folder : folders) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", folder.getId());
            map.put("name", folder.getName());
            result.add(map);
        }
        return result;
    }
}
