package com.ruoyi.web.modules.trading.support;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.modules.trading.domain.BizIsolationPen;

/**
 * 隔离圈位入参校验。
 */
public final class IsolationPenValidation
{
    private IsolationPenValidation()
    {
    }

    public static void trimFieldsForSave(BizIsolationPen row)
    {
        if (row == null)
        {
            return;
        }
        if (row.getRemark() != null)
        {
            String remark = row.getRemark().trim();
            row.setRemark(remark.isEmpty() ? null : remark);
        }
    }

    public static void validateRemark(String remark)
    {
        if (remark != null && remark.length() > 50)
        {
            throw new ServiceException("圈位备注不能超过50个字符");
        }
    }

    public static void validateRowForSave(BizIsolationPen row)
    {
        trimFieldsForSave(row);
        validateRemark(row.getRemark());
    }
}
