|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.dromara.business.common.service.impl.BaseServiceImpl;
|
|
|
import org.dromara.business.common.utils.BusinessUtil;
|
|
|
import org.dromara.business.common.utils.QueryHelpPlus;
|
|
@@ -18,6 +19,7 @@ import org.dromara.business.domain.PageResult;
|
|
|
import org.dromara.business.dozer.service.IGenerator;
|
|
|
import org.dromara.business.enums.ErrorEnums;
|
|
|
import org.dromara.business.exception.BusinessException;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -58,13 +60,16 @@ public class ContactPersonServiceImpl extends BaseServiceImpl<ContactPersonMappe
|
|
|
// 检查唯一性
|
|
|
unique(resources);
|
|
|
// 获取当前登录用户ID
|
|
|
+ Long userId = LoginHelper.getUserId();
|
|
|
// 新增
|
|
|
if (resources.getId() == null) {
|
|
|
+ resources.setCreateUserId(userId);
|
|
|
// 设置初始乐观锁版本号
|
|
|
resources.setVersion(BusinessConstants.DEFAULT_VERSION);
|
|
|
// 保存数据
|
|
|
save(resources);
|
|
|
} else {
|
|
|
+ resources.setUpdateUserId(userId);
|
|
|
// 检查版本号是否为空
|
|
|
BusinessUtil.checkVersion(resources);
|
|
|
// 更新条件
|
|
@@ -86,7 +91,7 @@ public class ContactPersonServiceImpl extends BaseServiceImpl<ContactPersonMappe
|
|
|
// 手机号
|
|
|
String phone = resources.getMobilePhone();
|
|
|
ContactPersonDto person = this.queryByPhone(phone);
|
|
|
- if (person != null) {
|
|
|
+ if (ObjectUtils.isNotEmpty(person)) {
|
|
|
if (resources.getId() == null || !resources.getId().equals(person.getId())) {
|
|
|
int code = ErrorEnums.MOBILE_USE_ERR.getCode();
|
|
|
throw new BusinessException(code, ErrorEnums.getInfo(code, phone, person.getUserName()));
|