package com.red.circle.console.adapter.app.dynamic;

import com.red.circle.console.app.service.app.dynamic.DynamicBlacklistService;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
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.user.UserProfileDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动态-黑名单 前端控制器.
 *
 * @author pengshigang
 * @since 2022-06-30
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/dynamic/blacklist")
public class DynamicBlacklistRestController extends BaseController {

  private final DynamicBlacklistService dynamicBlacklistService;

  /**
   * 分页
   */
  @GetMapping("/page")
  public PageResult<UserProfileDTO> pageData(DynamicBlacklistQryCmd query) {
    return dynamicBlacklistService.page(query);
  }

  /**
   * 添加.
   */
  @PostMapping("/add")
  public void add(@RequestBody @Validated DynamicBlacklistCmd param) {
    dynamicBlacklistService.add(param);
  }

  /**
   * 删除.
   */
  @GetMapping("/delete/{userId}")
  public void deleteByUserId(@PathVariable("userId") Long userId) {
    dynamicBlacklistService.deleteByUserId(userId);
  }

}
