@ -4,6 +4,7 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil ;
import com.baiye.model.dto.ClueDto ;
import com.baiye.model.dto.ClueQueryCriteria ;
import com.baiye.model.vo.ResSourceLabel ;
import com.baiye.util.AESUtils ;
import org.apache.commons.lang.StringUtils ;
import org.hibernate.query.internal.NativeQueryImpl ;
@ -155,4 +156,29 @@ public class ClueJpa {
}
return clueDtoList ;
}
public List < ResSourceLabel > findSourceLabel ( List < Long > clueIds ) {
StringBuilder sql = new StringBuilder ( ) ;
sql . append ( "select tcm.source_label sourceLabel, clue_id as clueId,tc.name as name from tb_clue_middle tcm LEFT JOIN tb_clue tc on tcm.clue_id = tc.id where 1=1 " ) ;
if ( clueIds ! = null & & clueIds . size ( ) > 0 ) {
sql . append ( "AND tcm.clue_id IN (:clueIds) " ) ;
}
Query query = entityManager . createNativeQuery ( sql . toString ( ) ) ;
if ( clueIds ! = null & & clueIds . size ( ) > 0 ) {
query . setParameter ( "clueIds" , clueIds ) ;
}
query . unwrap ( NativeQueryImpl . class ) . setResultTransformer ( Transformers . ALIAS_TO_ENTITY_MAP ) ;
List resultList = query . getResultList ( ) ;
List < ResSourceLabel > list = new ArrayList < > ( ) ;
for ( Object obj : resultList ) {
Map row = ( Map ) obj ;
ResSourceLabel resSourceLabel = new ResSourceLabel ( ) ;
resSourceLabel . setSourceLabel ( ( String ) row . get ( "sourceLabel" ) ) ;
resSourceLabel . setName ( ( String ) row . get ( "name" ) ) ;
BigInteger clueId = ( BigInteger ) row . get ( "clueId" ) ;
resSourceLabel . setClueId ( clueId . longValue ( ) ) ;
list . add ( resSourceLabel ) ;
}
return list ;
}
}