// 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/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
//     @PrimaryKey(autoIncrement = true)
//     @Column(name = "id")
//     public Long id;
// 
//     @NotNull
//     @Column(name = "status")
//     public CustomerStatus status;
// 
//     @NotNull
//     @NotBlank
//     @Column(name = "email")
//     public String email;
// 
//     @NotNull
//     @NotBlank
//     @Column(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Column(name = "last_name")
//     public String lastName;
// 
//     @NotNull
//     @Column(name = "updated_time")
//     public LocalDateTime updatedTime;
// }
// 
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
//     @DBEnumValue("ACTIVE")
//     ACTIVE,
//     @DBEnumValue("INACTIVE")
//     INACTIVE
// }


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.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;
package app.demo.customer.service;



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);
        }

// 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/domain/Customer.java
// @Table(name = "customer")
// public class Customer {
//     @PrimaryKey(autoIncrement = true)
//     @Column(name = "id")
//     public Long id;
// 
//     @NotNull
//     @Column(name = "status")
//     public CustomerStatus status;
// 
//     @NotNull
//     @NotBlank
//     @Column(name = "email")
//     public String email;
// 
//     @NotNull
//     @NotBlank
//     @Column(name = "first_name")
//     public String firstName;
// 
//     @NotBlank
//     @Column(name = "last_name")
//     public String lastName;
// 
//     @NotNull
//     @Column(name = "updated_time")
//     public LocalDateTime updatedTime;
// }
// 
// Path: demo-service/src/main/java/app/demo/customer/domain/CustomerStatus.java
// public enum CustomerStatus {
//     @DBEnumValue("ACTIVE")
//     ACTIVE,
//     @DBEnumValue("INACTIVE")
//     INACTIVE
// }


// Path: demo-service/src/main/java/app/demo/customer/service/CustomerService.java
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.domain.Customer;
import app.demo.customer.domain.CustomerStatus;
import core.framework.db.Query;
import core.framework.db.Repository;
import core.framework.inject.Inject;
import core.framework.util.Strings;
import core.framework.web.exception.ConflictException;
import core.framework.web.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Optional;
import java.util.stream.Collectors;

package app.demo.customer.service;



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();