|
@@ -8,6 +8,7 @@ import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.newfeifan.mall.framework.common.exception.ServiceException;
|
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
|
import cn.newfeifan.mall.framework.common.util.collection.CollectionUtils;
|
|
|
+import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
|
|
|
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
|
import cn.newfeifan.mall.framework.datapermission.core.util.DataPermissionUtils;
|
|
|
import cn.newfeifan.mall.module.infra.api.file.FileApi;
|
|
@@ -91,10 +92,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Long createUser(UserSaveReqVO createReqVO) {
|
|
|
+ public Long createUser(UserSaveReqVO createReqVO, Long loginUserId) {
|
|
|
// 校验账户配合
|
|
|
tenantService.handleTenantInfo(tenant -> {
|
|
|
long count = userMapper.selectCount();
|
|
@@ -105,10 +105,21 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
// 校验正确性
|
|
|
validateUserForCreateOrUpdate(null, createReqVO.getUsername(),
|
|
|
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds());
|
|
|
+
|
|
|
+ if (createReqVO.getMerchantId() == null || createReqVO.getShopId() == null && loginUserId != null) {
|
|
|
+ Map shopMessage = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("shop:" + loginUserId), Map.class);
|
|
|
+ if (shopMessage != null) {
|
|
|
+ createReqVO.setShopId(Long.valueOf(String.valueOf(shopMessage.get("shopId"))));
|
|
|
+ createReqVO.setMerchantId(Long.valueOf(String.valueOf(shopMessage.get("merId"))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 插入用户
|
|
|
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
|
|
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
|
|
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
|
|
|
+
|
|
|
userMapper.insert(user);
|
|
|
// 插入关联岗位
|
|
|
if (CollectionUtil.isNotEmpty(user.getPostIds())) {
|
|
@@ -503,7 +514,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
.shopId(shopId)
|
|
|
.merchantId(merId)
|
|
|
.build();
|
|
|
- createUser(build);
|
|
|
+ createUser(build, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -521,10 +532,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
UserShopDetailsVO userShopDetailsVO = new UserShopDetailsVO();
|
|
|
userShopDetailsVO.setShopId(adminUserDO.getShopId());
|
|
|
userShopDetailsVO.setMerchantId(adminUserDO.getMerchantId());
|
|
|
- log.info("====userShopDetailsVO:{}",userShopDetailsVO);
|
|
|
+ log.info("====userShopDetailsVO:{}", userShopDetailsVO);
|
|
|
return userShopDetailsVO;
|
|
|
} else {
|
|
|
- log.info("====userShopDetailsVO:{}",s);
|
|
|
+ log.info("====userShopDetailsVO:{}", s);
|
|
|
return JSONObject.parseObject(s, UserShopDetailsVO.class);
|
|
|
}
|
|
|
}
|