完成账号验证功能!
This commit is contained in:
		@@ -2,7 +2,7 @@
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2022-12-15 11:11:21
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @LastEditTime: 2022-12-16 15:25:23
 | 
			
		||||
 * @LastEditTime: 2022-12-16 21:38:32
 | 
			
		||||
 * @FilePath: \AdminSys\src\main\java\com\cpic\xim\web\controllers\account\P13AccountCheckController.java
 | 
			
		||||
 * @Description: P13账号验证用Controller。
 | 
			
		||||
 * 
 | 
			
		||||
@@ -12,13 +12,17 @@ package com.cpic.xim.web.controllers.account;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.nio.channels.IllegalSelectorException;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import javax.servlet.ServletContext;
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import javax.servlet.http.HttpSession;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.ResponseBody;
 | 
			
		||||
import com.cpic.xim.myutils.account.CpicXIMStaffInfo;
 | 
			
		||||
import com.cpic.xim.myutils.account.LdapAccountCheck;
 | 
			
		||||
 | 
			
		||||
@Controller
 | 
			
		||||
@RequestMapping( path = "/account")
 | 
			
		||||
@@ -38,6 +42,57 @@ public class P13AccountCheckController
 | 
			
		||||
        ServletContext context = request.getServletContext();
 | 
			
		||||
 | 
			
		||||
        // context.getAttribute( null );
 | 
			
		||||
        CpicXIMStaffInfo staff = null;
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            // 先根据用户输入的09工号或p13账号获得p13账号,确定账号存在
 | 
			
		||||
            staff = CpicXIMStaffInfo.getStaffInfo( param.getP13Account() );
 | 
			
		||||
        }
 | 
			
		||||
        catch ( SQLException error )
 | 
			
		||||
        {
 | 
			
		||||
            result.setMessage( "人员工号或P13账号不存在!" );
 | 
			
		||||
            result.setSuccess( false );
 | 
			
		||||
        }
 | 
			
		||||
        catch ( ClassNotFoundException error )
 | 
			
		||||
        {
 | 
			
		||||
            result.setMessage( "加载Oracle驱动失败!" );
 | 
			
		||||
            result.setSuccess( false );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 查询结果是null,说明工号或p13账号不存在,返回结果。
 | 
			
		||||
        if ( staff == null)
 | 
			
		||||
        {
 | 
			
		||||
            return result;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 判断一下p13是否存在,如果不存在就结束过程
 | 
			
		||||
        if ( staff.getP13UID().isEmpty() == true)
 | 
			
		||||
        {
 | 
			
		||||
            result.setMessage( "P13账号不存在,请联系信息技术部申请账号!" );
 | 
			
		||||
            result.setSuccess( false );
 | 
			
		||||
 | 
			
		||||
            return result;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 进行ldap验证
 | 
			
		||||
        boolean ldapCheckResult =
 | 
			
		||||
                LdapAccountCheck.ldapLogin( staff.getP13UID(), param.getPassword() );
 | 
			
		||||
 | 
			
		||||
        if ( ldapCheckResult == true)
 | 
			
		||||
        {
 | 
			
		||||
            result.setSuccess( true );
 | 
			
		||||
            result.setMessage( "验证成功!" );
 | 
			
		||||
 | 
			
		||||
            // 将获取到的人员信息保存到会话中
 | 
			
		||||
            HttpSession session = request.getSession();
 | 
			
		||||
 | 
			
		||||
            session.setAttribute( "staff_info", staff );
 | 
			
		||||
        } else
 | 
			
		||||
        {
 | 
			
		||||
            result.setSuccess( false );
 | 
			
		||||
            result.setMessage( "验证失败!" );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +1,2 @@
 | 
			
		||||
com\cpic\xim\myutils\account\CpicXIMStaffInfoTest.class
 | 
			
		||||
com\cpic\xim\myutils\account\LdapAccountCheckTest.class
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +1,2 @@
 | 
			
		||||
F:\练手代码\vue-learning\企业级管理系统\java\AdminSys\src\test\java\com\cpic\xim\myutils\account\CpicXIMStaffInfoTest.java
 | 
			
		||||
F:\练手代码\vue-learning\企业级管理系统\java\AdminSys\src\test\java\com\cpic\xim\myutils\account\LdapAccountCheckTest.java
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user