IDEA+Java+Servlet,一举拿下腾讯美团滴滴offer

sb.append(" where t1.userName like ‘%" + s_dormManager.getUserName() + "%’");

}

PreparedStatement pstmt = con.prepareStatement(sb.toString());

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

return rs.getInt(“total”);

} else {

return 0;

}

}

public DormManager dormManagerShow(Connection con, String dormManagerId) throws Exception {

String sql = “select * from t_dormManager t1 where t1.dormManId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, dormManagerId);

ResultSet rs = pstmt.executeQuery();

DormManager dormManager = new DormManager();

if (rs.next()) {

dormManager.setDormManagerId(rs.getInt(“dormManId”));

dormManager.setDormBuildId(rs.getInt(“dormBuildId”));

dormManager.setName(rs.getString(“name”));

dormManager.setSex(rs.getString(“sex”));

dormManager.setUserName(rs.getString(“userName”));

dormManager.setTel(rs.getString(“tel”));

dormManager.setPassword(rs.getString(“password”));

}

return dormManager;

}

public int dormManagerAdd(Connection con, DormManager dormManager) throws Exception {

String sql = “insert into t_dormManager values(null,?,?,null,?,?,?)”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, dormManager.getUserName());

pstmt.setString(2, dormManager.getPassword());

pstmt.setString(3, dormManager.getName());

pstmt.setString(4, dormManager.getSex());

pstmt.setString(5, dormManager.getTel());

return pstmt.executeUpdate();

}

public int dormManagerDelete(Connection con, String dormManagerId) throws Exception {

String sql = “delete from t_dormManager where dormManId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, dormManagerId);

return pstmt.executeUpdate();

}

public int dormManagerUpdate(Connection con, DormManager dormManager) throws Exception {

String sql = “update t_dormManager set userName=?,password=?,name=?,sex=?,tel=? where dormManId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, dormManager.getUserName());

pstmt.setString(2, dormManager.getPassword());

pstmt.setString(3, dormManager.getName());

pstmt.setString(4, dormManager.getSex());

pstmt.setString(5, dormManager.getTel());

pstmt.setInt(6, dormManager.getDormManagerId());

return pstmt.executeUpdate();

}

public boolean haveManagerByUser(Connection con, String userName) throws Exception {

String sql = “select * from t_dormmanager t1 where t1.userName=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, userName);

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

return true;

}

return false;

}

}

RecordDao


package com.lero.dao;

import com.lero.model.DormBuild;

import com.lero.model.Record;

import com.lero.util.StringUtil;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.ArrayList;

import java.util.List;

public class RecordDao {

public List recordList(Connection con, Record s_record) throws Exception {

List recordList = new ArrayList();

StringBuffer sb = new StringBuffer(“select * from t_record t1”);

if (StringUtil.isNotEmpty(s_record.getStudentNumber())) {

sb.append(" and t1.studentNumber like ‘%" + s_record.getStudentNumber() + "%’");

} else if (StringUtil.isNotEmpty(s_record.getStudentName())) {

sb.append(" and t1.studentName like ‘%" + s_record.getStudentName() + "%’");

}

if (s_record.getDormBuildId() != 0) {

sb.append(" and t1.dormBuildId=" + s_record.getDormBuildId());

}

if (StringUtil.isNotEmpty(s_record.getDate())) {

sb.append(" and t1.date=" + s_record.getDate());

}

if (StringUtil.isNotEmpty(s_record.getStartDate())) {

sb.append(" and TO_DAYS(t1.date)>=TO_DAYS(‘" + s_record.getStartDate() + "’)");

}

if (StringUtil.isNotEmpty(s_record.getEndDate())) {

sb.append(" and TO_DAYS(t1.date)<=TO_DAYS(‘" + s_record.getEndDate() + "’)");

}

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

Record record = new Record();

record.setRecordId(rs.getInt(“recordId”));

record.setStudentNumber(rs.getString(“studentNumber”));

record.setStudentName(rs.getString(“studentName”));

int dormBuildId = rs.getInt(“dormBuildId”);

record.setDormBuildId(dormBuildId);

record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

record.setDormName(rs.getString(“dormName”));

record.setDate(rs.getString(“date”));

record.setDetail(rs.getString(“detail”));

recordList.add(record);

}

return recordList;

}

public List recordListWithBuild(Connection con, Record s_record, int buildId) throws Exception {

List recordList = new ArrayList();

StringBuffer sb = new StringBuffer(“select * from t_record t1”);

if (StringUtil.isNotEmpty(s_record.getStudentNumber())) {

sb.append(" and t1.studentNumber like ‘%" + s_record.getStudentNumber() + "%’");

} else if (StringUtil.isNotEmpty(s_record.getStudentName())) {

sb.append(" and t1.studentName like ‘%" + s_record.getStudentName() + "%’");

}

sb.append(" and t1.dormBuildId=" + buildId);

if (StringUtil.isNotEmpty(s_record.getStartDate())) {

sb.append(" and TO_DAYS(t1.date)>=TO_DAYS(‘" + s_record.getStartDate() + "’)");

}

if (StringUtil.isNotEmpty(s_record.getEndDate())) {

sb.append(" and TO_DAYS(t1.date)<=TO_DAYS(‘" + s_record.getEndDate() + "’)");

}

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

Record record = new Record();

record.setRecordId(rs.getInt(“recordId”));

record.setStudentNumber(rs.getString(“studentNumber”));

record.setStudentName(rs.getString(“studentName”));

int dormBuildId = rs.getInt(“dormBuildId”);

record.setDormBuildId(dormBuildId);

record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

record.setDormName(rs.getString(“dormName”));

record.setDate(rs.getString(“date”));

record.setDetail(rs.getString(“detail”));

recordList.add(record);

}

return recordList;

}

public List recordListWithNumber(Connection con, Record s_record, String studentNumber) throws Exception {

List recordList = new ArrayList();

StringBuffer sb = new StringBuffer(“select * from t_record t1”);

if (StringUtil.isNotEmpty(studentNumber)) {

sb.append(" and t1.studentNumber =" + studentNumber);

}

if (StringUtil.isNotEmpty(s_record.getStartDate())) {

sb.append(" and TO_DAYS(t1.date)>=TO_DAYS(‘" + s_record.getStartDate() + "’)");

}

if (StringUtil.isNotEmpty(s_record.getEndDate())) {

sb.append(" and TO_DAYS(t1.date)<=TO_DAYS(‘" + s_record.getEndDate() + "’)");

}

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

Record record = new Record();

record.setRecordId(rs.getInt(“recordId”));

record.setStudentNumber(rs.getString(“studentNumber”));

record.setStudentName(rs.getString(“studentName”));

int dormBuildId = rs.getInt(“dormBuildId”);

record.setDormBuildId(dormBuildId);

record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

record.setDormName(rs.getString(“dormName”));

record.setDate(rs.getString(“date”));

record.setDetail(rs.getString(“detail”));

recordList.add(record);

}

return recordList;

}

public List dormBuildList(Connection con) throws Exception {

List dormBuildList = new ArrayList();

String sql = “select * from t_dormBuild”;

PreparedStatement pstmt = con.prepareStatement(sql);

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

DormBuild dormBuild = new DormBuild();

dormBuild.setDormBuildId(rs.getInt(“dormBuildId”));

dormBuild.setDormBuildName(rs.getString(“dormBuildName”));

dormBuild.setDetail(rs.getString(“dormBuildDetail”));

dormBuildList.add(dormBuild);

}

return dormBuildList;

}

//

// public int studentCount(Connection con, Student s_student)throws Exception {

// StringBuffer sb = new StringBuffer(“select count(*) as total from t_student t1”);

// if(StringUtil.isNotEmpty(s_student.getName())) {

// sb.append(" and t1.name like ‘%“+s_student.getName()+”%’");

