diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaFollowUpRecordController.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaFollowUpRecordController.java index c2490e7..1b6fda6 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaFollowUpRecordController.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaFollowUpRecordController.java @@ -118,7 +118,7 @@ public class OaFollowUpRecordController extends BaseController { */ @GetMapping("/list/{customerId}") public R selectByCustomerIdId( - @NotNull(message = "主键不能为空") + @NotNull(message = "顾客id不能为空") @PathVariable Long customerId) { return R.ok(iOaFollowUpRecordService.selectByCustomerId(customerId)); } diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaFollowUpRecordServiceImpl.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaFollowUpRecordServiceImpl.java index 3ee958c..07db245 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaFollowUpRecordServiceImpl.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/service/impl/OaFollowUpRecordServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.oa.service.impl; import cn.hutool.core.bean.BeanUtil; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.domain.PageQuery; @@ -106,7 +107,11 @@ public class OaFollowUpRecordServiceImpl implements IOaFollowUpRecordService { * 保存前的数据校验 */ private void validEntityBeforeSave(OaFollowUpRecord entity){ - //TODO 做一些数据校验,如唯一约束 + //TODO 做一些数据校验,如唯一约束--(仅仅验证了顾客id唯一,如有不对可删去) + if(!checkCustomerId(entity)){ + throw new ServiceException("操作跟进记录失败, 跟进记录客服ID已存在!"); + } + } /** @@ -133,6 +138,17 @@ public class OaFollowUpRecordServiceImpl implements IOaFollowUpRecordService { return baseMapper.selectVoList(queryWrapper); } + /** + * 验证customerid是否可以操作 + */ + public Boolean checkCustomerId(OaFollowUpRecord entity) { + if(entity.getCustomerId() != null){ + OaFollowUpRecord followUpRecord=baseMapper.selectOne(new LambdaQueryWrapper().eq(OaFollowUpRecord::getCustomerId,entity.getCustomerId())); + if(followUpRecord!=null&&!entity.getFollowId().equals(followUpRecord.getFollowId()))return false; + } + return true; + } + /** * 添加跟进记录 */