Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwplvx
Aurora
提交
94ef69a0
Aurora
项目概览
lwplvx
/
Aurora
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Aurora
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
94ef69a0
编写于
9月 29, 2021
作者:
lwplvx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加翻译接口相关
上级
c8552e19
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
156 addition
and
0 deletion
+156
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Controllers/TranslateController.cs
...a.Core/Aurora.Core.Api/Controllers/TranslateController.cs
+49
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.Domain/Entities/Rocket.cs
...ervices/Aurora.Core/Aurora.Core.Domain/Entities/Rocket.cs
+16
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.IService/Dto/RocketDto.cs
...ervices/Aurora.Core/Aurora.Core.IService/Dto/RocketDto.cs
+11
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.IService/IRocketService.cs
...rvices/Aurora.Core/Aurora.Core.IService/IRocketService.cs
+14
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.Service/RocketService.cs
...services/Aurora.Core/Aurora.Core.Service/RocketService.cs
+66
-0
未找到文件。
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Controllers/TranslateController.cs
0 → 100644
浏览文件 @
94ef69a0
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Aurora.Core.IService
;
using
Aurora.Core.IService.Dto
;
using
Aurora.Infrastructure.Response
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Logging
;
namespace
Aurora.Core.Api.Controllers
{
[
ApiController
]
[
Route
(
"[controller]/[action]"
)]
public
class
TranslateController
:
ControllerBase
{
private
readonly
ILogger
<
TranslateController
>
_logger
;
private
readonly
IRocketService
_rocketService
;
public
TranslateController
(
ILogger
<
TranslateController
>
logger
,
IRocketService
rocketService
)
{
_logger
=
logger
;
_rocketService
=
rocketService
;
}
[
HttpGet
]
/// <summary>
/// get words list
/// </summary>
/// <returns></returns>
public
async
Task
<
IActionResult
>
GetList
()
{
var
res
=
await
_rocketService
.
GetList
();
return
Ok
(
res
);
}
[
HttpPost
]
/// <summary>
/// biu word
/// </summary>
/// <returns></returns>
public
async
Task
<
ResponseModel
<
RocketDto
>>
Rocket
(
RocketDto
model
)
{
var
res
=
await
_rocketService
.
Add
(
model
);
return
res
;
}
}
}
Aurora.Microservices/Aurora.Core/Aurora.Core.Domain/Entities/Rocket.cs
0 → 100644
浏览文件 @
94ef69a0
using
System
;
using
System.Collections.Generic
;
namespace
Aurora.Core.Domain.Entities
{
/// <summary>
/// 单词,我就用 Rocket 老表示单词
/// </summary>
public
class
Rocket
:
TenantEntityBase
{
public
int
CategoryId
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
// 其他字段…… ,翻译接口调用通了再补充
public
string
Remark
{
get
;
set
;
}
}
}
Aurora.Microservices/Aurora.Core/Aurora.Core.IService/Dto/RocketDto.cs
0 → 100644
浏览文件 @
94ef69a0
using
System
;
namespace
Aurora.Core.IService.Dto
{
public
class
RocketDto
:
BaseDto
{
public
string
Name
{
get
;
set
;
}
public
string
Remark
{
get
;
set
;
}
public
int
CatetoryId
{
get
;
set
;
}
}
}
Aurora.Microservices/Aurora.Core/Aurora.Core.IService/IRocketService.cs
0 → 100644
浏览文件 @
94ef69a0
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
Aurora.Core.IService.Dto
;
using
Aurora.Infrastructure.Response
;
namespace
Aurora.Core.IService
{
public
interface
IRocketService
{
Task
<
ResponseModel
<
List
<
RocketDto
>>>
GetList
();
Task
<
ResponseModel
<
RocketDto
>>
Rocket
(
RocketDto
model
);
}
}
Aurora.Microservices/Aurora.Core/Aurora.Core.Service/RocketService.cs
0 → 100644
浏览文件 @
94ef69a0
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Aurora.Core.Domain.Entities
;
using
Aurora.Core.EntityFramework
;
using
Aurora.Core.IService
;
using
Aurora.Core.IService.Dto
;
using
Aurora.Infrastructure.Response
;
using
AutoMapper
;
using
Microsoft.EntityFrameworkCore
;
namespace
Aurora.Core.Service
{
public
class
RocketService
:
IRocketService
{
private
readonly
ApplicationDbContext
_dbContext
;
private
readonly
ApplicationReadonlyDbContext
_readonlyDbContext
;
private
readonly
IMapper
_mapper
;
public
RocketService
(
ApplicationDbContext
dbContext
,
ApplicationReadonlyDbContext
readonlyDbContext
,
IMapper
mapper
)
{
_mapper
=
mapper
??
throw
new
ArgumentNullException
(
nameof
(
mapper
));
_dbContext
=
dbContext
;
_readonlyDbContext
=
readonlyDbContext
;
}
public
async
Task
<
ResponseModel
<
List
<
RocketDto
>>>
GetList
()
{
var
list
=
await
_readonlyDbContext
.
Categories
.
ToListAsync
();
var
dtoList
=
_mapper
.
Map
<
List
<
RocketDto
>>(
list
);
var
res
=
new
ResponseModel
<
List
<
RocketDto
>>(
dtoList
);
return
res
;
}
public
async
Task
<
ResponseModel
<
RocketDto
>>
GetById
(
int
id
)
{
var
entity
=
await
_readonlyDbContext
.
Categories
.
FirstOrDefaultAsync
(
m
=>
m
.
ID
==
id
);
var
dto
=
_mapper
.
Map
<
RocketDto
>(
entity
);
var
res
=
new
ResponseModel
<
RocketDto
>(
dto
);
return
res
;
}
public
async
Task
<
ResponseModel
<
RocketDto
>>
Rocket
(
RocketDto
model
)
{
var
entity
=
_mapper
.
Map
<
RocketWord
>(
model
);
_dbContext
.
Categories
.
Add
(
entity
);
var
num
=
await
_dbContext
.
SaveChangesAsync
();
var
dto
=
_mapper
.
Map
<
RocketDto
>(
entity
);
var
res
=
new
ResponseModel
<
RocketDto
>(
dto
);
return
res
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录