-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from openviglet/0.3.2
0.3.2 - Ecommerce
- Loading branch information
Showing
95 changed files
with
3,319 additions
and
1,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/viglet/shiohara/api/customer/ShCustomerAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.viglet.shiohara.api.customer; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
import com.viglet.shiohara.api.ShJsonView; | ||
import com.viglet.shiohara.persistence.document.customer.ShCustomer; | ||
import com.viglet.shiohara.persistence.repository.customer.ShCustomerRepository; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
|
||
@RestController | ||
@RequestMapping("/api/v2/customer") | ||
@Api(tags = "Customer", description = "Customer API") | ||
public class ShCustomerAPI { | ||
|
||
@Autowired | ||
private ShCustomerRepository repository; | ||
|
||
@ApiOperation(value = "Customer list") | ||
@GetMapping | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public List<ShCustomer> shCustomerList() throws Exception { | ||
repository.deleteAll(); | ||
|
||
// save a couple of customers | ||
repository.save(new ShCustomer("Alice", "Smith")); | ||
repository.save(new ShCustomer("Bob", "Smith")); | ||
|
||
return repository.findByLastName("Smith"); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/com/viglet/shiohara/api/ecommerce/ShEcomOrderAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.viglet.shiohara.api.ecommerce; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
import com.viglet.shiohara.api.ShJsonView; | ||
import com.viglet.shiohara.persistence.model.ecommerce.ShEcomOrder; | ||
import com.viglet.shiohara.persistence.repository.ecommerce.ShEcomOrderRepository; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
|
||
@RestController | ||
@RequestMapping("/api/v2/ecom/order") | ||
@Api(tags = "Order", description = "Order API") | ||
public class ShEcomOrderAPI { | ||
|
||
@Autowired | ||
private ShEcomOrderRepository shEcomOrderRepository; | ||
|
||
@ApiOperation(value = "Order List") | ||
@GetMapping | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public List<ShEcomOrder> shEcomOrderList() throws Exception { | ||
return shEcomOrderRepository.findAll(); | ||
} | ||
|
||
@ApiOperation(value = "Show a Order") | ||
@GetMapping("/{id}") | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public ShEcomOrder ShEcomOrderGet(@PathVariable String id) throws Exception { | ||
return shEcomOrderRepository.findById(id).get(); | ||
} | ||
|
||
@ApiOperation(value = "Update a Order") | ||
@PutMapping("/{id}") | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public ShEcomOrder ShEcomOrderUpdate(@PathVariable String id, | ||
@RequestBody ShEcomOrder shEcomOrder) throws Exception { | ||
|
||
ShEcomOrder shEcomOrderEdit = shEcomOrderRepository.findById(id).get(); | ||
|
||
shEcomOrderEdit.setDescription(shEcomOrder.getDescription()); | ||
|
||
shEcomOrderRepository.saveAndFlush(shEcomOrderEdit); | ||
|
||
return shEcomOrderEdit; | ||
} | ||
|
||
@Transactional | ||
@ApiOperation(value = "Delete a Order") | ||
@DeleteMapping("/{id}") | ||
public boolean ShEcomOrderDelete(@PathVariable String id) throws Exception { | ||
shEcomOrderRepository.findById(id).ifPresent(new Consumer<ShEcomOrder>() { | ||
@Override | ||
public void accept(ShEcomOrder shEcomOrder) { | ||
shEcomOrderRepository.delete(shEcomOrder); | ||
} | ||
}); | ||
return true; | ||
} | ||
|
||
@ApiOperation(value = "Create a Order") | ||
@PostMapping | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public ShEcomOrder ShEcomOrderAdd(@RequestBody ShEcomOrder shEcomOrder) throws Exception { | ||
shEcomOrderRepository.save(shEcomOrder); | ||
|
||
return shEcomOrder; | ||
|
||
} | ||
} |
89 changes: 0 additions & 89 deletions
89
src/main/java/com/viglet/shiohara/api/ecommerce/ShEcomPaymentTypeAPI.java
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
src/main/java/com/viglet/shiohara/api/ecommerce/ShEcomPaymentTypeDefinitionAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.viglet.shiohara.api.ecommerce; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
|
||
import com.viglet.shiohara.api.ShJsonView; | ||
import com.viglet.shiohara.persistence.model.ecommerce.ShEcomPaymentTypeDefinition; | ||
import com.viglet.shiohara.persistence.repository.ecommerce.ShEcomPaymentTypeDefinitionRepository; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
|
||
@RestController | ||
@RequestMapping("/api/v2/ecom/payment/type/definition") | ||
@Api(tags = "Payment Type Definition", description = "Payment Type Definition API") | ||
public class ShEcomPaymentTypeDefinitionAPI { | ||
|
||
@Autowired | ||
private ShEcomPaymentTypeDefinitionRepository shEcomPaymentTypeDefinitionRepository; | ||
|
||
@ApiOperation(value = "Payment Type list") | ||
@GetMapping | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public List<ShEcomPaymentTypeDefinition> shEcomPaymentTypeDefinitionList() throws Exception { | ||
return shEcomPaymentTypeDefinitionRepository.findAll(); | ||
} | ||
|
||
@ApiOperation(value = "Show a Payment Type") | ||
@GetMapping("/{id}") | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public ShEcomPaymentTypeDefinition shEcomPaymentTypeDefinitioneGet(@PathVariable String id) throws Exception { | ||
return shEcomPaymentTypeDefinitionRepository.findById(id).get(); | ||
} | ||
|
||
@ApiOperation(value = "Update a Payment Type") | ||
@PutMapping("/{id}") | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public ShEcomPaymentTypeDefinition shEcomPaymentTypeDefinitionUpdate(@PathVariable String id, | ||
@RequestBody ShEcomPaymentTypeDefinition shEcomPaymentTypeDefinition) throws Exception { | ||
|
||
ShEcomPaymentTypeDefinition shEcomPaymentTypeDefinitionEdit = shEcomPaymentTypeDefinitionRepository.findById(id).get(); | ||
|
||
shEcomPaymentTypeDefinitionEdit.setDate(new Date()); | ||
shEcomPaymentTypeDefinitionEdit.setClassName(shEcomPaymentTypeDefinition.getClassName()); | ||
shEcomPaymentTypeDefinitionEdit.setDescription(shEcomPaymentTypeDefinition.getDescription()); | ||
shEcomPaymentTypeDefinitionEdit.setName(shEcomPaymentTypeDefinition.getName()); | ||
shEcomPaymentTypeDefinitionEdit.setSettingPath(shEcomPaymentTypeDefinition.getSettingPath()); | ||
|
||
shEcomPaymentTypeDefinitionRepository.saveAndFlush(shEcomPaymentTypeDefinitionEdit); | ||
|
||
return shEcomPaymentTypeDefinitionEdit; | ||
} | ||
|
||
@Transactional | ||
@ApiOperation(value = "Delete a Payment Type") | ||
@DeleteMapping("/{id}") | ||
public boolean shEcomPaymentTypeDefinitionDelete(@PathVariable String id) throws Exception { | ||
shEcomPaymentTypeDefinitionRepository.findById(id).ifPresent(new Consumer<ShEcomPaymentTypeDefinition>() { | ||
@Override | ||
public void accept(ShEcomPaymentTypeDefinition shEcomPaymentTypeDefinition) { | ||
shEcomPaymentTypeDefinitionRepository.delete(shEcomPaymentTypeDefinition); | ||
} | ||
}); | ||
return true; | ||
} | ||
|
||
@ApiOperation(value = "Create a Payment Type") | ||
@PostMapping | ||
@JsonView({ ShJsonView.ShJsonViewObject.class }) | ||
public ShEcomPaymentTypeDefinition ShEcomPaymentTypeAdd(@RequestBody ShEcomPaymentTypeDefinition shEcomPaymentTypeDefinition) throws Exception { | ||
shEcomPaymentTypeDefinition.setDate(new Date()); | ||
shEcomPaymentTypeDefinitionRepository.save(shEcomPaymentTypeDefinition); | ||
|
||
return shEcomPaymentTypeDefinition; | ||
|
||
} | ||
} |
Oops, something went wrong.