一、系统介绍
本系统实现的功能:用户登录、员工信息的增删改查、导出Execl、计算器、记事本、信息排序。采用AES加密算法,数据库使用Mysql8.0.13,界面良好。
二、系统展示
1.登录页
2.主页面
3.添加员工信息
4.修改员工信息
5.计算器
6.记事本
7.导出Execl
三、系统实现
AccountDao.java
package com.sjsq.dao; import java.util.List; import com.sjsq.model.TbAccount; import com.sjsq.model.TbDept; import com.sjsq.model.TbPerson; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcTemplate; import com.sjsq.tools.JDBCUtils; public class AccountDao { private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource()); public static List<TbAccount> findAllAccount() { try { String sql = "select * from tb_account"; List<TbAccount> a = template.query(sql, new BeanPropertyRowMapper<TbAccount>(TbAccount.class)); return a; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static String findAccountMoneyById(int i) { try { String sql = "select * from tb_account where timecard_id=?"; TbAccount tbAccount = template.queryForObject(sql, new BeanPropertyRowMapper<TbAccount>(TbAccount.class), i); return tbAccount.getMoney(); } catch (DataAccessException e) { e.printStackTrace(); return null; } } }
DeptDao.java
package com.sjsq.dao; import java.util.List; import com.sjsq.model.TbDept; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcTemplate; import com.sjsq.tools.JDBCUtils; public class DeptDao { private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource()); public static TbDept findDeptById(int deptId) { String sql = "select * from tb_dept where id=?"; TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class), deptId); return dept; } public static List<TbDept> findAllDept() { try { String sql = "select * from tb_dept"; List<TbDept> tbDept = template.query(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class)); return tbDept; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static int findDeptIdByName(String item) { String sql = "select * from tb_dept where name=?"; TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class), item); return dept.getId(); } public static List<TbDept> findAllDeptExceptZero() { try { String sql = "select * from tb_dept where id<>0"; List<TbDept> tbDept = template.query(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class)); return tbDept; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static TbDept findDeptByName(String name) { try { String sql = "select * from tb_dept where name=?"; TbDept dept = template.queryForObject(sql, new BeanPropertyRowMapper<TbDept>(TbDept.class), name); return dept; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static void addDept(TbDept d2) { try { String sql = "insert into tb_dept(name) values (?)"; template.update(sql, d2.getName()); } catch (DataAccessException e) { e.printStackTrace(); } } public static void deleteDeptById(int id) { try { String sql = "delete from tb_dept where id=?"; template.update(sql, id); } catch (DataAccessException e) { e.printStackTrace(); } } public static void updateDept(int id, String input) { try { String sql = "update tb_dept set name = ? where id = ?"; template.update(sql, input, id); } catch (Exception e) { e.printStackTrace(); } } }
PersonDao.java
package com.sjsq.dao; import java.util.List; import com.sjsq.model.TbPerson; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcTemplate; import com.sjsq.tools.JDBCUtils; import com.sjsq.tools.PwEncryption; public class PersonDao { private static JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource()); public static TbPerson queryRecordByNum(String num) { try { String sql = "select * from tb_person where record_number=?"; TbPerson tbRecord = template.queryForObject(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), num); return tbRecord; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static List<TbPerson> findAllPerson() { try { String sql = "select * from tb_person"; List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class)); return tbPerson; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static List<TbPerson> likePersonByRecordNumber(String recordNumber) { try { String sql = "select * from tb_person where record_number like '%' ? '%'"; List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), recordNumber); return tbPerson; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static List<TbPerson> findPersonByDeptId(int i) { try { String sql = "select * from tb_person where dept_id=?"; List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), i); return tbPerson; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static TbPerson findPersonByRecordNumber(String recordNumber) { try { String sql = "select * from tb_person where record_number=?"; TbPerson tbPerson = template.queryForObject(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), recordNumber); return tbPerson; } catch (DataAccessException e) { System.out.println("查找员工为空数据"); e.printStackTrace(); return null; } } public static void updatePerson(TbPerson person) { try { String sql = "update tb_person set dept_id=?,duty_id=?,name=?,sex=?," + "birthday=?,photo=?,id_card=?,marriaged=?,native_place_id=?," + "party_member=?,school_age=?,specialty=?,foreign_language=?," + "grade=?,state=?,role_id=? where record_number=?"; template.update(sql, person.getDeptId(), person.getDutyId(), person.getName(), person.getSex(), person.getBirthday(), person.getPhoto(), person.getIdCard(), person.getMarriaged(), person.getNativePlaceId(), person.getPartyMember(), person.getSchoolAge(), person.getSpecialty(), person.getForeignLanguage(), person.getGrade(), person.getState(), person.getRoleId(), person.getRecordNumber()); } catch (Exception e) { e.printStackTrace(); } } public static void addPerson(TbPerson person) { try { String sql = "insert into tb_person(record_number,dept_id,duty_id,name,sex," + "birthday,photo,id_card,marriaged,native_place_id," + "party_member,school_age,specialty,foreign_language," + "grade,state,role_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; template.update(sql, person.getRecordNumber(), person.getDeptId(), person.getDutyId(), person.getName(), person.getSex(), person.getBirthday(), person.getPhoto(), person.getIdCard(), person.getMarriaged(), person.getNativePlaceId(), person.getPartyMember(), person.getSchoolAge(), person.getSpecialty(), person.getForeignLanguage(), person.getGrade(), person.getState(), person.getRoleId()); } catch (DataAccessException e) { e.printStackTrace(); } } public static void deletePersonByrecordNumber(String recordNumber) { try { String sql = "delete from tb_person where record_number=?"; template.update(sql, recordNumber); } catch (DataAccessException e) { e.printStackTrace(); } } public static TbPerson login(TbPerson person) { try { String sql = "select * from tb_person where record_number=? and password=?"; TbPerson tbPerson = template.queryForObject(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), person.getRecordNumber(), person.getPassword()); return tbPerson; } catch (DataAccessException e) { System.out.println("空结果数据访问异常"); e.printStackTrace(); return null; } } public static void updatePersonPassword(TbPerson person) { try { String sql = "update tb_person set password = ? where record_number= ?"; template.update(sql, person.getPassword(), person.getRecordNumber()); } catch (Exception e) { e.printStackTrace(); } } public static List<TbPerson> likePersonByName(String name) { try { String sql = "select * from tb_person where name like '%' ? '%'"; List<TbPerson> tbPerson = template.query(sql, new BeanPropertyRowMapper<TbPerson>(TbPerson.class), name); return tbPerson; } catch (DataAccessException e) { e.printStackTrace(); return null; } } public static void main(String args[]) { String userName = "T00001"; String password = "123456"; TbPerson person = new TbPerson(userName, PwEncryption.encrypt(password, "key")); login(person); } }