Skip to content

Commit 83ee69c

Browse files
Merge pull request #56 from ordero-team/fix-55
[FIX-55] Location - Address field
2 parents 5266de6 + 92bd995 commit 83ee69c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/app/owner/restaurant/location/location.controller.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class LocationController {
4141
async create(@Rest() rest, @Body() body, @Res() response) {
4242
const rules = {
4343
name: 'required|unique|safe_text',
44+
address: 'required',
4445
is_default: 'boolean',
4546
};
4647
const validation = Validator.init(body, rules);
@@ -55,6 +56,7 @@ export class LocationController {
5556

5657
const loc = new Location();
5758
loc.name = body.name;
59+
loc.address = body.address;
5860
loc.is_default = isTrue(body.is_default);
5961
loc.restaurant_id = rest.id;
6062
await loc.save();
@@ -68,6 +70,7 @@ export class LocationController {
6870
async update(@Rest() rest, @Body() body, @Res() response, @Param() param) {
6971
const rules = {
7072
name: 'required|unique|safe_text',
73+
address: 'required',
7174
is_default: 'boolean',
7275
};
7376
const validation = Validator.init(body, rules);
@@ -92,6 +95,7 @@ export class LocationController {
9295

9396
const loc = await Location.findOneByOrFail({ id: param.location_id });
9497
loc.name = body.name;
98+
loc.address = body.address;
9599
loc.is_default = isTrue(body.is_default);
96100
await loc.save();
97101

src/database/entities/owner/location.entity.ts

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export class Location extends BaseEntity {
1818
@BooleanColumn()
1919
is_default: boolean;
2020

21+
@NotNullColumn({ type: 'longtext' })
22+
address: string;
23+
2124
@Exclude()
2225
@ForeignColumn()
2326
restaurant_id: string;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class LocationAddress1726760246672 implements MigrationInterface {
4+
name = 'LocationAddress1726760246672';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`ALTER TABLE \`location\` ADD \`address\` longtext NOT NULL`);
8+
}
9+
10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`ALTER TABLE \`location\` DROP COLUMN \`address\``);
12+
}
13+
}

0 commit comments

Comments
 (0)