package com.red.circle.console.app.service.app.activity;

import com.red.circle.common.business.dto.cmd.IdLongCmd;
import com.red.circle.console.app.convertor.activity.ActivityGlobalizationDescriptionAppConvertor;
import com.red.circle.console.app.dto.cmd.app.activity.ActivityGlobalizationDescriptionCmd;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.inner.endpoint.activity.ActivityGlobalizationDescriptionClient;
import com.red.circle.other.inner.model.dto.activity.ActivityGlobalizationDescriptionDTO;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 国际化描述 实现.
 *
 * @author pengliang on 2023/10/8
 */
@Service
@RequiredArgsConstructor
public class ActivityGlobalizationDescriptionServiceImpl implements
    ActivityGlobalizationDescriptionService {

  private final ActivityGlobalizationDescriptionClient activityGlobalizationDescriptionClient;
  private final ActivityGlobalizationDescriptionAppConvertor activityGlobalizationDescriptionAppConvertor;

  @Override
  public List<ActivityGlobalizationDescriptionDTO> listByRelationId(IdLongCmd cmd) {
    return ResponseAssert.requiredSuccess(
        activityGlobalizationDescriptionClient.listByRelationId(cmd.getId()));
  }

  @Override
  public void saveOrUpdate(ActivityGlobalizationDescriptionCmd cmd) {
    activityGlobalizationDescriptionClient.saveOrUpdate(
        activityGlobalizationDescriptionAppConvertor.toActivityGlobalizationDescriptionDTO(
            cmd
        ));
  }

  @Override
  public void deleteById(IdLongCmd cmd) {
    activityGlobalizationDescriptionClient.deleteById(cmd.getId());
  }
}
