Skip to content

Commit 671b97c

Browse files
author
alirizaadiyahsi
authored
Merge pull request #367 from personball/dev
update sample code in vue template and add more localization text
2 parents 1c63b77 + e8507a3 commit 671b97c

File tree

14 files changed

+167
-193
lines changed

14 files changed

+167
-193
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Abp.Application.Services.Dto;
2+
3+
namespace AbpCompanyName.AbpProjectName.MultiTenancy.Dto
4+
{
5+
public class PagedTenantResultRequestDto : PagedResultRequestDto
6+
{
7+
public string TenancyName { get; set; }
8+
public string Name { get; set; }
9+
public bool? IsActive { get; set; }
10+
}
11+
}
12+

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/MultiTenancy/ITenantAppService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace AbpCompanyName.AbpProjectName.MultiTenancy
66
{
7-
public interface ITenantAppService : IAsyncCrudAppService<TenantDto, int, PagedResultRequestDto, CreateTenantDto, TenantDto>
7+
public interface ITenantAppService : IAsyncCrudAppService<TenantDto, int, PagedTenantResultRequestDto, CreateTenantDto, TenantDto>
88
{
99
}
1010
}
11+

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/MultiTenancy/TenantAppService.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Linq;
1+
using System.Linq;
22
using System.Threading.Tasks;
33
using Microsoft.AspNetCore.Identity;
44
using Abp.Application.Services;
@@ -14,11 +14,12 @@
1414
using AbpCompanyName.AbpProjectName.Authorization.Users;
1515
using AbpCompanyName.AbpProjectName.Editions;
1616
using AbpCompanyName.AbpProjectName.MultiTenancy.Dto;
17+
using Abp.Linq.Extensions;
1718

1819
namespace AbpCompanyName.AbpProjectName.MultiTenancy
1920
{
2021
[AbpAuthorize(PermissionNames.Pages_Tenants)]
21-
public class TenantAppService : AsyncCrudAppService<Tenant, TenantDto, int, PagedResultRequestDto, CreateTenantDto, TenantDto>, ITenantAppService
22+
public class TenantAppService : AsyncCrudAppService<Tenant, TenantDto, int, PagedTenantResultRequestDto, CreateTenantDto, TenantDto>, ITenantAppService
2223
{
2324
private readonly TenantManager _tenantManager;
2425
private readonly EditionManager _editionManager;
@@ -28,23 +29,23 @@ public class TenantAppService : AsyncCrudAppService<Tenant, TenantDto, int, Page
2829
private readonly IPasswordHasher<User> _passwordHasher;
2930

3031
public TenantAppService(
31-
IRepository<Tenant, int> repository,
32-
TenantManager tenantManager,
32+
IRepository<Tenant, int> repository,
33+
TenantManager tenantManager,
3334
EditionManager editionManager,
34-
UserManager userManager,
35-
RoleManager roleManager,
36-
IAbpZeroDbMigrator abpZeroDbMigrator,
37-
IPasswordHasher<User> passwordHasher)
35+
UserManager userManager,
36+
RoleManager roleManager,
37+
IAbpZeroDbMigrator abpZeroDbMigrator,
38+
IPasswordHasher<User> passwordHasher)
3839
: base(repository)
3940
{
40-
_tenantManager = tenantManager;
41+
_tenantManager = tenantManager;
4142
_editionManager = editionManager;
4243
_userManager = userManager;
4344
_roleManager = roleManager;
4445
_abpZeroDbMigrator = abpZeroDbMigrator;
4546
_passwordHasher = passwordHasher;
4647
}
47-
48+
4849
public override async Task<TenantDto> Create(CreateTenantDto input)
4950
{
5051
CheckCreatePermission();
@@ -93,6 +94,14 @@ public override async Task<TenantDto> Create(CreateTenantDto input)
9394
return MapToEntityDto(tenant);
9495
}
9596

97+
protected override IQueryable<Tenant> CreateFilteredQuery(PagedTenantResultRequestDto input)
98+
{
99+
return Repository.GetAll()
100+
.WhereIf(!input.TenancyName.IsNullOrWhiteSpace(), x => x.TenancyName.Contains(input.TenancyName))
101+
.WhereIf(!input.Name.IsNullOrWhiteSpace(), x => x.Name.Contains(input.Name))
102+
.WhereIf(input.IsActive.HasValue, x => x.IsActive == input.IsActive);
103+
}
104+
96105
protected override void MapToEntity(TenantDto updateInput, Tenant entity)
97106
{
98107
// Manually mapped since TenantDto contains non-editable properties too.
@@ -115,3 +124,4 @@ private void CheckErrors(IdentityResult identityResult)
115124
}
116125
}
117126
}
127+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Abp.Application.Services.Dto;
5+
6+
namespace AbpCompanyName.AbpProjectName.Roles.Dto
7+
{
8+
public class PagedRoleResultRequestDto : PagedResultRequestDto
9+
{
10+
public string RoleName { get; set; }
11+
public string DisplayName { get; set; }
12+
public string Description { get; set; }
13+
}
14+
}
15+

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Roles/IRoleAppService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
namespace AbpCompanyName.AbpProjectName.Roles
77
{
8-
public interface IRoleAppService : IAsyncCrudAppService<RoleDto, int, PagedResultRequestDto, CreateRoleDto, RoleDto>
8+
public interface IRoleAppService : IAsyncCrudAppService<RoleDto, int, PagedRoleResultRequestDto, CreateRoleDto, RoleDto>
99
{
1010
Task<ListResultDto<PermissionDto>> GetAllPermissions();
1111

1212
Task<GetRoleForEditOutput> GetRoleForEdit(EntityDto input);
1313

1414
Task<ListResultDto<RoleListDto>> GetRolesAsync(GetRolesInput input);
1515
}
16-
}
16+
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Roles/RoleAppService.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace AbpCompanyName.AbpProjectName.Roles
1919
{
2020
[AbpAuthorize(PermissionNames.Pages_Roles)]
21-
public class RoleAppService : AsyncCrudAppService<Role, RoleDto, int, PagedResultRequestDto, CreateRoleDto, RoleDto>, IRoleAppService
21+
public class RoleAppService : AsyncCrudAppService<Role, RoleDto, int, PagedRoleResultRequestDto, CreateRoleDto, RoleDto>, IRoleAppService
2222
{
2323
private readonly RoleManager _roleManager;
2424
private readonly UserManager _userManager;
@@ -106,17 +106,20 @@ public Task<ListResultDto<PermissionDto>> GetAllPermissions()
106106
));
107107
}
108108

