package com.liquidnet.service.adam.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.service.adam.dto.param.AdamCaomeiPassportNoParam;
import com.liquidnet.service.adam.dto.vo.AdamCaomeiPassportHomeVo;
import com.liquidnet.service.adam.dto.vo.AdamCaomeiPassportUserClaimedBadgeVo;
import com.liquidnet.service.adam.service.IAdamCaomeiPassportUserService;
import com.liquidnet.service.base.ResponseDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@ApiSupport(order = 10045)
@Api(tags = "草莓护照（用户端）")
@Slf4j
@Validated
@RestController
@RequestMapping("caomei/passport")
public class AdamCaomeiPassportUserController {

    @Autowired
    private IAdamCaomeiPassportUserService adamCaomeiPassportUserService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("绑定实体护照（内含·编号有效性、是否可绑等校验）")
    @PostMapping("bind")
    public ResponseDto<List<AdamCaomeiPassportUserClaimedBadgeVo>> bind(@Valid @RequestBody AdamCaomeiPassportNoParam param) {
        return adamCaomeiPassportUserService.bindPassport(param.getPassportNo());
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("护照首页聚合数据（含签证页 type=4 字段 visaBadges，访问时自动静默发放）")
    @GetMapping("home")
    public ResponseDto<AdamCaomeiPassportHomeVo> home() {
        return adamCaomeiPassportUserService.getPassportHome();
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("校验当前用户是否已绑定护照")
    @GetMapping("/check")
    public ResponseDto<Boolean> checkBound() {
        return adamCaomeiPassportUserService.checkPassportBound();
    }
}
