Commit a9c2bb68 authored by nanahira's avatar nanahira

make to modern nicot

parent 18188772
...@@ -6,13 +6,13 @@ WORKDIR /usr/src/app ...@@ -6,13 +6,13 @@ WORKDIR /usr/src/app
COPY ./package*.json ./ COPY ./package*.json ./
FROM base as builder FROM base as builder
RUN npm ci && npm cache clean --force RUN npm ci -f && npm cache clean --force
COPY . ./ COPY . ./
RUN npm run build RUN npm run build
FROM base FROM base
ENV NODE_ENV production ENV NODE_ENV production
RUN npm ci && npm cache clean --force RUN npm ci -f && npm cache clean --force
COPY --from=builder /usr/src/app/dist ./dist COPY --from=builder /usr/src/app/dist ./dist
COPY ./config.example.yaml ./config.yaml COPY ./config.example.yaml ./config.yaml
......
...@@ -4,7 +4,7 @@ DB_HOST: localhost ...@@ -4,7 +4,7 @@ DB_HOST: localhost
DB_USER: nanahira DB_USER: nanahira
DB_PASS: password DB_PASS: password
DB_NAME: wall DB_NAME: wall
INITIAL_TIME: '2021-12-01 00:00:00' # INITIAL_TIME: '2021-12-01 00:00:00'
FETCHER_URL: http://wenyuanwall-fetcher:3000 # FETCHER_URL: http://wenyuanwall-fetcher:3000
CRON: '0 0 1 * * *' # CRON: '0 0 1 * * *'
# http: # http:
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4,9 +4,9 @@ import { BlacklistAccountService } from './blacklist-account.service'; ...@@ -4,9 +4,9 @@ import { BlacklistAccountService } from './blacklist-account.service';
import { RestfulFactory } from 'nicot'; import { RestfulFactory } from 'nicot';
const dec = new RestfulFactory(BlacklistAccount, { const dec = new RestfulFactory(BlacklistAccount, {
fieldsToOmit: ['blacklist'], relations: ['blacklist'],
}); });
class UpdateDto extends dec.updateDto {} class FindAllDto extends dec.findAllDto {}
@Controller('blacklist') @Controller('blacklist')
export class BlacklistAccountController { export class BlacklistAccountController {
...@@ -19,7 +19,7 @@ export class BlacklistAccountController { ...@@ -19,7 +19,7 @@ export class BlacklistAccountController {
'Cache-Control', 'Cache-Control',
'public, max-age=600, stale-while-revalidate=600, stale-if-error=604800', 'public, max-age=600, stale-while-revalidate=600, stale-if-error=604800',
) )
findAll(@dec.findAllParam() param: UpdateDto) { findAll(@dec.findAllParam() param: FindAllDto) {
return this.blacklistAccountService.findAll(param); return this.blacklistAccountService.findAll(param);
} }
} }
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { BlacklistAccount } from '../entities/blacklist-account.entity'; import { BlacklistAccount } from '../entities/blacklist-account.entity';
import { InjectDataSource } from '@nestjs/typeorm'; import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
......
...@@ -9,7 +9,7 @@ import { CrudService, Inner } from 'nicot'; ...@@ -9,7 +9,7 @@ import { CrudService, Inner } from 'nicot';
@Injectable() @Injectable()
export class BlacklistService extends CrudService(Blacklist, { export class BlacklistService extends CrudService(Blacklist, {
relations: [Inner('blacklistAccount')], relations: [Inner('accounts')],
}) { }) {
constructor( constructor(
@InjectDataSource() db: DataSource, @InjectDataSource() db: DataSource,
......
import { Entity, Index, ManyToOne, SelectQueryBuilder, Unique } from 'typeorm'; import { Entity, Index, ManyToOne, Unique } from 'typeorm';
import { Blacklist } from './blacklist.entity'; import { Blacklist } from './blacklist.entity';
import { applyQueryProperty, IdBase, NotColumn, StringColumn } from 'nicot'; import { IdBase, NotColumn, QueryEqual, StringColumn } from 'nicot';
@Unique(['account', 'blacklist']) @Unique(['account', 'blacklist'])
@Entity() @Entity()
export class BlacklistAccount extends IdBase() { export class BlacklistAccount extends IdBase() {
@Index() @Index()
@QueryEqual()
@StringColumn(11, { @StringColumn(11, {
required: true, required: true,
description: 'QQ account number.', description: 'QQ account number.',
}) })
account: string; account: string;
@QueryEqual()
@StringColumn(32, { @StringColumn(32, {
required: true, required: true,
description: 'Blacklist ID.', description: 'Blacklist ID.',
...@@ -23,12 +25,4 @@ export class BlacklistAccount extends IdBase() { ...@@ -23,12 +25,4 @@ export class BlacklistAccount extends IdBase() {
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })
blacklist: Blacklist; blacklist: Blacklist;
override applyQuery(
qb: SelectQueryBuilder<BlacklistAccount>,
entityName: string,
) {
super.applyQuery(qb, entityName);
applyQueryProperty(this, qb, entityName, 'account', 'blacklistId');
}
} }
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"outDir": "./dist", "outDir": "./dist",
"baseUrl": "./", "baseUrl": "./",
"incremental": true, "incremental": true,
"esModuleInterop": true "esModuleInterop": true,
"skipLibCheck": true
}, },
"compileOnSave": true, "compileOnSave": true,
"allowJs": true "allowJs": true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment