Ejemplo n.º 1
0
  @RequestMapping("/list")
  @ResponseBody
  public List<CustomerAddress> listAddress(HttpSession session) {
    Customer customer = (Customer) session.getAttribute("customer");
    int customerId = customer.getId();
    List<CustomerAddress> addresses =
        customerAddressMapper.getCustomerAddressByCustomerId(customerId);

    return addresses;
  }
Ejemplo n.º 2
0
  @RequestMapping("/add")
  @ResponseBody
  public CustomerAddress addAddress(
      @RequestParam String name,
      @RequestParam String address,
      @RequestParam String city,
      @RequestParam int countryCode,
      @RequestParam String postCode,
      HttpSession session) {
    Customer customer = (Customer) session.getAttribute("customer");
    int customerId = customer.getId();
    Country country = countryMapper.getCountryById(countryCode);

    CustomerAddress customerAddress =
        new CustomerAddress(
            name, address, city, country.getName(), countryCode, postCode, customerId);

    customerAddressMapper.insertCustomerAddress(customerAddress);
    return customerAddress;
  }