Search in sources :

Example 11 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class JobServiceImpl method saveOrUpdate.

/**
 * 新增任务
 *
 * @param job 调度信息 调度信息
 */
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdate(Job job) {
    ArgumentAssert.isTrue(checkCronExpressionIsValid(job.getCronExpression()), "cronExpression 不合法");
    try {
        if (job.getId() == null) {
            job.setStatus(JobStatus.PAUSE);
            int rows = repository.insert(job);
            if (rows > 0) {
                RedisUtil.sendScheduleChannelMessage(ScheduleVo.createDataAdd(JSONUtil.toJsonStr(job)));
            }
        } else {
            Job temp = repository.selectById(job.getId());
            int rows = repository.updateById(job);
            if (rows > 0) {
                updateSchedulerJob(job, temp.getGroup());
            }
        }
        return true;
    } catch (Exception e) {
        throw new BizException(e);
    }
}
Also used : BizException(com.albedo.java.common.core.exception.BizException) Job(com.albedo.java.modules.quartz.domain.Job) BizException(com.albedo.java.common.core.exception.BizException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class DictServiceImpl method removeByIds.

@Override
public boolean removeByIds(Collection<?> ids) {
    ids.forEach(id -> {
        // 查询父节点为当前节点的节点
        List<DictDo> menuList = this.list(Wrappers.<DictDo>query().lambda().eq(DictDo::getParentId, id));
        ArgumentAssert.notEmpty(menuList, () -> new BizException("字典含有下级不能删除"));
    });
    boolean b = super.removeByIds(ids);
    cacheOps.del(new DictCacheKeyBuilder().key(CACHE_FIND_CODES));
    return b;
}
Also used : BizException(com.albedo.java.common.core.exception.BizException) DictDo(com.albedo.java.modules.sys.domain.DictDo) DictCacheKeyBuilder(com.albedo.java.modules.sys.cache.DictCacheKeyBuilder)

Example 13 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class RoleServiceImpl method findLevelByUserId.

@Override
public Integer findLevelByUserId(Long userId) {
    List<Integer> levels = this.findListByUserId(SecurityUtil.getUser().getId()).stream().map(RoleDo::getLevel).collect(Collectors.toList());
    ArgumentAssert.notEmpty(levels, () -> new BizException("权限不足,找不到可用的角色信息"));
    int min = Collections.min(levels);
    return min;
}
Also used : BizException(com.albedo.java.common.core.exception.BizException)

Example 14 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class BodyRequestWrapper method readBody.

private static String readBody(ServletRequest request) {
    StringBuilder sb = new StringBuilder();
    String inputLine;
    BufferedReader br = null;
    try {
        br = request.getReader();
        while ((inputLine = br.readLine()) != null) {
            sb.append(inputLine);
        }
    } catch (IOException e) {
        throw new BizException("Failed to read body. {}", e);
    } finally {
        if (br != null) {
            try {
                br.close();
            } catch (IOException e) {
            }
        }
    }
    return sb.toString();
}
Also used : BizException(com.albedo.java.common.core.exception.BizException) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 15 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class AliPayServiceImpl method toPayAsWeb.

@Override
public String toPayAsWeb(AlipayConfigDo alipay, TradeVo trade) throws Exception {
    ArgumentAssert.notNull(alipay.getId(), () -> new BizException("请先添加相应配置,再操作"));
    AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType());
    double money = Double.parseDouble(trade.getTotalAmount());
    double maxMoney = 5000;
    if (money <= 0 || money >= maxMoney) {
        throw new BizException("测试金额过大");
    }
    // 创建API对应的request(手机网页版)
    AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
    request.setReturnUrl(alipay.getReturnUrl());
    request.setNotifyUrl(alipay.getNotifyUrl());
    request.setBizContent("{" + "    \"out_trade_no\":\"" + trade.getOutTradeNo() + "\"," + "    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," + "    \"total_amount\":" + trade.getTotalAmount() + "," + "    \"subject\":\"" + trade.getSubject() + "\"," + "    \"body\":\"" + trade.getBody() + "\"," + "    \"extend_params\":{" + "    \"sys_service_provider_id\":\"" + alipay.getSysServiceProviderId() + "\"" + "    }" + "  }");
    return alipayClient.pageExecute(request, "GET").getBody();
}
Also used : BizException(com.albedo.java.common.core.exception.BizException) DefaultAlipayClient(com.alipay.api.DefaultAlipayClient) AlipayClient(com.alipay.api.AlipayClient) AlipayTradeWapPayRequest(com.alipay.api.request.AlipayTradeWapPayRequest) DefaultAlipayClient(com.alipay.api.DefaultAlipayClient)

Aggregations

BizException (com.albedo.java.common.core.exception.BizException)22 UserDo (com.albedo.java.modules.sys.domain.UserDo)3 SneakyThrows (lombok.SneakyThrows)3 RoleDo (com.albedo.java.modules.sys.domain.RoleDo)2 AlipayClient (com.alipay.api.AlipayClient)2 DefaultAlipayClient (com.alipay.api.DefaultAlipayClient)2 IORuntimeException (cn.hutool.core.io.IORuntimeException)1 TableColumnDo (com.albedo.java.modules.gen.domain.TableColumnDo)1 TableDo (com.albedo.java.modules.gen.domain.TableDo)1 SchemeDto (com.albedo.java.modules.gen.domain.dto.SchemeDto)1 TableDto (com.albedo.java.modules.gen.domain.dto.TableDto)1 TemplateVo (com.albedo.java.modules.gen.domain.vo.TemplateVo)1 GenConfig (com.albedo.java.modules.gen.domain.xml.GenConfig)1 Job (com.albedo.java.modules.quartz.domain.Job)1 DictCacheKeyBuilder (com.albedo.java.modules.sys.cache.DictCacheKeyBuilder)1 DeptDo (com.albedo.java.modules.sys.domain.DeptDo)1 DictDo (com.albedo.java.modules.sys.domain.DictDo)1 LogOperateDo (com.albedo.java.modules.sys.domain.LogOperateDo)1 MenuDo (com.albedo.java.modules.sys.domain.MenuDo)1 RoleMenuDo (com.albedo.java.modules.sys.domain.RoleMenuDo)1