109-
protected override IQueryable<Role> CreateFilteredQuery(PagedResultRequestDto input)
109+
protected override IQueryable<Role> CreateFilteredQuery(PagedRoleResultRequestDto input)
110110
{
111-
return Repository.GetAllIncluding(x => x.Permissions);
111+
return Repository.GetAllIncluding(x => x.Permissions)
112+
.WhereIf(!input.RoleName.IsNullOrWhiteSpace(), x => x.Name.Contains(input.RoleName))
113+
.WhereIf(!input.DisplayName.IsNullOrWhiteSpace(), x => x.DisplayName.Contains(input.DisplayName))
114+
.WhereIf(!input.Description.IsNullOrWhiteSpace(), x => x.Description.Contains(input.Description));
112115
}
113116

114117
protected override async Task<Role> GetEntityByIdAsync(int id)
115118
{
116119
return await Repository.GetAllIncluding(x => x.Permissions).FirstOrDefaultAsync(x => x.Id == id);
117120
}
118121

119-
protected override IQueryable<Role> ApplySorting(IQueryable<Role> query, PagedResultRequestDto input)
122+
protected override IQueryable<Role> ApplySorting(IQueryable<Role> query, PagedRoleResultRequestDto input)
120123
{
121124
return query.OrderBy(r => r.DisplayName);
122125
}
@@ -142,3 +145,4 @@ public async Task<GetRoleForEditOutput> GetRoleForEdit(EntityDto input)
142145
}
143146
}
144147
}
148+

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/UserAppService.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Linq;
33
using System.Threading.Tasks;
4-
using Microsoft.AspNetCore.Identity;
5-
using Microsoft.EntityFrameworkCore;
64
using Abp.Application.Services;
75
using Abp.Application.Services.Dto;
86
using Abp.Authorization;
97
using Abp.Domain.Entities;
108
using Abp.Domain.Repositories;
9+
using Abp.Extensions;
1110
using Abp.IdentityFramework;
11+
using Abp.Linq.Extensions;
1212
using Abp.Localization;
1313
using Abp.Runtime.Session;
1414
using AbpCompanyName.AbpProjectName.Authorization;
1515
using AbpCompanyName.AbpProjectName.Authorization.Roles;
1616
using AbpCompanyName.AbpProjectName.Authorization.Users;
1717
using AbpCompanyName.AbpProjectName.Roles.Dto;
1818
using AbpCompanyName.AbpProjectName.Users.Dto;
19-
using Abp.Linq.Extensions;
20-
using Abp.Extensions;
19+
using Microsoft.AspNetCore.Identity;
20+
using Microsoft.EntityFrameworkCore;
2121

