使用ABP框架踩过的坑系列2

时间:2018-06-11 12:48:22   收藏:0   阅读:441

ABP中有很多惯例,如果使用得当,可以事半功倍,如果使用不当,也会有很大的麻烦,是否适当其实还是要看Need需求

ASP.NET Boilerplate (ABP) is an open source and well documented application framework started idea of "developing a common framework for all companies and all developers!" It‘s not just a framework but also provides a strong architectural model based on Domain Driven Design and best practices in mind. 开源和文档友好,适合所有公司所有开发者的公共框架,基于DDD提供强壮架构,并且是最佳实践,这是作者的预期目标。
    看一下,代码例子,也许是程序员更喜欢的方式:
public class TaskAppService : ApplicationService, ITaskAppService
{
    private readonly IRepository<Task> _taskRepository;

    public TaskAppService(IRepository<Task> taskRepository)
    {
        _taskRepository = taskRepository;
    }

    [AbpAuthorize(MyPermissions.UpdatingTasks)]
    public async Task UpdateTask(UpdateTaskInput input)
    {
        Logger.Info("Updating a task for input: " + input);

        var task = await _taskRepository.FirstOrDefaultAsync(input.TaskId);
        if (task == null)
        {
            throw new UserFriendlyException(L("CouldNotFoundTheTaskMessage"));
        }

        input.MapTo(task);
    }
}
 
Here, we see a sample Application Service method. An application service, in DDD, is directly used by presentation layer to perform use cases of the application. We can think that UpdateTask method is called by javascript via AJAX. Let‘s see ABP‘s some benefits here:
Application Service 的方法,在DDD中对应的是UseCase用例,用例是什么?是用户需求,不清楚的同学请参考《有效需求分析》一书。从B/S角度看,该方法是由页面中js的AJAX调用的(其实也可能是被手机端APP调用的)。这个方式带来以下好处(注意要使用得当才有的,否则适得其反)

原文:https://www.cnblogs.com/szdlsoft/p/9166274.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!