|
|
|
@ -115,7 +115,7 @@ public class EnterpriseEvaluateServiceImpl implements IEnterpriseEvaluateService |
|
|
|
@Override |
|
|
|
public Boolean insertByBo(EnterpriseEvaluateBo bo) { |
|
|
|
EnterpriseEvaluate add = MapstructUtils.convert(bo, EnterpriseEvaluate.class); |
|
|
|
validEntityBeforeSave(add); |
|
|
|
validEntityBeforeSave(add, true); // 新增时需要校验重复评价
|
|
|
|
boolean flag =false; |
|
|
|
flag= baseMapper.insert(add) > 0; |
|
|
|
|
|
|
|
@ -140,15 +140,25 @@ public class EnterpriseEvaluateServiceImpl implements IEnterpriseEvaluateService |
|
|
|
@Override |
|
|
|
public Boolean updateByBo(EnterpriseEvaluateBo bo) { |
|
|
|
EnterpriseEvaluate update = MapstructUtils.convert(bo, EnterpriseEvaluate.class); |
|
|
|
validEntityBeforeSave(update); |
|
|
|
validEntityBeforeSave(update, false); // 更新时不需要校验重复评价
|
|
|
|
return baseMapper.updateById(update) > 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存前的数据校验 |
|
|
|
* @param entity 待保存的实体 |
|
|
|
* @param isNew 是否为新增操作 |
|
|
|
*/ |
|
|
|
private void validEntityBeforeSave(EnterpriseEvaluate entity){ |
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
|
private void validEntityBeforeSave(EnterpriseEvaluate entity, boolean isNew){ |
|
|
|
// 仅在新增时校验enforcementId是否已存在评价记录,防止重复评价
|
|
|
|
if (isNew && StringUtils.isNotBlank(entity.getEnforcementId())) { |
|
|
|
LambdaQueryWrapper<EnterpriseEvaluate> lqw = Wrappers.lambdaQuery(); |
|
|
|
lqw.eq(EnterpriseEvaluate::getEnforcementId, entity.getEnforcementId()); |
|
|
|
long count = baseMapper.selectCount(lqw); |
|
|
|
if (count > 0) { |
|
|
|
throw new RuntimeException("该执法案件已评价过,不支持二次评价"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|