// } else if(StringUtil.isNotEmpty(s_student.getStuNumber())) {

// sb.append(" and t1.stuNum like ‘%“+s_student.getStuNumber()+”%’");

// } else if(StringUtil.isNotEmpty(s_student.getDormName())) {

// sb.append(" and t1.dormName like ‘%“+s_student.getDormName()+”%’");

// }

// if(s_student.getDormBuildId()!=0) {

// sb.append(" and t1.dormBuildId="+s_student.getDormBuildId());

// }

// PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

// ResultSet rs = pstmt.executeQuery();

// if(rs.next()) {

// return rs.getInt(“total”);

// } else {

// return 0;

// }

// }

public Record recordShow(Connection con, String recordId) throws Exception {

String sql = “select * from t_record t1 where t1.recordId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, recordId);

ResultSet rs = pstmt.executeQuery();

Record record = new Record();

if (rs.next()) {

record.setRecordId(rs.getInt(“recordId”));

record.setStudentNumber(rs.getString(“studentNumber”));

record.setStudentName(rs.getString(“studentName”));

int dormBuildId = rs.getInt(“dormBuildId”);

record.setDormBuildId(dormBuildId);

record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

record.setDormName(rs.getString(“dormName”));

record.setDate(rs.getString(“date”));

record.setDetail(rs.getString(“detail”));

}

return record;

}

public int recordAdd(Connection con, Record record) throws Exception {

String sql = “insert into t_record values(null,?,?,?,?,?,?)”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, record.getStudentNumber());

pstmt.setString(2, record.getStudentName());

pstmt.setInt(3, record.getDormBuildId());

pstmt.setString(4, record.getDormName());

pstmt.setString(5, record.getDate());

pstmt.setString(6, record.getDetail());

return pstmt.executeUpdate();

}

public int recordDelete(Connection con, String recordId) throws Exception {

String sql = “delete from t_record where recordId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, recordId);

return pstmt.executeUpdate();

}

public int recordUpdate(Connection con, Record record) throws Exception {

String sql = “update t_record set studentNumber=?,studentName=?,dormBuildId=?,dormName=?,detail=? where recordId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, record.getStudentNumber());

pstmt.setString(2, record.getStudentName());

pstmt.setInt(3, record.getDormBuildId());

pstmt.setString(4, record.getDormName());

pstmt.setString(5, record.getDetail());

pstmt.setInt(6, record.getRecordId());

return pstmt.executeUpdate();

}

}

StudentDao


package com.lero.dao;

import com.lero.model.DormBuild;

import com.lero.model.Student;

import com.lero.util.StringUtil;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.ArrayList;

import java.util.List;

public class StudentDao {

// public List studentList(Connection con, PageBean pageBean, Student s_student)throws Exception {

// List studentList = new ArrayList();

// StringBuffer sb = new StringBuffer(“select * from t_student t1”);

// if(StringUtil.isNotEmpty(s_student.getName())) {

// sb.append(" and t1.name like ‘%“+s_student.getName()+”%’");

// } else if(StringUtil.isNotEmpty(s_student.getStuNumber())) {

// sb.append(" and t1.stuNum like ‘%“+s_student.getStuNumber()+”%’");

// } else if(StringUtil.isNotEmpty(s_student.getDormName())) {

// sb.append(" and t1.dormName like ‘%“+s_student.getDormName()+”%’");

// }

// if(s_student.getDormBuildId()!=0) {

// sb.append(" and t1.dormBuildId="+s_student.getDormBuildId());

// }

// if(pageBean != null) {

// sb.append(" limit “+pageBean.getStart()+”,"+pageBean.getPageSize());

// }

// PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

// ResultSet rs = pstmt.executeQuery();

// while(rs.next()) {

// Student student=new Student();

// student.setStudentId(rs.getInt(“studentId”));

// int dormBuildId = rs.getInt(“dormBuildId”);

// student.setDormBuildId(dormBuildId);

// student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

// student.setDormName(rs.getString(“dormName”));

// student.setName(rs.getString(“name”));

// student.setSex(rs.getString(“sex”));

// student.setStuNumber(rs.getString(“stuNum”));

// student.setTel(rs.getString(“tel”));

// student.setPassword(rs.getString(“password”));

// studentList.add(student);

// }

// return studentList;

// }

public static Student getNameById(Connection con, String studentNumber, int dormBuildId) throws Exception {

String sql = “select * from t_student t1 where t1.stuNum=? and t1.dormBuildId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, studentNumber);

pstmt.setInt(2, dormBuildId);

ResultSet rs = pstmt.executeQuery();

Student student = new Student();

if (rs.next()) {

student.setName(rs.getString(“name”));

student.setDormBuildId(rs.getInt(“dormBuildId”));

student.setDormName(rs.getString(“dormName”));

}

return student;

}

