class DeviceMetadataMappingEntity extends GenericEntity<String> implements RecordCreationEntity {

    @Schema(description = "产品ID")
    @Column(length = 64, nullable = false, updatable = false)
    @NotBlank(groups = CreateGroup.class)
    private String productId;

    @Schema(description = "设备ID,为空时表示映射对产品下所有设备生效")
    @Column(length = 64, updatable = false)
    @NotBlank
    private String deviceId;

    @Schema(description = "物模型类型,如:property")
    @Column(length = 32, nullable = false, updatable = false)
    @DefaultValue("property")
    @NotNull(groups = CreateGroup.class)
    @EnumCodec
    @ColumnType(javaType = String.class)
    private ThingMetadataType metadataType;

    @Schema(description = "物模型ID,如:属性ID")
    @Column(length = 64, nullable = false, updatable = false)
    @NotBlank(groups = CreateGroup.class)
    private String metadataId;

    @Schema(description = "原始物模型ID")
    @Column(length = 64, nullable = false)
    @NotBlank(groups = CreateGroup.class)
    private String originalId;

    @Schema(description = "其他配置")
    @Column
    @JsonCodec
    @ColumnType(jdbcType = JDBCType.LONGVARCHAR)
    private Map<String, Object> others;

    @Schema(description = "说明")
    @Column(length = 512)
    private String description;

    @Schema(description = "创建者ID", accessMode = Schema.AccessMode.READ_ONLY)
    @Column(length = 64, updatable = false)
    private String creatorId;

    @Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY)
    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    private Long createTime;

    @Override
    public String getId() {
        if (super.getId() == null) {
            generateId();
        }
        return super.getId();
    }

    public void generateId() {<FILL_FUNCTION_BODY>}

    public static String generateIdByProduct(String productId, ThingMetadataType type, String metadataId) {
        return DigestUtils.md5Hex(String.join(":", "product", productId, type.name(), metadataId));
    }

    public static String generateIdByDevice(String deviceId, ThingMetadataType type, String metadataId) {
        return DigestUtils.md5Hex(String.join(":", "device", deviceId, type.name(), metadataId));
    }
}

        if (StringUtils.hasText(deviceId)) {
            setId(
                generateIdByDevice(deviceId, metadataType, metadataId)
            );
        } else if (StringUtils.hasText(productId)) {
            setId(
                generateIdByProduct(productId, metadataType, metadataId)
            );
        }
    
<no_super_class>