Forráskód Böngészése

上传文件至 'src/main/java/com/weavi/ahh_v2/service/impl'

rookies 5 éve
szülő
commit
8cb8d4f9e0

+ 65 - 0
src/main/java/com/weavi/ahh_v2/service/impl/LabelServiceImpl.java

@@ -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;
+    }
+}

+ 56 - 0
src/main/java/com/weavi/ahh_v2/service/impl/UserServiceImpl.java

@@ -0,0 +1,56 @@
+package com.weavi.ahh_v2.service.impl;
+
+import com.weavi.ahh_v2.domain.UserInfo;
+import com.weavi.ahh_v2.repository.UserRepository;
+import com.weavi.ahh_v2.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @auther jiangzuole
+ * @date 2019-05-27
+ * @time 15:58
+ */
+@Service
+public class UserServiceImpl implements UserService {
+
+    @Autowired
+    private UserRepository userRepository;
+
+    @Override
+    public UserInfo findByUsername(String userName) {
+        return userRepository.findByUserName(userName);
+    }
+
+    @Override
+    public UserInfo findByNickname(String nickName) {
+        return userRepository.findByNickName(nickName);
+    }
+
+    @Override
+    public UserInfo findByPhoneAndSource(Integer phone, String signAddress) {
+        return userRepository.findByPhoneAndSignAddress(phone,signAddress);
+    }
+
+    @Override
+    public UserInfo findByNicknameAndSource(String nickName, String signAddress) {
+        return userRepository.findByNickNameAndSignAddress(nickName,signAddress);
+    }
+
+    @Override
+    public UserInfo findByIdAndDeleted(Integer id, Integer deleted) {
+        return userRepository.findByIdAndDeleted(id,deleted);
+    }
+
+    @Override
+    public List<UserInfo> findBySource(String signAddress) {
+        return userRepository.findBySignAddress(signAddress);
+    }
+
+    @Override
+    public UserInfo findById(Integer id) {
+        return userRepository.findById(id).get();
+    }
+}