mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-01 19:48:14 +08:00
refactor(core): refactor report
This commit is contained in:
parent
a42ee06dad
commit
12f0fa0f87
@ -1,11 +1,8 @@
|
||||
package io.edurt.datacap.server.controller;
|
||||
|
||||
import io.edurt.datacap.common.response.CommonResponse;
|
||||
import io.edurt.datacap.service.body.FilterBody;
|
||||
import io.edurt.datacap.service.entity.ReportEntity;
|
||||
import io.edurt.datacap.service.repository.ReportRepository;
|
||||
import io.edurt.datacap.service.service.ReportService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -23,10 +20,4 @@ public class ReportController
|
||||
this.repository = repository;
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse list(@RequestBody FilterBody filter)
|
||||
{
|
||||
return this.service.getAll(filter);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.edurt.datacap.service.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.edurt.datacap.common.enums.FunctionType;
|
||||
import io.edurt.datacap.common.view.EntityView;
|
||||
import io.edurt.datacap.service.validation.ValidationGroup;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -37,6 +39,7 @@ public class FunctionEntity
|
||||
ValidationGroup.Crud.Update.class
|
||||
})
|
||||
@Column(name = "content")
|
||||
@JsonView(value = {EntityView.UserView.class, EntityView.AdminView.class})
|
||||
private String content;
|
||||
|
||||
@NotBlank(groups = {
|
||||
@ -44,6 +47,7 @@ public class FunctionEntity
|
||||
ValidationGroup.Crud.Update.class
|
||||
})
|
||||
@Column(name = "description")
|
||||
@JsonView(value = {EntityView.UserView.class, EntityView.AdminView.class})
|
||||
private String description;
|
||||
|
||||
@NotNull(groups = {
|
||||
@ -52,6 +56,7 @@ public class FunctionEntity
|
||||
})
|
||||
@Size(min = 1)
|
||||
@Column(name = "plugin")
|
||||
@JsonView(value = {EntityView.UserView.class, EntityView.AdminView.class})
|
||||
private String plugin;
|
||||
|
||||
@NotBlank(groups = {
|
||||
@ -59,10 +64,12 @@ public class FunctionEntity
|
||||
ValidationGroup.Crud.Update.class
|
||||
})
|
||||
@Column(name = "example")
|
||||
@JsonView(value = {EntityView.UserView.class, EntityView.AdminView.class})
|
||||
private String example;
|
||||
|
||||
@Column(name = "type", unique = true)
|
||||
@Enumerated(EnumType.STRING)
|
||||
@JsonView(value = {EntityView.UserView.class, EntityView.AdminView.class})
|
||||
private FunctionType type = FunctionType.KEYWORD;
|
||||
|
||||
public List<String> getPlugin()
|
||||
|
@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.edurt.datacap.common.utils.JsonUtils;
|
||||
import io.edurt.datacap.common.view.EntityView;
|
||||
import io.edurt.datacap.plugin.Plugin;
|
||||
import io.edurt.datacap.plugin.PluginManager;
|
||||
import io.edurt.datacap.service.configure.IConfigure;
|
||||
@ -52,6 +54,7 @@ public class SourceEntity
|
||||
private String description;
|
||||
|
||||
@Column(name = "_type", nullable = false)
|
||||
@JsonView(value = {EntityView.UserView.class, EntityView.AdminView.class})
|
||||
private String type;
|
||||
|
||||
@Column(name = "protocol", unique = true, nullable = false, columnDefinition = "varchar default 'HTTP'")
|
||||
|
@ -57,8 +57,8 @@ export abstract class BaseService
|
||||
}
|
||||
}
|
||||
|
||||
deleteById(id: number): Promise<ResponseModel>
|
||||
deleteByCode(code: string): Promise<ResponseModel>
|
||||
{
|
||||
return new HttpUtils().delete(`${ this.baseUrl }/${ id }`)
|
||||
return new HttpUtils().delete(`${ this.baseUrl }/${ code }`)
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@
|
||||
|
||||
<DatasetReport v-if="publishVisible"
|
||||
:info="dataInfo as any"
|
||||
:id="Number(id)"
|
||||
:code="reportCode"
|
||||
:dimension="originalDimensions[0] as any"
|
||||
:visible="publishVisible"
|
||||
:commit-options="commitOptions as any"
|
||||
@ -264,7 +264,7 @@ export default defineComponent({
|
||||
return {
|
||||
loading: false,
|
||||
code: null as string | null,
|
||||
id: null as number | null,
|
||||
reportCode: null as string | null,
|
||||
originalMetrics: [],
|
||||
originalDimensions: [],
|
||||
originalData: [],
|
||||
@ -309,7 +309,7 @@ export default defineComponent({
|
||||
const code = this.$route.params.code as string
|
||||
this.code = code as string
|
||||
const id = this.$route.params.id
|
||||
this.id = id as unknown as number
|
||||
this.reportCode = id
|
||||
DatasetService.getColumnsByCode(this.code)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
@ -317,7 +317,7 @@ export default defineComponent({
|
||||
this.originalMetrics = response.data.filter((item: { mode: string; }) => item.mode === 'METRIC')
|
||||
this.originalDimensions = response.data.filter((item: { mode: string; }) => item.mode === 'DIMENSION')
|
||||
if (id) {
|
||||
ReportService.getById(this.id as number)
|
||||
ReportService.getByCode(id)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
this.dataInfo.name = response.data.name
|
||||
|
@ -42,7 +42,7 @@ const { proxy } = getCurrentInstance()!
|
||||
const props = defineProps<{
|
||||
visible: boolean,
|
||||
info?: { name: string, description: string, build: boolean }
|
||||
id?: number
|
||||
code?: string
|
||||
dimension?: any
|
||||
commitOptions?: any
|
||||
configure?: any
|
||||
@ -56,8 +56,8 @@ const onSubmit = () => {
|
||||
published.value = true
|
||||
const obj = props.dimension
|
||||
const configure = {
|
||||
id: 0,
|
||||
name: formState.value.name,
|
||||
code: props.code,
|
||||
realtime: true,
|
||||
type: 'DATASET',
|
||||
configure: JSON.stringify(props.commitOptions),
|
||||
@ -67,9 +67,6 @@ const onSubmit = () => {
|
||||
query: JSON.stringify(props.configure),
|
||||
description: formState.value.description
|
||||
}
|
||||
if (props.id) {
|
||||
configure.id = props.id
|
||||
}
|
||||
ReportService.saveOrUpdate(configure)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
|
@ -82,7 +82,7 @@ export default defineComponent({
|
||||
{
|
||||
if (this.info) {
|
||||
this.loading = true
|
||||
ReportService.deleteById(this.info.id as number)
|
||||
ReportService.deleteByCode(this.info.code!)
|
||||
.then((response) => {
|
||||
if (response.status) {
|
||||
this.$Message.success({
|
||||
|
@ -38,7 +38,7 @@
|
||||
</template>
|
||||
|
||||
<ShadcnDropdownItem :disabled="row.type === 'QUERY'">
|
||||
<ShadcnLink :link="`/admin/dataset/adhoc/${row.dataset?.code}/${row.id}`" target="_blank">
|
||||
<ShadcnLink :link="`/admin/dataset/adhoc/${row.dataset?.code}/${row.code}`" target="_blank">
|
||||
<div class="flex items-center space-x-2">
|
||||
<ShadcnIcon icon="Pencil" size="15"/>
|
||||
<span>{{ $t('report.common.modify') }}</span>
|
||||
|
@ -11,7 +11,7 @@
|
||||
:type="info.type"
|
||||
:configuration="JSON.parse(info.configure as string)"
|
||||
:query="info.type === 'DATASET' ? JSON.parse(info.query as string) : info.query"
|
||||
:original="info?.source?.id"/>
|
||||
:original="info?.source?.code"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -60,7 +60,7 @@ import { defineComponent } from 'vue'
|
||||
import { useHeaders } from '@/views/pages/system/function/FunctionUtils'
|
||||
import { FunctionModel } from '@/model/function'
|
||||
import FunctionService from '@/services/function'
|
||||
import SourceService from '@/services/source'
|
||||
import PluginService from '@/services/plugin'
|
||||
import { cloneDeep, omit } from 'lodash'
|
||||
|
||||
export default defineComponent({
|
||||
@ -128,17 +128,12 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
SourceService.getPlugins()
|
||||
PluginService.getPlugins()
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
const result = Array.from(
|
||||
new Set(
|
||||
(Object.values(response.data)
|
||||
.reduce((acc: any, curr) => acc.concat(curr), []) as any[])
|
||||
const result = response.data
|
||||
.filter((value: { type: string }) => value.type === 'CONNECTOR')
|
||||
.map((value: { name: string }) => ({ label: value.name, value: value.name }))
|
||||
)
|
||||
)
|
||||
|
||||
this.plugins = result
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user