Advertisement
ballchaichana

configAdmin

Nov 16th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. package th.in.oneauthen.admin;
  2.  
  3. import java.io.IOException;
  4. import th.in.oneauthen.object.UserUidDB;
  5. import th.in.oneauthen.object.DAO.UserUidDAO;
  6.  
  7. import javax.servlet.ServletException;
  8. import javax.servlet.http.HttpServlet;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11.  
  12. public class configAdmin extends HttpServlet {
  13.    
  14.     /**
  15.      *
  16.      */
  17.     private static final long serialVersionUID = 1L;
  18.     public static final String QUERY_LIMIT = "Limit";
  19.    
  20.     public static final String REQUEST_QUERY = "view";
  21.     public  String selectQuery = "view";
  22.    
  23.     public static final String ID = "id";
  24.     public static final String EMAIL = "email";
  25.    
  26.     public static final String TYPE = "type";
  27.  
  28.     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  29.        
  30.         selectQuery = request.getParameter(REQUEST_QUERY);
  31.        
  32.        
  33.         switch (selectQuery) {
  34.         case "editEmail" :
  35.             String idStr = request.getParameter(ID);
  36.             String email = request.getParameter(EMAIL);
  37.             int id = Integer.parseInt(idStr);
  38.             try {
  39.                 UserUidDB user = new UserUidDAO().find(id);
  40.                 user.setOneEmail(email);
  41.                
  42.                 new UserUidDAO().updateAttrEmail(user);
  43.                
  44.             } catch (Exception e) {
  45.                 // TODO Auto-generated catch block
  46.                 e.printStackTrace();
  47.             }
  48.  
  49.             break;
  50.            
  51.         case "editEmailAndType" :
  52.             String idString = request.getParameter(ID);
  53.             String type = request.getParameter(TYPE);
  54.             int idUser = Integer.parseInt(idString);
  55.             try {
  56.                 UserUidDB user = new UserUidDAO().find(idUser);
  57.                 user.setType(type);
  58.                
  59.                 new UserUidDAO().updateAttrType(user);
  60.                
  61.             } catch (Exception e) {
  62.                 // TODO Auto-generated catch block
  63.                 e.printStackTrace();
  64.             }
  65.  
  66.             break;
  67.            
  68.            
  69.            
  70.            
  71.         }
  72.  
  73.          
  74.     }
  75.  
  76.        
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement