Abp添加新的接口(扩展底层接口)
在https://aspnetboilerplate.com/Templates 创建项目之后,下载用Vs2019打开(vs2017不支持netcore3.0)结构如下:
一、

2、
在xx.core中新增实体类Code codemapping


3、
在xx.core 中新增 仓储接口

4、在xx.EntityFrameWork中实现仓储

不要忘记在项目中上下文中做如下设置,否则执行add-migration 及update-database 时不会产生对应的表结构

public class CodeMappingRepository:WuMingRepositoryBase<CodeMapping,int>,ICodeMappingRepository
{
public CodeMappingRepository(IDbContextProvider<WuMingDbContext> dbContextProvider) : base(dbContextProvider)
{
} public int Account()
{
throw new NotImplementedException();
}
}
public class CodeRepository :WuMingRepositoryBase<Code,int>,ICodeRepository
{
public CodeRepository(IDbContextProvider<WuMingDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
5 .在xx.Application 定义Ixxservice 和实现实现接口

定义和实现:
ICodeAppService
public interface ICodeAppService: IApplicationService
{
List<Code> GetCodes(); void UpdateCode(Code entity); void CreateCode(Code entity); void DeleteCode(int Id);
}
CodeAppService:
[AbpAllowAnonymous]
public class CodeAppService :WuMingAppServiceBase, ICodeAppService
{ ICodeRepository _CodeRepository;
ICodeMappingRepository _CodeMappingRepository; public CodeAppService(ICodeRepository CodeRepository, ICodeMappingRepository CodeMappingRepository)
{
_CodeRepository = CodeRepository;
_CodeMappingRepository = CodeMappingRepository;
} public void CreateCode(Code entity)
{
Logger.Info($"Created a User for entity at:{DateTime.Now}");
try
{
_CodeRepository.Insert(entity);
}
catch (Exception ex)
{
Logger.Error(ex.ToString());
}
} public void DeleteCode(int Id)
{
Logger.Info($"Created a User for entity at:{DateTime.Now}");
try
{
// _CodeRepository.Delete(new Code() { Id = Id }); }
catch (Exception ex)
{ Logger.Error(ex.ToString());
} } public List<Code> GetCodes()
{
Logger.Info($"Created a User for entity at:{DateTime.Now}");
try
{
//return _CodeRepository.GetAll().ToList();
return null;
}
catch (Exception ex)
{ throw;
}
} public void UpdateCode(Code entity)
{
Logger.Info($"Created a User for entity at:{DateTime.Now}");
try
{
// _CodeRepository.Update(entity); }
catch (Exception ex)
{ Logger.Error(ex.ToString());
}
}
}
6.设置项目启动项: F5 就可以看到api接口地址及接口描述


Abp添加新的接口(扩展底层接口)的更多相关文章
- typescript接口扩展、接口的继承
//接口扩展:接口可以继承接口 // interface Animal{ // eat():void; // } // interface Person extends Animal{ // work ...
- Abp添加新的Api(不扩展底层方法)
定义新的实体类:FileManage;继承 FullAuditedEntity<Guid> 在XX.Application 中定义IXXservice及实现XXservice public ...
- 添加新硬盘,扩展Centos7根分区
##背景介绍,系统安装时,分配的硬盘容量太小,根分区空间不够用,现添加一个新硬盘,通过以下步骤来扩展centos7根分区 [root@t201 ~]# df -h 文件系统 容量 已用 可用 已用% ...
- JEECMS 2.4.2 之添加新的可扩展的ftl模版文件、自定义方法
Demo: <@cms.CfgList isPage='1' league='0' recommend='0' lala='0' hot='1' memberId='0' pageNo=page ...
- Android Telephony分析(六) ---- 接口扩展(实践篇)
本文将结合前面五篇文章所讲解的知识,综合起来,实现一个接口扩展的功能.如果还没有阅读过前面五篇文章的内容,请先阅读:<Android Telephony分析(一) — Phone详解 >& ...
- typescript接口扩展
/* typeScript中的接口 接口扩展 */ /* 接口的作用:在面向对象的编程中,接口是一种规范的定义,它定义了行为和动作的规范,在程序设计里面,接口起到一种限制和规范的作用.接口定义了某一批 ...
- Java EE HttpServletRequest接口和HttpServletResponse接口
package javax.servlet.http (https://docs.oracle.com/javaee/7/api/javax/servlet/http/package-summary. ...
- Surface Pro 4 和 Surface Book 使用名为 Surface UEFI(统一可扩展固件接口)的新固件接口
Surface Pro 4 和 Surface Book 使用名为 Surface UEFI(统一可扩展固件接口)的新固件接口.Surface UEFI 提供新功能,如启动更快速.安全性更高.可替换 ...
- 如何利用phpize在生产环境中为php添加新的扩展php-bcmath
在日常的开发当中,随着开发的功能越来越复杂.对运行环境的要求也就随着需求的变化需要不断地更新和变化.一个在线的生产系统不可能一开始就满足了所有的运行依赖,因此动态地添加依赖就显得比较必要了.如果你的应 ...
随机推荐
- springboot @Configuration配置类里面使用@Value获取不到.yml配置文件属性的值
之前一个项目里面分为很多子工程的那种结构,要求让我改成一个项目的结构.我这边手动将代码合并之后出现下面的这种问题,然后尝试进行用各种方式解决 Error creating bean with name ...
- pure-ftpd搭建简单的Ubuntu FTP服务器
Linux下的ftpd很多,Ubuntu下常用vsftpd, proftpd和pure-ftpd,当初使用的就是proftpd. 不过前两者有个致命的问题就是内码转换,它们默认使用UTF-8编码,而W ...
- vue中如何刷新页面
vue中刷新页面的方法 1. 不能使用 this.$router.go(0) 或者 window.reload() 不起作用还特别恶心 这个才是有效果的刷新页面,只要照图敲,就能有效果 我们在 app ...
- Telnet/SSH 客户端
一.WinSCP linux 与 windows 间传递文件.可以与 putty 配合使用. 官网提供便携版下载:https://winscp.net/eng/downloads.php 支持中文,语 ...
- leetcode-hard-array-11 Container With Most Water -NO
mycode time limited class Solution(object): def maxArea(self, height): """ :type hei ...
- ccf 201512-3 画图(90)
ccf 201512-3 画图(90) #include<iostream> #include<cstring> #include<algorithm> using ...
- 开始JavaScript的学习了
为何学习? 1. 所有主流浏览器都支持JavaScript. 2. 目前,全世界大部分网页都使用JavaScript. 3. 它可以让网页呈现各种动态效果. 4. 做为一个Web开发师,如果你想提供漂 ...
- python pymysql 连接 mysql数据库进行操作
1.数据库的连接操作 import pymysql conn = pymysql.connect(host=', db='oldboydb') # host表示ip地址,user表示用户名,passw ...
- LC 244. Shortest Word Distance II 【lock, Medium】
Design a class which receives a list of words in the constructor, and implements a method that takes ...
- LC 465. Optimal Account Balancing 【lock,hard】
A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for ...