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

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.trading.domain.BizMarketStall;

/**
 * 市场栏位入参校验。
 */
public final class MarketStallValidation
{
    private MarketStallValidation()
    {
    }

    public static void trimFieldsForSave(BizMarketStall 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(BizMarketStall row)
    {
        trimFieldsForSave(row);
        validateRemark(row.getRemark());
    }
}
