Commit 06a45b5e authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Add published state to organization modele, allow filter on getAll endpoint

parent 233e6874
Pipeline #2368 passed with stages
in 6 minutes and 31 seconds
......@@ -17,6 +17,7 @@
coverage
node_modules
npm-debug.log
.vscode
# Don't commit *.env except the template
*.env
......
......@@ -18,10 +18,10 @@
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json",
"webpack": "webpack --config webpack.config.js",
"typeorm:generate": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:generate -n",
"typeorm:migrate": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:run",
"typeorm:revert": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:revert",
"typeorm:migrate-ci": "ts-node -r tsconfig-paths/register ./node_modules/.bin/typeorm migration:run"
"typeorm:generate": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate -n",
"typeorm:migrate": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run",
"typeorm:revert": "cross-env MIGRATION=1 ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:revert",
"typeorm:migrate-ci": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run"
},
"dependencies": {
"@godaddy/terminus": "^4.1.0",
......@@ -83,4 +83,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
\ No newline at end of file
import * as dotenv from 'dotenv';
import * as fs from 'fs';
import { config } from './config';
export class ConfigService {
......
import {MigrationInterface, QueryRunner} from "typeorm";
export class draftMode1564557674250 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "organization" ADD "published" boolean NOT NULL DEFAULT false`);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "organization" DROP COLUMN "published"`);
}
}
import { Organization } from './organization.entity';
import { Link } from '../links/link.dto';
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional, IsArray, MaxLength } from 'class-validator';
import { IsString, IsOptional, IsArray, MaxLength, IsBoolean } from 'class-validator';
export class OrganizationDTO {
@ApiModelProperty()
......@@ -27,6 +27,10 @@ export class OrganizationDTO {
@IsOptional()
@IsArray()
links?: [Link];
@ApiModelProperty()
@IsBoolean()
published: boolean;
}
export interface OrganizationsRO {
......
import { Entity, PrimaryColumn, Column, OneToMany, Generated, BeforeInsert, BeforeUpdate } from 'typeorm';
import { LinkEntity } from '../links/link.entity';
import { ApiModelProperty } from '@nestjs/swagger';
import { IsBoolean } from 'class-validator';
@Entity('organization')
export class Organization {
......@@ -31,4 +32,9 @@ export class Organization {
@Column('text', { nullable: true })
@ApiModelProperty()
logo: string;
@Column({ default: false })
@ApiModelProperty()
@IsBoolean()
published: boolean;
}
......@@ -26,7 +26,9 @@ export class OrganizationsService {
const qb = await this.organizationRepository
.createQueryBuilder('organization')
.leftJoinAndSelect('organization.links', 'links');
qb.where('1 = 1');
const [key, value] = query.q ? query.q.split(':') : [null, null];
key && value ? qb.where(`organization.${key} = :value`, { value }) : null;
// Sorting
if ('sort_by' in query) {
......
Supports Markdown
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