|
|
@@ -1,5 +1,7 @@
|
|
|
package org.dromara.customer.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.crypto.digest.BCrypt;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
@@ -11,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.customer.controller.SupplierInfoController;
|
|
|
import org.dromara.customer.domain.SupplierInfo;
|
|
|
import org.dromara.customer.domain.vo.SupplierInformationVo;
|
|
|
@@ -23,6 +26,7 @@ import org.dromara.customer.domain.vo.SupplierContactVo;
|
|
|
import org.dromara.customer.domain.SupplierContact;
|
|
|
import org.dromara.customer.mapper.SupplierContactMapper;
|
|
|
import org.dromara.customer.service.ISupplierContactService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -158,9 +162,18 @@ public class SupplierContactServiceImpl extends ServiceImpl<SupplierContactMapp
|
|
|
* @return 是否新增成功
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByBo(SupplierContactBo bo) {
|
|
|
SupplierContact add = MapstructUtils.convert(bo, SupplierContact.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
+ RemoteUserBo remoteUserBo = new RemoteUserBo();
|
|
|
+ remoteUserBo.setNickName(bo.getUserName());
|
|
|
+ remoteUserBo.setUserName(bo.getPhone());
|
|
|
+ String password = ObjectUtil.isNotEmpty(bo.getPassword()) ? bo.getPassword() : "123456";
|
|
|
+ remoteUserBo.setPassword(BCrypt.hashpw(password));
|
|
|
+ remoteUserBo.setUserSonType("1");
|
|
|
+ remoteUserBo.setTenantId(LoginHelper.getTenantId());
|
|
|
+ Long userId = remoteUserService.addUser(remoteUserBo);
|
|
|
|
|
|
// 查询最大的用户编号
|
|
|
LambdaQueryWrapper<SupplierContact> lqw = Wrappers.lambdaQuery();
|
|
|
@@ -171,6 +184,7 @@ public class SupplierContactServiceImpl extends ServiceImpl<SupplierContactMapp
|
|
|
String maxUserNo = maxContact.getUserNo();
|
|
|
long l = Long.parseLong(maxUserNo) + 1;
|
|
|
add.setUserNo(String.valueOf(l));
|
|
|
+ add.setUserId(userId);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
return flag;
|
|
|
}
|
|
|
@@ -182,9 +196,18 @@ public class SupplierContactServiceImpl extends ServiceImpl<SupplierContactMapp
|
|
|
* @return 是否修改成功
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByBo(SupplierContactBo bo) {
|
|
|
SupplierContact update = MapstructUtils.convert(bo, SupplierContact.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
+ RemoteUserBo remoteUserBo = new RemoteUserBo();
|
|
|
+ remoteUserBo.setNickName(bo.getUserName());
|
|
|
+ remoteUserBo.setUserName(bo.getPhone());
|
|
|
+ String password = ObjectUtil.isNotEmpty(bo.getPassword()) ? bo.getPassword() : "123456";
|
|
|
+ remoteUserBo.setPassword(BCrypt.hashpw(password));
|
|
|
+ remoteUserBo.setUserSonType("1");
|
|
|
+ remoteUserBo.setTenantId(LoginHelper.getTenantId());
|
|
|
+ Long userId = remoteUserService.editUser(remoteUserBo);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|