package com.vincent.rsf.openApi.controller; import com.vincent.rsf.framework.common.Cools; import com.vincent.rsf.openApi.entity.dto.CommonResponse; import com.vincent.rsf.openApi.entity.params.GetTokenParam; import com.vincent.rsf.openApi.service.TokenService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController @Api(tags = "应用认证管理") public class AuthController { @Autowired private TokenService tokenService; @ApiOperation("获取App认证Token") @PostMapping("/getToken") public CommonResponse getToken(@RequestBody GetTokenParam param) { String appId = param != null ? param.getAppId() : null; String appSecret = param != null ? param.getAppSecret() : null; if (Cools.isEmpty(appId, appSecret)) { return CommonResponse.error("AppId和AppSecret不能为空"); } String token = tokenService.issueToken(appId, appSecret); if (token == null) { return CommonResponse.error("AppId或AppSecret无效"); } return CommonResponse.ok().setMsg("获取Token成功").setData(token); } }