lzj 4 سال پیش
والد
کامیت
23798bba48

+ 1 - 11
provider-demo/src/main/java/com/tsf/demo/provider/dao/MpBehalfDao.java

@@ -14,15 +14,5 @@ import java.util.List;
  */
 public interface MpBehalfDao extends JpaRepository<MpBehalf,Long> {
 
-    @Query(value=
-            "select behalf.* from " +
-                    "mp_behalf as behalf " +
-            "inner join " +
-                    "mp_ms_card_application_log as log " +
-            "on " +
-                    "behalf.id=log.behalf_id " +
-            "where " +
-                    "log.mp_user_id = :userId"
-            ,nativeQuery=true)
-    List<MpBehalf> queryUserBehalfCard(@Param("userId") Long userId);
+
 }

+ 18 - 0
provider-demo/src/main/java/com/tsf/demo/provider/dao/MpMsCardApplicationDao.java

@@ -1,5 +1,6 @@
 package com.tsf.demo.provider.dao;
 
+import com.tsf.demo.provider.bean.po.MpBehalf;
 import com.tsf.demo.provider.bean.po.MpMsCardApplicationLog;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
@@ -22,4 +23,21 @@ public interface MpMsCardApplicationDao extends JpaRepository<MpMsCardApplicatio
     List<MpMsCardApplicationLog> queryUserCard(@Param("userId") Long userId);
 
 
+    @Query(value=
+            "select log.* from " +
+                    "mp_user_identification as iden " +
+            "inner join " +
+                    "mp_behalf as behalf " +
+            "on " +
+                    "behalf.identification_id=iden.id " +
+            "inner join " +
+                    "mp_ms_card_application_log as log " +
+            "on " +
+                    "log.behalf_id = behalf.id " +
+            "where " +
+                    "iden.mp_user_id=:userId"
+            ,nativeQuery=true)
+    List<MpMsCardApplicationLog> queryUserBehalfCard(@Param("userId") Long userId);
+
+
 }

+ 10 - 17
provider-demo/src/main/java/com/tsf/demo/provider/service/impl/MpMsCardApplicationImpl.java

@@ -9,7 +9,9 @@ import com.tsf.demo.provider.service.MpMsCardApplicationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author LiuZhenJi
@@ -24,22 +26,13 @@ public class MpMsCardApplicationImpl implements MpMsCardApplicationService {
 
     @Override
     public R queryUserCard(Long userId) {
-        //用户领卡集合
-        List<MpMsCardApplicationLog> mpMsCardApplicationLogs = mpMsCardApplicationDao.queryUserCard(userId);
-        //用户代领课集合
-        List<MpBehalf> mpBehalves = behalfDao.queryUserBehalfCard(userId);
-        int flag = -1;
-        for (MpMsCardApplicationLog mpMsCardApplicationLog : mpMsCardApplicationLogs) {
-            for (MpBehalf mpBehalf : mpBehalves) {
-                flag++;
-                if (mpMsCardApplicationLog.getBehalfId().equals(mpBehalf.getId())) {
-                    mpMsCardApplicationLog.setMpBehalf(mpBehalf);
-                    mpBehalves.remove(flag);
-                    break;
-                }
-            }
-            flag=-1;
-        }
-        return R.data(mpMsCardApplicationLogs);
+        //用户本人领卡集合
+        List<MpMsCardApplicationLog> selfMpMsCardApplicationLogList = mpMsCardApplicationDao.queryUserCard(userId);
+        //用户代领卡集合
+        List<MpMsCardApplicationLog> otherMpMsCardApplicationLogList = mpMsCardApplicationDao.queryUserBehalfCard(userId);
+        Map<String, List<MpMsCardApplicationLog>> map = new HashMap<>();
+        map.put("self",selfMpMsCardApplicationLogList);
+        map.put("other",otherMpMsCardApplicationLogList);
+        return R.data(map);
     }
 }