Merge commit '671e148c274feee0c1cf6401e1ababc3688ee736' into 8.x

This commit is contained in:
COOL 2025-04-02 13:02:17 +08:00
commit 102beffc07
5 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "8.0.2", "version": "8.0.3",
"description": "cool-admin midway core", "description": "cool-admin midway core",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -33,6 +33,7 @@ export enum ERRINFO {
NOENTITY = '未设置操作实体', NOENTITY = '未设置操作实体',
NOID = '查询参数[id]不存在', NOID = '查询参数[id]不存在',
SORTFIELD = '排序参数不正确', SORTFIELD = '排序参数不正确',
NOTFOUND = '数据不存在~',
} }
/** /**

View File

@ -309,7 +309,10 @@ export abstract class BaseMysqlService {
const upsert = this._coolConfig.crud?.upsert || 'normal'; const upsert = this._coolConfig.crud?.upsert || 'normal';
if (type == 'update') { if (type == 'update') {
if (upsert == 'save') { 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 = { param = {
...info, ...info,
...param, ...param,

View File

@ -5,7 +5,7 @@ import { Application, Context } from '@midwayjs/koa';
import { Scope, ScopeEnum } from '@midwayjs/core'; import { Scope, ScopeEnum } from '@midwayjs/core';
import { CoolConfig } from '../interface'; import { CoolConfig } from '../interface';
import { TypeORMDataSourceManager } from '@midwayjs/typeorm'; 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 { QueryOp } from '../decorator/controller';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { CoolEventManager } from '../event'; import { CoolEventManager } from '../event';
@ -365,7 +365,10 @@ export abstract class BasePgService {
const upsert = this._coolConfig.crud?.upsert || 'normal'; const upsert = this._coolConfig.crud?.upsert || 'normal';
if (type == 'update') { if (type == 'update') {
if (upsert == 'save') { 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 = { param = {
...info, ...info,
...param, ...param,

View File

@ -6,7 +6,7 @@ import { Application, Context } from '@midwayjs/koa';
import * as SqlString from 'sqlstring'; import * as SqlString from 'sqlstring';
import { CoolConfig } from '../interface'; import { CoolConfig } from '../interface';
import { TypeORMDataSourceManager } from '@midwayjs/typeorm'; 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 { QueryOp } from '../decorator/controller';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { CoolEventManager } from '../event'; import { CoolEventManager } from '../event';
@ -367,7 +367,10 @@ export abstract class BaseSqliteService {
const upsert = this._coolConfig.crud?.upsert || 'normal'; const upsert = this._coolConfig.crud?.upsert || 'normal';
if (type == 'update') { if (type == 'update') {
if (upsert == 'save') { 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 = { param = {
...info, ...info,
...param, ...param,