mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-02-24 22:40:27 +00:00
整理代码
This commit is contained in:
parent
a66d67cf64
commit
591fc20e6f
@ -35,7 +35,7 @@ export class BaseAuthorityMiddleware implements IWebMiddleware {
|
|||||||
try {
|
try {
|
||||||
ctx.admin = jwt.verify(token, this.coolConfig.jwt.secret);
|
ctx.admin = jwt.verify(token, this.coolConfig.jwt.secret);
|
||||||
// 超管拥有所有权限
|
// 超管拥有所有权限
|
||||||
if(ctx.admin.username == 'admin' && !ctx.admin.isRefresh){
|
if (ctx.admin.username == 'admin' && !ctx.admin.isRefresh) {
|
||||||
await next();
|
await next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,27 +30,29 @@ import { DemoAppGoodsEntity } from '../../entity/goods';
|
|||||||
// 指定返回字段
|
// 指定返回字段
|
||||||
select: ['a.*', 'b.name'],
|
select: ['a.*', 'b.name'],
|
||||||
// 关联表用户表
|
// 关联表用户表
|
||||||
leftJoin: [{
|
leftJoin: [
|
||||||
|
{
|
||||||
// 管理的表
|
// 管理的表
|
||||||
entity: BaseSysUserEntity,
|
entity: BaseSysUserEntity,
|
||||||
// 别名
|
// 别名
|
||||||
alias: 'b',
|
alias: 'b',
|
||||||
// 关联条件
|
// 关联条件
|
||||||
condition: 'a.userId = b.id'
|
condition: 'a.userId = b.id',
|
||||||
}],
|
},
|
||||||
|
],
|
||||||
// 增加其他条件
|
// 增加其他条件
|
||||||
where: async (ctx: Context) => {
|
where: async (ctx: Context) => {
|
||||||
return [
|
return [
|
||||||
// 价格大于90
|
// 价格大于90
|
||||||
['a.price > :price', { price: 90.00 }]
|
['a.price > :price', { price: 90.0 }],
|
||||||
]
|
];
|
||||||
},
|
},
|
||||||
// 添加排序
|
// 添加排序
|
||||||
addOrderBy: {
|
addOrderBy: {
|
||||||
// 排序字段及排序方式
|
// 排序字段及排序方式
|
||||||
price: 'desc'
|
price: 'desc',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
export class DemoAdminGoodsController extends BaseController {
|
export class DemoAdminGoodsController extends BaseController {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -20,5 +20,5 @@ export class DemoAppGoodsEntity extends BaseEntity {
|
|||||||
price: number;
|
price: number;
|
||||||
|
|
||||||
@Column({ comment: '分类', type: 'tinyint' })
|
@Column({ comment: '分类', type: 'tinyint' })
|
||||||
type: number
|
type: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user