mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-11 05:42:49 +00:00
fix update
This commit is contained in:
parent
69536b0da1
commit
671e148c27
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-midway/core",
|
||||
"version": "8.0.2",
|
||||
"version": "8.0.3",
|
||||
"description": "cool-admin midway core",
|
||||
"main": "dist/index.js",
|
||||
"typings": "index.d.ts",
|
||||
|
||||
@ -33,6 +33,7 @@ export enum ERRINFO {
|
||||
NOENTITY = '未设置操作实体',
|
||||
NOID = '查询参数[id]不存在',
|
||||
SORTFIELD = '排序参数不正确',
|
||||
NOTFOUND = '数据不存在~',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -309,7 +309,10 @@ export abstract class BaseMysqlService {
|
||||
const upsert = this._coolConfig.crud?.upsert || 'normal';
|
||||
if (type == 'update') {
|
||||
if (upsert == 'save') {
|
||||
const info = await this.entity.findOneBy({ id: param.id });
|
||||
const info = await this.entity.findOneBy({ id: Equal(param.id) });
|
||||
if (!info) {
|
||||
throw new CoolValidateException(ERRINFO.NOTFOUND);
|
||||
}
|
||||
param = {
|
||||
...info,
|
||||
...param,
|
||||
|
||||
@ -5,7 +5,7 @@ import { Application, Context } from '@midwayjs/koa';
|
||||
import { Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { CoolConfig } from '../interface';
|
||||
import { TypeORMDataSourceManager } from '@midwayjs/typeorm';
|
||||
import { Brackets, In, Repository, SelectQueryBuilder } from 'typeorm';
|
||||
import { Brackets, Equal, In, Repository, SelectQueryBuilder } from 'typeorm';
|
||||
import { QueryOp } from '../decorator/controller';
|
||||
import * as _ from 'lodash';
|
||||
import { CoolEventManager } from '../event';
|
||||
@ -365,7 +365,10 @@ export abstract class BasePgService {
|
||||
const upsert = this._coolConfig.crud?.upsert || 'normal';
|
||||
if (type == 'update') {
|
||||
if (upsert == 'save') {
|
||||
const info = await this.entity.findOneBy({ id: param.id });
|
||||
const info = await this.entity.findOneBy({ id: Equal(param.id) });
|
||||
if (!info) {
|
||||
throw new CoolValidateException(ERRINFO.NOTFOUND);
|
||||
}
|
||||
param = {
|
||||
...info,
|
||||
...param,
|
||||
|
||||
@ -6,7 +6,7 @@ import { Application, Context } from '@midwayjs/koa';
|
||||
import * as SqlString from 'sqlstring';
|
||||
import { CoolConfig } from '../interface';
|
||||
import { TypeORMDataSourceManager } from '@midwayjs/typeorm';
|
||||
import { Brackets, In, Repository, SelectQueryBuilder } from 'typeorm';
|
||||
import { Brackets, Equal, In, Repository, SelectQueryBuilder } from 'typeorm';
|
||||
import { QueryOp } from '../decorator/controller';
|
||||
import * as _ from 'lodash';
|
||||
import { CoolEventManager } from '../event';
|
||||
@ -367,7 +367,10 @@ export abstract class BaseSqliteService {
|
||||
const upsert = this._coolConfig.crud?.upsert || 'normal';
|
||||
if (type == 'update') {
|
||||
if (upsert == 'save') {
|
||||
const info = await this.entity.findOneBy({ id: param.id });
|
||||
const info = await this.entity.findOneBy({ id: Equal(param.id) });
|
||||
if (!info) {
|
||||
throw new CoolValidateException(ERRINFO.NOTFOUND);
|
||||
}
|
||||
param = {
|
||||
...info,
|
||||
...param,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user