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

import com.jeesharp.business.modules.setting.dto.AboutUsSaveDTO;
import com.jeesharp.business.modules.setting.entity.AboutUs;
import com.jeesharp.business.modules.setting.vo.AboutUsInfoVO;
import com.jeesharp.business.modules.setting.vo.AboutUsListVO;
import com.jeesharp.business.modules.setting.vo.AboutUsQueryVO;
import com.jeesharp.framework.common.pojo.convert.BasePojoConvert;
import org.mapstruct.Mapper;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * 关于我们转换器
 *
 * @author jeesharp
 * @version 2026-02-05
 */
@Mapper
public interface AboutUsConvert extends BasePojoConvert<AboutUs, AboutUsSaveDTO, AboutUsInfoVO, AboutUsListVO, AboutUsQueryVO> {

    AboutUsConvert INSTANCE = Mappers.getMapper(AboutUsConvert.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 -> "未知";
        };
    }
}