2222
namespace AbpCompanyName.AbpProjectName.Users
2323
{
@@ -128,11 +128,10 @@ protected override UserDto MapToEntityDto(User user)
128128

129129
protected override IQueryable<User> CreateFilteredQuery(PagedUserResultRequestDto input)
130130
{
131-
return
132-
Repository.GetAllIncluding(x => x.Roles)
131+
return Repository.GetAllIncluding(x => x.Roles)
133132
.WhereIf(!input.UserName.IsNullOrWhiteSpace(), x => x.UserName.Contains(input.UserName))
134133
.WhereIf(!input.Name.IsNullOrWhiteSpace(), x => x.Name.Contains(input.Name))
135-
.WhereIf(input.IsActive.HasValue, x => x.IsActive)
134+
.WhereIf(input.IsActive.HasValue, x => x.IsActive == input.IsActive)
136135
.WhereIf(input.From.HasValue, x => x.CreationTime >= input.From.Value.LocalDateTime)
137136
.WhereIf(input.To.HasValue, x => x.CreationTime <= input.To.Value.LocalDateTime);
138137
}
@@ -160,3 +159,4 @@ protected virtual void CheckErrors(IdentityResult identityResult)
160159
}
161160
}
162161
}
162+

aspnet-core/src/AbpCompanyName.AbpProjectName.Core/Localization/SourceFiles/AbpProjectName-zh-Hans.xml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,29 @@
44
<text name="HomePage" value="主页" />
55
<text name="About" value="关于我们" />
66
<text name="WelcomeMessage" value="欢迎使用 AbpProjectName!" />
7-
87
<text name="FormIsNotValidMessage" value="部分输入信息不符合要求,请检查并改正.." />
98
<text name="TenantNameCanNotBeEmpty" value="租户名不能为空" />
10-
119
<text name="InvalidUserNameOrPassword" value="用户名或密码无效" />
1210
<text name="ThereIsNoTenantDefinedWithName{0}" value="租户 {0}不存在" />
1311
<text name="TenantIsNotActive" value="租户 {0} 未激活." />
1412
<text name="UserIsNotActiveAndCanNotLogin" value="用户 {0} 未激活,不能登录." />
1513
<text name="PleaseEnterLoginInformation" value="请输入登录信息" />
16-
<text name="TenancyName" value="租户名称" />
14+
<text name="TenancyName" value="租户标识" />
1715
<text name="UserNameOrEmail" value="用户名或邮箱地址" />
1816
<text name="Password" value="密码" />
1917
<text name="RememberMe" value="记住我" />
2018
<text name="LogIn" value="登录" />
21-
2219
<text name="LoginFailed" value="登录失败!" />
23-
2420
<text name="AppName" >AbpProjectName</text>
2521
<text name="UserNamePlaceholder" >请输入账户</text>
2622
<text name="PasswordPlaceholder" >请输入密码</text>
2723
<text name="CopyRight" >© 2018 AbpProjectName</text>
2824
<text name="LoginPrompt" >正在登陆,请稍候!</text>
29-
3025
<text name="UserProfile" >用户资料</text>
3126
<text name="Users" >用户</text>
3227
<text name="Roles" >角色</text>
3328
<text name="Tenants" >租户</text>
3429
<text name="Logout" >注销</text>
35-
3630
<text name="ManageMenu" >菜单</text>
3731
<text name="LabelOptions" >页签操作</text>
3832
<text name="ClearAll" >关闭所有</text>
@@ -52,17 +46,14 @@
5246
<text name="DeleteConfirm">确定删除?</text>
5347
<text name="Title" >标题</text>
5448
<text name="Content" >内容</text>
55-
5649
<text name="ChangePassword" >修改密码</text>
57-
5850
<text name="PasswordComplexityNotSatisfied">密码复杂度要求不符.</text>
5951
<text name="PasswordRequireDigit">密码至少需要一位是0到9的数字.</text>
6052
<text name="PasswordRequireLowercase">密码至少需要一位是a到z的小写字母.</text>
6153
<text name="PasswordRequireNonAlphanumeric">密码至少需要包含一个特殊字符(非字母或数字的字符).</text>
6254
<text name="PasswordRequireUppercase">密码至少需要一位是A到Z的大写字母.</text>
6355
<text name="PasswordTooShort">密码长度太短</text>
64-
65-
<text name="UserName">用户名</text>
56+
<text name="UserName">用户名</text>
6657
<text name="Name">名称</text>
6758
<text name="IsActive">是否启用</text>
6859
<text name="LastLoginTime">最近登陆时间</text>
@@ -77,5 +68,33 @@
7768

