package com.xunhong.erp.turbo.api.infra.dto.vo;

import com.alibaba.cola.dto.DTO;
import com.xunhong.erp.turbo.api.infra.dto.enums.CategoryTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@Schema(title = "素材内容")
@EqualsAndHashCode(callSuper = true)
public class MaterialVO extends DTO {

	@Schema(title = "素材内容ID", requiredMode = Schema.RequiredMode.REQUIRED, type = "string")
	private Long materialId;

	@Schema(title = "素材内容标题", requiredMode = Schema.RequiredMode.REQUIRED)
	private String name;

	@Schema(title = "素材内容路劲", requiredMode = Schema.RequiredMode.REQUIRED)
	private String path;

	@Schema(title = "素材内容地址", requiredMode = Schema.RequiredMode.REQUIRED)
	private String url;

	@Schema(title = "上级分类id", requiredMode = Schema.RequiredMode.REQUIRED, type = "string")
	private Long categoryId;

	@Schema(title = "素材类型", requiredMode = Schema.RequiredMode.REQUIRED)
	private CategoryTypeEnum type;

	@Schema(title = "分类内容")
	private CategoryVO categoryVO;

	public String getUrl() {
		if (this.type.equals(CategoryTypeEnum.SPEECH)) {
			return null;
		}

		return "https://img.qilincloud168.com/" + this.path;
	}
}
