package com.red.circle.other.app.inner.endpoint.dynamic;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.dynamic.DynamicTagClientService;
import com.red.circle.other.inner.endpoint.dynamic.api.DynamicTagClientApi;
import com.red.circle.other.inner.model.cmd.dynamic.DynamicTagCmd;
import com.red.circle.other.inner.model.cmd.dynamic.PageDynamicTagQryCmd;
import com.red.circle.other.inner.model.dto.dynamic.DynamicTagDTO;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动态-内容服务.
 *
 * @author pengliang on 2023/6/5
 */
@Validated
@RestController
@RequestMapping(value = DynamicTagClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class DynamicTagClientEndpoint implements DynamicTagClientApi {

  private final DynamicTagClientService dynamicTagClientService;

  @Override
  public ResultResponse<Void> addOrUpdate(DynamicTagCmd dynamicTag) {
    dynamicTagClientService.addOrUpdate(dynamicTag);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<PageResult<DynamicTagDTO>> pageData(PageDynamicTagQryCmd query) {
    return ResultResponse.success(dynamicTagClientService.pageData(query));
  }

  @Override
  public ResultResponse<Map<String, DynamicTagDTO>> getAllDynamicTag() {
    return ResultResponse.success(dynamicTagClientService.getAllDynamicTag());
  }
}
