make write service method transactional along with minor style changes.
This commit is contained in:
@@ -164,22 +164,22 @@ public class StaffApiResource {
|
|||||||
.extractFieldsForResponseIfProvided(uriInfo
|
.extractFieldsForResponseIfProvided(uriInfo
|
||||||
.getQueryParameters());
|
.getQueryParameters());
|
||||||
|
|
||||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
.getQueryParameters());
|
|
||||||
|
|
||||||
Collection<OfficeLookup> offices = this.officeReadPlatformService.retrieveAllOfficesForLookup();
|
final Collection<OfficeLookup> offices = this.officeReadPlatformService.retrieveAllOfficesForLookup();
|
||||||
|
|
||||||
Collection<StaffData> loanOfficers = null;
|
Collection<StaffData> loanOfficers = null;
|
||||||
StaffAccountSummaryCollectionData staffAccountSummaryCollectionData = null;
|
StaffAccountSummaryCollectionData staffAccountSummaryCollectionData = null;
|
||||||
|
|
||||||
if (officeId != null){
|
if (officeId != null) {
|
||||||
loanOfficers = this.readPlatformService.retrieveAllLoanOfficersByOffice(officeId);
|
loanOfficers = this.readPlatformService.retrieveAllLoanOfficersByOffice(officeId);
|
||||||
}
|
}
|
||||||
if (loanOfficerId != null){
|
|
||||||
|
if (loanOfficerId != null) {
|
||||||
staffAccountSummaryCollectionData = this.readPlatformService.retrieveLoanOfficerAccountSummary(loanOfficerId);
|
staffAccountSummaryCollectionData = this.readPlatformService.retrieveLoanOfficerAccountSummary(loanOfficerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoanReassignmentData loanReassignmentData = new LoanReassignmentData(officeId, loanOfficerId, offices,
|
final LoanReassignmentData loanReassignmentData = new LoanReassignmentData(officeId, loanOfficerId, offices,
|
||||||
loanOfficers, staffAccountSummaryCollectionData);
|
loanOfficers, staffAccountSummaryCollectionData);
|
||||||
|
|
||||||
return this.apiJsonSerializerService.serializeLoanReassignmentDataToJson(prettyPrint, responseParameters, loanReassignmentData);
|
return this.apiJsonSerializerService.serializeLoanReassignmentDataToJson(prettyPrint, responseParameters, loanReassignmentData);
|
||||||
|
|||||||
+21
-25
@@ -1,35 +1,31 @@
|
|||||||
package org.mifosng.platform.api.commands;
|
package org.mifosng.platform.api.commands;
|
||||||
|
|
||||||
|
/**
|
||||||
import java.util.Set;
|
* Immutable data object for reassigning loan officers on loans in bulk.
|
||||||
|
*/
|
||||||
public class BulkLoanReassignmentCommand {
|
public class BulkLoanReassignmentCommand {
|
||||||
|
|
||||||
private final Long fromLoanOfficerId;
|
private final Long fromLoanOfficerId;
|
||||||
private final Long toLoanOfficerId;
|
private final Long toLoanOfficerId;
|
||||||
|
|
||||||
private final String[] loans;
|
private final String[] loans;
|
||||||
|
|
||||||
private final Set<String> modifiedParameters;
|
public BulkLoanReassignmentCommand(Long fromLoanOfficerId,
|
||||||
|
Long toLoanOfficerId, String[] loans) {
|
||||||
|
this.fromLoanOfficerId = fromLoanOfficerId;
|
||||||
|
this.toLoanOfficerId = toLoanOfficerId;
|
||||||
|
this.loans = loans;
|
||||||
|
}
|
||||||
|
|
||||||
public BulkLoanReassignmentCommand(Set<String> modifiedParameters, Long fromLoanOfficerId,
|
public Long getFromLoanOfficerId() {
|
||||||
Long toLoanOfficerId, String[] loans) {
|
return fromLoanOfficerId;
|
||||||
this.fromLoanOfficerId = fromLoanOfficerId;
|
}
|
||||||
this.toLoanOfficerId = toLoanOfficerId;
|
|
||||||
this.loans = loans;
|
|
||||||
this.modifiedParameters = modifiedParameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getFromLoanOfficerId() {
|
public Long getToLoanOfficerId() {
|
||||||
return fromLoanOfficerId;
|
return toLoanOfficerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getToLoanOfficerId() {
|
|
||||||
return toLoanOfficerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getLoans() {
|
|
||||||
return loans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public String[] getLoans() {
|
||||||
|
return loans;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+15
-26
@@ -2,45 +2,34 @@ package org.mifosng.platform.api.data;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object returned for loan-officer reassignment screens.
|
||||||
|
*/
|
||||||
public class LoanReassignmentData {
|
public class LoanReassignmentData {
|
||||||
|
|
||||||
private final Long officeId;
|
@SuppressWarnings("unused")
|
||||||
|
private final Long officeId;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final Long fromLoanOfficerId;
|
private final Long fromLoanOfficerId;
|
||||||
|
|
||||||
//template
|
//template
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final Collection<OfficeLookup> officeOptions;
|
private final Collection<OfficeLookup> officeOptions;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final Collection<StaffData> loanOfficerOptions;
|
private final Collection<StaffData> loanOfficerOptions;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final StaffAccountSummaryCollectionData accountSummaryCollection;
|
private final StaffAccountSummaryCollectionData accountSummaryCollection;
|
||||||
|
|
||||||
public LoanReassignmentData(Long officeId, Long fromLoanOfficerId,
|
public LoanReassignmentData(
|
||||||
Collection<OfficeLookup> officeOptions, Collection<StaffData> loanOfficerOptions,
|
final Long officeId,
|
||||||
StaffAccountSummaryCollectionData accountSummaryCollection) {
|
final Long fromLoanOfficerId,
|
||||||
|
final Collection<OfficeLookup> officeOptions,
|
||||||
|
final Collection<StaffData> loanOfficerOptions,
|
||||||
|
final StaffAccountSummaryCollectionData accountSummaryCollection) {
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.fromLoanOfficerId = fromLoanOfficerId;
|
this.fromLoanOfficerId = fromLoanOfficerId;
|
||||||
this.officeOptions = officeOptions;
|
this.officeOptions = officeOptions;
|
||||||
this.loanOfficerOptions = loanOfficerOptions;
|
this.loanOfficerOptions = loanOfficerOptions;
|
||||||
this.accountSummaryCollection = accountSummaryCollection;
|
this.accountSummaryCollection = accountSummaryCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getOfficeId() {
|
|
||||||
return officeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getFromLoanOfficerId() {
|
|
||||||
return fromLoanOfficerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<OfficeLookup> getOfficeOptions() {
|
|
||||||
return officeOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<StaffData> getLoanOfficerOptions() {
|
|
||||||
return loanOfficerOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StaffAccountSummaryCollectionData getAccountSummaryCollection() {
|
|
||||||
return accountSummaryCollection;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+53
-58
@@ -1,83 +1,78 @@
|
|||||||
package org.mifosng.platform.api.data;
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class StaffAccountSummaryCollectionData {
|
public class StaffAccountSummaryCollectionData {
|
||||||
|
|
||||||
private final List<ClientSummary> clients;
|
@SuppressWarnings("unused")
|
||||||
|
private final List<ClientSummary> clients;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final List<GroupSummary> groups;
|
||||||
|
|
||||||
private final List<GroupSummary> groups;
|
public StaffAccountSummaryCollectionData(final List<ClientSummary> clients, final List<GroupSummary> groups) {
|
||||||
|
this.clients = clients;
|
||||||
|
this.groups = groups;
|
||||||
|
}
|
||||||
|
|
||||||
public StaffAccountSummaryCollectionData(List<ClientSummary> clients, List<GroupSummary> groups) {
|
public static final class ClientSummary {
|
||||||
this.clients = clients;
|
|
||||||
this.groups = groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientSummary> getClients() {
|
private final Long id;
|
||||||
return clients;
|
private final String displayName;
|
||||||
}
|
|
||||||
|
|
||||||
public List<GroupSummary> getGroups() {
|
private Collection<ClientAccountSummaryData> loans;
|
||||||
return groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class ClientSummary {
|
public ClientSummary(Long id, String displayName) {
|
||||||
|
this.id = id;
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
private final Long id;
|
public Long getId() {
|
||||||
private final String displayName;
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
private Collection<ClientAccountSummaryData> loans;
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientSummary(Long id, String displayName) {
|
public Collection<ClientAccountSummaryData> getLoans() {
|
||||||
this.id = id;
|
return loans;
|
||||||
this.displayName = displayName;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
public void setLoans(Collection<ClientAccountSummaryData> loans) {
|
||||||
return id;
|
this.loans = loans;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplayName() {
|
public static final class GroupSummary {
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<ClientAccountSummaryData> getLoans() {
|
private final Long id;
|
||||||
return loans;
|
private final String name;
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoans(Collection<ClientAccountSummaryData> loans) {
|
private Collection<GroupAccountSummaryData> loans;
|
||||||
this.loans = loans;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class GroupSummary {
|
public GroupSummary(Long id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
private final Long id;
|
public Long getId() {
|
||||||
private final String name;
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
private Collection<GroupAccountSummaryData> loans;
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public GroupSummary(Long id, String name) {
|
public Collection<GroupAccountSummaryData> getLoans() {
|
||||||
this.id = id;
|
return loans;
|
||||||
this.name = name;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
public void setLoans(Collection<GroupAccountSummaryData> loans) {
|
||||||
return id;
|
this.loans = loans;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<GroupAccountSummaryData> getLoans() {
|
|
||||||
return loans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoans(Collection<GroupAccountSummaryData> loans) {
|
|
||||||
this.loans = loans;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -155,7 +155,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BulkLoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(String json) {
|
public BulkLoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(final String json) {
|
||||||
|
|
||||||
if (StringUtils.isBlank(json)) {
|
if (StringUtils.isBlank(json)) {
|
||||||
throw new InvalidJsonException();
|
throw new InvalidJsonException();
|
||||||
@@ -193,7 +193,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
return new BulkLoanReassignmentCommand(modifiedParameters, fromLoanOfficerId, toLoanOfficerId, loans);
|
return new BulkLoanReassignmentCommand(fromLoanOfficerId, toLoanOfficerId, loans);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -296,14 +296,6 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return this.loanProduct;
|
return this.loanProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Staff getLoanofficer() {
|
|
||||||
return loanofficer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoanofficer(Staff loanofficer) {
|
|
||||||
this.loanofficer = loanofficer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoanProductRelatedDetail repaymentScheduleDetail() {
|
public LoanProductRelatedDetail repaymentScheduleDetail() {
|
||||||
return this.loanRepaymentScheduleDetail;
|
return this.loanRepaymentScheduleDetail;
|
||||||
}
|
}
|
||||||
@@ -1375,6 +1367,18 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return loanId.equals(this.getId());
|
return loanId.equals(this.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasLoanOfficer(final Staff fromLoanOfficer) {
|
||||||
|
|
||||||
|
boolean matchesCurrentLoanOfficer = false;
|
||||||
|
if (this.loanofficer != null) {
|
||||||
|
matchesCurrentLoanOfficer = this.loanofficer.identifiedBy(fromLoanOfficer);
|
||||||
|
} else {
|
||||||
|
matchesCurrentLoanOfficer = fromLoanOfficer == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchesCurrentLoanOfficer;
|
||||||
|
}
|
||||||
|
|
||||||
public LocalDate getInterestChargedFromDate() {
|
public LocalDate getInterestChargedFromDate() {
|
||||||
LocalDate interestChargedFrom = null;
|
LocalDate interestChargedFrom = null;
|
||||||
if (this.interestChargedFromDate != null) {
|
if (this.interestChargedFromDate != null) {
|
||||||
@@ -1420,4 +1424,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
private MonetaryCurrency getCurrency() {
|
private MonetaryCurrency getCurrency() {
|
||||||
return this.loanRepaymentScheduleDetail.getCurrency();
|
return this.loanRepaymentScheduleDetail.getCurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateLoanofficer(final Staff newLoanOfficer) {
|
||||||
|
this.loanofficer = newLoanOfficer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-3
@@ -728,8 +728,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
return new EntityIdentifier(loanCharge.getId());
|
return new EntityIdentifier(loanCharge.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public EntityIdentifier bulkLoanReassignment(BulkLoanReassignmentCommand command) {
|
public EntityIdentifier bulkLoanReassignment(final BulkLoanReassignmentCommand command) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
@@ -746,11 +747,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
if (loan == null) {
|
if (loan == null) {
|
||||||
throw new LoanNotFoundException(loanId);
|
throw new LoanNotFoundException(loanId);
|
||||||
}
|
}
|
||||||
if (!loan.getLoanofficer().equals(fromLoanOfficer)){
|
|
||||||
|
if (!loan.hasLoanOfficer(fromLoanOfficer)){
|
||||||
throw new LoanOfficerAssignmentException(loan.getId(), fromLoanOfficer.getId());
|
throw new LoanOfficerAssignmentException(loan.getId(), fromLoanOfficer.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
loan.setLoanofficer(toLoanOfficer);
|
loan.updateLoanofficer(toLoanOfficer);
|
||||||
this.loanRepository.save(loan);
|
this.loanRepository.save(loan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,4 +91,7 @@ public class Staff extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return loanOfficerFlag;
|
return loanOfficerFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean identifiedBy(Staff staff) {
|
||||||
|
return getId().equals(staff.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -11,7 +11,7 @@ public interface StaffReadPlatformService {
|
|||||||
|
|
||||||
Collection<StaffData> retrieveAllStaff(final String extraCriteria);
|
Collection<StaffData> retrieveAllStaff(final String extraCriteria);
|
||||||
|
|
||||||
Collection<StaffData> retrieveAllLoanOfficersByOffice(final long officeId);
|
Collection<StaffData> retrieveAllLoanOfficersByOffice(final Long officeId);
|
||||||
|
|
||||||
StaffAccountSummaryCollectionData retrieveLoanOfficerAccountSummary(final long loanOfficerId);
|
StaffAccountSummaryCollectionData retrieveLoanOfficerAccountSummary(final Long loanOfficerId);
|
||||||
}
|
}
|
||||||
+36
-37
@@ -82,10 +82,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<StaffData> retrieveAllLoanOfficersByOffice(long officeId) {
|
public Collection<StaffData> retrieveAllLoanOfficersByOffice(final Long officeId) {
|
||||||
return retrieveAllStaff(" office_id = " + officeId
|
return retrieveAllStaff(" office_id=" + officeId + " and is_loan_officer=1");
|
||||||
+ " and is_loan_officer = 1");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -106,73 +104,74 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StaffAccountSummaryCollectionData retrieveLoanOfficerAccountSummary(long loanOfficerId) {
|
public StaffAccountSummaryCollectionData retrieveLoanOfficerAccountSummary(final Long loanOfficerId) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
StaffClientMapper staffClientMapper = new StaffClientMapper();
|
StaffClientMapper staffClientMapper = new StaffClientMapper();
|
||||||
String clientSql = "select distinct " + staffClientMapper.schema();
|
String clientSql = "select distinct " + staffClientMapper.schema();
|
||||||
|
|
||||||
StaffGroupMapper staffGroupMapper = new StaffGroupMapper();
|
StaffGroupMapper staffGroupMapper = new StaffGroupMapper();
|
||||||
String groupSql = "select distinct " + staffGroupMapper.schema();
|
String groupSql = "select distinct " + staffGroupMapper.schema();
|
||||||
|
|
||||||
List<StaffAccountSummaryCollectionData.ClientSummary> clientSummaryList =
|
List<StaffAccountSummaryCollectionData.ClientSummary> clientSummaryList = this.jdbcTemplate
|
||||||
this.jdbcTemplate.query(clientSql, staffClientMapper, new Object[]{loanOfficerId});
|
.query(clientSql, staffClientMapper,
|
||||||
|
new Object[] { loanOfficerId });
|
||||||
|
|
||||||
for (StaffAccountSummaryCollectionData.ClientSummary clientSummary : clientSummaryList){
|
for (StaffAccountSummaryCollectionData.ClientSummary clientSummary : clientSummaryList) {
|
||||||
|
|
||||||
Collection<ClientAccountSummaryData> clientLoanAccounts =
|
Collection<ClientAccountSummaryData> clientLoanAccounts = this.clientReadPlatformService
|
||||||
this.clientReadPlatformService.retrieveClientLoanAccountsByLoanOfficerId(clientSummary.getId(), loanOfficerId);
|
.retrieveClientLoanAccountsByLoanOfficerId(
|
||||||
|
clientSummary.getId(), loanOfficerId);
|
||||||
|
|
||||||
clientSummary.setLoans(clientLoanAccounts);
|
clientSummary.setLoans(clientLoanAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StaffAccountSummaryCollectionData.GroupSummary> groupSummaryList =
|
List<StaffAccountSummaryCollectionData.GroupSummary> groupSummaryList = this.jdbcTemplate
|
||||||
this.jdbcTemplate.query(groupSql, staffGroupMapper, new Object[]{loanOfficerId});
|
.query(groupSql, staffGroupMapper, new Object[] { loanOfficerId });
|
||||||
|
|
||||||
for (StaffAccountSummaryCollectionData.GroupSummary groupSummary : groupSummaryList){
|
for (StaffAccountSummaryCollectionData.GroupSummary groupSummary : groupSummaryList) {
|
||||||
|
|
||||||
Collection<GroupAccountSummaryData> groupLoanAccounts =
|
Collection<GroupAccountSummaryData> groupLoanAccounts = this.groupReadPlatformService
|
||||||
this.groupReadPlatformService.retrieveGroupLoanAccountsByLoanOfficerId(groupSummary.getId(), loanOfficerId);
|
.retrieveGroupLoanAccountsByLoanOfficerId(
|
||||||
|
groupSummary.getId(), loanOfficerId);
|
||||||
|
|
||||||
groupSummary.setLoans(groupLoanAccounts);
|
groupSummary.setLoans(groupLoanAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StaffAccountSummaryCollectionData(clientSummaryList, groupSummaryList);
|
return new StaffAccountSummaryCollectionData(clientSummaryList, groupSummaryList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class StaffClientMapper implements RowMapper<StaffAccountSummaryCollectionData.ClientSummary> {
|
private static final class StaffClientMapper implements RowMapper<StaffAccountSummaryCollectionData.ClientSummary> {
|
||||||
|
|
||||||
public String schema(){
|
public String schema() {
|
||||||
return " c.id as id, c.display_name as displayName from m_client c " +
|
return " c.id as id, c.display_name as displayName from m_client c " +
|
||||||
" join m_loan l on c.id = l.client_id where l.loan_officer_id = ? ";
|
" join m_loan l on c.id = l.client_id where l.loan_officer_id = ? ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StaffAccountSummaryCollectionData.ClientSummary mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public StaffAccountSummaryCollectionData.ClientSummary mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
Long id = JdbcSupport.getLong(rs, "id");
|
final Long id = JdbcSupport.getLong(rs, "id");
|
||||||
String displayName = rs.getString("displayName");
|
final String displayName = rs.getString("displayName");
|
||||||
|
|
||||||
return new StaffAccountSummaryCollectionData.ClientSummary(id, displayName);
|
return new StaffAccountSummaryCollectionData.ClientSummary(id, displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class StaffGroupMapper implements RowMapper<StaffAccountSummaryCollectionData.GroupSummary> {
|
private static final class StaffGroupMapper implements RowMapper<StaffAccountSummaryCollectionData.GroupSummary> {
|
||||||
|
|
||||||
public String schema(){
|
public String schema() {
|
||||||
return " g.id as id, g.name as name from m_group g" +
|
return " g.id as id, g.name as name from m_group g" +
|
||||||
" join m_loan l on g.id = l.group_id where l.loan_officer_id = ? ";
|
" join m_loan l on g.id = l.group_id where l.loan_officer_id = ? ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StaffAccountSummaryCollectionData.GroupSummary mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public StaffAccountSummaryCollectionData.GroupSummary mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
Long id = JdbcSupport.getLong(rs, "id");
|
final Long id = JdbcSupport.getLong(rs, "id");
|
||||||
String name = rs.getString("name");
|
final String name = rs.getString("name");
|
||||||
|
|
||||||
return new StaffAccountSummaryCollectionData.GroupSummary(id, name);
|
return new StaffAccountSummaryCollectionData.GroupSummary(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -48,8 +48,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
StaffCommandValidator validator = new StaffCommandValidator(command);
|
StaffCommandValidator validator = new StaffCommandValidator(command);
|
||||||
validator.validateForCreate();
|
validator.validateForCreate();
|
||||||
|
|
||||||
Office staffOffice = this.officeRepository.findOne(command
|
Office staffOffice = this.officeRepository.findOne(command.getOfficeId());
|
||||||
.getOfficeId());
|
|
||||||
if (staffOffice == null) {
|
if (staffOffice == null) {
|
||||||
throw new OfficeNotFoundException(command.getOfficeId());
|
throw new OfficeNotFoundException(command.getOfficeId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user