Merge branch 'main' of http://113.45.157.195:3003/insiinc/nice-playground
This commit is contained in:
commit
b553dcd758
|
@ -5,6 +5,7 @@ export class GoodsController {
|
||||||
constructor() {
|
constructor() {
|
||||||
console.log('goods controller')
|
console.log('goods controller')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 示例1:基本查询参数
|
// 示例1:基本查询参数
|
||||||
@Get('hello')
|
@Get('hello')
|
||||||
getHello(@Query('name') name?: string) {
|
getHello(@Query('name') name?: string) {
|
||||||
|
@ -16,25 +17,12 @@ export class GoodsController {
|
||||||
|
|
||||||
// 示例2:路径参数
|
// 示例2:路径参数
|
||||||
@Get('detail/:id')
|
@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,
|
keyword,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
results: []
|
results: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class GoodsService {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
<<<<<<< HEAD
|
||||||
export class GoodsService {}
|
export class GoodsService {}
|
||||||
|
=======
|
||||||
|
export class GoodsService {
|
||||||
|
|
||||||
|
}
|
||||||
|
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
|
||||||
|
|
|
@ -6,9 +6,9 @@ import { DepartmentModule } from '../department/department.module';
|
||||||
import { MessageController } from './message.controller';
|
import { MessageController } from './message.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [DepartmentModule], // 导入其他模块
|
imports: [DepartmentModule],
|
||||||
providers: [MessageService, MessageRouter, TrpcService], // 注册服务器,可以被自己使用
|
providers: [MessageService, MessageRouter, TrpcService],
|
||||||
exports: [MessageService, MessageRouter], // 导出服务器
|
exports: [MessageService, MessageRouter],
|
||||||
controllers: [MessageController], // 注册控制器
|
controllers: [MessageController],
|
||||||
})
|
})
|
||||||
export class MessageModule {}
|
export class MessageModule { }
|
||||||
|
|
|
@ -34,7 +34,11 @@ import { GoodsModule } from '@server/models/goods/goods.module';
|
||||||
VisitModule,
|
VisitModule,
|
||||||
WebSocketModule,
|
WebSocketModule,
|
||||||
ResourceModule,
|
ResourceModule,
|
||||||
|
<<<<<<< HEAD
|
||||||
|
GoodsModule,
|
||||||
|
=======
|
||||||
GoodsModule
|
GoodsModule
|
||||||
|
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
|
||||||
],
|
],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [TrpcService, TrpcRouter, Logger],
|
providers: [TrpcService, TrpcRouter, Logger],
|
||||||
|
|
|
@ -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 { api } from "@nice/client"
|
||||||
import { apiClient } from "@web/src/utils"
|
import { apiClient } from "@web/src/utils"
|
||||||
import { Button, Tag } from "antd"
|
import { Button, Tag } from "antd"
|
||||||
|
@ -43,3 +98,4 @@ function HomePage() {
|
||||||
}
|
}
|
||||||
// export { HomePage }
|
// export { HomePage }
|
||||||
export default HomePage
|
export default HomePage
|
||||||
|
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
|
||||||
|
|
|
@ -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;
|
|
|
@ -6,7 +6,7 @@ export const MainRoute: CustomRouteObject = {
|
||||||
element: <MainLayout></MainLayout>,
|
element: <MainLayout></MainLayout>,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
index: true, //默认为主页,app进入第一次进入这个页面
|
index: true,
|
||||||
element: <HomePage />,
|
element: <HomePage />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -330,11 +330,8 @@ model Resource {
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
|
>>>>>>> de6e632ec69dd408a6c4e85d5cda01a1aa8e8276
|
||||||
|
|
||||||
>>>>>>> dc75314e36f86056790758574c3426f379c16a87
|
|
||||||
//商品表
|
//商品表
|
||||||
model Goods {
|
model Goods {
|
||||||
id String @id @default(cuid()) // 商品ID
|
id String @id @default(cuid()) // 商品ID
|
||||||
|
|
Loading…
Reference in New Issue