package com.lesingle.creation.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 作品类型枚举
 */
@Getter
@AllArgsConstructor
public enum WorkTypeEnum {

    IMAGE("image", "图片"),
    VIDEO("video", "视频"),
    DOCUMENT("document", "文档"),
    CODE("code", "代码"),
    OTHER("other", "其他");

    private final String code;
    private final String desc;

    public static WorkTypeEnum getByCode(String code) {
        if (code == null) {
            return OTHER;
        }
        for (WorkTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return OTHER;
    }
}
