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
a3a1b55c
Commit
a3a1b55c
authored
Mar 06, 2019
by
zry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v1
parent
cb1b5c73
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
162 additions
and
33 deletions
+162
-33
performance/Performance.Api/Controllers/AccountController.cs
+8
-8
performance/Performance.Api/Controllers/HospitalController.cs
+7
-4
performance/Performance.Api/Controllers/MenuController.cs
+4
-2
performance/Performance.Api/Controllers/SmsController.cs
+2
-2
performance/Performance.Api/Filters/ActionsFilter.cs
+7
-0
performance/Performance.Api/Program.cs
+1
-1
performance/Performance.Api/Properties/PublishProfiles/FolderProfile.pubxml
+23
-0
performance/Performance.Api/Startup.cs
+3
-0
performance/Performance.Api/Util/ClaimService.cs
+8
-4
performance/Performance.DtoModels/ApiRequest.cs
+16
-1
performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
+5
-1
performance/Performance.DtoModels/Request/LoginRequest.cs
+1
-1
performance/Performance.DtoModels/Response/MenuResponse.cs
+38
-0
performance/Performance.DtoModels/Response/UserIdentity.cs
+1
-1
performance/Performance.Services/HospitalService.cs
+2
-2
performance/Performance.Services/MenuService.cs
+24
-3
performance/Performance.Services/SmsService.cs
+1
-1
performance/Performance.Services/UserService.cs
+11
-2
No files found.
performance/Performance.Api/Controllers/AccountController.cs
View file @
a3a1b55c
...
...
@@ -21,16 +21,19 @@ public class AccountController : Controller
private
RoleService
_roleService
;
private
IMemoryCache
_memoryCache
;
private
Application
_options
;
private
ClaimService
_claim
;
public
AccountController
(
UserService
userService
,
HospitalService
hospitalService
,
RoleService
roleService
,
IMemoryCache
memoryCache
,
IOptions
<
Application
>
options
)
IOptions
<
Application
>
options
,
ClaimService
claim
)
{
_userService
=
userService
;
_roleService
=
roleService
;
_memoryCache
=
memoryCache
;
_options
=
options
.
Value
;
_claim
=
claim
;
}
/// <summary>
...
...
@@ -69,11 +72,10 @@ public ApiResponse<UserIdentity> Login([FromBody]LoginRequest request)
/// <returns></returns>
[
Route
(
"insert"
)]
[
HttpPost
]
public
ApiResponse
Insert
(
[
CustomizeValidator
(
RuleSet
=
"Insert"
)]
[
FromBody
]
UserRequest
request
)
public
ApiResponse
Insert
([
CustomizeValidator
(
RuleSet
=
"Insert"
),
FromBody
]
UserRequest
request
)
{
if
(!
_userService
.
Insert
(
request
))
var
userid
=
_claim
.
At
(
request
.
Token
).
UserID
;
if
(!
_userService
.
Insert
(
request
,
userid
))
return
new
ApiResponse
(
ResponseType
.
Fail
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
...
...
@@ -85,9 +87,7 @@ public ApiResponse<UserIdentity> Login([FromBody]LoginRequest request)
/// <returns></returns>
[
Route
(
"update"
)]
[
HttpPost
]
public
ApiResponse
Update
(
[
CustomizeValidator
(
RuleSet
=
"Update"
)]
[
FromBody
]
UserRequest
request
)
public
ApiResponse
Update
([
CustomizeValidator
(
RuleSet
=
"Update"
),
FromBody
]
UserRequest
request
)
{
if
(!
_userService
.
Update
(
request
))
return
new
ApiResponse
(
ResponseType
.
Fail
);
...
...
performance/Performance.Api/Controllers/HospitalController.cs
View file @
a3a1b55c
...
...
@@ -14,17 +14,19 @@ namespace Performance.Api.Controllers
[
Route
(
"api/[controller]"
)]
public
class
HospitalController
:
Controller
{
HospitalService
_hospitalService
;
public
HospitalController
(
HospitalService
hospitalService
)
private
HospitalService
_hospitalService
;
private
ClaimService
_claim
;
public
HospitalController
(
HospitalService
hospitalService
,
ClaimService
claimService
)
{
_hospitalService
=
hospitalService
;
_claim
=
claimService
;
}
[
Route
(
"hospitallist"
)]
[
HttpPost
]
public
ApiResponse
<
List
<
HospitalResponse
>>
GetHospitalList
([
FromBody
]
ApiRequest
request
)
{
var
hospitalList
=
_hospitalService
.
GetUserHopital
(
request
.
ActiveU
ID
);
var
hospitalList
=
_hospitalService
.
GetUserHopital
(
_claim
.
At
(
request
.
Token
).
User
ID
);
return
new
ApiResponse
<
List
<
HospitalResponse
>>(
ResponseType
.
OK
,
"ok"
,
hospitalList
);
}
...
...
@@ -32,7 +34,8 @@ public ApiResponse<List<HospitalResponse>> GetHospitalList([FromBody]ApiRequest
[
HttpPost
]
public
ApiResponse
Insert
([
CustomizeValidator
(
RuleSet
=
"Insert"
),
FromBody
]
HospitalRequest
request
)
{
if
(!
_hospitalService
.
Insert
(
request
))
var
userid
=
_claim
.
At
(
request
.
Token
).
UserID
;
if
(!
_hospitalService
.
Insert
(
request
,
userid
))
return
new
ApiResponse
(
ResponseType
.
Fail
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
...
...
performance/Performance.Api/Controllers/MenuController.cs
View file @
a3a1b55c
...
...
@@ -18,9 +18,11 @@ namespace Performance.Api.Controllers
public
class
MenuController
:
Controller
{
private
MenuService
_menuService
;
public
MenuController
(
MenuService
menuService
)
private
ClaimService
_claim
;
public
MenuController
(
MenuService
menuService
,
ClaimService
claimService
)
{
_menuService
=
menuService
;
_claim
=
claimService
;
}
/// <summary>
...
...
@@ -32,7 +34,7 @@ public MenuController(MenuService menuService)
[
HttpPost
]
public
ApiResponse
MenuList
([
FromBody
]
ApiRequest
request
)
{
var
menuList
=
_menuService
.
GetMenuList
(
request
.
ActiveU
ID
);
var
menuList
=
_menuService
.
GetMenuList
(
_claim
.
At
(
request
.
Token
).
User
ID
);
return
new
ApiResponse
(
ResponseType
.
OK
,
menuList
);
}
}
...
...
performance/Performance.Api/Controllers/SmsController.cs
View file @
a3a1b55c
...
...
@@ -32,7 +32,7 @@ public SmsController(SmsService smsService)
[
NoVerify
]
public
ApiResponse
Code
([
FromBody
]
SmsCodeRequest
request
)
{
if
(
_smsService
.
SendCode
(
request
.
Type
,
request
.
Mobile
))
if
(
!
_smsService
.
SendCode
(
request
.
Type
,
request
.
Mobile
))
return
new
ApiResponse
(
ResponseType
.
Fail
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
...
...
@@ -47,7 +47,7 @@ public ApiResponse Code([FromBody]SmsCodeRequest request)
[
NoVerify
]
public
ApiResponse
Check
([
CustomizeValidator
(
RuleSet
=
"SmsCheck"
)][
FromBody
]
SmsCodeRequest
request
)
{
if
(
_smsService
.
Check
(
request
.
Mobile
,
request
.
Code
))
if
(
!
_smsService
.
Check
(
request
.
Mobile
,
request
.
Code
))
return
new
ApiResponse
(
ResponseType
.
Fail
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
...
...
performance/Performance.Api/Filters/ActionsFilter.cs
View file @
a3a1b55c
...
...
@@ -52,6 +52,13 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
context
.
Result
=
new
ObjectResult
(
response
);
return
;
}
var
activeuid
=
kv
.
GetValue
<
Nullable
<
int
>>(
"activeuid"
);
if
(!
activeuid
.
HasValue
)
{
var
response
=
new
ApiResponse
(
ResponseType
.
TokenError
,
"Token无效"
);
context
.
Result
=
new
ObjectResult
(
response
);
return
;
}
}
}
...
...
performance/Performance.Api/Program.cs
View file @
a3a1b55c
...
...
@@ -23,9 +23,9 @@ public static void Main(string[] args)
.
ConfigureAppConfiguration
((
context
,
config
)
=>
{
var
env
=
context
.
HostingEnvironment
;
env
.
ConfigureNLog
(
"nlog.config"
);
config
.
AddJsonFile
(
"appsettings.json"
,
true
,
true
);
config
.
AddJsonFile
(
$"appsettings.
{
env
.
EnvironmentName
}
.json"
,
true
,
true
);
env
.
ConfigureNLog
(
"nlog.config"
);
})
.
UseStartup
<
Startup
>();
}
...
...
performance/Performance.Api/Properties/PublishProfiles/FolderProfile.pubxml
0 → 100644
View file @
a3a1b55c
<?xml version="1.0" encoding="utf-8"?>
<!--
此文件由 Web 项目的发布/打包过程使用。可以通过编辑此 MSBuild 文件
自定义此过程的行为。为了解与此相关的更多内容,请访问 https://go.microsoft.com/fwlink/?LinkID=208121。
-->
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<WebPublishMethod>
FileSystem
</WebPublishMethod>
<PublishProvider>
FileSystem
</PublishProvider>
<LastUsedBuildConfiguration>
Release
</LastUsedBuildConfiguration>
<LastUsedPlatform>
Any CPU
</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish
/>
<LaunchSiteAfterPublish>
True
</LaunchSiteAfterPublish>
<ExcludeApp_Data>
False
</ExcludeApp_Data>
<TargetFramework>
netcoreapp2.2
</TargetFramework>
<ProjectGuid>
3ae00ff5-f0ba-4d72-a23b-770186309327
</ProjectGuid>
<SelfContained>
false
</SelfContained>
<_IsPortable>
true
</_IsPortable>
<publishUrl>
E:\release\jx.suvalue.com
</publishUrl>
<DeleteExistingFiles>
True
</DeleteExistingFiles>
</PropertyGroup>
</Project>
\ No newline at end of file
performance/Performance.Api/Startup.cs
View file @
a3a1b55c
...
...
@@ -96,6 +96,8 @@ public void ConfigureServices(IServiceCollection services)
//huyi短信发送注入
services
.
AddScoped
<
HuyiSmsNotify
>();
//用户身份信息服务
services
.
AddScoped
<
ClaimService
>();
//ef配置
var
connection
=
services
.
BuildServiceProvider
().
GetService
<
IOptions
<
AppConnection
>>();
...
...
@@ -117,6 +119,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
{
app
.
UseStatusCodePagesWithReExecute
(
"/error/{0}"
);
}
loggerFactory
.
CreateLogger
<
Startup
>().
LogDebug
(
env
.
EnvironmentName
);
app
.
UseMvc
();
}
}
...
...
performance/Performance.Api/Util/
UserUtil
.cs
→
performance/Performance.Api/Util/
ClaimService
.cs
View file @
a3a1b55c
...
...
@@ -5,15 +5,16 @@
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Performance.Api
.Util
namespace
Performance.Api
{
public
class
UserUtil
public
class
ClaimService
{
IMemoryCache
_memoryCache
;
public
UserUtil
(
IMemoryCache
memoryCache
)
public
ClaimService
(
IMemoryCache
memoryCache
)
{
_memoryCache
=
memoryCache
;
}
public
UserIdentity
At
(
ApiRequest
request
)
{
return
At
(
request
.
Token
);
...
...
@@ -23,7 +24,10 @@ public UserIdentity At(string token)
{
if
(
string
.
IsNullOrEmpty
(
token
))
throw
new
PerformanceException
(
"token is not null"
);
return
_memoryCache
.
Get
<
UserIdentity
>(
token
);
var
user
=
_memoryCache
.
Get
<
UserIdentity
>(
token
);
if
(
user
==
null
)
throw
new
PerformanceException
(
"当前用户未登录"
);
return
user
;
}
}
}
performance/Performance.DtoModels/ApiRequest.cs
View file @
a3a1b55c
...
...
@@ -8,10 +8,25 @@ namespace Performance.DtoModels
{
public
class
ApiRequest
{
/// <summary>
/// 登录后返回登录令牌
/// </summary>
public
string
Token
{
get
;
set
;
}
/// <summary>
/// 版本号 v1
/// </summary>
public
string
Version
{
get
;
set
;
}
/// <summary>
/// 设备号 1 苹果 2 安卓 3 网页
/// </summary>
public
string
Device
{
get
;
set
;
}
/// <summary>
/// App名称
/// </summary>
public
string
AppName
{
get
;
set
;
}
public
int
ActiveUID
{
get
;
set
;
}
///// <summary>
///// 操作用户
///// </summary>
//public Nullable<int> ActiveUID { get; set; }
}
}
performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
View file @
a3a1b55c
...
...
@@ -36,7 +36,11 @@ public AutoMapperConfigs()
CreateMap
<
sys_role
,
RoleResponse
>()
.
ForMember
(
dest
=>
dest
.
RoleID
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
ID
));
// 菜单 响应
CreateMap
<
MenuResponse
,
sys_menu
>()
.
ForMember
(
dest
=>
dest
.
ID
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
MenuID
));
CreateMap
<
sys_menu
,
MenuResponse
>()
.
ForMember
(
dest
=>
dest
.
MenuID
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
ID
));
}
}
}
performance/Performance.DtoModels/Request/LoginRequest.cs
View file @
a3a1b55c
...
...
@@ -22,7 +22,7 @@ public class LoginRequestValidator : AbstractValidator<LoginRequest>
{
public
LoginRequestValidator
()
{
RuleFor
(
x
=>
x
.
LoginType
).
InclusiveBetween
(
1
,
2
);
RuleFor
(
x
=>
x
.
LoginType
).
NotNull
().
NotEmpty
().
InclusiveBetween
(
1
,
2
);
RuleFor
(
x
=>
x
.
Account
).
NotEmpty
().
NotNull
().
Length
(
1
,
200
);
...
...
performance/Performance.DtoModels/Response/MenuResponse.cs
0 → 100644
View file @
a3a1b55c
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
MenuResponse
{
public
int
MenuID
{
get
;
set
;
}
/// <summary>
/// 菜单名称
/// </summary>
public
string
MenuName
{
get
;
set
;
}
/// <summary>
/// 菜单Url
/// </summary>
public
string
MenuUrl
{
get
;
set
;
}
/// <summary>
/// 菜单图标
/// </summary>
public
string
MenuIcon
{
get
;
set
;
}
/// <summary>
/// 菜单类型 1 首页中出现 2 医院页中出现
/// </summary>
public
int
MenuType
{
get
;
set
;
}
/// <summary>
/// 菜单状态 1 启用 2禁用
/// </summary>
public
int
States
{
get
;
set
;
}
public
List
<
MenuResponse
>
Children
{
get
;
set
;
}
}
}
performance/Performance.DtoModels/Response/UserIdentity.cs
View file @
a3a1b55c
...
...
@@ -8,7 +8,7 @@ public class UserIdentity
{
public
string
Token
{
get
;
set
;
}
public
int
UserID
{
get
;
set
;
}
public
DateTime
CreatDate
{
get
;
set
;
}
public
DateTime
Creat
e
Date
{
get
;
set
;
}
public
int
CreateUser
{
get
;
set
;
}
public
string
RealName
{
get
;
set
;
}
public
string
Login
{
get
;
set
;
}
...
...
performance/Performance.Services/HospitalService.cs
View file @
a3a1b55c
...
...
@@ -44,13 +44,13 @@ public List<HospitalResponse> GetUserHopital(int userid)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
bool
Insert
(
HospitalRequest
request
)
public
bool
Insert
(
HospitalRequest
request
,
int
userid
)
{
if
(
null
!=
_hospitalRepository
.
GetEntity
(
t
=>
t
.
HosName
==
request
.
HosName
))
throw
new
PerformanceException
(
"医院名称重复"
);
var
hospital
=
Mapper
.
Map
<
sys_hospital
>(
request
);
hospital
.
CreateDate
=
DateTime
.
Now
;
hospital
.
CreateUser
=
request
.
ActiveUID
;
hospital
.
CreateUser
=
userid
;
hospital
.
States
=
(
int
)
States
.
Enabled
;
return
_hospitalRepository
.
Add
(
hospital
);
...
...
performance/Performance.Services/MenuService.cs
View file @
a3a1b55c
using
Performance.EntityModels
;
using
AutoMapper
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Performance.Services
...
...
@@ -14,9 +17,27 @@ public MenuService(PerforMenuRepository menuRepository)
_menuRepository
=
menuRepository
;
}
public
List
<
sys_menu
>
GetMenuList
(
int
userid
)
public
List
<
MenuResponse
>
GetMenuList
(
int
userid
)
{
return
_menuRepository
.
GetMenuList
(
userid
);
var
menuList
=
_menuRepository
.
GetMenuList
(
userid
);
return
RecursionFill
(
menuList
,
0
);
}
private
List
<
MenuResponse
>
RecursionFill
(
List
<
sys_menu
>
menuList
,
int
parentId
)
{
if
(
menuList
.
Any
(
t
=>
t
.
ParentID
==
parentId
))
{
var
list
=
new
List
<
MenuResponse
>();
foreach
(
var
item
in
menuList
.
Where
(
t
=>
t
.
ParentID
==
parentId
))
{
var
menu
=
Mapper
.
Map
<
MenuResponse
>(
item
);
menu
.
Children
=
RecursionFill
(
menuList
,
item
.
ID
);
list
.
Add
(
menu
);
}
return
list
;
}
return
null
;
}
}
}
performance/Performance.Services/SmsService.cs
View file @
a3a1b55c
...
...
@@ -76,7 +76,7 @@ public bool Check(string mobile, string code)
if
(
string
.
IsNullOrEmpty
(
mobile
)
||
string
.
IsNullOrEmpty
(
code
))
throw
new
PerformanceException
(
"参数无效"
);
var
sms
=
_smsRepository
.
GetEntity
(
t
=>
t
.
Mobile
==
mobile
.
Trim
()
&&
t
.
SmsCode
==
code
.
Trim
());
return
sms
==
null
;
return
(
sms
!=
null
&&
sms
.
Expiration
>
DateTime
.
Now
)
;
}
}
}
performance/Performance.Services/UserService.cs
View file @
a3a1b55c
...
...
@@ -69,7 +69,7 @@ public UserIdentity Login(LoginRequest request)
/// 新增用户
/// </summary>
/// <param name="request"></param>
public
bool
Insert
(
UserRequest
request
)
public
bool
Insert
(
UserRequest
request
,
int
userid
)
{
if
(
null
!=
_userRepository
.
GetEntity
(
t
=>
t
.
Login
==
request
.
Login
))
throw
new
PerformanceException
(
"登录名重复"
);
...
...
@@ -77,7 +77,7 @@ public bool Insert(UserRequest request)
throw
new
PerformanceException
(
"手机号重复"
);
var
user
=
Mapper
.
Map
<
sys_user
>(
request
);
user
.
CreateDate
=
DateTime
.
Now
;
user
.
CreateUser
=
request
.
ActiveUID
;
user
.
CreateUser
=
userid
;
user
.
States
=
(
int
)
States
.
Enabled
;
return
_userRepository
.
Add
(
user
);
...
...
@@ -125,6 +125,15 @@ public bool Update(UserRequest request)
var
user
=
_userRepository
.
GetEntity
(
t
=>
t
.
ID
==
request
.
ID
);
if
(
null
==
user
)
throw
new
PerformanceException
(
$"用户不存在 UserId:
{
request
.
ID
}
"
);
var
vlist
=
_userRepository
.
GetEntities
(
t
=>
t
.
ID
!=
user
.
ID
&&
t
.
Login
==
request
.
Login
);
if
(
null
!=
vlist
&&
vlist
.
Count
()
>
0
)
throw
new
PerformanceException
(
"登录名重复"
);
vlist
=
_userRepository
.
GetEntities
(
t
=>
t
.
ID
!=
user
.
ID
&&
t
.
Mobile
==
request
.
Mobile
);
if
(
null
!=
vlist
&&
vlist
.
Count
()
>
0
)
throw
new
PerformanceException
(
"手机号重复"
);
user
.
Login
=
request
.
Login
;
user
.
Mobile
=
request
.
Mobile
;
user
.
RealName
=
request
.
RealName
;
...
...
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