|
@@ -3,7 +3,9 @@ package com.ruoyi.web.work.service.impl;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ruoyi.common.constant.CacheConstants;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.http.HttpUtils;
|
|
@@ -27,6 +29,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -42,6 +46,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
private TokenServices tokenService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private IResumeService resumeService;
|
|
|
|
|
|
@Autowired
|
|
@@ -50,6 +57,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Autowired
|
|
|
private Environment env;
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public List<User> selectList(User user) {
|
|
|
return userMapper.selectList(user);
|
|
@@ -157,4 +165,36 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
public AjaxResult info() {
|
|
|
return AjaxResult.success(userMapper.selectUser(AppUtil.getUser()));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult enable(User user) {
|
|
|
+ if (!updateById(user)) {
|
|
|
+ throw new ServiceException("启用或停用账户失败");
|
|
|
+ }
|
|
|
+ if (user.getState() == 1) {
|
|
|
+ deleteCache(user.getId());
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult remove(Long[] ids) {
|
|
|
+ if (!removeByIds(Arrays.asList(ids))) {
|
|
|
+ throw new ServiceException("删除失败");
|
|
|
+ }
|
|
|
+ for (Long id : ids) {
|
|
|
+ deleteCache(id);
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteCache(Long id) {
|
|
|
+ Collection<String> keys = redisCache.keys(CacheConstants.APP_LOGIN_TOKEN_KEY + "*");
|
|
|
+ for (String key : keys) {
|
|
|
+ User loginUser = redisCache.getCacheObject(key);
|
|
|
+ if (loginUser != null && loginUser.getId().equals(id)) {
|
|
|
+ tokenService.delLoginUser(loginUser.getToken());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|