Skip to content
Snippets Groups Projects
Commit 116251dc authored by stendler's avatar stendler
Browse files

base model and functionality

- rename and restructure our only model object
- repository may be able to handle REST stuff alone
parent 196181ba
No related branches found
No related tags found
No related merge requests found
package de.fuberlin.imp.memorybox.restmembox.controller;
import de.fuberlin.imp.memorybox.restmembox.model.MemoryBox;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/memorybox")
public class MemoryBoxController {
private static final String REQUEST_PARAM_ID = "id";
public MemoryBox memoryBox(@RequestParam(value=REQUEST_PARAM_ID, defaultValue = "0") long id) {
return new MemoryBox(id);
}
}
package de.fuberlin.imp.memorybox.restmembox.model;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.time.LocalDate;
@Data
@Entity
public class Memory {
@Id
@GeneratedValue()
private long id;
private final LocalDate creationDate;
private boolean published;
// gps location
// user?
private byte[] voice;
private String voiceText;
private byte[] image;
private String note; // optional Text
public Memory() {
this.creationDate = LocalDate.now();
this.published = false;
}
}
package de.fuberlin.imp.memorybox.restmembox.model;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
public class MemoryBox {
@Getter
private final long id;
@Getter
@Setter
private String name;
@Getter
private final LocalDate creationDate;
@Getter
@Setter
private String memory; // demo
/*
// for later - how this might look like
@Getter
@Setter
private MemoryBox memoryBox;
*/
public MemoryBox(long id) {
this.id = id;
this.creationDate = LocalDate.now();
}
}
package de.fuberlin.imp.memorybox.restmembox.repository;
import de.fuberlin.imp.memorybox.restmembox.model.Memory;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource
public interface MemoryRepository extends PagingAndSortingRepository<Memory, Long> {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment