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

     

  • 相关阅读:
    Hadoop学习入门
    node.js学习一——什么是node.js
    判断投递失败原因方法
    MySQL慢查询(一)
    jmeter5.1.1 打印OOM的问题
    Jmeter ForEach Controler、IF Controller、switch Controller
    Jmeter5.1.1 NON GUI下线程数可传参
    在JMeter压测 控制交易占比
    Linux下安装配置Jmeter5.1, 并执行jmx文件
    jmeter 生成报告 --- 如果已经生成jtl文件,可运行如下命令:jmeter -g test.jtl -o ./output
  • 原文地址:https://www.cnblogs.com/yanwuming/p/12006816.html
Copyright © 2020-2023  润新知