package com.sunyard.chsm.controller;

import com.sunyard.chsm.param.AppTokenReq;
import com.sunyard.chsm.param.AppTokenResp;
import com.sunyard.chsm.service.AppLoginService;
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.annotation.Resource;
import javax.validation.Valid;

/**
 * 应用Token服务接口
 *
 * @author liulu
 * @version V1.0
 * @since 2024/12/4
 */
@RestController
@RequestMapping
public class AppLoginController {

    @Resource
    private AppLoginService appLoginService;


    /**
     * 获取应用Token接口
     * 密码服务平台为各个接入应用提供生成应用授权Token,
     * 接入应用需在密码服务平台获取了到平台分配的appKey和appSecret
     *
     * @param appTokenReq 请求参数
     * @return
     */
    @PostMapping("/appUser/getAppToken")
    public AppTokenResp getAppToken(@Valid @RequestBody AppTokenReq appTokenReq) {
        return appLoginService.getAppToken(appTokenReq);
    }

    @PostMapping("/appUser/getAppTokenTest")
    public AppTokenResp getAppTokenForTest(@Valid @RequestBody AppTokenReq appTokenReq) {
        return appLoginService.getAppTokenForTest(appTokenReq);
    }



}
