fix: 新建视图后权限问题

This commit is contained in:
junjie 2021-07-28 12:16:59 +08:00
parent ce1cd9131c
commit c6fd782d39
4 changed files with 31 additions and 4 deletions

View File

@ -12,6 +12,8 @@ import java.util.List;
public interface ExtChartViewMapper {
List<ChartViewDTO> search(ChartViewRequest request);
ChartViewDTO searchOne(ChartViewRequest request);
void chartCopy(@Param("newChartId")String newChartId,@Param("oldChartId")String oldChartId);
@Select("select id from chart_view where table_id = #{tableId}")

View File

@ -8,6 +8,25 @@
<result column="privileges" property="privileges"/>
</resultMap>
<select id="searchOne" resultMap="BaseResultMapDTO">
select
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,
style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot,
get_auths(id,'chart',#{userId}) as `privileges`
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'chart') cids) t,chart_view
<where>
FIND_IN_SET(chart_view.id,cids)
<if test="sceneId != null">
and scene_id = #{sceneId,jdbcType=VARCHAR}
</if>
<if test="id != null">
and id = #{id,jdbcType=VARCHAR}
</if>
</where>
<if test="sort != null">
order by ${sort}
</if>
</select>
<select id="search" resultMap="BaseResultMapDTO">
select

View File

@ -79,8 +79,7 @@ public class ChartViewService {
Optional.ofNullable(chartView.getId()).ifPresent(id -> {
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id);
});
return chartView;
return getOneWithPermission(chartView.getId());
}
public List<ChartViewDTO> list(ChartViewRequest chartViewRequest) {
@ -115,6 +114,13 @@ public class ChartViewService {
return chartViewMapper.selectByPrimaryKey(id);
}
public ChartViewDTO getOneWithPermission(String id) {
ChartViewRequest chartViewRequest = new ChartViewRequest();
chartViewRequest.setId(id);
chartViewRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
return extChartViewMapper.searchOne(chartViewRequest);
}
public void delete(String id) {
chartViewMapper.deleteByPrimaryKey(id);
}

View File

@ -679,7 +679,7 @@ export default {
}
},
sceneClick(data, node) {
this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': data.id }})
this.$emit('switchComponent', { name: 'ChartEdit', param: data })
},
reviewChartList() {
if (this.$store.state.chart.chartSceneData) {
@ -753,7 +753,7 @@ export default {
if (this.optFrom === 'panel') {
this.$emit('newViewInfo', { 'id': response.data.id })
} else {
this.$emit('switchComponent', { name: 'ChartEdit', param: { 'id': response.data.id }})
this.$emit('switchComponent', { name: 'ChartEdit', param: response.data })
// this.$store.dispatch('chart/setViewId', response.data.id)
// this.chartTree()
this.refreshNodeBy(view.sceneId)