From 9310ae81f98dbeb1567ec45e60a0f1ab8054ad39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9C=8B=E5=8B=83?= <243310820@qq.com> Date: Mon, 24 Dec 2018 13:50:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=90=8E=E7=AB=AFbook=E4=BB=A3=E7=A0=81=E5=92=8C=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../books/books.component.html | 172 ------------------ .../books/books.component.less | 0 .../cloud-book-list/books/books.component.ts | 123 ------------- .../create-or-edit-book.component.html | 101 ---------- .../create-or-edit-book.component.ts | 79 -------- .../cloud-book-list-routing.module.ts | 6 - .../cloud-book-list/cloud-book-list.module.ts | 10 +- .../Books/BookAppService.cs | 116 ------------ .../Books/Dtos/BookEditDto.cs | 27 --- .../Books/Dtos/BookListDto.cs | 24 --- .../Books/Dtos/CreateOrUpdateBookInput.cs | 10 - .../Books/Dtos/GetBookForEditOutput.cs | 7 - .../Books/Dtos/GetBookInput.cs | 19 -- .../Books/IBookAppService.cs | 46 ----- .../Books/Mapper/BookMapper.cs | 15 -- .../BookAuthorizationProvider.cs | 30 --- .../Books/Authorization/BookPermissions.cs | 16 -- 17 files changed, 2 insertions(+), 799 deletions(-) delete mode 100644 src/booklist-angular/src/app/cloud-book-list/books/books.component.html delete mode 100644 src/booklist-angular/src/app/cloud-book-list/books/books.component.less delete mode 100644 src/booklist-angular/src/app/cloud-book-list/books/books.component.ts delete mode 100644 src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html delete mode 100644 src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookAppService.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookInput.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookAppService.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs delete mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs diff --git a/src/booklist-angular/src/app/cloud-book-list/books/books.component.html b/src/booklist-angular/src/app/cloud-book-list/books/books.component.html deleted file mode 100644 index 03d9dbb..0000000 --- a/src/booklist-angular/src/app/cloud-book-list/books/books.component.html +++ /dev/null @@ -1,172 +0,0 @@ - - - -
- - - - - - - - - - - - - - - -
- -
- - - - - - - - -
- - - -
- - - - - {{ l('ClearEmpty') }} - - {{ l('Refresh') }} - - - -
- - - - - - - - - - - {{ - l( - 'GridFooterDisplayText', - pageNumber, - totalPages, - total, - range[0], - range[1] - ) - }} - - - - - - - - {{ l('ImgUrl') }} - - - {{ l('Name') }} - - - {{ l('Author') }} - - - {{ l('Intro') }} - - - {{ l('PriceUrl') }} - - - {{ l('Actions') }} - - - - - - - - - - 封面图片 - - - {{ item.name }} - - - - - {{ item.author }} - - - - - {{ item.intro }} - - - - - {{ item.priceUrl }} - - - - - - - - - {{ l('Edit') }} - - - - - - - - - {{ l('Delete') }} - - - - - - - - - - {{ l('More') }} - - - - - - - - - -
diff --git a/src/booklist-angular/src/app/cloud-book-list/books/books.component.less b/src/booklist-angular/src/app/cloud-book-list/books/books.component.less deleted file mode 100644 index e69de29..0000000 diff --git a/src/booklist-angular/src/app/cloud-book-list/books/books.component.ts b/src/booklist-angular/src/app/cloud-book-list/books/books.component.ts deleted file mode 100644 index 1e54824..0000000 --- a/src/booklist-angular/src/app/cloud-book-list/books/books.component.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { PagedRequestDto } from '@shared/component-base/paged-listing-component-base'; -import { BookServiceProxy } from './../../../shared/service-proxies/service-proxies'; -import { Component, OnInit, Injector } from '@angular/core'; -import { appModuleAnimation } from '@shared/animations/routerTransition'; -import { PagedListingComponentBase } from '@shared/component-base'; -import { BookListDto } from '@shared/service-proxies/service-proxies'; -import { finalize } from 'rxjs/operators'; -import * as _ from 'lodash'; -import { CreateOrEditBookComponent } from './create-or-edit-book/create-or-edit-book.component'; - -@Component({ - // selector: 'app-books', - templateUrl: './books.component.html', - styles: ['./books.component.less'], - animations: [appModuleAnimation()], -}) -export class BooksComponent extends PagedListingComponentBase - implements OnInit { - constructor(injector: Injector, private _bookService: BookServiceProxy) { - super(injector); - } - - // ngOnInit() { - // this.refresh(); - // } - - /** - * 默认获取后端分页数据列表信息 - * @param request 请求数据的dto,比如分页 - * @param pageNumber 当前的页码 - * @param finishedCallback 完成请求后的回调信息 - */ - protected fetchDataList( - request: PagedRequestDto, - pageNumber: number, - finishedCallback: Function, - ): void { - this._bookService - .getPageBookAsync( - this.filterText, - request.sorting, - request.skipCount, - request.maxResultCount, - ) - .pipe( - finalize(() => { - finishedCallback(); - }), - ) - .subscribe(result => { - this.dataList = result.items; - this.showPaging(result); - }); - } - - /** - * 新增或编辑DTO信息 - * @param id 当前DTO的Id - */ - createOrEdit(id?: number): void { - this.modalHelper - .static(CreateOrEditBookComponent, { id: id }) - .subscribe(result => { - if (result) { - this.refresh(); - } - }); - } - - /** - * 删除功能 - * @param entity 角色的实体信息 - */ - delete(entity: BookListDto): void { - this._bookService.deleteBook(entity.id).subscribe(() => { - /** - * 刷新表格数据并跳转到第一页(`pageNumber = 1`) - */ - this.refreshGoFirstPage(); - this.notify.success(this.l('SuccessfullyDeleted')); - }); - } - - /** - * 批量删除 - */ - batchDelete(): void { - const selectCount = this.selectedDataItems.length; - if (selectCount <= 0) { - abp.message.warn(this.l('PleaseSelectAtLeastOneItem')); - return; - } - - abp.message.confirm( - this.l('ConfirmDeleteXItemsWarningMessage', selectCount), - res => { - if (res) { - const ids = _.map(this.selectedDataItems, 'id'); - this._bookService.batchDeleteBook(ids).subscribe(() => { - this.refreshGoFirstPage(); - this.notify.success(this.l('SuccessfullyDeleted')); - }); - } - }, - ); - } - - /** - * 导出为Excel表 - */ - exportToExcel(): void { - abp.message.error('功能开发中!!!!'); - // this._bookService.getBookexportToExcel().subscribe(result => { - // this._fileDownloadService.downloadTempFile(result); - // }); - } - - // showImg(url: string) { - // this.modalHelper - // .open(ImgShowComponent, { imgUrl: url }, 'md') - // .subscribe(() => {}); - // } -} diff --git a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html deleted file mode 100644 index 520958b..0000000 --- a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html +++ /dev/null @@ -1,101 +0,0 @@ -
- - - -
- - - {{l('Name')}} - - - - - - {{l('超过最大长度')+50}} - {{l('小于最小长度')+1}} - {{l('CanNotNull')}} - - - - - - {{l('Author')}} - - - - - - {{l('超过最大长度')+50}} - {{l('小于最小长度')+1}} - {{l('CanNotNull')}} - - - - - - {{l('Intro')}} - - - - - - {{l('超过最大长度')+300}} - {{l('小于最小长度')+10}} - {{l('CanNotNull')}} - - - - - - {{l('PriceUrl')}} - - - - - - - - {{l('ImgUrl')}} - - - - - - - - - - - {{l('BookTag')}} - - - - - - - - - - - - -
- - -
diff --git a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts deleted file mode 100644 index 0edc8f8..0000000 --- a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { - Component, - OnInit, - Injector, - Input, - ViewChild, - AfterViewInit, -} from '@angular/core'; -import { ModalComponentBase } from '@shared/component-base/modal-component-base'; -import { - CreateOrUpdateBookInput, - BookEditDto, - BookServiceProxy, -} from '@shared/service-proxies/service-proxies'; -import { Validators, AbstractControl, FormControl } from '@angular/forms'; - -@Component({ - // tslint:disable-next-line:component-selector - selector: 'create-or-edit-book', - templateUrl: './create-or-edit-book.component.html', - styleUrls: [], -}) -export class CreateOrEditBookComponent extends ModalComponentBase - implements OnInit { - /** - * 编辑时DTO的id - */ - id: any; - - entity: BookEditDto = new BookEditDto(); - - // tags: any; // 所有的书籍标签 - // selectedTags: any = []; - - /** - * 初始化的构造函数 - */ - constructor(injector: Injector, private _bookService: BookServiceProxy) { - super(injector); - } - - ngOnInit(): void { - this.init(); - } - - /** - * 初始化方法 - */ - init(): void { - this._bookService.getForEditBook(this.id).subscribe(result => { - this.entity = result.book; - // this.tags = result.bookTags; - }); - } - - /** - * 保存方法,提交form表单 - */ - submitForm(): void { - const input = new CreateOrUpdateBookInput(); - input.bookEditDto = this.entity; - // input.tagIds = this.selectedTags; - this.saving = true; - - this._bookService - .createOrUpdateBook(input) - .finally(() => (this.saving = false)) - .subscribe(() => { - this.notify.success(this.l('SavedSuccessfully')); - this.success(true); - }); - } - - // 获取选择的tag值 - - tagSelectChange(data: any[]) { - // this.selectedTags = data; - } -} diff --git a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts index 7d0e6a7..9bfa021 100644 --- a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts +++ b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts @@ -1,5 +1,4 @@ import { BookListsComponent } from './book-lists/book-lists.component'; -import { BooksComponent } from './books/books.component'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -7,11 +6,6 @@ const routes: Routes = [ { path: '', children: [ - { - path: 'books', - component: BooksComponent, - data: { permission: 'Pages.BookManager' }, - }, { path: 'booklists', component: BookListsComponent, diff --git a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts index b9f9320..925ca8f 100644 --- a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts +++ b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts @@ -5,10 +5,8 @@ import { CommonModule } from '@angular/common'; import { CloudBookListRoutingModule } from './cloud-book-list-routing.module'; import { BookListsComponent } from './book-lists/book-lists.component'; -import { BooksComponent } from './books/books.component'; import { SharedModule } from '@shared/shared.module'; import { TitleService } from 'yoyo-ng-module/src/theme'; -import { CreateOrEditBookComponent } from './books/create-or-edit-book/create-or-edit-book.component'; @NgModule({ imports: [ @@ -18,12 +16,8 @@ import { CreateOrEditBookComponent } from './books/create-or-edit-book/create-or AbpModule, CloudBookListRoutingModule, ], - declarations: [BookListsComponent, BooksComponent, CreateOrEditBookComponent], - entryComponents: [ - BookListsComponent, - BooksComponent, - CreateOrEditBookComponent, - ], + declarations: [BookListsComponent], + entryComponents: [BookListsComponent], providers: [LocalizationService, TitleService], }) export class CloudBookListModule {} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookAppService.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookAppService.cs deleted file mode 100644 index e1dfcab..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookAppService.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Abp.Application.Services.Dto; -using Abp.AutoMapper; -using Abp.Domain.Repositories; -using Abp.Extensions; -using Abp.Linq.Extensions; -using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq.Dynamic.Core; -using System.Threading.Tasks; -using Abp.Authorization; -using Lpb.BookList.BookListManagement.Books.Authorization; -using Lpb.BookList.BookListManagement.Books.Dtos; - -namespace Lpb.BookList.BookListManagement.Books -{ - [AbpAuthorize(BookPermissions.BookManager)] - - public class BookAppService : BookListAppServiceBase, IBookAppService - { - private readonly IRepository _bookRepository; - - public BookAppService(IRepository bookRepository) - { - _bookRepository = bookRepository; - } - - [AbpAuthorize(BookPermissions.Query)] - public async Task> GetPageBookAsync(GetBookInput input) - { - var query = _bookRepository.GetAll().AsNoTracking().WhereIf(!input.FilterText.IsNullOrWhiteSpace(), - p => p.Name.Contains(input.FilterText)); - - var count = await query.CountAsync(); - var entityList = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync(); - - var entityListDtos = entityList.MapTo>(); - return new PagedResultDto(count, entityListDtos); - } - - [AbpAuthorize(BookPermissions.Create, BookPermissions.Edit)] - public async Task CreateOrUpdateBook(CreateOrUpdateBookInput input) - { - if (input.bookEditDto.Id.HasValue) - { - //修改 - await UpdateBook(input.bookEditDto); - } - else - { - //添加 - await CreateBook(input.bookEditDto); - } - } - - [AbpAuthorize(BookPermissions.Delete)] - public async Task DeleteBook(EntityDto input) - { - var entity = await _bookRepository.GetAsync(input.Id); - if (entity != null) - { - await _bookRepository.DeleteAsync(input.Id); - } - } - - [AbpAuthorize(BookPermissions.BatchDelete)] - public async Task BatchDeleteBook(List input) - { - await _bookRepository.DeleteAsync(p => input.Contains(p.Id)); - } - - public async Task GetForEditBook(NullableIdDto input) - { - var output = new GetBookForEditOutput(); - BookEditDto dto; - if (input.Id.HasValue) - { - var entity = await _bookRepository.GetAsync(input.Id.Value); - dto = entity.MapTo(); - } - else - { - dto = new BookEditDto(); - } - - output.Book = dto; - return output; - } - - [AbpAuthorize(BookPermissions.Create)] - protected virtual async Task CreateBook(BookEditDto input) - { - //使用单元测试时,如下使用AutoMapper - //var model = ObjectMapper.Map(input); - - var entity = input.MapTo(); - await _bookRepository.InsertAsync(entity); - var dto = entity.MapTo(); - return dto; - } - - [AbpAuthorize(BookPermissions.Edit)] - protected virtual async Task UpdateBook(BookEditDto input) - { - //使用单元测试时,如下使用AutoMapper - //var model = ObjectMapper.Map(input); - - Debug.Assert(input.Id != null, "input.Id != null"); - var entity = await _bookRepository.GetAsync(input.Id.Value); - input.MapTo(entity); - //ObjectMapper.Map(input, entity); - await _bookRepository.UpdateAsync(entity); - } - - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs deleted file mode 100644 index b68c9bf..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Lpb.BookList.BookListManagement.Books.Dtos -{ - public class BookEditDto - { - public long? Id { get; set; } - /// - /// 名称 - /// - public string Name { get; set; } - /// - /// 作者 - /// - public string Author { get; set; } - /// - /// 简介 - /// - public string Intro { get; set; } - /// - /// 价格链接 - /// - public string PriceUrl { get; set; } - /// - /// 封面链接 - /// - public string ImgUrl { get; set; } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs deleted file mode 100644 index 4b50325..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Abp.Application.Services.Dto; - -namespace Lpb.BookList.BookListManagement.Books.Dtos -{ - public class BookListDto : EntityDto - { - /// - /// 名称 - /// - public string Name { get; set; } - /// - /// 作者 - /// - public string Author { get; set; } - /// - /// 简介 - /// - public string Intro { get; set; } - /// - /// 封面链接 - /// - public string ImgUrl { get; set; } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs deleted file mode 100644 index 0c4e6e2..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Lpb.BookList.BookListManagement.Books.Dtos -{ - public class CreateOrUpdateBookInput - { - [Required] - public BookEditDto bookEditDto { get; set; } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs deleted file mode 100644 index 5741fdf..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Lpb.BookList.BookListManagement.Books.Dtos -{ - public class GetBookForEditOutput - { - public BookEditDto Book { get; set; } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookInput.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookInput.cs deleted file mode 100644 index 1af1817..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookInput.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Abp.Runtime.Validation; -using Lpb.BookList.Dtos; - -namespace Lpb.BookList.BookListManagement.Books.Dtos -{ - public class GetBookInput:PageAndFilteredInputDto, IShouldNormalize - { - /// - /// 默认排序 - /// - public void Normalize() - { - if (string.IsNullOrWhiteSpace(Sorting)) - { - Sorting = "Id"; - } - } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookAppService.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookAppService.cs deleted file mode 100644 index 8eaada0..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookAppService.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Abp.Application.Services; -using Abp.Application.Services.Dto; -using Lpb.BookList.BookListManagement.Books.Dtos; - -namespace Lpb.BookList.BookListManagement.Books -{ - public interface IBookAppService : IApplicationService - { - /// - /// 分页获取查询书籍的功能 - /// - /// - /// - Task> GetPageBookAsync(GetBookInput input); - - /// - /// 添加或修改书籍信息 - /// - /// - /// - Task CreateOrUpdateBook(CreateOrUpdateBookInput input); - - /// - /// 删除书籍 - /// - /// - /// - Task DeleteBook(EntityDto input); - - /// - /// 批量删除书籍 - /// - /// - /// - Task BatchDeleteBook(List input); - - /// - /// 获取用于编辑的实体 - /// - /// - /// - Task GetForEditBook(NullableIdDto input); - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs deleted file mode 100644 index 635d59f..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AutoMapper; -using Lpb.BookList.BookListManagement.Books.Dtos; - -namespace Lpb.BookList.BookListManagement.Books.Mapper -{ - internal class BookMapper - { - public static void CreateMappers(IMapperConfigurationExpression configuration) - { - configuration.CreateMap(); - configuration.CreateMap(); - configuration.CreateMap(); - } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs deleted file mode 100644 index d2cbf66..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Linq; -using Abp.Authorization; -using Abp.Localization; -using Lpb.BookList.Authorization; - -namespace Lpb.BookList.BookListManagement.Books.Authorization -{ - public class BookAuthorizationProvider : AuthorizationProvider - { - public override void SetPermissions(IPermissionDefinitionContext context) - { - var pages = context.GetPermissionOrNull(PermissionNames.Pages) ?? context.CreatePermission(PermissionNames.Pages, L("Pages")); - var admin = pages.Children.FirstOrDefault(p => p.Name == PermissionNames.Pages_Administrator) ?? pages.CreateChildPermission(PermissionNames.Pages_Administrator, L("Administrator")); - - var entityPermission = admin.CreateChildPermission(BookPermissions.BookManager, L("BookManager")); - entityPermission.CreateChildPermission(BookPermissions.Query, L("Query")); - entityPermission.CreateChildPermission(BookPermissions.Create, L("Create")); - entityPermission.CreateChildPermission(BookPermissions.Edit, L("Edit")); - entityPermission.CreateChildPermission(BookPermissions.Delete, L("Delete")); - entityPermission.CreateChildPermission(BookPermissions.BatchDelete, L("BatchDelete")); - entityPermission.CreateChildPermission(BookPermissions.ExportExcel, L("ExportExcel")); - } - - private ILocalizableString L(string v) - { - return new LocalizableString(v, BookListConsts.LocalizationSourceName); - } - } -} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs deleted file mode 100644 index a057c69..0000000 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Lpb.BookList.BookListManagement.Books.Authorization -{ - /// - /// 对书籍权限的申明 - /// - public static class BookPermissions - { - public const string BookManager = "Pages.BookManager"; - public const string Query = "Pages.Book.Query"; - public const string Create = "Pages.Book.Create"; - public const string Edit = "Pages.Book.Edit"; - public const string Delete = "Pages.Book.Delete"; - public const string BatchDelete = "Pages.Book.BatchDelete"; - public const string ExportExcel = "Pages.Book.ExportExcel"; - } -} \ No newline at end of file -- Gitee From bfd6ee6b2de731ad956b79c9fe9673369cf83649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9C=8B=E5=8B=83?= <243310820@qq.com> Date: Mon, 24 Dec 2018 14:20:02 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=E7=94=9F=E6=88=90=E4=B9=A6=E7=B1=8D=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../52abp_code_power/Book.json | 2 +- src/booklist-aspnet-core/solutionInfo.json | 2 +- .../BookListApplicationModule.cs | 2 +- .../Books/BookApplicationService.cs | 212 ++++++++++++++++++ .../Books/Client/NGZorro/books/Readme.md | 75 +++++++ .../Client/NGZorro/books/book.component.html | 202 +++++++++++++++++ .../Client/NGZorro/books/book.component.less | 0 .../Client/NGZorro/books/book.component.ts | 115 ++++++++++ .../create-or-edit-book.component.html | 94 ++++++++ .../create-or-edit-book.component.less | 0 .../create-or-edit-book.component.ts | 65 ++++++ .../Books/Dtos/BookEditDto.cs | 65 ++++++ .../Books/Dtos/BookListDto.cs | 61 +++++ .../Books/Dtos/CreateOrUpdateBookInput.cs | 15 ++ .../Books/Dtos/GetBookForEditOutput.cs | 15 ++ .../Books/Dtos/GetBooksInput.cs | 23 ++ .../Books/IBookApplicationService.cs | 82 +++++++ .../Books/Mapper/BookMapper.cs | 24 ++ .../BookListManagement/Books/Readme.md | 110 +++++++++ .../Dtos/PagedAndFilteredInputDto.cs | 29 +++ .../Dtos/PagedAndSortedInputDto.cs | 21 ++ .../Dtos/PagedInputDto.cs | 20 +- .../Dtos/PagedSortedAndFilteredInputDto.cs | 16 ++ .../src/Lpb.BookList.Core/AppLtmConsts.cs | 17 ++ .../Authorization/AppLtmPermissions.cs | 21 ++ .../BookListDomainServiceBase.cs | 21 ++ .../{ => BookTags}/BookTag.cs | 7 +- .../BookAuthorizationProvider.cs | 59 +++++ .../Books/Authorization/BookPermissions.cs | 52 +++++ .../Books/DomainService/BookManager.cs | 61 +++++ .../Books/DomainService/IBookManager.cs | 27 +++ .../BookListManagement/Books/Readme.md | 110 +++++++++ .../{ => CloudBookLists}/CloudBookList.cs | 7 +- .../SourceFiles/BookList-zh-Hans.xml | 2 + .../Lpb.BookList.Core/YoYoAbpefCoreConsts.cs | 33 +++ .../EntityFrameworkCore/BookListDbContext.cs | 8 + 36 files changed, 1655 insertions(+), 20 deletions(-) create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookApplicationService.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/Readme.md create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.html create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.less create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.ts create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.html create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.less create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.ts create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBooksInput.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookApplicationService.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Readme.md create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndFilteredInputDto.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndSortedInputDto.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedSortedAndFilteredInputDto.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/AppLtmConsts.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/Authorization/AppLtmPermissions.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListDomainServiceBase.cs rename src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/{ => BookTags}/BookTag.cs (62%) create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/BookManager.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/IBookManager.cs create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Readme.md rename src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/{ => CloudBookLists}/CloudBookList.cs (70%) create mode 100644 src/booklist-aspnet-core/src/Lpb.BookList.Core/YoYoAbpefCoreConsts.cs diff --git a/src/booklist-aspnet-core/52abp_code_power/Book.json b/src/booklist-aspnet-core/52abp_code_power/Book.json index 285a887..d7a3126 100644 --- a/src/booklist-aspnet-core/52abp_code_power/Book.json +++ b/src/booklist-aspnet-core/52abp_code_power/Book.json @@ -1 +1 @@ -{"EntityKeyName":"long","BaseClassName":"CreationAuditedEntity","BaseClassDtoName":"CreationAuditedEntityDto","BaseClassNameList":"","Name":"Book","LowerName":"book","SplitName":"book","NameSplit":["book"],"Namespace":"Lpb.BookList.BookListManagement","Properties":[{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"Name","FieldDisplayName":"Name","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"name","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"Author","FieldDisplayName":"Author","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"author","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"Intro","FieldDisplayName":"Intro","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"intro","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"PriceUrl","FieldDisplayName":"PriceUrl","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"priceUrl","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"ImgUrl","FieldDisplayName":"ImgUrl","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"imgUrl","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null}]} \ No newline at end of file +{"EntityKeyName":"long","BaseClassName":"CreationAuditedEntity","BaseClassDtoName":"CreationAuditedEntityDto","BaseClassNameList":"","Name":"Book","LowerName":"book","SplitName":"book","NameSplit":["book"],"Namespace":"Lpb.BookList.BookListManagement.Books","Properties":[{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"Name","FieldDisplayName":"书名","Required":true,"MinLength":1,"MaxLength":50,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"name","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"Author","FieldDisplayName":"作者","Required":true,"MinLength":1,"MaxLength":50,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"author","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"Intro","FieldDisplayName":"简介","Required":true,"MinLength":10,"MaxLength":300,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":2,"IsCollection":false,"FieldNameFirstLower":"intro","ContrlType":"Textarea","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"PriceUrl","FieldDisplayName":"购买链接","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"priceUrl","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null},{"Checked":true,"EditChecked":true,"ListChecked":true,"FieldName":"ImgUrl","FieldDisplayName":"图片链接","Required":false,"MinLength":null,"MaxLength":null,"RegularExpression":null,"FieldTypeStr":"string","FieldType":null,"CtrlTypes":["Text","Checkbox","Textarea","DatePicker","DateTimePicker","DropdownList"],"CtrlTypeIndex":0,"IsCollection":false,"FieldNameFirstLower":"imgUrl","ContrlType":"Text","AttributesList":[],"IsSimpleProperty":true,"IsRelation":false,"RelatedEntityName":null}]} \ No newline at end of file diff --git a/src/booklist-aspnet-core/solutionInfo.json b/src/booklist-aspnet-core/solutionInfo.json index 80d373a..7beeace 100644 --- a/src/booklist-aspnet-core/solutionInfo.json +++ b/src/booklist-aspnet-core/solutionInfo.json @@ -1 +1 @@ -{"Application":{"PType":2,"BasePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.Application","ProjectName":"Lpb.BookList.Application","CodeTemplates":[]},"Core":{"PType":0,"BasePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.Core","ProjectName":"Lpb.BookList.Core","CodeTemplates":[]},"EF":{"PType":1,"BasePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.EntityFrameworkCore","ProjectName":"Lpb.BookList.EntityFrameworkCore","CodeTemplates":[]},"SolutionNamespace":"BookList","CompanyNamespace":"Lpb.","CurrentProjectName":"Lpb.BookList.Core","CurrentSelectFilePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.Core\\BookListManagement\\Book.cs","IsAbpZero":false,"SolutionPath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core"} \ No newline at end of file +{"Application":{"PType":2,"BasePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.Application","ProjectName":"Lpb.BookList.Application","CodeTemplates":[]},"Core":{"PType":0,"BasePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.Core","ProjectName":"Lpb.BookList.Core","CodeTemplates":[]},"EF":{"PType":1,"BasePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.EntityFrameworkCore","ProjectName":"Lpb.BookList.EntityFrameworkCore","CodeTemplates":[]},"SolutionNamespace":"BookList","CompanyNamespace":"Lpb.","CurrentProjectName":"Lpb.BookList.Core","CurrentSelectFilePath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core\\src\\Lpb.BookList.Core\\BookListManagement\\Books\\Book.cs","IsAbpZero":false,"SolutionPath":"D:\\VS_work\\DotNetCore\\52ABP\\Lpb.BookList_V3.9.0\\src\\booklist-aspnet-core"} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListApplicationModule.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListApplicationModule.cs index 10df9c2..8f64474 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListApplicationModule.cs +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListApplicationModule.cs @@ -23,7 +23,7 @@ namespace Lpb.BookList Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration => { // XXXMapper.CreateMappers(configuration); - BookMapper.CreateMappers(configuration); + BookMapper.CreateMappings(configuration); }); } diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookApplicationService.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookApplicationService.cs new file mode 100644 index 0000000..026a3ef --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/BookApplicationService.cs @@ -0,0 +1,212 @@ + +using System; +using System.Data; +using System.Linq; +using System.Linq.Dynamic; +using System.Linq.Dynamic.Core; +using System.Linq.Expressions; +using System.Threading.Tasks; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +using Abp.UI; +using Abp.AutoMapper; +using Abp.Extensions; +using Abp.Authorization; +using Abp.Domain.Repositories; +using Abp.Application.Services.Dto; +using Abp.Linq.Extensions; + + +using Lpb.BookList.BookListManagement.Books; +using Lpb.BookList.BookListManagement.Books.Dtos; +using Lpb.BookList.BookListManagement.Books.DomainService; +using Lpb.BookList.BookListManagement.Books.Authorization; + + +namespace Lpb.BookList.BookListManagement.Books +{ + /// + /// Book应用层服务的接口实现方法 + /// + [AbpAuthorize] + public class BookAppService : BookListAppServiceBase, IBookAppService + { + private readonly IRepository _entityRepository; + + private readonly IBookManager _entityManager; + + /// + /// 构造函数 + /// + public BookAppService( + IRepository entityRepository + , IBookManager entityManager + ) + { + _entityRepository = entityRepository; + _entityManager = entityManager; + } + + + /// + /// 获取Book的分页列表信息 + /// + /// + /// + [AbpAuthorize(BookPermissions.Query)] + public async Task> GetPaged(GetBooksInput input) + { + + var query = _entityRepository.GetAll(); + // TODO:根据传入的参数添加过滤条件 + + + var count = await query.CountAsync(); + + var entityList = await query + .OrderBy(input.Sorting).AsNoTracking() + .PageBy(input) + .ToListAsync(); + + // var entityListDtos = ObjectMapper.Map>(entityList); + var entityListDtos = entityList.MapTo>(); + + return new PagedResultDto(count, entityListDtos); + } + + + /// + /// 通过指定id获取BookListDto信息 + /// + [AbpAuthorize(BookPermissions.Query)] + public async Task GetById(EntityDto input) + { + var entity = await _entityRepository.GetAsync(input.Id); + + return entity.MapTo(); + } + + /// + /// 获取编辑 Book + /// + /// + /// + [AbpAuthorize(BookPermissions.Create, BookPermissions.Edit)] + public async Task GetForEdit(NullableIdDto input) + { + var output = new GetBookForEditOutput(); + BookEditDto editDto; + + if (input.Id.HasValue) + { + var entity = await _entityRepository.GetAsync(input.Id.Value); + + editDto = entity.MapTo(); + + //bookEditDto = ObjectMapper.Map>(entity); + } + else + { + editDto = new BookEditDto(); + } + + output.Book = editDto; + return output; + } + + + /// + /// 添加或者修改Book的公共方法 + /// + /// + /// + [AbpAuthorize(BookPermissions.Create, BookPermissions.Edit)] + public async Task CreateOrUpdate(CreateOrUpdateBookInput input) + { + + if (input.Book.Id.HasValue) + { + await Update(input.Book); + } + else + { + await Create(input.Book); + } + } + + + /// + /// 新增Book + /// + [AbpAuthorize(BookPermissions.Create)] + protected virtual async Task Create(BookEditDto input) + { + //TODO:新增前的逻辑判断,是否允许新增 + + // var entity = ObjectMapper.Map (input); + var entity = input.MapTo(); + + + entity = await _entityRepository.InsertAsync(entity); + return entity.MapTo(); + } + + /// + /// 编辑Book + /// + [AbpAuthorize(BookPermissions.Edit)] + protected virtual async Task Update(BookEditDto input) + { + //TODO:更新前的逻辑判断,是否允许更新 + + var entity = await _entityRepository.GetAsync(input.Id.Value); + input.MapTo(entity); + + // ObjectMapper.Map(input, entity); + await _entityRepository.UpdateAsync(entity); + } + + + + /// + /// 删除Book信息的方法 + /// + /// + /// + [AbpAuthorize(BookPermissions.Delete)] + public async Task Delete(EntityDto input) + { + //TODO:删除前的逻辑判断,是否允许删除 + await _entityRepository.DeleteAsync(input.Id); + } + + + + /// + /// 批量删除Book的方法 + /// + [AbpAuthorize(BookPermissions.BatchDelete)] + public async Task BatchDelete(List input) + { + // TODO:批量删除前的逻辑判断,是否允许删除 + await _entityRepository.DeleteAsync(s => input.Contains(s.Id)); + } + + + /// + /// 导出Book为excel表,等待开发。 + /// + /// + //public async Task GetToExcel() + //{ + // var users = await UserManager.Users.ToListAsync(); + // var userListDtos = ObjectMapper.Map>(users); + // await FillRoleNames(userListDtos); + // return _userListExcelExporter.ExportToFile(userListDtos); + //} + + } +} + + diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/Readme.md b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/Readme.md new file mode 100644 index 0000000..638a66a --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/Readme.md @@ -0,0 +1,75 @@ + + +# 前端配置 +# service-proxy.module 配置 + +1. 首先在前端项目的根目录中的打开 `nswag-> refresh.bat` 批处理文件更新 service-proxies.ts 文件内容 + +2. 再到文件夹路径为`\src\shared\service-proxies\service-proxy.module.ts` 文件中添加以下代码: + +``` +@NgModule({ + providers: [ + //以下内容复制进去 + ApiServiceProxies.BookServiceProxy, + // + ], + }) + +``` + +# 菜单配置, 添加到菜单位置 +到`AppMenus.ts`文件中添加菜单路径 + +> 复制以下最新代码段内容 + +``` +{text:'Book',i18n:'Book',acl:'Pages.Book',icon:'anticon anticon-dashboard',link:'/app/admin/book'} +``` + + +> 如果您使用的是`yoyo-ng-module`的话,请复制以下代码段内容: +``` +new MenuItem('Book', 'Pages.Book', 'anticon anticon-dashboard', '/app/admin/book') +``` + +> '/app/admin/book') 中的 admin 可以自行更改到你的特定模块下, + +# 路由配置, 添加到使用位置路由的代码段 + + +添加以下代码到自己的模块路由中:如`src\app\admin\admin-routing.module.ts` + + +#### 不带权限 +``` +{ path: 'book', component:BookComponent }, +``` + +#### 带权限验证 + +``` +{ path: 'book', component:BookComponent,data: { permission: 'Pages.Book' } }, + +``` + +以上二选一 + + + + + +# 在本组件的 Module 中,添加以下代码到使用的 @NgModule 中的代码 +### ================ 在 declarations 项中: + +``` +BookComponent, +CreateOrEditBookComponent, + +``` + +### ================ 在 entryComponents 项中: + +``` +CreateOrEditBookComponent, +``` \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.html b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.html new file mode 100644 index 0000000..cbc67f6 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.html @@ -0,0 +1,202 @@ + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + {{l('GridFooterDisplayText',pageNumber,totalPages,total,range[0],range[1])}} + + + + + + + {{l('Name')}} + + + {{l('Author')}} + + + {{l('Intro')}} + + + {{l('PriceUrl')}} + + + {{l('ImgUrl')}} + + + {{l('Actions')}} + + + + + + + + + + + + + {{item.name}} + + + + + + + {{item.author}} + + + + + + + {{item.intro}} + + + + + + + {{item.priceUrl}} + + + + + + + {{item.imgUrl}} + + + + + + + + + + + {{l('Edit')}} + + + + + + + + + {{l('Delete')}} + + + + + + + + + + {{l('More')}} + + + + + + + + + + + +
+ diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.less b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.ts b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.ts new file mode 100644 index 0000000..464b581 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/book.component.ts @@ -0,0 +1,115 @@ + +import { Component, Injector, OnInit } from '@angular/core'; +import * as _ from 'lodash'; +import { appModuleAnimation } from '@shared/animations/routerTransition'; +import { PagedListingComponentBase, PagedRequestDto } from '@shared/component-base/paged-listing-component-base'; +import {BookServiceProxy, PagedResultDtoOfBookListDto, BookListDto } from '@shared/service-proxies/service-proxies'; +import { CreateOrEditBookComponent } from './create-or-edit-book/create-or-edit-book.component'; +import { AppConsts } from '@shared/AppConsts'; +// import { FileDownloadService } from '@shared/utils/file-download.service'; + +@Component({ + templateUrl: './book.component.html', + styleUrls: ['./book.component.less'], + animations: [appModuleAnimation()], +}) + + +export class BookComponent extends PagedListingComponentBase + implements OnInit { + + constructor( + injector: Injector, + private _bookService: BookServiceProxy + ) { + super(injector); + } + + /** + * 获取后端数据列表信息 + * @param request 请求的数据的dto 请求必需参数 skipCount: number; maxResultCount: number; + * @param pageNumber 当前页码 + * @param finishedCallback 完成后回调函数 + */ + protected fetchDataList(request: PagedRequestDto,pageNumber: number,finishedCallback: Function): void { + this._bookService.getPaged( + this.filterText, + request.sorting, + request.maxResultCount, + request.skipCount, + ) + .finally(() => { + finishedCallback(); + }) + .subscribe(result => { + this.dataList = result.items; + this.showPaging(result); + }); + } + + /** + * 新增或编辑DTO信息 + * @param id 当前DTO的Id + */ + createOrEdit(id?: number): void { + this.modalHelper.static(CreateOrEditBookComponent, { id: id }) + .subscribe(result => { + if (result) { + this.refresh(); + } + }); + } + + + /** + * 删除功能 + * @param entity 角色的实体信息 + */ + delete(entity: BookListDto): void { + this._bookService.delete(entity.id) + .subscribe(() => { + /** + * 刷新表格数据并跳转到第一页(`pageNumber = 1`) + */ + this.refreshGoFirstPage(); + this.notify.success(this.l('SuccessfullyDeleted')); + }); + } + + /** + * 批量删除 + */ + batchDelete(): void { + const selectCount = this.selectedDataItems.length; + if (selectCount <= 0) { + abp.message.warn(this.l('PleaseSelectAtLeastOneItem')); + return; + } + + abp.message.confirm( + this.l('ConfirmDeleteXItemsWarningMessage', selectCount), + res => { + if (res) { + const ids = _.map(this.selectedDataItems, 'id'); + this._bookService.batchDelete(ids).subscribe(() => { + this.refreshGoFirstPage(); + this.notify.success(this.l('SuccessfullyDeleted')); + }); + } + }, + ); + } + + + /** + * 导出为Excel表 + */ + exportToExcel(): void { + abp.message.error('功能开发中!!!!'); + // this._bookService.getBookexportToExcel().subscribe(result => { + // this._fileDownloadService.downloadTempFile(result); + // }); + } + +} + diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.html b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.html new file mode 100644 index 0000000..6585f1a --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.html @@ -0,0 +1,94 @@ + + +
+ + + +
+ + + + {{l('Name')}} + + + + + +{{l('超过最大长度')+50}} {{l('小于最小长度')+1}} {{l('CanNotNull')}} + + + + + + {{l('Author')}} + + + + + +{{l('超过最大长度')+50}} {{l('小于最小长度')+1}} {{l('CanNotNull')}} + + + + + + {{l('Intro')}} + + + + + +{{l('超过最大长度')+300}} {{l('小于最小长度')+10}} {{l('CanNotNull')}} + + + + + + {{l('PriceUrl')}} + + + + + + + + {{l('ImgUrl')}} + + + + + + + +
+ + +
+ + + + + diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.less b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.ts b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.ts new file mode 100644 index 0000000..a5ac6eb --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Client/NGZorro/books/create-or-edit-book/create-or-edit-book.component.ts @@ -0,0 +1,65 @@ + +import { Component, OnInit, Injector, Input, ViewChild, AfterViewInit } from '@angular/core'; +import { ModalComponentBase } from '@shared/component-base/modal-component-base'; +import { CreateOrUpdateBookInput,BookEditDto, BookServiceProxy } from '@shared/service-proxies/service-proxies'; +import { Validators, AbstractControl, FormControl } from '@angular/forms'; + +@Component({ + selector: 'create-or-edit-book', + templateUrl: './create-or-edit-book.component.html', + styleUrls:[ + 'create-or-edit-book.component.less' + ], +}) + +export class CreateOrEditBookComponent + extends ModalComponentBase + implements OnInit { + /** + * 编辑时DTO的id + */ + id: any ; + + entity: BookEditDto=new BookEditDto(); + + /** + * 初始化的构造函数 + */ + constructor( + injector: Injector, + private _bookService: BookServiceProxy + ) { + super(injector); + } + + ngOnInit() :void{ + this.init(); + } + + + /** + * 初始化方法 + */ + init(): void { + this._bookService.getForEdit(this.id).subscribe(result => { + this.entity = result.book; + }); + } + + /** + * 保存方法,提交form表单 + */ + submitForm(): void { + const input = new CreateOrUpdateBookInput(); + input.book = this.entity; + + this.saving = true; + + this._bookService.createOrUpdate(input) + .finally(() => (this.saving = false)) + .subscribe(() => { + this.notify.success(this.l('SavedSuccessfully')); + this.success(true); + }); + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs new file mode 100644 index 0000000..fbd0e94 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookEditDto.cs @@ -0,0 +1,65 @@ + +using System; +using System.ComponentModel.DataAnnotations; +using Abp.Domain.Entities.Auditing; +using Lpb.BookList.BookListManagement.Books; + +namespace Lpb.BookList.BookListManagement.Books.Dtos +{ + public class BookEditDto + { + + /// + /// Id + /// + public long? Id { get; set; } + + + + /// + /// 书名 + /// + [MaxLength(50, ErrorMessage="书名超出最大长度")] + [MinLength(1, ErrorMessage="书名小于最小长度")] + [Required(ErrorMessage="书名不能为空")] + public string Name { get; set; } + + + + /// + /// 作者 + /// + [MaxLength(50, ErrorMessage="作者超出最大长度")] + [MinLength(1, ErrorMessage="作者小于最小长度")] + [Required(ErrorMessage="作者不能为空")] + public string Author { get; set; } + + + + /// + /// 简介 + /// + [MaxLength(300, ErrorMessage="简介超出最大长度")] + [MinLength(10, ErrorMessage="简介小于最小长度")] + [Required(ErrorMessage="简介不能为空")] + public string Intro { get; set; } + + + + /// + /// 购买链接 + /// + public string PriceUrl { get; set; } + + + + /// + /// 图片链接 + /// + public string ImgUrl { get; set; } + + + + + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs new file mode 100644 index 0000000..57d5d65 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/BookListDto.cs @@ -0,0 +1,61 @@ + + +using System; +using Abp.Application.Services.Dto; +using Abp.Domain.Entities.Auditing; +using System.ComponentModel.DataAnnotations; +using Lpb.BookList.BookListManagement.Books; + +namespace Lpb.BookList.BookListManagement.Books.Dtos +{ + public class BookListDto : CreationAuditedEntityDto + { + + + /// + /// 书名 + /// + [MaxLength(50, ErrorMessage="书名超出最大长度")] + [MinLength(1, ErrorMessage="书名小于最小长度")] + [Required(ErrorMessage="书名不能为空")] + public string Name { get; set; } + + + + /// + /// 作者 + /// + [MaxLength(50, ErrorMessage="作者超出最大长度")] + [MinLength(1, ErrorMessage="作者小于最小长度")] + [Required(ErrorMessage="作者不能为空")] + public string Author { get; set; } + + + + /// + /// 简介 + /// + [MaxLength(300, ErrorMessage="简介超出最大长度")] + [MinLength(10, ErrorMessage="简介小于最小长度")] + [Required(ErrorMessage="简介不能为空")] + public string Intro { get; set; } + + + + /// + /// 购买链接 + /// + public string PriceUrl { get; set; } + + + + /// + /// 图片链接 + /// + public string ImgUrl { get; set; } + + + + + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs new file mode 100644 index 0000000..e52623f --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/CreateOrUpdateBookInput.cs @@ -0,0 +1,15 @@ + + +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Lpb.BookList.BookListManagement.Books; + +namespace Lpb.BookList.BookListManagement.Books.Dtos +{ + public class CreateOrUpdateBookInput + { + [Required] + public BookEditDto Book { get; set; } + + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs new file mode 100644 index 0000000..dfa60cc --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBookForEditOutput.cs @@ -0,0 +1,15 @@ + + +using System.Collections.Generic; +using Abp.Application.Services.Dto; +using Lpb.BookList.BookListManagement.Books; + +namespace Lpb.BookList.BookListManagement.Books.Dtos +{ + public class GetBookForEditOutput + { + + public BookEditDto Book { get; set; } + + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBooksInput.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBooksInput.cs new file mode 100644 index 0000000..51422bc --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Dtos/GetBooksInput.cs @@ -0,0 +1,23 @@ + +using Abp.Runtime.Validation; +using Lpb.BookList.Dtos; +using Lpb.BookList.BookListManagement.Books; + +namespace Lpb.BookList.BookListManagement.Books.Dtos +{ + public class GetBooksInput : PagedSortedAndFilteredInputDto, IShouldNormalize + { + + /// + /// 正常化排序使用 + /// + public void Normalize() + { + if (string.IsNullOrEmpty(Sorting)) + { + Sorting = "Id"; + } + } + + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookApplicationService.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookApplicationService.cs new file mode 100644 index 0000000..48d61db --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/IBookApplicationService.cs @@ -0,0 +1,82 @@ + +using System; +using System.Data; +using System.Linq; +using System.Linq.Dynamic; +using System.Linq.Dynamic.Core; +using System.Linq.Expressions; +using System.Threading.Tasks; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +using Abp.UI; +using Abp.AutoMapper; +using Abp.Authorization; +using Abp.Linq.Extensions; +using Abp.Domain.Repositories; +using Abp.Application.Services; +using Abp.Application.Services.Dto; + + +using Lpb.BookList.BookListManagement.Books.Dtos; +using Lpb.BookList.BookListManagement.Books; + +namespace Lpb.BookList.BookListManagement.Books +{ + /// + /// Book应用层服务的接口方法 + /// + public interface IBookAppService : IApplicationService + { + /// + /// 获取Book的分页列表信息 + /// + /// + /// + Task> GetPaged(GetBooksInput input); + + + /// + /// 通过指定id获取BookListDto信息 + /// + Task GetById(EntityDto input); + + + /// + /// 返回实体的EditDto + /// + /// + /// + Task GetForEdit(NullableIdDto input); + + + /// + /// 添加或者修改Book的公共方法 + /// + /// + /// + Task CreateOrUpdate(CreateOrUpdateBookInput input); + + + /// + /// 删除Book信息的方法 + /// + /// + /// + Task Delete(EntityDto input); + + + /// + /// 批量删除Book + /// + Task BatchDelete(List input); + + + /// + /// 导出Book为excel表 + /// + /// + //Task GetToExcel(); + + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs new file mode 100644 index 0000000..4ec7167 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Mapper/BookMapper.cs @@ -0,0 +1,24 @@ + +using AutoMapper; +using Lpb.BookList.BookListManagement.Books; +using Lpb.BookList.BookListManagement.Books.Dtos; + +namespace Lpb.BookList.BookListManagement.Books.Mapper +{ + + /// + /// 配置Book的AutoMapper + /// + internal static class BookMapper + { + public static void CreateMappings(IMapperConfigurationExpression configuration) + { + configuration.CreateMap (); + configuration.CreateMap (); + + configuration.CreateMap (); + configuration.CreateMap (); + + } + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Readme.md b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Readme.md new file mode 100644 index 0000000..c862861 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/BookListManagement/Books/Readme.md @@ -0,0 +1,110 @@ + +#代码生成器(ABP Code Power Tools )使用说明文档 + +**52ABP官方网站:[http://www.52abp.com](http://www.52abp.com)** + +>欢迎您使用 ABP Code Power Tools ,.net core 版本。 +开发代码生成器的初衷是为了让大家专注于业务开发, +而基础设施的地方,由代码生成器实现,节约大家的实现。 +实现提高效率、共赢的局面。 + +欢迎到:[Github地址](https://github.com/52ABP/52ABP.CodeGenerator) 提供您的脑洞, +如果合理的我会实现哦~ + +# 使用说明: + +**配置Automapper** : + +复制以下代码到Application层下的:BookListApplicationModule.cs +中的 PreInitialize 方法中: + +``` +// 自定义类型映射 +// 如果没有这一段就把这一段复制上去 +Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration => +{ + // .... + + // 只需要复制这一段 +BookMapper.CreateMappings(configuration); + + // .... +}); + +``` + +**配置权限功能** : + +如果你生成了**权限功能**。复制以下代码到 BookListApplicationModule.cs +中的 PreInitialize 方法中: + +``` +Configuration.Authorization.Providers.Add(); + +``` + +**EntityFramework功能配置**: + +可以在```DbContext```中增加: + + ``` +public DbSet Books { get; set; } + + ``` + +在方法```OnModelCreating```中添加 + +``` + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.ApplyConfiguration(new BookCfg()); + } + +``` + + +**多语言配置** + +.Core 层下 Localization->SourceFiles 中 + +``` + + + + + + + + +``` + + + + + **路线图** + +todo: 目前优先完成SPA 以angular 为主, +如果你有想法我替你实现前端生成的代码块。 +那么请到github 贴出你的代码段。 +我感兴趣的话,会配合你的。 + +[https://github.com/52ABP/52ABP.CodeGenerator](https://github.com/52ABP/52ABP.CodeGenerator) 提供您的脑洞, + +已完成: +- [x ]SPA版本的前端 + +待办: +- [ ]暂时搞不定注释,后期想办法 +- [ ]菜单栏问题,如果是MPA版本 +- [ ]MPA版本的前端 +## 广告 + +52ABP官方网站:[http://www.52abp.com](http://www.52abp.com) + +代码生成器帮助文档:[http://www.cnblogs.com/wer-ltm/p/8445682.html](http://www.cnblogs.com/wer-ltm/p/8445682.html) + +【ABP代码生成器交流群】:104390185(收费) +[![52ABP .NET CORE 实战群](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=3f301fa3101d3201c391aba77803b523fcc53e59d0c68e6eeb9a79336c366d92) + +【52ABP .NET CORE 实战群】:633751348 (免费) +[![52ABP .NET CORE 实战群](http://pub.idqqimg.com/wpa/images/group.png)](https://jq.qq.com/?_wv=1027&k=5pWtBvu) diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndFilteredInputDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndFilteredInputDto.cs new file mode 100644 index 0000000..23a6dab --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndFilteredInputDto.cs @@ -0,0 +1,29 @@ + + +using System.ComponentModel.DataAnnotations; +using Abp.Application.Services.Dto; + +namespace Lpb.BookList.Dtos +{ + public class PagedAndFilteredInputDto : IPagedResultRequest + { + [Range(1, AppLtmConsts.MaxPageSize)] + public int MaxResultCount { get; set; } + + [Range(0, int.MaxValue)] + public int SkipCount { get; set; } + + public string FilterText { get; set; } + + + + + + + + public PagedAndFilteredInputDto() + { + MaxResultCount = AppLtmConsts.DefaultPageSize; + } + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndSortedInputDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndSortedInputDto.cs new file mode 100644 index 0000000..814738d --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedAndSortedInputDto.cs @@ -0,0 +1,21 @@ + + +using Abp.Application.Services.Dto; + +namespace Lpb.BookList.Dtos +{ + public class PagedAndSortedInputDto : PagedInputDto, ISortedResultRequest + { + public string Sorting { get; set; } + + + + + + + public PagedAndSortedInputDto() + { + MaxResultCount = AppLtmConsts.DefaultPageSize; + } + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedInputDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedInputDto.cs index d6269e5..8ec7704 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedInputDto.cs +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedInputDto.cs @@ -1,22 +1,28 @@ -using System; -using System.Collections.Generic; + + using System.ComponentModel.DataAnnotations; -using System.Text; using Abp.Application.Services.Dto; namespace Lpb.BookList.Dtos { public class PagedInputDto : IPagedResultRequest { + [Range(1, AppLtmConsts.MaxPageSize)] + public int MaxResultCount { get; set; } + [Range(0, int.MaxValue)] public int SkipCount { get; set; } - [Range(1, AppConsts.MaxPageSize)] - public int MaxResultCount { get; set; } + + + + + + public PagedInputDto() { - MaxResultCount = AppConsts.DefaultPageSize; + MaxResultCount = AppLtmConsts.DefaultPageSize; } } -} +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedSortedAndFilteredInputDto.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedSortedAndFilteredInputDto.cs new file mode 100644 index 0000000..f521802 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Application/Dtos/PagedSortedAndFilteredInputDto.cs @@ -0,0 +1,16 @@ + + +namespace Lpb.BookList.Dtos +{ + public class PagedSortedAndFilteredInputDto : PagedAndSortedInputDto + { + public string FilterText { get; set; } + + + + + + + + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/AppLtmConsts.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/AppLtmConsts.cs new file mode 100644 index 0000000..73ae2b0 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/AppLtmConsts.cs @@ -0,0 +1,17 @@ + + +namespace Lpb.BookList +{ + public class AppLtmConsts + { + // TODO: 52ABP代码生成器默认生成的一些常量类 ,不影响业务逻辑点 + public const int DefaultPageSize = 10; + public const int MaxPageSize = 1000; + + + + + + + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/Authorization/AppLtmPermissions.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/Authorization/AppLtmPermissions.cs new file mode 100644 index 0000000..f3745aa --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/Authorization/AppLtmPermissions.cs @@ -0,0 +1,21 @@ + + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Lpb.BookList.Authorization +{ + /// + /// 52abp定义的默认权限变量名称 + /// + public class AppLtmPermissions + { + public const string Pages = "Pages"; + public const string Pages_Administration = "Pages.Administration"; + + + + + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListDomainServiceBase.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListDomainServiceBase.cs new file mode 100644 index 0000000..4ba0fe5 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListDomainServiceBase.cs @@ -0,0 +1,21 @@ + + +using Abp.Domain.Services; + +namespace Lpb.BookList +{ + public abstract class BookListDomainServiceBase : DomainService + { + /* Add your common members for all your domain services. */ + /*在领域服务中添加你的自定义公共方法*/ + + + + + + protected BookListDomainServiceBase() + { + LocalizationSourceName = BookListConsts.LocalizationSourceName; + } + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/BookTag.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/BookTags/BookTag.cs similarity index 62% rename from src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/BookTag.cs rename to src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/BookTags/BookTag.cs index 89c0ec9..ad6e93d 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/BookTag.cs +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/BookTags/BookTag.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Abp.Domain.Entities.Auditing; +using Abp.Domain.Entities.Auditing; -namespace Lpb.BookList.BookListManagement +namespace Lpb.BookList.BookListManagement.BookTags { /// /// 书籍标签 diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs new file mode 100644 index 0000000..8772cbd --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookAuthorizationProvider.cs @@ -0,0 +1,59 @@ + + +using System.Linq; +using Abp.Authorization; +using Abp.Configuration.Startup; +using Abp.Localization; +using Abp.MultiTenancy; +using Lpb.BookList.Authorization; + +namespace Lpb.BookList.BookListManagement.Books.Authorization +{ + /// + /// 权限配置都在这里。 + /// 给权限默认设置服务 + /// See for all permission names. Book + /// + public class BookAuthorizationProvider : AuthorizationProvider + { + private readonly bool _isMultiTenancyEnabled; + + public BookAuthorizationProvider() + { + + } + + public BookAuthorizationProvider(bool isMultiTenancyEnabled) + { + _isMultiTenancyEnabled = isMultiTenancyEnabled; + } + + public BookAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig) + { + _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled; + } + + public override void SetPermissions(IPermissionDefinitionContext context) + { + // 在这里配置了Book 的权限。 + var pages = context.GetPermissionOrNull(AppLtmPermissions.Pages) ?? context.CreatePermission(AppLtmPermissions.Pages, L("Pages")); + + var administration = pages.Children.FirstOrDefault(p => p.Name == AppLtmPermissions.Pages_Administration) ?? pages.CreateChildPermission(AppLtmPermissions.Pages_Administration, L("Administration")); + + var entityPermission = administration.CreateChildPermission(BookPermissions.Node , L("Book")); + entityPermission.CreateChildPermission(BookPermissions.Query, L("QueryBook")); + entityPermission.CreateChildPermission(BookPermissions.Create, L("CreateBook")); + entityPermission.CreateChildPermission(BookPermissions.Edit, L("EditBook")); + entityPermission.CreateChildPermission(BookPermissions.Delete, L("DeleteBook")); + entityPermission.CreateChildPermission(BookPermissions.BatchDelete, L("BatchDeleteBook")); + entityPermission.CreateChildPermission(BookPermissions.ExportExcel, L("ExportExcelBook")); + + + } + + private static ILocalizableString L(string name) + { + return new LocalizableString(name, BookListConsts.LocalizationSourceName); + } + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs new file mode 100644 index 0000000..760b24d --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Authorization/BookPermissions.cs @@ -0,0 +1,52 @@ + + +namespace Lpb.BookList.BookListManagement.Books.Authorization +{ + /// + /// 定义系统的权限名称的字符串常量。 + /// 中对权限的定义. + /// + public static class BookPermissions + { + /// + /// Book权限节点 + /// + public const string Node = "Pages.Book"; + + /// + /// Book查询授权 + /// + public const string Query = "Pages.Book.Query"; + + /// + /// Book创建权限 + /// + public const string Create = "Pages.Book.Create"; + + /// + /// Book修改权限 + /// + public const string Edit = "Pages.Book.Edit"; + + /// + /// Book删除权限 + /// + public const string Delete = "Pages.Book.Delete"; + + /// + /// Book批量删除权限 + /// + public const string BatchDelete = "Pages.Book.BatchDelete"; + + /// + /// Book导出Excel + /// + public const string ExportExcel="Pages.Book.ExportExcel"; + + + + + } + +} + diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/BookManager.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/BookManager.cs new file mode 100644 index 0000000..49a4fcc --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/BookManager.cs @@ -0,0 +1,61 @@ + + +using System; +using System.Data; +using System.IO; +using System.Linq; +using System.Linq.Dynamic; +using System.Linq.Expressions; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Abp.Linq; +using Abp.Linq.Extensions; +using Abp.Extensions; +using Abp.UI; +using Abp.Domain.Repositories; +using Abp.Domain.Services; + +using Lpb.BookList; +using Lpb.BookList.BookListManagement.Books; + + +namespace Lpb.BookList.BookListManagement.Books.DomainService +{ + /// + /// Book领域层的业务管理 + /// + public class BookManager :BookListDomainServiceBase, IBookManager + { + + private readonly IRepository _repository; + + /// + /// Book的构造方法 + /// + public BookManager( + IRepository repository + ) + { + _repository = repository; + } + + + /// + /// 初始化 + /// + public void InitBook() + { + throw new NotImplementedException(); + } + + // TODO:编写领域业务代码 + + + + + + + + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/IBookManager.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/IBookManager.cs new file mode 100644 index 0000000..1153077 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/DomainService/IBookManager.cs @@ -0,0 +1,27 @@ + + +using System; +using System.Threading.Tasks; +using Abp; +using Abp.Domain.Services; +using Lpb.BookList.BookListManagement.Books; + + +namespace Lpb.BookList.BookListManagement.Books.DomainService +{ + public interface IBookManager : IDomainService + { + + /// + /// 初始化方法 + /// + void InitBook(); + + + + + + + + } +} diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Readme.md b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Readme.md new file mode 100644 index 0000000..c862861 --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/Books/Readme.md @@ -0,0 +1,110 @@ + +#代码生成器(ABP Code Power Tools )使用说明文档 + +**52ABP官方网站:[http://www.52abp.com](http://www.52abp.com)** + +>欢迎您使用 ABP Code Power Tools ,.net core 版本。 +开发代码生成器的初衷是为了让大家专注于业务开发, +而基础设施的地方,由代码生成器实现,节约大家的实现。 +实现提高效率、共赢的局面。 + +欢迎到:[Github地址](https://github.com/52ABP/52ABP.CodeGenerator) 提供您的脑洞, +如果合理的我会实现哦~ + +# 使用说明: + +**配置Automapper** : + +复制以下代码到Application层下的:BookListApplicationModule.cs +中的 PreInitialize 方法中: + +``` +// 自定义类型映射 +// 如果没有这一段就把这一段复制上去 +Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration => +{ + // .... + + // 只需要复制这一段 +BookMapper.CreateMappings(configuration); + + // .... +}); + +``` + +**配置权限功能** : + +如果你生成了**权限功能**。复制以下代码到 BookListApplicationModule.cs +中的 PreInitialize 方法中: + +``` +Configuration.Authorization.Providers.Add(); + +``` + +**EntityFramework功能配置**: + +可以在```DbContext```中增加: + + ``` +public DbSet Books { get; set; } + + ``` + +在方法```OnModelCreating```中添加 + +``` + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.ApplyConfiguration(new BookCfg()); + } + +``` + + +**多语言配置** + +.Core 层下 Localization->SourceFiles 中 + +``` + + + + + + + + +``` + + + + + **路线图** + +todo: 目前优先完成SPA 以angular 为主, +如果你有想法我替你实现前端生成的代码块。 +那么请到github 贴出你的代码段。 +我感兴趣的话,会配合你的。 + +[https://github.com/52ABP/52ABP.CodeGenerator](https://github.com/52ABP/52ABP.CodeGenerator) 提供您的脑洞, + +已完成: +- [x ]SPA版本的前端 + +待办: +- [ ]暂时搞不定注释,后期想办法 +- [ ]菜单栏问题,如果是MPA版本 +- [ ]MPA版本的前端 +## 广告 + +52ABP官方网站:[http://www.52abp.com](http://www.52abp.com) + +代码生成器帮助文档:[http://www.cnblogs.com/wer-ltm/p/8445682.html](http://www.cnblogs.com/wer-ltm/p/8445682.html) + +【ABP代码生成器交流群】:104390185(收费) +[![52ABP .NET CORE 实战群](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=3f301fa3101d3201c391aba77803b523fcc53e59d0c68e6eeb9a79336c366d92) + +【52ABP .NET CORE 实战群】:633751348 (免费) +[![52ABP .NET CORE 实战群](http://pub.idqqimg.com/wpa/images/group.png)](https://jq.qq.com/?_wv=1027&k=5pWtBvu) diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/CloudBookList.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/CloudBookLists/CloudBookList.cs similarity index 70% rename from src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/CloudBookList.cs rename to src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/CloudBookLists/CloudBookList.cs index 9a93db4..003df26 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/CloudBookList.cs +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/BookListManagement/CloudBookLists/CloudBookList.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Abp.Domain.Entities.Auditing; +using Abp.Domain.Entities.Auditing; -namespace Lpb.BookList.BookListManagement +namespace Lpb.BookList.BookListManagement.CloudBookLists { /// /// 书单 diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml b/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml index 0d874c4..2aa600b 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml @@ -6,6 +6,8 @@ + + diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/YoYoAbpefCoreConsts.cs b/src/booklist-aspnet-core/src/Lpb.BookList.Core/YoYoAbpefCoreConsts.cs new file mode 100644 index 0000000..cb0d2ff --- /dev/null +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/YoYoAbpefCoreConsts.cs @@ -0,0 +1,33 @@ + + +namespace Lpb.BookList +{ + public class YoYoAbpefCoreConsts + { + public static class SchemaNames + { + public const string Basic = "Basic"; + + public const string ABP = "ABP"; + + public const string CMS = "CMS"; + } + + /// + /// 实体长度单位 + /// + public static class EntityLengthNames + { + public const int Length8 = 8; + public const int Length16 = 16; + public const int Length32 = 32; + public const int Length64 = 65; + public const int Length128 = 128; + public const int Length256 = 256; + public const int Length512 = 512; + + public const int Length1024 = 1024; + + } + } +} \ No newline at end of file diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs b/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs index 5e4efc3..0b9f5ca 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs +++ b/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs @@ -4,6 +4,9 @@ using Lpb.BookList.Authorization.Roles; using Lpb.BookList.Authorization.Users; using Lpb.BookList.BookListManagement; using Lpb.BookList.BookListManagement.Books; +using Lpb.BookList.BookListManagement.BookTags; +using Lpb.BookList.BookListManagement.CloudBookLists; +using Lpb.BookList.EntityMapper.Books; using Lpb.BookList.MultiTenancy; namespace Lpb.BookList.EntityFrameworkCore @@ -20,5 +23,10 @@ namespace Lpb.BookList.EntityFrameworkCore : base(options) { } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + //modelBuilder.ApplyConfiguration(new BookCfg()); + } } } -- Gitee From 9955959299d295581b656ef39f70cc06dcb038e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9C=8B=E5=8B=83?= <243310820@qq.com> Date: Mon, 24 Dec 2018 15:03:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B9=A6=E7=B1=8D?= =?UTF-8?q?=E8=A1=A8=E7=9A=84curd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/booklist-angular/src/app/AppMenus.ts | 7 +- .../src/app/cloud-book-list/books/Readme.md | 75 +++++ .../cloud-book-list/books/book.component.html | 198 ++++++++++++ .../cloud-book-list/books/book.component.less | 0 .../cloud-book-list/books/book.component.ts | 116 +++++++ .../create-or-edit-book.component.html | 94 ++++++ .../create-or-edit-book.component.less | 0 .../create-or-edit-book.component.ts | 65 ++++ .../cloud-book-list-routing.module.ts | 6 + .../cloud-book-list/cloud-book-list.module.ts | 10 +- .../shared/service-proxies/service-proxies.ts | 289 ++++++++++++------ .../SourceFiles/BookList-zh-Hans.xml | 2 +- .../EntityFrameworkCore/BookListDbContext.cs | 9 +- 13 files changed, 770 insertions(+), 101 deletions(-) create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/Readme.md create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/book.component.html create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/book.component.less create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/book.component.ts create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.less create mode 100644 src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts diff --git a/src/booklist-angular/src/app/AppMenus.ts b/src/booklist-angular/src/app/AppMenus.ts index 68f305e..df41722 100644 --- a/src/booklist-angular/src/app/AppMenus.ts +++ b/src/booklist-angular/src/app/AppMenus.ts @@ -19,13 +19,14 @@ export class AppMenus { ), new MenuItem('Users', 'Pages.Users', 'anticon anticon-user', '/app/users'), new MenuItem('About', '', 'anticon anticon-info-circle-o', '/app/about'), - new MenuItem('CloudBookList', '', 'anticon anticon-info-circle-o', '', [ // 租户 // 角色 // 用户 // 关于我们 // 云书单 + new MenuItem('CloudBookList', '', 'anticon anticon-info-circle-o', '', [ + // 租户 // 角色 // 用户 // 关于我们 // 云书单 // 书籍 new MenuItem( 'Books', - 'Pages.BookManager', + 'Pages.Book', 'anticon anticon-book', - '/app/cloud-book-list/books', + '/app/cloud-book-list/book', ), // 书单列表 new MenuItem( diff --git a/src/booklist-angular/src/app/cloud-book-list/books/Readme.md b/src/booklist-angular/src/app/cloud-book-list/books/Readme.md new file mode 100644 index 0000000..638a66a --- /dev/null +++ b/src/booklist-angular/src/app/cloud-book-list/books/Readme.md @@ -0,0 +1,75 @@ + + +# 前端配置 +# service-proxy.module 配置 + +1. 首先在前端项目的根目录中的打开 `nswag-> refresh.bat` 批处理文件更新 service-proxies.ts 文件内容 + +2. 再到文件夹路径为`\src\shared\service-proxies\service-proxy.module.ts` 文件中添加以下代码: + +``` +@NgModule({ + providers: [ + //以下内容复制进去 + ApiServiceProxies.BookServiceProxy, + // + ], + }) + +``` + +# 菜单配置, 添加到菜单位置 +到`AppMenus.ts`文件中添加菜单路径 + +> 复制以下最新代码段内容 + +``` +{text:'Book',i18n:'Book',acl:'Pages.Book',icon:'anticon anticon-dashboard',link:'/app/admin/book'} +``` + + +> 如果您使用的是`yoyo-ng-module`的话,请复制以下代码段内容: +``` +new MenuItem('Book', 'Pages.Book', 'anticon anticon-dashboard', '/app/admin/book') +``` + +> '/app/admin/book') 中的 admin 可以自行更改到你的特定模块下, + +# 路由配置, 添加到使用位置路由的代码段 + + +添加以下代码到自己的模块路由中:如`src\app\admin\admin-routing.module.ts` + + +#### 不带权限 +``` +{ path: 'book', component:BookComponent }, +``` + +#### 带权限验证 + +``` +{ path: 'book', component:BookComponent,data: { permission: 'Pages.Book' } }, + +``` + +以上二选一 + + + + + +# 在本组件的 Module 中,添加以下代码到使用的 @NgModule 中的代码 +### ================ 在 declarations 项中: + +``` +BookComponent, +CreateOrEditBookComponent, + +``` + +### ================ 在 entryComponents 项中: + +``` +CreateOrEditBookComponent, +``` \ No newline at end of file diff --git a/src/booklist-angular/src/app/cloud-book-list/books/book.component.html b/src/booklist-angular/src/app/cloud-book-list/books/book.component.html new file mode 100644 index 0000000..d1e6468 --- /dev/null +++ b/src/booklist-angular/src/app/cloud-book-list/books/book.component.html @@ -0,0 +1,198 @@ + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + {{l('GridFooterDisplayText',pageNumber,totalPages,total,range[0],range[1])}} + + + + + + + {{l('Name')}} + + + {{l('Author')}} + + + {{l('Intro')}} + + + {{l('PriceUrl')}} + + + {{l('ImgUrl')}} + + + {{l('Actions')}} + + + + + + + + + + + + + {{item.name}} + + + + + + + {{item.author}} + + + + + + + {{item.intro}} + + + + + + + {{item.priceUrl}} + + + + + + + + + + + + + + {{l('Edit')}} + + + + + + + + + {{l('Delete')}} + + + + + + + + + + {{l('More')}} + + + + + + + + + + + +
diff --git a/src/booklist-angular/src/app/cloud-book-list/books/book.component.less b/src/booklist-angular/src/app/cloud-book-list/books/book.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/booklist-angular/src/app/cloud-book-list/books/book.component.ts b/src/booklist-angular/src/app/cloud-book-list/books/book.component.ts new file mode 100644 index 0000000..68095a0 --- /dev/null +++ b/src/booklist-angular/src/app/cloud-book-list/books/book.component.ts @@ -0,0 +1,116 @@ +import { Component, Injector, OnInit } from '@angular/core'; +import * as _ from 'lodash'; +import { appModuleAnimation } from '@shared/animations/routerTransition'; +import { + PagedListingComponentBase, + PagedRequestDto, +} from '@shared/component-base/paged-listing-component-base'; +import { + BookServiceProxy, + PagedResultDtoOfBookListDto, + BookListDto, +} from '@shared/service-proxies/service-proxies'; +import { CreateOrEditBookComponent } from './create-or-edit-book/create-or-edit-book.component'; +import { AppConsts } from '@shared/AppConsts'; +// import { FileDownloadService } from '@shared/utils/file-download.service'; + +@Component({ + templateUrl: './book.component.html', + styleUrls: ['./book.component.less'], + animations: [appModuleAnimation()], +}) +export class BookComponent extends PagedListingComponentBase + implements OnInit { + constructor(injector: Injector, private _bookService: BookServiceProxy) { + super(injector); + } + + /** + * 获取后端数据列表信息 + * @param request 请求的数据的dto 请求必需参数 skipCount: number; maxResultCount: number; + * @param pageNumber 当前页码 + * @param finishedCallback 完成后回调函数 + */ + protected fetchDataList( + request: PagedRequestDto, + pageNumber: number, + finishedCallback: Function, + ): void { + this._bookService + .getPaged( + this.filterText, + request.sorting, + request.maxResultCount, + request.skipCount, + ) + .finally(() => { + finishedCallback(); + }) + .subscribe(result => { + this.dataList = result.items; + this.showPaging(result); + }); + } + + /** + * 新增或编辑DTO信息 + * @param id 当前DTO的Id + */ + createOrEdit(id?: number): void { + this.modalHelper + .static(CreateOrEditBookComponent, { id: id }) + .subscribe(result => { + if (result) { + this.refresh(); + } + }); + } + + /** + * 删除功能 + * @param entity 角色的实体信息 + */ + delete(entity: BookListDto): void { + this._bookService.delete(entity.id).subscribe(() => { + /** + * 刷新表格数据并跳转到第一页(`pageNumber = 1`) + */ + this.refreshGoFirstPage(); + this.notify.success(this.l('SuccessfullyDeleted')); + }); + } + + /** + * 批量删除 + */ + batchDelete(): void { + const selectCount = this.selectedDataItems.length; + if (selectCount <= 0) { + abp.message.warn(this.l('PleaseSelectAtLeastOneItem')); + return; + } + + abp.message.confirm( + this.l('ConfirmDeleteXItemsWarningMessage', selectCount), + res => { + if (res) { + const ids = _.map(this.selectedDataItems, 'id'); + this._bookService.batchDelete(ids).subscribe(() => { + this.refreshGoFirstPage(); + this.notify.success(this.l('SuccessfullyDeleted')); + }); + } + }, + ); + } + + /** + * 导出为Excel表 + */ + exportToExcel(): void { + abp.message.error('功能开发中!!!!'); + // this._bookService.getBookexportToExcel().subscribe(result => { + // this._fileDownloadService.downloadTempFile(result); + // }); + } +} diff --git a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html new file mode 100644 index 0000000..6585f1a --- /dev/null +++ b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.html @@ -0,0 +1,94 @@ + + +
+ + + +
+ + + + {{l('Name')}} + + + + + +{{l('超过最大长度')+50}} {{l('小于最小长度')+1}} {{l('CanNotNull')}} + + + + + + {{l('Author')}} + + + + + +{{l('超过最大长度')+50}} {{l('小于最小长度')+1}} {{l('CanNotNull')}} + + + + + + {{l('Intro')}} + + + + + +{{l('超过最大长度')+300}} {{l('小于最小长度')+10}} {{l('CanNotNull')}} + + + + + + {{l('PriceUrl')}} + + + + + + + + {{l('ImgUrl')}} + + + + + + + +
+ + +
+ + + + + diff --git a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.less b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts new file mode 100644 index 0000000..a5ac6eb --- /dev/null +++ b/src/booklist-angular/src/app/cloud-book-list/books/create-or-edit-book/create-or-edit-book.component.ts @@ -0,0 +1,65 @@ + +import { Component, OnInit, Injector, Input, ViewChild, AfterViewInit } from '@angular/core'; +import { ModalComponentBase } from '@shared/component-base/modal-component-base'; +import { CreateOrUpdateBookInput,BookEditDto, BookServiceProxy } from '@shared/service-proxies/service-proxies'; +import { Validators, AbstractControl, FormControl } from '@angular/forms'; + +@Component({ + selector: 'create-or-edit-book', + templateUrl: './create-or-edit-book.component.html', + styleUrls:[ + 'create-or-edit-book.component.less' + ], +}) + +export class CreateOrEditBookComponent + extends ModalComponentBase + implements OnInit { + /** + * 编辑时DTO的id + */ + id: any ; + + entity: BookEditDto=new BookEditDto(); + + /** + * 初始化的构造函数 + */ + constructor( + injector: Injector, + private _bookService: BookServiceProxy + ) { + super(injector); + } + + ngOnInit() :void{ + this.init(); + } + + + /** + * 初始化方法 + */ + init(): void { + this._bookService.getForEdit(this.id).subscribe(result => { + this.entity = result.book; + }); + } + + /** + * 保存方法,提交form表单 + */ + submitForm(): void { + const input = new CreateOrUpdateBookInput(); + input.book = this.entity; + + this.saving = true; + + this._bookService.createOrUpdate(input) + .finally(() => (this.saving = false)) + .subscribe(() => { + this.notify.success(this.l('SavedSuccessfully')); + this.success(true); + }); + } +} diff --git a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts index 9bfa021..6083ff2 100644 --- a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts +++ b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list-routing.module.ts @@ -1,11 +1,17 @@ import { BookListsComponent } from './book-lists/book-lists.component'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import { BookComponent } from './books/book.component'; const routes: Routes = [ { path: '', children: [ + { + path: 'book', + component: BookComponent, + data: { permission: 'Pages.Book' }, + }, { path: 'booklists', component: BookListsComponent, diff --git a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts index 925ca8f..756d3b2 100644 --- a/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts +++ b/src/booklist-angular/src/app/cloud-book-list/cloud-book-list.module.ts @@ -7,6 +7,8 @@ import { CloudBookListRoutingModule } from './cloud-book-list-routing.module'; import { BookListsComponent } from './book-lists/book-lists.component'; import { SharedModule } from '@shared/shared.module'; import { TitleService } from 'yoyo-ng-module/src/theme'; +import { BookComponent } from './books/book.component'; +import { CreateOrEditBookComponent } from './books/create-or-edit-book/create-or-edit-book.component'; @NgModule({ imports: [ @@ -16,8 +18,12 @@ import { TitleService } from 'yoyo-ng-module/src/theme'; AbpModule, CloudBookListRoutingModule, ], - declarations: [BookListsComponent], - entryComponents: [BookListsComponent], + declarations: [BookListsComponent, BookComponent, CreateOrEditBookComponent], + entryComponents: [ + BookListsComponent, + BookComponent, + CreateOrEditBookComponent, + ], providers: [LocalizationService, TitleService], }) export class CloudBookListModule {} diff --git a/src/booklist-angular/src/shared/service-proxies/service-proxies.ts b/src/booklist-angular/src/shared/service-proxies/service-proxies.ts index 678feb0..84ede1f 100644 --- a/src/booklist-angular/src/shared/service-proxies/service-proxies.ts +++ b/src/booklist-angular/src/shared/service-proxies/service-proxies.ts @@ -154,20 +154,20 @@ export class BookServiceProxy { /** * @param filterText (optional) * @param sorting (optional) - * @param skipCount (optional) * @param maxResultCount (optional) + * @param skipCount (optional) * @return Success */ - getPageBookAsync(filterText: string | null | undefined, sorting: string | null | undefined, skipCount: number | null | undefined, maxResultCount: number | null | undefined): Observable { - let url_ = this.baseUrl + "/api/services/app/Book/GetPageBookAsync?"; + getPaged(filterText: string | null | undefined, sorting: string | null | undefined, maxResultCount: number | null | undefined, skipCount: number | null | undefined): Observable { + let url_ = this.baseUrl + "/api/services/app/Book/GetPaged?"; if (filterText !== undefined) url_ += "FilterText=" + encodeURIComponent("" + filterText) + "&"; if (sorting !== undefined) url_ += "Sorting=" + encodeURIComponent("" + sorting) + "&"; - if (skipCount !== undefined) - url_ += "SkipCount=" + encodeURIComponent("" + skipCount) + "&"; if (maxResultCount !== undefined) url_ += "MaxResultCount=" + encodeURIComponent("" + maxResultCount) + "&"; + if (skipCount !== undefined) + url_ += "SkipCount=" + encodeURIComponent("" + skipCount) + "&"; url_ = url_.replace(/[?&]$/, ""); let options_ : any = { @@ -180,11 +180,11 @@ export class BookServiceProxy { }; return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => { - return this.processGetPageBookAsync(response_); + return this.processGetPaged(response_); })).pipe(_observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetPageBookAsync(response_); + return this.processGetPaged(response_); } catch (e) { return >_observableThrow(e); } @@ -193,7 +193,7 @@ export class BookServiceProxy { })); } - protected processGetPageBookAsync(response: HttpResponseBase): Observable { + protected processGetPaged(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -207,6 +207,14 @@ export class BookServiceProxy { result200 = resultData200 ? PagedResultDtoOfBookListDto.fromJS(resultData200) : new PagedResultDtoOfBookListDto(); return _observableOf(result200); })); + } else if (status === 401) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status === 403) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); } else if (status !== 200 && status !== 204) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); @@ -216,39 +224,39 @@ export class BookServiceProxy { } /** - * @param input (optional) + * @param id (optional) * @return Success */ - createOrUpdateBook(input: CreateOrUpdateBookInput | null | undefined): Observable { - let url_ = this.baseUrl + "/api/services/app/Book/CreateOrUpdateBook"; + getById(id: number | null | undefined): Observable { + let url_ = this.baseUrl + "/api/services/app/Book/GetById?"; + if (id !== undefined) + url_ += "Id=" + encodeURIComponent("" + id) + "&"; url_ = url_.replace(/[?&]$/, ""); - const content_ = JSON.stringify(input); - let options_ : any = { - body: content_, observe: "response", responseType: "blob", headers: new HttpHeaders({ "Content-Type": "application/json", + "Accept": "application/json" }) }; - return this.http.request("post", url_, options_).pipe(_observableMergeMap((response_ : any) => { - return this.processCreateOrUpdateBook(response_); + return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => { + return this.processGetById(response_); })).pipe(_observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processCreateOrUpdateBook(response_); + return this.processGetById(response_); } catch (e) { - return >_observableThrow(e); + return >_observableThrow(e); } } else - return >_observableThrow(response_); + return >_observableThrow(response_); })); } - protected processCreateOrUpdateBook(response: HttpResponseBase): Observable { + protected processGetById(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -257,22 +265,33 @@ export class BookServiceProxy { let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }}; if (status === 200) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { - return _observableOf(null); + let result200: any = null; + let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); + result200 = resultData200 ? BookListDto.fromJS(resultData200) : new BookListDto(); + return _observableOf(result200); + })); + } else if (status === 401) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status === 403) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); })); } else if (status !== 200 && status !== 204) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); })); } - return _observableOf(null); + return _observableOf(null); } /** * @param id (optional) * @return Success */ - deleteBook(id: number | null | undefined): Observable { - let url_ = this.baseUrl + "/api/services/app/Book/DeleteBook?"; + getForEdit(id: number | null | undefined): Observable { + let url_ = this.baseUrl + "/api/services/app/Book/GetForEdit?"; if (id !== undefined) url_ += "Id=" + encodeURIComponent("" + id) + "&"; url_ = url_.replace(/[?&]$/, ""); @@ -282,24 +301,25 @@ export class BookServiceProxy { responseType: "blob", headers: new HttpHeaders({ "Content-Type": "application/json", + "Accept": "application/json" }) }; - return this.http.request("delete", url_, options_).pipe(_observableMergeMap((response_ : any) => { - return this.processDeleteBook(response_); + return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => { + return this.processGetForEdit(response_); })).pipe(_observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processDeleteBook(response_); + return this.processGetForEdit(response_); } catch (e) { - return >_observableThrow(e); + return >_observableThrow(e); } } else - return >_observableThrow(response_); + return >_observableThrow(response_); })); } - protected processDeleteBook(response: HttpResponseBase): Observable { + protected processGetForEdit(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -308,22 +328,33 @@ export class BookServiceProxy { let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }}; if (status === 200) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { - return _observableOf(null); + let result200: any = null; + let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); + result200 = resultData200 ? GetBookForEditOutput.fromJS(resultData200) : new GetBookForEditOutput(); + return _observableOf(result200); + })); + } else if (status === 401) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status === 403) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); })); } else if (status !== 200 && status !== 204) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); })); } - return _observableOf(null); + return _observableOf(null); } /** * @param input (optional) * @return Success */ - batchDeleteBook(input: number[] | null | undefined): Observable { - let url_ = this.baseUrl + "/api/services/app/Book/BatchDeleteBook"; + createOrUpdate(input: CreateOrUpdateBookInput | null | undefined): Observable { + let url_ = this.baseUrl + "/api/services/app/Book/CreateOrUpdate"; url_ = url_.replace(/[?&]$/, ""); const content_ = JSON.stringify(input); @@ -338,11 +369,11 @@ export class BookServiceProxy { }; return this.http.request("post", url_, options_).pipe(_observableMergeMap((response_ : any) => { - return this.processBatchDeleteBook(response_); + return this.processCreateOrUpdate(response_); })).pipe(_observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processBatchDeleteBook(response_); + return this.processCreateOrUpdate(response_); } catch (e) { return >_observableThrow(e); } @@ -351,7 +382,7 @@ export class BookServiceProxy { })); } - protected processBatchDeleteBook(response: HttpResponseBase): Observable { + protected processCreateOrUpdate(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -362,6 +393,14 @@ export class BookServiceProxy { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { return _observableOf(null); })); + } else if (status === 401) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status === 403) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); } else if (status !== 200 && status !== 204) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); @@ -374,8 +413,8 @@ export class BookServiceProxy { * @param id (optional) * @return Success */ - getForEditBook(id: number | null | undefined): Observable { - let url_ = this.baseUrl + "/api/services/app/Book/GetForEditBook?"; + delete(id: number | null | undefined): Observable { + let url_ = this.baseUrl + "/api/services/app/Book/Delete?"; if (id !== undefined) url_ += "Id=" + encodeURIComponent("" + id) + "&"; url_ = url_.replace(/[?&]$/, ""); @@ -385,25 +424,24 @@ export class BookServiceProxy { responseType: "blob", headers: new HttpHeaders({ "Content-Type": "application/json", - "Accept": "application/json" }) }; - return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => { - return this.processGetForEditBook(response_); + return this.http.request("delete", url_, options_).pipe(_observableMergeMap((response_ : any) => { + return this.processDelete(response_); })).pipe(_observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetForEditBook(response_); + return this.processDelete(response_); } catch (e) { - return >_observableThrow(e); + return >_observableThrow(e); } } else - return >_observableThrow(response_); + return >_observableThrow(response_); })); } - protected processGetForEditBook(response: HttpResponseBase): Observable { + protected processDelete(response: HttpResponseBase): Observable { const status = response.status; const responseBlob = response instanceof HttpResponse ? response.body : @@ -412,17 +450,82 @@ export class BookServiceProxy { let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }}; if (status === 200) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { - let result200: any = null; - let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 ? GetBookForEditOutput.fromJS(resultData200) : new GetBookForEditOutput(); - return _observableOf(result200); + return _observableOf(null); + })); + } else if (status === 401) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status === 403) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); })); } else if (status !== 200 && status !== 204) { return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { return throwException("An unexpected server error occurred.", status, _responseText, _headers); })); } - return _observableOf(null); + return _observableOf(null); + } + + /** + * @param input (optional) + * @return Success + */ + batchDelete(input: number[] | null | undefined): Observable { + let url_ = this.baseUrl + "/api/services/app/Book/BatchDelete"; + url_ = url_.replace(/[?&]$/, ""); + + const content_ = JSON.stringify(input); + + let options_ : any = { + body: content_, + observe: "response", + responseType: "blob", + headers: new HttpHeaders({ + "Content-Type": "application/json", + }) + }; + + return this.http.request("post", url_, options_).pipe(_observableMergeMap((response_ : any) => { + return this.processBatchDelete(response_); + })).pipe(_observableCatch((response_: any) => { + if (response_ instanceof HttpResponseBase) { + try { + return this.processBatchDelete(response_); + } catch (e) { + return >_observableThrow(e); + } + } else + return >_observableThrow(response_); + })); + } + + protected processBatchDelete(response: HttpResponseBase): Observable { + const status = response.status; + const responseBlob = + response instanceof HttpResponse ? response.body : + (response).error instanceof Blob ? (response).error : undefined; + + let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }}; + if (status === 200) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return _observableOf(null); + })); + } else if (status === 401) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status === 403) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("A server error occurred.", status, _responseText, _headers); + })); + } else if (status !== 200 && status !== 204) { + return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => { + return throwException("An unexpected server error occurred.", status, _responseText, _headers); + })); + } + return _observableOf(null); } } @@ -2154,10 +2257,13 @@ export interface IPagedResultDtoOfBookListDto { } export class BookListDto implements IBookListDto { - name: string | undefined; - author: string | undefined; - intro: string | undefined; + name: string; + author: string; + intro: string; + priceUrl: string | undefined; imgUrl: string | undefined; + creationTime: moment.Moment | undefined; + creatorUserId: number | undefined; id: number | undefined; constructor(data?: IBookListDto) { @@ -2174,7 +2280,10 @@ export class BookListDto implements IBookListDto { this.name = data["name"]; this.author = data["author"]; this.intro = data["intro"]; + this.priceUrl = data["priceUrl"]; this.imgUrl = data["imgUrl"]; + this.creationTime = data["creationTime"] ? moment(data["creationTime"].toString()) : undefined; + this.creatorUserId = data["creatorUserId"]; this.id = data["id"]; } } @@ -2191,7 +2300,10 @@ export class BookListDto implements IBookListDto { data["name"] = this.name; data["author"] = this.author; data["intro"] = this.intro; + data["priceUrl"] = this.priceUrl; data["imgUrl"] = this.imgUrl; + data["creationTime"] = this.creationTime ? this.creationTime.toISOString() : undefined; + data["creatorUserId"] = this.creatorUserId; data["id"] = this.id; return data; } @@ -2205,64 +2317,64 @@ export class BookListDto implements IBookListDto { } export interface IBookListDto { - name: string | undefined; - author: string | undefined; - intro: string | undefined; + name: string; + author: string; + intro: string; + priceUrl: string | undefined; imgUrl: string | undefined; + creationTime: moment.Moment | undefined; + creatorUserId: number | undefined; id: number | undefined; } -export class CreateOrUpdateBookInput implements ICreateOrUpdateBookInput { - bookEditDto: BookEditDto; +export class GetBookForEditOutput implements IGetBookForEditOutput { + book: BookEditDto | undefined; - constructor(data?: ICreateOrUpdateBookInput) { + constructor(data?: IGetBookForEditOutput) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) (this)[property] = (data)[property]; } } - if (!data) { - this.bookEditDto = new BookEditDto(); - } } init(data?: any) { if (data) { - this.bookEditDto = data["bookEditDto"] ? BookEditDto.fromJS(data["bookEditDto"]) : new BookEditDto(); + this.book = data["book"] ? BookEditDto.fromJS(data["book"]) : undefined; } } - static fromJS(data: any): CreateOrUpdateBookInput { + static fromJS(data: any): GetBookForEditOutput { data = typeof data === 'object' ? data : {}; - let result = new CreateOrUpdateBookInput(); + let result = new GetBookForEditOutput(); result.init(data); return result; } toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - data["bookEditDto"] = this.bookEditDto ? this.bookEditDto.toJSON() : undefined; + data["book"] = this.book ? this.book.toJSON() : undefined; return data; } - clone(): CreateOrUpdateBookInput { + clone(): GetBookForEditOutput { const json = this.toJSON(); - let result = new CreateOrUpdateBookInput(); + let result = new GetBookForEditOutput(); result.init(json); return result; } } -export interface ICreateOrUpdateBookInput { - bookEditDto: BookEditDto; +export interface IGetBookForEditOutput { + book: BookEditDto | undefined; } export class BookEditDto implements IBookEditDto { id: number | undefined; - name: string | undefined; - author: string | undefined; - intro: string | undefined; + name: string; + author: string; + intro: string; priceUrl: string | undefined; imgUrl: string | undefined; @@ -2314,34 +2426,37 @@ export class BookEditDto implements IBookEditDto { export interface IBookEditDto { id: number | undefined; - name: string | undefined; - author: string | undefined; - intro: string | undefined; + name: string; + author: string; + intro: string; priceUrl: string | undefined; imgUrl: string | undefined; } -export class GetBookForEditOutput implements IGetBookForEditOutput { - book: BookEditDto | undefined; +export class CreateOrUpdateBookInput implements ICreateOrUpdateBookInput { + book: BookEditDto; - constructor(data?: IGetBookForEditOutput) { + constructor(data?: ICreateOrUpdateBookInput) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) (this)[property] = (data)[property]; } } + if (!data) { + this.book = new BookEditDto(); + } } init(data?: any) { if (data) { - this.book = data["book"] ? BookEditDto.fromJS(data["book"]) : undefined; + this.book = data["book"] ? BookEditDto.fromJS(data["book"]) : new BookEditDto(); } } - static fromJS(data: any): GetBookForEditOutput { + static fromJS(data: any): CreateOrUpdateBookInput { data = typeof data === 'object' ? data : {}; - let result = new GetBookForEditOutput(); + let result = new CreateOrUpdateBookInput(); result.init(data); return result; } @@ -2352,16 +2467,16 @@ export class GetBookForEditOutput implements IGetBookForEditOutput { return data; } - clone(): GetBookForEditOutput { + clone(): CreateOrUpdateBookInput { const json = this.toJSON(); - let result = new GetBookForEditOutput(); + let result = new CreateOrUpdateBookInput(); result.init(json); return result; } } -export interface IGetBookForEditOutput { - book: BookEditDto | undefined; +export interface ICreateOrUpdateBookInput { + book: BookEditDto; } export class ChangeUiThemeInput implements IChangeUiThemeInput { diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml b/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml index 2aa600b..6f77ac1 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml +++ b/src/booklist-aspnet-core/src/Lpb.BookList.Core/Localization/SourceFiles/BookList-zh-Hans.xml @@ -7,7 +7,7 @@ - + diff --git a/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs b/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs index 0b9f5ca..5d733f2 100644 --- a/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs +++ b/src/booklist-aspnet-core/src/Lpb.BookList.EntityFrameworkCore/EntityFrameworkCore/BookListDbContext.cs @@ -1,13 +1,11 @@ -using Microsoft.EntityFrameworkCore; using Abp.Zero.EntityFrameworkCore; using Lpb.BookList.Authorization.Roles; using Lpb.BookList.Authorization.Users; -using Lpb.BookList.BookListManagement; using Lpb.BookList.BookListManagement.Books; using Lpb.BookList.BookListManagement.BookTags; using Lpb.BookList.BookListManagement.CloudBookLists; -using Lpb.BookList.EntityMapper.Books; using Lpb.BookList.MultiTenancy; +using Microsoft.EntityFrameworkCore; namespace Lpb.BookList.EntityFrameworkCore { @@ -23,10 +21,5 @@ namespace Lpb.BookList.EntityFrameworkCore : base(options) { } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - //modelBuilder.ApplyConfiguration(new BookCfg()); - } } } -- Gitee