public List studentList(Connection con, Student s_student) throws Exception {

List studentList = new ArrayList();

StringBuffer sb = new StringBuffer(“select * from t_student t1”);

if (StringUtil.isNotEmpty(s_student.getName())) {

sb.append(" and t1.name like ‘%" + s_student.getName() + "%’");

} else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {

sb.append(" and t1.stuNum like ‘%" + s_student.getStuNumber() + "%’");

} else if (StringUtil.isNotEmpty(s_student.getDormName())) {

sb.append(" and t1.dormName like ‘%" + s_student.getDormName() + "%’");

}

if (s_student.getDormBuildId() != 0) {

sb.append(" and t1.dormBuildId=" + s_student.getDormBuildId());

}

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

Student student = new Student();

student.setStudentId(rs.getInt(“studentId”));

int dormBuildId = rs.getInt(“dormBuildId”);

student.setDormBuildId(dormBuildId);

student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

student.setDormName(rs.getString(“dormName”));

student.setName(rs.getString(“name”));

student.setSex(rs.getString(“sex”));

student.setStuNumber(rs.getString(“stuNum”));

student.setTel(rs.getString(“tel”));

student.setPassword(rs.getString(“password”));

studentList.add(student);

}

return studentList;

}

public boolean haveNameByNumber(Connection con, String studentNumber) throws Exception {

String sql = “select * from t_student t1 where t1.stuNum=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, studentNumber);

ResultSet rs = pstmt.executeQuery();

Student student = new Student();

if (rs.next()) {

student.setName(rs.getString(“name”));

student.setDormBuildId(rs.getInt(“dormBuildId”));

student.setDormName(rs.getString(“dormName”));

return true;

}

return false;

}

public List studentListWithBuild(Connection con, Student s_student, int buildId) throws Exception {

List studentList = new ArrayList();

StringBuffer sb = new StringBuffer(“select * from t_student t1”);

if (StringUtil.isNotEmpty(s_student.getName())) {

sb.append(" and t1.name like ‘%" + s_student.getName() + "%’");

} else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {

sb.append(" and t1.stuNum like ‘%" + s_student.getStuNumber() + "%’");

} else if (StringUtil.isNotEmpty(s_student.getDormName())) {

sb.append(" and t1.dormName like ‘%" + s_student.getDormName() + "%’");

}

sb.append(" and t1.dormBuildId=" + buildId);

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

Student student = new Student();

student.setStudentId(rs.getInt(“studentId”));

int dormBuildId = rs.getInt(“dormBuildId”);

student.setDormBuildId(dormBuildId);

student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

student.setDormName(rs.getString(“dormName”));

student.setName(rs.getString(“name”));

student.setSex(rs.getString(“sex”));

student.setStuNumber(rs.getString(“stuNum”));

student.setTel(rs.getString(“tel”));

student.setPassword(rs.getString(“password”));

studentList.add(student);

}

return studentList;

}

public List dormBuildList(Connection con) throws Exception {

List dormBuildList = new ArrayList();

String sql = “select * from t_dormBuild”;

PreparedStatement pstmt = con.prepareStatement(sql);

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {

DormBuild dormBuild = new DormBuild();

dormBuild.setDormBuildId(rs.getInt(“dormBuildId”));

dormBuild.setDormBuildName(rs.getString(“dormBuildName”));

dormBuild.setDetail(rs.getString(“dormBuildDetail”));

dormBuildList.add(dormBuild);

}

return dormBuildList;

}

public int studentCount(Connection con, Student s_student) throws Exception {

StringBuffer sb = new StringBuffer(“select count(*) as total from t_student t1”);

if (StringUtil.isNotEmpty(s_student.getName())) {

sb.append(" and t1.name like ‘%" + s_student.getName() + "%’");

} else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {

sb.append(" and t1.stuNum like ‘%" + s_student.getStuNumber() + "%’");

} else if (StringUtil.isNotEmpty(s_student.getDormName())) {

sb.append(" and t1.dormName like ‘%" + s_student.getDormName() + "%’");

}

if (s_student.getDormBuildId() != 0) {

sb.append(" and t1.dormBuildId=" + s_student.getDormBuildId());

}

PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst(“and”, “where”));

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

return rs.getInt(“total”);

} else {

return 0;

}

}

public Student studentShow(Connection con, String studentId) throws Exception {

String sql = “select * from t_student t1 where t1.studentId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, studentId);

ResultSet rs = pstmt.executeQuery();

Student student = new Student();

if (rs.next()) {

student.setStudentId(rs.getInt(“studentId”));

int dormBuildId = rs.getInt(“dormBuildId”);

student.setDormBuildId(dormBuildId);

student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

student.setDormName(rs.getString(“dormName”));

student.setName(rs.getString(“name”));

student.setSex(rs.getString(“sex”));

student.setStuNumber(rs.getString(“stuNum”));

student.setTel(rs.getString(“tel”));

student.setPassword(rs.getString(“password”));

}

return student;

}

public int studentAdd(Connection con, Student student) throws Exception {

String sql = “insert into t_student values(null,?,?,?,?,?,?,?)”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, student.getStuNumber());

pstmt.setString(2, student.getPassword());

pstmt.setString(3, student.getName());

pstmt.setInt(4, student.getDormBuildId());

pstmt.setString(5, student.getDormName());

pstmt.setString(6, student.getSex());

pstmt.setString(7, student.getTel());

return pstmt.executeUpdate();

}

public int studentDelete(Connection con, String studentId) throws Exception {

String sql = “delete from t_student where studentId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, studentId);

return pstmt.executeUpdate();

}

public int studentUpdate(Connection con, Student student) throws Exception {

String sql = “update t_student set stuNum=?,password=?,name=?,dormBuildId=?,dormName=?,sex=?,tel=? where studentId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, student.getStuNumber());

pstmt.setString(2, student.getPassword());

pstmt.setString(3, student.getName());

pstmt.setInt(4, student.getDormBuildId());

pstmt.setString(5, student.getDormName());

pstmt.setString(6, student.getSex());

pstmt.setString(7, student.getTel());

pstmt.setInt(8, student.getStudentId());

return pstmt.executeUpdate();

}

}

UserDao


package com.lero.dao;

import com.lero.model.Admin;

import com.lero.model.DormManager;

import com.lero.model.Student;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

public class UserDao {

public Admin Login(Connection con, Admin admin) throws Exception {

Admin resultAdmin = null;

String sql = “select * from t_admin where userName=? and password=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, admin.getUserName());

pstmt.setString(2, admin.getPassword());

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

resultAdmin = new Admin();

resultAdmin.setAdminId(rs.getInt(“adminId”));

resultAdmin.setUserName(rs.getString(“userName”));

resultAdmin.setPassword(rs.getString(“password”));

resultAdmin.setName(rs.getString(“name”));

resultAdmin.setSex(rs.getString(“sex”));

resultAdmin.setTel(rs.getString(“tel”));

}

