ludc
2023-09-25 3128b4a7241e675d955e25c83ee09faf7b07babc
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/PasswordFreeLoginController.java
@@ -5,12 +5,21 @@
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.view.RedirectView;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import static com.vci.ubcs.starter.util.AESUtils.aesDecrypt;
import static com.vci.ubcs.starter.util.AESUtils.aesEncrypt;
@@ -24,6 +33,12 @@
@Api(value = "免密登录接口", tags = "免密登录接口")
@Slf4j
public class PasswordFreeLoginController {
   @Value("${password-free.client-id:a104c4fd2f0e4958}")
   private String clientId;//应用ID
   @Value("${password-free.secret-key:9fbd170bd83eb869}")
   private String secretKey;//应用秘钥
   @Resource
   private IPasswordFreeLoginService passwordFreeLoginService;
@@ -41,21 +56,19 @@
   /**
    * 单点登录
    * @param request
    * @param empCode
    * @return
    * @throws Exception
    */
   @GetMapping("/ssoLogin")
   public ModelAndView oaSsoLogin(HttpServletRequest request, ModelAndView model){
   @PostMapping("/ssoLogin")
   public String oaSsoLogin(String empCode){
      String token;
      try {
         token = passwordFreeLoginService.ssoFreeLogin(request);
         token = passwordFreeLoginService.ssoFreeLogin(empCode);
      }catch (Exception e){
         throw new ServiceException("单点登录获取token失败:"+e.getMessage());
      }
      model.addObject("token",token);
      model.setViewName("sso");
      return model;
      return token;
   }
}