package cn.stylefeng.team.project.api.format;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.rule.format.BaseSimpleFieldFormatProcess;
import cn.stylefeng.team.project.api.BusinessServiceApi;

public class BusinessNameFormatProcess extends BaseSimpleFieldFormatProcess {

    @Override
    public Class<?> getItemClass() {
        return Long.class;
    }

    @Override
    public Object simpleItemFormat(Object businessId) {
        if (ObjectUtil.isEmpty(businessId)) {
            return null;
        }

        BusinessServiceApi businessServiceApi = SpringUtil.getBean(BusinessServiceApi.class);

        try {
            return businessServiceApi.getBusinessName(Convert.toLong(businessId));
        } catch (Exception e) {

            return null;
        }
    }

}
