|
@@ -3,19 +3,24 @@ package com.zhongzheng.framework.web.service;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
import com.zhongzheng.common.constant.UserConstants;
|
|
import com.zhongzheng.common.constant.UserConstants;
|
|
|
|
|
+import com.zhongzheng.common.core.bo.SysUserEditBo;
|
|
|
import com.zhongzheng.common.core.domain.entity.store.StoreRole;
|
|
import com.zhongzheng.common.core.domain.entity.store.StoreRole;
|
|
|
import com.zhongzheng.common.core.domain.entity.store.StoreUser;
|
|
import com.zhongzheng.common.core.domain.entity.store.StoreUser;
|
|
|
import com.zhongzheng.common.core.domain.entity.store.StoreUserRole;
|
|
import com.zhongzheng.common.core.domain.entity.store.StoreUserRole;
|
|
|
|
|
+import com.zhongzheng.common.core.domain.model.StoreLoginUser;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.enums.UserStatus;
|
|
import com.zhongzheng.common.enums.UserStatus;
|
|
|
import com.zhongzheng.common.exception.BaseException;
|
|
import com.zhongzheng.common.exception.BaseException;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.AES;
|
|
import com.zhongzheng.common.utils.AES;
|
|
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.modules.store.mapper.StoreUserMapper;
|
|
import com.zhongzheng.modules.store.mapper.StoreUserMapper;
|
|
|
import com.zhongzheng.modules.store.mapper.StoreUserRoleMapper;
|
|
import com.zhongzheng.modules.store.mapper.StoreUserRoleMapper;
|
|
@@ -23,7 +28,6 @@ import com.zhongzheng.modules.store.service.IStoreRoleService;
|
|
|
import com.zhongzheng.modules.store.service.IStoreUserService;
|
|
import com.zhongzheng.modules.store.service.IStoreUserService;
|
|
|
import com.zhongzheng.modules.user.bo.UserAppAccountLoginBo;
|
|
import com.zhongzheng.modules.user.bo.UserAppAccountLoginBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserAppSmsLoginBo;
|
|
import com.zhongzheng.modules.user.bo.UserAppSmsLoginBo;
|
|
|
-import com.zhongzheng.common.core.domain.model.StoreLoginUser;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -60,7 +64,6 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
public List<StoreUser> selectUserList(StoreUser user) {
|
|
public List<StoreUser> selectUserList(StoreUser user) {
|
|
|
List<StoreUser> sysUsers = baseMapper.selectUserList(user);
|
|
List<StoreUser> sysUsers = baseMapper.selectUserList(user);
|
|
|
for (StoreUser sysUser : sysUsers) {
|
|
for (StoreUser sysUser : sysUsers) {
|
|
|
-
|
|
|
|
|
List<StoreUserRole> StoreUserRoles = StoreUserRoleMapper.selectList(new LambdaQueryWrapper<StoreUserRole>().eq(StoreUserRole::getUserId, sysUser.getUserId()));
|
|
List<StoreUserRole> StoreUserRoles = StoreUserRoleMapper.selectList(new LambdaQueryWrapper<StoreUserRole>().eq(StoreUserRole::getUserId, sysUser.getUserId()));
|
|
|
if (CollectionUtils.isNotEmpty(StoreUserRoles)){
|
|
if (CollectionUtils.isNotEmpty(StoreUserRoles)){
|
|
|
List<Long> collect = StoreUserRoles.stream().map(StoreUserRole::getRoleId).collect(Collectors.toList());
|
|
List<Long> collect = StoreUserRoles.stream().map(StoreUserRole::getRoleId).collect(Collectors.toList());
|
|
@@ -69,12 +72,12 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
if (CollectionUtils.isNotEmpty(sysRoles)){
|
|
if (CollectionUtils.isNotEmpty(sysRoles)){
|
|
|
List<StoreRole> collect1 = sysRoles.stream().map(x -> BeanUtil.toBean(x, StoreRole.class)).collect(Collectors.toList());
|
|
List<StoreRole> collect1 = sysRoles.stream().map(x -> BeanUtil.toBean(x, StoreRole.class)).collect(Collectors.toList());
|
|
|
sysUser.setRoles(collect1);
|
|
sysUser.setRoles(collect1);
|
|
|
|
|
+ sysUser.setRoleName(sysRoles.stream().map(StoreRole::getRoleName).collect(Collectors.joining(",")));
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
sysUser.setRoleIds(new ArrayList<>());
|
|
sysUser.setRoleIds(new ArrayList<>());
|
|
|
sysUser.setRoles(new ArrayList<>());
|
|
sysUser.setRoles(new ArrayList<>());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
return sysUsers;
|
|
return sysUsers;
|
|
|
}
|
|
}
|
|
@@ -166,6 +169,31 @@ public class StoreUserServiceImpl extends ServiceImpl<StoreUserMapper, StoreUser
|
|
|
return baseMapper.updateById(user);
|
|
return baseMapper.updateById(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean restorePwd(SysUserEditBo bo) {
|
|
|
|
|
+ if(Validator.isEmpty(bo.getUserId())){
|
|
|
|
|
+ throw new CustomException("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ StoreUser store = getOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getUserId, bo.getUserId()).last("limit 1"));
|
|
|
|
|
+ LambdaUpdateWrapper<StoreUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ objectLambdaUpdateWrapper.eq(StoreUser::getUserId, bo.getUserId());
|
|
|
|
|
+ objectLambdaUpdateWrapper.set(StoreUser::getPassword,
|
|
|
|
|
+ SecurityUtils.encryptPassword(store.getTelphone().substring(store.getTelphone().length()-7,store.getTelphone().length()-1)));
|
|
|
|
|
+ objectLambdaUpdateWrapper.set(StoreUser::getUpdateTime, DateUtils.getNowTime());
|
|
|
|
|
+ return this.update(null, objectLambdaUpdateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean batchDelete(SysUserEditBo bo) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(bo.getUserIds())){
|
|
|
|
|
+ throw new CustomException("参数有误");
|
|
|
|
|
+ }
|
|
|
|
|
+ // todo 删除校验
|
|
|
|
|
+ return update(new LambdaUpdateWrapper<StoreUser>()
|
|
|
|
|
+ .in(StoreUser::getUserId,bo.getUserIds())
|
|
|
|
|
+ .set(StoreUser::getStatus,-1));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public StoreUser queryByUnionId(String unionId) {
|
|
public StoreUser queryByUnionId(String unionId) {
|
|
|
StoreUser user = getOne(new LambdaQueryWrapper<StoreUser>()
|
|
StoreUser user = getOne(new LambdaQueryWrapper<StoreUser>()
|