数据源管理页面-新增与修改页面:增加智能填入功能

sql执行器页面刷新记住数据源,可同时存在多个数据源执行器页面
This commit is contained in:
diant
2023-05-22 18:32:42 +08:00
parent 6642ba24cc
commit a02aa870ae
14 changed files with 310 additions and 56 deletions

View File

@@ -18,4 +18,9 @@ public interface DbDatasourceService extends IService<DbDatasource> {
* @return List<DbDatasource>
*/
List<DbDatasource> getDataSourceList();
/**
* 获取数据源
*/
DbDatasource getDataSource(Long sourceId);
}

View File

@@ -12,6 +12,7 @@ import com.zyplayer.doc.data.repository.support.consts.DocSysModuleType;
import com.zyplayer.doc.data.repository.support.consts.DocSysType;
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
import com.zyplayer.doc.data.service.manage.UserAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -33,6 +34,9 @@ public class DbDatasourceServiceImpl extends ServiceImpl<DbDatasourceMapper, DbD
@Resource
UserAuthService userAuthService;
@Autowired
private DbDatasourceMapper dbDatasourceMapper;
@Override
public List<DbDatasource> getDataSourceList() {
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
@@ -55,6 +59,36 @@ public class DbDatasourceServiceImpl extends ServiceImpl<DbDatasourceMapper, DbD
wrapper.in("id", userAuthDbIds);
}
wrapper.select("id", "name", "group_name");
return list(wrapper);
}
/**
* 获取数据源
*/
@Override
public DbDatasource getDataSource(Long sourceId){
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
wrapper.eq("yn", 1);
wrapper.eq("id", sourceId);
// 没管理权限只返回有权限的数据源
if (!DocUserUtil.haveAuth(DocAuthConst.DB_DATASOURCE_MANAGE)) {
QueryWrapper<UserAuth> updateWrapper = new QueryWrapper<>();
updateWrapper.eq("sys_type", DocSysType.DB.getType());
updateWrapper.eq("sys_module_type", DocSysModuleType.Db.DATASOURCE.getType());
updateWrapper.eq("del_flag", 0);
updateWrapper.eq("user_id", currentUser.getUserId());
List<UserAuth> userAuthList = userAuthService.list(updateWrapper);
if (userAuthList == null || userAuthList.isEmpty()) {
return null;
}
List<Long> userAuthDbIds = userAuthList.stream()
.map(UserAuth::getSysModuleId)
.collect(Collectors.toList());
wrapper.in("id", userAuthDbIds);
}
wrapper.select("id", "name", "group_name");
return dbDatasourceMapper.selectOne(wrapper);
}
}