39 changed files with 2746 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||
# Ordering |
|||
|
|||
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.0. |
|||
|
|||
## Code scaffolding |
|||
|
|||
Run `ng generate component component-name --project ordering` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ordering`. |
|||
> Note: Don't forget to add `--project ordering` or else it will be added to the default project in your `angular.json` file. |
|||
|
|||
## Build |
|||
|
|||
Run `ng build ordering` to build the project. The build artifacts will be stored in the `dist/` directory. |
|||
|
|||
## Publishing |
|||
|
|||
After building your library with `ng build ordering`, go to the dist folder `cd dist/ordering` and run `npm publish`. |
|||
|
|||
## Running unit tests |
|||
|
|||
Run `ng test ordering` to execute the unit tests via [Karma](https://karma-runner.github.io). |
|||
|
|||
## Further help |
|||
|
|||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. |
|||
@ -0,0 +1,2 @@ |
|||
export * from './policy-names'; |
|||
export * from './route-names'; |
|||
@ -0,0 +1,7 @@ |
|||
export const enum eOrderingPolicyNames { |
|||
Ordering = 'CatalogService.Products', |
|||
|
|||
ProductManagementCreate = 'CatalogService.Products.Create', |
|||
ProductManagementUpdate = 'CatalogService.Products.Update', |
|||
ProductManagementDelete = 'CatalogService.Products.Delete', |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
export const enum eOrderingRouteNames { |
|||
Ordering = 'CatalogService::Menu:CatalogManagement', |
|||
Orders = 'CatalogService::Menu:Products', |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
import { RouterModule, Routes } from '@angular/router'; |
|||
|
|||
const routes: Routes = []; |
|||
|
|||
@NgModule({ |
|||
imports: [RouterModule.forChild(routes)], |
|||
exports: [RouterModule] |
|||
}) |
|||
export class OrderConfigRoutingModule { } |
|||
@ -0,0 +1,13 @@ |
|||
import { ModuleWithProviders, NgModule } from '@angular/core'; |
|||
import { ORDERING_ROUTE_PROVIDERS } from './providers/route.provider'; |
|||
|
|||
|
|||
@NgModule() |
|||
export class OrderConfigModule { |
|||
static forRoot(): ModuleWithProviders<OrderConfigModule> { |
|||
return { |
|||
ngModule: OrderConfigModule, |
|||
providers: [ORDERING_ROUTE_PROVIDERS], |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
export * from './route.provider'; |
|||
@ -0,0 +1,23 @@ |
|||
import { eLayoutType, RoutesService } from '@abp/ng.core'; |
|||
import { APP_INITIALIZER } from '@angular/core'; |
|||
import { eOrderingPolicyNames } from '../enums/policy-names'; |
|||
import { eOrderingRouteNames} from '../enums/route-names'; |
|||
|
|||
export const ORDERING_ROUTE_PROVIDERS = [ |
|||
{ provide: APP_INITIALIZER, useFactory: configureRoutes, deps: [RoutesService], multi: true }, |
|||
]; |
|||
|
|||
export function configureRoutes(routesService: RoutesService) { |
|||
return () => { |
|||
routesService.add([ |
|||
{ |
|||
path: '/ordering', |
|||
name: eOrderingRouteNames.Ordering, |
|||
layout: eLayoutType.application, |
|||
parentName: null, |
|||
iconClass: 'bi bi-collection-fill', |
|||
requiredPolicy: eOrderingPolicyNames.Ordering, |
|||
}, |
|||
]); |
|||
}; |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
export * from './enums'; |
|||
export * from './providers'; |
|||
export * from './order-config.module' |
|||
@ -0,0 +1,44 @@ |
|||
// Karma configuration file, see link for more information
|
|||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|||
|
|||
module.exports = function (config) { |
|||
config.set({ |
|||
basePath: '', |
|||
frameworks: ['jasmine', '@angular-devkit/build-angular'], |
|||
plugins: [ |
|||
require('karma-jasmine'), |
|||
require('karma-chrome-launcher'), |
|||
require('karma-jasmine-html-reporter'), |
|||
require('karma-coverage'), |
|||
require('@angular-devkit/build-angular/plugins/karma') |
|||
], |
|||
client: { |
|||
jasmine: { |
|||
// you can add configuration options for Jasmine here
|
|||
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|||
// for example, you can disable the random execution with `random: false`
|
|||
// or set a specific seed with `seed: 4321`
|
|||
}, |
|||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|||
}, |
|||
jasmineHtmlReporter: { |
|||
suppressAll: true // removes the duplicated traces
|
|||
}, |
|||
coverageReporter: { |
|||
dir: require('path').join(__dirname, '../../coverage/ordering'), |
|||
subdir: '.', |
|||
reporters: [ |
|||
{ type: 'html' }, |
|||
{ type: 'text-summary' } |
|||
] |
|||
}, |
|||
reporters: ['progress', 'kjhtml'], |
|||
port: 9876, |
|||
colors: true, |
|||
logLevel: config.LOG_INFO, |
|||
autoWatch: true, |
|||
browsers: ['Chrome'], |
|||
singleRun: false, |
|||
restartOnFileChange: true |
|||
}); |
|||
}; |
|||
@ -0,0 +1,7 @@ |
|||
{ |
|||
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json", |
|||
"dest": "../../dist/ordering", |
|||
"lib": { |
|||
"entryFile": "src/public-api.ts" |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
{ |
|||
"name": "@eshoponabp/ordering", |
|||
"version": "0.0.1", |
|||
"peerDependencies": { |
|||
"@angular/common": "^12.2.0", |
|||
"@angular/core": "^12.2.0" |
|||
}, |
|||
"dependencies": { |
|||
"tslib": "^2.3.0" |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
import { TestBed } from '@angular/core/testing'; |
|||
|
|||
import { OrderingService } from './ordering.service'; |
|||
|
|||
describe('OrderingService', () => { |
|||
let service: OrderingService; |
|||
|
|||
beforeEach(() => { |
|||
TestBed.configureTestingModule({}); |
|||
service = TestBed.inject(OrderingService); |
|||
}); |
|||
|
|||
it('should be created', () => { |
|||
expect(service).toBeTruthy(); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,9 @@ |
|||
import { Injectable } from '@angular/core'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root' |
|||
}) |
|||
export class OrderingService { |
|||
|
|||
constructor() { } |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
# Proxy Generation Output |
|||
|
|||
This directory includes the output of the latest proxy generation. |
|||
The files and folders in it will be overwritten when proxy generation is run again. |
|||
Therefore, please do not place your own content in this folder. |
|||
|
|||
In addition, `generate-proxy.json` works like a lock file. |
|||
It includes information used by the proxy generator, so please do not delete or modify it. |
|||
|
|||
Finally, the name of the files and folders should not be changed for two reasons: |
|||
- Proxy generator will keep creating them at those paths and you will have multiple copies of the same content. |
|||
- ABP Suite generates files which include imports from this folder. |
|||
|
|||
> **Important Notice:** If you are building a module and are planning to publish to npm, |
|||
> some of the generated proxies are likely to be exported from public-api.ts file. In such a case, |
|||
> please make sure you export files directly and not from barrel exports. In other words, |
|||
> do not include index.ts exports in your public-api.ts exports. |
|||
File diff suppressed because it is too large
@ -0,0 +1,2 @@ |
|||
import * as Orders from './orders'; |
|||
export { Orders }; |
|||
@ -0,0 +1,2 @@ |
|||
export * from './models'; |
|||
export * from './order.service'; |
|||
@ -0,0 +1,62 @@ |
|||
import type { EntityDto } from '@abp/ng.core'; |
|||
|
|||
export interface BuyerDto extends EntityDto<string> { |
|||
name?: string; |
|||
email?: string; |
|||
} |
|||
|
|||
export interface GetMyOrdersInput { |
|||
filter?: string; |
|||
} |
|||
|
|||
export interface GetOrdersInput { |
|||
filter?: string; |
|||
} |
|||
|
|||
export interface OrderAddressDto { |
|||
description?: string; |
|||
street: string; |
|||
city: string; |
|||
country: string; |
|||
zipCode: string; |
|||
} |
|||
|
|||
export interface OrderCreateDto { |
|||
paymentMethod?: string; |
|||
address: OrderAddressDto; |
|||
products: OrderItemCreateDto[]; |
|||
} |
|||
|
|||
export interface OrderDto extends EntityDto<string> { |
|||
orderDate?: string; |
|||
orderNo: number; |
|||
orderStatusId: number; |
|||
orderStatus?: string; |
|||
paymentMethod?: string; |
|||
buyer: BuyerDto; |
|||
address: OrderAddressDto; |
|||
items: OrderItemDto[]; |
|||
} |
|||
|
|||
export interface OrderItemCreateDto { |
|||
productId?: string; |
|||
productCode?: string; |
|||
productName?: string; |
|||
pictureUrl?: string; |
|||
unitPrice: number; |
|||
discount: number; |
|||
units: number; |
|||
} |
|||
|
|||
export interface OrderItemDto extends EntityDto<string> { |
|||
productId?: string; |
|||
productName?: string; |
|||
pictureUrl?: string; |
|||
unitPrice: number; |
|||
discount: number; |
|||
units: number; |
|||
} |
|||
|
|||
export interface UpdateOrderDto { |
|||
orderStatusId: number; |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
import type { GetMyOrdersInput, GetOrdersInput, OrderCreateDto, OrderDto, UpdateOrderDto } from './models'; |
|||
import { RestService } from '@abp/ng.core'; |
|||
import { Injectable } from '@angular/core'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class OrderService { |
|||
apiName = 'Ordering'; |
|||
|
|||
create = (input: OrderCreateDto) => |
|||
this.restService.request<any, OrderDto>({ |
|||
method: 'POST', |
|||
url: '/api/ordering/order', |
|||
body: input, |
|||
}, |
|||
{ apiName: this.apiName }); |
|||
|
|||
get = (id: string) => |
|||
this.restService.request<any, OrderDto>({ |
|||
method: 'GET', |
|||
url: `/api/ordering/order/${id}`, |
|||
}, |
|||
{ apiName: this.apiName }); |
|||
|
|||
getByOrderNo = (orderNo: number) => |
|||
this.restService.request<any, OrderDto>({ |
|||
method: 'GET', |
|||
url: '/api/ordering/order/by-order-no', |
|||
params: { orderNo }, |
|||
}, |
|||
{ apiName: this.apiName }); |
|||
|
|||
getMyOrders = (input: GetMyOrdersInput) => |
|||
this.restService.request<any, OrderDto[]>({ |
|||
method: 'GET', |
|||
url: '/api/ordering/order/my-orders', |
|||
params: { filter: input.filter }, |
|||
}, |
|||
{ apiName: this.apiName }); |
|||
|
|||
getOrders = (input: GetOrdersInput) => |
|||
this.restService.request<any, OrderDto[]>({ |
|||
method: 'GET', |
|||
url: '/api/ordering/order/orders', |
|||
params: { filter: input.filter }, |
|||
}, |
|||
{ apiName: this.apiName }); |
|||
|
|||
update = (id: string, input: UpdateOrderDto) => |
|||
this.restService.request<any, OrderDto>({ |
|||
method: 'PUT', |
|||
url: `/api/ordering/order/${id}`, |
|||
body: input, |
|||
}, |
|||
{ apiName: this.apiName }); |
|||
|
|||
constructor(private restService: RestService) {} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
import { RouterModule, Routes } from '@angular/router'; |
|||
|
|||
const routes: Routes = [ |
|||
{ path: '', redirectTo: 'orders', pathMatch: 'full' }, |
|||
{ path: 'orders', loadChildren: () => import('./pages/orders/orders.module').then(m => m.OrdersModule) }, |
|||
]; |
|||
|
|||
@NgModule({ |
|||
imports: [RouterModule.forChild(routes)], |
|||
exports: [RouterModule], |
|||
}) |
|||
export class OrderingRoutingModule {} |
|||
@ -0,0 +1,13 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
import { OrderingRoutingModule } from './ordering-routing.module'; |
|||
|
|||
|
|||
@NgModule({ |
|||
declarations: [], |
|||
imports: [ |
|||
OrderingRoutingModule |
|||
], |
|||
exports: [] |
|||
}) |
|||
export class OrderingModule { |
|||
} |
|||
@ -0,0 +1 @@ |
|||
export * from './orders'; |
|||
@ -0,0 +1,3 @@ |
|||
export * from './orders-routing.module'; |
|||
export * from './orders.component'; |
|||
export * from './orders.module'; |
|||
@ -0,0 +1,11 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
import { RouterModule, Routes } from '@angular/router'; |
|||
import { OrdersComponent } from './orders.component'; |
|||
|
|||
const routes: Routes = [{ path: '', component: OrdersComponent }]; |
|||
|
|||
@NgModule({ |
|||
imports: [RouterModule.forChild(routes)], |
|||
exports: [RouterModule] |
|||
}) |
|||
export class OrdersRoutingModule { } |
|||
@ -0,0 +1 @@ |
|||
<p>orders works!</p> |
|||
@ -0,0 +1,25 @@ |
|||
import { ComponentFixture, TestBed } from '@angular/core/testing'; |
|||
|
|||
import { OrdersComponent } from './orders.component'; |
|||
|
|||
describe('OrdersComponent', () => { |
|||
let component: OrdersComponent; |
|||
let fixture: ComponentFixture<OrdersComponent>; |
|||
|
|||
beforeEach(async () => { |
|||
await TestBed.configureTestingModule({ |
|||
declarations: [ OrdersComponent ] |
|||
}) |
|||
.compileComponents(); |
|||
}); |
|||
|
|||
beforeEach(() => { |
|||
fixture = TestBed.createComponent(OrdersComponent); |
|||
component = fixture.componentInstance; |
|||
fixture.detectChanges(); |
|||
}); |
|||
|
|||
it('should create', () => { |
|||
expect(component).toBeTruthy(); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,15 @@ |
|||
import { Component, OnInit } from '@angular/core'; |
|||
|
|||
@Component({ |
|||
selector: 'lib-orders', |
|||
templateUrl: './orders.component.html', |
|||
styleUrls: ['./orders.component.css'] |
|||
}) |
|||
export class OrdersComponent implements OnInit { |
|||
|
|||
constructor() { } |
|||
|
|||
ngOnInit(): void { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
import { NgModule } from '@angular/core'; |
|||
import { CommonModule } from '@angular/common'; |
|||
|
|||
import { OrdersRoutingModule } from './orders-routing.module'; |
|||
import { OrdersComponent } from './orders.component'; |
|||
|
|||
|
|||
@NgModule({ |
|||
declarations: [ |
|||
OrdersComponent |
|||
], |
|||
imports: [ |
|||
CommonModule, |
|||
OrdersRoutingModule |
|||
] |
|||
}) |
|||
export class OrdersModule { } |
|||
@ -0,0 +1,7 @@ |
|||
/* |
|||
* Public API Surface of ordering |
|||
*/ |
|||
|
|||
export * from './pages/index'; |
|||
export * from './ordering.module'; |
|||
export * from './lib/proxy/index'; |
|||
@ -0,0 +1,28 @@ |
|||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|||
|
|||
import 'zone.js'; |
|||
import 'zone.js/testing'; |
|||
import { getTestBed } from '@angular/core/testing'; |
|||
import { |
|||
BrowserDynamicTestingModule, |
|||
platformBrowserDynamicTesting |
|||
} from '@angular/platform-browser-dynamic/testing'; |
|||
|
|||
declare const require: { |
|||
context(path: string, deep?: boolean, filter?: RegExp): { |
|||
keys(): string[]; |
|||
<T>(id: string): T; |
|||
}; |
|||
}; |
|||
|
|||
// First, initialize the Angular testing environment.
|
|||
getTestBed().initTestEnvironment( |
|||
BrowserDynamicTestingModule, |
|||
platformBrowserDynamicTesting(), |
|||
{ teardown: { destroyAfterEach: true }}, |
|||
); |
|||
|
|||
// Then we find all the tests.
|
|||
const context = require.context('./', true, /\.spec\.ts$/); |
|||
// And load the modules.
|
|||
context.keys().map(context); |
|||
@ -0,0 +1,20 @@ |
|||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ |
|||
{ |
|||
"extends": "../../tsconfig.json", |
|||
"compilerOptions": { |
|||
"outDir": "../../out-tsc/lib", |
|||
"target": "es2015", |
|||
"declaration": true, |
|||
"declarationMap": true, |
|||
"inlineSources": true, |
|||
"types": [], |
|||
"lib": [ |
|||
"dom", |
|||
"es2018" |
|||
] |
|||
}, |
|||
"exclude": [ |
|||
"src/test.ts", |
|||
"**/*.spec.ts" |
|||
] |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ |
|||
{ |
|||
"extends": "./tsconfig.lib.json", |
|||
"compilerOptions": { |
|||
"declarationMap": false |
|||
}, |
|||
"angularCompilerOptions": { |
|||
"compilationMode": "partial" |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ |
|||
{ |
|||
"extends": "../../tsconfig.json", |
|||
"compilerOptions": { |
|||
"outDir": "../../out-tsc/spec", |
|||
"types": [ |
|||
"jasmine" |
|||
] |
|||
}, |
|||
"files": [ |
|||
"src/test.ts" |
|||
], |
|||
"include": [ |
|||
"**/*.spec.ts", |
|||
"**/*.d.ts" |
|||
] |
|||
} |
|||
Loading…
Reference in new issue