subapp_model 1.0.6 → 1.0.7

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: 8c4e37b62f59e44df0dff7ecd7c4487ace085e21
4
- data.tar.gz: 90fde64dd337062584c38355201cb994d607c811
3
+ metadata.gz: f970fd3323a760c8feaaa3a082fd28f4f535789d
4
+ data.tar.gz: 351dbb56f7fa997931e33a0c57edff1d0b2d3617
5
5
  SHA512:
6
- metadata.gz: eea0c46e88c59b3dd0b49728cc17aacaa2f5ec4eee0261dd9688a50386d57d9dbbdbae3b62d7291180e6978468a6b6550f2f998320c2e3d3b4156bbf059712d1
7
- data.tar.gz: 72cf3146872bdf44c1421dd9aef3227e404fac76c7f9e4708c9cf58bc72425503501900b988dd8ea86217941d78fb9ae44c1ec3643e92ef42cae0014792ff363
6
+ metadata.gz: 58d1d011d89334ecabb4dc4e11beedc45e60075813c2468851581af354433959dda00a62350ebb4143525b54456fa0bace1184f6703b67feb2ec3daade255588
7
+ data.tar.gz: 78e58fa512e3d62e0c0941d19dda3f27b2fd89ca52051eb253511378f221fed16676a28215f2f51da0bb1e35af97d3910bb9225ac29cc701da401381f90662db
@@ -0,0 +1,113 @@
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, :ios_icon_72_path, :ios_icon_144_path, :ios_icon_76_path, :ios_icon_152_path, :pack_type, :init, :ios_is_audit_bookstore, :ios_is_banner,
54
+ :ios_is_audit_banner, :ios_ad_num, :and_ad_num,
55
+ :bookstore_type, #书城类型,1.全分类,2.单分类
56
+ :category_id #书城分类id
57
+
58
+ validates :title, :apple_appid, :name, :certificate_name, :presence => true
59
+ CONTENT_TYPES = {MUTI_BOZHU: 1, SINGLE_PERSON: 2, SINGLE_ALBUM: 3, MUTI_CATEGORY: 4, SINGLE_CATEGORY: 5, ALL_CATEGORY: 6}
60
+ # json:
61
+ # {
62
+ # id: app.id,
63
+ # title: app.title, # app名
64
+ # name: app.name, # app名
65
+ # content_type: app.content_type,
66
+ # app_icon_57_url: File.join(Settings.fdfs_root, app.app_icon_57_path), # app图标1
67
+ # app_icon_124_url: File.join(Settings.fdfs_root, app.app_icon_124_path), # app图标2
68
+ # loading_icon_320_url: picture_url('app_loading', app.loading_icon_path, '320'), # loading图标1
69
+ # loading_icon_640_960_url: picture_url('app_loading', app.loading_icon_path, '640_960'), # loading图标2
70
+ # loading_icon_640_1136_url: picture_url('app_loading', app.loading_icon_path, '640_1136'), # loading图标3
71
+ # loading_icon_480_url: picture_url('app_loading', app.loading_icon_path, '480'), # loading图标4
72
+ # loading_icon_1280_url: picture_url('app_loading', app.loading_icon_path, '1280'), # loading图标5
73
+ # talkingdata_iphone_key: app.talkingdata_iphone_key,
74
+ # talkingdata_android_key: app.talkingdata_android_key,
75
+ # duomeng_ios_key: app.duomeng_ios_key,
76
+ # duomeng_android_key: app.duomeng_android_key,
77
+ # apple_appid: app.apple_appid, # 苹果appid
78
+ # googlead_ios_key: app.googlead_ios_key,
79
+ # googlead_android_key: app.googlead_android_key,
80
+ # weixin_ios_key: app.weixin_ios_key,
81
+ # weixin_android_key: app.weixin_android_key,
82
+ # irateid: app.irateid,
83
+ # certificate_name: app.certificate_name
84
+ # }
85
+
86
+ #APP类型显示
87
+ def content_type_disp
88
+ case self.content_type
89
+ when 1
90
+ "多用户"
91
+ when 2
92
+ "单用户多专辑"
93
+ when 3
94
+ "单用户单专辑"
95
+ when 4
96
+ "多分类"
97
+ when 5
98
+ "单分类"
99
+ when 6
100
+ "全分类"
101
+ end
102
+ end
103
+
104
+ def envir_disp
105
+ case self.envir
106
+ when true
107
+ "测试"
108
+ when false
109
+ "开发"
110
+ end
111
+ end
112
+
113
+ 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.7"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subapp_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - gavin
@@ -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