@@ -55,19 +55,19 @@ public class CameraServiceImpl extends BaseServiceImpl<CameraMapper, Camera> imp | |||
//新增 | |||
if (StringUtils.isNull(entity.getId())) { | |||
if (StringUtils.isEmpty(entity.getCameraName())) { | |||
throw new ServiceException(-1, "摄像头名称不能为空"); | |||
throw new ServiceException("摄像头名称不能为空"); | |||
} | |||
if (ObjectUtil.isEmpty(entity.getCameraType())) { | |||
throw new ServiceException(-1, "设备类型不能为空"); | |||
throw new ServiceException("设备类型不能为空"); | |||
} | |||
if (StringUtils.isEmpty(entity.getLongitude())) { | |||
throw new ServiceException(-1, "经度不能为空"); | |||
throw new ServiceException("经度不能为空"); | |||
} | |||
if (StringUtils.isEmpty(entity.getLatitude())) { | |||
throw new ServiceException(-1, "纬度不能为空"); | |||
throw new ServiceException("纬度不能为空"); | |||
} | |||
if (StringUtils.isEmpty(entity.getFlvUrl())) { | |||
throw new ServiceException(-1, "摄像头地址不能为空"); | |||
throw new ServiceException("摄像头地址不能为空"); | |||
} | |||
} | |||
if(StringUtils.isNotEmpty(entity.getLongitude()) && StringUtils.isNotEmpty(entity.getLatitude())){ |
@@ -62,14 +62,14 @@ public class QueryGoodsListByWarehouseIdService { | |||
private JsonResult check(QueryGoodsListByWarehouseIdRequest request) { | |||
if (ObjectUtil.isNull(request.getWarehouseId())) { | |||
log.info("仓库ID为空, warehouseId:{}", request.getWarehouseId()); | |||
throw new ServiceException(-1, "仓库ID为空"); | |||
throw new ServiceException("仓库ID为空"); | |||
} | |||
Warehouse warehouse = warehouseMapper.selectOne(new LambdaQueryWrapper<Warehouse>() | |||
.eq(Warehouse::getTenantId, request.getTenantId()) | |||
.eq(Warehouse::getId, request.getWarehouseId())); | |||
if (ObjectUtil.isNull(warehouse)) { | |||
log.info("仓库不存在, warehouseId:{}", request.getWarehouseId()); | |||
throw new ServiceException(-1, "仓库不存在"); | |||
throw new ServiceException("仓库不存在"); | |||
} | |||
return JsonResult.success(); | |||
} |
@@ -84,7 +84,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
.eq(User::getUsername, tenantDto.getUsername()) | |||
.eq(User::getMark, 1)); | |||
if (count2 > 0) { | |||
throw new ServiceException(-1, "系统中已经存在相同的账号信息"); | |||
throw new ServiceException("系统中已经存在相同的账号信息"); | |||
} | |||
// 参数转换 | |||
Tenant tenant = new Tenant(); | |||
@@ -96,7 +96,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
// 新建租户数据 | |||
int count = tenantMapper.insert(tenant); | |||
if (count == 0) { | |||
throw new ServiceException(-1, "租户创建失败"); | |||
throw new ServiceException("租户创建失败"); | |||
} | |||
// 创建租户账号 | |||
User user = new User(); | |||
@@ -110,7 +110,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
user.setCreateTime(DateUtils.now()); | |||
int count3 = userMapper.insert(user); | |||
if (count3 == 0) { | |||
throw new ServiceException(-1, "租户登录账号创建失败"); | |||
throw new ServiceException("租户登录账号创建失败"); | |||
} | |||
return true; | |||
@@ -127,7 +127,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
// 查询租户信息 | |||
Tenant tenant = tenantMapper.selectById(tenantDto.getId()); | |||
if (StringUtils.isNull(tenant)) { | |||
throw new ServiceException(-1, "租户信息不存在"); | |||
throw new ServiceException("租户信息不存在"); | |||
} | |||
BeanUtils.copyProperties(tenantDto, tenant); | |||
// 租户头像 | |||
@@ -137,7 +137,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
// 更新租户信息 | |||
int count = tenantMapper.updateById(tenant); | |||
if (count == 0) { | |||
throw new ServiceException(-1, "更新租户信息失败"); | |||
throw new ServiceException("更新租户信息失败"); | |||
} | |||
// 验证账号 | |||
@@ -146,13 +146,13 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
.eq(User::getUsername, tenantDto.getUsername()) | |||
.eq(User::getMark, 1)); | |||
if (count2 > 0) { | |||
throw new ServiceException(-1, "系统中已经存在相同的账号信息"); | |||
throw new ServiceException("系统中已经存在相同的账号信息"); | |||
} | |||
// 查询租户账号信息 | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getTenantId, tenant.getId()).eq(User::getMark, 1)); | |||
if (StringUtils.isNull(user)) { | |||
throw new ServiceException(-1, "租户账号信息不存在"); | |||
throw new ServiceException("租户账号信息不存在"); | |||
} | |||
user.setRealname(tenantDto.getName()); | |||
user.setNickname(tenantDto.getName()); | |||
@@ -161,7 +161,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp | |||
user.setUpdateTime(DateUtils.now()); | |||
int count3 = userMapper.updateById(user); | |||
if (count3 == 0) { | |||
throw new ServiceException(-1, "租户账号信息更新失败"); | |||
throw new ServiceException("租户账号信息更新失败"); | |||
} | |||
return true; | |||
} |
@@ -68,7 +68,7 @@ public class WarehouseServiceImpl extends BaseServiceImpl<WarehouseMapper, Wareh | |||
//新增 | |||
if (StringUtils.isNull(entity.getId())) { | |||
if (StringUtils.isEmpty(entity.getWarehouseName())) { | |||
throw new ServiceException(-1, "仓库名称不能为空"); | |||
throw new ServiceException("仓库名称不能为空"); | |||
} | |||
} | |||
if (StringUtils.isNotEmpty(entity.getLongitude()) && StringUtils.isNotEmpty(entity.getLatitude())) { |
@@ -58,17 +58,17 @@ public class WarningConfirmService { | |||
private JsonResult check(Integer tenantId, WarningConfirmRequest request) { | |||
// 判断预警id是否为空 | |||
if (ObjectUtil.isNotNull(request.getId())) { | |||
throw new ServiceException(-1, "预警ID为空"); | |||
throw new ServiceException("预警ID为空"); | |||
} | |||
Warning warning = warningMapper.selectOne(new LambdaQueryWrapper<Warning>() | |||
.eq(Warning::getId, request.getId()) | |||
.eq(Warning::getTenantId, tenantId) | |||
.eq(Warning::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(warning)) { | |||
throw new ServiceException(-1, "预警信息不存在"); | |||
throw new ServiceException("预警信息不存在"); | |||
} | |||
if (!tenantId.equals(warning.getTenantId())) { | |||
throw new ServiceException(-1, "该租户没有查询该预警信息的权限"); | |||
throw new ServiceException("该租户没有查询该预警信息的权限"); | |||
} | |||
return JsonResult.success(warning); | |||
} | |||
@@ -91,7 +91,7 @@ public class WarningConfirmService { | |||
Integer rowCount = warningMapper.confirm(map); | |||
if (rowCount <= 0) { | |||
log.info("修改预警状态, 确认失败"); | |||
throw new ServiceException(-1, "修改预警状态, 确认失败"); | |||
throw new ServiceException("修改预警状态, 确认失败"); | |||
} | |||
return JsonResult.success(); | |||
} |
@@ -58,16 +58,16 @@ public class WarningIgnoreService { | |||
private JsonResult check(Integer tenantId, Integer id) { | |||
// 判断预警id是否为空 | |||
if (ObjectUtil.isNotNull(id)) { | |||
throw new ServiceException(-1, "预警ID为空"); | |||
throw new ServiceException("预警ID为空"); | |||
} | |||
Warning warning = warningMapper.selectOne(new LambdaQueryWrapper<Warning>() | |||
.in(Warning::getId, id) | |||
.eq(Warning::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(warning)) { | |||
throw new ServiceException(-1, "预警信息不存在"); | |||
throw new ServiceException("预警信息不存在"); | |||
} | |||
if (!tenantId.equals(warning.getTenantId())) { | |||
throw new ServiceException(-1, "该租户没有查询该预警信息的权限"); | |||
throw new ServiceException("该租户没有查询该预警信息的权限"); | |||
} | |||
return JsonResult.success(warning); | |||
} | |||
@@ -89,7 +89,7 @@ public class WarningIgnoreService { | |||
Integer rowCount = warningMapper.confirm(map); | |||
if (rowCount <= 0) { | |||
log.info("修改预警状态, 确认失败"); | |||
throw new ServiceException(-1, "修改预警状态, 确认失败"); | |||
throw new ServiceException("修改预警状态, 确认失败"); | |||
} | |||
return JsonResult.success(); | |||
} |
@@ -54,17 +54,17 @@ public class QueryWarningByIdService { | |||
private JsonResult check(Integer tenantId, Integer id) { | |||
// 判断预警id是否为空 | |||
if (ObjectUtil.isNotNull(id)) { | |||
throw new ServiceException(-1, "预警ID为空"); | |||
throw new ServiceException("预警ID为空"); | |||
} | |||
Warning warning = warningMapper.selectOne(new LambdaQueryWrapper<Warning>() | |||
.eq(Warning::getId, id) | |||
.eq(Warning::getTenantId, tenantId) | |||
.eq(Warning::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(warning)) { | |||
throw new ServiceException(-1, "预警信息不存在"); | |||
throw new ServiceException("预警信息不存在"); | |||
} | |||
if (!tenantId.equals(warning.getTenantId())) { | |||
throw new ServiceException(-1, "该租户没有查询该预警信息的权限"); | |||
throw new ServiceException("该租户没有查询该预警信息的权限"); | |||
} | |||
return JsonResult.success(warning); | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.common.exception; | |||
import com.tuoheng.common.common.ExceptionInterface; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 业务异常类(业务处理时手动抛出异常) | |||
@@ -30,6 +31,17 @@ public class ServiceException extends RuntimeException { | |||
this.code = exceptionInfo.getCode(); | |||
} | |||
/** | |||
* 构造器 | |||
* | |||
* @param msg | |||
*/ | |||
public ServiceException(String msg) { | |||
super(msg); | |||
this.msg = msg; | |||
this.code = JsonResult.ERROR; | |||
} | |||
/** | |||
* 构造器 | |||
* |
@@ -19,6 +19,11 @@ public class JsonResult<T> implements Serializable { | |||
*/ | |||
public static final int SUCCESS = 0;//CommonConstants.SUCCESS; | |||
/** | |||
* 失败 | |||
*/ | |||
public static final int ERROR = -1; | |||
/** | |||
* 失败 | |||
*/ |