package com.red.circle.other.app.inner.endpoint.material.props;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.material.props.EmojiConfigClientService;
import com.red.circle.other.inner.endpoint.material.props.api.EmojiConfigClientApi;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiConfigParamCmd;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiConfigQryCmd;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiGroupParamCmd;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiGroupQryCmd;
import com.red.circle.other.inner.model.dto.material.EmojiConfigDTO;
import com.red.circle.other.inner.model.dto.material.EmojiGroupDTO;
import java.util.List;
import java.util.Map;
import java.util.Set;
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/10
 */
@Validated
@RestController
@RequestMapping(value = EmojiConfigClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class EmojiConfigClientEndpoint implements EmojiConfigClientApi {

  private final EmojiConfigClientService emojiConfigClientService;

  @Override
  public ResultResponse<List<EmojiConfigDTO>> listEmojiByGroupId(Long groupId) {
    return ResultResponse.success(emojiConfigClientService.listEmojiByGroupId(groupId));
  }

  @Override
  public ResultResponse<Map<Long, List<EmojiConfigDTO>>> mapByGroupIds(Set<Long> groupIds) {
    return ResultResponse.success(emojiConfigClientService.mapByGroupIds(groupIds));
  }

  @Override
  public ResultResponse<List<EmojiConfigDTO>> listByIds(Set<Long> ids) {
    return ResultResponse.success(emojiConfigClientService.listByIds(ids));
  }

  @Override
  public ResultResponse<PageResult<EmojiGroupDTO>> pageEmojiGroup(SysEmojiGroupQryCmd query) {
    return ResultResponse.success(emojiConfigClientService.pageEmojiGroup(query));
  }

  @Override
  public ResultResponse<Void> groupAddOrUpdate(SysEmojiGroupParamCmd param) {
    emojiConfigClientService.groupAddOrUpdate(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<List<EmojiGroupDTO>> groupListBySysOrigin(String sysOrigin) {
    return ResultResponse.success(emojiConfigClientService.groupListBySysOrigin(sysOrigin));
  }

  @Override
  public ResultResponse<Void> switchGroupShelfStatus(Long id, Boolean status) {
    emojiConfigClientService.switchGroupShelfStatus(id, status);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<EmojiConfigDTO>> pageEmojiConfig(SysEmojiConfigQryCmd query) {
    return ResultResponse.success(emojiConfigClientService.pageEmojiConfig(query));
  }

  @Override
  public ResultResponse<Void> emojiConfigAddOrUpdate(SysEmojiConfigParamCmd param) {
    emojiConfigClientService.emojiConfigAddOrUpdate(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> offShelf(Long id) {
    emojiConfigClientService.offShelf(id);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Map<Long, EmojiGroupDTO>> mapEmojiGroupByIds(Set<Long> ids) {
    return ResultResponse.success(emojiConfigClientService.mapEmojiGroupByIds(ids));
  }

}
