|
@@ -0,0 +1,99 @@
|
|
|
+package com.weavi.ahh_v2.controller;
|
|
|
+
|
|
|
+import com.weavi.ahh_v2.domain.UserInfo;
|
|
|
+import com.weavi.ahh_v2.enums.ResultEnum;
|
|
|
+import com.weavi.ahh_v2.exception.AhhException;
|
|
|
+import com.weavi.ahh_v2.repository.LabelRepository;
|
|
|
+import com.weavi.ahh_v2.service.LabelService;
|
|
|
+import com.weavi.ahh_v2.service.UserService;
|
|
|
+import com.weavi.ahh_v2.vo.ResultVO;
|
|
|
+import com.weavi.ahh_v2.vo.UserInfoVO;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @auther jiangzuole
|
|
|
+ * @date 2019-05-27
|
|
|
+ * @time 16:23
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/v2")
|
|
|
+public class UserController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LabelRepository labelRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LabelService labelService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return resultVO
|
|
|
+ * 通过id查询用户的最外层对象信息
|
|
|
+ */
|
|
|
+ @GetMapping("/users/info")
|
|
|
+ public ResultVO findById(@RequestParam Integer id) {
|
|
|
+ if (id == null) {
|
|
|
+ throw new AhhException(ResultEnum.FAILED);
|
|
|
+ }
|
|
|
+ UserInfo userInfo = userService.findById(id);
|
|
|
+ List<String> label = labelService.findLabel(id);
|
|
|
+ UserInfoVO userInfoVO = new UserInfoVO();
|
|
|
+ ResultVO resultVO = new ResultVO();
|
|
|
+ BeanUtils.copyProperties(userInfo, userInfoVO);
|
|
|
+ userInfoVO.setLabel(label);
|
|
|
+ resultVO.setData(userInfoVO);
|
|
|
+ resultVO.setCode(ResultEnum.SUCCESS.getCode());
|
|
|
+ resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
|
|
|
+ return resultVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param nickName
|
|
|
+ * @return 用户最外层对象的信息
|
|
|
+ * 通过nickName查找用户的相关信息
|
|
|
+ */
|
|
|
+ @GetMapping("/users/nickname")
|
|
|
+ public ResultVO findByNickname(@RequestParam String nickName){
|
|
|
+ if (nickName==null){
|
|
|
+ throw new AhhException(ResultEnum.FAILED);
|
|
|
+ }
|
|
|
+ UserInfo userInfo = userService.findByNickname(nickName);
|
|
|
+ ResultVO resultVO = new ResultVO();
|
|
|
+ UserInfoVO userInfoVO = new UserInfoVO();
|
|
|
+ BeanUtils.copyProperties(userInfo,userInfoVO);
|
|
|
+ resultVO.setData(userInfoVO);
|
|
|
+ List<String> label = labelService.findLabel(userInfo.getUserId());
|
|
|
+ userInfoVO.setLabel(label);
|
|
|
+ resultVO.setCode(ResultEnum.SUCCESS.getCode());
|
|
|
+ resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
|
|
|
+ return resultVO;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /* @GetMapping("/users/info/new")
|
|
|
+ public ResultVO findByIds(@RequestParam Integer id){
|
|
|
+ UserInfo userInfo = userService.findById(id);
|
|
|
+ UserInfoVO userInfoVO = new UserInfoVO();
|
|
|
+ BeanUtils.copyProperties(userInfo,userInfoVO);
|
|
|
+ ResultVO resultVO = new ResultVO();
|
|
|
+ resultVO.setCode(ResultEnum.SUCCESS.getCode());
|
|
|
+ resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
|
|
|
+ return resultVO;
|
|
|
+ }*/
|
|
|
+
|
|
|
+}
|