package cn.axzo.msg.center.utils;

import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
import cn.axzo.msg.center.domain.enums.UserTypeEnum;
import cn.axzo.msg.center.service.enums.IdentityTypeEnum;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author cold_blade
 * @date 2023/10/23
 * @version 1.0
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class PersonIdentityUtil {

    public static UserTypeEnum toUserType(IdentityTypeEnum identityType) {
        switch (identityType) {
            case WORKER:
                return UserTypeEnum.CM;
            case WORKER_LEADER:
                return UserTypeEnum.TEAM;
            case PRACTITIONER:
                return UserTypeEnum.CMP;
            default:
                return UserTypeEnum.NOT_IDENTITY;
        }
    }

    public static IdentityTypeEnum toIdentityType(ReceiveTypeEnum receiveType) {
        if (Objects.isNull(receiveType)) {
            return IdentityTypeEnum.NOT_SUPPORT;
        }
        switch (receiveType) {
            case CM_WORKER:
                return IdentityTypeEnum.WORKER;
            case CM_LEADER:
                return IdentityTypeEnum.WORKER_LEADER;
            case CMP_USER:
                return IdentityTypeEnum.PRACTITIONER;
            default:
                return IdentityTypeEnum.NOT_SUPPORT;
        }
    }

    public static ReceiveTypeEnum toReceiveType(IdentityTypeEnum identityType) {
        switch (identityType) {
            case WORKER:
                return ReceiveTypeEnum.CM_WORKER;
            case WORKER_LEADER:
                return ReceiveTypeEnum.CM_LEADER;
            case PRACTITIONER:
                return ReceiveTypeEnum.CMP_USER;
            default:
                return ReceiveTypeEnum.NOT_IDENTITY;
        }
    }
}
