99public class Controller {
1010
1111 private ApplicationContext context ;
12- private UserDAO userJDBCTemplate ;
12+ private UserDAO userDAO ;
1313
1414 public Controller () {
1515 this .context = new AnnotationConfigApplicationContext (Configurations .class );
16- this .userJDBCTemplate = context .getBean (UserDAO .class );
16+ this .userDAO = context .getBean (UserDAO .class );
1717
1818 }
1919
2020 @ GetMapping (value = "/Users" )
2121 public String viewUsers () {
2222
23- List <User > users = userJDBCTemplate .viewAllUsers ();
23+ List <User > users = userDAO .viewAllUsers ();
2424 if (users != null ) {
2525 return new Gson ().toJson (users );
2626 }
@@ -46,7 +46,7 @@ public String createUsers(@RequestParam(value = "userName", defaultValue = " ")
4646 System .out .println ("password cannot exceed 20 characters" );
4747 return "password cannot exceed 20 characters" ;
4848 } else {
49- userJDBCTemplate .create (user );
49+ userDAO .create (user );
5050 return "created new user" ;
5151 }
5252
@@ -57,14 +57,14 @@ public String updatePassword(@RequestParam(value = "id", defaultValue = " ") int
5757 @ RequestParam (value = "opassword" , defaultValue = " " ) String oldPassword ,
5858 @ RequestParam (value = "npassword" , defaultValue = " " ) String newPassword ) {
5959
60- return userJDBCTemplate .updatePassword (id , oldPassword , newPassword );
60+ return userDAO .updatePassword (id , oldPassword , newPassword );
6161
6262 }
6363
6464 @ DeleteMapping ("/Users" )
6565 public String deleteUser (@ RequestParam (value = "id" , defaultValue = " " ) int id ) {
6666
67- return userJDBCTemplate .deleteUser (id );
67+ return userDAO .deleteUser (id );
6868 }
6969}
7070
0 commit comments