package com.red.circle.other.adapter.app.user.account;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.user.vip.UserVipAbilityCO;
import com.red.circle.other.app.dto.cmd.user.vip.UserVipAbilitySettingCmd;
import com.red.circle.other.app.service.user.vip.AppUserVipAbilityService;
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.*;

/**
 * 用户 VIP 设置服务
 *
 * @author tf
 * @eo.api-type http
 * @eo.groupName 用户服务.VIP管理
 * @eo.path /user/vip
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/user/vip", produces = MediaType.APPLICATION_JSON_VALUE)
public class AppUserVipAbilityRestController extends BaseController {

    private final AppUserVipAbilityService appUserVipAbilityService;

    /**
     * 获取用户 VIP 设置
     */
    @GetMapping("/ability")
    public UserVipAbilityCO getUserVipAbility(AppExtCommand appExtCommand) {
        Long userId = appExtCommand.getReqUserId();
        return appUserVipAbilityService.getUserVipAbility(userId);
    }

    /**
     * 更新用户 VIP 设置
     */
    @PostMapping(value = "/ability/update")
    public void updateUserVipAbility(@RequestBody @Validated UserVipAbilitySettingCmd cmd) {
        appUserVipAbilityService.updateUserVipAbility(cmd);
    }

}