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);
}
}
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;
}
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;
}
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();
}
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();
}
Aggregations