From 77ad9893910b8e6e7d66e17ac576bc530471b832 Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Sun, 14 Aug 2022 09:45:27 +0000 Subject: [PATCH 1/2] list of partners is implemented --- .../admin/member/partner/partner.routing.ts | 15 +- .../partner/resolvers/partner.resolver.ts | 175 ++++++++++++++++++ 2 files changed, 185 insertions(+), 5 deletions(-) diff --git a/src/app/modules/admin/member/partner/partner.routing.ts b/src/app/modules/admin/member/partner/partner.routing.ts index 8b586e2..2fa6302 100644 --- a/src/app/modules/admin/member/partner/partner.routing.ts +++ b/src/app/modules/admin/member/partner/partner.routing.ts @@ -3,6 +3,11 @@ import { Route } from '@angular/router'; import { ListComponent } from './components/list.component'; import { + PartnerListForBranchResolver, + PartnerListForDivisionResolver, + PartnerListForMainOfficeResolver, + PartnerListForOfficeResolver, + PartnerListForStoreResolver, PartnerListResolver, PartnersResolver, } from './resolvers/partner.resolver'; @@ -24,35 +29,35 @@ export const partnerRoutes: Route[] = [ path: 'main-office', component: ListComponent, resolve: { - Partners: PartnersResolver, + listPartner: PartnerListForMainOfficeResolver, }, }, { path: 'branch', component: ListComponent, resolve: { - Partners: PartnersResolver, + listPartner: PartnerListForBranchResolver, }, }, { path: 'division', component: ListComponent, resolve: { - Partners: PartnersResolver, + listPartner: PartnerListForDivisionResolver, }, }, { path: 'office', component: ListComponent, resolve: { - Partners: PartnersResolver, + listPartner: PartnerListForOfficeResolver, }, }, { path: 'store', component: ListComponent, resolve: { - Partners: PartnersResolver, + listPartner: PartnerListForStoreResolver, }, }, ]; diff --git a/src/app/modules/admin/member/partner/resolvers/partner.resolver.ts b/src/app/modules/admin/member/partner/resolvers/partner.resolver.ts index 89f65d2..f81dfcf 100644 --- a/src/app/modules/admin/member/partner/resolvers/partner.resolver.ts +++ b/src/app/modules/admin/member/partner/resolvers/partner.resolver.ts @@ -128,3 +128,178 @@ export class PartnerListResolver implements Resolve { return this.__memberService.listMembers(req); } } + +@Injectable({ + providedIn: 'root', +}) +export class PartnerListForMainOfficeResolver implements Resolve { + /** + * Constructor + */ + constructor(private __memberService: MemberService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMembersResponse.Result { + let req = new ListMembersRequest(); + let search = new ListMembersRequest.Search(); + search.setMemberClassId('4b014ef5-3bab-4413-aaf9-b0040a70ec77'); + req.setSearch(search); + + return this.__memberService.listMembers(req); + } +} + +@Injectable({ + providedIn: 'root', +}) +export class PartnerListForBranchResolver implements Resolve { + /** + * Constructor + */ + constructor(private __memberService: MemberService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMembersResponse.Result { + let req = new ListMembersRequest(); + let search = new ListMembersRequest.Search(); + search.setMemberClassId('ae9b874e-5d0e-4c4d-8432-f45f02691ceb'); + req.setSearch(search); + + return this.__memberService.listMembers(req); + } +} + +@Injectable({ + providedIn: 'root', +}) +export class PartnerListForDivisionResolver implements Resolve { + /** + * Constructor + */ + constructor(private __memberService: MemberService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMembersResponse.Result { + let req = new ListMembersRequest(); + let search = new ListMembersRequest.Search(); + search.setMemberClassId('f25a17e9-5c5f-4e9c-bf80-92a9cedf829c'); + req.setSearch(search); + + return this.__memberService.listMembers(req); + } +} + +@Injectable({ + providedIn: 'root', +}) +export class PartnerListForOfficeResolver implements Resolve { + /** + * Constructor + */ + constructor(private __memberService: MemberService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMembersResponse.Result { + let req = new ListMembersRequest(); + let search = new ListMembersRequest.Search(); + search.setMemberClassId('cac7b897-2549-4f04-8415-8868f1dcb1da'); + req.setSearch(search); + + return this.__memberService.listMembers(req); + } +} + +@Injectable({ + providedIn: 'root', +}) +export class PartnerListForStoreResolver implements Resolve { + /** + * Constructor + */ + constructor(private __memberService: MemberService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMembersResponse.Result { + let req = new ListMembersRequest(); + let search = new ListMembersRequest.Search(); + search.setMemberClassId('e11cac11-3825-4f4e-9cd5-39367f23f973'); + req.setSearch(search); + + return this.__memberService.listMembers(req); + } +} From 3b7ef1a8fad40875dd65075edb6a7b5540253bbf Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Sun, 14 Aug 2022 10:29:53 +0000 Subject: [PATCH 2/2] bug fixed --- .../partner/components/list.component.html | 4 +- .../partner/components/list.component.ts | 58 +++++++++++++++---- .../compose/regist-compose.component.html | 6 +- .../compose/regist-compose.component.ts | 30 ++++++++-- 4 files changed, 77 insertions(+), 21 deletions(-) diff --git a/src/app/modules/admin/member/partner/components/list.component.html b/src/app/modules/admin/member/partner/components/list.component.html index 1f6f706..25b87b8 100644 --- a/src/app/modules/admin/member/partner/components/list.component.html +++ b/src/app/modules/admin/member/partner/components/list.component.html @@ -10,7 +10,7 @@ -
전체목록
+
{{ title }}
@@ -191,7 +191,7 @@ [color]="'primary'" (click)="__onClickRegist($event, partner)" > - 대본등록 + {{ btnTitle }}
diff --git a/src/app/modules/admin/member/partner/components/list.component.ts b/src/app/modules/admin/member/partner/components/list.component.ts index 9c5fefd..3e5d5d4 100644 --- a/src/app/modules/admin/member/partner/components/list.component.ts +++ b/src/app/modules/admin/member/partner/components/list.component.ts @@ -100,9 +100,13 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { searchInputControl = new FormControl(); selectedPartner?: Partner; pagination?: PartnerPagination; - sites!: Site[]; + __members: MemberModel[] = []; + title: string = ''; + btnTitle: string = ''; + memberClassId = ''; + private _unsubscribeAll: Subject = new Subject(); /** @@ -115,10 +119,46 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { private _activatedRoute: ActivatedRoute, private _partnerService: PartnerService, private __memberService: MemberService, - private _siteService: SiteService, + private router: Router, private _matDialog: MatDialog - ) {} + ) { + switch (this.router.url) { + case '/member/partner/all': + this.title = '전체목록'; + this.btnTitle = '대본등록'; + this.memberClassId = 'ae9b874e-5d0e-4c4d-8432-f45f02691ceb'; + break; + case '/member/partner/main-office': + this.title = '본사목록'; + this.btnTitle = '대본등록'; + this.memberClassId = 'ae9b874e-5d0e-4c4d-8432-f45f02691ceb'; + break; + case '/member/partner/branch': + this.title = '대본목록'; + this.btnTitle = '부본등록'; + this.memberClassId = 'f25a17e9-5c5f-4e9c-bf80-92a9cedf829c'; + break; + case '/member/partner/division': + this.title = '부본목록'; + this.btnTitle = '총판등록'; + this.memberClassId = 'cac7b897-2549-4f04-8415-8868f1dcb1da'; + break; + case '/member/partner/office': + this.title = '총판목록'; + this.btnTitle = '매장등록'; + this.memberClassId = 'e11cac11-3825-4f4e-9cd5-39367f23f973'; + break; + case '/member/partner/store': + this.title = '매장목록'; + this.btnTitle = '회원등록'; + this.memberClassId = '4598f07a-86d1-42a4-b038-25706683a7cd'; + break; + default: + console.log(this.router.url); + break; + } + } // ----------------------------------------------------------------------------------------------------- // @ Lifecycle hooks @@ -139,12 +179,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); }); - this._siteService - .listSites() - .then((result) => { - this.sites = result.getSitesList(); - }) - .catch((reson) => console.log(reson)); // Get the products this._activatedRoute.data.subscribe((data) => { @@ -252,7 +286,11 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { __onClickRegist(event: MouseEvent, partner: MemberModel): void { const dialogRef = this._matDialog.open(RegistComposeComponent, { - data: { title: '대본 등록', parent: partner, sites: this.sites }, + data: { + title: this.btnTitle, + parent: partner, + classId: this.memberClassId, + }, }); dialogRef diff --git a/src/app/modules/admin/member/partner/compose/regist-compose.component.html b/src/app/modules/admin/member/partner/compose/regist-compose.component.html index 12b7408..bd37d22 100644 --- a/src/app/modules/admin/member/partner/compose/regist-compose.component.html +++ b/src/app/modules/admin/member/partner/compose/regist-compose.component.html @@ -48,7 +48,7 @@ 사이트명 - + {{ site.getUrl() }} @@ -140,10 +140,10 @@ 은행명 - + {{ bank.getName() }} - 국민은행 + 은행명은 필수 입력입니다. diff --git a/src/app/modules/admin/member/partner/compose/regist-compose.component.ts b/src/app/modules/admin/member/partner/compose/regist-compose.component.ts index 2c9b083..dbfef41 100644 --- a/src/app/modules/admin/member/partner/compose/regist-compose.component.ts +++ b/src/app/modules/admin/member/partner/compose/regist-compose.component.ts @@ -19,12 +19,12 @@ import { Bank } from 'app/modules/proto/models/bank_pb'; import { Site } from 'app/modules/proto/models/site_pb'; import { MemberModel } from 'app/modules/proto/models/member_pb'; import { fuseAnimations } from '@fuse/animations'; +import { BankService } from 'app/modules/polyglot/bank/services/bank.service'; export interface RegistComposeData { title: string; parent: MemberModel; - sites: Site[]; - banks: Bank[]; + classId: string; } export interface RegistComposeResult { choice: boolean; @@ -38,6 +38,8 @@ export interface RegistComposeResult { }) export class RegistComposeComponent implements OnInit { composeForm!: FormGroup; + sites!: Site[]; + banks!: Bank[]; alert: { type: FuseAlertType; message: string } = { type: 'success', @@ -50,12 +52,14 @@ export class RegistComposeComponent implements OnInit { * Constructor */ constructor( + private _changeDetectorRef: ChangeDetectorRef, public matDialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: RegistComposeData, private _formBuilder: FormBuilder, private _identityService: IdentityService, private _memberService: MemberService, - private _changeDetectorRef: ChangeDetectorRef + private _siteService: SiteService, + private _bankService: BankService ) {} // ----------------------------------------------------------------------------------------------------- @@ -71,7 +75,7 @@ export class RegistComposeComponent implements OnInit { partnerId: [{ value: this.data.parent.getUsername(), disabled: true }], siteName: ['', [Validators.required]], signinId: ['', [Validators.required]], - password: ['', [Validators.required]], + password: ['beteran', [Validators.required]], exchangePw: ['', [Validators.required]], nickname: ['', [Validators.required]], calculateType: ['', [Validators.required]], @@ -80,6 +84,20 @@ export class RegistComposeComponent implements OnInit { accountNumber: ['', [Validators.required]], accountHolder: ['', [Validators.required]], }); + + this._siteService + .listSites() + .then((result) => { + this.sites = result.getSitesList(); + }) + .catch((reson) => console.log(reson)); + + this._bankService + .listBanks() + .then((result) => { + this.banks = result.getBanksList(); + }) + .catch((reson) => console.log(reson)); } // ----------------------------------------------------------------------------------------------------- @@ -140,7 +158,7 @@ export class RegistComposeComponent implements OnInit { member.setSiteId(siteName); member.setUsername(signinId); member.setPassword('beteran'); - member.setMemberClassId('ae9b874e-5d0e-4c4d-8432-f45f02691ceb'); + member.setMemberClassId(this.data.classId); member.setMemberLevelId('c56231ac-2120-4a81-a30a-5d41fafb6c57'); member.setReferrerMemberUsername(this.data.parent.getUsername()); member.setNickname(nickname); @@ -156,7 +174,7 @@ export class RegistComposeComponent implements OnInit { this.showAlert = true; this.alert = { type: 'error', message: '등록에 실패하였습니다.' }; }) - .finally(() => (this.showAlert = false)); + .finally(() => setTimeout(() => this.close(), 5000)); } private close(): void {