This commit is contained in:
Park Byung Eun 2022-08-25 03:15:12 +00:00
parent f49e8a1fb7
commit fcfae3d496
4 changed files with 142 additions and 67 deletions

View File

@ -228,12 +228,12 @@
<mat-form-field class="w-1/3 pr-2">
<mat-label>레벨</mat-label>
<mat-select
[formControlName]="'levelId'"
[formControlName]="'levelName'"
placeholder="레벨 선택"
>
<mat-option
*ngFor="let level of memberLevels"
[value]="'level.getId()'"
[value]="level.getName()"
>
{{ level.getName() }}
</mat-option>
@ -306,12 +306,12 @@
<mat-label>사이트변경</mat-label>
<mat-select
[formControlName]="'siteId'"
[formControlName]="'siteUrl'"
placeholder="사이트 선택"
>
<mat-option
*ngFor="let site of sites"
[value]="site.getId()"
[value]="site.getUrl()"
>
{{ site.getUrl() }}
</mat-option>

View File

@ -92,13 +92,6 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
isLoading = false;
searchInputControl = new FormControl();
/* NONE: 0;
NORMAL: 1;
PENDING: 2;
WITHDRAWAL: 3;
DORMANCY: 4;
BLACKLIST: 5;
SUSPENDED: 6; */
memberStateOptions = [
{
value: 1,
@ -184,13 +177,13 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
nickname: [{ value: '', disabled: true }],
ownCash: [''],
mobilePhoneNumber: [''],
levelId: [''],
levelName: [''],
state: [''],
isExcahngeMoney: [''],
comp: [''],
coupon: [''],
recommender: [{ value: '', disabled: true }],
siteId: [''],
siteUrl: [''],
recommendCount: [''],
hodingGameMoney: [{ value: '0', disabled: true }],
});
@ -288,13 +281,25 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
this._changeDetectorRef.markForCheck();
});
this._siteService
.listSites()
.then((result) => (this.sites = result.getSitesList()));
this._siteService.listSites().then((result) => {
this.sites = result
.getSitesList()
.filter((v) => !!v.getShow() && !!v.getCanUse());
this.memberDefaultForm
.get('siteUrl')
?.setValue(this.currentMember?.getSite()?.getUrl());
this._changeDetectorRef.markForCheck();
});
this._memberLevelService.listMemberLevels().then((result) => {
this.memberLevels = result
.getMemberLevelsList()
.filter((v) => !!v.getShow());
this.memberDefaultForm
.get('levelName')
?.setValue(this.currentMember?.getMemberLevel()?.getName());
this._changeDetectorRef.markForCheck();
});
this._bankService
.listBanks()
@ -313,7 +318,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
signinPw: '',
exchangePw: '',
mobilePhoneNumber: this.currentMember?.getMobilePhoneNumber(),
levelId: this.currentMember?.getMemberLevel()?.getId(),
levelName: this.currentMember?.getMemberLevel()?.getId(),
state: this.currentMember?.getState(),
nickname: this.currentMember?.getNickname(),
bankId: this.currentMember?.getBankAccount()?.getId(),
@ -384,23 +389,27 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
nickname,
ownCash,
mobilePhoneNumber,
levelId,
levelName,
state,
isExcahngeMoney,
comp,
coupon,
siteId,
siteUrl,
hodingGameMoney,
} = this.memberDefaultForm.value;
if (!!levelId && levelId == '') {
req.setMemberLevelId(levelId);
if (!!levelName && levelName !== '') {
const level = this.memberLevels.find(
(v) => v.getName() === levelName
);
if (!!level) req.setMemberLevelId(level?.getId());
}
if (!!mobilePhoneNumber && mobilePhoneNumber == '') {
if (!!mobilePhoneNumber && mobilePhoneNumber !== '') {
req.setMobilePhoneNumber(mobilePhoneNumber);
}
if (!!siteId && siteId == '') {
req.setSiteId(siteId);
if (!!siteUrl && siteUrl !== '') {
const site = this.sites.find((v) => v.getUrl() === siteUrl);
if (!!site) req.setSiteId(site.getId());
}
}
@ -477,21 +486,14 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
?.value as string;
if (!password || !passwordConfirm) {
this.changePasswordResultShowAlert = true;
this.alertConfig = {
type: 'error',
message: '비밀번호를 입력하세요.',
};
this.showAlert('error', '비밀번호를 입력하세요.');
this.closeChangePasswordAlert();
return;
}
if (password !== passwordConfirm) {
this.changePasswordResultShowAlert = true;
this.alertConfig = {
type: 'error',
message: '비밀번호가 일치하지 않습니다.',
};
this.showAlert('error', '비밀번호가 일치하지 않습니다.');
this.closeChangePasswordAlert();
return;
}
@ -510,22 +512,12 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
this._memberService
.updateMemberForPassword(req)
.then((result) => {
this.changePasswordResultShowAlert = true;
this.alertConfig = {
type: 'success',
message: '비밀번호가 수정 되었습니다.',
};
this.showAlert('success', '비밀번호가 수정 되었습니다.');
this._changeDetectorRef.markForCheck();
})
.catch((reson) => {
this.changePasswordResultShowAlert = true;
// Set the alert
this.alertConfig = {
type: 'error',
message: '패스워드 변경이 실패하였습니다.',
};
this.showAlert('error', '패스워드 변경이 실패하였습니다.');
this._changeDetectorRef.markForCheck();
})
.finally(() => this.closeChangePasswordAlert());
@ -537,10 +529,8 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
const state = event.value;
if (!state) {
this.alertConfig = {
type: 'error',
message: '상태값이 선택 되지 않았습니다.',
};
this.showAlert('error', '상태값이 선택 되지 않았습니다.');
this.closeChangePasswordAlert();
return;
}
@ -552,19 +542,10 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
this._memberService
.updateMemberForState(req)
.then((result) => {
this.changePasswordResultShowAlert = true;
this.alertConfig = {
type: 'success',
message: '회원 상태가 수정 되었습니다.',
};
this.showAlert('success', '회원 상태가 수정 되었습니다.');
})
.catch((reson) => {
this.changePasswordResultShowAlert = true;
// Set the alert
this.alertConfig = {
type: 'error',
message: '회원 상태 변경이 실패하였습니다.',
};
this.showAlert('error', '회원 상태 변경이 실패하였습니다.');
})
.finally(() => this.closeChangePasswordAlert());
}
@ -573,6 +554,15 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy {
const state = this.memberDefaultForm.get('state')?.value;
}
private showAlert(type: FuseAlertType, message: string): void {
this.changePasswordResultShowAlert = true;
// Set the alert
this.alertConfig = {
type,
message,
};
}
private closeChangePasswordAlert(): void {
setTimeout(() => {
this.changePasswordResultShowAlert = false;

View File

@ -5,12 +5,18 @@ import {
Router,
RouterStateSnapshot,
} from '@angular/router';
import { BankService } from 'app/modules/polyglot/bank/services/bank.service';
import { MemberService } from 'app/modules/polyglot/member/services/member.service';
import { MemberLevelService } from 'app/modules/polyglot/member_level/services/member_level.service';
import { SiteService } from 'app/modules/polyglot/site/services/site.service';
import { ListBanksResponse } from 'app/modules/proto/c2se/bank_pb';
import { ListMemberLevelsResponse } from 'app/modules/proto/c2se/member_level_pb';
import { GetMemberResponse } from 'app/modules/proto/c2se/member_pb';
import {
ListMembersRequest,
ListMembersResponse,
} from 'app/modules/proto/c2se/member_pb';
import { ListSitesResponse } from 'app/modules/proto/c2se/site_pb';
import { catchError, Observable, throwError } from 'rxjs';
@ -155,3 +161,84 @@ export class MemberResolver implements Resolve<any> {
return this._memberService.getMember(memberId!);
}
}
export class SitesResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private __siteService: SiteService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListSitesResponse.Result>
| Promise<ListSitesResponse.Result>
| ListSitesResponse.Result {
return this.__siteService.listSites();
}
}
export class BanksResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _bankService: BankService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListBanksResponse.Result>
| Promise<ListBanksResponse.Result>
| ListBanksResponse.Result {
return this._bankService.listBanks();
}
}
export class MemberLevelsResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _memberLevelService: MemberLevelService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListMemberLevelsResponse.Result>
| Promise<ListMemberLevelsResponse.Result>
| ListMemberLevelsResponse.Result {
return this._memberLevelService.listMemberLevels();
}
}

View File

@ -3,12 +3,7 @@ import { Route } from '@angular/router';
import { ListComponent } from 'app/modules/admin/member/user/components/list.component';
import { ViewComponent } from 'app/modules/admin/member/user/components/view.component';
import {
UsersResolver,
UserResolver,
MemberResolver,
ListMemberResolver,
} from './resolvers/user.resolver';
import { MemberResolver, ListMemberResolver } from './resolvers/user.resolver';
export const userRoutes: Route[] = [
{
@ -16,6 +11,9 @@ export const userRoutes: Route[] = [
component: ListComponent,
resolve: {
listmembers: ListMemberResolver,
// listMemberLevels: MemberLevelsResolver,
// listSite: SitesResolver,
// listBanks: BanksResolver,
},
},
{