Search in sources :

Example 1 with CanNotOperateReason

use of build.dream.common.erp.catering.domains.CanNotOperateReason 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)

Example 2 with CanNotOperateReason

use of build.dream.common.erp.catering.domains.CanNotOperateReason in project erp-catering by liuyandong33.

the class CanNotOperateReasonUtils method constructCanNotOperateReason.

public static CanNotOperateReason constructCanNotOperateReason(BigInteger tenantId, String tenantCode, BigInteger branchId, BigInteger tableId, String tableName, BigInteger causeTableId, String causeTableName, Integer operateType, String reason) {
    CanNotOperateReason canNotOperateReason = new CanNotOperateReason();
    canNotOperateReason.setTenantId(tenantId);
    canNotOperateReason.setTenantCode(tenantCode);
    canNotOperateReason.setBranchId(branchId);
    canNotOperateReason.setTableId(tableId);
    canNotOperateReason.setTableName(tableName);
    canNotOperateReason.setCauseTableId(causeTableId);
    canNotOperateReason.setCauseTableName(causeTableName);
    canNotOperateReason.setOperateType(operateType);
    canNotOperateReason.setReason(reason);
    return canNotOperateReason;
}
Also used : CanNotOperateReason(build.dream.common.erp.catering.domains.CanNotOperateReason)

Aggregations

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