api-plnmobile/src/main/java/org/sadigit/model/request/CreateKeluhanV2Request.java
2024-06-15 17:04:28 +07:00

201 lines
6.4 KiB
Java

package org.sadigit.model.request;
import java.util.Map;
import org.sadigit.control.exception.CustomException;
import org.sadigit.model.response.base.ResponseModel;
import jakarta.ws.rs.QueryParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateKeluhanV2Request {
@QueryParam("in_idpel")
private String in_idpel;
@NonNull
@QueryParam("in_nama")
private String in_nama;
@NonNull
@QueryParam("in_alamat")
private String in_alamat;
@NonNull
@QueryParam("in_hp")
private String in_hp;
@NonNull
@QueryParam("in_unitup")
private String in_unitup;
@NonNull
@QueryParam("in_long")
private String in_long;
@NonNull
@QueryParam("in_lat")
private String in_lat;
@NonNull
@QueryParam("in_tipe_keluhan")
private String in_tipe_keluhan;
@NonNull
@QueryParam("in_subtipe_keluhan")
private String in_subtipe_keluhan;
@NonNull
@QueryParam("in_keterangan")
private String in_keterangan;
@QueryParam("in_prov")
private String in_prov;
@QueryParam("in_kab")
private String in_kab;
@QueryParam("in_kec")
private String in_kec;
@QueryParam("in_kel")
private String in_kel;
@QueryParam("in_kode_gardu")
private String in_kode_gardu;
@QueryParam("in_laporanulang_ref")
private String in_laporanulang_ref;
public void checkParameter() {
if (this.getIn_nama() == null || this.getIn_nama().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Nama tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_alamat() == null || this.getIn_alamat().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Alamat tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_hp() == null || this.getIn_hp().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "No telp tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_unitup() == null || this.getIn_unitup().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Unitup tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_long() == null || this.getIn_long().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Longitude tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_lat() == null || this.getIn_lat().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Latitude tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_tipe_keluhan() == null || this.getIn_tipe_keluhan().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Tipe keluhan tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_keterangan() == null || this.getIn_keterangan().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Keterangan tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_subtipe_keluhan() == null || this.getIn_subtipe_keluhan().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Subtipe keluhan tidak boleh kosong",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_idpel() == null || this.getIn_idpel().isEmpty()) {
if (this.getIn_kel() == null || this.getIn_kel().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Nama kelurahan tidak boleh kosong apabila idpel tidak diisi",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_kec() == null || this.getIn_kec().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Nama kecamatan tidak boleh kosong apabila idpel tidak diisi",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_kab() == null || this.getIn_kab().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Nama kabupaten tidak boleh kosong apabila idpel tidak diisi",
"result", "0"))
.build();
throw new CustomException(null, error);
}
if (this.getIn_prov() == null || this.getIn_prov().isEmpty()) {
var error = ResponseModel.builder()
.data(Map.of(
"msg", "Nama provinsi tidak boleh kosong apabila idpel tidak diisi",
"result", "0"))
.build();
throw new CustomException(null, error);
}
}
}
}