|
@@ -0,0 +1,65 @@
|
|
|
+package com.weavi.ahh_v2.service.impl;
|
|
|
+
|
|
|
+import com.weavi.ahh_v2.domain.UserLabel;
|
|
|
+import com.weavi.ahh_v2.domain.UserInfo;
|
|
|
+import com.weavi.ahh_v2.repository.LabelRepository;
|
|
|
+import com.weavi.ahh_v2.repository.UserRepository;
|
|
|
+import com.weavi.ahh_v2.service.LabelService;
|
|
|
+import com.weavi.ahh_v2.utils.Optional2List;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @auther jiangzuole
|
|
|
+ * @date 2019-05-28
|
|
|
+ * @time 10:27
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class LabelServiceImpl implements LabelService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LabelRepository labelRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserRepository userRepository;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UserLabel findById(Integer id) {
|
|
|
+ return labelRepository.findById(id).get();
|
|
|
+ }
|
|
|
+
|
|
|
+ /* @Override
|
|
|
+ public UserLabel findByUserId(Integer userId) {
|
|
|
+ return labelRepository.findByUserId(userId);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /** 通过标签查询用户的集合 */
|
|
|
+ @Override
|
|
|
+ public List<UserInfo> findByLabel(String label) {
|
|
|
+ UserLabel userLabel = labelRepository.findByLabel(label);
|
|
|
+ Optional<UserInfo> userInfo = userRepository.findById(userLabel.getUserId());
|
|
|
+ return Optional2List.toList(userInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<UserLabel> findAllLabel(Integer userId) {
|
|
|
+ List<UserLabel> labelList = labelRepository.findAll();
|
|
|
+ return labelList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> findLabel(Integer userId) {
|
|
|
+ List<UserLabel> labelList = labelRepository.findByUserId(userId);
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (UserLabel label:labelList
|
|
|
+ ) {
|
|
|
+ String label1 = label.getLabel();
|
|
|
+ list.add(label1);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+}
|