|
@@ -4,6 +4,7 @@ import * as path from 'path';
|
|
|
@Controller('/dict')
|
|
|
export class DictController {
|
|
|
fileName = 'dict.txt';
|
|
|
+ stopFileName = 'stop_dict.txt'
|
|
|
@Get('/')
|
|
|
async getDict() {
|
|
|
const filePath = path.resolve(process.cwd(), this.fileName);
|
|
@@ -25,4 +26,26 @@ export class DictController {
|
|
|
const fileData = fs.readFileSync(filePath, 'utf-8');
|
|
|
return fileData;
|
|
|
}
|
|
|
+
|
|
|
+ @Get('/stop')
|
|
|
+ async getStopDict() {
|
|
|
+ const filePath = path.resolve(process.cwd(), this.stopFileName);
|
|
|
+ const fileData = fs.readFileSync(filePath, 'utf-8');
|
|
|
+ const list = fileData.split('\n');
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Post('/stop')
|
|
|
+ async updateStopDict(@Body('data') data: Array<string>) {
|
|
|
+ const filePath = path.resolve(process.cwd(), this.stopFileName);
|
|
|
+ const fileData = data.join('\n');
|
|
|
+ fs.writeFileSync(filePath, fileData, 'utf-8');
|
|
|
+ }
|
|
|
+
|
|
|
+ @Get('/stop/remote')
|
|
|
+ async remoteStopDict() {
|
|
|
+ const filePath = path.resolve(process.cwd(), this.stopFileName);
|
|
|
+ const fileData = fs.readFileSync(filePath, 'utf-8');
|
|
|
+ return fileData;
|
|
|
+ }
|
|
|
}
|