return resultAdmin;

}

public DormManager Login(Connection con, DormManager dormManager) throws Exception {

DormManager resultDormManager = null;

String sql = “select * from t_dormmanager where userName=? and password=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, dormManager.getUserName());

pstmt.setString(2, dormManager.getPassword());

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

resultDormManager = new DormManager();

resultDormManager.setDormManagerId(rs.getInt(“dormManId”));

resultDormManager.setUserName(rs.getString(“userName”));

resultDormManager.setPassword(rs.getString(“password”));

resultDormManager.setDormBuildId(rs.getInt(“dormBuildId”));

resultDormManager.setName(rs.getString(“name”));

resultDormManager.setSex(rs.getString(“sex”));

resultDormManager.setTel(rs.getString(“tel”));

}

return resultDormManager;

}

public Student Login(Connection con, Student student) throws Exception {

Student resultStudent = null;

String sql = “select * from t_student where stuNum=? and password=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, student.getStuNumber());

pstmt.setString(2, student.getPassword());

ResultSet rs = pstmt.executeQuery();

if (rs.next()) {

resultStudent = new Student();

resultStudent.setStudentId(rs.getInt(“studentId”));

resultStudent.setStuNumber(rs.getString(“stuNum”));

resultStudent.setPassword(rs.getString(“password”));

int dormBuildId = rs.getInt(“dormBuildId”);

resultStudent.setDormBuildId(dormBuildId);

resultStudent.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));

resultStudent.setDormName(rs.getString(“dormName”));

resultStudent.setName(rs.getString(“name”));

resultStudent.setSex(rs.getString(“sex”));

resultStudent.setTel(rs.getString(“tel”));

}

return resultStudent;

}

public int adminUpdate(Connection con, int adminId, String password) throws Exception {

String sql = “update t_admin set password=? where adminId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, password);

pstmt.setInt(2, adminId);

return pstmt.executeUpdate();

}

public int managerUpdate(Connection con, int managerId, String password) throws Exception {

String sql = “update t_dormmanager set password=? where dormManId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, password);

pstmt.setInt(2, managerId);

return pstmt.executeUpdate();

}

public int studentUpdate(Connection con, int studentId, String password) throws Exception {

String sql = “update t_student set password=? where studentId=?”;

PreparedStatement pstmt = con.prepareStatement(sql);

pstmt.setString(1, password);

pstmt.setInt(2, studentId);

return pstmt.executeUpdate();

}

}

PropertiesUtil


package com.lero.util;

import java.io.IOException;

import java.io.InputStream;

import java.util.Properties;

public class PropertiesUtil {

public static String getValue(String key) {

Properties prop = new Properties();

InputStream in = new PropertiesUtil().getClass().getResourceAsStream(“/dorm.properties”);

try {

prop.load(in);

} catch (IOException e) {

e.printStackTrace();

}

return (String) prop.get(key);

}

}

login.jsp


<%@ page language=“java” contentType=“text/html; charset=utf-8”

pageEncoding=“utf-8” %>

<%@ page import=“com.lero.model.Admin” %>

<%@ page import=“com.lero.model.DormManager” %>

<%@ page import=“com.lero.model.Student” %>

<%

if (request.getAttribute(“user”) == null) {

String userName = null;

String password = null;

String userType = null;

String remember = null;

Cookie[] cookies = request.getCookies();

for (int i = 0; cookies != null && i < cookies.length; i++) {

if (cookies[i].getName().equals(“dormuser”)) {

userName = cookies[i].getValue().split(“-”)[0];

password = cookies[i].getValue().split(“-”)[1];

userType = cookies[i].getValue().split(“-”)[2];

remember = cookies[i].getValue().split(“-”)[3];

}

}

if (userName == null) {

userName = “”;

}

if (password == null) {

password = “”;

}

if (userType == null) {

userType = “”;

} else if (“admin”.equals(userType)) {

pageContext.setAttribute(“user”, new Admin(userName, password));

pageContext.setAttribute(“userType”, 1);

} else if (“dormManager”.equals(userType)) {

pageContext.setAttribute(“user”, new DormManager(userName, password));

pageContext.setAttribute(“userType”, 2);

} else if (“student”.equals(userType)) {

pageContext.setAttribute(“user”, new Student(userName, password));

pageContext.setAttribute(“userType”, 3);

}

if (“yes”.equals(remember)) {

pageContext.setAttribute(“remember”, 1);

}

}

%>

宿舍管理系统登录

<input id=“userName” name=“userName” value=“${user.userName }” type=“text” class=“input-block-level”

placeholder=“账号”>

<input id=“password” name=“password” value=“${user.password }” type=“password” class=“input-block-level”

placeholder=“密码”>

系统管理员

<input id=“dormManager” type=“radio” name=“userType” value=“dormManager” ${userType==2?‘checked’:‘’} />

宿舍管理员

<input id=“student” type=“radio” name=“userType” value=“student” ${userType==3?‘checked’:‘’}/> 学生

<input id=“remember” name=“remember” type=“checkbox” value=“remember-me” ${remember==1?‘checked’:‘’}>记住我

     ${error }

登录

    

重置

版权所有2021

mainAdmin.jsp


<%@ page language=“java” contentType=“text/html; charset=utf-8”

pageEncoding=“utf-8” %>

宿舍管理系统

rel=“stylesheet” media=“screen”>

href=“http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstra.css”>

color=“white” size=“6”>宿舍管理系统

当前用户:  ${currentUser.userName }
  • 首页
  • 宿舍管理员管理
  • 学生管理
  • 宿舍楼管理
  • 缺勤记录
  • 修改密码
  • 退出系统
  • <jsp:include page=“${mainPage==null?‘admin/blank.jsp’:mainPage}”></jsp:include>

    自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

    深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

    因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
    img
    img
    img
    img
    img
    img

    既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

    由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

    如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
    img

    最后

    基础知识是前端一面必问的,如果你在基础知识这一块翻车了,就算你框架玩的再6,webpack、git、node学习的再好也无济于事,因为对方就不会再给你展示的机会,千万不要因为基础错过了自己心怡的公司。前端的基础知识杂且多,并不是理解就ok了,有些是真的要去记。当然了我们是牛x的前端工程师,每天像背英语单词一样去背知识点就没必要了,只要平时工作中多注意总结,面试前端刷下题目就可以了。

    lor=“red”>${currentUser.userName }

  • 首页
  • 宿舍管理员管理
  • 学生管理
  • 宿舍楼管理
  • 缺勤记录
  • 修改密码
  • 退出系统
  • <jsp:include page=“${mainPage==null?‘admin/blank.jsp’:mainPage}”></jsp:include>

    自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

    深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

    因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
    [外链图片转存中…(img-waMOqBF7-1711742694429)]
    [外链图片转存中…(img-rcIeLfEn-1711742694430)]
    [外链图片转存中…(img-AK0IWFRg-1711742694431)]
    [外链图片转存中…(img-HgMzylFL-1711742694431)]
    [外链图片转存中…(img-d0dHUrVt-1711742694431)]
    [外链图片转存中…(img-GYzvU2RE-1711742694432)]

    既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

    由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

    如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注前端)
    [外链图片转存中…(img-u6e4skCq-1711742694432)]

    最后

    基础知识是前端一面必问的,如果你在基础知识这一块翻车了,就算你框架玩的再6,webpack、git、node学习的再好也无济于事,因为对方就不会再给你展示的机会,千万不要因为基础错过了自己心怡的公司。前端的基础知识杂且多,并不是理解就ok了,有些是真的要去记。当然了我们是牛x的前端工程师,每天像背英语单词一样去背知识点就没必要了,只要平时工作中多注意总结,面试前端刷下题目就可以了。

    CodeChina开源项目:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

  • 20
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值