package ink.wgink.login.app.controller.resource.appsign;

import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.login.app.service.appsign.IAppSignService;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultData;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: AppSignResourceController
 * @Description: APP登录
 * @Author: wanggeng
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "APP登录")
@RestController
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/appsign")
public class AppSignResourceController extends DefaultBaseController {

    @Autowired
    private IAppSignService appSignService;

    @ApiOperation(value = "通过用户ID获取token", notes = "通过用户ID获取token接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("get-token/user-id/{userId}")
    public SuccessResultData<String> getTokenByUserId(@PathVariable("userId") String userId) throws Exception {
        LOG.debug("Get token by userId: {}", userId);
        return new SuccessResultData<>(appSignService.userIdSign(userId));
    }


}
