1. 通过ID集合获取用户列表

main
lyp 10 months ago
parent b71a1438d8
commit b0dbe10454

@ -1,19 +1,8 @@
package com.luoo.user.controller;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import api.PageResult;
import api.Result;
import api.StatusCode;
import com.luoo.user.annotation.GlobalInterceptor;
import com.luoo.user.annotation.VerifyParam;
import com.luoo.user.constants.Constants;
@ -23,15 +12,23 @@ import com.luoo.user.enums.VerifyRegexEnum;
import com.luoo.user.pojo.User;
import com.luoo.user.service.UserService;
import com.luoo.user.util.NickNameUtil;
import api.PageResult;
import api.Result;
import api.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import util.IdWorker;
import util.JwtUtil;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
*
*
@ -268,4 +265,10 @@ public class UserController {
return Result.success();
}
@DeleteMapping("/{findUserByIds}")
public List<User> findUserByIds(@RequestBody List<String> userId){
List<User> byIds = userService.findByIds(userId);
return byIds;
}
}

@ -1,12 +1,13 @@
package com.luoo.user.dao;
import com.luoo.user.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.luoo.user.pojo.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* 访
* @author Administrator
@ -26,4 +27,8 @@ public interface UserDao extends JpaRepository<User,String>,JpaSpecificationExec
public User findByLoginname(String loginname);
@Query("SELECT * FROM tb_user m WHERE m.id IN ?1")
List<User> findUserByIds(List<String> ids);
}

@ -1,17 +1,11 @@
package com.luoo.user.service;
import java.util.*;
import java.util.concurrent.TimeUnit;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import com.luoo.user.constants.Constants;
import com.luoo.user.dao.UserDao;
import com.luoo.user.pojo.User;
import com.luoo.user.util.NickNameUtil;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -19,20 +13,18 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import util.IdWorker;
import com.apifan.common.random.RandomSource;
import com.luoo.user.constants.Constants;
import com.luoo.user.dao.UserDao;
import com.luoo.user.dto.response.UserRespDTO;
import com.luoo.user.enumerate.Gender;
import com.luoo.user.pojo.User;
import com.luoo.user.util.NickNameUtil;
import util.JwtUtil;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
*
*
@ -119,6 +111,11 @@ public class UserService {
return userDao.findById(id).get();
}
public List<User> findByIds(List<String> ids) {
return userDao.findUserByIds(ids);
}
/**
*
*

Loading…
Cancel
Save