Map Customer JPA API
This commit is contained in:
parent
4afcb55d8a
commit
5e35060d53
@ -2,32 +2,15 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="47c3fbf4-4238-47d3-9ffa-fcd23da4e01e" name="Default Changelist" comment="">
|
<list default="true" id="47c3fbf4-4238-47d3-9ffa-fcd23da4e01e" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/view/CustomerOrderView.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/view/OrderDetailView.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/view/OrderView.kt" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/view/ProductWithOrderDetail.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/service/customer/CustomerServiceImpl.kt" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/CustomerController.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/CustomerController.kt" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/CustomerController.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/CustomerController.kt" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/OrderController.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/OrderController.kt" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/service/customer/CustomerService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/service/customer/CustomerService.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/Customer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/Customer.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/service/customer/CustomerServiceImpl.java" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/Order.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/Order.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/OrderDetail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/OrderDetail.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/Product.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/model/Product.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/repo/CustomerRepo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/repo/CustomerRepo.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/repo/OrderRepo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/repo/OrderRepo.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/service/order/OrderServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/service/order/OrderServiceImpl.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/jpa/view/Views.java" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/META-INF/jdbc.kotlin_module" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/META-INF/jdbc.kotlin_module" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/controller/CustomerController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/controller/CustomerController.class" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/controller/CustomerController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/controller/CustomerController.class" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/controller/OrderController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/controller/OrderController.class" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/service/customer/CustomerServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/service/customer/CustomerServiceImpl.class" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Customer$GENDER.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Customer$GENDER.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Customer.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Customer.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Order.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Order.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/OrderDetail.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/OrderDetail.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Product.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/model/Product.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/repo/CustomerRepo.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/repo/CustomerRepo.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/service/order/OrderServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/service/order/OrderServiceImpl.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/view/Views$Public.class" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/jpa/view/Views.class" beforeDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -39,9 +22,9 @@
|
|||||||
<list>
|
<list>
|
||||||
<option value="Interface" />
|
<option value="Interface" />
|
||||||
<option value="Kotlin Interface" />
|
<option value="Kotlin Interface" />
|
||||||
|
<option value="Class" />
|
||||||
<option value="Kotlin Class" />
|
<option value="Kotlin Class" />
|
||||||
<option value="Kotlin File" />
|
<option value="Kotlin File" />
|
||||||
<option value="Class" />
|
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -67,7 +50,7 @@
|
|||||||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
<property name="aspect.path.notification.shown" value="true" />
|
<property name="aspect.path.notification.shown" value="true" />
|
||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/utils/JsonFliter" />
|
<property name="last_opened_file_path" value="D:/projectfloder/clinic-api" />
|
||||||
<property name="restartRequiresConfirmation" value="false" />
|
<property name="restartRequiresConfirmation" value="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
@ -102,7 +85,8 @@
|
|||||||
<workItem from="1589595157824" duration="4891000" />
|
<workItem from="1589595157824" duration="4891000" />
|
||||||
<workItem from="1589600878500" duration="1425000" />
|
<workItem from="1589600878500" duration="1425000" />
|
||||||
<workItem from="1589602595035" duration="1232000" />
|
<workItem from="1589602595035" duration="1232000" />
|
||||||
<workItem from="1589605337172" duration="14720000" />
|
<workItem from="1589605337172" duration="14812000" />
|
||||||
|
<workItem from="1589690218526" duration="2731000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -118,10 +102,14 @@
|
|||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="690" y="276" key="#com.intellij.codeInsight.editorActions.RestoreReferencesDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1589601961718" />
|
<state x="690" y="276" key="#com.intellij.codeInsight.editorActions.RestoreReferencesDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1589601961718" />
|
||||||
<state x="765" y="197" key="#com.intellij.ide.util.MemberChooser" timestamp="1589624306140">
|
<state x="765" y="197" key="#com.intellij.ide.util.MemberChooser" timestamp="1589692404775">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="765" y="197" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040@0.0.1920.1040" timestamp="1589624306140" />
|
<state x="765" y="197" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040@0.0.1920.1040" timestamp="1589692404775" />
|
||||||
|
<state x="649" y="437" key="#com.intellij.refactoring.move.MoveHandler.SelectRefactoringDialog" timestamp="1589690277066">
|
||||||
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
|
</state>
|
||||||
|
<state x="649" y="437" key="#com.intellij.refactoring.move.MoveHandler.SelectRefactoringDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1589690277066" />
|
||||||
<state x="690" y="268" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1589596932250">
|
<state x="690" y="268" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1589596932250">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
@ -130,49 +118,49 @@
|
|||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="739" y="31" key="#org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1589608464352" />
|
<state x="739" y="31" key="#org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1589608464352" />
|
||||||
<state x="740" y="276" key="FileChooserDialogImpl" timestamp="1589607130837">
|
<state x="740" y="276" key="FileChooserDialogImpl" timestamp="1589690795641">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="740" y="276" key="FileChooserDialogImpl/0.0.1920.1040@0.0.1920.1040" timestamp="1589607130837" />
|
<state x="740" y="276" key="FileChooserDialogImpl/0.0.1920.1040@0.0.1920.1040" timestamp="1589690795641" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.bottom" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.0.bottom" timestamp="1589692987531">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987531" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.center" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.0.center" timestamp="1589692987530">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987530" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.left" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.0.left" timestamp="1589692987530">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987530" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.right" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.0.right" timestamp="1589692987530">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987530" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.bottom" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.1.bottom" timestamp="1589692987531">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987531" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.center" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.1.center" timestamp="1589692987531">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987531" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.left" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.1.left" timestamp="1589692987531">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987531" />
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.right" timestamp="1589624369020">
|
<state width="1877" height="420" key="GridCell.Tab.1.right" timestamp="1589692987531">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="421" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589624369020" />
|
<state width="1877" height="420" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589692987531" />
|
||||||
<state x="767" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1589538516704">
|
<state x="767" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1589538516704">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="767" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.1920.1040@0.0.1920.1040" timestamp="1589538516704" />
|
<state x="767" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.1920.1040@0.0.1920.1040" timestamp="1589538516704" />
|
||||||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1589618568164">
|
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1589692961508">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1589618568164" />
|
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1589692961508" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -2,6 +2,8 @@ package com.chantha.jdbc.controller
|
|||||||
|
|
||||||
import com.chantha.jdbc.jpa.model.Customer
|
import com.chantha.jdbc.jpa.model.Customer
|
||||||
import com.chantha.jdbc.jpa.model.Order
|
import com.chantha.jdbc.jpa.model.Order
|
||||||
|
import com.chantha.jdbc.jpa.model.view.CustomerOrderView
|
||||||
|
import com.chantha.jdbc.jpa.repo.CustomerRepo
|
||||||
import com.chantha.jdbc.jpa.service.customer.CustomerService
|
import com.chantha.jdbc.jpa.service.customer.CustomerService
|
||||||
import com.chantha.jdbc.jpa.view.ViewsInvoice
|
import com.chantha.jdbc.jpa.view.ViewsInvoice
|
||||||
import org.apache.tomcat.util.json.JSONParser
|
import org.apache.tomcat.util.json.JSONParser
|
||||||
@ -14,8 +16,9 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RestController
|
@RestController
|
||||||
class CustomerController @Autowired constructor(private val customerService: CustomerService) {
|
class CustomerController @Autowired constructor(private val customerService: CustomerService) {
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/customer")
|
@GetMapping("/customer")
|
||||||
fun customer():List<Customer>{
|
fun customer():List<CustomerOrderView>{
|
||||||
return customerService.findAll().toList()
|
return customerService.fetchAllCustomerOrder()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.chantha.jdbc.jpa.model.view;
|
||||||
|
|
||||||
|
import com.chantha.jdbc.jpa.model.Gender;
|
||||||
|
import com.chantha.jdbc.jpa.model.Order;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CustomerOrderView {
|
||||||
|
public Long getCusID() {
|
||||||
|
return cusID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCusID(Long cusID) {
|
||||||
|
this.cusID = cusID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCusName() {
|
||||||
|
return cusName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCusName(String cusName) {
|
||||||
|
this.cusName = cusName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gender getGender() {
|
||||||
|
return gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGender(Gender gender) {
|
||||||
|
this.gender = gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderView> getOrderList() {
|
||||||
|
return orderList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderList(List<OrderView> orderList) {
|
||||||
|
this.orderList = orderList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long cusID;
|
||||||
|
private String cusName;
|
||||||
|
private Gender gender;
|
||||||
|
|
||||||
|
private List<OrderView> orderList;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
13
src/main/kotlin/com/chantha/jdbc/jpa/model/view/OrderView.kt
Normal file
13
src/main/kotlin/com/chantha/jdbc/jpa/model/view/OrderView.kt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.chantha.jdbc.jpa.model.view
|
||||||
|
|
||||||
|
import com.chantha.jdbc.utils.CustomDateSerializer
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
open class OrderView{
|
||||||
|
var orderId:Long ?= 0
|
||||||
|
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MMM-dd HH:mm:ss ")
|
||||||
|
var orderDate:Date ? = Calendar.getInstance().time
|
||||||
|
var amount:Double ? = 0.0
|
||||||
|
}
|
@ -5,16 +5,7 @@ import org.springframework.data.jpa.repository.Query;
|
|||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
public interface CustomerRepo extends CrudRepository<Customer,Long> {
|
public interface CustomerRepo extends CrudRepository<Customer,Long> {
|
||||||
@Query(value = "SELECT *\n" +
|
@Query(value ="SELECT * FROM tb_customer c INNER JOIN tb_order o ON (c.id=o.cus_id)",nativeQuery = true)
|
||||||
" FROM tb_order o\n" +
|
|
||||||
" INNER JOIN order_detail od\n" +
|
|
||||||
" ON (o.order_id=od.order_id)\n" +
|
|
||||||
" INNER JOIN tb_customer c\n" +
|
|
||||||
" ON (o.cus_id=c.id)\n" +
|
|
||||||
" INNER JOIN product pro\n" +
|
|
||||||
" ON (pro.product_id=od.product_id)\n" +
|
|
||||||
"\n" +
|
|
||||||
"\t\t",nativeQuery = true)
|
|
||||||
@Override
|
@Override
|
||||||
Iterable<Customer> findAll();
|
Iterable<Customer> findAll();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package com.chantha.jdbc.jpa.service.customer;
|
package com.chantha.jdbc.jpa.service.customer;
|
||||||
|
|
||||||
|
import com.chantha.jdbc.jpa.model.view.CustomerOrderView;
|
||||||
import com.chantha.jdbc.jpa.repo.CustomerRepo;
|
import com.chantha.jdbc.jpa.repo.CustomerRepo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
public interface CustomerService extends CustomerRepo {
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public interface CustomerService {
|
||||||
|
List<CustomerOrderView> fetchAllCustomerOrder();
|
||||||
}
|
}
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
package com.chantha.jdbc.jpa.service.customer;
|
|
||||||
|
|
||||||
import com.chantha.jdbc.jpa.model.Customer;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class CustomerServiceImpl implements CustomerService {
|
|
||||||
@Override
|
|
||||||
public <S extends Customer> S save(S s) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <S extends Customer> Iterable<S> saveAll(Iterable<S> iterable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Customer> findById(Long aLong) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean existsById(Long aLong) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<Customer> findAll() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<Customer> findAllById(Iterable<Long> iterable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteById(Long aLong) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(Customer customer) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteAll(Iterable<? extends Customer> iterable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteAll() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.chantha.jdbc.jpa.service.customer
|
||||||
|
|
||||||
|
|
||||||
|
import com.chantha.jdbc.jpa.model.Customer
|
||||||
|
import com.chantha.jdbc.jpa.model.Order
|
||||||
|
import com.chantha.jdbc.jpa.model.view.CustomerOrderView
|
||||||
|
import com.chantha.jdbc.jpa.model.view.OrderDetailView
|
||||||
|
import com.chantha.jdbc.jpa.model.view.OrderView
|
||||||
|
import com.chantha.jdbc.jpa.repo.CustomerRepo
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
|
||||||
|
@Service
|
||||||
|
class CustomerServiceImpl @Autowired constructor(private val customerRepo: CustomerRepo) : CustomerService {
|
||||||
|
override fun fetchAllCustomerOrder(): List<CustomerOrderView> {
|
||||||
|
return customerRepo.findAll().map { toView(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toView(data:Customer):CustomerOrderView{
|
||||||
|
val view=CustomerOrderView()
|
||||||
|
view.cusID=data.id
|
||||||
|
view.cusName=data.cusName
|
||||||
|
view.gender=data.gender
|
||||||
|
view.orderList=data.orders.map { toCustomerOrderView(it) }
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toCustomerOrderView(data:Order):OrderView{
|
||||||
|
val view=OrderView()
|
||||||
|
view.orderId=data.orderId
|
||||||
|
view.orderDate=data.orderDate
|
||||||
|
view.amount=data.amount
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
// private fun toView(data: Product): ProductWithOrderDetail {
|
||||||
|
// val view = ProductWithOrderDetail()
|
||||||
|
// view.productId = data.productId
|
||||||
|
// view.productName = data.productName
|
||||||
|
// view.details = data.orderDetails.map { toOrderDetailView(it) }
|
||||||
|
// return view
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private fun toOrderDetailView(data: OrderDetail): OrderDetailView {
|
||||||
|
// val view = OrderDetailView()
|
||||||
|
// view.orderDetailId = data.orderDetailId
|
||||||
|
// view.price = data.price
|
||||||
|
// view.qty = data.qty
|
||||||
|
// return view
|
||||||
|
// }
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
BIN
target/classes/com/chantha/jdbc/jpa/model/view/OrderView.class
Normal file
BIN
target/classes/com/chantha/jdbc/jpa/model/view/OrderView.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user