= ns_service_pack 实现部分REST架构(ROA)中Service层基础共享代码抽取 #==功能列表: * 支持自定义json格式的资源crud操作 * 提供全局字典常量/转换管理 * 提供数据库层-业务层字段自动转换 #==TODO TASK LIST * 更好用的安装使用接口,自动完成,可配置 * rake 任务的引入, 产品模式将数据文件预编译成一个数据文件 * 提供scaffold模式方法 生成一些辅助接口和方法 service_scaffold,生成需要的模板和基本方法 * fieldmapping 和 常量管理的分离 让使用者可以决定是否使用mapping,目前可以通过注释initializer中片段完成 * 用模板的方法生成initializer,以便插入一些动态数据 * application_controller_module的引入还是有问题!!! * 如何为application_controller_module中的action自动生成路由呢? 直接生成服务端和客户端基础代码 * index默认查询条件加入,传入条件的merge(目前已提供传入条件的精确搜索) #==NS Service Pack使用指南 *1 在rails3项目Gemfile中引入 gem 'ns_service_pack' *2 启动控制台 rails c,运行命令 NsServicePack.install *3 配置项目中的常量数据 config/code_hashes/**/*.yml中数据会作为CodeHash加载 可在控制台下用以下命令辅助生成: .dump_mapping 生成buz-db field_mapping, 可配置, -->/config/code_hashes/fields/*.yml .dump_new 客户new该资源时的结构,--> /data/*.yml 常量的使用: GlobalConst.ns_statuses[key_or_value] *4 配置项目的controllers和models 4.1)在ApplicationController子类,如: class AddressesController < ApplicationController ... def model_class #引用的模型类,是ActiveRecord::Base子类 end ... end 4.2)在ActiveRecord::Base子类中,如Customer class Customer < ActiveRecord::Base ... def self.get_map_value(k, v) #定制各字段值的业务显示格式 #value mapping end ... end == Contributing to ns_service_pack * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it * Fork the project * Start a feature/bugfix branch * Commit and push until you are happy with your contribution * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. == Copyright Copyright (c) 2011 caory. See LICENSE.txt for further details.