This commit is contained in:
Li1304553726 2025-02-23 20:42:29 +08:00
commit b553dcd758
16 changed files with 76 additions and 67 deletions

View File

@ -5,6 +5,7 @@ export class GoodsController {
constructor() {
console.log('goods controller')
}
// 示例1基本查询参数
@Get('hello')
getHello(@Query('name') name?: string) {
@ -16,25 +17,12 @@ export class GoodsController {
// 示例2路径参数
@Get('detail/:id')
getDetail(@Param('id') id: string) {
return {
id: id,
detail: `Detail for product ${id}`
};
}
// 示例3多个查询参数
@Get('search')
searchProducts(
@Query('keyword') keyword: string,
@Query('page') page: number = 1,
@Query('limit') limit: number = 10
) {
return {
keyword,
page,
limit,
results: []
};
}
}

View File

@ -1,7 +0,0 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class GoodsService {
}

View File

@ -1,5 +1,10 @@
import { Injectable } from '@nestjs/common';
@Injectable()
<<<<<<< HEAD
export class GoodsService {}
=======
export class GoodsService {
}
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276

View File

@ -6,9 +6,9 @@ import { DepartmentModule } from '../department/department.module';
import { MessageController } from './message.controller';
@Module({
imports: [DepartmentModule], // 导入其他模块
providers: [MessageService, MessageRouter, TrpcService], // 注册服务器,可以被自己使用
exports: [MessageService, MessageRouter], // 导出服务器
controllers: [MessageController], // 注册控制器
imports: [DepartmentModule],
providers: [MessageService, MessageRouter, TrpcService],
exports: [MessageService, MessageRouter],
controllers: [MessageController],
})
export class MessageModule { }

View File

@ -34,7 +34,11 @@ import { GoodsModule } from '@server/models/goods/goods.module';
VisitModule,
WebSocketModule,
ResourceModule,
<<<<<<< HEAD
GoodsModule,
=======
GoodsModule
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
],
controllers: [],
providers: [TrpcService, TrpcRouter, Logger],

0
apps/web/nginx.conf Executable file → Normal file
View File

0
apps/web/src/App.css Executable file → Normal file
View File

View File

@ -1,3 +1,58 @@
<<<<<<< HEAD
import { api } from "@nice/client";
import { apiClient } from "@web/src/utils";
import { Button, Tag } from "antd";
import { useEffect, useMemo, useState } from "react";
function HomePage() {
// 使用 useQuery 钩子从 API 获取数据
const { data } = api.staff.findMany.useQuery({
take: 10
});
// 定义 counter 状态和更新函数
const [counter, setCounter] = useState<number>(0);
// 使用 useMemo 记忆化 counterText仅在 counter 变化时重新计算
const counterText = useMemo(() => {
return `当前计数为: ${counter}`;
}, [counter]);
const getData = async()=>{
const res = @wait apiClient.get(*/goods/hello*)
console.log(res)
}
// 使用 useEffect 在 data 变化时打印 data
useEffect(() => {
apiClient.get(/goods/hello)
}, [data]);
return (
<div className="p-2 space-y-2">
<Tag>{counterText}</Tag>
<div className="space-x-2">
<Button type="primary" onClick={() => setCounter(counter + 1)}>
1
</Button>
<Button danger onClick={() => setCounter(counter - 1)}>
1
</Button>
</div>
{/* 如果 data 存在,遍历并渲染每个项目的 username */}
{data?.map((item) => (
<div className="p-2 rounded border shadow" key={item.username}>
<Tag>{item.username}</Tag>
</div>
))}
</div>
);
}
export default HomePage;
=======
import { api } from "@nice/client"
import { apiClient } from "@web/src/utils"
import { Button, Tag } from "antd"
@ -43,3 +98,4 @@ function HomePage() {
}
// export { HomePage }
export default HomePage
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276

View File

@ -1,34 +0,0 @@
import React, { useEffect } from 'react';
import { api } from "@nice/client"
import { apiClient } from '@web/src/utils';
function PersonCard(){
const {data} = api.staff.findMany.useQuery({
take: 10
})
useEffect(()=>{
console.log(data)
},[data])
const getdata=async ()=>{
const res=await apiClient.get("/goods/hello")
console.log(res)
}
return (
<div>
{data?.map((i, index) => (
<div key={index} className="bg-white rounded-lg shadow-sm p-6 hover:shadow-md transition-shadow duration-300">
<div className="flex items-center">
<h3 className="text-lg font-semibold text-gray-900">{i.username}</h3>
</div>
</div>
))}
</div>
);
}
export default PersonCard;

0
apps/web/src/app/main/layout/index.tsx Executable file → Normal file
View File

View File

0
apps/web/src/components/common/input/InputList.tsx Executable file → Normal file
View File

2
apps/web/src/routes/main-route.tsx Executable file → Normal file
View File

@ -6,7 +6,7 @@ export const MainRoute: CustomRouteObject = {
element: <MainLayout></MainLayout>,
children: [
{
index: true, //默认为主页app进入第一次进入这个页面
index: true,
element: <HomePage />,
},
],

0
apps/web/src/utils/index.ts Executable file → Normal file
View File

View File

@ -330,11 +330,8 @@ model Resource {
=======
<<<<<<< HEAD
=======
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
>>>>>>> dc75314e36f86056790758574c3426f379c16a87
//商品表
model Goods {
id String @id @default(cuid()) // 商品ID

0
packages/config/src/index.ts Executable file → Normal file
View File