Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
b47369b6
Commit
b47369b6
authored
Jun 04, 2021
by
lcx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/人员字典分页' into develop
parents
aaba54e6
f6539eae
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
234 additions
and
41 deletions
+234
-41
performance/Performance.Api/Controllers/PersonController.cs
+39
-4
performance/Performance.Api/Filters/RequestRateLimitingMiddleware.cs
+9
-10
performance/Performance.Api/Startup.cs
+4
-4
performance/Performance.Api/wwwroot/Performance.Api.xml
+8
-1
performance/Performance.Api/wwwroot/Performance.DtoModels.xml
+1
-1
performance/Performance.DtoModels/Request/PersonParamsRequest.cs
+25
-0
performance/Performance.Infrastructure/Models/PageList.cs
+2
-2
performance/Performance.Repository/PerforPeremployeeRepository.cs
+26
-0
performance/Performance.Services/PersonService.cs
+120
-19
No files found.
performance/Performance.Api/Controllers/PersonController.cs
View file @
b47369b6
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
FluentValidation.AspNetCore
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.StaticFiles
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Services
;
namespace
Performance.Api.Controllers
...
...
@@ -27,13 +30,21 @@ public PersonController(PersonService personService, ClaimService claimService)
/// 获取所有员工记录
/// </summary>
/// <param name="allotId"></param>
/// <param name="request"></param>
/// <returns></returns>
[
Route
(
"person/list/{allotId}"
)]
[
HttpPost
]
public
ApiResponse
GetPersons
(
int
allotId
)
public
ApiResponse
GetPersons
(
[
FromRoute
]
int
allotId
,
[
FromBody
]
PersonParamsRequest
request
)
{
var
list
=
personService
.
GetPersons
(
allotId
,
claimService
.
GetUserId
());
return
new
ApiResponse
(
ResponseType
.
OK
,
list
);
var
list
=
personService
.
GetPersons
(
allotId
,
claimService
.
GetUserId
(),
request
);
return
new
ApiResponse
(
ResponseType
.
OK
,
new
{
list
.
CurrentPage
,
list
.
TotalPages
,
list
.
PageSize
,
list
.
TotalCount
,
list
});
}
/// <summary>
...
...
@@ -80,6 +91,30 @@ public ApiResponse DeletePerson(int employeeId)
}
/// <summary>
/// 下载当前测算表
/// </summary>
/// <returns></returns>
[
Route
(
"person/list/download/{allotId}"
)]
[
HttpPost
]
public
IActionResult
DownloadCurrentCalculationTable
([
FromRoute
]
int
allotId
)
{
var
filepath
=
personService
.
GetPersonDictFile
(
allotId
,
claimService
.
GetUserId
());
if
(!
FileHelper
.
IsExistFile
(
filepath
))
throw
new
PerformanceException
(
"获取人员字典失败"
);
var
memoryStream
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
filepath
,
FileMode
.
Open
))
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
var
provider
=
new
FileExtensionContentTypeProvider
();
FileInfo
fileInfo
=
new
FileInfo
(
filepath
);
var
memi
=
provider
.
Mappings
[
".xlsx"
];
return
File
(
memoryStream
,
memi
,
Path
.
GetFileName
(
fileInfo
.
Name
));
}
/// <summary>
/// 获取所有科室记录
/// </summary>
/// <param name="hospitalId"></param>
...
...
@@ -206,7 +241,7 @@ public ApiResponse BathSavePerson(int allotId, int hospitalId, SaveCollectData r
if
(
result
)
return
new
ApiResponse
(
ResponseType
.
OK
);
else
return
new
ApiResponse
(
ResponseType
.
Error
,
"出勤天数或预留比例格式错误"
);
return
new
ApiResponse
(
ResponseType
.
Error
,
"出勤天数或预留比例格式错误"
);
}
/// <summary>
...
...
performance/Performance.Api/Filters/RequestRateLimitingMiddleware.cs
View file @
b47369b6
...
...
@@ -16,7 +16,7 @@ namespace Performance.Api
{
public
class
RequestRateLimitingMiddleware
{
private
readonly
int
Limit
;
private
readonly
int
Limit
=
1
;
private
readonly
ILogger
logger
;
private
readonly
RequestDelegate
next
;
private
readonly
IMemoryCache
requestStore
;
...
...
@@ -34,15 +34,14 @@ public class RequestRateLimitingMiddleware
this
.
next
=
next
;
this
.
requestStore
=
requestStore
;
this
.
httpContextAccessor
=
httpContextAccessor
;
if
(
options
==
null
)
throw
new
ArgumentNullException
(
nameof
(
options
));
this
.
options
=
options
.
Value
;
Limit
=
options
.
Value
.
Limit
;
if
(
options
!=
null
)
Limit
=
options
.
Value
.
Limit
;
}
public
async
Task
Invoke
(
HttpContext
context
)
{
if
(
options
.
Endpoints
==
null
||
!
options
.
Endpoints
.
Any
(
t
=>
context
.
Request
.
Path
.
ToString
().
StartsWith
(
t
)))
if
(
options
==
null
||
options
.
Endpoints
==
null
||
!
options
.
Endpoints
.
Any
(
t
=>
context
.
Request
.
Path
.
ToString
().
StartsWith
(
t
)))
await
next
(
context
);
var
ip
=
httpContextAccessor
.
HttpContext
.
Connection
.
RemoteIpAddress
.
ToString
();
...
...
@@ -69,7 +68,7 @@ public class RequestRateLimitingMiddleware
else
{
// X-RateLimit-RetryAfter:超出限制后能够再次正常访问的时间。
context
.
Response
.
Headers
[
"X-RateLimit-RetryAfter"
]
=
cacheOptions
.
AbsoluteExpiration
?.
ToString
();
//
context.Response.Headers["X-RateLimit-RetryAfter"] = cacheOptions.AbsoluteExpiration?.ToString();
context
.
Response
.
StatusCode
=
StatusCodes
.
Status200OK
;
context
.
Response
.
ContentType
=
"application/json; charset=utf-8"
;
var
response
=
new
ApiResponse
...
...
@@ -90,10 +89,10 @@ public class RequestRateLimitingMiddleware
{
hitCount
++;
requestStore
.
Set
(
requestKey
,
hitCount
,
cacheOptions
);
// X-RateLimit-Limit:同一个时间段所允许的请求的最大数目
context
.
Response
.
Headers
[
"X-RateLimit-Limit"
]
=
Limit
.
ToString
();
// X-RateLimit-Remaining:在当前时间段内剩余的请求的数量。
context
.
Response
.
Headers
[
"X-RateLimit-Remaining"
]
=
(
Limit
-
hitCount
).
ToString
();
//
//
X-RateLimit-Limit:同一个时间段所允许的请求的最大数目
//
context.Response.Headers["X-RateLimit-Limit"] = Limit.ToString();
//
//
X-RateLimit-Remaining:在当前时间段内剩余的请求的数量。
//
context.Response.Headers["X-RateLimit-Remaining"] = (Limit - hitCount).ToString();
await
next
(
context
);
}
}
...
...
performance/Performance.Api/Startup.cs
View file @
b47369b6
...
...
@@ -101,15 +101,15 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app
.
UseStatusCodePagesWithReExecute
(
"/error/{0}"
);
}
app
.
UseMiddleware
<
RequestRateLimitingMiddleware
>();
app
.
UseCors
(
"SignalrCore"
);
app
.
UseSignalR
(
routes
=>
routes
.
MapHub
<
AllotLogHub
>(
"/performance/allotLogHub"
));
app
.
UseMvc
();
app
.
UseSwaggerSetup
(
Configuration
);
app
.
UseMiddleware
<
RequestRateLimitingMiddleware
>();
app
.
UseMvc
();
}
private
void
JsonOptions
(
MvcJsonOptions
json
)
...
...
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
b47369b6
...
...
@@ -1101,11 +1101,12 @@
</summary>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.PersonController.GetPersons(System.Int32)"
>
<member
name=
"M:Performance.Api.Controllers.PersonController.GetPersons(System.Int32
,Performance.DtoModels.PersonParamsRequest
)"
>
<summary>
获取所有员工记录
</summary>
<param
name=
"allotId"
></param>
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.PersonController.CreatePerson(Performance.DtoModels.PerEmployeeResponse)"
>
...
...
@@ -1129,6 +1130,12 @@
<param
name=
"employeeId"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.PersonController.DownloadCurrentCalculationTable(System.Int32)"
>
<summary>
下载当前测算表
</summary>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.PersonController.GetDepartments(System.Int32)"
>
<summary>
获取所有科室记录
...
...
performance/Performance.Api/wwwroot/Performance.DtoModels.xml
View file @
b47369b6
...
...
@@ -1851,7 +1851,7 @@
</member>
<member
name=
"P:Performance.DtoModels.AccoungingRequest.Type"
>
<summary>
1 返回accounting列表 2 返回核算单元
3 返回核算单元类型
1 返回accounting列表 2 返回核算单元
类型 3 返回核算单元
</summary>
</member>
<member
name=
"P:Performance.DtoModels.AccoungingRequest.UnitType"
>
...
...
performance/Performance.DtoModels/Request/PersonParamsRequest.cs
0 → 100644
View file @
b47369b6
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
PersonParamsRequest
{
public
const
int
MaxPageSize
=
50
;
public
int
PageNumber
{
get
;
set
;
}
=
1
;
private
int
_pageSize
=
10
;
public
int
PageSize
{
get
{
return
_pageSize
;
}
set
{
_pageSize
=
value
>
MaxPageSize
?
MaxPageSize
:
value
;
}
}
public
string
SearchQuery
{
get
;
set
;
}
}
}
performance/Performance.Infrastructure/Models/PageList.cs
View file @
b47369b6
using
System
;
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Performance.Infrastructure.Models
{
...
...
performance/Performance.Repository/PerforPeremployeeRepository.cs
0 → 100644
View file @
b47369b6
//-----------------------------------------------------------------------
// <copyright file=" per_employee.cs">
// * FileName: per_employee.cs
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
System.Linq
;
using
System.Linq.Expressions
;
using
Performance.EntityModels
;
using
Performance.Infrastructure.Models
;
namespace
Performance.Repository
{
/// <summary>
/// per_employee Repository
/// </summary>
public
partial
class
PerforPeremployeeRepository
:
PerforRepository
<
per_employee
>
{
public
new
PageList
<
per_employee
>
GetEntitiesForPaging
(
int
pageNumber
,
int
pageSize
,
Expression
<
Func
<
per_employee
,
bool
>>
exp
)
{
IQueryable
<
per_employee
>
queryableAuthors
=
context
.
Set
<
per_employee
>().
Where
(
exp
);
return
PageList
<
per_employee
>.
Create
(
queryableAuthors
,
pageNumber
,
pageSize
);
}
}
}
performance/Performance.Services/PersonService.cs
View file @
b47369b6
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment