Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
优比特软件工作室
StudentManagementSystemSwingMySQL
提交
0663d7a8
S
StudentManagementSystemSwingMySQL
项目概览
优比特软件工作室
/
StudentManagementSystemSwingMySQL
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
StudentManagementSystemSwingMySQL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0663d7a8
编写于
4月 05, 2023
作者:
小刘28
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:完成管理员用户的登录功能,完成跳转找回密码页面的功能;
上级
84a24993
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
1023 addition
and
83 deletion
+1023
-83
img/icon.jpg
img/icon.jpg
+0
-0
src/Main.java
src/Main.java
+3
-26
src/com/ubitsgroup/controller/login/LoginController.java
src/com/ubitsgroup/controller/login/LoginController.java
+112
-0
src/com/ubitsgroup/controller/login/ResetPasswordController.java
.../ubitsgroup/controller/login/ResetPasswordController.java
+54
-0
src/com/ubitsgroup/dao/AccountDao.java
src/com/ubitsgroup/dao/AccountDao.java
+72
-0
src/com/ubitsgroup/db/AccountDB.java
src/com/ubitsgroup/db/AccountDB.java
+80
-0
src/com/ubitsgroup/db/DBUtil.java
src/com/ubitsgroup/db/DBUtil.java
+16
-51
src/com/ubitsgroup/joggle/DBJoggle.java
src/com/ubitsgroup/joggle/DBJoggle.java
+25
-0
src/com/ubitsgroup/local/CurrentUser.java
src/com/ubitsgroup/local/CurrentUser.java
+25
-0
src/com/ubitsgroup/model/AccountModel.java
src/com/ubitsgroup/model/AccountModel.java
+195
-0
src/com/ubitsgroup/util/VerifyCodeUtil.java
src/com/ubitsgroup/util/VerifyCodeUtil.java
+28
-0
src/com/ubitsgroup/view/login/LoginView.java
src/com/ubitsgroup/view/login/LoginView.java
+174
-1
src/com/ubitsgroup/view/login/ResetPasswordView.java
src/com/ubitsgroup/view/login/ResetPasswordView.java
+197
-1
src/com/ubitsgroup/view/main/admin/MainAdminView.java
src/com/ubitsgroup/view/main/admin/MainAdminView.java
+30
-0
src/com/ubitsgroup/view/main/admin/MainView.java
src/com/ubitsgroup/view/main/admin/MainView.java
+0
-4
src/com/ubitsgroup/view/main/student/MainStudentView.java
src/com/ubitsgroup/view/main/student/MainStudentView.java
+6
-0
src/com/ubitsgroup/view/main/teacher/MainTeacherView.java
src/com/ubitsgroup/view/main/teacher/MainTeacherView.java
+6
-0
未找到文件。
img/icon.jpg
0 → 100644
浏览文件 @
0663d7a8
36.2 KB
src/Main.java
浏览文件 @
0663d7a8
import
com.ubitsgroup.db.DBUtil
;
import
java.io.IOException
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
com.ubitsgroup.view.login.LoginView
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
System
.
out
.
println
(
"Hello world!"
);
DBUtil
db
=
new
DBUtil
();
// //查询操作
Object
[]
objs
=
{};
ResultSet
set
=
db
.
select
(
"select * from teacher"
,
objs
);
try
{
while
(
set
.
next
())
{
String
t_id
=
set
.
getString
(
"tea_id"
);
// String t_name = set.getString("t_name");
// String t_tel = set.getString("t_tel");
// String t_username = set.getString("t_username");
// String t_password = set.getString("t_password");
System
.
out
.
println
(
t_id
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
db
.
closeConnection
();
public
static
void
main
(
String
[]
args
)
{
new
LoginView
();
}
}
\ No newline at end of file
src/com/ubitsgroup/controller/login/LoginController.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.controller.login
;
import
com.ubitsgroup.dao.AccountDao
;
import
com.ubitsgroup.local.CurrentUser
;
import
com.ubitsgroup.model.AccountModel
;
import
com.ubitsgroup.util.VerifyCodeUtil
;
import
com.ubitsgroup.view.login.LoginView
;
import
com.ubitsgroup.view.main.admin.MainAdminView
;
import
com.ubitsgroup.view.main.student.MainStudentView
;
import
com.ubitsgroup.view.main.teacher.MainTeacherView
;
import
javax.swing.*
;
public
class
LoginController
{
VerifyCodeUtil
verifyCodeUtil
;
public
LoginController
()
{
verifyCodeUtil
=
new
VerifyCodeUtil
();
}
public
void
userLogin
(
LoginView
frame
,
int
userType
,
String
account
,
String
password
,
String
verifyCode
,
String
verifyCodeText
){
if
(
account
.
equals
(
""
)){
JOptionPane
.
showMessageDialog
(
frame
,
"账号不能为空"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
return
;
}
if
(
password
.
equals
(
""
)){
JOptionPane
.
showMessageDialog
(
frame
,
"密码不能为空"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
return
;
}
if
(
verifyCode
.
equals
(
""
)){
JOptionPane
.
showMessageDialog
(
frame
,
"验证码不能为空"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
return
;
}
if
(!
verifyCode
.
equalsIgnoreCase
(
verifyCodeText
)){
JOptionPane
.
showMessageDialog
(
frame
,
"验证码不正确"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
frame
.
setVerifyCodeTextLabel
(
verifyCodeUtil
.
getVerifyCode
(
4
));
return
;
}
AccountDao
accountDao
=
new
AccountDao
();
AccountModel
accountModel
=
null
;
switch
(
userType
){
case
0
:
accountModel
=
accountDao
.
selectDataByAccount
(
account
,
null
);
System
.
out
.
println
(
accountModel
);
if
(
accountModel
==
null
){
JOptionPane
.
showMessageDialog
(
frame
,
"账号不存在"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
frame
.
setVerifyCodeTextLabel
(
verifyCodeUtil
.
getVerifyCode
(
4
));
break
;
}
if
(!
accountModel
.
getPassword
().
equals
(
password
)){
JOptionPane
.
showMessageDialog
(
frame
,
"密码错误"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
frame
.
setVerifyCodeTextLabel
(
verifyCodeUtil
.
getVerifyCode
(
4
));
break
;
}
// 登录正确
accountModel
.
setPassword
(
null
);
CurrentUser
currentUser
=
CurrentUser
.
getInstance
();
currentUser
.
setAccountClass
(
accountModel
);
frame
.
dispose
();
new
MainAdminView
();
break
;
case
1
:
System
.
out
.
println
(
"教师登录"
);
break
;
case
2
:
System
.
out
.
println
(
"学生登录"
);
break
;
default
:
System
.
out
.
println
(
"账号类型错误"
);
}
}
public
String
toString
()
{
return
"LoginController{}"
;
}
}
src/com/ubitsgroup/controller/login/ResetPasswordController.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.controller.login
;
import
com.ubitsgroup.util.VerifyCodeUtil
;
import
com.ubitsgroup.view.login.ResetPasswordView
;
import
javax.swing.*
;
public
class
ResetPasswordController
{
VerifyCodeUtil
verifyCodeUtil
;
public
ResetPasswordController
()
{
verifyCodeUtil
=
new
VerifyCodeUtil
();
}
public
void
resetPassword
(
ResetPasswordView
frame
,
String
account
,
String
verifyCode
,
String
verifyCodeText
){
if
(
account
.
equals
(
""
)){
JOptionPane
.
showMessageDialog
(
frame
,
"账号不能为空"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
return
;
}
if
(
verifyCode
.
equals
(
""
)){
JOptionPane
.
showMessageDialog
(
frame
,
"验证码不能为空"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
return
;
}
if
(!
verifyCode
.
equalsIgnoreCase
(
verifyCodeText
)){
JOptionPane
.
showMessageDialog
(
frame
,
"验证码不正确"
,
"温馨提示"
,
JOptionPane
.
INFORMATION_MESSAGE
);
frame
.
setVerifyCodeTextLabel
(
verifyCodeUtil
.
getVerifyCode
(
4
));
return
;
}
System
.
out
.
println
(
"生成新的密码"
);
}
public
String
toString
()
{
return
"ResetPasswordController{}"
;
}
}
src/com/ubitsgroup/dao/AccountDao.java
浏览文件 @
0663d7a8
package
com.ubitsgroup.dao
;
import
com.ubitsgroup.db.DBUtil
;
import
com.ubitsgroup.model.AccountModel
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.List
;
public
class
AccountDao
{
private
DBUtil
db
=
DBUtil
.
getInstance
();
private
Connection
conn
;
private
PreparedStatement
pst
;
private
ResultSet
rs
;
int
total
;
public
ResultSet
selectAllData
(){
return
null
;
}
public
ResultSet
selectDataByID
(
String
sql
,
List
<
Object
>
params
){
conn
=
db
.
getConnection
();
try
{
pst
=
conn
.
prepareStatement
(
sql
);
int
paramsIndex
=
1
;
for
(
Object
p
:
params
){
pst
.
setObject
(
paramsIndex
++,
p
);
}
//执行sql语句获得结果集的对象
rs
=
pst
.
executeQuery
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
AccountModel
selectDataByAccount
(
String
account
,
List
<
Object
>
params
){
conn
=
db
.
getConnection
();
String
sql
=
"select * from account a where acc_name = ?"
;
AccountModel
accountModel
=
null
;
try
{
pst
=
conn
.
prepareStatement
(
sql
);
pst
.
setString
(
1
,
account
);
//执行sql语句获得结果集的对象
rs
=
pst
.
executeQuery
();
while
(
rs
.
next
()){
accountModel
=
new
AccountModel
();
accountModel
.
setID
(
rs
.
getString
(
"acc_id"
));
accountModel
.
setName
(
rs
.
getString
(
"acc_name"
));
accountModel
.
setPassword
(
rs
.
getString
(
"acc_password"
));
accountModel
.
setEnabled
(
rs
.
getInt
(
"had_enabled"
));
accountModel
.
setDelete
(
rs
.
getInt
(
"had_delete"
));
accountModel
.
setCreateTime
(
rs
.
getString
(
"create_time"
));
accountModel
.
setUpdateTime
(
rs
.
getString
(
"update_time"
));
accountModel
.
setDeleteTime
(
rs
.
getString
(
"delete_time"
));
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
accountModel
;
}
public
ResultSet
selectDataBySearch
(){
return
null
;
}
public
int
selectAllDataTotal
(){
return
0
;
}
...
...
src/com/ubitsgroup/db/AccountDB.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.db
;
import
com.ubitsgroup.joggle.DBJoggle
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Set
;
public
class
AccountDB
implements
DBJoggle
{
private
DBUtil
db
=
DBUtil
.
getInstance
();
private
Connection
conn
;
private
PreparedStatement
pst
;
private
ResultSet
rs
;
int
total
;
// 新增操作
@Override
public
int
insertData
(
String
sql
)
{
return
0
;
}
// 更新操作
@Override
public
int
updateData
(
String
sql
)
{
return
0
;
}
// 删除操作
@Override
public
int
deleteData
(
String
sql
)
{
return
0
;
}
// 查询操作
@Override
public
Object
selectDataByID
(
String
sql
)
{
return
null
;
}
@Override
public
Set
selectData
(
String
sql
)
{
db
.
getConnection
();
try
{
pst
=
conn
.
prepareStatement
(
sql
);
rs
=
pst
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
String
acc_id
=
rs
.
getString
(
"acc_id"
);
// String t_name = set.getString("t_name");
// String t_tel = set.getString("t_tel");
// String t_username = set.getString("t_username");
// String t_password = set.getString("t_password");
System
.
out
.
println
(
acc_id
);
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
null
;
}
@Override
public
int
selectTotal
(
String
sql
)
{
return
0
;
}
public
Set
selectDataByName
(
String
sql
)
{
return
null
;
}
}
src/com/ubitsgroup/db/DBUtil.java
浏览文件 @
0663d7a8
...
...
@@ -11,6 +11,8 @@ public class DBUtil {
private
static
String
url
;
private
static
String
username
;
private
static
String
password
;
public
static
DBUtil
db
=
null
;
private
static
Connection
connection
;
//注册驱动,使用静态块,只需注册一次
static
{
...
...
@@ -34,73 +36,36 @@ public class DBUtil {
}
}
//jdbc对象
private
Connection
connection
=
null
;
private
PreparedStatement
preparedStatement
=
null
;
private
ResultSet
resultSet
=
null
;
private
DBUtil
(){
//获取连接
public
void
getConnection
()
{
try
{
//2、建立连接
connection
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
//更新操作:增删改
public
int
update
(
String
sql
,
Object
[]
objs
)
{
int
i
=
0
;
try
{
getConnection
();
//3、创建sql对象
preparedStatement
=
connection
.
prepareStatement
(
sql
);
for
(
int
j
=
0
;
j
<
objs
.
length
;
j
++)
{
preparedStatement
.
setObject
(
j
+
1
,
objs
[
j
]);
public
static
DBUtil
getInstance
()
{
if
(
db
==
null
)
{
synchronized
(
DBUtil
.
class
)
{
if
(
db
==
null
)
{
db
=
new
DBUtil
();
}
}
//4、执行sql,返回改变的行数
i
=
preparedStatement
.
executeUpdate
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
i
;
return
db
;
}
//
查询操作
public
ResultSet
select
(
String
sql
,
Object
[]
objs
)
{
//
获取连接
public
Connection
getConnection
(
)
{
try
{
getConnection
();
//3、创建sql对象
preparedStatement
=
connection
.
prepareStatement
(
sql
);
for
(
int
j
=
0
;
j
<
objs
.
length
;
j
++)
{
preparedStatement
.
setObject
(
j
+
1
,
objs
[
j
]);
}
//4、执行sql,返回查询到的set集合
resultSet
=
preparedStatement
.
executeQuery
();
//2、建立连接
connection
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
return
connection
;
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
resultSet
;
}
//断开连接
public
void
closeConnection
()
{
//5、断开连接
if
(
resultSet
!=
null
)
{
try
{
resultSet
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
preparedStatement
!=
null
)
{
try
{
preparedStatement
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
connection
!=
null
)
{
try
{
connection
.
close
();
...
...
src/com/ubitsgroup/joggle/DBJoggle.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.joggle
;
import
java.util.Set
;
public
interface
DBJoggle
{
// 新增操作
int
insertData
(
String
sql
);
// 修改操作
int
updateData
(
String
sql
);
// 删除操作
int
deleteData
(
String
sql
);
// 查询操作
Object
selectDataByID
(
String
sql
);
Set
selectData
(
String
sql
);
int
selectTotal
(
String
sql
);
}
src/com/ubitsgroup/local/CurrentUser.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.local
;
import
com.ubitsgroup.model.AccountModel
;
public
class
CurrentUser
{
private
static
final
CurrentUser
instance
=
new
CurrentUser
();
private
AccountModel
accountModel
;
private
CurrentUser
(){}
public
static
CurrentUser
getInstance
(){
return
instance
;
}
public
AccountModel
getAccountClass
()
{
return
accountModel
;
}
public
void
setAccountClass
(
AccountModel
accountModel
)
{
this
.
accountModel
=
accountModel
;
}
}
src/com/ubitsgroup/model/AccountModel.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.model
;
public
class
AccountModel
{
private
String
ID
;
private
String
name
;
private
String
password
;
private
int
type
;
private
String
remarks
;
private
int
enabled
;
private
int
delete
;
private
String
createTime
;
private
String
updateTime
;
private
String
deleteTime
;
public
AccountModel
()
{
}
public
AccountModel
(
String
ID
,
String
name
,
String
password
,
int
type
,
String
remarks
,
int
enabled
,
int
delete
,
String
createTime
,
String
updateTime
,
String
deleteTime
)
{
this
.
ID
=
ID
;
this
.
name
=
name
;
this
.
password
=
password
;
this
.
type
=
type
;
this
.
remarks
=
remarks
;
this
.
enabled
=
enabled
;
this
.
delete
=
delete
;
this
.
createTime
=
createTime
;
this
.
updateTime
=
updateTime
;
this
.
deleteTime
=
deleteTime
;
}
/**
* 获取
* @return ID
*/
public
String
getID
()
{
return
ID
;
}
/**
* 设置
* @param ID
*/
public
void
setID
(
String
ID
)
{
this
.
ID
=
ID
;
}
/**
* 获取
* @return name
*/
public
String
getName
()
{
return
name
;
}
/**
* 设置
* @param name
*/
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
/**
* 获取
* @return password
*/
public
String
getPassword
()
{
return
password
;
}
/**
* 设置
* @param password
*/
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
/**
* 获取
* @return type
*/
public
int
getType
()
{
return
type
;
}
/**
* 设置
* @param type
*/
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
/**
* 获取
* @return remarks
*/
public
String
getRemarks
()
{
return
remarks
;
}
/**
* 设置
* @param remarks
*/
public
void
setRemarks
(
String
remarks
)
{
this
.
remarks
=
remarks
;
}
/**
* 获取
* @return enabled
*/
public
int
getEnabled
()
{
return
enabled
;
}
/**
* 设置
* @param enabled
*/
public
void
setEnabled
(
int
enabled
)
{
this
.
enabled
=
enabled
;
}
/**
* 获取
* @return delete
*/
public
int
getDelete
()
{
return
delete
;
}
/**
* 设置
* @param delete
*/
public
void
setDelete
(
int
delete
)
{
this
.
delete
=
delete
;
}
/**
* 获取
* @return createTime
*/
public
String
getCreateTime
()
{
return
createTime
;
}
/**
* 设置
* @param createTime
*/
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
/**
* 获取
* @return updateTime
*/
public
String
getUpdateTime
()
{
return
updateTime
;
}
/**
* 设置
* @param updateTime
*/
public
void
setUpdateTime
(
String
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
/**
* 获取
* @return deleteTime
*/
public
String
getDeleteTime
()
{
return
deleteTime
;
}
/**
* 设置
* @param deleteTime
*/
public
void
setDeleteTime
(
String
deleteTime
)
{
this
.
deleteTime
=
deleteTime
;
}
public
String
toString
()
{
return
"AccountModel{ID = "
+
ID
+
", name = "
+
name
+
", password = "
+
password
+
", type = "
+
type
+
", remarks = "
+
remarks
+
", enabled = "
+
enabled
+
", delete = "
+
delete
+
", createTime = "
+
createTime
+
", updateTime = "
+
updateTime
+
", deleteTime = "
+
deleteTime
+
"}"
;
}
}
src/com/ubitsgroup/util/VerifyCodeUtil.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.util
;
import
java.util.Random
;
public
class
VerifyCodeUtil
{
public
String
getVerifyCode
(
int
length
)
{
Random
r
=
new
Random
();
String
verifyCode
=
""
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
num
=
r
.
nextInt
(
3
);
switch
(
num
)
{
case
0
:
char
s
=
(
char
)
(
r
.
nextInt
(
26
)
+
65
);
verifyCode
=
verifyCode
+
s
;
break
;
case
1
:
char
s1
=
(
char
)
(
r
.
nextInt
(
26
)
+
97
);
verifyCode
=
verifyCode
+
s1
;
break
;
case
2
:
int
s2
=
r
.
nextInt
(
10
);
verifyCode
=
verifyCode
+
s2
;
break
;
}
}
return
verifyCode
;
}
}
src/com/ubitsgroup/view/login/LoginView.java
浏览文件 @
0663d7a8
package
com.ubitsgroup.view.login
;
public
class
LoginView
{
import
com.ubitsgroup.controller.login.LoginController
;
import
com.ubitsgroup.util.VerifyCodeUtil
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.*
;
public
class
LoginView
extends
JFrame
{
LoginView
frame
;
JPanel
panel
;
JComboBox
<
String
>
userTypeComboBox
;
// 用户类型选择器
JTextField
accountTextField
;
// 账号输入框
JPasswordField
passwordTextField
;
// 密码输入框
JTextField
verifyCodeTextField
;
// 验证码输入框
JLabel
verifyCodeTextLabel
;
// 验证码显示标签
String
verifyCodeText
;
LoginController
loginController
;
VerifyCodeUtil
verifyCodeUtil
;
public
LoginView
()
{
initData
();
initJFrame
();
initPanel
();
initView
();
}
public
void
setVerifyCodeTextLabel
(
String
newVerifyCode
){
verifyCodeText
=
newVerifyCode
;
verifyCodeTextLabel
.
setText
(
verifyCodeText
);
}
private
void
initData
(){
verifyCodeUtil
=
new
VerifyCodeUtil
();
loginController
=
new
LoginController
();
}
private
void
initJFrame
(){
frame
=
this
;
this
.
setTitle
(
"登录"
);
this
.
setIconImage
(
new
ImageIcon
(
"img/icon.jpg"
).
getImage
());
this
.
setSize
(
500
,
440
);
this
.
setLocationRelativeTo
(
null
);
this
.
setResizable
(
false
);
this
.
setDefaultCloseOperation
(
WindowConstants
.
EXIT_ON_CLOSE
);
}
private
void
initPanel
(){
panel
=
new
JPanel
();
panel
.
setLayout
(
null
);
}
private
void
initView
(){
// 标题
JLabel
systemNameLabel
=
new
JLabel
(
"学生信息管理系统"
,
SwingConstants
.
CENTER
);
systemNameLabel
.
setBounds
(
100
,
20
,
300
,
40
);
systemNameLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
26
));
panel
.
add
(
systemNameLabel
);
// 账号类型
String
userTypeHtml
=
"<html><span style='color:red'>*</span>用户类型</html>"
;
JLabel
userTypeLabel
=
new
JLabel
(
userTypeHtml
,
SwingConstants
.
CENTER
);
userTypeLabel
.
setBounds
(
40
,
80
,
100
,
30
);
userTypeLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
userTypeLabel
);
String
[]
userTypeData
=
new
String
[]{
"管理员"
,
"教师"
,
"学生"
};
userTypeComboBox
=
new
JComboBox
<>(
userTypeData
);
userTypeComboBox
.
setBounds
(
140
,
80
,
280
,
30
);
userTypeComboBox
.
addItemListener
(
e
->
{
});
userTypeComboBox
.
setSelectedIndex
(
0
);
panel
.
add
(
userTypeComboBox
);
// 账号
String
accountHtml
=
"<html><span style='color:red'>*</span>账号</html>"
;
JLabel
accountLabel
=
new
JLabel
(
accountHtml
,
SwingConstants
.
CENTER
);
accountLabel
.
setBounds
(
40
,
130
,
100
,
30
);
accountLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
accountLabel
);
accountTextField
=
new
JTextField
();
accountTextField
.
setBounds
(
140
,
130
,
280
,
30
);
panel
.
add
(
accountTextField
);
// 密码
String
passwordHtml
=
"<html><span style='color:red'>*</span>密码</html>"
;
JLabel
passwordLabel
=
new
JLabel
(
passwordHtml
,
SwingConstants
.
CENTER
);
passwordLabel
.
setBounds
(
40
,
180
,
100
,
30
);
passwordLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
passwordLabel
);
passwordTextField
=
new
JPasswordField
();
passwordTextField
.
setBounds
(
140
,
180
,
280
,
30
);
panel
.
add
(
passwordTextField
);
// 验证码
String
verifyCodeHtml
=
"<html><span style='color:red'>*</span>验证码</html>"
;
JLabel
verifyCodeLabel
=
new
JLabel
(
verifyCodeHtml
,
SwingConstants
.
CENTER
);
verifyCodeLabel
.
setBounds
(
40
,
230
,
100
,
30
);
verifyCodeLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
verifyCodeLabel
);
verifyCodeTextField
=
new
JTextField
();
verifyCodeTextField
.
setBounds
(
140
,
230
,
200
,
30
);
panel
.
add
(
verifyCodeTextField
);
verifyCodeText
=
verifyCodeUtil
.
getVerifyCode
(
4
);
verifyCodeTextLabel
=
new
JLabel
(
verifyCodeText
,
SwingConstants
.
CENTER
);
verifyCodeTextLabel
.
addMouseListener
(
new
MouseListener
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
verifyCodeText
=
verifyCodeUtil
.
getVerifyCode
(
4
);
verifyCodeTextLabel
.
setText
(
verifyCodeText
);
}
@Override
public
void
mousePressed
(
MouseEvent
e
)
{
}
@Override
public
void
mouseReleased
(
MouseEvent
e
)
{
}
@Override
public
void
mouseEntered
(
MouseEvent
e
)
{
}
@Override
public
void
mouseExited
(
MouseEvent
e
)
{
}
});
verifyCodeTextLabel
.
setBounds
(
340
,
230
,
80
,
30
);
verifyCodeTextLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
verifyCodeTextLabel
);
JButton
loginButton
=
new
JButton
(
"登录系统"
);
loginButton
.
setBounds
(
80
,
300
,
100
,
30
);
panel
.
add
(
loginButton
);
loginButton
.
addActionListener
(
e
->
userLogin
());
JButton
retrievePasswordButton
=
new
JButton
(
"找回密码"
);
retrievePasswordButton
.
setBounds
(
320
,
300
,
100
,
30
);
retrievePasswordButton
.
addActionListener
(
e
->
{
frame
.
dispose
();
new
ResetPasswordView
();
});
panel
.
add
(
retrievePasswordButton
);
JLabel
initTipLabel
=
new
JLabel
(
"系统初始管理员账号为:admin,密码为:123456"
);
initTipLabel
.
setBounds
(
50
,
350
,
400
,
30
);
initTipLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
14
));
initTipLabel
.
setHorizontalAlignment
(
SwingConstants
.
CENTER
);
panel
.
add
(
initTipLabel
);
accountTextField
.
setText
(
"admin"
);
passwordTextField
.
setText
(
"123456"
);
this
.
setContentPane
(
panel
);
this
.
setVisible
(
true
);
}
private
void
userLogin
(){
int
userType
=
userTypeComboBox
.
getSelectedIndex
();
String
account
=
accountTextField
.
getText
().
trim
();
String
password
=
new
String
(
passwordTextField
.
getPassword
()).
trim
();
String
verifyCode
=
verifyCodeTextField
.
getText
().
trim
();
loginController
.
userLogin
(
frame
,
userType
,
account
,
password
,
verifyCode
,
verifyCodeText
);
}
}
src/com/ubitsgroup/view/login/ResetPasswordView.java
浏览文件 @
0663d7a8
package
com.ubitsgroup.view.login
;
public
class
ResetPasswordView
{
import
com.ubitsgroup.controller.login.ResetPasswordController
;
import
com.ubitsgroup.model.AccountModel
;
import
com.ubitsgroup.util.VerifyCodeUtil
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseListener
;
public
class
ResetPasswordView
extends
JFrame
{
ResetPasswordView
frame
;
JPanel
panel
;
JTextField
accountTextField
;
// 账号输入框
JTextField
verifyCodeTextField
;
// 验证码输入框
JLabel
verifyCodeTextLabel
;
// 验证码显示标签
String
verifyCodeText
;
JLabel
newPasswordContentLabel
;
// 新密码展示标签
VerifyCodeUtil
verifyCodeUtil
;
ResetPasswordController
resetPasswordController
;
public
ResetPasswordView
()
{
initData
();
initJFrame
();
initPanel
();
initView
();
}
public
void
setVerifyCodeTextLabel
(
String
newVerifyCode
){
verifyCodeText
=
newVerifyCode
;
verifyCodeTextLabel
.
setText
(
verifyCodeText
);
}
private
void
initData
(){
verifyCodeUtil
=
new
VerifyCodeUtil
();
resetPasswordController
=
new
ResetPasswordController
();
}
private
void
initJFrame
(){
frame
=
this
;
this
.
setTitle
(
"找回密码"
);
this
.
setIconImage
(
new
ImageIcon
(
"img/icon.jpg"
).
getImage
());
this
.
setSize
(
500
,
350
);
this
.
setLocationRelativeTo
(
null
);
this
.
setResizable
(
false
);
this
.
setDefaultCloseOperation
(
WindowConstants
.
EXIT_ON_CLOSE
);
}
private
void
initPanel
(){
panel
=
new
JPanel
();
panel
.
setLayout
(
null
);
}
private
void
initView
(){
JLabel
systemNameLabel
=
new
JLabel
(
"学生信息管理系统"
,
SwingConstants
.
CENTER
);
systemNameLabel
.
setBounds
(
100
,
20
,
300
,
40
);
systemNameLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
26
));
panel
.
add
(
systemNameLabel
);
String
accountHtml
=
"<html><span style='color:red'>*</span>账号</html>"
;
JLabel
accountLabel
=
new
JLabel
(
accountHtml
,
SwingConstants
.
CENTER
);
accountLabel
.
setBounds
(
40
,
80
,
100
,
30
);
accountLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
accountLabel
);
accountTextField
=
new
JTextField
();
accountTextField
.
setBounds
(
140
,
80
,
280
,
30
);
panel
.
add
(
accountTextField
);
// 验证码
String
verifyCodeHtml
=
"<html><span style='color:red'>*</span>验证码</html>"
;
JLabel
verifyCodeLabel
=
new
JLabel
(
verifyCodeHtml
,
SwingConstants
.
CENTER
);
verifyCodeLabel
.
setBounds
(
40
,
130
,
100
,
30
);
verifyCodeLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
verifyCodeLabel
);
verifyCodeTextField
=
new
JTextField
();
verifyCodeTextField
.
setBounds
(
140
,
130
,
200
,
30
);
panel
.
add
(
verifyCodeTextField
);
verifyCodeText
=
verifyCodeUtil
.
getVerifyCode
(
4
);
verifyCodeTextLabel
=
new
JLabel
(
verifyCodeText
,
SwingConstants
.
CENTER
);
verifyCodeTextLabel
.
addMouseListener
(
new
MouseListener
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
verifyCodeText
=
verifyCodeUtil
.
getVerifyCode
(
4
);
verifyCodeTextLabel
.
setText
(
verifyCodeText
);
}
@Override
public
void
mousePressed
(
MouseEvent
e
)
{
}
@Override
public
void
mouseReleased
(
MouseEvent
e
)
{
}
@Override
public
void
mouseEntered
(
MouseEvent
e
)
{
}
@Override
public
void
mouseExited
(
MouseEvent
e
)
{
}
});
verifyCodeTextLabel
.
setBounds
(
340
,
130
,
80
,
30
);
verifyCodeTextLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
verifyCodeTextLabel
);
JLabel
newPasswordLabel
=
new
JLabel
(
"新密码"
,
SwingConstants
.
CENTER
);
newPasswordLabel
.
setBounds
(
40
,
180
,
100
,
30
);
newPasswordLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
newPasswordLabel
);
newPasswordContentLabel
=
new
JLabel
(
"未找回"
,
SwingConstants
.
LEFT
);
newPasswordContentLabel
.
setBounds
(
140
,
180
,
160
,
30
);
newPasswordContentLabel
.
setFont
(
new
Font
(
null
,
Font
.
PLAIN
,
16
));
panel
.
add
(
newPasswordContentLabel
);
JButton
copyNewPasswordButton
=
new
JButton
(
"复制"
);
copyNewPasswordButton
.
setBounds
(
320
,
180
,
100
,
30
);
copyNewPasswordButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
// copyNewPassword();
}
});
panel
.
add
(
copyNewPasswordButton
);
JButton
retrievePasswordButton
=
new
JButton
(
"找回密码"
);
retrievePasswordButton
.
setBounds
(
80
,
250
,
100
,
30
);
retrievePasswordButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
retrievePassword
();
}
});
panel
.
add
(
retrievePasswordButton
);
JButton
loginButton
=
new
JButton
(
"返回登录"
);
loginButton
.
setBounds
(
320
,
250
,
100
,
30
);
loginButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
frame
.
dispose
();
new
LoginView
();
}
});
panel
.
add
(
loginButton
);
this
.
setContentPane
(
panel
);
this
.
setVisible
(
true
);
}
private
void
retrievePassword
(){
String
account
=
accountTextField
.
getText
().
trim
();
String
verifyCode
=
verifyCodeTextField
.
getText
().
trim
();
resetPasswordController
.
resetPassword
(
frame
,
account
,
verifyCode
,
verifyCodeText
);
// if(account.trim().equals("")){
// JOptionPane.showMessageDialog(
// frame,
// "账号不能为空",
// "温馨提示",
// JOptionPane.INFORMATION_MESSAGE
// );
// return;
// }
// AccountClass accountClass = accountData.getObjectByAccount(account);;
// if(accountClass == null){
// JOptionPane.showMessageDialog(
// frame,
// "该账号不存在",
// "温馨提示",
// JOptionPane.INFORMATION_MESSAGE
// );
// return;
// }
// String newPassword = PasswordUtil.newPassword();
// accountClass.setPassword(newPassword);
// accountData.editObject(accountClass);
// newPasswordContentLabel.setText(newPassword);
// JOptionPane.showMessageDialog(
// frame,
// "密码已找回",
// "温馨提示",
// JOptionPane.INFORMATION_MESSAGE
// );
}
}
src/com/ubitsgroup/view/main/admin/MainAdminView.java
0 → 100644
浏览文件 @
0663d7a8
package
com.ubitsgroup.view.main.admin
;
import
javax.swing.*
;
public
class
MainAdminView
extends
JFrame
{
JFrame
frame
;
JPanel
panel
;
public
MainAdminView
()
{
initData
();
initJFrame
();
// initMenuBar();
// initPanel();
// initView();
}
private
void
initData
(){
}
private
void
initJFrame
(){
frame
=
this
;
this
.
setTitle
(
"主界面"
);
this
.
setIconImage
(
new
ImageIcon
(
"img/icon.png"
).
getImage
());
this
.
setSize
(
900
,
600
);
this
.
setLocationRelativeTo
(
null
);
this
.
setResizable
(
false
);
this
.
setDefaultCloseOperation
(
WindowConstants
.
EXIT_ON_CLOSE
);
}
}
src/com/ubitsgroup/view/main/admin/MainView.java
已删除
100644 → 0
浏览文件 @
84a24993
package
com.ubitsgroup.view.main.admin
;
public
class
MainView
{
}
src/com/ubitsgroup/view/main/student/MainView.java
→
src/com/ubitsgroup/view/main/student/Main
Student
View.java
浏览文件 @
0663d7a8
package
com.ubitsgroup.view.main.student
;
public
class
MainView
{
import
javax.swing.*
;
public
class
MainStudentView
extends
JFrame
{
}
src/com/ubitsgroup/view/main/teacher/MainView.java
→
src/com/ubitsgroup/view/main/teacher/Main
Teacher
View.java
浏览文件 @
0663d7a8
package
com.ubitsgroup.view.main.teacher
;
public
class
MainView
{
import
javax.swing.*
;
public
class
MainTeacherView
extends
JFrame
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录