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.DynamicBlacklistClientService;
import com.red.circle.other.inner.endpoint.dynamic.api.DynamicBlacklistClientApi;
import com.red.circle.other.inner.model.cmd.dynamic.DynamicBlacklistCmd;
import com.red.circle.other.inner.model.cmd.dynamic.DynamicBlacklistQryCmd;
import com.red.circle.other.inner.model.dto.dynamic.PageDynamicBlacklistDTO;
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 = DynamicBlacklistClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class DynamicBlacklistClientEndpoint implements DynamicBlacklistClientApi {

  private final DynamicBlacklistClientService dynamicBlacklistClientService;


  @Override
  public ResultResponse<Void> deleteByUserId(Long userId) {
    dynamicBlacklistClientService.deleteByUserId(userId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> add(DynamicBlacklistCmd cmd) {
    dynamicBlacklistClientService.add(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<PageDynamicBlacklistDTO>> pageDynamicBlacklist(
      DynamicBlacklistQryCmd cmd) {
    return ResultResponse.success(dynamicBlacklistClientService.pageDynamicBlacklist(cmd));
  }
}
