实现前端对学号和用户名的异步判断,核心技术为axios

This commit is contained in:
F嘉阳
2018-02-24 16:00:23 +08:00
parent e61800efb9
commit 99aca7d6c8
5 changed files with 128 additions and 10 deletions

View File

@@ -1,15 +1,20 @@
package com.fjy.spring.controller;
import com.fjy.spring.domain.TbStudentlist;
import com.fjy.spring.domain.TbUser;
import com.fjy.spring.enums.ResultEnum;
import com.fjy.spring.exception.UserException;
import com.fjy.spring.properties.ServerProperties;
import com.fjy.spring.service.StudentService;
import com.fjy.spring.service.UserService;
import com.fjy.spring.untils.CodingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -22,6 +27,9 @@ public class RegisterController {
@Autowired
private UserService userService;
@Autowired
private StudentService studentService;
@Autowired
private ServerProperties serverProperties;
@@ -45,4 +53,23 @@ public class RegisterController {
throw new UserException(ResultEnum.UNKOWN_ERROR);
}
@GetMapping("/CheckStudentNo")
@ResponseBody
public boolean doCheckStudentNo(@RequestParam(value = "studentno") String studentno){
TbStudentlist studentlist = studentService.findStudentByNo(studentno);
if (studentlist!=null)
return true;
return false;
}
@GetMapping("/CheckStudent")
@ResponseBody
public boolean doCheckStudent(@RequestParam(value = "studentno") String studentno,
@RequestParam(value = "realname") String realname){
TbStudentlist studentlist = studentService.findByColstudentnoAndColrealname(studentno,realname);
if (studentlist!=null)
return true;
return false;
}
}

View File

@@ -0,0 +1,11 @@
package com.fjy.spring.repository;
import com.fjy.spring.domain.TbStudentlist;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TbStudentListRepository extends JpaRepository<TbStudentlist,Integer> {
public TbStudentlist findByColstudentno(String colstudentno);
public TbStudentlist findByColstudentnoAndColrealname(String colstudentno,String colrealname);
}

View File

@@ -1,7 +1,9 @@
package com.fjy.spring.service;
import com.fjy.spring.domain.TbStudent;
import com.fjy.spring.domain.TbStudentlist;
import com.fjy.spring.domain.TbUser;
import com.fjy.spring.repository.TbStudentListRepository;
import com.fjy.spring.repository.TbStudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -13,4 +15,15 @@ public class StudentService {
@Autowired
private TbStudentRepository tbStudentRepository;
@Autowired
private TbStudentListRepository tbStudentListRepository;
public TbStudentlist findStudentByNo(String studentno){
return tbStudentListRepository.findByColstudentno(studentno);
}
public TbStudentlist findByColstudentnoAndColrealname(String studentno,String realname){
return tbStudentListRepository.findByColstudentnoAndColrealname(studentno,realname);
}
}