Merge branch 'development' into 'devops-staging'
fix: add user detail on create member See merge request empatnusabangsa/ppob/ppob-backend!25
This commit is contained in:
commit
d6f4ea1680
|
@ -1,10 +1,17 @@
|
|||
import { IsNotEmpty, IsOptional, IsUUID, ValidateIf } from 'class-validator';
|
||||
import { Partner } from '../entities/partner.entity';
|
||||
import { Column } from 'typeorm';
|
||||
|
||||
export class CreateUserDto {
|
||||
@IsNotEmpty()
|
||||
username: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
name: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
phone_number: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
import { Roles } from 'src/configurable/entities/roles.entity';
|
||||
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
} from 'typeorm';
|
||||
import { BaseModel } from '../../config/basemodel.entity';
|
||||
import { hashPassword } from '../../helper/hash_password';
|
||||
import { Partner } from './partner.entity';
|
||||
import { UserDetail } from './user_detail.entity';
|
||||
|
||||
@Entity()
|
||||
export class User extends BaseModel {
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
OneToOne,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { accountType } from '../../helper/enum-list';
|
||||
import { User } from './user.entity';
|
||||
|
||||
@Entity()
|
||||
export class UserDetail {
|
||||
|
@ -9,14 +17,10 @@ export class UserDetail {
|
|||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column()
|
||||
first_name: string;
|
||||
|
||||
@Column()
|
||||
phone_number: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
})
|
||||
type: accountType;
|
||||
@OneToOne(() => User)
|
||||
@JoinColumn()
|
||||
user: User;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,11 @@ import { SupplierService } from './supplier/supplier.service';
|
|||
import { Supplier } from './entities/supplier.entity';
|
||||
import { Partner } from './entities/partner.entity';
|
||||
import { PartnerService } from './partner/partner.service';
|
||||
import { UserDetail } from './entities/user_detail.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([User, Supplier, Partner]),
|
||||
TypeOrmModule.forFeature([User, Supplier, Partner, UserDetail]),
|
||||
forwardRef(() => TransactionModule),
|
||||
ConfigurableModule,
|
||||
],
|
||||
|
|
|
@ -23,6 +23,7 @@ import { balanceType, coaType } from 'src/helper/enum-list';
|
|||
import { RoleService } from 'src/configurable/roles.service';
|
||||
import { InputCoaDto } from 'src/transaction/dto/input-coa.dto';
|
||||
import * as uuid from 'uuid';
|
||||
import { UserDetail } from './entities/user_detail.entity';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
|
@ -76,6 +77,12 @@ export class UsersService {
|
|||
await this.connection.transaction(async (manager) => {
|
||||
const result = await manager.insert(User, userData);
|
||||
|
||||
const userDetailData = new UserDetail();
|
||||
userDetailData.name = createUserDto.name;
|
||||
userDetailData.phone_number = createUserDto.phone_number;
|
||||
userDetailData.user = userData;
|
||||
const user_detail = await manager.insert(UserDetail, userDetailData);
|
||||
|
||||
const dataCoaWallet = new InputCoaDto();
|
||||
dataCoaWallet.user = userData;
|
||||
dataCoaWallet.balanceType = balanceType.CREDIT;
|
||||
|
|
Loading…
Reference in New Issue
Block a user