diff --git a/src/main/java/com/example/cosmos_serversb/entities/Request.java b/src/main/java/com/example/cosmos_serversb/entities/Request.java index 4cbe7ae..dc99cc5 100644 --- a/src/main/java/com/example/cosmos_serversb/entities/Request.java +++ b/src/main/java/com/example/cosmos_serversb/entities/Request.java @@ -1,11 +1,18 @@ package com.example.cosmos_serversb.entities; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; public class Request { private String rId; private String uri, IssuerUid, product; - private Date date, deadline; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Tokyo") + private Date date; + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Tokyo") + private Date deadline; private int location;// YahooローカルサーチAPIの業種コード private boolean done = false; @@ -13,6 +20,17 @@ } + public Request(String rId, String uri, Date date, String IssuerUid, String product, String deadline, int location){ + setrId(rId); + setUri(uri); + setDate(date); + setIssuerUid(IssuerUid); + setProduct(product); + setDeadline(deadline); + setLocation(location); + this.done = false; + } + public Request(String rId, String uri, Date date, String IssuerUid, String product, Date deadline, int location){ setrId(rId); setUri(uri); @@ -24,6 +42,14 @@ this.done = false; } + public void update(String uId, String product, String deadline, int location, boolean done){ + setIssuerUid(uId); + setProduct(product); + setDeadline(deadline); + setLocation(location); + setDone(done); + } + private void setrId(String rId){ this.rId = rId; } @@ -72,12 +98,26 @@ this.deadline = deadline; } + public void setDeadline(String deadline) { + if(deadline == null) return; + //String型をDate型に変換 + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + this.deadline = sdf.parse(deadline); + }catch (ParseException e){ + e.printStackTrace(); + } + } + public int getLocation() { return location; } public void setLocation(int location) { - this.location = location; + //更新の際に上書きされないように + if(location != 0) { + this.location = location; + } } public boolean isDone() {