Merge branch 'dev' into pr@dev@feat_user_assist

This commit is contained in:
fit2cloud-chenyw 2022-09-21 14:28:06 +08:00 committed by GitHub
commit 6360b82430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 62 deletions

View File

@ -3,22 +3,23 @@ package io.dataease.controller.datasource;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DeLog; import io.dataease.auth.annotation.DeLog;
import io.dataease.auth.annotation.DePermission; import io.dataease.auth.annotation.DePermission;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.utils.DeLogUtils;
import io.dataease.dto.SysLogDTO;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.commons.constants.DePermissionType; import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel; import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.DeLogUtils;
import io.dataease.controller.ResultHolder; import io.dataease.controller.ResultHolder;
import io.dataease.controller.datasource.request.UpdataDsRequest; import io.dataease.controller.datasource.request.UpdataDsRequest;
import io.dataease.controller.request.DatasourceUnionRequest; import io.dataease.controller.request.DatasourceUnionRequest;
import io.dataease.controller.request.datasource.ApiDefinition; import io.dataease.controller.request.datasource.ApiDefinition;
import io.dataease.dto.datasource.DBTableDTO;
import io.dataease.service.datasource.DatasourceService;
import io.dataease.dto.DatasourceDTO; import io.dataease.dto.DatasourceDTO;
import io.dataease.dto.SysLogDTO;
import io.dataease.dto.datasource.DBTableDTO;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.service.datasource.DatasourceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -43,19 +44,19 @@ public class DatasourceController {
@ApiOperation("新增数据源") @ApiOperation("新增数据源")
@PostMapping("/add") @PostMapping("/add")
@DeLog( @DeLog(
operatetype = SysLogConstants.OPERATE_TYPE.CREATE, operatetype = SysLogConstants.OPERATE_TYPE.CREATE,
sourcetype = SysLogConstants.SOURCE_TYPE.DATASOURCE, sourcetype = SysLogConstants.SOURCE_TYPE.DATASOURCE,
positionIndex = 0,positionKey = "type", positionIndex = 0, positionKey = "type",
value = "id" value = "id"
) )
public Datasource addDatasource(@RequestBody Datasource datasource) throws Exception{ public Datasource addDatasource(@RequestBody Datasource datasource) throws Exception {
return datasourceService.addDatasource(datasource); return datasourceService.addDatasource(datasource);
} }
@RequiresPermissions("datasource:read") @RequiresPermissions("datasource:read")
@ApiOperation("数据源类型") @ApiOperation("数据源类型")
@GetMapping("/types") @GetMapping("/types")
public Collection types() throws Exception{ public Collection types() throws Exception {
return datasourceService.types(); return datasourceService.types();
} }
@ -81,6 +82,16 @@ public class DatasourceController {
return datasourceService.getDatasourceList(request); return datasourceService.getDatasourceList(request);
} }
@ApiOperation("查询数据源详情")
@PostMapping("/get/{id}")
public DatasourceDTO getDatasource(@PathVariable String id) throws Exception {
DatasourceUnionRequest request = new DatasourceUnionRequest();
request.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
request.setId(id);
List<DatasourceDTO> datasourceList = datasourceService.getDatasourceList(request);
return CollectionUtils.isNotEmpty(datasourceList) ? datasourceList.get(0) : null;
}
@ApiOperation("查询当前用户数据源") @ApiOperation("查询当前用户数据源")
@GetMapping("/list/{type}") @GetMapping("/list/{type}")
public List<DatasourceDTO> getDatasourceListByType(@PathVariable String type) throws Exception { public List<DatasourceDTO> getDatasourceListByType(@PathVariable String type) throws Exception {
@ -105,12 +116,12 @@ public class DatasourceController {
@ApiOperation("更新数据源") @ApiOperation("更新数据源")
@PostMapping("/update") @PostMapping("/update")
@DeLog( @DeLog(
operatetype = SysLogConstants.OPERATE_TYPE.MODIFY, operatetype = SysLogConstants.OPERATE_TYPE.MODIFY,
sourcetype = SysLogConstants.SOURCE_TYPE.DATASOURCE, sourcetype = SysLogConstants.SOURCE_TYPE.DATASOURCE,
positionIndex = 0,positionKey = "type", positionIndex = 0, positionKey = "type",
value = "id" value = "id"
) )
public void updateDatasource(@RequestBody UpdataDsRequest dsRequest) throws Exception{ public void updateDatasource(@RequestBody UpdataDsRequest dsRequest) throws Exception {
datasourceService.updateDatasource(dsRequest); datasourceService.updateDatasource(dsRequest);
} }
@ -124,7 +135,7 @@ public class DatasourceController {
@ApiIgnore @ApiIgnore
@PostMapping("/getSchema") @PostMapping("/getSchema")
public List<String> getSchema(@RequestBody Datasource datasource) throws Exception { public List<String> getSchema(@RequestBody Datasource datasource) throws Exception {
return datasourceService.getSchema(datasource); return datasourceService.getSchema(datasource);
} }
@ApiIgnore @ApiIgnore

View File

@ -10,7 +10,7 @@
<select id="query" parameterType="io.dataease.ext.query.GridExample" resultMap="BaseResultMapDTO"> <select id="query" parameterType="io.dataease.ext.query.GridExample" resultMap="BaseResultMapDTO">
select datasource.*, select datasource.*,
authInfo.privileges as `privileges` authInfo.privileges as `privileges`
from (select GET_V_AUTH_MODEL_ID_P_USE (#{extendCondition}, 'link') cids) t,datasource from (select GET_V_AUTH_MODEL_ID_P_USE (#{extendCondition}, 'link') cids) t,datasource
left join ( left join (
SELECT SELECT
auth_source, auth_source,
@ -43,7 +43,7 @@
) authInfo ) authInfo
on datasource.id = authInfo.auth_source on datasource.id = authInfo.auth_source
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.gridCondition" /> <include refid="io.dataease.ext.query.GridSql.gridCondition"/>
</if> </if>
and FIND_IN_SET(datasource.id,cids) and FIND_IN_SET(datasource.id,cids)
<if test="orderByClause != null"> <if test="orderByClause != null">
@ -54,7 +54,7 @@
</if> </if>
</select> </select>
<select id="queryUnion" resultMap="BaseResultMapDTO"> <select id="queryUnion" resultMap="BaseResultMapDTO">
select datasource.*, select datasource.*,
authInfo.privileges as `privileges` authInfo.privileges as `privileges`
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'link') cids) t,datasource from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'link') cids) t,datasource
@ -91,46 +91,43 @@
on datasource.id = authInfo.auth_source on datasource.id = authInfo.auth_source
<where> <where>
FIND_IN_SET(datasource.id,cids) FIND_IN_SET(datasource.id,cids)
<if test="id != null"> <if test="id != null">
id = #{id,jdbcType=VARCHAR} and id = #{id,jdbcType=VARCHAR}
</if> </if>
<if test="name != null"> <if test="name != null">
`name` like concat('%',#{name,jdbcType=VARCHAR},'%') and `name` like concat('%',#{name,jdbcType=VARCHAR},'%')
</if> </if>
<if test="desc != null"> <if test="desc != null">
`desc` = #{desc,jdbcType=VARCHAR} and `desc` = #{desc,jdbcType=VARCHAR}
</if> </if>
<if test="type != null"> <if test="type != null">
`type` = #{type,jdbcType=VARCHAR} and `type` = #{type,jdbcType=VARCHAR}
</if> </if>
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT} and create_time = #{createTime,jdbcType=BIGINT}
</if> </if>
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT} and update_time = #{updateTime,jdbcType=BIGINT}
</if> </if>
<if test="configuration != null"> <if test="configuration != null">
configuration = #{configuration,jdbcType=LONGVARCHAR} and configuration = #{configuration,jdbcType=LONGVARCHAR}
</if> </if>
</where> </where>
<if test="sort == null"> <if test="sort == null">
order by ${sort} order by ${sort}
</if> </if>
</select> </select>
<select id="findByPanelId" resultMap="BaseResultMapDTO"> <select id="findByPanelId" resultMap="BaseResultMapDTO">
SELECT DISTINCT SELECT DISTINCT datasource.id,
datasource.id, datasource.`name`,
datasource.`name`, datasource.DESC,
datasource.DESC, datasource.type
datasource.type FROM chart_view
FROM INNER JOIN panel_view ON chart_view.id = panel_view.chart_view_id
chart_view INNER JOIN dataset_table ON chart_view.table_id = dataset_table.id
INNER JOIN panel_view ON chart_view.id = panel_view.chart_view_id INNER JOIN datasource ON dataset_table.data_source_id = datasource.id
INNER JOIN dataset_table ON chart_view.table_id = dataset_table.id WHERE panel_view.panel_id = #{panelId}
INNER JOIN datasource ON dataset_table.data_source_id = datasource.id
WHERE
panel_view.panel_id = #{panelId}
</select> </select>

View File

@ -313,13 +313,6 @@ export default {
trigger: 'blur' trigger: 'blur'
} }
], ],
roleIds: [
{
required: true,
message: this.$t('user.role_mandatory'),
trigger: 'change'
}
],
deptId: [], deptId: [],
gender: [], gender: [],
enabled: [{ required: true, trigger: 'change' }] enabled: [{ required: true, trigger: 'change' }]