|
|
|
package com.epmet.controller;
|
|
|
|
|
|
|
|
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService;
|
|
|
|
import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO;
|
|
|
|
import com.epmet.commons.tools.utils.Result;
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
|
|
import com.epmet.dto.form.SsoLoginFormDTO;
|
|
|
|
import com.epmet.dto.result.SsoLoginResultDTO;
|
|
|
|
import com.epmet.service.SsoService;
|
|
|
|
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.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author zxc
|
|
|
|
* @DateTime 2021/1/18 下午4:33
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("sso")
|
|
|
|
public class SsoController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private SsoService ssoService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private JcetApiService jcetApiService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Description 0、入口:得到token
|
|
|
|
* @Param formDTO
|
|
|
|
* @author zxc
|
|
|
|
* @date 2021/1/18 下午4:59
|
|
|
|
*/
|
|
|
|
@PostMapping("resi/login")
|
|
|
|
public Result<SsoLoginResultDTO> ssoLogin(@RequestBody SsoLoginFormDTO formDTO){
|
|
|
|
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class);
|
|
|
|
return new Result<SsoLoginResultDTO>().ok(ssoService.ssoLogin(formDTO));
|
|
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("testlogin")
|
|
|
|
public Result<UserInfoResultDTO> testssoLogin(){
|
|
|
|
UserInfoResultDTO userInfoByTicket = null;
|
|
|
|
try {
|
|
|
|
userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui");
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return new Result<UserInfoResultDTO>().ok(userInfoByTicket);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|