diff --git a/luoo_common/src/main/java/client/vo/SimpleUser.java b/luoo_common/src/main/java/client/vo/SimpleUser.java index 2198356..c6dd300 100644 --- a/luoo_common/src/main/java/client/vo/SimpleUser.java +++ b/luoo_common/src/main/java/client/vo/SimpleUser.java @@ -8,4 +8,9 @@ public class SimpleUser { private String userId; private String nickName; + + public SimpleUser(String userId, String nickName) { + this.userId = userId; + this.nickName = nickName; + } } diff --git a/luoo_user/src/main/java/com/luoo/user/controller/SimpleUserController.java b/luoo_user/src/main/java/com/luoo/user/controller/SimpleUserController.java new file mode 100644 index 0000000..4c4aeb6 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/controller/SimpleUserController.java @@ -0,0 +1,72 @@ + +package com.luoo.user.controller; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import javax.servlet.http.HttpServletResponse; + +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 constants.Constants; +import com.luoo.user.dto.response.CreateImageCode; +import com.luoo.user.pojo.Admin; +import com.luoo.user.pojo.UserInfo; +import com.luoo.user.service.UserInfoService; +import com.luoo.user.util.NickNameUtil; + +import annotation.GlobalInterceptor; +import annotation.VerifyParam; +import api.PageResult; +import api.Result; +import api.StatusCode; +import client.vo.SimpleUser; +import enums.RequestFrequencyTypeEnum; +import enums.VerifyRegexEnum; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import util.IdWorker; +import util.JwtUtil; +import util.StringTools; + +/** + * 控制器层 + * + * @author Administrator + * + */ + +@RestController +@CrossOrigin +@RequestMapping("/simple_user") +@Api(tags = "SimpleUserController") +public class SimpleUserController { + + @Autowired + private UserInfoService userInfoService; + + + /** + * 通过用户ids查询SimpleUser + * @param ids + * @return + */ + @ApiOperation(value = "通过用户ids查询SimpleUser") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "多个id以','分隔", required = true) }) + @GetMapping("/ids/{ids}") + public Result> orderByField(@PathVariable @VerifyParam(required=true) String ids){ + List idList=Arrays.stream(ids.split(",")).map(String::trim).collect(Collectors.toList()); + return Result.success(userInfoService.getSimpleUserOrderByField(idList)); + } +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java index a68949d..49dc10a 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserInfoDao.java @@ -11,6 +11,8 @@ import org.springframework.data.jpa.repository.Query; import com.luoo.user.pojo.Admin; import com.luoo.user.pojo.UserInfo; +import client.vo.SimpleUser; + public interface UserInfoDao extends JpaRepository, JpaSpecificationExecutor { public UserInfo findByMobile(String mobile); @@ -26,4 +28,7 @@ public interface UserInfoDao extends JpaRepository, JpaSpecifi @Query(value = "select * from tb_user_info where id in ?1 order by field(id,?1)", nativeQuery = true) public List orderByField(List idList); + + @Query(value = "select new client.vo.SimpleUser(id, nickName) from UserInfo where id in ?1 order by field(id,?1)") + public List getSimpleUserOrderByField(List idList); } diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/User.java b/luoo_user/src/main/java/com/luoo/user/pojo/User.java index 36f33af..e050bb8 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/User.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/User.java @@ -40,11 +40,4 @@ public class User implements Serializable{ private Integer followcount;//关注数 //private String deviceId;//设备id //private String deviceBrand;//设备品牌 - - public SimpleUser converSimpleUser(){ - SimpleUser simpleUser = new SimpleUser(); - simpleUser.setUserId(this.getId()); - simpleUser.setNickName(this.nickname); - return simpleUser; - } } diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index 88d8c39..5d48ae9 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -29,6 +29,7 @@ import com.luoo.user.pojo.Admin; import com.luoo.user.pojo.UserInfo; import com.luoo.user.util.NickNameUtil; +import client.vo.SimpleUser; import dto.UserLoginDto; import enums.UserStatusEnum; import util.JwtUtil; @@ -309,4 +310,8 @@ public class UserInfoService { public List orderByField(List idList) { return userInfoDao.orderByField(idList); } + + public List getSimpleUserOrderByField(List idList) { + return userInfoDao.getSimpleUserOrderByField(idList); + } }