package com.battery.business.service.report;
|
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
import com.ruoyi.common.exception.ServiceException;
|
|
/** 拼接详情字段只描述身份、顺序与展示语义,不携带测试或数据值。 */
|
public record SpliceField(String name, String category, String unit, Long fieldDefinitionId, String displayName)
|
{
|
public SpliceField
|
{
|
if (name == null || name.isBlank() || name.length() > 100
|
|| !("battery".equals(category) || "special".equals(category)))
|
throw new ServiceException("拼接字段名称或分类无效");
|
unit = unit == null ? "" : unit.trim();
|
displayName = displayName == null ? name : displayName.trim();
|
if (unit.length() > 30 || displayName.isBlank() || displayName.length() > 100
|
|| (fieldDefinitionId != null && (fieldDefinitionId <= 0 || !"battery".equals(category))))
|
throw new ServiceException("拼接字段展示名称、单位或共享身份无效");
|
}
|
|
/** 拒绝将测量或人工值混入模板字段。 */
|
@JsonAnySetter
|
public void rejectUnknown(String field, Object value) { throw new ServiceException("拼接字段不允许提交属性:" + field); }
|
}
|