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

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.UserGuardCountIncrCmd;
import com.red.circle.other.app.inner.service.user.user.UserGuardCountClientService;
import com.red.circle.other.inner.endpoint.user.user.api.UserGuardCountClientApi;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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/10/17
 */
@Slf4j
@Validated
@RestController
@RequestMapping(value = UserGuardCountClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserGuardCountClientEndpoint implements UserGuardCountClientApi {

  private final UserGuardCountClientService userGuardCountClientService;

  @Override
  public ResultResponse<Void> incrLasts15Days(Long userId, Long guardUserId, Long quantity) {
    userGuardCountClientService.incrLasts15Days(userId, guardUserId, quantity);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> incrLasts15Days(UserGuardCountIncrCmd cmd) {
    userGuardCountClientService.incrLasts15Days(cmd.getUserId(), cmd.getGuardUserIds(),
        cmd.getQuantity());
    return ResultResponse.success();
  }

}
