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