Search in sources :

Example 1 with CanNotEditAndDeleteException

use of build.dream.catering.exceptions.CanNotEditAndDeleteException in project erp-catering by liuyandong33.

the class BasicService method validateCanNotOperate.

public void validateCanNotOperate(BigInteger tenantId, BigInteger branchId, String tableName, BigInteger tableId, int operateType) {
    SearchModel searchModel = new SearchModel();
    searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
    searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
    searchModel.addSearchCondition("table_name", Constants.SQL_OPERATION_SYMBOL_EQUALS, tableName);
    searchModel.addSearchCondition("table_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tableId);
    searchModel.addSearchCondition("operate_type", Constants.SQL_OPERATION_SYMBOL_IN, new int[] { operateType, 3 });
    CanNotOperateReason canNotOperateReason = canNotOperateReasonMapper.find(searchModel);
    if (canNotOperateReason != null) {
        int persistenceOperateType = canNotOperateReason.getOperateType();
        String reason = canNotOperateReason.getReason();
        if (persistenceOperateType == 1) {
            throw new CanNotDeleteException(reason);
        } else if (persistenceOperateType == 2) {
            throw new CanNotEditException(reason);
        } else if (persistenceOperateType == 3) {
            throw new CanNotEditAndDeleteException(String.format(reason, operateType == 1 ? "编辑" : "删除"));
        }
    }
}
Also used : SearchModel(build.dream.common.utils.SearchModel) CanNotDeleteException(build.dream.catering.exceptions.CanNotDeleteException) CanNotOperateReason(build.dream.common.erp.catering.domains.CanNotOperateReason) CanNotEditException(build.dream.catering.exceptions.CanNotEditException) CanNotEditAndDeleteException(build.dream.catering.exceptions.CanNotEditAndDeleteException)

Aggregations

CanNotDeleteException (build.dream.catering.exceptions.CanNotDeleteException)1 CanNotEditAndDeleteException (build.dream.catering.exceptions.CanNotEditAndDeleteException)1 CanNotEditException (build.dream.catering.exceptions.CanNotEditException)1 CanNotOperateReason (build.dream.common.erp.catering.domains.CanNotOperateReason)1 SearchModel (build.dream.common.utils.SearchModel)1