[Core] [Dataset] Replace id to code

This commit is contained in:
qianmoQ 2024-04-16 19:26:43 +08:00
parent 9d30f17e15
commit 1548e3540c
8 changed files with 20 additions and 27 deletions

View File

@ -1,6 +1,5 @@
<code_scheme name="DataCapStyleScheme" version="173"> <code_scheme name="DataCapStyleScheme" version="173">
<option name="RIGHT_MARGIN" value="180" /> <option name="RIGHT_MARGIN" value="180" />
<option name="ENABLE_SECOND_REFORMAT" value="true" />
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" /> <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" /> <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="CLASS_BRACE_STYLE" value="2" /> <option name="CLASS_BRACE_STYLE" value="2" />

View File

@ -9,8 +9,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController() @RestController()
@RequestMapping(value = "/api/v1/database") @RequestMapping(value = "/api/v1/database")
public class DatabaseController public class DatabaseController
@ -26,9 +24,9 @@ public class DatabaseController
this.service = service; this.service = service;
} }
@PostMapping(value = "source/{id}") @PostMapping(value = "source/{code}")
public CommonResponse<List<DatabaseEntity>> fetchBySource(@PathVariable Long id) public CommonResponse<Object> fetchBySource(@PathVariable String code)
{ {
return this.service.getAllBySource(id); return this.service.getAllBySource(code);
} }
} }

View File

@ -3,16 +3,14 @@ package io.edurt.datacap.service.service;
import io.edurt.datacap.common.response.CommonResponse; import io.edurt.datacap.common.response.CommonResponse;
import io.edurt.datacap.service.entity.DatabaseEntity; import io.edurt.datacap.service.entity.DatabaseEntity;
import java.util.List;
public interface DatabaseService public interface DatabaseService
extends BaseService<DatabaseEntity> extends BaseService<DatabaseEntity>
{ {
/** /**
* Retrieves a list of DatabaseEntity objects based on the provided id. * Retrieves a list of DatabaseEntity objects based on the provided id.
* *
* @param id the id used to filter the results * @param code the code used to filter the results
* @return a list of DatabaseEntity objects that match the id * @return a list of DatabaseEntity objects that match the id
*/ */
CommonResponse<List<DatabaseEntity>> getAllBySource(Long id); CommonResponse<Object> getAllBySource(String code);
} }

View File

@ -1,31 +1,29 @@
package io.edurt.datacap.service.service.impl; package io.edurt.datacap.service.service.impl;
import io.edurt.datacap.common.response.CommonResponse; import io.edurt.datacap.common.response.CommonResponse;
import io.edurt.datacap.service.entity.DatabaseEntity; import io.edurt.datacap.service.repository.SourceRepository;
import io.edurt.datacap.service.entity.SourceEntity;
import io.edurt.datacap.service.repository.metadata.DatabaseRepository; import io.edurt.datacap.service.repository.metadata.DatabaseRepository;
import io.edurt.datacap.service.service.DatabaseService; import io.edurt.datacap.service.service.DatabaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public class DatabaseServiceImpl public class DatabaseServiceImpl
implements DatabaseService implements DatabaseService
{ {
private final DatabaseRepository repository; private final DatabaseRepository repository;
private final SourceRepository sourceRepository;
public DatabaseServiceImpl(DatabaseRepository repository) public DatabaseServiceImpl(DatabaseRepository repository, SourceRepository sourceRepository)
{ {
this.repository = repository; this.repository = repository;
this.sourceRepository = sourceRepository;
} }
@Override @Override
public CommonResponse<List<DatabaseEntity>> getAllBySource(Long id) public CommonResponse<Object> getAllBySource(String code)
{ {
SourceEntity source = SourceEntity.builder() return sourceRepository.findByCode(code)
.id(id) .map(value -> CommonResponse.success(this.repository.findAllBySource(value)))
.build(); .orElse(CommonResponse.failure(String.format("Source [ %s ] not found", code)));
return CommonResponse.success(this.repository.findAllBySource(source));
} }
} }

View File

@ -215,7 +215,7 @@ const createAdminRouter = (router: any) => {
component: () => import('@/views/pages/admin/source/SourceHome.vue') component: () => import('@/views/pages/admin/source/SourceHome.vue')
}, },
{ {
path: 'source/:id/manager', path: 'source/manager/:code',
meta: { meta: {
title: 'common.source', title: 'common.source',
isRoot: false isRoot: false

View File

@ -15,12 +15,12 @@ class DatabaseService
/** /**
* Retrieves all items by source ID. * Retrieves all items by source ID.
* *
* @param {number} id - The ID of the source. * @param {number} code - The ID of the source.
* @return {Promise<ResponseModel>} A promise that resolves to the response model. * @return {Promise<ResponseModel>} A promise that resolves to the response model.
*/ */
getAllBySource(id: string): Promise<ResponseModel> getAllBySource(code: string): Promise<ResponseModel>
{ {
return new HttpUtils().post(`${DEFAULT_PATH}/source/${id}`) return new HttpUtils().post(`${DEFAULT_PATH}/source/${code}`)
} }
} }

View File

@ -42,7 +42,7 @@
<DropdownMenuContent> <DropdownMenuContent>
<DropdownMenuGroup> <DropdownMenuGroup>
<DropdownMenuItem :disabled="(loginUserId !== row.user.id) || !row.available" class="cursor-pointer"> <DropdownMenuItem :disabled="(loginUserId !== row.user.id) || !row.available" class="cursor-pointer">
<RouterLink :to="`/admin/source/${row?.id}/manager`" target="_blank" class="flex items-center"> <RouterLink :to="`/admin/source/manager/${row?.code}`" target="_blank" class="flex items-center">
<Cog class="mr-2 h-4 w-4"/> <Cog class="mr-2 h-4 w-4"/>
<span>{{ $t('source.common.manager') }}</span> <span>{{ $t('source.common.manager') }}</span>
</RouterLink> </RouterLink>

View File

@ -262,8 +262,8 @@ export default defineComponent({
{ {
this.loading = true this.loading = true
const router = useRouter() const router = useRouter()
const id = router.currentRoute?.value?.params['id'] const code = router.currentRoute?.value?.params['code'] as string
DatabaseService.getAllBySource(id as unknown as string) DatabaseService.getAllBySource(code)
.then(response => { .then(response => {
if (response.status) { if (response.status) {
response.data.forEach((item: { name: null; catalog: null; id: null }) => { response.data.forEach((item: { name: null; catalog: null; id: null }) => {