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

import com.jeesharp.business.modules.setting.dto.PrivacyPolicySaveDTO;
import com.jeesharp.business.modules.setting.entity.PrivacyPolicy;
import com.jeesharp.business.modules.setting.enums.PrivacyPolicyStatusEnum;
import com.jeesharp.business.modules.setting.vo.PrivacyPolicyInfoVO;
import com.jeesharp.business.modules.setting.vo.PrivacyPolicyListVO;
import com.jeesharp.business.modules.setting.vo.PrivacyPolicyQueryVO;
import com.jeesharp.framework.common.pojo.convert.BasePojoConvert;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

/**
 * 隐私政策 MapStruct 转换器。
 *
 * @author jeesharp
 * @since 2026-05-20
 */
@Mapper
public interface PrivacyPolicyConvert extends BasePojoConvert<
        PrivacyPolicy,
        PrivacyPolicySaveDTO,
        PrivacyPolicyInfoVO,
        PrivacyPolicyListVO,
        PrivacyPolicyQueryVO> {

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

    @AfterMapping
    default void fillStatusName(@MappingTarget PrivacyPolicyInfoVO vo) {
        if (vo != null) {
            vo.setStatusName(PrivacyPolicyStatusEnum.getDescByValue(vo.getStatus()));
        }
    }

    @AfterMapping
    default void fillListStatusName(@MappingTarget PrivacyPolicyListVO vo) {
        if (vo != null) {
            vo.setStatusName(PrivacyPolicyStatusEnum.getDescByValue(vo.getStatus()));
        }
    }
}
