// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
//     @GET
//     @Path("/customer/:id")
//     CustomerView get(@PathParam("id") Long id);
// 
//     @POST
//     @Path("/customer")
//     @ResponseStatus(HTTPStatus.CREATED)
//     CustomerView create(CreateCustomerRequest request);
// 
//     @PUT
//     @Path("/customer/:id")
//     CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
// 
//     @GET
//     @Path("/customer")
//     SearchCustomerResponse search(SearchCustomerRequest request);
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
//     @NotNull
//     @NotBlank
//     @Property(name = "email")
//     public String email;
// 
//     @NotNull
//     @NotBlank
//     @Property(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Property(name = "last_name")
//     public String lastName;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
//     @NotNull
//     @Property(name = "id")
//     public Long id;
// 
//     @NotNull
//     @NotBlank
//     @Property(name = "email")
//     public String email;
// 
//     @NotNull
//     @NotBlank
//     @Property(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Property(name = "last_name")
//     public String lastName;
// 
//     @NotNull
//     @Property(name = "updated_time")
//     public LocalDateTime updatedTime;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
//     @NotNull
//     @QueryParam(name = "skip")
//     public Integer skip = 0;
// 
//     @NotNull
//     @QueryParam(name = "limit")
//     public Integer limit = 1000;
// 
//     @QueryParam(name = "email")
//     public String email;
// 
//     @QueryParam(name = "first_name")
//     public String firstName;
// 
//     @QueryParam(name = "last_name")
//     public String lastName;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
//     @Property(name = "total")
//     public Long total;
// 
//     @Property(name = "customers")
//     public List<CustomerView> customers;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
//     @NotNull
//     @NotBlank
//     @Property(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Property(name = "last_name")
//     public String lastName;
// }
// 
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
//     @Inject
//     Repository<Customer> customerRepository;
// 
//     public CustomerView get(Long id) {
//         Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
//         return view(customer);
//     }
// 
//     public CustomerView create(CreateCustomerRequest request) {
//         Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
//         if (existingCustomer.isPresent()) {
//             throw new ConflictException("customer already exists, email=" + request.email);
//         }
// 
//         Customer customer = new Customer();
//         customer.status = CustomerStatus.ACTIVE;
//         customer.email = request.email;
//         customer.firstName = request.firstName;
//         customer.lastName = request.lastName;
//         customer.updatedTime = LocalDateTime.now();
//         customer.id = customerRepository.insert(customer).orElseThrow();
// 
//         return view(customer);
//     }
// 
//     public CustomerView update(Long id, UpdateCustomerRequest request) {
//         Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
//         customer.updatedTime = LocalDateTime.now();
//         customer.firstName = request.firstName;
//         if (request.lastName != null) {
//             customer.lastName = request.lastName;
//         }
//         customerRepository.partialUpdate(customer);
//         return view(customer);
//     }
// 
//     public SearchCustomerResponse search(SearchCustomerRequest request) {
//         SearchCustomerResponse result = new SearchCustomerResponse();
//         Query<Customer> query = customerRepository.select();
//         query.skip(request.skip);
//         query.limit(request.limit);
//         if (!Strings.isBlank(request.email)) {
//             query.where("email = ?", request.email);
//         }
//         if (!Strings.isBlank(request.firstName)) {
//             query.where("first_name like ?", Strings.format("{}%", request.firstName));
//         }
//         if (!Strings.isBlank(request.lastName)) {
//             query.where("last_name like ?", Strings.format("{}%", request.lastName));
//         }
//         result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
//         result.total = query.count();
// 
//         return result;
//     }
// 
//     private CustomerView view(Customer customer) {
//         CustomerView result = new CustomerView();
//         result.id = customer.id;
//         result.email = customer.email;
//         result.firstName = customer.firstName;
//         result.lastName = customer.lastName;
//         result.updatedTime = customer.updatedTime;
//         return result;
//     }
// }


import app.demo.api.CustomerWebService;
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.service.CustomerService;
import core.framework.inject.Inject;
package app.demo.customer.web;


public class CustomerWebServiceImpl implements CustomerWebService {
    @Inject
    CustomerService customerService;

