package ua.com.jpy.controllers.profile;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import ua.com.jpy.entity.customer.Customer;
import ua.com.jpy.services.customer.ICustomerService;
/**
* @author LSD25
*
*/
@Controller
@SessionAttributes({ "customer" })
@RequestMapping(value = "/customer")
public class CustomerController {
private static final Log log = LogFactory.getLog(CustomerController.class);
@Autowired
private ICustomerService customerService;
@SuppressWarnings("deprecation")
@RequestMapping(value = "/profile", method = RequestMethod.GET)
public String profile(ModelMap modelMap) {
Customer customer = customerService.getCurrentCustomer();
if(customer != null) {
modelMap.addAttribute(customer);
modelMap.addObject(customer);
log.info("Customer found, login: " + customer.getLogin());
} else {
log.info("Customer was not found");
}
return "profile";
}
}