forked from github/dataease
Merge pull request #3251 from dataease/pr@dev@refactor_view-copy
refactor: 更新视图复制自动命名函数,兼容富文本视图不需要显示标题的情况
This commit is contained in:
commit
109e78b819
@ -209,3 +209,33 @@ RETURN oTemp;
|
|||||||
END
|
END
|
||||||
;;
|
;;
|
||||||
delimiter ;
|
delimiter ;
|
||||||
|
|
||||||
|
DROP FUNCTION IF EXISTS `GET_CHART_VIEW_COPY_NAME`;
|
||||||
|
delimiter ;;
|
||||||
|
CREATE FUNCTION `GET_CHART_VIEW_COPY_NAME`(chartId varchar(255),pid varchar(255))
|
||||||
|
RETURNS varchar(255) CHARSET utf8mb4
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
DECLARE chartName varchar(255);
|
||||||
|
|
||||||
|
DECLARE regexpInfo varchar(255);
|
||||||
|
|
||||||
|
DECLARE chartNameCount INTEGER;
|
||||||
|
|
||||||
|
select (case when `type`='richTextView' then 'RICH_TEXT_VIEW' else `name` end) into chartName from chart_view where id =chartId;
|
||||||
|
/**
|
||||||
|
因为名称存在()等特殊字符,所以不能直接用REGEXP进行查找
|
||||||
|
1.用like 'chartName%' 过滤可能的数据项
|
||||||
|
2.REPLACE(name,chartName,'') REGEXP '-copy\\(([0-9])+\\)$' 过滤去掉chartName后的字符以 -copy(/d) 结尾的数据
|
||||||
|
3.(LENGTH(REPLACE(name,chartName,''))-LENGTH(replace(REPLACE(name,chartName,''),'-',''))=1) 确定只出现一次 ‘-’ 防止多次copy
|
||||||
|
**/
|
||||||
|
select (count(1)+1) into chartNameCount from chart_view
|
||||||
|
where (LENGTH(REPLACE(name,chartName,''))-LENGTH(replace(REPLACE(name,chartName,''),'-',''))=1)
|
||||||
|
and REPLACE(name,chartName,'') REGEXP '-copy\\(([0-9])+\\)$' and name like CONCAT(chartName,'%') and chart_view.scene_id=pid ;
|
||||||
|
|
||||||
|
RETURN concat(chartName,'-copy(',chartNameCount,')');
|
||||||
|
|
||||||
|
END
|
||||||
|
;;
|
||||||
|
delimiter ;
|
||||||
|
Loading…
Reference in New Issue
Block a user