package com.qianwen.smartman.modules.auth.endpoint; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import com.qianwen.core.log.annotation.ApiLog; import com.qianwen.core.social.request.CustomAuthWeChatEntWebRequest; import com.qianwen.core.tool.api.R; import com.qianwen.core.tool.support.Kv; import com.qianwen.smartman.modules.auth.enums.AccountType; import com.qianwen.smartman.modules.auth.provider.TokenParameter; import com.qianwen.smartman.modules.auth.service.MicroAppAuthService; import com.qianwen.smartman.modules.auth.vo.AuthConfigVO; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RequestMapping({"blade-auth"}) @Api(value = "钉钉企微微应用三方登陆", tags = {"钉钉企微微应用三方登陆"}) @RestController /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/auth/endpoint/MicroAppAuthEndpoint.class */ public class MicroAppAuthEndpoint { private MicroAppAuthService microAppAuthService; public MicroAppAuthEndpoint(final MicroAppAuthService microAppAuthService) { this.microAppAuthService = microAppAuthService; } @GetMapping({"/oauth/app/config"}) @ApiLog("获取配置信息") @ApiOperation("获取配置信息") public R config(String source) { return R.data(this.microAppAuthService.getAuthConfig(source)); } @GetMapping({"/oauth/app/code-login"}) @ApiLog("钉钉微应用授权码登录") @ApiOperation("根据授权码登录") public R loginByCode(@RequestParam String code, @RequestParam(required = false) String state, @RequestParam String source) { TokenParameter tokenParameter = new TokenParameter(); tokenParameter.getArgs().set("code", code); tokenParameter.getArgs().set("source", source); tokenParameter.getArgs().set("state", state); return this.microAppAuthService.loginByCode(tokenParameter); } @GetMapping({"/oauth/app/login"}) @ApiLog("用户名密码登录") @ApiOperation("用户密码登录") public R loginByPassword(@RequestParam @ApiParam(value = "账号", required = true) String username, @RequestParam @ApiParam(value = "密码", required = true) String password, @RequestParam(required = false) @ApiParam("认证ID") String oauthId, @RequestParam(required = false) @ApiParam("三方登录标识") String source) { return this.microAppAuthService.loginByPassword(username, password, oauthId); } @GetMapping({"/oauth/app/wechat-enterprise-web/sign"}) @ApiLog("企业微信获取企业签名信息") @ApiOperation("企业微信获取企业签名信息") public R weChatSign(@RequestParam @ApiParam("当前网页的URL, 不包含#及其后面部分") String url, boolean isAgent) { return this.microAppAuthService.getWeChatSiginValue(url, isAgent); } @GetMapping({"/oauth/app/change-account"}) @ApiLog("切换员工和用户token") @ApiOperation("切换员工和用户token") public R changeAccount(@RequestParam @ApiParam(value = "账号", required = true) String userId, @RequestParam @ApiParam(value = "需要切换的账号类型", required = true) AccountType type) { return this.microAppAuthService.loginByToggleAccount(userId, type); } @GetMapping({"/oauth/app/refresh-token"}) @ApiLog("刷新token") @ApiOperation("刷新员工和账号token") public R refreshToken(@RequestParam @ApiParam("需要刷新的账号类型") AccountType accountType, @RequestParam @ApiParam("刷新token") String refreshToken) { return this.microAppAuthService.refreshToken(accountType, refreshToken); } }