|
|
@@ -1,5 +1,8 @@
|
|
|
package org.dromara.backstage.basics.service.impl;
|
|
|
|
|
|
+import org.dromara.backstage.basics.domain.PtOperator;
|
|
|
+import org.dromara.backstage.basics.mapper.PtOperatorMapper;
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
@@ -8,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.backstage.basics.domain.bo.PtAccountBo;
|
|
|
import org.dromara.backstage.basics.domain.vo.PtAccountVo;
|
|
|
@@ -31,6 +35,8 @@ public class PtAccountServiceImpl implements IPtAccountService {
|
|
|
|
|
|
private final PtAccountMapper baseMapper;
|
|
|
|
|
|
+ private final PtOperatorMapper ptOperatorMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询结算账户
|
|
|
*
|
|
|
@@ -115,7 +121,19 @@ public class PtAccountServiceImpl implements IPtAccountService {
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
private void validEntityBeforeSave(PtAccount entity){
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
+ //做一些数据校验,如唯一约束
|
|
|
+ LambdaQueryWrapper<PtAccount> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.ne(entity.getAccountId()!=null,PtAccount::getAccountId, entity.getAccountId());
|
|
|
+ lqw.and((e) -> e.eq(
|
|
|
+ PtAccount::getAccountName, entity.getAccountName())
|
|
|
+ .or().
|
|
|
+ eq(StringUtils.isNotEmpty(entity.getAccountCode()),PtAccount::getAccountCode, entity.getAccountCode())
|
|
|
+ );
|
|
|
+ Long aLong = baseMapper.selectCount(lqw);
|
|
|
+ if (aLong>0) {
|
|
|
+ throw new ServiceException("账户名称或账户代码已经存在");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -128,7 +146,9 @@ public class PtAccountServiceImpl implements IPtAccountService {
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
if(isValid){
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ if(ptOperatorMapper.selectCount(Wrappers.<PtOperator>lambdaQuery().in(PtOperator::getAccountId, ids)) > 0){
|
|
|
+ throw new ServiceException("已有营业员绑定此账号,不能删除");
|
|
|
+ }
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|