Merge branch 'development' into 'devops-staging'

Development

See merge request empatnusabangsa/ppob/ppob-backend!11
This commit is contained in:
ilham dwi pratama 2021-12-10 03:59:31 +00:00
commit 1476a65695
6 changed files with 21 additions and 19 deletions

View File

@ -23,5 +23,5 @@ export class ProductCategories extends BaseModel {
() => ProductSubCategories, () => ProductSubCategories,
(subCategories) => subCategories.category, (subCategories) => subCategories.category,
) )
subCategories: ProductSubCategories; sub_categories: ProductSubCategories;
} }

View File

@ -1,9 +1,4 @@
import { import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
Entity,
Column,
PrimaryGeneratedColumn,
ManyToOne,
} from 'typeorm';
import { Product } from './product.entity'; import { Product } from './product.entity';
import { BaseModel } from '../../config/basemodel.entity'; import { BaseModel } from '../../config/basemodel.entity';
import { productType } from '../../helper/enum-list'; import { productType } from '../../helper/enum-list';
@ -20,14 +15,14 @@ export class ProductHistoryPrice extends BaseModel {
price: number; price: number;
@Column() @Column()
markUpPrice: number; mark_up_price: number;
@Column({ type: 'date' }) @Column({ type: 'date' })
startDate: Date; startDate: Date;
@Column({ @Column({
type: 'date', type: 'date',
nullable:true nullable: true,
}) })
endDate: Date; endDate: Date;

View File

@ -17,9 +17,9 @@ export class ProductSubCategories extends BaseModel {
@Column() @Column()
name: string; name: string;
@ManyToOne(() => ProductCategories, (categories) => categories.subCategories) @ManyToOne(() => ProductCategories, (categories) => categories.sub_categories)
category: ProductCategories; category: ProductCategories;
@OneToMany(() => Product, (product) => product.subCategories) @OneToMany(() => Product, (product) => product.sub_categories)
product: Product; product: Product;
} }

View File

@ -42,5 +42,5 @@ export class Product extends BaseModel {
return subCategories.product; return subCategories.product;
}, },
) )
subCategories: ProductSubCategories; sub_categories: ProductSubCategories;
} }

View File

@ -27,7 +27,7 @@ export class ProductService {
name: createProductDto.name, name: createProductDto.name,
code: createProductDto.code, code: createProductDto.code,
status: createProductDto.status, status: createProductDto.status,
subCategories: subCategories, sub_categories: subCategories,
price: createProductDto.price, price: createProductDto.price,
}); });
@ -35,7 +35,7 @@ export class ProductService {
product: result.identifiers[0], product: result.identifiers[0],
type: productType.NORMAL, type: productType.NORMAL,
price: createProductDto.price, price: createProductDto.price,
markUpPrice: createProductDto.markUpPrice, mark_up_price: createProductDto.markUpPrice,
startDate: new Date(), startDate: new Date(),
endDate: null, endDate: null,
}); });
@ -111,7 +111,7 @@ export class ProductService {
name: updateProductDto.name, name: updateProductDto.name,
code: updateProductDto.code, code: updateProductDto.code,
status: updateProductDto.status, status: updateProductDto.status,
subCategories: subCategories, sub_categories: subCategories,
}); });
return this.productRepository.findOneOrFail(id); return this.productRepository.findOneOrFail(id);
@ -127,7 +127,7 @@ export class ProductService {
product: product, product: product,
type: updatePriceProductDto.type, type: updatePriceProductDto.type,
price: updatePriceProductDto.price, price: updatePriceProductDto.price,
markUpPrice: updatePriceProductDto.markUpPrice, mark_up_price: updatePriceProductDto.markUpPrice,
startDate: updatePriceProductDto.startDate, startDate: updatePriceProductDto.startDate,
endDate: updatePriceProductDto.endDate, endDate: updatePriceProductDto.endDate,
}); });

View File

@ -47,8 +47,13 @@ export class UsersController {
@Get('find-by-supperior') @Get('find-by-supperior')
async findBySuperrior(@Request() req, @Query('page') page: number) { async findBySuperrior(@Request() req, @Query('page') page: number) {
const [data, count] = await this.usersService.findBySuperrior(
req.user.userId,
page,
);
return { return {
data: await this.usersService.findBySuperrior(req.user.userId, page), data,
count,
statusCode: HttpStatus.OK, statusCode: HttpStatus.OK,
message: 'success', message: 'success',
}; };
@ -59,8 +64,10 @@ export class UsersController {
@Param('id', ParseUUIDPipe) id: string, @Param('id', ParseUUIDPipe) id: string,
@Query('page') page: number, @Query('page') page: number,
) { ) {
const [data, count] = await this.usersService.findByRoles(id, page);
return { return {
data: await this.usersService.findByRoles(id, page), data,
count,
statusCode: HttpStatus.OK, statusCode: HttpStatus.OK,
message: 'success', message: 'success',
}; };