diff --git a/leopard-core/src/main/java/com/lanyuanxiaoyao/leopard/core/repository/StockCollectionRepository.java b/leopard-core/src/main/java/com/lanyuanxiaoyao/leopard/core/repository/StockCollectionRepository.java new file mode 100644 index 0000000..5f19279 --- /dev/null +++ b/leopard-core/src/main/java/com/lanyuanxiaoyao/leopard/core/repository/StockCollectionRepository.java @@ -0,0 +1,9 @@ +package com.lanyuanxiaoyao.leopard.core.repository; + +import com.lanyuanxiaoyao.leopard.core.entity.StockCollection; +import com.lanyuanxiaoyao.service.template.repository.SimpleRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface StockCollectionRepository extends SimpleRepository { +} diff --git a/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockCollectionController.java b/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockCollectionController.java new file mode 100644 index 0000000..61f70de --- /dev/null +++ b/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/controller/StockCollectionController.java @@ -0,0 +1,82 @@ +package com.lanyuanxiaoyao.leopard.server.controller; + +import com.lanyuanxiaoyao.leopard.core.entity.Stock; +import com.lanyuanxiaoyao.leopard.core.entity.StockCollection; +import com.lanyuanxiaoyao.leopard.server.service.StockCollectionService; +import com.lanyuanxiaoyao.leopard.server.service.StockService; +import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Function; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("stock_collection") +public class StockCollectionController extends SimpleControllerSupport { + private final StockService stockService; + + public StockCollectionController(StockCollectionService service, StockService stockService) { + super(service); + this.stockService = stockService; + } + + @Override + protected Function saveItemMapper() { + return item -> { + var collection = new StockCollection(); + collection.setId(item.id()); + collection.setName(item.name()); + collection.setDescription(item.description()); + var stocks = stockService.list(item.stockIds()); + collection.setStocks(new HashSet<>(stocks)); + return collection; + }; + } + + @Override + protected Function listItemMapper() { + return collection -> new ListItem( + collection.getId(), + collection.getName(), + collection.getDescription(), + collection.getStocks().size() + ); + } + + @Override + protected Function detailItemMapper() { + return collection -> new DetailItem( + collection.getId(), + collection.getName(), + collection.getDescription(), + collection.getStocks().size(), + collection.getStocks() + ); + } + + public record SaveItem( + Long id, + String name, + String description, + Set stockIds + ) { + } + + public record ListItem( + Long id, + String name, + String description, + Integer count + ) { + } + + public record DetailItem( + Long id, + String name, + String description, + Integer count, + Set stocks + ) { + } +} diff --git a/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/service/StockCollectionService.java b/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/service/StockCollectionService.java new file mode 100644 index 0000000..c5e012b --- /dev/null +++ b/leopard-server/src/main/java/com/lanyuanxiaoyao/leopard/server/service/StockCollectionService.java @@ -0,0 +1,15 @@ +package com.lanyuanxiaoyao.leopard.server.service; + +import com.lanyuanxiaoyao.leopard.core.entity.StockCollection; +import com.lanyuanxiaoyao.leopard.core.repository.StockCollectionRepository; +import com.lanyuanxiaoyao.service.template.service.SimpleServiceSupport; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class StockCollectionService extends SimpleServiceSupport { + public StockCollectionService(StockCollectionRepository repository) { + super(repository); + } +} diff --git a/leopard-web/src/index.tsx b/leopard-web/src/index.tsx index a134d85..b5ea14e 100644 --- a/leopard-web/src/index.tsx +++ b/leopard-web/src/index.tsx @@ -12,6 +12,7 @@ import TaskTemplateList from './pages/task/TaskTemplateList.tsx' import TaskTemplateSave from './pages/task/TaskTemplateSave.tsx' import TaskScheduleList from './pages/task/TaskScheduleList.tsx' import TaskScheduleSave from './pages/task/TaskScheduleSave.tsx' +import StockCollectionList from './pages/stock/StockCollectionList.tsx' const routes: RouteObject[] = [ { @@ -29,10 +30,6 @@ const routes: RouteObject[] = [ { path: 'stock', children: [ - { - index: true, - element: , - }, { path: 'list', Component: StockList, @@ -41,6 +38,15 @@ const routes: RouteObject[] = [ path: 'detail/:id', Component: StockDetail, }, + { + path: "collection", + children: [ + { + path: 'list', + Component: StockCollectionList, + }, + ], + }, ], }, { diff --git a/leopard-web/src/pages/Root.tsx b/leopard-web/src/pages/Root.tsx index 2f23629..e2b5f71 100644 --- a/leopard-web/src/pages/Root.tsx +++ b/leopard-web/src/pages/Root.tsx @@ -1,7 +1,10 @@ import { + ClockCircleOutlined, DeploymentUnitOutlined, + FileOutlined, InfoCircleOutlined, MoneyCollectOutlined, + StarOutlined, UnorderedListOutlined, } from '@ant-design/icons' import {type AppItemProps, ProLayout} from '@ant-design/pro-components' @@ -39,23 +42,37 @@ const menus = { { path: '/stock', name: '股票', - icon: , - }, { + routes: [ + { + path: '/stock/list', + name: '股票列表', + icon: , + }, + { + path: "/stock/collection/list", + name: '股票集', + icon: , + }, + ] + }, + { path: '/task', name: '任务', - icon: , routes: [ { path: '/task/list', name: '任务列表', + icon: , }, { path: '/task/template/list', name: '任务模板', + icon: , }, { path: '/task/schedule/list', name: '定时任务', + icon: , }, ], }, @@ -105,7 +122,7 @@ const Root: React.FC = () => { title="金钱豹" route={menus} location={{pathname: location.pathname}} - menu={{type: 'sub'}} + menu={{type: 'group'}} menuItemRender={(item, defaultDom) => {defaultDom} } diff --git a/leopard-web/src/pages/stock/StockCollectionList.tsx b/leopard-web/src/pages/stock/StockCollectionList.tsx new file mode 100644 index 0000000..89f44b5 --- /dev/null +++ b/leopard-web/src/pages/stock/StockCollectionList.tsx @@ -0,0 +1,9 @@ +import React from "react" + +function StockCollectionList() { + return ( +
+ ) +} + +export default React.memo(StockCollectionList) \ No newline at end of file diff --git a/leopard-web/src/pages/task/TaskList.tsx b/leopard-web/src/pages/task/TaskList.tsx index 3591186..674909c 100644 --- a/leopard-web/src/pages/task/TaskList.tsx +++ b/leopard-web/src/pages/task/TaskList.tsx @@ -45,8 +45,6 @@ function TaskList() { name: 'step', label: '进度', type: 'progress', - stripe: true, - animate: true, showLabel: false, }, {