package com.red.circle.other.app.command.dynamic.query;

import com.red.circle.other.app.dto.clientobject.dynamic.UserThumbsUpCO;
import com.red.circle.other.app.dto.cmd.dynamic.UserRelationThumbsUpCmd;
import com.red.circle.other.infra.database.rds.service.dynamic.UserThumbsUpService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 用户关系点赞信息
 *
 * @author zongpubin on 2023/04/06
 */
@Component
@RequiredArgsConstructor
public class UserRelationThumsUpQryExe {

  private final UserThumbsUpService userThumbsUpService;

  public UserThumbsUpCO execute(UserRelationThumbsUpCmd cmd) {
    boolean checkExist = userThumbsUpService.checkExist(cmd.requiredReqUserId(),
        cmd.getThumbsUpId());
    long count = userThumbsUpService.countThumbsUp(cmd.getThumbsUpId());
    return new UserThumbsUpCO()
        .setThumbsUps(count)
        .setLike(checkExist);
  }

}
