Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import com.dev9.dataexample.entity.Sprocket;
import com.dev9.dataexample.repo.SprocketRepository;
import com.google.common.collect.Lists;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

Expand Down Expand Up @@ -43,5 +42,9 @@ public void newSprocket(@RequestBody Sprocket sprocket) {
public Sprocket getSprocketBySku(@PathVariable("sku") String sku) {
return sprocketRepository.findBySku(sku);
}


@RequestMapping(value = "/sprockets/sku/{sku}", method = {RequestMethod.DELETE})
public void deleteSprocketBySku(@PathVariable("sku") String sku) {
sprocketRepository.deleteBySku(sku);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/dev9/dataexample/entity/Sprocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Sprocket implements Serializable {
private String sku;

private String brand;

public String getDescription() {
return description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@


import com.dev9.dataexample.entity.Sprocket;

import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional
public interface SprocketRepository extends CrudRepository<Sprocket, Long> {

Sprocket findBySku(String sku);
List<Sprocket> findByBrand(String brand);


void deleteBySku(String sku);
}