Вот пример как надо писать view: [code] Теперь для модели department-model: [code]…
- User
Вот пример как надо писать view:
import { Button, Space, Table } from "antd"; import React, { useEffect, useState } from "react"; import { EditOutlined, DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons'; import ProductService from "../../api/services/product-service"; import { ProductDialog } from "../../components/dialogs/product-dialog/ProductDialog"; export const ProductView = ({ ...props }) => { const columns = [ { title: 'Код', dataIndex: 'id', key: 'id', }, { title: 'Наименование', dataIndex: 'title', key: 'title', }, { title: 'Действия', key: 'actions', render: (text, record) => { return ( <Space size="middle"> <div onClick={() => updateRecordHandler(record)}> <EditOutlined /> </div> <div onClick={() => deleteRecordHandler(record.id)}> <DeleteOutlined /> </div> </Space> ) } } ]; const [list, setList] = useState([]); const [currentRecord, setCurrentRecord] = useState(null); const [visible, setVisible] = useState(false); useEffect(() => { const fetchData = async () => { const records = await ProductService.getAllRecords(); setList(records); }; fetchData(); }, []); const createRecordHandler = () => { setCurrentRecord(null); setVisible(true); }; const updateRecordHandler = (record) => { setCurrentRecord(record); setVisible(true); }; const deleteRecordHandler = async (recordId) => { await ProductService.removeRecord(recordId); setList(list.filter(item => item.id !== recordId)); }; return ( <div style={{ padding: 16 }}> <Table dataSource={list} columns={columns} rowKey="id" /> <Button type="primary" icon={<PlusCircleOutlined />} onClick={createRecordHandler}> Создать </Button> <ProductDialog visible={visible} onOk={(record) => { if (currentRecord) { setList(list.map(item => item.id === currentRecord.id ? { ...record } : item)); } else { setList([...list, record]); } setCurrentRecord(null); setVisible(false); }} onCancel={() => setVisible(false)} currentRecord={currentRecord} /> </div> ); }Теперь для модели department-model:
const Sequelize = require('sequelize'); const sequelize = require('../connection'); const DepartmentModel = sequelize.define( 'department', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false, }, name: { type: Sequelize.STRING(50), allowNull: false, }, }, { tableName: 'department', timestamps: false, // Отключаем временные метки } ); module.exports = DepartmentModel; - Assistant
- User
Теперь по:
const Sequelize = require('sequelize'); const sequelize = require('../connection'); const InstitutionModel = sequelize.define( 'institution', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false, }, title: { type: Sequelize.STRING(100), allowNull: false, }, address: { type: Sequelize.STRING(100), allowNull: false, }, INN: { type: Sequelize.STRING(100), allowNull: false, }, KPP: { type: Sequelize.STRING(100), allowNull: false, }, }, { tableName: 'institution', timestamps: false, // Отключаем временные метки } ); module.exports = InstitutionModel; - Assistant
- User
const Sequelize = require('sequelize'); const sequelize = require('../connection'); const PersonModel = sequelize.define( 'person', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false, }, lastname: { type: Sequelize.STRING(50), allowNull: false, }, firstname: { type: Sequelize.STRING(50), allowNull: false, }, patronymic: { type: Sequelize.STRING(50), allowNull: true, // Значение по умолчанию NULL допускает null }, position: { // Использование обратных кавычек в SQL для защиты зарезервированных слов type: Sequelize.STRING(50), allowNull: false, }, phonenumber: { type: Sequelize.STRING(50), allowNull: false, }, series: { type: Sequelize.STRING(50), allowNull: false, }, number: { type: Sequelize.STRING(50), allowNull: false, }, }, { tableName: 'person', timestamps: false, // Отключаем временные метки } ); module.exports = PersonModel; - Assistant
- User
const Sequelize = require('sequelize'); const sequelize = require('../connection'); const StorageModel = sequelize.define( 'storage', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false, }, type: { type: Sequelize.STRING(50), allowNull: false, }, address: { type: Sequelize.STRING(50), allowNull: false, }, }, { tableName: 'storage', timestamps: false, // Отключаем временные метки } ); module.exports = StorageModel; - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.