사이드메뉴-파트너관리 정리
This commit is contained in:
parent
b82b13bc30
commit
74afc90896
|
@ -214,11 +214,11 @@ export const appRoutes: Route[] = [
|
|||
// ).then((m: any) => m.PartnerStoreModule),
|
||||
// },
|
||||
{
|
||||
path: 'recommendation',
|
||||
path: 'partner-recommendation',
|
||||
loadChildren: () =>
|
||||
import(
|
||||
'app/modules/admin/member/recommendation/recommendation.module'
|
||||
).then((m: any) => m.RecommendationModule),
|
||||
'app/modules/admin/member/partner-recommendation/partner-recommendation.module'
|
||||
).then((m: any) => m.PartnerRecommendationModule),
|
||||
},
|
||||
{
|
||||
path: 'coupon',
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { assign, cloneDeep } from 'lodash-es';
|
||||
import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
|
||||
import { recommendations as recommendationsData } from './data';
|
||||
import { partnerRecommendations as partnerRecommendationsData } from './data';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MemberRecommendationMockApi {
|
||||
private _recommendations: any[] = recommendationsData;
|
||||
export class MemberPartnerRecommendationMockApi {
|
||||
private _partnerRecommendations: any[] = partnerRecommendationsData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -26,10 +26,13 @@ export class MemberRecommendationMockApi {
|
|||
*/
|
||||
registerHandlers(): void {
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Recommendations - GET
|
||||
// @ PartnerRecommendations - GET
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
this._fuseMockApiService
|
||||
.onGet('api/apps/member/recommendation/recommendations', 300)
|
||||
.onGet(
|
||||
'api/apps/member/partner-recommendation/partner-recommendations',
|
||||
300
|
||||
)
|
||||
.reply(({ request }) => {
|
||||
// Get available queries
|
||||
const search = request.params.get('search');
|
||||
|
@ -38,12 +41,14 @@ export class MemberRecommendationMockApi {
|
|||
const page = parseInt(request.params.get('page') ?? '1', 10);
|
||||
const size = parseInt(request.params.get('size') ?? '10', 10);
|
||||
|
||||
// Clone the recommendations
|
||||
let recommendations: any[] | null = cloneDeep(this._recommendations);
|
||||
// Clone the partnerRecommendations
|
||||
let partnerRecommendations: any[] | null = cloneDeep(
|
||||
this._partnerRecommendations
|
||||
);
|
||||
|
||||
// Sort the recommendations
|
||||
// Sort the partnerRecommendations
|
||||
if (sort === 'signinId' || sort === 'nickname' || sort === 'state') {
|
||||
recommendations.sort((a, b) => {
|
||||
partnerRecommendations.sort((a, b) => {
|
||||
const fieldA = a[sort].toString().toUpperCase();
|
||||
const fieldB = b[sort].toString().toUpperCase();
|
||||
return order === 'asc'
|
||||
|
@ -51,15 +56,15 @@ export class MemberRecommendationMockApi {
|
|||
: fieldB.localeCompare(fieldA);
|
||||
});
|
||||
} else {
|
||||
recommendations.sort((a, b) =>
|
||||
partnerRecommendations.sort((a, b) =>
|
||||
order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort]
|
||||
);
|
||||
}
|
||||
|
||||
// If search exists...
|
||||
if (search) {
|
||||
// Filter the recommendations
|
||||
recommendations = recommendations.filter(
|
||||
// Filter the partnerRecommendations
|
||||
partnerRecommendations = partnerRecommendations.filter(
|
||||
(contact: any) =>
|
||||
contact.name &&
|
||||
contact.name.toLowerCase().includes(search.toLowerCase())
|
||||
|
@ -67,32 +72,35 @@ export class MemberRecommendationMockApi {
|
|||
}
|
||||
|
||||
// Paginate - Start
|
||||
const recommendationsLength = recommendations.length;
|
||||
const partnerRecommendationsLength = partnerRecommendations.length;
|
||||
|
||||
// Calculate pagination details
|
||||
const begin = page * size;
|
||||
const end = Math.min(size * (page + 1), recommendationsLength);
|
||||
const lastPage = Math.max(Math.ceil(recommendationsLength / size), 1);
|
||||
const end = Math.min(size * (page + 1), partnerRecommendationsLength);
|
||||
const lastPage = Math.max(
|
||||
Math.ceil(partnerRecommendationsLength / size),
|
||||
1
|
||||
);
|
||||
|
||||
// Prepare the pagination object
|
||||
let pagination = {};
|
||||
|
||||
// If the requested page number is bigger than
|
||||
// the last possible page number, return null for
|
||||
// recommendations but also send the last possible page so
|
||||
// partnerRecommendations but also send the last possible page so
|
||||
// the app can navigate to there
|
||||
if (page > lastPage) {
|
||||
recommendations = null;
|
||||
partnerRecommendations = null;
|
||||
pagination = {
|
||||
lastPage,
|
||||
};
|
||||
} else {
|
||||
// Paginate the results by size
|
||||
recommendations = recommendations.slice(begin, end);
|
||||
partnerRecommendations = partnerRecommendations.slice(begin, end);
|
||||
|
||||
// Prepare the pagination mock-api
|
||||
pagination = {
|
||||
length: recommendationsLength,
|
||||
length: partnerRecommendationsLength,
|
||||
size: size,
|
||||
page: page,
|
||||
lastPage: lastPage,
|
||||
|
@ -105,41 +113,41 @@ export class MemberRecommendationMockApi {
|
|||
return [
|
||||
200,
|
||||
{
|
||||
recommendations,
|
||||
partnerRecommendations,
|
||||
pagination,
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Recommendation - GET
|
||||
// @ PartnerRecommendation - GET
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
this._fuseMockApiService
|
||||
.onGet('api/apps/member/recommendation/recommendation')
|
||||
.onGet('api/apps/member/partner-recommendation/partner-recommendation')
|
||||
.reply(({ request }) => {
|
||||
// Get the id from the params
|
||||
const id = request.params.get('id');
|
||||
|
||||
// Clone the recommendations
|
||||
const recommendations = cloneDeep(this._recommendations);
|
||||
// Clone the partnerRecommendations
|
||||
const partnerRecommendations = cloneDeep(this._partnerRecommendations);
|
||||
|
||||
// Find the recommendation
|
||||
const recommendation = recommendations.find(
|
||||
// Find the partnerRecommendation
|
||||
const partnerRecommendation = partnerRecommendations.find(
|
||||
(item: any) => item.id === id
|
||||
);
|
||||
|
||||
// Return the response
|
||||
return [200, recommendation];
|
||||
return [200, partnerRecommendation];
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Recommendation - POST
|
||||
// @ PartnerRecommendation - POST
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
this._fuseMockApiService
|
||||
.onPost('api/apps/member/recommendation/recommendation')
|
||||
.onPost('api/apps/member/partner-recommendation/partner-recommendation')
|
||||
.reply(() => {
|
||||
// Generate a new recommendation
|
||||
const newRecommendation = {
|
||||
// Generate a new partnerRecommendation
|
||||
const newPartnerRecommendation = {
|
||||
id: FuseMockApiUtils.guid(),
|
||||
category: '',
|
||||
name: 'A New User',
|
||||
|
@ -161,58 +169,62 @@ export class MemberRecommendationMockApi {
|
|||
active: false,
|
||||
};
|
||||
|
||||
// Unshift the new recommendation
|
||||
this._recommendations.unshift(newRecommendation);
|
||||
// Unshift the new partnerRecommendation
|
||||
this._partnerRecommendations.unshift(newPartnerRecommendation);
|
||||
|
||||
// Return the response
|
||||
return [200, newRecommendation];
|
||||
return [200, newPartnerRecommendation];
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Recommendation - PATCH
|
||||
// @ PartnerRecommendation - PATCH
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
this._fuseMockApiService
|
||||
.onPatch('api/apps/member/recommendation/recommendation')
|
||||
.onPatch('api/apps/member/partner-recommendation/partner-recommendation')
|
||||
.reply(({ request }) => {
|
||||
// Get the id and recommendation
|
||||
// Get the id and partnerRecommendation
|
||||
const id = request.body.id;
|
||||
const recommendation = cloneDeep(request.body.recommendation);
|
||||
|
||||
// Prepare the updated recommendation
|
||||
let updatedRecommendation = null;
|
||||
|
||||
// Find the recommendation and update it
|
||||
this._recommendations.forEach((item, index, recommendations) => {
|
||||
if (item.id === id) {
|
||||
// Update the recommendation
|
||||
recommendations[index] = assign(
|
||||
{},
|
||||
recommendations[index],
|
||||
recommendation
|
||||
const partnerRecommendation = cloneDeep(
|
||||
request.body.partnerRecommendation
|
||||
);
|
||||
|
||||
// Store the updated recommendation
|
||||
updatedRecommendation = recommendations[index];
|
||||
// Prepare the updated partnerRecommendation
|
||||
let updatedPartnerRecommendation = null;
|
||||
|
||||
// Find the partnerRecommendation and update it
|
||||
this._partnerRecommendations.forEach(
|
||||
(item, index, partnerRecommendations) => {
|
||||
if (item.id === id) {
|
||||
// Update the partnerRecommendation
|
||||
partnerRecommendations[index] = assign(
|
||||
{},
|
||||
partnerRecommendations[index],
|
||||
partnerRecommendation
|
||||
);
|
||||
|
||||
// Store the updated partnerRecommendation
|
||||
updatedPartnerRecommendation = partnerRecommendations[index];
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Return the response
|
||||
return [200, updatedRecommendation];
|
||||
return [200, updatedPartnerRecommendation];
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Recommendation - DELETE
|
||||
// @ PartnerRecommendation - DELETE
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
this._fuseMockApiService
|
||||
.onDelete('api/apps/member/recommendation/recommendation')
|
||||
.onDelete('api/apps/member/partner-recommendation/partner-recommendation')
|
||||
.reply(({ request }) => {
|
||||
// Get the id
|
||||
const id = request.params.get('id');
|
||||
|
||||
// Find the recommendation and delete it
|
||||
this._recommendations.forEach((item, index) => {
|
||||
// Find the partnerRecommendation and delete it
|
||||
this._partnerRecommendations.forEach((item, index) => {
|
||||
if (item.id === id) {
|
||||
this._recommendations.splice(index, 1);
|
||||
this._partnerRecommendations.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable */
|
||||
|
||||
export const recommendations = [
|
||||
export const partnerRecommendations = [
|
||||
{
|
||||
id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c',
|
||||
signinId: 'on04',
|
|
@ -67,19 +67,62 @@ export const defaultNavigation: FuseNavigationItem[] = [
|
|||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/current-user',
|
||||
},
|
||||
{
|
||||
id: 'apps.ecommerce',
|
||||
title: 'partner-management',
|
||||
type: 'collapsable',
|
||||
icon: 'heroicons_outline:shopping-cart',
|
||||
children: [
|
||||
{
|
||||
id: 'member.partner',
|
||||
title: 'Partner',
|
||||
title: 'All Partner',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/partner',
|
||||
link: '/member/partner/all',
|
||||
},
|
||||
{
|
||||
id: 'member.recommendation',
|
||||
title: 'Recommendation',
|
||||
id: 'member.partner-mainoffice',
|
||||
title: 'Partner Mainoffice',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/recommendation',
|
||||
link: '/member/partner/main-office',
|
||||
},
|
||||
{
|
||||
id: 'member.partner-branch',
|
||||
title: 'Partner Branch',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/partner/branch',
|
||||
},
|
||||
{
|
||||
id: 'member.partner-division',
|
||||
title: 'Partner Division',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/partner/division',
|
||||
},
|
||||
{
|
||||
id: 'member.partner-office',
|
||||
title: 'Partner Office',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/partner/office',
|
||||
},
|
||||
{
|
||||
id: 'member.partner-store',
|
||||
title: 'Partner Store',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/partner/store',
|
||||
},
|
||||
{
|
||||
id: 'member.partner-recommendation',
|
||||
title: 'Partner Recommendation',
|
||||
type: 'basic',
|
||||
icon: 'heroicons_outline:academic-cap',
|
||||
link: '/member/partner/recommendation',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ import { MemberPartnerBranchMockApi } from './apps/member/partner-branch/api';
|
|||
import { MemberPartnerDivisionMockApi } from './apps/member/partner-division/api';
|
||||
import { MemberPartnerOfficeMockApi } from './apps/member/partner-office/api';
|
||||
import { MemberPartnerStoreMockApi } from './apps/member/partner-store/api';
|
||||
import { MemberRecommendationMockApi } from './apps/member/recommendation/api';
|
||||
import { MemberPartnerRecommendationMockApi } from './apps/member/partner-recommendation/api';
|
||||
import { MemberCouponMockApi } from './apps/member/coupon/api';
|
||||
import { MemberCouponMoneyLogMockApi } from './apps/member/coupon-money-log/api';
|
||||
import { MemberCouponLogMockApi } from './apps/member/coupon-log/api';
|
||||
|
@ -94,7 +94,7 @@ export const mockApiServices = [
|
|||
MemberPartnerDivisionMockApi,
|
||||
MemberPartnerOfficeMockApi,
|
||||
MemberPartnerStoreMockApi,
|
||||
MemberRecommendationMockApi,
|
||||
MemberPartnerRecommendationMockApi,
|
||||
MemberCouponMockApi,
|
||||
MemberCouponMoneyLogMockApi,
|
||||
MemberCouponLogMockApi,
|
||||
|
|
|
@ -70,8 +70,15 @@
|
|||
<div
|
||||
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
|
||||
>
|
||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
||||
<ng-container *ngIf="recommendations.length > 0; else noRecommendation">
|
||||
<ng-container
|
||||
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||
>
|
||||
<ng-container
|
||||
*ngIf="
|
||||
partnerRecommendations.length > 0;
|
||||
else noPartnerRecommendation
|
||||
"
|
||||
>
|
||||
<div class="grid">
|
||||
<!-- Header -->
|
||||
<div
|
||||
|
@ -96,10 +103,12 @@
|
|||
<div class="hidden md:block">사이트</div>
|
||||
</div>
|
||||
<!-- Rows -->
|
||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
||||
<ng-container
|
||||
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||
>
|
||||
<ng-container
|
||||
*ngFor="
|
||||
let recommendation of recommendations;
|
||||
let partnerRecommendation of partnerRecommendations;
|
||||
trackBy: __trackByFn
|
||||
"
|
||||
>
|
||||
|
@ -109,25 +118,25 @@
|
|||
<div>
|
||||
<mat-checkbox></mat-checkbox>
|
||||
</div>
|
||||
<div>{{ recommendation.highRank }}</div>
|
||||
<div>{{ partnerRecommendation.highRank }}</div>
|
||||
<div>
|
||||
{{ recommendation.signinId }}
|
||||
{{ partnerRecommendation.signinId }}
|
||||
<hr style="margin: 7px 0px" />
|
||||
{{ recommendation.nickname }}
|
||||
{{ partnerRecommendation.nickname }}
|
||||
<hr style="margin: 7px 0px" />
|
||||
{{ recommendation.state }}
|
||||
{{ partnerRecommendation.state }}
|
||||
</div>
|
||||
<div>
|
||||
{{ recommendation.rank }}
|
||||
{{ partnerRecommendation.rank }}
|
||||
</div>
|
||||
<div>{{ recommendation.accountHolder }}</div>
|
||||
<div>{{ partnerRecommendation.accountHolder }}</div>
|
||||
<div class="hidden sm:block">
|
||||
{{ recommendation.holdingMoney }}
|
||||
{{ partnerRecommendation.holdingMoney }}
|
||||
<hr style="margin: 7px 0px" />
|
||||
{{ recommendation.ownComp }}
|
||||
{{ partnerRecommendation.ownComp }}
|
||||
</div>
|
||||
<div class="hidden lg:block">
|
||||
{{ recommendation.siteAddress }}
|
||||
{{ partnerRecommendation.siteAddress }}
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
@ -151,7 +160,7 @@
|
|||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noRecommendation>
|
||||
<ng-template #noPartnerRecommendation>
|
||||
<div
|
||||
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
|
||||
>
|
||||
|
@ -214,8 +223,15 @@
|
|||
<div
|
||||
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
|
||||
>
|
||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
||||
<ng-container *ngIf="recommendations.length > 0; else noRecommendation">
|
||||
<ng-container
|
||||
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||
>
|
||||
<ng-container
|
||||
*ngIf="
|
||||
partnerRecommendations.length > 0;
|
||||
else noPartnerRecommendation
|
||||
"
|
||||
>
|
||||
<div class="grid">
|
||||
<!-- Header -->
|
||||
<div
|
||||
|
@ -235,10 +251,12 @@
|
|||
<div class="hidden sm:block">회원수</div>
|
||||
</div>
|
||||
<!-- Rows -->
|
||||
<ng-container *ngIf="recommendations$ | async as recommendations">
|
||||
<ng-container
|
||||
*ngIf="partnerRecommendations$ | async as partnerRecommendations"
|
||||
>
|
||||
<ng-container
|
||||
*ngFor="
|
||||
let recommendation of recommendations;
|
||||
let partnerRecommendation of partnerRecommendations;
|
||||
trackBy: __trackByFn
|
||||
"
|
||||
>
|
||||
|
@ -248,23 +266,23 @@
|
|||
<div>
|
||||
<mat-checkbox></mat-checkbox>
|
||||
</div>
|
||||
<div>{{ recommendation.highRank }}</div>
|
||||
<div>{{ partnerRecommendation.highRank }}</div>
|
||||
<div>
|
||||
{{ recommendation.signinId }}
|
||||
{{ partnerRecommendation.signinId }}
|
||||
<hr style="margin: 7px 0px" />
|
||||
{{ recommendation.nickname }}
|
||||
{{ partnerRecommendation.nickname }}
|
||||
<hr style="margin: 7px 0px" />
|
||||
{{ recommendation.state }}
|
||||
{{ partnerRecommendation.state }}
|
||||
</div>
|
||||
<div>
|
||||
{{ recommendation.rank }}
|
||||
{{ partnerRecommendation.rank }}
|
||||
</div>
|
||||
<div>{{ recommendation.useOrNot }}</div>
|
||||
<div>{{ partnerRecommendation.useOrNot }}</div>
|
||||
<div class="hidden sm:block">
|
||||
{{ recommendation.memberCount }}
|
||||
{{ partnerRecommendation.memberCount }}
|
||||
</div>
|
||||
<div class="hidden lg:block">
|
||||
{{ recommendation.siteAddress }}
|
||||
{{ partnerRecommendation.siteAddress }}
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
@ -288,7 +306,7 @@
|
|||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #noRecommendation>
|
||||
<ng-template #noPartnerRecommendation>
|
||||
<div
|
||||
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
|
||||
>
|
|
@ -31,16 +31,16 @@ import { FuseConfirmationService } from '@fuse/services/confirmation';
|
|||
|
||||
import { User } from '../../user/models/user';
|
||||
|
||||
import { Recommendation as Recommendation } from '../models/recommendation';
|
||||
import { RecommendationPagination as RecommendationPagination } from '../models/recommendation-pagination';
|
||||
import { RecommendationService as RecommendationService } from '../services/recommendation.service';
|
||||
import { PartnerRecommendation as PartnerRecommendation } from '../models/partner-recommendation';
|
||||
import { PartnerRecommendationPagination as PartnerRecommendationPagination } from '../models/partner-recommendation-pagination';
|
||||
import { PartnerRecommendationService as PartnerRecommendationService } from '../services/partner-recommendation.service';
|
||||
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { RegistComposeComponent } from '../compose/regist-compose.component';
|
||||
@Component({
|
||||
selector: 'recommendation-list',
|
||||
selector: 'partner-recommendation-list',
|
||||
templateUrl: './list.component.html',
|
||||
styles: [
|
||||
/* language=SCSS */
|
||||
|
@ -74,15 +74,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
@ViewChild(MatPaginator) private _paginator!: MatPaginator;
|
||||
@ViewChild(MatSort) private _sort!: MatSort;
|
||||
|
||||
recommendations$!: Observable<Recommendation[] | undefined>;
|
||||
partnerRecommendations$!: Observable<PartnerRecommendation[] | undefined>;
|
||||
users$!: Observable<User[] | undefined>;
|
||||
|
||||
__isSearchOpened1 = false;
|
||||
__isSearchOpened2 = false;
|
||||
isLoading = false;
|
||||
searchInputControl = new FormControl();
|
||||
selectedRecommendation?: Recommendation;
|
||||
pagination?: RecommendationPagination;
|
||||
selectedPartnerRecommendation?: PartnerRecommendation;
|
||||
pagination?: PartnerRecommendationPagination;
|
||||
|
||||
private _unsubscribeAll: Subject<any> = new Subject<any>();
|
||||
|
||||
|
@ -93,7 +93,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
private _changeDetectorRef: ChangeDetectorRef,
|
||||
private _fuseConfirmationService: FuseConfirmationService,
|
||||
private _formBuilder: FormBuilder,
|
||||
private _recommendationService: RecommendationService,
|
||||
private _partnerRecommendationService: PartnerRecommendationService,
|
||||
private router: Router,
|
||||
private _matDialog: MatDialog
|
||||
) {}
|
||||
|
@ -107,9 +107,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
*/
|
||||
ngOnInit(): void {
|
||||
// Get the pagination
|
||||
this._recommendationService.pagination$
|
||||
this._partnerRecommendationService.pagination$
|
||||
.pipe(takeUntil(this._unsubscribeAll))
|
||||
.subscribe((pagination: RecommendationPagination | undefined) => {
|
||||
.subscribe((pagination: PartnerRecommendationPagination | undefined) => {
|
||||
// Update the pagination
|
||||
this.pagination = pagination;
|
||||
|
||||
|
@ -118,7 +118,8 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
});
|
||||
|
||||
// Get the products
|
||||
this.recommendations$ = this._recommendationService.recommendations$;
|
||||
this.partnerRecommendations$ =
|
||||
this._partnerRecommendationService.partnerRecommendations$;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +137,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
// Mark for check
|
||||
this._changeDetectorRef.markForCheck();
|
||||
|
||||
// If the recommendation changes the sort order...
|
||||
// If the partnerRecommendation changes the sort order...
|
||||
this._sort.sortChange
|
||||
.pipe(takeUntil(this._unsubscribeAll))
|
||||
.subscribe(() => {
|
||||
|
@ -149,7 +150,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||
.pipe(
|
||||
switchMap(() => {
|
||||
this.isLoading = true;
|
||||
return this._recommendationService.getRecommendations(
|
||||
return this._partnerRecommendationService.getPartnerRecommendations(
|
||||
this._paginator.pageIndex,
|
||||
this._paginator.pageSize,
|
||||
this._sort.active,
|
|
@ -1,4 +1,4 @@
|
|||
export interface RecommendationPagination {
|
||||
export interface PartnerRecommendationPagination {
|
||||
length: number;
|
||||
size: number;
|
||||
page: number;
|
|
@ -1,6 +1,6 @@
|
|||
import { NumberValueAccessor } from '@angular/forms';
|
||||
|
||||
export interface Recommendation {
|
||||
export interface PartnerRecommendation {
|
||||
id: string;
|
||||
signinId?: string;
|
||||
nickname?: string;
|
|
@ -23,14 +23,14 @@ import { SharedModule } from 'app/shared/shared.module';
|
|||
import { COMPONENTS } from './components';
|
||||
import { COMPOSE } from './compose';
|
||||
|
||||
import { recommendationRoutes } from './recommendation.routing';
|
||||
import { partnerRecommendationRoutes } from './partner-recommendation.routing';
|
||||
|
||||
@NgModule({
|
||||
declarations: [COMPONENTS, COMPOSE],
|
||||
imports: [
|
||||
TranslocoModule,
|
||||
SharedModule,
|
||||
RouterModule.forChild(recommendationRoutes),
|
||||
RouterModule.forChild(partnerRecommendationRoutes),
|
||||
|
||||
MatButtonModule,
|
||||
MatFormFieldModule,
|
||||
|
@ -48,4 +48,4 @@ import { recommendationRoutes } from './recommendation.routing';
|
|||
MatCheckboxModule,
|
||||
],
|
||||
})
|
||||
export class RecommendationModule {}
|
||||
export class PartnerRecommendationModule {}
|
|
@ -2,9 +2,9 @@ import { Route } from '@angular/router';
|
|||
|
||||
import { ListComponent } from './components/list.component';
|
||||
|
||||
import { RecommendationsResolver } from './resolvers/recommendation.resolver';
|
||||
import { PartnerRecommendationsResolver } from './resolvers/partner-recommendation.resolver';
|
||||
|
||||
export const recommendationRoutes: Route[] = [
|
||||
export const partnerRecommendationRoutes: Route[] = [
|
||||
// {
|
||||
// path: '',
|
||||
// pathMatch: 'full',
|
||||
|
@ -14,7 +14,7 @@ export const recommendationRoutes: Route[] = [
|
|||
path: '',
|
||||
component: ListComponent,
|
||||
resolve: {
|
||||
Recommendations: RecommendationsResolver,
|
||||
PartnerRecommendations: PartnerRecommendationsResolver,
|
||||
},
|
||||
},
|
||||
];
|
|
@ -7,19 +7,19 @@ import {
|
|||
} from '@angular/router';
|
||||
import { catchError, Observable, throwError } from 'rxjs';
|
||||
|
||||
import { Recommendation } from '../models/recommendation';
|
||||
import { RecommendationPagination } from '../models/recommendation-pagination';
|
||||
import { RecommendationService } from '../services/recommendation.service';
|
||||
import { PartnerRecommendation } from '../models/partner-recommendation';
|
||||
import { PartnerRecommendationPagination } from '../models/partner-recommendation-pagination';
|
||||
import { PartnerRecommendationService } from '../services/partner-recommendation.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RecommendationResolver implements Resolve<any> {
|
||||
export class PartnerRecommendationResolver implements Resolve<any> {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
constructor(
|
||||
private _recommendationServiceService: RecommendationService,
|
||||
private _partnerRecommendationServiceService: PartnerRecommendationService,
|
||||
private _router: Router
|
||||
) {}
|
||||
|
||||
|
@ -36,9 +36,9 @@ export class RecommendationResolver implements Resolve<any> {
|
|||
resolve(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<Recommendation | undefined> {
|
||||
return this._recommendationServiceService
|
||||
.getRecommendationById(route.paramMap.get('id'))
|
||||
): Observable<PartnerRecommendation | undefined> {
|
||||
return this._partnerRecommendationServiceService
|
||||
.getPartnerRecommendationById(route.paramMap.get('id'))
|
||||
.pipe(
|
||||
// Error here means the requested product is not available
|
||||
catchError((error) => {
|
||||
|
@ -61,11 +61,13 @@ export class RecommendationResolver implements Resolve<any> {
|
|||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RecommendationsResolver implements Resolve<any> {
|
||||
export class PartnerRecommendationsResolver implements Resolve<any> {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
constructor(private _recommendationService: RecommendationService) {}
|
||||
constructor(
|
||||
private _partnerRecommendationService: PartnerRecommendationService
|
||||
) {}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Public methods
|
||||
|
@ -81,9 +83,9 @@ export class RecommendationsResolver implements Resolve<any> {
|
|||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<{
|
||||
pagination: RecommendationPagination;
|
||||
recommendations: Recommendation[];
|
||||
pagination: PartnerRecommendationPagination;
|
||||
partnerRecommendations: PartnerRecommendation[];
|
||||
}> {
|
||||
return this._recommendationService.getRecommendations();
|
||||
return this._partnerRecommendationService.getPartnerRecommendations();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {
|
||||
BehaviorSubject,
|
||||
filter,
|
||||
map,
|
||||
Observable,
|
||||
of,
|
||||
switchMap,
|
||||
take,
|
||||
tap,
|
||||
throwError,
|
||||
} from 'rxjs';
|
||||
|
||||
import { PartnerRecommendation } from '../models/partner-recommendation';
|
||||
import { PartnerRecommendationPagination } from '../models/partner-recommendation-pagination';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PartnerRecommendationService {
|
||||
// Private
|
||||
private __pagination = new BehaviorSubject<
|
||||
PartnerRecommendationPagination | undefined
|
||||
>(undefined);
|
||||
private __partnerRecommendation = new BehaviorSubject<
|
||||
PartnerRecommendation | undefined
|
||||
>(undefined);
|
||||
private __partnerRecommendations = new BehaviorSubject<
|
||||
PartnerRecommendation[] | undefined
|
||||
>(undefined);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
constructor(private _httpClient: HttpClient) {}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Accessors
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Getter for pagination
|
||||
*/
|
||||
get pagination$(): Observable<PartnerRecommendationPagination | undefined> {
|
||||
return this.__pagination.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for partnerRecommendation
|
||||
*/
|
||||
get partnerRecommendation$(): Observable<PartnerRecommendation | undefined> {
|
||||
return this.__partnerRecommendation.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for partnerRecommendations
|
||||
*/
|
||||
get partnerRecommendations$(): Observable<
|
||||
PartnerRecommendation[] | undefined
|
||||
> {
|
||||
return this.__partnerRecommendations.asObservable();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Public methods
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get partnerRecommendations
|
||||
*
|
||||
*
|
||||
* @param page
|
||||
* @param size
|
||||
* @param sort
|
||||
* @param order
|
||||
* @param search
|
||||
*/
|
||||
getPartnerRecommendations(
|
||||
page: number = 0,
|
||||
size: number = 10,
|
||||
sort: string = 'name',
|
||||
order: 'asc' | 'desc' | '' = 'asc',
|
||||
search: string = ''
|
||||
): Observable<{
|
||||
pagination: PartnerRecommendationPagination;
|
||||
partnerRecommendations: PartnerRecommendation[];
|
||||
}> {
|
||||
return this._httpClient
|
||||
.get<{
|
||||
pagination: PartnerRecommendationPagination;
|
||||
partnerRecommendations: PartnerRecommendation[];
|
||||
}>('api/apps/member/partner-recommendation/partner-recommendations', {
|
||||
params: {
|
||||
page: '' + page,
|
||||
size: '' + size,
|
||||
sort,
|
||||
order,
|
||||
search,
|
||||
},
|
||||
})
|
||||
.pipe(
|
||||
tap((response) => {
|
||||
this.__pagination.next(response.pagination);
|
||||
this.__partnerRecommendations.next(response.partnerRecommendations);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product by id
|
||||
*/
|
||||
getPartnerRecommendationById(
|
||||
id: string | null
|
||||
): Observable<PartnerRecommendation> {
|
||||
return this.__partnerRecommendations.pipe(
|
||||
take(1),
|
||||
map((partnerRecommendations) => {
|
||||
// Find the product
|
||||
const partnerRecommendation =
|
||||
partnerRecommendations?.find((item) => item.id === id) || undefined;
|
||||
|
||||
// Update the product
|
||||
this.__partnerRecommendation.next(partnerRecommendation);
|
||||
|
||||
// Return the product
|
||||
return partnerRecommendation;
|
||||
}),
|
||||
switchMap((product) => {
|
||||
if (!product) {
|
||||
return throwError('Could not found product with id of ' + id + '!');
|
||||
}
|
||||
|
||||
return of(product);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create product
|
||||
*/
|
||||
createPartnerRecommendation(): Observable<PartnerRecommendation> {
|
||||
return this.partnerRecommendations$.pipe(
|
||||
take(1),
|
||||
switchMap((partnerRecommendations) =>
|
||||
this._httpClient
|
||||
.post<PartnerRecommendation>(
|
||||
'api/apps/member/partner-recommendation/product',
|
||||
{}
|
||||
)
|
||||
.pipe(
|
||||
map((newPartnerRecommendation) => {
|
||||
// Update the partnerRecommendations with the new product
|
||||
if (!!partnerRecommendations) {
|
||||
this.__partnerRecommendations.next([
|
||||
newPartnerRecommendation,
|
||||
...partnerRecommendations,
|
||||
]);
|
||||
}
|
||||
|
||||
// Return the new product
|
||||
return newPartnerRecommendation;
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ export const partnerRoutes: Route[] = [
|
|||
// redirectTo: 'all',
|
||||
// },
|
||||
{
|
||||
path: '',
|
||||
path: 'all',
|
||||
component: ListComponent,
|
||||
resolve: {
|
||||
Partners: PartnersResolver,
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {
|
||||
BehaviorSubject,
|
||||
filter,
|
||||
map,
|
||||
Observable,
|
||||
of,
|
||||
switchMap,
|
||||
take,
|
||||
tap,
|
||||
throwError,
|
||||
} from 'rxjs';
|
||||
|
||||
import { Recommendation } from '../models/recommendation';
|
||||
import { RecommendationPagination } from '../models/recommendation-pagination';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RecommendationService {
|
||||
// Private
|
||||
private __pagination = new BehaviorSubject<
|
||||
RecommendationPagination | undefined
|
||||
>(undefined);
|
||||
private __recommendation = new BehaviorSubject<Recommendation | undefined>(
|
||||
undefined
|
||||
);
|
||||
private __recommendations = new BehaviorSubject<Recommendation[] | undefined>(
|
||||
undefined
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
constructor(private _httpClient: HttpClient) {}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Accessors
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Getter for pagination
|
||||
*/
|
||||
get pagination$(): Observable<RecommendationPagination | undefined> {
|
||||
return this.__pagination.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for recommendation
|
||||
*/
|
||||
get recommendation$(): Observable<Recommendation | undefined> {
|
||||
return this.__recommendation.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for recommendations
|
||||
*/
|
||||
get recommendations$(): Observable<Recommendation[] | undefined> {
|
||||
return this.__recommendations.asObservable();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// @ Public methods
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get recommendations
|
||||
*
|
||||
*
|
||||
* @param page
|
||||
* @param size
|
||||
* @param sort
|
||||
* @param order
|
||||
* @param search
|
||||
*/
|
||||
getRecommendations(
|
||||
page: number = 0,
|
||||
size: number = 10,
|
||||
sort: string = 'name',
|
||||
order: 'asc' | 'desc' | '' = 'asc',
|
||||
search: string = ''
|
||||
): Observable<{
|
||||
pagination: RecommendationPagination;
|
||||
recommendations: Recommendation[];
|
||||
}> {
|
||||
return this._httpClient
|
||||
.get<{
|
||||
pagination: RecommendationPagination;
|
||||
recommendations: Recommendation[];
|
||||
}>('api/apps/member/recommendation/recommendations', {
|
||||
params: {
|
||||
page: '' + page,
|
||||
size: '' + size,
|
||||
sort,
|
||||
order,
|
||||
search,
|
||||
},
|
||||
})
|
||||
.pipe(
|
||||
tap((response) => {
|
||||
this.__pagination.next(response.pagination);
|
||||
this.__recommendations.next(response.recommendations);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product by id
|
||||
*/
|
||||
getRecommendationById(id: string | null): Observable<Recommendation> {
|
||||
return this.__recommendations.pipe(
|
||||
take(1),
|
||||
map((recommendations) => {
|
||||
// Find the product
|
||||
const recommendation =
|
||||
recommendations?.find((item) => item.id === id) || undefined;
|
||||
|
||||
// Update the product
|
||||
this.__recommendation.next(recommendation);
|
||||
|
||||
// Return the product
|
||||
return recommendation;
|
||||
}),
|
||||
switchMap((product) => {
|
||||
if (!product) {
|
||||
return throwError('Could not found product with id of ' + id + '!');
|
||||
}
|
||||
|
||||
return of(product);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create product
|
||||
*/
|
||||
createRecommendation(): Observable<Recommendation> {
|
||||
return this.recommendations$.pipe(
|
||||
take(1),
|
||||
switchMap((recommendations) =>
|
||||
this._httpClient
|
||||
.post<Recommendation>('api/apps/member/recommendation/product', {})
|
||||
.pipe(
|
||||
map((newRecommendation) => {
|
||||
// Update the recommendations with the new product
|
||||
if (!!recommendations) {
|
||||
this.__recommendations.next([
|
||||
newRecommendation,
|
||||
...recommendations,
|
||||
]);
|
||||
}
|
||||
|
||||
// Return the new product
|
||||
return newRecommendation;
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -6,8 +6,14 @@
|
|||
"Casino Money": "Casino Money",
|
||||
"Unconnected": "Unconnected",
|
||||
"Project": "Project",
|
||||
"Partner": "Partner",
|
||||
"Recommendation": "Recommendation",
|
||||
"partner-management": "partner-management",
|
||||
"All Partner": "All Partner",
|
||||
"Partner Mainoffice": "Partner Mainoffice",
|
||||
"Partner Branch": "Partner Branch",
|
||||
"Partner Division": "Partner Division",
|
||||
"Partner Office": "Partner Office",
|
||||
"Partner Store": "Partner Store",
|
||||
"Partner Recommendation": "Recommendation",
|
||||
"Coupon": "Coupon",
|
||||
"Coupon Money Log": "Coupon Money Log",
|
||||
"Coupon Log": "Coupon Log",
|
||||
|
|
|
@ -7,8 +7,13 @@
|
|||
"Unconnected": "장기미접속회원",
|
||||
"Project": "프로젝트",
|
||||
"partner-management": "파트너관리",
|
||||
"Partner": "파트너",
|
||||
"Recommendation": "추천코드등록",
|
||||
"All Partner": "전체파트너",
|
||||
"Partner Mainoffice": "본사",
|
||||
"Partner Branch": "대본",
|
||||
"Partner Division": "부본",
|
||||
"Partner Office": "총판",
|
||||
"Partner Store": "매장",
|
||||
"Partner Recommendation": "추천코드등록",
|
||||
"Coupon": "쿠폰발행리스트",
|
||||
"Coupon Money Log": "쿠폰발행머니로그",
|
||||
"Coupon Log": "쿠폰발행 로그",
|
||||
|
|
Loading…
Reference in New Issue
Block a user