0
私はモデルとリポジトリを持っています。モデルにはゲッターとセッターの値があり、レスポンスに追加する必要があります。変数status_message
は私のAPIの状態を表してここkatharsisで次のように扱うには?
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.katharsis.resource.annotations.JsonApiId;
import io.katharsis.resource.annotations.JsonApiResource;
@JsonApiResource(type="employee") //no i18n
public class Employee {
@JsonApiId
private String name;
private int emp_id;
private String dob;
private String profile_url;
private String status_message;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public int getEmp_id() {
return this.emp_id;
}
public void setEmp_id(int empid) {
this.emp_id = empid;
}
public String getDob() {
return this.dob;
}
public void setDob(String dob) {
this.dob = dob;
}
public String getProfile_url() {
return this.profile_url;
}
public void setProfile_url(String url) {
this.profile_url = url;
}
public String getStatus_message() {
return this.status_message;
}
public void setStatus_message(String message) {
this.status_message = message;
}
}
を次のように私のモデルがあります。データベースは、入力されたIDの従業員を有する場合、API応答が
- ようにする必要があり
{名: "rajasuba"、EMP_ID: "123"、DOB: "March301993"、PROFILE_URL:「HTTPS : "STATUS_MESSAGE: "成功"}
-
従業員が応答が
- : "rajasuba"、EMP_IDを" 567 " 、status_messsage: "発射"}
- は、そのような従業員が存在しない場合、次に私の応答は
{名前のようでなければならない組織を残し
ようでなければならない{STATUS_MESSAGEは:
} "無効なIDをemployeed"しかし、上記のすべての場合、私はすべての属性値を取得しています。特定のシナリオのために属性値(@JsonIgnoreなど)を選択的に無視するにはどうすればよいですか?