mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-11 00:22:49 +00:00
BaseEntiy 外置,方便修改
This commit is contained in:
parent
6adadc5dc3
commit
7369cbbd42
@ -122,7 +122,7 @@ $ open http://localhost:8001/
|
||||
`src/modules/demo/entity/goods.ts`,项目启动数据库会自动创建该表,无需手动创建
|
||||
|
||||
```ts
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity, Index } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -19,7 +19,8 @@ export default {
|
||||
logging: true,
|
||||
// 实体路径
|
||||
entities,
|
||||
// 扩展配置
|
||||
// 时区
|
||||
timezone: '+08:00',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -19,6 +19,7 @@ import * as ProdConfig from './config/config.prod';
|
||||
import * as cool from '@cool-midway/core';
|
||||
import * as upload from '@midwayjs/upload';
|
||||
import * as task from '@cool-midway/task';
|
||||
import './modules/base/entity/base';
|
||||
|
||||
@Configuration({
|
||||
imports: [
|
||||
@ -39,7 +40,7 @@ import * as task from '@cool-midway/task';
|
||||
// cool-admin 官方组件 https://cool-js.com
|
||||
cool,
|
||||
// 任务与队列
|
||||
// task,
|
||||
task,
|
||||
{
|
||||
component: info,
|
||||
enabledEnvironment: ['local', 'prod'],
|
||||
|
||||
@ -10,16 +10,17 @@ import * as entity7 from './modules/recycle/entity/data';
|
||||
import * as entity8 from './modules/plugin/entity/info';
|
||||
import * as entity9 from './modules/dict/entity/type';
|
||||
import * as entity10 from './modules/dict/entity/info';
|
||||
import * as entity11 from './modules/base/entity/sys/user_role';
|
||||
import * as entity12 from './modules/base/entity/sys/user';
|
||||
import * as entity13 from './modules/base/entity/sys/role_menu';
|
||||
import * as entity14 from './modules/base/entity/sys/role_department';
|
||||
import * as entity15 from './modules/base/entity/sys/role';
|
||||
import * as entity16 from './modules/base/entity/sys/param';
|
||||
import * as entity17 from './modules/base/entity/sys/menu';
|
||||
import * as entity18 from './modules/base/entity/sys/log';
|
||||
import * as entity19 from './modules/base/entity/sys/department';
|
||||
import * as entity20 from './modules/base/entity/sys/conf';
|
||||
import * as entity11 from './modules/base/entity/base';
|
||||
import * as entity12 from './modules/base/entity/sys/user_role';
|
||||
import * as entity13 from './modules/base/entity/sys/user';
|
||||
import * as entity14 from './modules/base/entity/sys/role_menu';
|
||||
import * as entity15 from './modules/base/entity/sys/role_department';
|
||||
import * as entity16 from './modules/base/entity/sys/role';
|
||||
import * as entity17 from './modules/base/entity/sys/param';
|
||||
import * as entity18 from './modules/base/entity/sys/menu';
|
||||
import * as entity19 from './modules/base/entity/sys/log';
|
||||
import * as entity20 from './modules/base/entity/sys/department';
|
||||
import * as entity21 from './modules/base/entity/sys/conf';
|
||||
export const entities = [
|
||||
...Object.values(entity0),
|
||||
...Object.values(entity1),
|
||||
@ -42,4 +43,5 @@ export const entities = [
|
||||
...Object.values(entity18),
|
||||
...Object.values(entity19),
|
||||
...Object.values(entity20),
|
||||
...Object.values(entity21),
|
||||
];
|
||||
|
||||
107
src/index.ts
107
src/index.ts
@ -1,107 +0,0 @@
|
||||
/** This file generated by @midwayjs/bundle-helper */
|
||||
export { MainConfiguration as Configuration } from './configuration';
|
||||
export * from './comm/path';
|
||||
export * from './comm/utils';
|
||||
export * from './config/config.default';
|
||||
export * from './modules/user/entity/wx';
|
||||
export * from './modules/user/entity/info';
|
||||
export * from './modules/user/entity/address';
|
||||
export * from './modules/task/entity/log';
|
||||
export * from './modules/task/entity/info';
|
||||
export * from './modules/space/entity/type';
|
||||
export * from './modules/space/entity/info';
|
||||
export * from './modules/recycle/entity/data';
|
||||
export * from './modules/plugin/entity/info';
|
||||
export * from './modules/dict/entity/type';
|
||||
export * from './modules/dict/entity/info';
|
||||
export * from './modules/base/entity/sys/user_role';
|
||||
export * from './modules/base/entity/sys/user';
|
||||
export * from './modules/base/entity/sys/role_menu';
|
||||
export * from './modules/base/entity/sys/role_department';
|
||||
export * from './modules/base/entity/sys/role';
|
||||
export * from './modules/base/entity/sys/param';
|
||||
export * from './modules/base/entity/sys/menu';
|
||||
export * from './modules/base/entity/sys/log';
|
||||
export * from './modules/base/entity/sys/department';
|
||||
export * from './modules/base/entity/sys/conf';
|
||||
export * from './entities';
|
||||
export * from './config/config.local';
|
||||
export * from './config/config.prod';
|
||||
export * from './interface';
|
||||
export * from './modules/base/service/sys/conf';
|
||||
export * from './modules/base/service/sys/log';
|
||||
export * from './modules/base/middleware/log';
|
||||
export * from './modules/base/middleware/authority';
|
||||
export * from './modules/base/config';
|
||||
export * from './modules/plugin/interface';
|
||||
export * from './modules/plugin/service/center';
|
||||
export * from './modules/plugin/event/init';
|
||||
export * from './modules/plugin/service/types';
|
||||
export * from './modules/plugin/service/info';
|
||||
export * from './modules/base/dto/login';
|
||||
export * from './modules/base/service/sys/data';
|
||||
export * from './modules/base/service/sys/menu';
|
||||
export * from './modules/base/service/sys/department';
|
||||
export * from './modules/base/service/sys/perms';
|
||||
export * from './modules/base/service/sys/role';
|
||||
export * from './modules/base/service/sys/login';
|
||||
export * from './modules/base/service/sys/user';
|
||||
export * from './modules/base/controller/admin/comm';
|
||||
export * from './modules/base/service/sys/param';
|
||||
export * from './modules/base/controller/admin/open';
|
||||
export * from './modules/base/controller/admin/sys/department';
|
||||
export * from './modules/base/controller/admin/sys/log';
|
||||
export * from './modules/base/controller/admin/sys/menu';
|
||||
export * from './modules/base/controller/admin/sys/param';
|
||||
export * from './modules/base/controller/admin/sys/role';
|
||||
export * from './modules/base/controller/admin/sys/user';
|
||||
export * from './modules/base/controller/app/comm';
|
||||
export * from './modules/base/event/menu';
|
||||
export * from './modules/base/job/log';
|
||||
export * from './modules/demo/config';
|
||||
export * from './modules/demo/controller/open/plugin';
|
||||
export * from './modules/dict/config';
|
||||
export * from './modules/dict/service/info';
|
||||
export * from './modules/dict/controller/admin/info';
|
||||
export * from './modules/dict/service/type';
|
||||
export * from './modules/dict/controller/admin/type';
|
||||
export * from './modules/dict/controller/app/info';
|
||||
export * from './modules/plugin/config';
|
||||
export * from './modules/plugin/controller/admin/info';
|
||||
export * from './modules/plugin/event/app';
|
||||
export * from './modules/plugin/hooks/base';
|
||||
export * from './modules/plugin/hooks/upload/interface';
|
||||
export * from './modules/plugin/hooks/upload/index';
|
||||
export * from './modules/recycle/config';
|
||||
export * from './modules/recycle/service/data';
|
||||
export * from './modules/recycle/controller/admin/data';
|
||||
export * from './modules/recycle/event/data';
|
||||
export * from './modules/recycle/schedule/data';
|
||||
export * from './modules/space/config';
|
||||
export * from './modules/space/service/info';
|
||||
export * from './modules/space/controller/admin/info';
|
||||
export * from './modules/space/service/type';
|
||||
export * from './modules/space/controller/admin/type';
|
||||
export * from './modules/task/service/bull';
|
||||
export * from './modules/task/queue/task';
|
||||
export * from './modules/task/service/local';
|
||||
export * from './modules/task/service/info';
|
||||
export * from './modules/task/middleware/task';
|
||||
export * from './modules/task/config';
|
||||
export * from './modules/task/controller/admin/info';
|
||||
export * from './modules/task/event/app';
|
||||
export * from './modules/task/service/demo';
|
||||
export * from './modules/user/middleware/app';
|
||||
export * from './modules/user/config';
|
||||
export * from './modules/user/service/address';
|
||||
export * from './modules/user/controller/admin/address';
|
||||
export * from './modules/user/controller/admin/info';
|
||||
export * from './modules/user/controller/app/address';
|
||||
export * from './modules/user/service/wx';
|
||||
export * from './modules/user/controller/app/comm';
|
||||
export * from './modules/user/service/sms';
|
||||
export * from './modules/user/service/info';
|
||||
export * from './modules/user/controller/app/info';
|
||||
export * from './modules/user/service/login';
|
||||
export * from './modules/user/controller/app/login';
|
||||
export * from './modules/user/event/app';
|
||||
30
src/modules/base/entity/base.ts
Normal file
30
src/modules/base/entity/base.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import {
|
||||
Index,
|
||||
UpdateDateColumn,
|
||||
CreateDateColumn,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { CoolBaseEntity } from '@cool-midway/core';
|
||||
|
||||
/**
|
||||
* 模型基类
|
||||
*/
|
||||
export abstract class BaseEntity extends CoolBaseEntity {
|
||||
// 默认自增
|
||||
@PrimaryGeneratedColumn('increment', {
|
||||
comment: 'ID',
|
||||
})
|
||||
id: number;
|
||||
|
||||
@Index()
|
||||
@CreateDateColumn({ comment: '创建时间' })
|
||||
createTime: Date;
|
||||
|
||||
@Index()
|
||||
@UpdateDateColumn({ comment: '更新时间' })
|
||||
updateTime: Date;
|
||||
|
||||
// @Index()
|
||||
// @Column({ comment: '租户ID', nullable: true })
|
||||
// tenantId: number;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -136,7 +136,7 @@ export class BaseSysUserService extends BaseService {
|
||||
throw new CoolCommException('用户名已经存在~');
|
||||
}
|
||||
param.password = md5(param.password);
|
||||
await this.baseSysUserEntity.save(param);
|
||||
await super.add(param);
|
||||
await this.updateUserRole(param);
|
||||
return param.id;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity, DataSource, Index } from 'typeorm';
|
||||
|
||||
console.log(DataSource);
|
||||
|
||||
@ -82,6 +82,15 @@ export class CoolPlugin extends BasePluginHook implements BaseUpload {
|
||||
const { domain } = this.pluginInfo.config;
|
||||
try {
|
||||
const { key } = ctx.fields;
|
||||
if (
|
||||
key &&
|
||||
(key.includes('..') ||
|
||||
key.includes('./') ||
|
||||
key.includes('\\') ||
|
||||
key.includes('//'))
|
||||
) {
|
||||
throw new CoolCommException('非法的key值');
|
||||
}
|
||||
if (_.isEmpty(ctx.files)) {
|
||||
throw new CoolCommException('上传文件为空');
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Entity, Column, Index } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Index, Entity } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Entity, Column, Index } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity, Index } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BaseEntity } from '@cool-midway/core';
|
||||
import { BaseEntity } from '../../base/entity/base';
|
||||
import { Column, Entity, Index } from 'typeorm';
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user