package cn.stylefeng.workflow.design.modular.factory;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.pinyin.api.PinYinApi;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.workflow.api.constants.WorkflowConstants;
import cn.stylefeng.workflow.api.enums.ModelIconTypeEnum;
import cn.stylefeng.workflow.design.modular.pojo.request.ModelRequest;

import java.math.BigDecimal;

public class BusinessModelFactory {

    public static ModelRequest createBusinessModel(String modelName) {
        return createBusinessModel(modelName, null);
    }

    public static ModelRequest createBusinessModel(String modelName, String remark) {
        ModelRequest modelRequest = new ModelRequest();
        modelRequest.setBusinessCategoryId(WorkflowConstants.NONE_CATEGORY_ID);
        modelRequest.setModelName(modelName);
        modelRequest.setRemark(remark);

        PinYinApi pinYinApi = SpringUtil.getBean(PinYinApi.class);
        modelRequest.setModelCode(pinYinApi.parsePinyinString(modelName) + RandomUtil.randomString(10));

        modelRequest.setModelIconType(ModelIconTypeEnum.ITEM_2.getCode());
        modelRequest.setModelIcon("folder.svg");
        modelRequest.setStatusFlag(StatusEnum.ENABLE.getCode());
        modelRequest.setFldSort(new BigDecimal("100"));

        modelRequest.setHiddenFlag(YesOrNotEnum.Y.getCode());

        return modelRequest;
    }

}