7869
<text name="Yes">是</text>
7970
<text name="No">否</text>
71+
72+
<text name="Cancel">取消</text>
73+
<text name="OK">确定</text>
74+
<text name="CreateNewRole">创建新角色</text>
75+
<text name="RoleDetails">角色详情</text>
76+
<text name="RolePermission">角色权限</text>
77+
<text name="EditRole">编辑角色</text>
78+
<text name="DeleteRolesConfirm">确认删除该角色?</text>
79+
80+
<text name="CreateNewUser">创建新用户</text>
81+
<text name="UserDetails">用户详情</text>
82+
<text name="UserRoles">用户角色</text>
83+
<text name="ConfirmPassword">确认密码</text>
84+
<text name="EmailAddress">邮箱地址</text>
85+
<text name="Surname">姓</text>
86+
<text name="DeleteUserConfirm">确认删除该用户?</text>
87+
<text name="EditUser">编辑用户</text>
88+
89+
<text name="CreateNewTenant">创建新租户</text>
90+
<text name="DatabaseConnectionString">数据库连接</text>
91+
<text name="AdminEmailAddress">管理员邮箱地址</text>
92+
<text name="DefaultPasswordIs">默认密码为:{0}</text>
93+
<text name="DeleteTenantConfirm">确认删除该租户?</text>
94+
<text name="EditTenant">编辑租户</text>
95+
96+
8097
</texts>
8198
</localizationDictionary>
99+
100+

vue/src/lib/util.ts

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -9,94 +9,6 @@ class Util{
99
script.src=url;
1010
document.body.appendChild(script);
1111
}
12-
buildFilters(filters:Filter[]){
13-
console.warn('SQL Injection warning.');
14-
let fileswhere:string[]=[];
15-
filters.forEach(f=>{
16-
let where='';
17-
if(f.Type===FieldType.Number){
18-
where=this.buildNumber(f);
19-
}else if(f.Type===FieldType.String){
20-
where=this.buildString(f);
21-
}else if(f.Type===FieldType.Boolean){
22-
where=this.buildBoolean(f);
23-
}else if(f.Type===FieldType.DataRange||f.Type===FieldType.Date){
24-
where=this.buildDate(f);
25-
}else if(f.Type===FieldType.Enum){
26-
where=this.buildEnum(f);
27-
}
28-
if(where){
29-
fileswhere.push(where);
30-
}
31-
32-
})
33-
return fileswhere.join(' AND ');
34-
}
35-
private buildDate(filter:Filter){
36-
if(filter.Type===FieldType.Date){
37-
if(!!filter.Value){
38-
let compare=this.caseCompare(filter.CompareType);
39-
let date=new Date(filter.Value);
40-
return `${filter.FieldName}${compare} DateTime(${date.getFullYear()},${date.getMonth()+1},${date.getDate()})`;
41-
}else{
42-
return ''
43-
}
44-
}else if(filter.Type===FieldType.DataRange){
45-
if(!!filter.Value){
46-
let dates=filter.Value as Array<Date>;
47-
if(dates.length!==2){
48-
throw 'Dates format is error';
49-
}else if(dates[0]&&dates[1]){
50-
return `(${filter.FieldName}>= DateTime(${dates[0].getFullYear()},${dates[0].getMonth()+1},${dates[0].getDate()}) AND ${filter.FieldName}<= DateTime(${dates[1].getFullYear()},${dates[1].getMonth()+1},${dates[1].getDate()}))`;
51-
}else{
52-
return ''
53-
}
54-
}else{
55-
return ''
56-
}
57-
}else{
58-
return ''
59-
}
60-
}
61-
private buildEnum(filter:Filter){
62-
let compare=this.caseCompare(filter.CompareType);
63-
return `${filter.FieldName}${compare}"${filter.Value}"`;
64-
}
65-
private buildBoolean(filter:Filter){
66-
if(filter.Value==null){
67-
return ''
68-
}else if(filter.Value){
69-
return `${filter.FieldName}=true`
70-
}else if(!filter.Value){
71-
return `${filter.FieldName}=false`
72-
}else{
73-
return ''
74-
}
75-
}
76-
private buildString(filter:Filter){
77-
if(!filter.Value){
78-
return ''
79-
}
80-
let compare=this.caseCompare(filter.CompareType);
81-
return `${filter.FieldName}${compare}("${filter.Value}")`
82-
}
83-
private buildNumber(filter:Filter){
84-
let compare=this.caseCompare(filter.CompareType);
85-
return `${filter.FieldName}${compare}${filter.Value}`
86-
}
87-
private caseCompare(compareType:CompareType){
88-
switch(compareType){
89-
case CompareType.Greater:return '>';
90-
case CompareType.Less:return '<';
91-
case CompareType.Equal:return '=';
92-
case CompareType.GreaterOrEqual:return '>=';
93-
case CompareType.LessOrEqual:return '<=';
94-
case CompareType.Contains:return '.Contains';
95-
case CompareType.StartWith:return '.StartWith';
96-
case CompareType.EndWith:return '.EndWith';
97-
case CompareType.NotEqual:return '!=';
98-
}
99-
}
10012
title(title:string){
10113
let appname=this.abp.localization.localize('AppName',appconst.localization.defaultLocalizationSourceName);
10214
let page=this.abp.localization.localize(title,appconst.localization.defaultLocalizationSourceName);

0 commit comments

Comments
 (0)