02232031
This commit is contained in:
parent
6cf6248b59
commit
7e485220fa
|
@ -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 {}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { RoleMapModule } from '@server/models/rbac/rbac.module';
|
||||||
import { TransformModule } from '@server/models/transform/transform.module';
|
import { TransformModule } from '@server/models/transform/transform.module';
|
||||||
|
|
||||||
import { ResourceModule } from '@server/models/resource/resource.module';
|
import { ResourceModule } from '@server/models/resource/resource.module';
|
||||||
|
import { GoodsModule } from '@server/models/goods/goods.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -33,6 +34,7 @@ import { ResourceModule } from '@server/models/resource/resource.module';
|
||||||
VisitModule,
|
VisitModule,
|
||||||
WebSocketModule,
|
WebSocketModule,
|
||||||
ResourceModule,
|
ResourceModule,
|
||||||
|
GoodsModule,
|
||||||
],
|
],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [TrpcService, TrpcRouter, Logger],
|
providers: [TrpcService, TrpcRouter, Logger],
|
||||||
|
|
|
@ -1,45 +1,80 @@
|
||||||
import { api, useStaff } from "@nice/client"
|
// import { api, useStaff } from "@nice/client"
|
||||||
import { useAuth } from "@web/src/providers/auth-provider";
|
// //import { useAuth } from "@web/src/providers/auth-provider";
|
||||||
import { Button, Tag } from "antd";
|
// import { Button, Tag } from "antd";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
// import { useEffect, useMemo, useState } from "react";
|
||||||
function HomePage(){
|
// import PersonCard from './personcard';
|
||||||
const {data} = api.staff.findMany.useQuery({
|
|
||||||
take: 10
|
// function HomePage(){
|
||||||
})
|
// // function HomePage(){
|
||||||
const {user,}=useAuth()
|
// // const {data} = api.staff.findMany.useQuery({
|
||||||
const {update,create}=useStaff()
|
// // take: 5
|
||||||
const [counter, setCounter] = useState(0)
|
// // })
|
||||||
const counterText=useMemo(()=>{
|
// // //const {user,}=useAuth()
|
||||||
return `当前计数为:${counter}`
|
// // //const {update,create}=useStaff()
|
||||||
},[counter])
|
// // const [counter, setCounter] = useState(0)
|
||||||
// const test=async ()=>{
|
// // const counterText=useMemo(()=>{
|
||||||
|
// // return `当前计数为:${counter}`
|
||||||
|
// // },[counter])
|
||||||
|
// // const test=async ()=>{
|
||||||
|
|
||||||
|
// // await update.mutateAsync({
|
||||||
|
// // where: {
|
||||||
|
// // username: user?.username
|
||||||
|
// // },
|
||||||
|
// // data: {
|
||||||
|
// // username: "test"
|
||||||
|
// // }
|
||||||
|
// // })
|
||||||
|
// // }
|
||||||
|
// // useEffect(()=>{
|
||||||
|
// // console.log(data)
|
||||||
|
// // },[data])
|
||||||
|
// return (
|
||||||
|
// <div>
|
||||||
|
// <h1>主页</h1>
|
||||||
|
// {/* 调用 PersonCard 组件 */}
|
||||||
|
// <PersonCard />
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
// // return <div className="p-2 space-y-2">
|
||||||
|
// // <Tag>当前计数为:{counter}</Tag>
|
||||||
|
// // <div className="p-z space-x-2">
|
||||||
|
// // <Button type="primary" onClick={()=>{setCounter(counter + 1)}}>加1</Button>
|
||||||
|
// // <Button danger onClick={()=>{setCounter(counter - 1)}}>减1</Button>
|
||||||
|
// // <div/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// export default HomePage;
|
||||||
|
// // export {HomePage};//main-route那里也需要加括号
|
||||||
|
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { api } from "@nice/client"
|
||||||
|
|
||||||
|
function PersonCard(){
|
||||||
|
const {data} = api.staff.findMany.useQuery({
|
||||||
|
take: 15
|
||||||
|
})
|
||||||
|
|
||||||
// await update.mutateAsync({
|
|
||||||
// where: {
|
|
||||||
// username: user?.username
|
|
||||||
// },
|
|
||||||
// data: {
|
|
||||||
// username: "test"
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
console.log(data)
|
console.log(data)
|
||||||
},[data])
|
},[data])
|
||||||
|
|
||||||
return <div className="p-2 space-y-2">
|
|
||||||
<Tag>当前计数为:{counter}</Tag>
|
|
||||||
<div className="p-z space-x-2">
|
|
||||||
<Button type="primary" onClick={()=>{setCounter(counter + 1)}}>加1</Button>
|
|
||||||
<Button danger onClick={()=>{setCounter(counter - 1)}}>减1</Button>
|
|
||||||
</div>
|
|
||||||
{
|
|
||||||
data?.map(i=>{
|
|
||||||
return <div className="p-2 rounded border shadow"><Tag>i.username</Tag></div>
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{data?.map((i, index) => (
|
||||||
|
<div key={index} className="bg-blue 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>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
export default HomePage;
|
|
||||||
// export {HomePage};//main-route那里也需要加括号
|
export default PersonCard;
|
|
@ -0,0 +1,34 @@
|
||||||
|
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;
|
|
@ -329,3 +329,44 @@ model Resource {
|
||||||
@@index([createdAt])
|
@@index([createdAt])
|
||||||
@@map("resource")
|
@@map("resource")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//商品表
|
||||||
|
model Goods {
|
||||||
|
id String @id @default(cuid()) // 商品ID
|
||||||
|
name String @unique // 商品名称
|
||||||
|
description String? // 商品描述
|
||||||
|
price Float @default(0.0) // 商品价格
|
||||||
|
images String[] @default([]) // 商品图片
|
||||||
|
tags Tag[] @relation("GoodsTags") // 多对多关系
|
||||||
|
reviews Review[] // 一对多关系
|
||||||
|
createdAt DateTime @default(now()) @map("created_at") // 创建时间
|
||||||
|
updatedAt DateTime @updatedAt @map("updated_at") // 更新时间
|
||||||
|
deletedAt DateTime? @map("deleted_at") // 删除时间,可为空
|
||||||
|
@@index([name])
|
||||||
|
@@map("goods")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标签表
|
||||||
|
model Tag {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
name String @unique
|
||||||
|
goods Goods[] @relation("GoodsTags")
|
||||||
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
deletedAt DateTime? @map("deleted_at")
|
||||||
|
@@map("tag")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Review {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
content String
|
||||||
|
rating Int @default(0)
|
||||||
|
goodsId String @map("goods_id")
|
||||||
|
goods Goods @relation(fields: [goodsId], references: [id])
|
||||||
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
deletedAt DateTime? @map("deleted_at")
|
||||||
|
@@index([goodsId])
|
||||||
|
@@index([rating])
|
||||||
|
@@map("review")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue