Package com.lgx8.gateway.member.servlet

Source Code of com.lgx8.gateway.member.servlet.SetMerchantCardNumberServlet

package com.lgx8.gateway.member.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.lgx8.gateway.dao.ICardDao;
import com.lgx8.gateway.entities.Card;
import com.lgx8.right.dao.IUserDao;
import com.lgx8.right.entities.User;

/**
* Servlet implementation class SetMerchantCardNumberServlet
*/
public class SetMerchantCardNumberServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
      
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SetMerchantCardNumberServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request, response);
  }

  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String userId = request.getParameter("userId");
    String cardStart = request.getParameter("cardStart");
    String cardEnd = request.getParameter("cardEnd");
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
   
    IUserDao userDao = (IUserDao) ac.getBean("userDao");
   
    User user = userDao.findUserById(Long.parseLong(userId));
   
    PrintWriter out = response.getWriter();
   
    ICardDao cardDao = (ICardDao) ac.getBean("cardDao");
    List<Card> cards = cardDao.findCardByConditions(null, cardStart, cardEnd);
   
    if(user != null)
    {
      if(cards.size() == 0)
      {
        user.setCardStart((!"0".equals(user.getCardStart())||user.getCardStart() != null)?(user.getCardStart()+","+cardStart):cardStart);
        user.setCardEnd((!"0".equals(user.getCardEnd())||user.getCardEnd() != null)?(user.getCardEnd()+","+cardEnd):cardEnd);
       
        userDao.updateUser(user);
       
        out.println("1");
      }else
      {
        out.println("2");
      }
     
    }else
    {
      out.println("3");
    }
   
   
  }

}
TOP

Related Classes of com.lgx8.gateway.member.servlet.SetMerchantCardNumberServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.