package com.ktg.system.strategy;

import com.ktg.common.core.domain.entity.SysAutoCodePart;
import com.ktg.common.utils.MessageUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

@Component
@Order(0)
public class PartTypeInputCharHandler implements PartTypeTemplate {


    @Override
    public String partHandle(SysAutoCodePart sysAutoCodePart) {
        String inputCharacter = sysAutoCodePart.getInputCharacter();
        Assert.notNull(inputCharacter, MessageUtils.message("assert.code.rule.input.char.not.null"));
        Assert.isTrue(inputCharacter.length() == sysAutoCodePart.getPartLength(),MessageUtils.message("assert.code.rule.input.char.length.error"));
        return inputCharacter;
    }
}
