Commit e040f306 by guojuxing

打款户拖拽排序接口

parent e0cf4b82
...@@ -45,6 +45,17 @@ public interface PayAccountService { ...@@ -45,6 +45,17 @@ public interface PayAccountService {
TabPayAccount getById(Integer id); TabPayAccount getById(Integer id);
/** /**
* 拖拽排序
* @Title: setSort

* @Description:

 * @author guojuxing
* @param record
* @param sortValue

* @return void


 */
void setSort(TabPayAccount record, Integer sortValue);
/**
* 查询排序值最大的,即排在最末 * 查询排序值最大的,即排在最末
* @Title: getTheMaxSort
 * @Title: getTheMaxSort

* @Description: * @Description:
......
...@@ -39,6 +39,33 @@ public class PayAccountServiceImpl implements PayAccountService { ...@@ -39,6 +39,33 @@ public class PayAccountServiceImpl implements PayAccountService {
} }
@Override @Override
public void setSort(TabPayAccount record, Integer sortValue) {
List<TabPayAccount> list = tabPayAccountMapper.listPayAccount();
Integer fromSortValue = record.getSort();
if (fromSortValue > sortValue) {
//向上拖拽
for (int i = 0, length = list.size(); i < length; i++) {
TabPayAccount temp = list.get(i);
//如果大于sortValue,都需要降低排序值,往后推
boolean isNeedDown = temp.getSort() >= sortValue && temp.getSort() < fromSortValue;
if (isNeedDown) {
updateSort(list.get(i + 1).getSort(), temp.getPayAccountId());
}
}
} else if (fromSortValue < sortValue) {
//向下拖拽
for (int i = 0, length = list.size(); i < length; i++) {
TabPayAccount temp = list.get(i);
boolean isNeedUp = temp.getSort() <= sortValue && temp.getSort() > fromSortValue;
if (isNeedUp) {
updateSort(list.get(i - 1).getSort(), temp.getPayAccountId());
}
}
}
updateSort(sortValue, record.getPayAccountId());
}
@Override
public int getTheMaxSort() { public int getTheMaxSort() {
return tabPayAccountMapper.getMaxSort(); return tabPayAccountMapper.getMaxSort();
} }
...@@ -57,4 +84,11 @@ public class PayAccountServiceImpl implements PayAccountService { ...@@ -57,4 +84,11 @@ public class PayAccountServiceImpl implements PayAccountService {
public TabPayAccount getNextOfSort(Integer sort) { public TabPayAccount getNextOfSort(Integer sort) {
return null; return null;
} }
private void updateSort(Integer sort, Integer id) {
TabPayAccount record = new TabPayAccount();
record.setPayAccountId(id);
record.setSort(sort);
tabPayAccountMapper.updateByPrimaryKeySelective(record);
}
} }
...@@ -64,6 +64,19 @@ public class PayAccountApiServiceImpl implements PayAccountApiService { ...@@ -64,6 +64,19 @@ public class PayAccountApiServiceImpl implements PayAccountApiService {
} }
@Override @Override
public ServiceResponse<Void> setSort(Integer id, Integer sort) {
TabPayAccount tab = payAccountService.getById(id);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数有误,无此记录");
}
if (sort == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "排序值不能为空");
}
payAccountService.setSort(tab, sort);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> upSort(Integer id) { public ServiceResponse<Void> upSort(Integer id) {
TabPayAccount tab = payAccountService.getById(id); TabPayAccount tab = payAccountService.getById(id);
if (tab == null) { if (tab == null) {
......
...@@ -167,6 +167,9 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA ...@@ -167,6 +167,9 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
if (tab == null) { if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "订单流水号有误"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "订单流水号有误");
} }
if (tab.getApprovalStatus().intValue() != TransferAccountApprovalStatusEnum.TO_BE_APPROVED.getCode()) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "此订单已审核,不能取消");
}
updateCancelApproval(tab.getTransferApprovalId()); updateCancelApproval(tab.getTransferApprovalId());
return ServiceResponse.success(); return ServiceResponse.success();
} }
...@@ -177,6 +180,9 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA ...@@ -177,6 +180,9 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
if (tab == null) { if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "转账审批主键有误"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "转账审批主键有误");
} }
if (tab.getApprovalStatus().intValue() != TransferAccountApprovalStatusEnum.TO_BE_APPROVED.getCode()) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "此订单已审核,不能取消");
}
updateCancelApproval(transferApprovalId); updateCancelApproval(transferApprovalId);
return ServiceResponse.success(); return ServiceResponse.success();
} }
......
...@@ -69,6 +69,19 @@ public class CashWithdrawalController { ...@@ -69,6 +69,19 @@ public class CashWithdrawalController {
return ResultControllerUtils.commonResult(payAccountApiService.upSort(id)); return ResultControllerUtils.commonResult(payAccountApiService.upSort(id));
} }
/**
* 拖拽排序
* @Title: setSort

* @Description:

 * @author guojuxing
* @param id

* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/set-sort")
public RestResponse setSort(Integer id, Integer sortValue) {
return ResultControllerUtils.commonResult(payAccountApiService.setSort(id, sortValue));
}
@RequestMapping("/delete-pay-account") @RequestMapping("/delete-pay-account")
public RestResponse deletePayAccount(Integer id) { public RestResponse deletePayAccount(Integer id) {
return ResultControllerUtils.commonResult(payAccountApiService.delete(id)); return ResultControllerUtils.commonResult(payAccountApiService.delete(id));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment