{
"create_time": "2023-08-21T08:27:50.146Z",
"update_time": "2023-08-24T07:54:34.000Z",
"id": 1,
"name": "部门 1",
"code": "1111",
"down_dep": [
{
"create_time": "2023-08-21T08:27:50.146Z",
"update_time": "2023-08-24T07:55:25.000Z",
"id": 22,
"name": "部门 2",
"code": "100"
}
],
"up_dep": null
},
这种接口的数据怎么修改? 还有一个问题就是 DTO 中没有 create_time ,update_time 两个字段,修改时传入就会报错。
at Query.onResult (C:\pm-server\src\driver\mysql\MysqlQueryRunner.ts:222:33)
at Query.execute (C:\pm-server\node_modules\mysql2\lib\commands\command.js:36:14)
at PoolConnection.handlePacket (C:\pm-server\node_modules\mysql2\lib\connection.js:478:34)
at PacketParser.onPacket (C:\pm-server\node_modules\mysql2\lib\connection.js:97:12)
at PacketParser.executeStart (C:\pm-server\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket.<anonymous> (C:\pm-server\node_modules\mysql2\lib\connection.js:104:25)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Socket.Readable.push (node:internal/streams/readable:234:10) {
query: 'INSERT INTO `dept`(`create_time`, `update_time`, `id`, `name`, `code`, `upDepId`) VALUES (DEFAULT, DEFAULT, DEFAULT, ?, ?, DEFAULT)',
parameters: [ '456456', '1111' ],
driverError: Error: Duplicate entry '456456' for key 'IDX_5eb4a4c9f25934f105299edffd'
at Packet.asError (C:\pm-server\node_modules\mysql2\lib\packets\packet.js:728:17)
at Query.execute (C:\pm-server\node_modules\mysql2\lib\commands\command.js:29:26)
at PoolConnection.handlePacket (C:\pm-server\node_modules\mysql2\lib\connection.js:478:34)
at PacketParser.onPacket (C:\pm-server\node_modules\mysql2\lib\connection.js:97:12)
at PacketParser.executeStart (C:\pm-server\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket.<anonymous> (C:\pm-server\node_modules\mysql2\lib\connection.js:104:25)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Socket.Readable.push (node:internal/streams/readable:234:10) {
code: 'ER_DUP_ENTRY',
errno: 1062,
sqlState: '23000',
sqlMessage: "Duplicate entry '456456' for key 'IDX_5eb4a4c9f25934f105299edffd'",
sql: "INSERT INTO `dept`(`create_time`, `update_time`, `id`, `name`, `code`, `upDepId`) VALUES (DEFAULT, DEFAULT, DEFAULT, '456456', '1111', DEFAULT)"
},
code: 'ER_DUP_ENTRY',
errno: 1062,
sqlState: '23000',
sqlMessage: "Duplicate entry '456456' for key 'IDX_5eb4a4c9f25934f105299edffd'",
sql: "INSERT INTO `dept`(`create_time`, `update_time`, `id`, `name`, `code`, `upDepId`) VALUES (DEFAULT, DEFAULT, DEFAULT, '456456', '1111', DEFAULT)"
}```
值重复异常如何处理?自己写正则吗?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.