feat: 增加股票集相关服务
This commit is contained in:
@@ -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<StockCollection> {
|
||||
}
|
||||
@@ -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<StockCollection, StockCollectionController.SaveItem, StockCollectionController.ListItem, StockCollectionController.DetailItem> {
|
||||
private final StockService stockService;
|
||||
|
||||
public StockCollectionController(StockCollectionService service, StockService stockService) {
|
||||
super(service);
|
||||
this.stockService = stockService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<SaveItem, StockCollection> 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<StockCollection, ListItem> listItemMapper() {
|
||||
return collection -> new ListItem(
|
||||
collection.getId(),
|
||||
collection.getName(),
|
||||
collection.getDescription(),
|
||||
collection.getStocks().size()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<StockCollection, DetailItem> 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<Long> stockIds
|
||||
) {
|
||||
}
|
||||
|
||||
public record ListItem(
|
||||
Long id,
|
||||
String name,
|
||||
String description,
|
||||
Integer count
|
||||
) {
|
||||
}
|
||||
|
||||
public record DetailItem(
|
||||
Long id,
|
||||
String name,
|
||||
String description,
|
||||
Integer count,
|
||||
Set<Stock> stocks
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -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<StockCollection> {
|
||||
public StockCollectionService(StockCollectionRepository repository) {
|
||||
super(repository);
|
||||
}
|
||||
}
|
||||
@@ -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: <Navigate to="/stock/list" replace/>,
|
||||
},
|
||||
{
|
||||
path: 'list',
|
||||
Component: StockList,
|
||||
@@ -41,6 +38,15 @@ const routes: RouteObject[] = [
|
||||
path: 'detail/:id',
|
||||
Component: StockDetail,
|
||||
},
|
||||
{
|
||||
path: "collection",
|
||||
children: [
|
||||
{
|
||||
path: 'list',
|
||||
Component: StockCollectionList,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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: <MoneyCollectOutlined/>,
|
||||
}, {
|
||||
routes: [
|
||||
{
|
||||
path: '/stock/list',
|
||||
name: '股票列表',
|
||||
icon: <MoneyCollectOutlined/>,
|
||||
},
|
||||
{
|
||||
path: "/stock/collection/list",
|
||||
name: '股票集',
|
||||
icon: <StarOutlined/>,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/task',
|
||||
name: '任务',
|
||||
icon: <UnorderedListOutlined/>,
|
||||
routes: [
|
||||
{
|
||||
path: '/task/list',
|
||||
name: '任务列表',
|
||||
icon: <UnorderedListOutlined/>,
|
||||
},
|
||||
{
|
||||
path: '/task/template/list',
|
||||
name: '任务模板',
|
||||
icon: <FileOutlined/>,
|
||||
},
|
||||
{
|
||||
path: '/task/schedule/list',
|
||||
name: '定时任务',
|
||||
icon: <ClockCircleOutlined/>,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -105,7 +122,7 @@ const Root: React.FC = () => {
|
||||
title="金钱豹"
|
||||
route={menus}
|
||||
location={{pathname: location.pathname}}
|
||||
menu={{type: 'sub'}}
|
||||
menu={{type: 'group'}}
|
||||
menuItemRender={(item, defaultDom) =>
|
||||
<NavLink to={item.path || '/'}>{defaultDom}</NavLink>
|
||||
}
|
||||
|
||||
9
leopard-web/src/pages/stock/StockCollectionList.tsx
Normal file
9
leopard-web/src/pages/stock/StockCollectionList.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from "react"
|
||||
|
||||
function StockCollectionList() {
|
||||
return (
|
||||
<div className="stock-collection-list"></div>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(StockCollectionList)
|
||||
@@ -45,8 +45,6 @@ function TaskList() {
|
||||
name: 'step',
|
||||
label: '进度',
|
||||
type: 'progress',
|
||||
stripe: true,
|
||||
animate: true,
|
||||
showLabel: false,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user