mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 04:57:28 +00:00
(improvement)(Headless) Filter metrics and dimensions based on whether they were created as tags (#866)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -35,6 +35,13 @@ public class ChatQueryController {
|
|||||||
return chatService.search(chatParseReq);
|
return chatService.search(chatParseReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("map")
|
||||||
|
public Object map(@RequestBody ChatParseReq chatParseReq,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
chatParseReq.setUser(UserHolder.findUser(request, response));
|
||||||
|
return chatService.performMapping(chatParseReq);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("parse")
|
@PostMapping("parse")
|
||||||
public Object parse(@RequestBody ChatParseReq chatParseReq,
|
public Object parse(@RequestBody ChatParseReq chatParseReq,
|
||||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
|
|||||||
import com.tencent.supersonic.chat.api.pojo.request.ChatQueryDataReq;
|
import com.tencent.supersonic.chat.api.pojo.request.ChatQueryDataReq;
|
||||||
import com.tencent.supersonic.headless.api.pojo.SemanticParseInfo;
|
import com.tencent.supersonic.headless.api.pojo.SemanticParseInfo;
|
||||||
import com.tencent.supersonic.headless.api.pojo.request.DimensionValueReq;
|
import com.tencent.supersonic.headless.api.pojo.request.DimensionValueReq;
|
||||||
|
import com.tencent.supersonic.headless.api.pojo.response.MapResp;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.ParseResp;
|
import com.tencent.supersonic.headless.api.pojo.response.ParseResp;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.QueryResult;
|
import com.tencent.supersonic.headless.api.pojo.response.QueryResult;
|
||||||
import com.tencent.supersonic.headless.api.pojo.response.SearchResult;
|
import com.tencent.supersonic.headless.api.pojo.response.SearchResult;
|
||||||
@@ -16,6 +17,8 @@ public interface ChatService {
|
|||||||
|
|
||||||
List<SearchResult> search(ChatParseReq chatParseReq);
|
List<SearchResult> search(ChatParseReq chatParseReq);
|
||||||
|
|
||||||
|
MapResp performMapping(ChatParseReq chatParseReq);
|
||||||
|
|
||||||
ParseResp performParsing(ChatParseReq chatParseReq);
|
ParseResp performParsing(ChatParseReq chatParseReq);
|
||||||
|
|
||||||
QueryResult performExecution(ChatExecuteReq chatExecuteReq) throws Exception;
|
QueryResult performExecution(ChatExecuteReq chatExecuteReq) throws Exception;
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ public class ChatServiceImpl implements ChatService {
|
|||||||
return searchService.search(queryReq);
|
return searchService.search(queryReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapResp performMapping(ChatParseReq chatParseReq) {
|
||||||
|
return getMapResp(chatParseReq);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParseResp performParsing(ChatParseReq chatParseReq) {
|
public ParseResp performParsing(ChatParseReq chatParseReq) {
|
||||||
ParseResp parseResp = new ParseResp(chatParseReq.getChatId(), chatParseReq.getQueryText());
|
ParseResp parseResp = new ParseResp(chatParseReq.getChatId(), chatParseReq.getQueryText());
|
||||||
@@ -105,6 +110,16 @@ public class ChatServiceImpl implements ChatService {
|
|||||||
return chatParseContext;
|
return chatParseContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MapResp getMapResp(ChatParseReq chatParseReq) {
|
||||||
|
ChatParseContext chatParseContext = new ChatParseContext();
|
||||||
|
BeanMapper.mapper(chatParseReq, chatParseContext);
|
||||||
|
AgentService agentService = ContextUtils.getBean(AgentService.class);
|
||||||
|
Agent agent = agentService.getAgent(chatParseReq.getAgentId());
|
||||||
|
chatParseContext.setAgent(agent);
|
||||||
|
QueryReq queryReq = QueryReqConverter.buildText2SqlQueryReq(chatParseContext);
|
||||||
|
return chatQueryService.performMapping(queryReq);
|
||||||
|
}
|
||||||
|
|
||||||
private ChatExecuteContext buildExecuteContext(ChatExecuteReq chatExecuteReq) {
|
private ChatExecuteContext buildExecuteContext(ChatExecuteReq chatExecuteReq) {
|
||||||
ChatExecuteContext chatExecuteContext = new ChatExecuteContext();
|
ChatExecuteContext chatExecuteContext = new ChatExecuteContext();
|
||||||
BeanMapper.mapper(chatExecuteReq, chatExecuteContext);
|
BeanMapper.mapper(chatExecuteReq, chatExecuteContext);
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ public class PageMetricReq extends PageSchemaItemReq {
|
|||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
private Integer isTag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import com.tencent.supersonic.headless.server.persistence.mapper.MetricQueryDefa
|
|||||||
import com.tencent.supersonic.headless.server.persistence.repository.MetricRepository;
|
import com.tencent.supersonic.headless.server.persistence.repository.MetricRepository;
|
||||||
import com.tencent.supersonic.headless.server.pojo.MetricFilter;
|
import com.tencent.supersonic.headless.server.pojo.MetricFilter;
|
||||||
import com.tencent.supersonic.headless.server.pojo.MetricsFilter;
|
import com.tencent.supersonic.headless.server.pojo.MetricsFilter;
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public class MetaFilter {
|
|||||||
|
|
||||||
private List<String> fieldsDepend;
|
private List<String> fieldsDepend;
|
||||||
|
|
||||||
|
private Integer isTag;
|
||||||
|
|
||||||
public MetaFilter(List<Long> modelIds) {
|
public MetaFilter(List<Long> modelIds) {
|
||||||
this.modelIds = modelIds;
|
this.modelIds = modelIds;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,52 +117,54 @@
|
|||||||
|
|
||||||
<select id="query" resultMap="ResultMapWithBLOBs">
|
<select id="query" resultMap="ResultMapWithBLOBs">
|
||||||
select *
|
select *
|
||||||
from s2_dimension
|
from s2_dimension t
|
||||||
|
left join (
|
||||||
|
select *
|
||||||
|
from s2_tag
|
||||||
|
where type = 'DIMENSION'
|
||||||
|
) t1 on t.id = t1.item_id
|
||||||
where status != 3
|
where status != 3
|
||||||
<if test="key != null and key != ''">
|
<if test="key != null and key != ''">
|
||||||
and ( id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
and ( t.id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
|
t.description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
|
||||||
</if>
|
</if>
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
and id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
|
and t.id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="name != null and name != '' ">
|
<if test="name != null and name != '' ">
|
||||||
and name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
|
and t.name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="bizName != null and bizName != ''">
|
<if test="bizName != null and bizName != ''">
|
||||||
and biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
|
and t.biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="sensitiveLevel != null">
|
<if test="sensitiveLevel != null">
|
||||||
and sensitive_level = #{sensitiveLevel}
|
and t.sensitive_level = #{sensitiveLevel}
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="status != null">
|
||||||
and status = #{status}
|
and t.status = #{status}
|
||||||
</if>
|
</if>
|
||||||
<if test="modelIds != null and modelIds.size >0">
|
<if test="modelIds != null and modelIds.size >0">
|
||||||
and model_id in
|
and t.model_id in
|
||||||
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
|
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
|
||||||
separator=",">
|
separator=",">
|
||||||
#{model}
|
#{model}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="ids != null and ids.size >0">
|
<if test="ids != null and ids.size >0">
|
||||||
and id in
|
and t.id in
|
||||||
<foreach collection="ids" index="index" item="id" open="(" close=")"
|
<foreach collection="ids" index="index" item="id" open="(" close=")"
|
||||||
separator=",">
|
separator=",">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="createdBy != null">
|
<if test="createdBy != null">
|
||||||
and created_by = #{createdBy}
|
and t.created_by = #{createdBy}
|
||||||
</if>
|
</if>
|
||||||
<if test="isTag != null and isTag == 1">
|
<if test="isTag != null and isTag == 1">
|
||||||
and is_tag = 1
|
and t1.id is not null
|
||||||
</if>
|
|
||||||
<if test="isTag != null and isTag == 0">
|
|
||||||
and (is_tag = 0 or is_tag is null)
|
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -98,52 +98,60 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="query" resultMap="ResultMapWithBLOBs">
|
<select id="query" resultMap="ResultMapWithBLOBs">
|
||||||
select *
|
select t.*
|
||||||
from s2_metric
|
from s2_metric t
|
||||||
where status != 3
|
left join (
|
||||||
|
select *
|
||||||
|
from s2_tag
|
||||||
|
where type = 'METRIC'
|
||||||
|
) t1 on t.id = t1.item_id
|
||||||
|
where t.status != 3
|
||||||
<if test="type != null and type != ''">
|
<if test="type != null and type != ''">
|
||||||
and type = #{type}
|
and t.type = #{type}
|
||||||
</if>
|
</if>
|
||||||
<if test="key != null and key != ''">
|
<if test="key != null and key != ''">
|
||||||
and ( id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
and ( t.id like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.biz_name like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.description like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.alias like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
classifications like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
t.classifications like CONCAT('%',#{key , jdbcType=VARCHAR},'%') or
|
||||||
created_by like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
|
t.created_by like CONCAT('%',#{key , jdbcType=VARCHAR},'%') )
|
||||||
</if>
|
</if>
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
and id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
|
and t.id like CONCAT('%',#{id , jdbcType=VARCHAR},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="name != null and name != '' ">
|
<if test="name != null and name != '' ">
|
||||||
and name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
|
and t.name like CONCAT('%',#{name , jdbcType=VARCHAR},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="bizName != null and bizName != ''">
|
<if test="bizName != null and bizName != ''">
|
||||||
and biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
|
and t.biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="sensitiveLevel != null">
|
<if test="sensitiveLevel != null">
|
||||||
and sensitive_level = #{sensitiveLevel}
|
and t.sensitive_level = #{sensitiveLevel}
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="status != null">
|
||||||
and status = #{status}
|
and t.status = #{status}
|
||||||
</if>
|
</if>
|
||||||
<if test="modelIds != null and modelIds.size >0">
|
<if test="modelIds != null and modelIds.size >0">
|
||||||
and model_id in
|
and t.model_id in
|
||||||
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
|
<foreach collection="modelIds" index="index" item="model" open="(" close=")"
|
||||||
separator=",">
|
separator=",">
|
||||||
#{model}
|
#{model}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="ids != null and ids.size >0">
|
<if test="ids != null and ids.size >0">
|
||||||
and id in
|
and t.id in
|
||||||
<foreach collection="ids" index="index" item="id" open="(" close=")"
|
<foreach collection="ids" index="index" item="id" open="(" close=")"
|
||||||
separator=",">
|
separator=",">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="createdBy != null">
|
<if test="createdBy != null">
|
||||||
and created_by = #{createdBy}
|
and t.created_by = #{createdBy}
|
||||||
|
</if>
|
||||||
|
<if test="isTag != null and isTag == 1">
|
||||||
|
and t1.id is not null
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user