title: What's the advantage of create interface and implement it instead of do all code in controller in spring boot?
body: <p>like this
  <br></p>
  <pre><code>package com.levent.consultantapi.service;
  
  import java.util.List;
  
  import com.levent.consultantapi.model.Consultant;
  
  public interface ConsultantService {
      
      List&lt;Consultant&gt; getConsultants();
      Consultant createConsultant(Consultant consultant);
      Consultant getConsultantById(Long id);
      Consultant updateConsultantById(Long id, Consultant consultant);
      Consultant deleteConsultantById(Long id);
  
  }
  </code></pre>
  <br>
  <pre><code>
  package com.levent.consultantapi.service.consultant.impl;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import com.levent.consultantapi.model.Consultant;
  import com.levent.consultantapi.repository.ConsultantRepository;
  import com.levent.consultantapi.service.ConsultantService;
  
  @Service
  public class ConsultantServiceImpl implements ConsultantService {
      
      @Autowired
      private ConsultantRepository consultantRepository;
      
      @Override
      public List&lt;Consultant&gt; getConsultants() {
          return consultantRepository.list();
      }
  
      @Override
      public Consultant createConsultant(Consultant consultant) {
          return consultantRepository.create(consultant);
      }
  
      @Override
      public Consultant getConsultantById(Long id) {
          return consultantRepository.get(id);
      }
  
      @Override
      public Consultant updateConsultantById(Long id, Consultant consultant) {
          return consultantRepository.update(id, consultant);
      }
  
      @Override
      public Consultant deleteConsultantById(Long id) {
          return consultantRepository.delete(id);
      }
  
  }
  
  </code></pre>
  <p>What's the advantage of doing this and we can do it without interface only class of service?
  <br>
  what's about doing all code in controller?
  <br></p>
  <p>/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</p>