diff --git a/AstuteSystem/src/main/java/com/astute/dao/DAO.java b/AstuteSystem/src/main/java/com/astute/dao/DAO.java index afbf5b3..6b01957 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/DAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/DAO.java @@ -107,6 +107,8 @@ public abstract class DAO { public abstract List getServiceTypes() throws AstuteException; + public abstract List getFeeTypes() throws AstuteException; + public abstract void createServiceType(String desc) throws AstuteException; public abstract void updateServiceType(int serviceTypeId, String desc) throws AstuteException; diff --git a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java index 2cd27b2..d1db438 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java @@ -292,6 +292,25 @@ public class SqlDAO extends DAO { } } + public List getFeeTypes() throws AstuteException { + try { + List feeTypes = new ArrayList(); + Statement stmt = conn.createStatement(); + String sql = "SELECT FEE_TYPE_ID, FEE_TYPE_DESC FROM FEE_TYPE ORDER BY 1 "; + ResultSet rs = stmt.executeQuery(sql); + while (rs.next()) { + int feeTypeId = rs.getInt(1); + String desc = rs.getString(2); + FeeType feeType = new FeeType(feeTypeId, desc); + feeTypes.add(feeType); + } + return feeTypes; + } catch (SQLException e) { + e.printStackTrace(); + throw new AstuteException(DB_ERROR,e.getMessage()); + } + + } public void createServiceType(String desc) throws AstuteException { try { Statement stmt = conn.createStatement(); diff --git a/AstuteSystem/src/main/java/com/astute/model/FeeType.java b/AstuteSystem/src/main/java/com/astute/model/FeeType.java new file mode 100644 index 0000000..17f8a6f --- /dev/null +++ b/AstuteSystem/src/main/java/com/astute/model/FeeType.java @@ -0,0 +1,27 @@ +package com.astute.model; + +public class FeeType { + int feeTypeId; + String feeTypeDesc; + + public FeeType(int feeTypeId, String feeTypeDesc) { + this.feeTypeId = feeTypeId; + this.feeTypeDesc = feeTypeDesc; + } + + public int getFeeTypeId() { + return feeTypeId; + } + + public void setFeeTypeId(int feeTypeId) { + this.feeTypeId = feeTypeId; + } + + public String getFeeTypeDesc() { + return feeTypeDesc; + } + + public void setFeeTypeDesc(String feeTypeDesc) { + this.feeTypeDesc = feeTypeDesc; + } +} diff --git a/AstuteSystem/src/main/java/com/astute/resources/POResource.java b/AstuteSystem/src/main/java/com/astute/resources/POResource.java index dd6a2b9..7f0879a 100644 --- a/AstuteSystem/src/main/java/com/astute/resources/POResource.java +++ b/AstuteSystem/src/main/java/com/astute/resources/POResource.java @@ -107,5 +107,13 @@ public class POResource { return new ApiResponse(POService.getServiceTypes()).toResponse(); } + @Path("/feeTypes") + @GET + public Response getFeeTypes(@QueryParam("sessionId") String sessionId) throws AstuteException { + authService.authenticateSession(sessionId); + return new ApiResponse(POService.getFeeTypes()).toResponse(); + } + + } diff --git a/AstuteSystem/src/main/java/com/astute/service/POService.java b/AstuteSystem/src/main/java/com/astute/service/POService.java index 754f845..ad5a154 100644 --- a/AstuteSystem/src/main/java/com/astute/service/POService.java +++ b/AstuteSystem/src/main/java/com/astute/service/POService.java @@ -1,6 +1,7 @@ package com.astute.service; import com.astute.exceptions.*; +import com.astute.model.FeeType; import com.astute.model.PO; import com.astute.model.PODetail; import com.astute.model.ServiceType; @@ -61,4 +62,10 @@ public class POService extends Service{ public List getServiceTypes() throws AstuteException { return getDao().getServiceTypes(); } + + + public List getFeeTypes() throws AstuteException { + return getDao().getFeeTypes(); + } + }