package com.jeesharp.business.modules.setting.convert;

import com.jeesharp.business.modules.setting.dto.HelpCategorySaveDTO;
import com.jeesharp.business.modules.setting.entity.HelpCategory;
import com.jeesharp.business.modules.setting.vo.HelpCategoryVO;
import com.jeesharp.business.modules.setting.vo.HelpCategoryListVO;
import com.jeesharp.business.modules.setting.vo.HelpCategoryQueryVO;
import com.jeesharp.framework.common.pojo.convert.BasePojoConvert;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * 帮助分类转换器
 *
 * @author jeesharp
 * @version 2026-02-05
 */
@Mapper
public interface HelpCategoryConvert extends BasePojoConvert<HelpCategory, HelpCategorySaveDTO, HelpCategoryVO, HelpCategoryListVO, HelpCategoryQueryVO> {

    HelpCategoryConvert INSTANCE = Mappers.getMapper(HelpCategoryConvert.class);

    // ==================== 转换方法 ====================

    /**
     * 应用标识转名称
     */
    @Named("appToName")
    default String appToName(String app) {
        if (app == null || app.isEmpty()) {
            return "";
        }
        return switch (app) {
            case "APP" -> "APP客户端";
            case "WECHAT_MINI" -> "微信小程序";
            case "WECHAT_MP" -> "微信公众号";
            case "H5" -> "H5页面";
            case "PC" -> "PC端";
            default -> app;
        };
    }

    /**
     * 状态转名称
     */
    @Named("statusToName")
    default String statusToName(Integer status) {
        if (status == null) {
            return "";
        }
        return switch (status) {
            case 0 -> "禁用";
            case 1 -> "启用";
            default -> "未知";
        };
    }
}
