Last active
August 21, 2017 20:53
-
-
Save cliffgr/dffee4e61eee6a07eeda40eecd565394 to your computer and use it in GitHub Desktop.
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
test |
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
package com.apodeixoulis.Apodeixoulis.model.rating; | |
import com.fasterxml.jackson.annotation.JsonIgnore; | |
import javax.persistence.*; | |
import java.util.List; | |
import java.util.Set; | |
/** | |
* Created by cliff on 12/8/2017. | |
*/ | |
@Entity(name = "ap_place") | |
public class Place { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "id") | |
private int id; | |
@Column(name="placeId") | |
private String placeId; | |
private String placeName; | |
@OneToMany(cascade = CascadeType.ALL, mappedBy ="place") | |
private Set<Rate> rateSet; | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public String getPlaceId() { | |
return placeId; | |
} | |
public void setPlaceId(String placeId) { | |
this.placeId = placeId; | |
} | |
public String getPlaceName() { | |
return placeName; | |
} | |
public void setPlaceName(String placeName) { | |
this.placeName = placeName; | |
} | |
public Set<Rate> getRateSet() { | |
return rateSet; | |
} | |
public void setRateSet(Set<Rate> rateSet) { | |
this.rateSet = rateSet; | |
} | |
} |
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
package com.apodeixoulis.Apodeixoulis.model.rating; | |
import javax.persistence.*; | |
import java.io.Serializable; | |
/** | |
* Created by cliff on 12/8/2017. | |
*/ | |
@Entity(name="ap_rate") | |
public class Rate implements Serializable { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
private int id; | |
@ManyToOne | |
@JoinColumn(name = "placeId", referencedColumnName = "placeId") | |
private Place place; | |
private String userId; | |
private String comment; | |
public Rate() { | |
} | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public Place getPlace() { | |
return place; | |
} | |
public void setPlace(Place place) { | |
this.place = place; | |
} | |
public String getUserId() { | |
return userId; | |
} | |
public void setUserId(String userId) { | |
this.userId = userId; | |
} | |
public String getComment() { | |
return comment; | |
} | |
public void setComment(String comment) { | |
this.comment = comment; | |
} | |
} |
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
@RestController | |
@RequestMapping(value = "/api/rate") | |
public class RateController { | |
@Autowired | |
private RateService rateService; | |
@PostMapping(value = "/insertplace") | |
public void insertUser(@Validated @RequestBody final Place place) { | |
rateService.addPlace(place); | |
} | |
} |
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
@Service | |
public class RateService { | |
@Autowired | |
private RateRepository rateRepository; | |
@Autowired | |
private PlaceRepository placeRepository; | |
public void addPlace(Place place) { | |
placeRepository.save(place); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment