package com.fzm.mall.server.front.system.controller;

import com.fzm.mall.server.front.base.ResponseVO;
import com.fzm.mall.server.front.repo.ResponseFactory;
import com.fzm.mall.server.front.system.service.ApiTokenService;
import com.fzm.mall.server.front.user.model.Header;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wulixian
 * @since 2021/5/25
 */
@RestController
@RequestMapping("/mall/apiToken")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ApiTokenController {

    private final ResponseFactory resFac;
    private final ApiTokenService tokenService;

    @PostMapping("/creatApiToken")
    public ResponseVO creatApiToken(@Ignore @RequestAttribute Header header) {
        String result = tokenService.creatApiToken(header.getUid());
        return resFac.getSuccessResponseWithData(result);
    }

}
