package garbagetown.domain.service.customer;

import garbagetown.domain.model.Customer;
import garbagetown.domain.repository.CustomerRepository;
import garbagetown.domain.service.customer.CustomerService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.terasoluna.gfw.common.sequencer.Sequencer;

import javax.inject.Inject;
import javax.transaction.Transactional;

/**
 * Created by garbagetown on 10/10/15.
 */
@Transactional
@Service
public class CustomerServiceImpl implements CustomerService {

    @Inject
    CustomerRepository repository;

    @Inject
    Sequencer<String> customerCodeSeq;

    @Inject
    PasswordEncoder passwordEncoder;

    @Override
    public Customer findOne(String customerCode) {
        return repository.findOne(customerCode);
    }

    @Override
    public Customer register(Customer customer, String rawPassword) {
        String customerCode = customerCodeSeq.getNext();
        String password = passwordEncoder.encode(rawPassword);

        customer.setCustomerCode(customerCode);
        customer.setCustomerPass(password);

        return repository.save(customer);
    }
}

@@ -142,68 +142,8 @@
 ry;%0A
-import garbagetown.domain.service.customer.CustomerService;%0A
 impo
@@ -203,24 +203,24 @@
 ordEncoder;%0A
+
 import org.s
@@ -547,17 +547,25 @@
 ository 
-r
+customerR
 epositor
@@ -742,33 +742,41 @@
 %0A        return 
-r
+customerR
 epository.findOn
@@ -1112,17 +1112,25 @@
  return 
-r
+customerR
 epositor

refactor a field name