Question

In: Computer Science

Can anyone implement RestApi(CRUD) for this using Spring boot and Firebase? I will appreciate it farms:...

Can anyone implement RestApi(CRUD) for this using Spring boot and Firebase? I will appreciate it

farms: [

{

id: string,

farmer: string,

name: string,

image: reference,

description: string,

location: string,

geoLocation: geopoint,

rating: number

}

]

(subcollection within a farm document) products: [

{

id: string,

name: string,

image: reference,

quantity: number,

description: string,

price: number,

expirationDate: timestamp,

updatedDate: timestamp,

categories: array[string],

tags: array[string],

location: string,

geoLocation: geopoint,

rating: number

}

]

Solutions

Expert Solution

Here you can go setp by setps ::

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
public class Application  {

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(Application.class);
        springApplication.addListeners(new ApplicationPidFileWriter());
        springApplication.run(args);
    }
}


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class InputController {

 @PostMapping(value = "/greeting",produces= MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
    public boolean indexCreator(@RequestBody  InputClass input) throws IOException {
        System.out.println(input[0].getF());
                 System.out.println(input[0].getP());
        
        return true;
    }
}

        
import java.util.List;

class InputClass {
    private List<Farms> f;
    private  List<Products> p;

    public InputClass(List<Farms> f, List<Products> p) {
        this.f = f;
        this.p = p;
    }

    public List<Farms> getF() {
        return f;
    }

    public void setF(List<Farms> f) {
        this.f = f;
    }

    public List<Products> getP() {
        return p;
    }

    public void setP(List<Products> p) {
        this.p = p;
    }
}
import org.apache.lucene.spatial3d.geom.GeoPoint;

import javax.naming.Reference;

public class Farms {
    private  int id;
    private  String farmer;
    private  String name;
    private Reference image;
    private  String description;
    private  String location;
    private GeoPoint geolocation;
    private  String rating;

    public Farms(int id, String farmer, String name, Reference image, String description, String location, GeoPoint geolocation, String rating) {
        this.id = id;
        this.farmer = farmer;
        this.name = name;
        this.image = image;
        this.description = description;
        this.location = location;
        this.geolocation = geolocation;
        this.rating = rating;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getFarmer() {
        return farmer;
    }

    public void setFarmer(String farmer) {
        this.farmer = farmer;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Reference getImage() {
        return image;
    }

    public void setImage(Reference image) {
        this.image = image;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public GeoPoint getGeolocation() {
        return geolocation;
    }

    public void setGeolocation(GeoPoint geolocation) {
        this.geolocation = geolocation;
    }

    public String getRating() {
        return rating;
    }

    public void setRating(String rating) {
        this.rating = rating;
    }
}
import org.apache.lucene.spatial3d.geom.GeoPoint;

import java.lang.ref.Reference;
import java.sql.Timestamp;

public class Products {
    private String id;
    private  String name;
   private Reference image;
   private  int quantity;
   private  String description;
   private int price;
   private Timestamp expirationDate;

    private Timestamp updatedDate;
   private String[] categories;
   private  String[] tags;
   private  String location;
   private GeoPoint geoLocation;
   private int rating;

    public Products(String id, String name, Reference image, int quantity, String description, int price, Timestamp expirationDate, Timestamp updatedDate, String[] categories, String[] tags, String location, GeoPoint geoLocation, int rating) {
        this.id = id;
        this.name = name;
        this.image = image;
        this.quantity = quantity;
        this.description = description;
        this.price = price;
        this.expirationDate = expirationDate;
        this.updatedDate = updatedDate;
        this.categories = categories;
        this.tags = tags;
        this.location = location;
        this.geoLocation = geoLocation;
        this.rating = rating;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Reference getImage() {
        return image;
    }

    public void setImage(Reference image) {
        this.image = image;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public Timestamp getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(Timestamp expirationDate) {
        this.expirationDate = expirationDate;
    }

    public Timestamp getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Timestamp updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String[] getCategories() {
        return categories;
    }

    public void setCategories(String[] categories) {
        this.categories = categories;
    }

    public String[] getTags() {
        return tags;
    }

    public void setTags(String[] tags) {
        this.tags = tags;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public GeoPoint getGeoLocation() {
        return geoLocation;
    }

    public void setGeoLocation(GeoPoint geoLocation) {
        this.geoLocation = geoLocation;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }
}

Here Now This will accept Rest Call :

/greeting

{

farms: [

{

id: string,

farmer: string,

name: string,

image: reference,

description: string,

location: string,

geoLocation: geopoint,

rating: number

}

]

products: [

{

id: string,

name: string,

image: reference,

quantity: number,

description: string,

price: number,

expirationDate: timestamp,

updatedDate: timestamp,

categories: array[string],

tags: array[string],

location: string,

geoLocation: geopoint,

rating: number

}

]

}


Related Solutions

If anyone can show me how these are solved I would appreciate it, answers included though...
If anyone can show me how these are solved I would appreciate it, answers included though please. 16.) Which of the follow conatin the GREATEST number of MOLES of OXYGEN. Show your work. 0.50 mol P4010, 1.5mol P2O5, 2.5mol CO2, 2.0mol N2O4    20.) Ibuprofen has a chemical formula C13H1802. When the equation is properly balanced what is a correct mole ratio of CO2 to H2O in the reaction? 21.) 4Al(s) + 3O2(g) ---> 2 Al2O3 (s) If 10.0 mol...
If anyone can "dumb this down for me I'd appreciate it. I'm really not good with...
If anyone can "dumb this down for me I'd appreciate it. I'm really not good with statistics, I'm easily confused by all the terms and symbols so if someone is willing to explain a basic easy to understand example that would be much appreciated- What types of misconceptions and errors do your foresee occurring in a business setting if the normal distribution assumptions are not applied correctly? Please include a real-world business example in your response.
Could anyone please explain how to do this? I would appreciate it! The judges of County...
Could anyone please explain how to do this? I would appreciate it! The judges of County X try thousands of cases per year. Although in a big majority of the cases disposed the verdict stands as rendered, some cases are appealed. Of those appealed, some are reversed. Because appeals are often made as a result of mistakes by the judges, you want to determine which judges are doing a good job and which ones are making too many mistakes. The...
I appreciate your explanation. I found different answers on these questions and it can be confusing....
I appreciate your explanation. I found different answers on these questions and it can be confusing. 7. For a beneficiary to receive a qualified distribution from a Roth IRA, who must meet the five-year requirement? A. The beneficiary, after taking distributions. B. Both the owner and the beneficiary. C. Either the owner or the beneficiary, before taking distributions. 8. Which statement about the American Opportunity Tax Credit and the lifetime learning credit is FALSE? A. A portion of the American...
Please typing if you can i will appreciate had my answers but i need to compare...
Please typing if you can i will appreciate had my answers but i need to compare my solution . o changes you have had to personally make due to the Any Personality things o how you feel about those changes; how you are coping o economic impacts for you, friends, and/or family o educational impacts for you, friends or family Typing please it is help me for grammar
Please typing if you can i will appreciate had my answers but i need to compare...
Please typing if you can i will appreciate had my answers but i need to compare my solution . o changes you have had to personally make due to the Any Personality things o how you feel about those changes; how you are coping o economic impacts for you, friends, and/or family o educational impacts for you, friends or family Typing please it is help me for grammar
Please typing if you can i will appreciate had my answers but i need to compare...
Please typing if you can i will appreciate had my answers but i need to compare my solution . o changes you have had to personally make due to the Any activity or sport  things o how you feel about those changes; how you are coping o economic impacts for you, friends, and/or family o educational impacts for you, friends or family Typing please it is help me for grammar
Please typing if you can i will appreciate had my answers but i need to compare...
Please typing if you can i will appreciate had my answers but i need to compare my solution . o changes you have had to personally make due to the Any Personality things o how you feel about those changes; how you are coping o economic impacts for you, friends, and/or family o educational impacts for you, friends or family Typing please it is help me for grammar
Please typing if you can i will appreciate had my answers but i need to compare...
Please typing if you can i will appreciate had my answers but i need to compare my solution . o changes you have had to personally make due to the fast food o how you feel about those changes; how you are coping o economic impacts for you, friends, and/or family o educational impacts for you, friends or family Typing please it is help me for grammar
Please typing if you can i will appreciate had my answers but i need to compare...
Please typing if you can i will appreciate had my answers but i need to compare my solution . o changes you have had to personally make due to the any experience o how you feel about those changes; how you are coping o economic impacts for you, friends, and/or family o educational impacts for you, friends or family Typing please it is help me for grammar
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT