springboot+mybatis信息查询系统:登录验证,条件查询

本文介绍了一个使用SpringBoot和Mybatis构建的信息查询系统,涉及登录验证和条件查询功能。通过分析项目结构,包括Controller、Service、Dao、Model及配置文件,展示了如何在实际操作中整合这两个框架。
摘要由CSDN通过智能技术生成

 项目效果图

 

 

StudentController.java 

package cn.wmyskxz.controller;

import cn.wmyskxz.entity.Student;
import cn.wmyskxz.service.StudentService;
import cn.wmyskxz.util.Page;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Student 控制器
 *
 * @author:z84108918
 */
@Controller
public class StudentController {

    @Autowired
    private StudentService studentService;
    
	@RequestMapping(value = "/queryByCon", method = RequestMethod.POST)
	@ResponseBody
    public  List<Student> queryByCon(@RequestBody Student student) 
	 {
		
		 List<Student> stu = new ArrayList<Student>();
    	 stu = studentService.findOrdersByCon(student.getName(), student.getSex(), student.getGrade(), student.getClass_name());
		 return stu;
	 }
    
}

 UserController.java

package cn.wmyskxz.controller;


import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.wmyskxz.entity.User;
import cn.wmyskxz.service.StudentService;
import cn.wmyskxz.service.UserService;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;



@RestController

public class UserController {
	
	@Autowired
    private UserService userService;

	 @RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	 @ResponseBody
	 public  boolean login(@RequestBody User user) 
	 {
		

		 return userService.checkLogin(user.getUserName(), user.getPassword());
		
	 }
}
   

 StudentDao.java

package cn.wmyskxz.dao;

import cn.wmyskxz.entity.Student;

import java.util.List;

import org.apache.ibatis.annotations.Param;

public interface StudentDao
{
    int getTotal();
    
    void addStudent(Student student);
    
    void deleteStudent(int id);
    
    void updateStudent(Student student);
    
    Student getStudent(int id);
    
    void getStudentByFuzzyQuery(Student student);
    
    List<Student> list(@Param("start") int start, @Param("count") int count);
    
    List<Student> findOrdersByCon(@Param("name") String name, @Param("sex") String sex, @Param("grade") int grade,
            @Param("class_name") int class_name);
    // List<Student> findOrdersByCon(Student student);
}

 

UserDao.java

 

package cn.wmyskxz.dao;

import java.sql.SQLException;

import org.apache.ibatis.annotations.Param;

import cn.wmyskxz.entity.User;

public interface UserDao {
	
    int insert(User user) throws SQLException;
    
    User selectByName(@Param("userName") String userName) throws SQLException;
		
}

Student.java 

package cn.wmyskxz.entity;


/**
 * Student 实体类
 *
 * @author: 
 */
public class Student {

    private int id;
    private int student_id;
    private String name;
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值