    @Override
// Path: demo-service-interface/src/main/java/app/demo/api/CustomerWebService.java
// public interface CustomerWebService {
//     @GET
//     @Path("/customer/:id")
//     CustomerView get(@PathParam("id") Long id);
// 
//     @POST
//     @Path("/customer")
//     @ResponseStatus(HTTPStatus.CREATED)
//     CustomerView create(CreateCustomerRequest request);
// 
//     @PUT
//     @Path("/customer/:id")
//     CustomerView update(@PathParam("id") Long id, UpdateCustomerRequest request);
// 
//     @GET
//     @Path("/customer")
//     SearchCustomerResponse search(SearchCustomerRequest request);
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CreateCustomerRequest.java
// public class CreateCustomerRequest {
//     @NotNull
//     @NotBlank
//     @Property(name = "email")
//     public String email;
// 
//     @NotNull
//     @NotBlank
//     @Property(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Property(name = "last_name")
//     public String lastName;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/CustomerView.java
// public class CustomerView {
//     @NotNull
//     @Property(name = "id")
//     public Long id;
// 
//     @NotNull
//     @NotBlank
//     @Property(name = "email")
//     public String email;
// 
//     @NotNull
//     @NotBlank
//     @Property(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Property(name = "last_name")
//     public String lastName;
// 
//     @NotNull
//     @Property(name = "updated_time")
//     public LocalDateTime updatedTime;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerRequest.java
// public class SearchCustomerRequest {
//     @NotNull
//     @QueryParam(name = "skip")
//     public Integer skip = 0;
// 
//     @NotNull
//     @QueryParam(name = "limit")
//     public Integer limit = 1000;
// 
//     @QueryParam(name = "email")
//     public String email;
// 
//     @QueryParam(name = "first_name")
//     public String firstName;
// 
//     @QueryParam(name = "last_name")
//     public String lastName;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/SearchCustomerResponse.java
// public class SearchCustomerResponse {
//     @Property(name = "total")
//     public Long total;
// 
//     @Property(name = "customers")
//     public List<CustomerView> customers;
// }
// 
// Path: demo-service-interface/src/main/java/app/demo/api/customer/UpdateCustomerRequest.java
// public class UpdateCustomerRequest {
//     @NotNull
//     @NotBlank
//     @Property(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Property(name = "last_name")
//     public String lastName;
// }
// 
// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
// public class CustomerService {
//     @Inject
//     Repository<Customer> customerRepository;
// 
//     public CustomerView get(Long id) {
//         Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
//         return view(customer);
//     }
// 
//     public CustomerView create(CreateCustomerRequest request) {
//         Optional<Customer> existingCustomer = customerRepository.selectOne("email = ?", request.email);
//         if (existingCustomer.isPresent()) {
//             throw new ConflictException("customer already exists, email=" + request.email);
//         }
// 
//         Customer customer = new Customer();
//         customer.status = CustomerStatus.ACTIVE;
//         customer.email = request.email;
//         customer.firstName = request.firstName;
//         customer.lastName = request.lastName;
//         customer.updatedTime = LocalDateTime.now();
//         customer.id = customerRepository.insert(customer).orElseThrow();
// 
//         return view(customer);
//     }
// 
//     public CustomerView update(Long id, UpdateCustomerRequest request) {
//         Customer customer = customerRepository.get(id).orElseThrow(() -> new NotFoundException("customer not found, id=" + id));
//         customer.updatedTime = LocalDateTime.now();
//         customer.firstName = request.firstName;
//         if (request.lastName != null) {
//             customer.lastName = request.lastName;
//         }
//         customerRepository.partialUpdate(customer);
//         return view(customer);
//     }
// 
//     public SearchCustomerResponse search(SearchCustomerRequest request) {
//         SearchCustomerResponse result = new SearchCustomerResponse();
//         Query<Customer> query = customerRepository.select();
//         query.skip(request.skip);
//         query.limit(request.limit);
//         if (!Strings.isBlank(request.email)) {
//             query.where("email = ?", request.email);
//         }
//         if (!Strings.isBlank(request.firstName)) {
//             query.where("first_name like ?", Strings.format("{}%", request.firstName));
//         }
//         if (!Strings.isBlank(request.lastName)) {
//             query.where("last_name like ?", Strings.format("{}%", request.lastName));
//         }
//         result.customers = query.fetch().stream().map(this::view).collect(Collectors.toList());
//         result.total = query.count();
// 
//         return result;
//     }
// 
//     private CustomerView view(Customer customer) {
//         CustomerView result = new CustomerView();
//         result.id = customer.id;
//         result.email = customer.email;
//         result.firstName = customer.firstName;
//         result.lastName = customer.lastName;
//         result.updatedTime = customer.updatedTime;
//         return result;
//     }
// }


// Path: demo-service/src/main/java/app/demo/customer/web/CustomerWebServiceImpl.java
import app.demo.api.CustomerWebService;
import app.demo.api.customer.CreateCustomerRequest;
import app.demo.api.customer.CustomerView;
import app.demo.api.customer.SearchCustomerRequest;
import app.demo.api.customer.SearchCustomerResponse;
import app.demo.api.customer.UpdateCustomerRequest;
import app.demo.customer.service.CustomerService;
import core.framework.inject.Inject;

package app.demo.customer.web;


public class CustomerWebServiceImpl implements CustomerWebService {
    @Inject
    CustomerService customerService;

    @Override
    public CustomerView get(Long id) {