From 61a592ba01d2ddb29b5c75df83ed0ffae288bf46 Mon Sep 17 00:00:00 2001
From: Jack <jack.su@pollex.com.tw>
Date: 星期三, 10 十一月 2021 15:14:05 +0800
Subject: [PATCH] [ADD] 預約前詢問API [ADD] 顧問登入取得所屬全部的預約單API

---
 pamapi/src/main/java/com/pollex/pam/domain/Customer.java                              |  101 +++++
 pamapi/src/doc/預約單/預約前詢問.txt                                                          |   22 +
 pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java                  |    6 
 pamapi/src/doc/預約單/顧問取得所有自己的預約單API                                                    |   40 ++
 pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java                 |   24 +
 pamapi/src/main/java/com/pollex/pam/repository/AppointmentCustomerViewRepository.java |   15 
 pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java             |   27 +
 pamapi/src/main/java/com/pollex/pam/domain/Appointment.java                           |  186 +++++++++
 pamapi/src/main/java/com/pollex/pam/security/SecurityUtils.java                       |   22 +
 pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCreateDTO.java             |   80 ++++
 pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java       |  120 ++++++
 pamapi/src/main/java/com/pollex/pam/domain/AppointmentCustomerView.java               |  193 ++++++++++
 pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java                   |   37 +
 pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java                    |   24 +
 pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentDTOMapper.java          |   18 
 pamapi/src/main/java/com/pollex/pam/repository/AppointmentRepository.java             |   15 
 pamapi/src/main/java/com/pollex/pam/repository/CustomerRepository.java                |   11 
 pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentDTO.java                   |  114 ++++++
 pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java |   28 +
 19 files changed, 1,082 insertions(+), 1 deletions(-)

