subapp_model 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7fad6e653f1ecec8abb4c0acb0608254f9d4116
4
- data.tar.gz: d28bfe44e4611ee36695c43fdc3c18311b2a8445
3
+ metadata.gz: bb75d0f7e947db6518771395c6dc3cd783074ebb
4
+ data.tar.gz: faf27cc043de1f2edf9f07a2afac64166ac36bf9
5
5
  SHA512:
6
- metadata.gz: 9eed1f16e6447e615ce29f939cde1ca97edd10accf38aeab4f4bd4089ebc1c73f27e533d0691deb5eaedcea0371b67029153e7c0d7e1cf405f727fc032654007
7
- data.tar.gz: 64823e433a6a07d6b40075694f8ca93a5870e698c9bceed43098d0da229336feb97a94a3bb95b6b4cf34dbee4d761a80214b6d577523c35d1c26f98a5963c76e
6
+ metadata.gz: 063a2fa2163ac3b1f96a5ee8ece331dc3caf7f23f0d5daf91894989c811a589f6c8382cae9646eec9bd8ef8f3f224d165e55fbc1c1cf19f8204c5570106d675b
7
+ data.tar.gz: 42e6096b15c8043a7bc7f54985b9c2d0ee3d10bf6a6e6cb0e8749df43fed8b58dbe7059858b9f269361adf42d1883107f05cf09172cc9e281d4087750aade33d
@@ -0,0 +1,110 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class App < ActiveRecord::Base
3
+ self.table_name = 'tb_app' # 子app
4
+ establish_connection SUBAPP_DB
5
+ attr_accessible :title,
6
+ :name, # 拼音
7
+ :content_type, # 1:多人 2:单人 3:单专辑
8
+ :is_published, # 是否发布过
9
+ :app_icon_path,
10
+ :app_icon_default,
11
+ :app_icon_57_path,
12
+ :app_icon_124_path,
13
+ :background_path,
14
+ :default_background,
15
+ :loading_icon_path,
16
+ :loading_default,
17
+ :loading_320x480_path,
18
+ :loading_640x960_path,
19
+ :loading_640x1136_path,
20
+ :loading_480x800_path,
21
+ :loading_1280x720_path,
22
+ :loading_music_path,
23
+ :loading_music_default,
24
+ :apple_appid,
25
+ :talkingdata_iphone_key,
26
+ :talkingdata_android_key,
27
+ :duomeng_ios_key, # 多盟广告ios版key
28
+ :duomeng_android_key, # 多盟广告android版key
29
+ :googlead_ios_key,
30
+ :googlead_android_key,
31
+ :weixin_ios_key,
32
+ :weixin_android_key,
33
+ :irateid,
34
+ :certificate_name, #打包用的苹果证书名
35
+ :envir, #环境 0:开发 1:测试
36
+ :app_icon_72_path, #android用
37
+ :app_icon_144_path, #android用
38
+ :channel_num, #渠道号
39
+ :baidu_ios_id, :baidu_ios_key, :baidu_android_id, :baidu_android_key, :ios_ads, :android_ads, :ios_is_upgraded, :android_is_upgraded,
40
+ :ios_is_recommended, :android_is_recommended, :ad_id, :is_push, :ios_version, :android_version, :production_id, :skin, :font,
41
+ :is_lite, :ios_is_search, :android_is_search,
42
+ :qq_ios_key, :qq_android_key,
43
+ :qq_ios_id, :qq_android_id,
44
+ :app_icon_120_path, :app_type, :file_url, :certificate_url,
45
+ :ios_is_chaping, :android_is_chaping, :ios_ad_time, :and_ad_time,
46
+ :ios_comment_lock, :android_comment_lock,
47
+ :ios_integral_wall, :android_integral_wall,
48
+ :count, :unlock, :comment, :ximalaya, :other, :ios_force_comment, :android_force_comment,
49
+ :ios_comment_time, :android_comment_time,
50
+ :android_480_skin, :android_720_skin, :android_font, :download,
51
+ :ios_is_bookstore, :android_is_bookstore, :ios_is_upgrade_in_download, :android_is_upgrade_in_download, :ios_is_upgrade_in_play, :android_is_upgrade_in_play,
52
+ :ios_is_rate_pop, :android_is_rate_pop, :ios_time_to_rate, :android_time_to_rate, :old_version_switch, :ios_is_you_mi, :android_is_you_mi, :weixin_share, :is_audit,
53
+ :pad_loading_icon_path
54
+
55
+ validates :title, :apple_appid, :name, :certificate_name, :presence => true
56
+ CONTENT_TYPES = {MUTI_BOZHU: 1, SINGLE_PERSON: 2, SINGLE_ALBUM: 3, MUTI_CATEGORY: 4, SINGLE_CATEGORY: 5, ALL_CATEGORY: 6}
57
+ # json:
58
+ # {
59
+ # id: app.id,
60
+ # title: app.title, # app名
61
+ # name: app.name, # app名
62
+ # content_type: app.content_type,
63
+ # app_icon_57_url: File.join(Settings.fdfs_root, app.app_icon_57_path), # app图标1
64
+ # app_icon_124_url: File.join(Settings.fdfs_root, app.app_icon_124_path), # app图标2
65
+ # loading_icon_320_url: picture_url('app_loading', app.loading_icon_path, '320'), # loading图标1
66
+ # loading_icon_640_960_url: picture_url('app_loading', app.loading_icon_path, '640_960'), # loading图标2
67
+ # loading_icon_640_1136_url: picture_url('app_loading', app.loading_icon_path, '640_1136'), # loading图标3
68
+ # loading_icon_480_url: picture_url('app_loading', app.loading_icon_path, '480'), # loading图标4
69
+ # loading_icon_1280_url: picture_url('app_loading', app.loading_icon_path, '1280'), # loading图标5
70
+ # talkingdata_iphone_key: app.talkingdata_iphone_key,
71
+ # talkingdata_android_key: app.talkingdata_android_key,
72
+ # duomeng_ios_key: app.duomeng_ios_key,
73
+ # duomeng_android_key: app.duomeng_android_key,
74
+ # apple_appid: app.apple_appid, # 苹果appid
75
+ # googlead_ios_key: app.googlead_ios_key,
76
+ # googlead_android_key: app.googlead_android_key,
77
+ # weixin_ios_key: app.weixin_ios_key,
78
+ # weixin_android_key: app.weixin_android_key,
79
+ # irateid: app.irateid,
80
+ # certificate_name: app.certificate_name
81
+ # }
82
+
83
+ #APP类型显示
84
+ def content_type_disp
85
+ case self.content_type
86
+ when 1
87
+ "多用户"
88
+ when 2
89
+ "单用户多专辑"
90
+ when 3
91
+ "单用户单专辑"
92
+ when 4
93
+ "多分类"
94
+ when 5
95
+ "单分类"
96
+ when 6
97
+ "全分类"
98
+ end
99
+ end
100
+
101
+ def envir_disp
102
+ case self.envir
103
+ when true
104
+ "测试"
105
+ when false
106
+ "开发"
107
+ end
108
+ end
109
+
110
+ end
@@ -0,0 +1,6 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class AppAd < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_app_ad' # 子App广告
5
+ attr_accessible :name, :description, :is_delete
6
+ end
@@ -0,0 +1,6 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class AppAdChangelog < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_app_ad_changelog' # 子App广告配置修改日志
5
+ attr_accessible :user, :op, :action
6
+ end
@@ -0,0 +1,6 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class AppAdMaterial < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_app_ad_material' # 子App广告物料关系
5
+ attr_accessible :ad_id, :material_id, :start_time, :end_time, :is_active
6
+ end
@@ -0,0 +1,16 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class AppAlbum < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_app_album' # 子App专辑
5
+
6
+ attr_accessible :album_id,
7
+ :app_id,
8
+ :uid,
9
+ :order_num,
10
+ :cover_path,
11
+ :album_title,
12
+ :album_intro
13
+
14
+ #belongs_to :app_bozhu,:foreign_key=>"uid"
15
+ #belongs_to :app
16
+ end
@@ -0,0 +1,20 @@
1
+ class AppBozhu < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = 'tb_app_bozhu'
4
+
5
+ attr_accessible :app_id,
6
+ :uid,
7
+ :bozhu_name,
8
+ :is_all_album,
9
+ :is_auto_update,
10
+ :order_num,
11
+ :bozhu_pic
12
+
13
+ # has_many :app_album
14
+ # belongs_to :app
15
+ # has_many :app_album,:association_foreign_key=>"uid", :limit=>Settings.per_page.app_album
16
+
17
+ def self.find_by_appid(appid, limit)
18
+ return AppBozhu.where(app_id: appid).page(limit[:page_id]).per(limit[:page_size]).order("order_num asc, created_at desc")
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class AppCategory < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_app_category' # 子App分类类型
5
+ attr_accessible :app_id, :category_id, :category_version, :is_all_tags, :order_num
6
+ end
@@ -0,0 +1,5 @@
1
+ class AppMaterial < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = 'tb_app_material' # 子App物料
4
+ attr_accessible :pic_url, :web_url, :name
5
+ end
@@ -0,0 +1,6 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class AppTag < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_app_tag' # 子App标签类型
5
+ attr_accessible :app_id, :tag_name, :is_all_albums, :order_num
6
+ end
@@ -0,0 +1,5 @@
1
+ class Font < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = 'tb_font' #字体包配置
4
+ attr_accessible :name, :url, :terminal, :color
5
+ end
@@ -0,0 +1,44 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class SelectedAlbums < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_selected_albums' # 子App分类类型
5
+ attr_accessible :title, :tags, :album_extra_tags, :extra_tags, :order_num, :cover_path, :category_id, :last_uptrack_at, :created_at, :updated_at
6
+
7
+ def self.get(selected_album_cache, id)
8
+ selected_album = selected_album_cache.get(id)
9
+ selected_album = self.where(id: id).first if selected_album.nil?
10
+ selected_album_cache.put(selected_album) unless selected_album.nil?
11
+ selected_album
12
+ end
13
+
14
+ def self.mget(selected_album_cache, ids)
15
+ selected_albums = selected_album_cache.multi_get(ids)
16
+ fetch_ids_hash= {}
17
+ fetch_ids = []
18
+ selected_albums.each_with_index do |selected_album, i|
19
+ if selected_album.nil?
20
+ fetch_ids << ids[i]
21
+ fetch_ids_hash[ids[i]] = i
22
+ end
23
+ end
24
+
25
+ if fetch_ids.length > 0
26
+ selected_albums_not_hit = self.find(fetch_ids)
27
+ cached_selected_albums = []
28
+
29
+ selected_albums_not_hit.each_with_index do |selected_album, i|
30
+ if !selected_album.nil?
31
+ selected_albums[fetch_ids_hash[selected_album.id]] = selected_album
32
+ cached_selected_albums << selected_album
33
+ end
34
+ end
35
+
36
+ selected_album_cache.multi_put(cached_selected_albums) if cached_selected_albums.length > 0
37
+ end
38
+ selected_albums
39
+ end
40
+
41
+ def self.disable_cache(selected_album_cache, id)
42
+ selected_album_cache.evict(id)
43
+ end
44
+ end
@@ -0,0 +1,29 @@
1
+ #-*- encoding: utf-8 -*-
2
+ class SelectedAlbumsRelation < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = 'tb_selected_albums_relation' # 子App分类类型
5
+ attr_accessible :selected_id, :album_id, :updated_at
6
+
7
+ def self.get_album_ids(list_ids_cache, selected_album, page, limit)
8
+ id = selected_album.id
9
+ album_ids = nil
10
+ if page == 1
11
+ album_ids = list_ids_cache.get(id, page, limit)
12
+ album_ids = album_ids.collect {|id| id.to_i unless id.nil? || id.empty?}
13
+ end
14
+
15
+ if album_ids.nil? || album_ids.length == 0
16
+ select = "album_id"
17
+ album_relations = self.select(select).where(:selected_id=>id).order("field(album_id,#{selected_album.order_num})").offset((page-1)*limit).limit(limit)
18
+ album_ids = album_relations.collect{|album_relation| album_relation.album_id unless album_relation.nil?}
19
+ if page == 1 && album_ids.length > 0
20
+ list_ids_cache.put(id, album_ids)
21
+ end
22
+ end
23
+ album_ids
24
+ end
25
+
26
+ def self.disable_cache(list_ids_cache, id)
27
+ list_ids_cache.evict(id)
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ class Skin < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = 'tb_skin' #皮肤包配置
4
+ attr_accessible :name, :url, :terminal, :size, :color
5
+ end
@@ -0,0 +1,7 @@
1
+ class SubAppAdvertisement < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = "tb_sub_app_advertisement" #子APP广告显示
4
+ attr_accessible :channel, :column_type, :link_url, :position, :sub_app_recommend_id, :terminal, :time_at
5
+
6
+ belongs_to :sub_app_recommend
7
+ end
@@ -0,0 +1,21 @@
1
+ class SubAppLog < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = "tb_sub_app_log" #子APP日志
4
+ attr_accessible :app_download_url, :app_id, :operator, :version, :certificate_name, :status, :backtrace, :device_type, :version_code
5
+
6
+ # status 1: 正在打包 2:打包成功 3:打包失败
7
+ # backtrace 打包日志
8
+ # device_type 1: iphone 2: ipad 3: android
9
+
10
+ def status_disp
11
+ case self.status
12
+ when 1
13
+ "打包中"
14
+ when 2
15
+ "打包成功"
16
+ when 3
17
+ "打包失败"
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+ class SubAppRecommend < ActiveRecord::Base
3
+ establish_connection SUBAPP_DB
4
+ self.table_name = "tb_sub_app_recommend" #子APP广告配置
5
+ attr_accessible :app_name, :channel, :column_type, :cover_path, :intro, :link_url, :name, :terminal, :is_deleted
6
+
7
+ has_many :sub_app_advertisements, dependent: :destroy
8
+ validates_uniqueness_of :name, message: "广告名称已经存在!"
9
+
10
+ def terminal_disp
11
+ case self.terminal
12
+ when 1
13
+ "ios"
14
+ when 2
15
+ "android"
16
+ else
17
+ ""
18
+ end
19
+ end
20
+
21
+ def channel_disp
22
+ case self.channel
23
+ when 1
24
+ "应用推荐"
25
+ when 2
26
+ "Feed广告"
27
+ else
28
+ ""
29
+ end
30
+ end
31
+
32
+ def is_deleted_disp
33
+ case self.is_deleted
34
+ when true
35
+ "是"
36
+ when false
37
+ "否"
38
+ else
39
+ ""
40
+ end
41
+ end
42
+
43
+ def column_type_disp
44
+ case self.column_type
45
+ when 1
46
+ "今日推荐"
47
+ when 2
48
+ "热门推荐"
49
+ when 3
50
+ "装机必备"
51
+ else
52
+ ""
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ class SubappPushApp < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = "tb_subapp_push_app" #子APP推送消息与子APP关联表
4
+ attr_accessible :msg_id, :subapp_id
5
+ end
@@ -0,0 +1,5 @@
1
+ class SubappPushMsg < ActiveRecord::Base
2
+ establish_connection SUBAPP_DB
3
+ self.table_name = "tb_subapp_push_msg" #子APP消息推送
4
+ attr_accessible :content, :link, :send_at, :terminal, :title
5
+ end
@@ -0,0 +1,3 @@
1
+ module SubappModel
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ require "subapp_model/version"
2
+
3
+ # load Rails/Railtie
4
+ begin
5
+ require 'rails'
6
+ rescue LoadError
7
+ #do nothing
8
+ end
9
+ # if not using Railtie, call `Kaminari::Hooks.init` directly
10
+ if defined? Rails
11
+ if (!defined? RAILS_APP_MODULE) || RAILS_APP_MODULE.nil?
12
+ %w{subapp_model}.each do |dir|
13
+ puts __FILE__
14
+ Dir.glob(File.expand_path("../#{dir}", __FILE__) + '/**/*.rb').each do |file|
15
+ puts file
16
+ require file
17
+ end
18
+ end
19
+ else
20
+ current_file = __FILE__
21
+ load_str = "module " + RAILS_APP_MODULE + "; class Application < Rails::Application; config.autoload_paths += [File.expand_path(\"../subapp_model\", \"#{current_file}\")]; end; end"
22
+ eval(load_str)
23
+ end
24
+ else
25
+ %w{subapp_model}.each do |dir|
26
+ Dir.glob(File.expand_path("../#{dir}", __FILE__) + '/**/*.rb').each do |file|
27
+ # if(file.index("home_controller") == nil)
28
+ # $LOAD_PATH.unshift(file)
29
+
30
+ require_file = File.basename(file, ".rb")
31
+ require_class = require_file.split('_').map {|w| w.capitalize}.join
32
+
33
+ # puts "#{require_class} : #{file}"
34
+
35
+ autoload "#{require_class}".to_sym,file
36
+ end
37
+ end
38
+ end
39
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subapp_model
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gavin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,7 +44,27 @@ email:
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
- files: []
47
+ files:
48
+ - lib/subapp_model.rb
49
+ - lib/subapp_model/app.rb
50
+ - lib/subapp_model/app_ad.rb
51
+ - lib/subapp_model/app_ad_changelog.rb
52
+ - lib/subapp_model/app_ad_material.rb
53
+ - lib/subapp_model/app_album.rb
54
+ - lib/subapp_model/app_bozhu.rb
55
+ - lib/subapp_model/app_category.rb
56
+ - lib/subapp_model/app_material.rb
57
+ - lib/subapp_model/app_tag.rb
58
+ - lib/subapp_model/font.rb
59
+ - lib/subapp_model/selected_albums.rb
60
+ - lib/subapp_model/selected_albums_relation.rb
61
+ - lib/subapp_model/skin.rb
62
+ - lib/subapp_model/sub_app_advertisement.rb
63
+ - lib/subapp_model/sub_app_log.rb
64
+ - lib/subapp_model/sub_app_recommend.rb
65
+ - lib/subapp_model/subapp_push_app.rb
66
+ - lib/subapp_model/subapp_push_msg.rb
67
+ - lib/subapp_model/version.rb
48
68
  homepage: ''
49
69
  licenses:
50
70
  - MIT