package com.liquidnet.service.adam.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.adam.dto.param.AdamCaomeiBadgeClaimParam;
import com.liquidnet.service.adam.service.IAdamCaomeiBadgeUserService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@ApiSupport(order = 10046)
@Api(tags = "草莓徽章（用户端）")
@Slf4j
@Validated
@RestController
@RequestMapping("caomei/badge")
public class AdamCaomeiBadgeUserController {

    @Autowired
    private IAdamCaomeiBadgeUserService adamCaomeiBadgeUserService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("认领徽章")
    @PostMapping("claim")
    public ResponseDto<String> claim(@Valid @RequestBody AdamCaomeiBadgeClaimParam param) {
        String uid = CurrentUtil.getCurrentUid();
        return adamCaomeiBadgeUserService.claimBadge(param.getBadgeId(), uid);
    }
}
