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.class),
i);
return tbAccount.getMoney();
} catch (DataAccessException e) {
e.printStackTrace();
return null;
}
}
}
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.class), deptId);
return dept;
}
public static List findAllDept() {
try {
String sql = “select * from tb_dept”;
List tbDept = template.query(sql, new BeanPropertyRowMapper(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.class), item);
return dept.getId();
}
public static List findAllDeptExceptZero() {
try {
String sql = “select * from tb_dept where id<>0”;
List tbDept = template.query(sql, new BeanPropertyRowMapper(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.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();
}
}
}
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.class), num);
return tbRecord;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
}
}
public static List findAllPerson() {
try {
String sql = “select * from tb_person”;
List tbPerson = template.query(sql, new BeanPropertyRowMapper(TbPerson.class));
return tbPerson;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
}
}
public static List likePersonByRecordNumber(String recordNumber) {
try {
String sql = “select * from tb_person where record_number like ‘%’ ? ‘%’”;
List tbPerson = template.query(sql, new BeanPropertyRowMapper(TbPerson.class),
recordNumber);
return tbPerson;
} catch (DataAccessException e) {
e.printStackTrace();
return null;
}
}
public static List findPersonByDeptId(int i) {
try {
String sql = “select * from tb_person where dept_id=?”;
List tbPerson = template.query(sql, new BeanPropertyRowMapper(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.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.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 likePersonByName(String name) {
try {
String sql = “select * from tb_person where name like ‘%’ ? ‘%’”;
List tbPerson = template.query(sql, new BeanPropertyRowMapper(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);
}
}
package com.sjsq.tools;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
/**
- Druid连接池工具类,将来dao层调用
*/
public class JDBCUtils {
private static DataSource dataSource; // 定义成员变量DataSource
static {
try {
// 加载配置文件
Properties properties = new Properties();
properties.load(JDBCUtils.class.getClassLoader().getResourceAsStream(“druid.properties”));
// 获取DataSource
dataSource = DruidDataSourceFactory.createDataSource(properties);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
- 获取连接
*/
public static Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
/**
- 释放资源
*/
public static void close(Statement statement, Connection connection) {
close(null, statement, connection);
}
public static void close(ResultSet resultSet, Statement statement, Connection connection) {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();// 归还连接
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
- 获取连接池方法
*/
public static DataSource getDataSource() {
return dataSource;
}
}
package com.sjsq.view;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Toolkit;
import java.io.IOException;
import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.SwingConstants;
import com.sjsq.model.TbPerson;
import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
import com.sjsq.dao.PersonDao;
import com.sjsq.tools.PwEncryption;
import com.sjsq.tools.StringUtil;
import com.sjsq.tools.TxtExport;
/**
-
登陆窗体类,为用户第一窗体
-
@author 22219
*/
public class LoginFrame extends JFrame {
/**
- 串行版本标识serialVersionUID
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
public static JTextField userNameTxt;
private JPasswordField passwordTxt;
public static String time;
public static String userId;
/**
- 登陆窗体类的构造函数
*/
public LoginFrame() {
this.setBounds(0, 0, 500, 400);
this.setLocationRelativeTo(null);
setResizable(false);
//setIconImage(Toolkit.getDefaultToolkit().getImage(LoginFrame.class.getResource(“/images/storage_128px.png”)));
setTitle(“登录”);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel(“企业人事管理系统”);
lblNewLabel.setBounds(96, 29, 300, 48);
lblNewLabel.setFont(new Font(“方正粗黑宋简体”, Font.BOLD, 27));
lblNewLabel.setIcon(new ImageIcon(LoginFrame.class.getResource(“/images/hrm.png”)));
JLabel lblNewLabel_1 = new JLabel(“账号”);
lblNewLabel_1.setFont(new Font(“Microsoft YaHei UI”, Font.PLAIN, 15));
lblNewLabel_1.setBounds(34, 126, 80, 18);
lblNewLabel_1.setIcon(new ImageIcon(LoginFrame.class.getResource(“/images/userName.png”)));
JLabel lblNewLabel_2 = new JLabel(“密码”);
lblNewLabel_2.setFont(new Font(“Microsoft YaHei UI”, Font.PLAIN, 15));
lblNewLabel_2.setBounds(34, 185, 65, 18);
lblNewLabel_2.setIcon(new ImageIcon(LoginFrame.class.getResource(“/images/password.png”)));
userNameTxt = new JTextField();
userNameTxt.setHorizontalAlignment(SwingConstants.CENTER);
userNameTxt.setBounds(96, 110, 308, 46);
userNameTxt.setFont(new Font(“微软雅黑”, Font.BOLD, 20));
userNameTxt.setToolTipText(“输入用户名”);
userNameTxt.setColumns(10);
passwordTxt = new JPasswordField();
passwordTxt.setHorizontalAlignment(SwingConstants.CENTER);
passwordTxt.setBounds(96, 169, 308, 46);
passwordTxt.setFont(new Font(“微软雅黑”, Font.BOLD, 20));
passwordTxt.setToolTipText(“输入密码”);
JButton btnNewButton = new JButton(“登录”);
btnNewButton.setFont(new Font(“Microsoft YaHei UI”, Font.PLAIN, 15));
btnNewButton.setBounds(120, 252, 90, 40);
this.getRootPane().setDefaultButton(btnNewButton);
btnNewButton.setIcon(new ImageIcon(LoginFrame.class.getResource(“/images/login.png”)));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
loginActionPerformed(e);
}
});
JButton btnNewButton_1 = new JButton(“重置”);
btnNewButton_1.setFont(new Font(“Microsoft YaHei UI”, Font.PLAIN, 15));
btnNewButton_1.setBounds(280, 252, 90, 40);
btnNewButton_1.setIcon(new ImageIcon(LoginFrame.class.getResource(“/images/reset.png”)));
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resetValueActionPerformed(e);
}
});
JButton btnNewButton_2 = new JButton(“注/改”);
btnNewButton_2.setFont(new Font(“Microsoft YaHei UI”, Font.PLAIN, 15));
btnNewButton_2.setBounds(305, 252, 90, 40);
btnNewButton_2.setIcon(new ImageIcon(LoginFrame.class.getResource(“/images/add.png”)));
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
enrollValueActionPerformed(e);
}
});
contentPane.add(lblNewLabel);
contentPane.add(lblNewLabel_1);
contentPane.add(lblNewLabel_2);
contentPane.add(passwordTxt);
contentPane.add(userNameTxt);
Spring全套教学资料
Spring是Java程序员的《葵花宝典》,其中提供的各种大招,能简化我们的开发,大大提升开发效率!目前99%的公司使用了Spring,大家可以去各大招聘网站看一下,Spring算是必备技能,所以一定要掌握。
目录:
部分内容:
Spring源码
- 第一部分 Spring 概述
- 第二部分 核心思想
- 第三部分 手写实现 IoC 和 AOP(自定义Spring框架)
- 第四部分 Spring IOC 高级应用
基础特性
高级特性 - 第五部分 Spring IOC源码深度剖析
设计优雅
设计模式
注意:原则、方法和技巧 - 第六部分 Spring AOP 应用
声明事务控制 - 第七部分 Spring AOP源码深度剖析
必要的笔记、必要的图、通俗易懂的语言化解知识难点
脚手框架:SpringBoot技术
它的目标是简化Spring应用和服务的创建、开发与部署,简化了配置文件,使用嵌入式web服务器,含有诸多开箱即用的微服务功能,可以和spring cloud联合部署。
Spring Boot的核心思想是约定大于配置,应用只需要很少的配置即可,简化了应用开发模式。
- SpringBoot入门
- 配置文件
- 日志
- Web开发
- Docker
- SpringBoot与数据访问
- 启动配置原理
- 自定义starter
微服务架构:Spring Cloud Alibaba
同 Spring Cloud 一样,Spring Cloud Alibaba 也是一套微服务解决方案,包含开发分布式应用微服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式应用服务。
- 微服务架构介绍
- Spring Cloud Alibaba介绍
- 微服务环境搭建
- 服务治理
- 服务容错
- 服务网关
- 链路追踪
- ZipKin集成及数据持久化
- 消息驱动
- 短信服务
- Nacos Confifig—服务配置
- Seata—分布式事务
- Dubbo—rpc通信
Spring MVC
目录:
部分内容:
]
[外链图片转存中…(img-XdYgyCwo-1714288391365)]
脚手框架:SpringBoot技术
它的目标是简化Spring应用和服务的创建、开发与部署,简化了配置文件,使用嵌入式web服务器,含有诸多开箱即用的微服务功能,可以和spring cloud联合部署。
Spring Boot的核心思想是约定大于配置,应用只需要很少的配置即可,简化了应用开发模式。
- SpringBoot入门
- 配置文件
- 日志
- Web开发
- Docker
- SpringBoot与数据访问
- 启动配置原理
- 自定义starter
[外链图片转存中…(img-ZfFsS7lf-1714288391366)]
[外链图片转存中…(img-HvuI0XIz-1714288391366)]
微服务架构:Spring Cloud Alibaba
同 Spring Cloud 一样,Spring Cloud Alibaba 也是一套微服务解决方案,包含开发分布式应用微服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式应用服务。
- 微服务架构介绍
- Spring Cloud Alibaba介绍
- 微服务环境搭建
- 服务治理
- 服务容错
- 服务网关
- 链路追踪
- ZipKin集成及数据持久化
- 消息驱动
- 短信服务
- Nacos Confifig—服务配置
- Seata—分布式事务
- Dubbo—rpc通信
[外链图片转存中…(img-yvnGJEKY-1714288391367)]
[外链图片转存中…(img-GQrbOuRQ-1714288391367)]
Spring MVC
目录:
[外链图片转存中…(img-BxuaDEzK-1714288391368)]
[外链图片转存中…(img-4lHo7BJp-1714288391368)]
[外链图片转存中…(img-qeZ3e8Tl-1714288391369)]
部分内容:
[外链图片转存中…(img-UKTo1PNG-1714288391369)]
[外链图片转存中…(img-R7PHxQwO-1714288391370)]