package com.sonic.frog.controller.web;

import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Result;
import com.sonic.frog.domain.output.SignInRoundOutput;
import com.sonic.frog.service.SignInRecordService;
import com.sonic.frog.service.SignInStatSearchService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Web-签到
 * @author code
 */
@Slf4j
@Validated
@RestController
public class SignInWeb {

    @Autowired
    private SignInRecordService signInRecordService;
    @Autowired
    private SignInStatSearchService signInStatSearchService;

    @ApiOperation(value = "签到", tags = {"Web-签到"})
    @PostMapping("/web/si/asi")
    public Result<Boolean> signIn(@ApiParam(hidden = true) Session session, @ApiParam(hidden = true) HttpServletRequest request) {
        return Result.success(signInRecordService.signIn(session.getUserId()));
    }

    @ApiOperation(value = "七天签到列表", tags = {"Web-签到"})
    @PostMapping("/web/si/list")
    public Result<SignInRoundOutput> signInList(@ApiParam(hidden = true) Session session, @ApiParam(hidden = true) HttpServletRequest request) {
        return Result.success(signInStatSearchService.signInList(session.getUserId()));
    }

}
