package com.kingdee.eas.custom.dataconfig.utils.service;

import com.alibaba.fastjson.JSONObject;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.bsf.service.app.IHRMsfService;
import com.kingdee.bos.metadata.entity.EntityObjectInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.dataconfig.utils.SqlUtils;

import java.util.Map;

public class GetEntityInfoService  implements IHRMsfService {
    @Override
    public Object process(Context context, Map map) throws EASBizException, BOSException {
        Object o = map.get("entryFull");
        String entryFull = o.toString();
        SqlUtils sqlUtils = new SqlUtils();
        EntityObjectInfo entryInfo = sqlUtils.getEntryInfo(entryFull, context);
        JSONObject jsonObject = new JSONObject();
        if (entryInfo.getTable()!=null){
            jsonObject.put("code",200);
            JSONObject object = new JSONObject();
            object.put("name", entryInfo.getName());
            object.put("alias", entryInfo.getAlias());
            object.put("displayName", entryInfo.getAlias());
            jsonObject.put("data",object);
        }else {
            jsonObject.put("code",400);
        }

        return jsonObject;
    }

}
