package com.sonic.frog.controller.api;

import com.sonic.common.rpc.Result;
import com.sonic.frog.domain.input.SubMemberGiftUserCreateCountInput;
import com.sonic.frog.domain.input.UserIdInput;
import com.sonic.frog.service.ChatSetService;
import com.sonic.frog.service.UserCreateCountStatService;
import com.sonic.sdk.api.annotation.IgnoreAuth;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * AI接口
 *
 * @author code
 */
@RestController
@Slf4j
public class UserMemberApi {

    @Autowired
    private ChatSetService chatSetService;
    @Autowired
    private UserCreateCountStatService userCreateCountStatService;

    @IgnoreAuth
    @ApiOperation(value = "用户会员过期通知", tags = {"API-接口"})
    @PostMapping("/api/user-member/exp-notify")
    public Result<Void> userMemberExpNotify(@RequestBody UserIdInput input) {
        //关闭掉自动播放语音的开关
        chatSetService.closeAutoPlayVoice(input.getUserIdList());
        return Result.success();
    }

    @IgnoreAuth
    @ApiOperation(value = "订阅会员或续订时，增加用户会员创作次数", tags = {"API-接口"})
    @PostMapping("/api/user-member/gift-user-create-count")
    public Result<Void> subMemberGiftUserCreateCount(@RequestBody SubMemberGiftUserCreateCountInput input) {
        userCreateCountStatService.subMemberGiftUserCreateCount(input.getUserId(),input.getStartTime(),input.getExpireTime());
        return Result.success();
    }

}

