|
@@ -14,8 +14,6 @@ import org.springblade.core.mp.base.BasicsServiceImpl;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.utils.BeanUtils;
|
|
import org.springblade.core.tool.utils.BeanUtils;
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
|
-import org.springblade.core.tool.utils.Md5Utils;
|
|
|
|
import org.springblade.core.tool.utils.id.IdUtils;
|
|
import org.springblade.core.tool.utils.id.IdUtils;
|
|
import org.springblade.system.constant.RoleConstant;
|
|
import org.springblade.system.constant.RoleConstant;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
@@ -192,62 +190,62 @@ public class SupplyServiceImpl extends BasicsServiceImpl<SupplyMapper, Supply> i
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
@Override
|
|
@Override
|
|
public void update(Supply supply) {
|
|
public void update(Supply supply) {
|
|
- if (StringUtils.isAnyBlank(supply.getId(), supply.getSupplyName(), supply.getAccount())) {
|
|
|
|
|
|
+ if (StringUtils.isAnyBlank(supply.getId(), supply.getSupplyName())) {
|
|
throw new ServiceException("参数缺失");
|
|
throw new ServiceException("参数缺失");
|
|
}
|
|
}
|
|
- //当前租户id
|
|
|
|
|
|
+ // 当前租户id
|
|
String tenantId = AuthUtil.getTenantId();
|
|
String tenantId = AuthUtil.getTenantId();
|
|
if (StringUtils.isBlank(tenantId)) {
|
|
if (StringUtils.isBlank(tenantId)) {
|
|
throw new ServiceException("当前租户ID为空");
|
|
throw new ServiceException("当前租户ID为空");
|
|
}
|
|
}
|
|
|
|
|
|
- //判断账号是否重复
|
|
|
|
- boolean exist = getAccountIsExist(supply.getId(), tenantId, supply.getAccount());
|
|
|
|
- if (exist) {
|
|
|
|
- throw new ServiceException("账号已存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //供应商详情
|
|
|
|
- Supply info = getById(supply.getId());
|
|
|
|
- //如果供应商账号为空则新增账号
|
|
|
|
- if (StringUtils.isBlank(info.getAccount())) {
|
|
|
|
- if (StringUtils.isBlank(supply.getPassword())) {
|
|
|
|
- throw new ServiceException("参数缺失");
|
|
|
|
- }
|
|
|
|
- //校验账号是否存在
|
|
|
|
- R<Boolean> r = iUserClient.checkAccountExist(tenantId, null, supply.getAccount());
|
|
|
|
- if (!r.isSuccess()) {
|
|
|
|
- throw new ServiceException("获取用户失败");
|
|
|
|
- }
|
|
|
|
- if (r.getData()) {
|
|
|
|
- throw new ServiceException("账号已存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //新增用户
|
|
|
|
- User user = new User();
|
|
|
|
- user.setAccount(supply.getAccount());
|
|
|
|
- user.setPassword(Md5Utils.hash(supply.getPassword()));
|
|
|
|
- user.setName(supply.getSupplyName());
|
|
|
|
- user.setRealName(supply.getSupplyName());
|
|
|
|
- user.setEmail(supply.getContactMail());
|
|
|
|
- user.setPhone(supply.getSupplyTel());
|
|
|
|
- saveUser(Arrays.asList(user));
|
|
|
|
- } else {
|
|
|
|
- //校验账号是否存在
|
|
|
|
- R<Boolean> r = iUserClient.checkAccountExist(tenantId, info.getAccount(), supply.getAccount());
|
|
|
|
- if (!r.isSuccess()) {
|
|
|
|
- throw new ServiceException("获取用户失败");
|
|
|
|
- }
|
|
|
|
- if (r.getData()) {
|
|
|
|
- throw new ServiceException("账号已存在");
|
|
|
|
- }
|
|
|
|
- //通过旧账号修改账号
|
|
|
|
- R r2 = iUserClient.updateAccount(tenantId, info.getAccount(), supply.getAccount());
|
|
|
|
- if (!r2.isSuccess()) {
|
|
|
|
- throw new ServiceException("修改供应商账号失败");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //修改供应商
|
|
|
|
|
|
+ // //判断账号是否重复
|
|
|
|
+ // boolean exist = getAccountIsExist(supply.getId(), tenantId, supply.getAccount());
|
|
|
|
+ // if (exist) {
|
|
|
|
+ // throw new ServiceException("账号已存在");
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // //供应商详情
|
|
|
|
+ // Supply info = getById(supply.getId());
|
|
|
|
+ // //如果供应商账号为空则新增账号
|
|
|
|
+ // if (StringUtils.isBlank(info.getAccount())) {
|
|
|
|
+ // if (StringUtils.isBlank(supply.getPassword())) {
|
|
|
|
+ // throw new ServiceException("参数缺失");
|
|
|
|
+ // }
|
|
|
|
+ // //校验账号是否存在
|
|
|
|
+ // R<Boolean> r = iUserClient.checkAccountExist(tenantId, null, supply.getAccount());
|
|
|
|
+ // if (!r.isSuccess()) {
|
|
|
|
+ // throw new ServiceException("获取用户失败");
|
|
|
|
+ // }
|
|
|
|
+ // if (r.getData()) {
|
|
|
|
+ // throw new ServiceException("账号已存在");
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // //新增用户
|
|
|
|
+ // User user = new User();
|
|
|
|
+ // user.setAccount(supply.getAccount());
|
|
|
|
+ // user.setPassword(Md5Utils.hash(supply.getPassword()));
|
|
|
|
+ // user.setName(supply.getSupplyName());
|
|
|
|
+ // user.setRealName(supply.getSupplyName());
|
|
|
|
+ // user.setEmail(supply.getContactMail());
|
|
|
|
+ // user.setPhone(supply.getSupplyTel());
|
|
|
|
+ // saveUser(Arrays.asList(user));
|
|
|
|
+ // } else {
|
|
|
|
+ // //校验账号是否存在
|
|
|
|
+ // R<Boolean> r = iUserClient.checkAccountExist(tenantId, info.getAccount(), supply.getAccount());
|
|
|
|
+ // if (!r.isSuccess()) {
|
|
|
|
+ // throw new ServiceException("获取用户失败");
|
|
|
|
+ // }
|
|
|
|
+ // if (r.getData()) {
|
|
|
|
+ // throw new ServiceException("账号已存在");
|
|
|
|
+ // }
|
|
|
|
+ // //通过旧账号修改账号
|
|
|
|
+ // R r2 = iUserClient.updateAccount(tenantId, info.getAccount(), supply.getAccount());
|
|
|
|
+ // if (!r2.isSuccess()) {
|
|
|
|
+ // throw new ServiceException("修改供应商账号失败");
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // 修改供应商
|
|
super.updateById(supply);
|
|
super.updateById(supply);
|
|
}
|
|
}
|
|
|
|
|