mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-01-22 05:58:12 +00:00
4.x 就绪
This commit is contained in:
parent
956b74084a
commit
489bfaa0f7
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cool-admin",
|
"name": "cool-admin",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"md5": "^2.3.0",
|
"md5": "^2.3.0",
|
||||||
"midwayjs-cool-alipay": "^1.0.8",
|
"midwayjs-cool-alipay": "^1.0.8",
|
||||||
"midwayjs-cool-core": "^3.2.32",
|
"midwayjs-cool-core": "/Users/mac/Documents/src/cool/admin/midway-core/core/dist/",
|
||||||
"midwayjs-cool-oss": "^1.0.12",
|
"midwayjs-cool-oss": "^1.0.12",
|
||||||
"midwayjs-cool-queue": "^1.0.8",
|
"midwayjs-cool-queue": "^1.0.8",
|
||||||
"midwayjs-cool-redis": "^1.1.6",
|
"midwayjs-cool-redis": "^1.1.6",
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { BaseSysLogService } from '../../../service/sys/log';
|
|||||||
entity: BaseSysLogEntity,
|
entity: BaseSysLogEntity,
|
||||||
pageQueryOp: {
|
pageQueryOp: {
|
||||||
keyWordLikeFields: ['b.name', 'a.params', 'a.ipAddr'],
|
keyWordLikeFields: ['b.name', 'a.params', 'a.ipAddr'],
|
||||||
select: ['a.*, b.name'],
|
select: ['a.*', 'b.name'],
|
||||||
leftJoin: [
|
leftJoin: [
|
||||||
{
|
{
|
||||||
entity: BaseSysUserEntity,
|
entity: BaseSysUserEntity,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Inject, Provide } from '@midwayjs/decorator';
|
import { Get, Inject, Provide } from '@midwayjs/decorator';
|
||||||
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
||||||
import { BaseSysMenuEntity } from '../../../entity/sys/menu';
|
import { BaseSysMenuEntity } from '../../../entity/sys/menu';
|
||||||
import { BaseSysMenuService } from '../../../service/sys/menu';
|
import { BaseSysMenuService } from '../../../service/sys/menu';
|
||||||
@ -15,4 +15,16 @@ import { BaseSysMenuService } from '../../../service/sys/menu';
|
|||||||
export class BaseSysMenuController extends BaseController {
|
export class BaseSysMenuController extends BaseController {
|
||||||
@Inject()
|
@Inject()
|
||||||
baseSysMenuService: BaseSysMenuService;
|
baseSysMenuService: BaseSysMenuService;
|
||||||
|
|
||||||
|
@Inject('cool:eps')
|
||||||
|
eps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体信息与路径
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
@Get('/eps')
|
||||||
|
public async getEps() {
|
||||||
|
return this.ok(this.eps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/app/modules/demo/controller/admin/crud.ts
Normal file
16
src/app/modules/demo/controller/admin/crud.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// import { Provide } from '@midwayjs/decorator';
|
||||||
|
// import { CoolController, BaseController } from 'midwayjs-cool-core';
|
||||||
|
// import { DemoCrudEntity } from '../../entity/crud';
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 描述
|
||||||
|
// */
|
||||||
|
// @Provide()
|
||||||
|
// @CoolController({
|
||||||
|
// api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
||||||
|
// entity: DemoCrudEntity,
|
||||||
|
// pageQueryOp: {
|
||||||
|
// fieldEq: ['age'],
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// export class AdminDemoCrudController extends BaseController {}
|
||||||
@ -2,7 +2,7 @@ import { Get, Provide } from '@midwayjs/decorator';
|
|||||||
import { Context } from 'egg';
|
import { Context } from 'egg';
|
||||||
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
||||||
import { BaseSysUserEntity } from '../../../base/entity/sys/user';
|
import { BaseSysUserEntity } from '../../../base/entity/sys/user';
|
||||||
import { DemoAppGoodsEntity } from '../../entity/goods';
|
import { DemoGoodsEntity } from '../../entity/goods';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品
|
* 商品
|
||||||
@ -12,7 +12,7 @@ import { DemoAppGoodsEntity } from '../../entity/goods';
|
|||||||
// 添加通用CRUD接口
|
// 添加通用CRUD接口
|
||||||
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
||||||
// 设置表实体
|
// 设置表实体
|
||||||
entity: DemoAppGoodsEntity,
|
entity: DemoGoodsEntity,
|
||||||
// 向表插入当前登录用户ID
|
// 向表插入当前登录用户ID
|
||||||
insertParam: async (ctx: Context) => {
|
insertParam: async (ctx: Context) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Get, Inject, Post, Provide } from '@midwayjs/decorator';
|
import { Get, Inject, Post, Provide } from '@midwayjs/decorator';
|
||||||
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
import { CoolController, BaseController } from 'midwayjs-cool-core';
|
||||||
import { IQueue } from 'midwayjs-cool-queue';
|
import { IQueue } from 'midwayjs-cool-queue';
|
||||||
import { DemoAppGoodsEntity } from '../../entity/goods';
|
import { DemoGoodsEntity } from '../../entity/goods';
|
||||||
import { DemoGoodsService } from '../../service/goods';
|
import { DemoGoodsService } from '../../service/goods';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,7 +11,7 @@ import { DemoGoodsService } from '../../service/goods';
|
|||||||
@CoolController(
|
@CoolController(
|
||||||
{
|
{
|
||||||
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
||||||
entity: DemoAppGoodsEntity,
|
entity: DemoGoodsEntity,
|
||||||
listQueryOp: {
|
listQueryOp: {
|
||||||
keyWordLikeFields: ['title'],
|
keyWordLikeFields: ['title'],
|
||||||
},
|
},
|
||||||
|
|||||||
39
src/app/modules/demo/entity/crud.ts
Normal file
39
src/app/modules/demo/entity/crud.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { EntityModel } from '@midwayjs/orm';
|
||||||
|
import { BaseEntity, CoolEntityCrud } from 'midwayjs-cool-core';
|
||||||
|
import { Column, SelectQueryBuilder } from 'typeorm';
|
||||||
|
import { DemoGoodsEntity } from './goods';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体类crud demo
|
||||||
|
*/
|
||||||
|
@CoolEntityCrud({
|
||||||
|
pageQueryOp: {
|
||||||
|
fieldEq: ['name'],
|
||||||
|
select: ['a.*', 'b.id as price'],
|
||||||
|
join: [
|
||||||
|
{
|
||||||
|
entity: DemoGoodsEntity,
|
||||||
|
alias: 'b',
|
||||||
|
condition: 'a.id = b.id',
|
||||||
|
type: 'innerJoin',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
other: async (find: SelectQueryBuilder<DemoCrudEntity>) => {
|
||||||
|
find.groupBy('a.id');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
@EntityModel('demo_crud')
|
||||||
|
export class DemoCrudEntity extends BaseEntity {
|
||||||
|
@Column({ comment: '头像' })
|
||||||
|
headImg: string;
|
||||||
|
|
||||||
|
@Column({ comment: '姓名' })
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column({ comment: '年龄' })
|
||||||
|
age: number;
|
||||||
|
|
||||||
|
@Column({ type: 'tinyint', comment: '性别 0-未知 1-男 2-女', default: 0 })
|
||||||
|
type: number;
|
||||||
|
}
|
||||||
@ -5,8 +5,8 @@ import { Column } from 'typeorm';
|
|||||||
/**
|
/**
|
||||||
* 商品
|
* 商品
|
||||||
*/
|
*/
|
||||||
@EntityModel('demo_app_goods')
|
@EntityModel('demo_goods')
|
||||||
export class DemoAppGoodsEntity extends BaseEntity {
|
export class DemoGoodsEntity extends BaseEntity {
|
||||||
@Column({ comment: '标题' })
|
@Column({ comment: '标题' })
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Inject, Provide } from '@midwayjs/decorator';
|
|||||||
import { BaseService, Cache, CoolTransaction } from 'midwayjs-cool-core';
|
import { BaseService, Cache, CoolTransaction } from 'midwayjs-cool-core';
|
||||||
import { InjectEntityModel } from '@midwayjs/orm';
|
import { InjectEntityModel } from '@midwayjs/orm';
|
||||||
import { Repository, QueryRunner } from 'typeorm';
|
import { Repository, QueryRunner } from 'typeorm';
|
||||||
import { DemoAppGoodsEntity } from '../entity/goods';
|
import { DemoGoodsEntity } from '../entity/goods';
|
||||||
import { ICoolCache } from 'midwayjs-cool-core';
|
import { ICoolCache } from 'midwayjs-cool-core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,8 +10,8 @@ import { ICoolCache } from 'midwayjs-cool-core';
|
|||||||
*/
|
*/
|
||||||
@Provide()
|
@Provide()
|
||||||
export class DemoGoodsService extends BaseService {
|
export class DemoGoodsService extends BaseService {
|
||||||
@InjectEntityModel(DemoAppGoodsEntity)
|
@InjectEntityModel(DemoGoodsEntity)
|
||||||
demoAppGoodsEntity: Repository<DemoAppGoodsEntity>;
|
demoAppGoodsEntity: Repository<DemoGoodsEntity>;
|
||||||
|
|
||||||
@Inject('cool:cache')
|
@Inject('cool:cache')
|
||||||
coolCache: ICoolCache;
|
coolCache: ICoolCache;
|
||||||
@ -31,7 +31,7 @@ export class DemoGoodsService extends BaseService {
|
|||||||
*/
|
*/
|
||||||
@CoolTransaction({ isolation: 'SERIALIZABLE' })
|
@CoolTransaction({ isolation: 'SERIALIZABLE' })
|
||||||
async testTransaction(params: any, queryRunner?: QueryRunner) {
|
async testTransaction(params: any, queryRunner?: QueryRunner) {
|
||||||
await queryRunner.manager.insert<DemoAppGoodsEntity>(DemoAppGoodsEntity, {
|
await queryRunner.manager.insert<DemoGoodsEntity>(DemoGoodsEntity, {
|
||||||
title: '这是个商品',
|
title: '这是个商品',
|
||||||
pic: '商品图',
|
pic: '商品图',
|
||||||
price: 99.0,
|
price: 99.0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user