Git Product home page Git Product logo

lulzzz / hiwjcn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wjcodestore/hiwjcn

0.0 2.0 0.0 17.79 MB

Asp.Net MVC开发框架,Lib项目,依赖注入,Aop,扩展,任务调度,队列,缓存,Akka,搜索,权限系统。。。

Home Page: https://www.nuget.org/packages/lib.com.nuget/

C# 98.50% Batchfile 0.01% Shell 0.01% PLpgSQL 1.29% HTML 0.13% ASP 0.03% CSS 0.04% JavaScript 0.01%

hiwjcn's Introduction

Asp.Net MVC开发框架

>基于autofac的ioc依赖注入
>基于autofac.dynamicproxy的aop面向切面编程
>entity framework orm+仓储模式架构
>events事件发布订阅
>使用PreApplicationStartMethod实现的插件机制(不稳定)
>基于json字典库的多语言
>基于redis/内存的缓存组件
>基于quartz的后台任务
>基于polly的熔断,重试,超时etc
>rabbitmq消息队列
>elasticsearch检索
>WCF调用封装
>Mysql存储Session
>第三方api调用
>身份验证权限
>Auth授权系统
>Akka Actor编程模型
>WebSocket(未完成)
>各种类库...

Lib项目

https://www.nuget.org/packages/lib.com.nuget/

Lib项目

Bug反馈

issue or [email protected]

约定

层级 引用 Example
data model dll T_User_Info Lib
service IRepository<> IData IRepository<T_User_Info> IUserData
controller IService IUserService

结构

    //数据层
    public interface IUserData : IRepository<T_User_Info>
    {
    }
    public class UserData : EFRepository<T_User_Info>, IUserData
    {
    }
    //业务层
    public interface IUserService : IServiceBase<T_User_Info>
    {
        T_User_Info GetByID(int id);
        List<T_User_Info> GetTop10();
        Tuple<bool, string> AddUser(T_User_Info model);
        Tuple<int, string> UpdateUser(T_User_Info model);
    }
    public class UserService : ServiceBase<T_User_Info>, IUserService
    {
        private readonly IUserData _IUserData;
        private readonly IEventPublisher _Publisher;
        private readonly IRepository<T_User_PayBill> _userpaybillRepository;
	
	//控制器注入实现
        public UserService(
            IUserData userdata,
            IEventPublisher publisher,
            IRepository<T_User_PayBill> userpaybillRepository)
        {
            this._IUserData = userdata;
            this._Publisher = publisher;
            this._userpaybillRepository = userpaybillRepository;

            this._Publisher.Publish("发布消息");
        }
        //methods
    }
    //控制器
    public class UserController : BaseController
    {
        private readonly IUserService _IUserService;
        private readonly IValidateCodeService _IValidateCodeService;

        public UserController(
            IUserService _IUserService,
            IValidateCodeService _IValidateCodeService)
        {
            this._IUserService = _IUserService;
            this._IValidateCodeService = _IValidateCodeService;
        }
    }

事件发布

    //实现消费接口
    public class UserEventHandler :
        IConsumer<EntityDeleted<T_User_Info>>,
        IConsumer<EntityUpdated<T_User_Info>>,
        IConsumer<EntityInserted<T_User_Info>>,
        IConsumer<string>
    {
        public void HandleEvent(EntityInserted<T_User_Info> eventMessage)
        {
            $"插入:{eventMessage.Entity.ToJson()}".AddBusinessInfoLog();
        }

        public void HandleEvent(string eventMessage)
        {
            $"来自订阅的消息:{eventMessage}".AddBusinessInfoLog();
        }

        public void HandleEvent(EntityUpdated<T_User_Info> eventMessage)
        {
            $"修改:{eventMessage.Entity.ToJson()}".AddBusinessInfoLog();
        }

        public void HandleEvent(EntityDeleted<T_User_Info> eventMessage)
        {
            $"删除:{eventMessage.Entity.ToJson()}".AddBusinessInfoLog();
        }
    }
    //发布消息
    //自动去ioc容器中找到实现并调用
    this._Publisher.Publish("发布消息");

Aop

    //实现拦截接口,并注册到ioc中
    public class LogPerformance : IInterceptor
    {
        public void Intercept(IInvocation invocation)
        {
            try
            {
                var start = DateTime.Now;

                invocation.Proceed();

                var sec = (DateTime.Now - start).TotalSeconds;

                var name = invocation.Method.Name;
                $"{name}运行耗时:{sec}".AddBusinessInfoLog();
            }
            catch (Exception e)
            {
                e.AddErrorLog();
            }
        }
    }
    //[Intercept(typeof(LogPerformance))]添加到需要拦截的类,然后会自动拦截virtual方法

hiwjcn's People

Contributors

wangfengjun404 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.