package com.red.circle.other.infra.common.user;

import com.red.circle.other.inner.model.dto.user.WeekCpUserIdDTO;
import com.red.circle.tool.core.parse.DataTypeUtils;
import com.red.circle.tool.core.text.StringUtils;

/**
 * @author pengliang on 2024/2/28
 */
public final class UserCpUtils {

  /**
   * 解析cp, id.
   */
  public static WeekCpUserIdDTO parseUserIdPair(String id) {

    if (StringUtils.isBlanks(id)) {
      return null;
    }
    String[] ids = id.split("_");
    if (ids.length < 2) {
      return null;
    }

    WeekCpUserIdDTO dto = new WeekCpUserIdDTO();
    dto.setUserIdOne(DataTypeUtils.toLong(ids[0]));
    dto.setUserIdTwo(DataTypeUtils.toLong(ids[1]));
    return dto;
  }

}
