21 lines
526 B
TypeScript
21 lines
526 B
TypeScript
|
|
import { Injectable } from '@nestjs/common';
|
||
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
||
|
|
import { Repository } from 'typeorm';
|
||
|
|
import { SysDict } from '../../entity/sysDict.entity';
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class SysDictService {
|
||
|
|
constructor(
|
||
|
|
@InjectRepository(SysDict)
|
||
|
|
private readonly dictRepo: Repository<SysDict>,
|
||
|
|
) {}
|
||
|
|
|
||
|
|
async list() {
|
||
|
|
return this.dictRepo.find({ order: { id: 'ASC' } as any });
|
||
|
|
}
|
||
|
|
|
||
|
|
async getByKey(key: string) {
|
||
|
|
return this.dictRepo.findOne({ where: { key } as any });
|
||
|
|
}
|
||
|
|
}
|