xinyb
9 天以前 b7ef4bb09e69ba27c29ea06a7f348f753c530a44
src/com/yc/crm/mail/action/MailFolder.java
@@ -1,6 +1,7 @@
package com.yc.crm.mail.action;
import com.yc.crm.mail.entity.FolderEntity;
import com.yc.crm.mail.entity.MailModuleBelowEntity;
import com.yc.crm.mail.entity.T482107Entity;
import com.yc.crm.mail.service.MailFolderIfc;
import com.yc.crm.mail.util.AllBackMsg;
@@ -161,7 +162,7 @@
     * @return
     */
    @GetMapping("/getFolder.do")
    public AllBackMsg getFolder(String search, HttpServletRequest request, HttpServletResponse response) {
    public AllBackMsg getFolder(HttpServletRequest request, HttpServletResponse response) {
        AllBackMsg msg = new AllBackMsg();
        try {
            HttpSession session = request.getSession();
@@ -172,7 +173,7 @@
            }
            DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
            SpObserver.setDBtoInstance("_" + dataSource.getDbId());
            List<T482107Entity> t482107Entities = mailFolderIfc.getMailFolder(userCode, search);
            List<T482107Entity> t482107Entities = mailFolderIfc.getMailFolder(userCode);
            if (t482107Entities.size() > 0) {
                //返回树结构
                msg.setSuccess("执行成功", getFolderList(t482107Entities, ""));
@@ -217,4 +218,37 @@
            throw e;
        }
    }
    /**
     * 文件夹树结构
     *
     * @param t482107
     * @param rowId
     * @return
     */
    public static List<MailModuleBelowEntity> getFolderModule(List<T482107Entity> t482107, String rowId) {
        List<MailModuleBelowEntity> folder = new ArrayList<>();
        try {
            for (T482107Entity t : t482107) {
                if (folder.stream().filter(f -> f.getParentKey().equals(rowId)).count() == 0) {
                    List<T482107Entity> fo = t482107.stream().filter(o -> o.getParentRowId().equals(rowId)).collect(Collectors.toList());
                    if (fo.size() > 0) {
                        for (T482107Entity y : fo) {
                            MailModuleBelowEntity folder1 = new MailModuleBelowEntity();
                            folder1.setKey(y.getRowId());
                            folder1.setParentKey(y.getParentRowId());
                            folder1.setName(y.getFolderName());
                            folder1.setList(getFolderModule(t482107, y.getRowId()));
                            folder.add(folder1);
                        }
                    } else {
                        break;
                    }
                }
            }
            return folder;
        } catch (Exception e) {
            throw e;
        }
    }
}