diff --git "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\240\220\347\264\204\345\211\215\350\251\242\345\225\217.txt" "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\240\220\347\264\204\345\211\215\350\251\242\345\225\217.txt"
new file mode 100644
index 0000000..207a414
--- /dev/null
+++ "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\240\220\347\264\204\345\211\215\350\251\242\345\225\217.txt"
@@ -0,0 +1,22 @@
+http post :
+
+http://localhost:8080/api/appointment/customer/create
+
+
+contactType: email,phone
+gender: male, female 
+
+request body:
+
+{
+    "phone":"09123456789",
+    "email":"pollex@pollex.comm.tw",
+    "contactType":"phone",
+    "gender":"male",
+    "age":20,
+    "job":"撠����",
+    "requirement":"鞎∪����,鞈蝘餉��",
+    "hopeContactTime":"'����~�����, 12:00~14:00, 18:00~21:00'",
+    "otherRequirement":"憭馳����",
+    "agentNo":"admin"
+}
\ No newline at end of file
diff --git "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API" "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API"
new file mode 100644
index 0000000..b213145
--- /dev/null
+++ "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API"
@@ -0,0 +1,40 @@
+http get : 
+
+http://localhost:8080/api/consultant/getMyAppointment
+
+
+
+response body :
+
+[
+    {
+        "id": 11,
+        "phone": "09123456789",
+        "email": "pollex@pollex.comm.tw",
+        "contactType": "phone",
+        "gender": "male",
+        "age": 20,
+        "job": "撠����",
+        "requirement": "鞎∪����,鞈蝘餉��",
+        "communicateStatus": "picked",
+        "hopeContactTime": "'����~�����, 12:00~14:00, 18:00~21:00'",
+        "otherRequirement": "憭馳����",
+        "appointmentDate": "2021-11-10T03:17:30.586Z",
+        "agentNo": "admin"
+    },
+    {
+        "id": 12,
+        "phone": "09123456789",
+        "email": "pollex@pollex.comm.tw",
+        "contactType": "phone",
+        "gender": "male",
+        "age": 20,
+        "job": "撠����",
+        "requirement": "鞎∪����,鞈蝘餉��",
+        "communicateStatus": "reserved",
+        "hopeContactTime": "'����~�����, 12:00~14:00, 18:00~21:00'",
+        "otherRequirement": "憭馳����",
+        "appointmentDate": "2021-11-10T03:20:00.563Z",
+        "agentNo": "admin"
+    }
+]
\ No newline at end of file
diff --git a/pamapi/src/main/java/com/pollex/pam/domain/Appointment.java b/pamapi/src/main/java/com/pollex/pam/domain/Appointment.java
new file mode 100644
index 0000000..c614e81
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/domain/Appointment.java
@@ -0,0 +1,186 @@
+package com.pollex.pam.domain;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.pollex.pam.enums.ContactStatusEnum;
+
+@Entity
+@Table(name = "appointment")
+public class Appointment implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	@Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+	
+	@Column(name = "phone")
+    private String phone;
+	
+	@Column(name = "email")
+    private String email;
+	
+	@Column(name = "contact_type")
+    private String contactType;
+	
+	@Column(name = "gender")
+    private String gender;
+	
+	@Column(name = "age")
+    private int age;
+	
+	@Column(name = "job")
+    private String job;
+	
+	@Column(name = "requirement")
+    private String requirement;
+	
+	@Enumerated(EnumType.STRING)
+	@Column(name = "communicate_status")
+    private ContactStatusEnum communicateStatus;
+	
+	@Column(name = "hope_contact_time")
+    private String hopeContactTime;
+	
+	@Column(name = "other_requirement")
+    private String otherRequirement;
+	
+	@Column(name = "appointment_date")
+    private Instant appointmentDate = Instant.now();
+	
+	@Column(name = "agent_no")
+    private String agentNo;
+	
+	@Column(name = "customer_id")
+    private Long customerId;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getPhone() {
+		return phone;
+	}
+
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public String getContactType() {
+		return contactType;
+	}
+
+	public void setContactType(String contactType) {
+		this.contactType = contactType;
+	}
+
+	public String getGender() {
+		return gender;
+	}
+
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+
+	public int getAge() {
+		return age;
+	}
+
+	public void setAge(int age) {
+		this.age = age;
+	}
+
+	public String getJob() {
+		return job;
+	}
+
+	public void setJob(String job) {
+		this.job = job;
+	}
+
+	public String getRequirement() {
+		return requirement;
+	}
+
+	public void setRequirement(String requirement) {
+		this.requirement = requirement;
+	}
+
+	public String getHopeContactTime() {
+		return hopeContactTime;
+	}
+
+	public void setHopeContactTime(String hopeContactTime) {
+		this.hopeContactTime = hopeContactTime;
+	}
+
+	public String getOtherRequirement() {
+		return otherRequirement;
+	}
+
+	public void setOtherRequirement(String otherRequirement) {
+		this.otherRequirement = otherRequirement;
+	}
+
+	public Instant getAppointmentDate() {
+		return appointmentDate;
+	}
+
+	public void setAppointmentDate(Instant appointmentDate) {
+		this.appointmentDate = appointmentDate;
+	}
+
+	public String getAgentNo() {
+		return agentNo;
+	}
+
+	public void setAgentNo(String agentNo) {
+		this.agentNo = agentNo;
+	}
+
+	public ContactStatusEnum getCommunicateStatus() {
+		return communicateStatus;
+	}
+
+	public void setCommunicateStatus(ContactStatusEnum communicateStatus) {
+		this.communicateStatus = communicateStatus;
+	}
+
+	public Long getCustomerId() {
+		return customerId;
+	}
+
+	public void setCustomerId(Long customerId) {
+		this.customerId = customerId;
+	}
+	
+	
+	
+	
+	
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/domain/AppointmentCustomerView.java b/pamapi/src/main/java/com/pollex/pam/domain/AppointmentCustomerView.java
new file mode 100644
index 0000000..05268c7
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/domain/AppointmentCustomerView.java
@@ -0,0 +1,193 @@
+package com.pollex.pam.domain;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.pollex.pam.enums.ContactStatusEnum;
+
+@Entity
+@Table(name = "appointment_customer_view")
+public class AppointmentCustomerView implements Serializable {
+	
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	@Column(name = "appointment_id")
+	@Id
+	private Long id;
+	
+	@Column(name = "phone")
+    private String phone;
+	
+	@Column(name = "email")
+    private String email;
+	
+	@Column(name = "contact_type")
+    private String contactType;
+	
+	@Column(name = "gender")
+    private String gender;
+	
+	@Column(name = "age")
+    private int age;
+	
+	@Column(name = "job")
+    private String job;
+	
+	@Column(name = "requirement")
+    private String requirement;
+	
+	@Enumerated(EnumType.STRING)
+	@Column(name = "communicate_status")
+    private ContactStatusEnum communicateStatus;
+	
+	@Column(name = "hope_contact_time")
+    private String hopeContactTime;
+	
+	@Column(name = "other_requirement")
+    private String otherRequirement;
+	
+	@Column(name = "appointment_date")
+    private Instant appointmentDate;
+	
+	@Column(name = "agent_no")
+    private String agentNo;
+	
+	@Column(name = "customer_id")
+    private Long customerId;
+	
+	@Column(name = "name")
+    private String name;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getPhone() {
+		return phone;
+	}
+
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public String getContactType() {
+		return contactType;
+	}
+
+	public void setContactType(String contactType) {
+		this.contactType = contactType;
+	}
+
+	public String getGender() {
+		return gender;
+	}
+
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+
+	public int getAge() {
+		return age;
+	}
+
+	public void setAge(int age) {
+		this.age = age;
+	}
+
+	public String getJob() {
+		return job;
+	}
+
+	public void setJob(String job) {
+		this.job = job;
+	}
+
+	public String getRequirement() {
+		return requirement;
+	}
+
+	public void setRequirement(String requirement) {
+		this.requirement = requirement;
+	}
+
+	public ContactStatusEnum getCommunicateStatus() {
+		return communicateStatus;
+	}
+
+	public void setCommunicateStatus(ContactStatusEnum communicateStatus) {
+		this.communicateStatus = communicateStatus;
+	}
+
+	public String getHopeContactTime() {
+		return hopeContactTime;
+	}
+
+	public void setHopeContactTime(String hopeContactTime) {
+		this.hopeContactTime = hopeContactTime;
+	}
+
+	public String getOtherRequirement() {
+		return otherRequirement;
+	}
+
+	public void setOtherRequirement(String otherRequirement) {
+		this.otherRequirement = otherRequirement;
+	}
+
+	public Instant getAppointmentDate() {
+		return appointmentDate;
+	}
+
+	public void setAppointmentDate(Instant appointmentDate) {
+		this.appointmentDate = appointmentDate;
+	}
+
+	public String getAgentNo() {
+		return agentNo;
+	}
+
+	public void setAgentNo(String agentNo) {
+		this.agentNo = agentNo;
+	}
+
+	public Long getCustomerId() {
+		return customerId;
+	}
+
+	public void setCustomerId(Long customerId) {
+		this.customerId = customerId;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	
+	
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/domain/Customer.java b/pamapi/src/main/java/com/pollex/pam/domain/Customer.java
new file mode 100644
index 0000000..225fba6
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/domain/Customer.java
@@ -0,0 +1,101 @@
+package com.pollex.pam.domain;
+
+import java.io.Serializable;
+import java.time.Instant;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+@Entity
+@Table(name = "customer")
+public class Customer implements Serializable {
+	
+	
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	@Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+	
+	@Column(name = "name")
+    private String name;
+	
+	@Column(name = "phone")
+    private String phone;
+	
+	@Column(name = "email")
+    private String email;
+	
+	@CreatedDate
+    @Column(name = "created_date", updatable = false)
+    @JsonIgnore
+    private Instant createdDate = Instant.now();
+
+    @LastModifiedDate
+    @Column(name = "last_modified_date")
+    @JsonIgnore
+    private Instant lastModifiedDate = Instant.now();
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getPhone() {
+		return phone;
+	}
+
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public Instant getCreatedDate() {
+		return createdDate;
+	}
+
+	public void setCreatedDate(Instant createdDate) {
+		this.createdDate = createdDate;
+	}
+
+	public Instant getLastModifiedDate() {
+		return lastModifiedDate;
+	}
+
+	public void setLastModifiedDate(Instant lastModifiedDate) {
+		this.lastModifiedDate = lastModifiedDate;
+	}
+    
+    
+
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/repository/AppointmentCustomerViewRepository.java b/pamapi/src/main/java/com/pollex/pam/repository/AppointmentCustomerViewRepository.java
new file mode 100644
index 0000000..0e39bd0
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/repository/AppointmentCustomerViewRepository.java
@@ -0,0 +1,15 @@
+package com.pollex.pam.repository;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import com.pollex.pam.domain.AppointmentCustomerView;
+
+@Repository
+public interface AppointmentCustomerViewRepository extends JpaRepository<AppointmentCustomerView, Long>{
+
+	List<AppointmentCustomerView> findByAgentNo(String agentNo);
+	
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/repository/AppointmentRepository.java b/pamapi/src/main/java/com/pollex/pam/repository/AppointmentRepository.java
new file mode 100644
index 0000000..245fde3
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/repository/AppointmentRepository.java
@@ -0,0 +1,15 @@
+package com.pollex.pam.repository;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import com.pollex.pam.domain.Appointment;
+
+@Repository
+public interface AppointmentRepository extends JpaRepository<Appointment, Long>{
+
+	List<Appointment> findByAgentNo(String agentNo);
+
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/repository/CustomerRepository.java b/pamapi/src/main/java/com/pollex/pam/repository/CustomerRepository.java
new file mode 100644
index 0000000..c4b87cf
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/repository/CustomerRepository.java
@@ -0,0 +1,11 @@
+package com.pollex.pam.repository;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import com.pollex.pam.domain.Customer;
+
+@Repository
+public interface CustomerRepository extends JpaRepository<Customer, Long>{
+
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/security/SecurityUtils.java b/pamapi/src/main/java/com/pollex/pam/security/SecurityUtils.java
index 2e170c5..ef4095a 100644
--- a/pamapi/src/main/java/com/pollex/pam/security/SecurityUtils.java
+++ b/pamapi/src/main/java/com/pollex/pam/security/SecurityUtils.java
@@ -1,8 +1,10 @@
 package com.pollex.pam.security;
 
 import java.util.Arrays;
+import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Stream;
+
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.context.SecurityContext;
@@ -97,4 +99,24 @@
     private static Stream<String> getAuthorities(Authentication authentication) {
         return authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority);
     }
+    
+    public static String getAgentNo() {
+    	return getCurrentUserLogin().orElseGet(null);
+    }
+    
+    // todo , should get id from user details
+    public static Long getCustomerId() {
+//    	Map<String, String> userDetails = getCurrentUserDetails();
+//    	return Long.parseLong(userDetails.get("id"));
+    	return Long.parseLong("2");
+    }
+    
+    public static Map<String, String> getCurrentUserDetails() {
+   	 SecurityContext securityContext = SecurityContextHolder.getContext();
+   	 if(securityContext.getAuthentication()==null ||
+   			 securityContext.getAuthentication().getDetails() ==null) {
+   		 return null;
+   	 }
+   	 return (Map<String, String>) securityContext.getAuthentication().getDetails();
+   }
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
new file mode 100644
index 0000000..3aba678
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -0,0 +1,37 @@
+package com.pollex.pam.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.pollex.pam.domain.Appointment;
+import com.pollex.pam.enums.ContactStatusEnum;
+import com.pollex.pam.repository.AppointmentRepository;
+import com.pollex.pam.security.SecurityUtils;
+import com.pollex.pam.service.dto.AppointmentCreateDTO;
+import com.pollex.pam.service.mapper.AppointmentDTOMapper;
+import com.pollex.pam.service.mapper.AppointmentMapper;
+
+@Service
+public class AppointmentService {
+	
+	@Autowired
+	AppointmentRepository appointmentRepository;
+	
+	@Autowired
+	AppointmentDTOMapper appointmentDTOMapper;
+	
+	
+	public void customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
+		Appointment appointment = appointmentDTOMapper.toAppointment(appointmentCreateDTO);
+		appointment.setCustomerId(SecurityUtils.getCustomerId());
+		appointment.setCommunicateStatus(ContactStatusEnum.RESERVED);
+		appointmentRepository.save(appointment);
+	}
+
+
+	public List<Appointment> findByAgentNo(String agentNo) {
+		return appointmentRepository.findByAgentNo(agentNo);
+	}
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
index b9fbf53..96a6383 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -1,17 +1,24 @@
 package com.pollex.pam.service;
 
+import com.pollex.pam.domain.Appointment;
+import com.pollex.pam.domain.AppointmentCustomerView;
 import com.pollex.pam.domain.Consultant;
 import com.pollex.pam.domain.CustomFavoriteConsultant;
 import com.pollex.pam.domain.User;
 import com.pollex.pam.enums.ContactStatusEnum;
+import com.pollex.pam.repository.AppointmentCustomerViewRepository;
 import com.pollex.pam.repository.ConsultantRepository;
 import com.pollex.pam.repository.CustomFavoriteConsultantRepository;
+import com.pollex.pam.security.SecurityUtils;
 import com.pollex.pam.service.dto.*;
+import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper;
+import com.pollex.pam.service.mapper.AppointmentMapper;
 import com.pollex.pam.service.mapper.ConsultantMapper;
 import com.pollex.pam.web.rest.errors.ConsultantNotFoundException;
 import com.pollex.pam.web.rest.errors.NotLoginException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -28,7 +35,16 @@
     private final CustomFavoriteConsultantRepository customFavoriteConsultantRepository;
     private final ConsultantMapper consultantMapper;
     private final UserService userService;
-
+    
+    @Autowired
+    AppointmentService appointmentService;
+    
+    @Autowired
+    AppointmentCustomerViewRepository appointmentCustomerViewRepository;
+    
+    @Autowired
+    AppointmentCustomerViewMapper appointmentCustomerViewMapper;
+    
     public ConsultantService(
         ConsultantRepository consultantRepository,
         CustomFavoriteConsultantRepository customFavoriteConsultantRepository,
@@ -97,4 +113,10 @@
         });
 
     }
+
+	public List<AppointmentCustomerViewDTO> getMyAppointment() {
+		String agentNo = SecurityUtils.getAgentNo();
+		List<AppointmentCustomerView> appointmentList = appointmentCustomerViewRepository.findByAgentNo(agentNo);
+		return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentList);
+	}
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCreateDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCreateDTO.java
new file mode 100644
index 0000000..9c03b5d
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCreateDTO.java
@@ -0,0 +1,80 @@
+package com.pollex.pam.service.dto;
+
+public class AppointmentCreateDTO {
+	
+    private String phone;
+    private String email;
+    private String contactType; //�蝯⊥撘�
+    private String gender;
+    private int age;
+    private String job;
+    private String requirement;
+    private String hopeContactTime; //撣�蝯∠����
+    private String otherRequirement;
+    private String agentNo;
+    
+	public String getPhone() {
+		return phone;
+	}
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	public String getContactType() {
+		return contactType;
+	}
+	public void setContactType(String contactType) {
+		this.contactType = contactType;
+	}
+	public String getGender() {
+		return gender;
+	}
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+	public String getJob() {
+		return job;
+	}
+	public void setJob(String job) {
+		this.job = job;
+	}
+	public String getRequirement() {
+		return requirement;
+	}
+	public void setRequirement(String requirement) {
+		this.requirement = requirement;
+	}
+	public String getHopeContactTime() {
+		return hopeContactTime;
+	}
+	public void setHopeContactTime(String hopeContactTime) {
+		this.hopeContactTime = hopeContactTime;
+	}
+	public String getOtherRequirement() {
+		return otherRequirement;
+	}
+	public void setOtherRequirement(String otherRequirement) {
+		this.otherRequirement = otherRequirement;
+	}
+	public int getAge() {
+		return age;
+	}
+	public void setAge(int age) {
+		this.age = age;
+	}
+	public String getAgentNo() {
+		return agentNo;
+	}
+	public void setAgentNo(String agentNo) {
+		this.agentNo = agentNo;
+	}
+    
+    
+	
+	
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java
new file mode 100644
index 0000000..3add092
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java
@@ -0,0 +1,120 @@
+package com.pollex.pam.service.dto;
+
+import java.time.Instant;
+
+import javax.persistence.Column;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+
+import com.pollex.pam.enums.ContactStatusEnum;
+
+public class AppointmentCustomerViewDTO {
+	
+	private Long id;
+    private String phone;
+    private String email;
+    private String contactType;
+    private String gender;
+    private int age;
+    private String job;
+    private String requirement;
+    private ContactStatusEnum communicateStatus;
+    private String hopeContactTime;
+    private String otherRequirement;
+    private Instant appointmentDate;
+    private String agentNo;
+    private Long customerId;
+    private String name;
+	public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public String getPhone() {
+		return phone;
+	}
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	public String getContactType() {
+		return contactType;
+	}
+	public void setContactType(String contactType) {
+		this.contactType = contactType;
+	}
+	public String getGender() {
+		return gender;
+	}
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+	public int getAge() {
+		return age;
+	}
+	public void setAge(int age) {
+		this.age = age;
+	}
+	public String getJob() {
+		return job;
+	}
+	public void setJob(String job) {
+		this.job = job;
+	}
+	public String getRequirement() {
+		return requirement;
+	}
+	public void setRequirement(String requirement) {
+		this.requirement = requirement;
+	}
+	public ContactStatusEnum getCommunicateStatus() {
+		return communicateStatus;
+	}
+	public void setCommunicateStatus(ContactStatusEnum communicateStatus) {
+		this.communicateStatus = communicateStatus;
+	}
+	public String getHopeContactTime() {
+		return hopeContactTime;
+	}
+	public void setHopeContactTime(String hopeContactTime) {
+		this.hopeContactTime = hopeContactTime;
+	}
+	public String getOtherRequirement() {
+		return otherRequirement;
+	}
+	public void setOtherRequirement(String otherRequirement) {
+		this.otherRequirement = otherRequirement;
+	}
+	public Instant getAppointmentDate() {
+		return appointmentDate;
+	}
+	public void setAppointmentDate(Instant appointmentDate) {
+		this.appointmentDate = appointmentDate;
+	}
+	public String getAgentNo() {
+		return agentNo;
+	}
+	public void setAgentNo(String agentNo) {
+		this.agentNo = agentNo;
+	}
+	public Long getCustomerId() {
+		return customerId;
+	}
+	public void setCustomerId(Long customerId) {
+		this.customerId = customerId;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+    
+    
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentDTO.java
new file mode 100644
index 0000000..05aa7cf
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentDTO.java
@@ -0,0 +1,114 @@
+package com.pollex.pam.service.dto;
+
+import java.time.Instant;
+
+import org.springframework.stereotype.Service;
+
+import com.pollex.pam.enums.ContactStatusEnum;
+
+@Service
+public class AppointmentDTO {
+	
+	private Long id;
+    private String phone;
+    private String email;
+    private String contactType;
+    private String gender;
+    private int age;
+    private String job;
+    private String requirement;
+    private ContactStatusEnum communicateStatus;
+    private String hopeContactTime;
+    private String otherRequirement;
+    private Instant appointmentDate;
+    private String agentNo;
+    private Long customerId;
+    
+	public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public String getPhone() {
+		return phone;
+	}
+	public void setPhone(String phone) {
+		this.phone = phone;
+	}
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	public String getContactType() {
+		return contactType;
+	}
+	public void setContactType(String contactType) {
+		this.contactType = contactType;
+	}
+	public String getGender() {
+		return gender;
+	}
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+	public int getAge() {
+		return age;
+	}
+	public void setAge(int age) {
+		this.age = age;
+	}
+	public String getJob() {
+		return job;
+	}
+	public void setJob(String job) {
+		this.job = job;
+	}
+	public String getRequirement() {
+		return requirement;
+	}
+	public void setRequirement(String requirement) {
+		this.requirement = requirement;
+	}
+	public ContactStatusEnum getCommunicateStatus() {
+		return communicateStatus;
+	}
+	public void setCommunicateStatus(ContactStatusEnum communicateStatus) {
+		this.communicateStatus = communicateStatus;
+	}
+	public String getHopeContactTime() {
+		return hopeContactTime;
+	}
+	public void setHopeContactTime(String hopeContactTime) {
+		this.hopeContactTime = hopeContactTime;
+	}
+	public String getOtherRequirement() {
+		return otherRequirement;
+	}
+	public void setOtherRequirement(String otherRequirement) {
+		this.otherRequirement = otherRequirement;
+	}
+	public Instant getAppointmentDate() {
+		return appointmentDate;
+	}
+	public void setAppointmentDate(Instant appointmentDate) {
+		this.appointmentDate = appointmentDate;
+	}
+	public String getAgentNo() {
+		return agentNo;
+	}
+	public void setAgentNo(String agentNo) {
+		this.agentNo = agentNo;
+	}
+	public Long getCustomerId() {
+		return customerId;
+	}
+	public void setCustomerId(Long customerId) {
+		this.customerId = customerId;
+	}
+	
+    
+    
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java
new file mode 100644
index 0000000..185103a
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java
@@ -0,0 +1,28 @@
+package com.pollex.pam.service.mapper;
+
+import static java.util.stream.Collectors.toList;
+
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import com.pollex.pam.domain.AppointmentCustomerView;
+import com.pollex.pam.service.dto.AppointmentCustomerViewDTO;
+import com.pollex.pam.service.dto.AppointmentDTO;
+
+@Service
+public class AppointmentCustomerViewMapper {
+	
+	public AppointmentCustomerViewDTO toAppointmentCustomerViewDTO(AppointmentCustomerView source) {
+		AppointmentCustomerViewDTO target = new AppointmentCustomerViewDTO();
+		BeanUtils.copyProperties(source, target);
+		return target;
+	}
+
+	public List<AppointmentCustomerViewDTO> toAppointmentCustomerViewDTO(
+			List<AppointmentCustomerView> source) {
+		return source.stream().map(s -> toAppointmentCustomerViewDTO(s))
+				.collect(toList());
+	}
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentDTOMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentDTOMapper.java
new file mode 100644
index 0000000..4275e7a
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentDTOMapper.java
@@ -0,0 +1,18 @@
+package com.pollex.pam.service.mapper;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import com.pollex.pam.domain.Appointment;
+import com.pollex.pam.enums.ContactStatusEnum;
+import com.pollex.pam.service.dto.AppointmentCreateDTO;
+
+@Service
+public class AppointmentDTOMapper {
+	
+	public Appointment toAppointment(AppointmentCreateDTO source) {
+		Appointment target = new Appointment();
+		BeanUtils.copyProperties(source, target);
+		return target;
+	}
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
new file mode 100644
index 0000000..7b9e398
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentMapper.java
@@ -0,0 +1,27 @@
+package com.pollex.pam.service.mapper;
+
+import static java.util.stream.Collectors.toList;
+
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import com.pollex.pam.domain.Appointment;
+import com.pollex.pam.service.dto.AppointmentDTO;
+
+@Service
+public class AppointmentMapper {
+
+	public AppointmentDTO toAppointmentDTO(Appointment source) {
+		AppointmentDTO target = new AppointmentDTO();
+		BeanUtils.copyProperties(source, target);
+		return target;
+	}
+
+	public List<AppointmentDTO> toAppointmentDTO(List<Appointment> source) {
+		return source.stream()
+				.map(s -> toAppointmentDTO(s)).collect(toList());
+	}
+
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
new file mode 100644
index 0000000..34ed909
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -0,0 +1,24 @@
+package com.pollex.pam.web.rest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.pollex.pam.service.AppointmentService;
+import com.pollex.pam.service.dto.AppointmentCreateDTO;
+
+@RestController
+@RequestMapping("/api/appointment")
+public class AppointmentResource {
+	
+	@Autowired
+	AppointmentService appointmentService;
+	
+	@PostMapping("/customer/create")
+	public void clientCreateAppointment(@RequestBody AppointmentCreateDTO appointmentCreateDTO) {
+		appointmentService.customerCreateAppointment(appointmentCreateDTO);
+	}
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
index ef325c3..44e175a 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
@@ -53,4 +53,10 @@
         ConsultantDetailDTO result = consultantService.getConsultantDetail(agentNo);
         return new ResponseEntity<>(result, HttpStatus.OK);
     }
+    
+    @GetMapping("/getMyAppointment")
+    public List<AppointmentCustomerViewDTO> getMyAppointment() {
+    	return consultantService.getMyAppointment();
+    }
+    
 }

--
Gitblit v1.8.0