Browse Source

上传文件至 'code/springboot/newBank/src/main/java/demo/zhangjialei/controller'

20241111提交修改
test
tangxinyuan 5 months ago
parent
commit
8b6675d178
  1. 2
      code/springboot/newBank/src/main/java/demo/zhangjialei/controller/makeNo.java
  2. 56
      code/springboot/newBank/src/main/java/demo/zhangjialei/controller/userController.java

2
code/springboot/newBank/src/main/java/demo/zhangjialei/controller/makeNo.java

@ -1,4 +1,4 @@
package demo; package demo.zhangjialei.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;

56
code/springboot/newBank/src/main/java/demo/zhangjialei/controller/userController.java

@ -136,5 +136,61 @@ public class userController {
// userNo=0003&passwd=123123&userName=Alex123&gender=3&birthday=20001010&docType=身份证&docNo=123123123&tel=123123123&addr=广西来宾 // userNo=0003&passwd=123123&userName=Alex123&gender=3&birthday=20001010&docType=身份证&docNo=123123123&tel=123123123&addr=广西来宾
} }
// 客户注销
@RequestMapping("/delUser")
public int delUser(HttpServletRequest request) {
// 接收要注销得客户编号
String userNo = request.getParameter("userdNo");
// 向数据库中查询编号是否存在
String sql_sel = String.format("select * from user where userNo = %s", userNo);
List<Map<String, Object>> sel_res = jdbcTemplate.queryForList(sql_sel);
if (sel_res.size() > 0){ // 查询结果大于 1 该如何处置?
// 在数据库中删除改客户编号对应数据
String sql_del = String.format("delete from user where userNo = %s", userNo);
return jdbcTemplate.update(sql_del);
} else {
// 编号不存在 返回 0
return 0;
}
// http://localhost:12709/delUser?userNo=9900
}
// 客户登录
@RequestMapping("/userLogin")
public int userLogin(HttpServletRequest request) {
// 接收客户编号和密码
String userNo = request.getParameter("userdNo");
String passwd_input = request.getParameter("passwd");
// 向数据库中查询编号是否存在
String sql_sel = String.format("select * from user where userNo = %s", userNo);
List<Map<String, Object>> sel_res = jdbcTemplate.queryForList(sql_sel);
System.out.println(sel_res);
if (sel_res.size() != 0){
// 正确密码
String passwd_true = (String) sel_res.get(0).get("passwd");
// 判断密码是否正确
if (passwd_input.equals(passwd_true)) {
// 密码正确 登录成功
return 1;
} else {
// 密码错误 登录失败
return 0;
}
} else {
// 编号不存在
return 0;
}
// 存在安全隐患
// http://localhost:12709/userLogin?userNo=9999&passwd=123456
}
} }
Loading…
Cancel
Save