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接口地址及接口描述

最新文章

  1. 关于 IE6、 IE7兼容性总结(转)
  2. 关于yii2框架活动记录activeRecord添加默认字段的问题
  3. shadowColor表示阴影颜色,shadowBlur表示模糊等级
  4. bp神经网络算法
  5. android中通过自定义xml实现你需要的shape效果 xml属性配置
  6. Beauty of Array(模拟)
  7. css3 滚动条出现 页面不跳动
  8. Rigidbody组件及相关API
  9. 数据交换格式与SpringIOC底层实现
  10. web工程设计&lt;mysql数据模型-数据类型的优化&gt;
  11. Luogu2046 NOI2010 海拔 平面图、最小割、最短路
  12. Python基础(函数,函数的定义,函数的调用,函数的参数,递归函数)
  13. C++四种类型之间的转换
  14. Java NIO系列教程
  15. 第三百二十三节,web爬虫,scrapy模块以及相关依赖模块安装
  16. 绚丽而实用的jQuery/CSS3应用及源码
  17. MTK 隐藏通知栏
  18. 分页器的js实现代码 bootstrap Paginator.js
  19. no persistent volumes available for this claim and no storage class is set FailedBinding -- nfs --存储
  20. css position:absolute align center bottom

热门文章

  1. LVS分析
  2. LeetCode 130. 被围绕的区域(Surrounded Regions)
  3. Oracle 11g的日志路径
  4. LC 562. Longest Line of Consecutive One in Matrix
  5. C实现通讯录管理系统(亮点:纯链表实现、子串匹配,文件读写)
  6. 日志框架之Logger
  7. 在Linux上安装Python3.7.1
  8. URL encoding(URL编码)
  9. python基础知识(保留字和标识符、变量、常量、基本数据类型)
  10. LeetCode.1108-使IP地址无效(Defanging an IP Address)