Skip to content

Instantly share code, notes, and snippets.

@frombegin
Last active December 8, 2015 20:55
Show Gist options
  • Save frombegin/6ff9d6308b5093457d6f to your computer and use it in GitHub Desktop.
Save frombegin/6ff9d6308b5093457d6f to your computer and use it in GitHub Desktop.

层次分解:

  1. api 层使用 jsonrpc
    com.xw.jsonrpc.intf.UserApi
    com.xw.jsonrpc.impl.UserApiImpl
    api 层构造 ScopeContext,调用 biz 层中的 Service, api 层自己要处理从对象到 json 的转换(如果缺省没实现的话)
  1. biz 层实现主要逻辑,创建 Connection,DSLContext,组合调用 model 层的数据库操作,并返回结果
    从 biz 层分解后的数据库操作保存在 Model 中
  1. model 层负责具体的数据库访问
    分解的 Model 保持和 Service 同级,比如:
    com.xw.biz.user.intf.UserService -> UserModel
    com.xw.biz.user.impl.UserServiceImpl -> UserModelImpl
    
    ScopedContext 增加获取 Model 的方法:
    UserModel um = getModel(ServiceId.USER)
  1. 上述接口和实现使用明确的 intf, impl 表示
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment