From f38e01edaf1760727b6fb1c8def68e7cf8896c3f Mon Sep 17 00:00:00 2001 From: jasder Date: Tue, 11 May 2021 18:17:17 +0800 Subject: [PATCH 01/12] =?UTF-8?q?FIX=20*=E4=B8=80=E7=BA=A7=E6=9D=BF?= =?UTF-8?q?=E5=9D=97=E5=8F=AF=E4=BB=A5=E6=9F=A5=E7=9C=8B=E5=B8=96=E5=AD=90?= =?UTF-8?q?=20*=20=E6=9D=BF=E5=9D=97=E7=AE=A1=E7=90=86=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E5=B8=96=E5=AD=90=E6=B7=BB=E5=8A=A0=E8=B6=85?= =?UTF-8?q?=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/forum_sections_service.rb | 12 ++++++------ app/services/memos_service.rb | 10 +++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/services/forum_sections_service.rb b/app/services/forum_sections_service.rb index fdfb14ac..3317a37b 100644 --- a/app/services/forum_sections_service.rb +++ b/app/services/forum_sections_service.rb @@ -364,7 +364,7 @@ class ForumSectionsService return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id]) select_section_ids = [params[:id]] unless @forum_section.parent_id.present? - children_forums = @forum_section.children_forum.pluck(:id) + children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums end select_section_ids.uniq @@ -389,7 +389,7 @@ class ForumSectionsService else memo_min_sections = memo.memo_forums.first end - memo_last_section = memo_min_sections.forum_section + memo_last_section = memo_min_sections&.forum_section memo_list = { memo_id: memo.id, @@ -416,7 +416,7 @@ class ForumSectionsService select_section_ids = [params[:id]] unless @forum_section.parent_id.present? - children_forums = @forum_section.children_forum.pluck(:id) + children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums end select_section_ids.uniq @@ -462,7 +462,7 @@ class ForumSectionsService select_section_ids = [params[:id]] unless @forum_section.parent_id.present? - children_forums = @forum_section.children_forum.pluck(:id) + children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums end select_section_ids.uniq @@ -473,7 +473,7 @@ class ForumSectionsService offset = page * LIMIT #全部的父帖子 memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq - memos_all = Memo.where(hidden: false,parent_id: nil, id: memo_forum_section_ids).order("created_at desc") + memos_all = Memo.where(hidden: false,parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") # memos_all = Memo.where(hidden: false, parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})") if params[:type].present? if params[:type] == "sticky" @@ -499,7 +499,7 @@ class ForumSectionsService else memo_min_sections = memo.memo_forums.first end - memo_last_section = memo_min_sections.forum_section + memo_last_section = memo_min_sections&.forum_section memo_list = { memo_id: memo.id, diff --git a/app/services/memos_service.rb b/app/services/memos_service.rb index 28e2b236..11742cdf 100644 --- a/app/services/memos_service.rb +++ b/app/services/memos_service.rb @@ -596,7 +596,14 @@ class MemosService page = params[:page].to_i > 0 ? (params[:page].to_i - 1) : 0 offset = page * LIMIT - all_memos = forum_section.memos.posts + all_memos = + if forum_section.is_root? + forum_section_ids = forum_section.child_ids << forum_section.id + Rails.logger.info "######### forum_section_ids: #{forum_section_ids}" + Memo.where(forum_section_id: forum_section_ids) + else + forum_section.memos.posts + end select_type = params[:select_type] case select_type.to_s when "is_fine" @@ -729,6 +736,7 @@ class MemosService def check_banned_permission current_user, memo_id + return true if current_user&.admin? forum_id = MemoForum&.where(is_children: false, memo_id: memo_id)&.first.try(:forum_id).to_s user_banned_permission current_user, forum_id end From 529e8e5fe6f1a00d3c5b9c3c744c222c31093d0b Mon Sep 17 00:00:00 2001 From: jasder Date: Tue, 11 May 2021 18:20:59 +0800 Subject: [PATCH 02/12] =?UTF-8?q?FIX=20=E4=B8=80=E7=BA=A7=E6=9D=BF?= =?UTF-8?q?=E5=9D=97=E5=8A=A0=E8=BD=BD=E5=B8=96=E5=AD=90=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/forum_sections_service.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/forum_sections_service.rb b/app/services/forum_sections_service.rb index 3317a37b..951e181d 100644 --- a/app/services/forum_sections_service.rb +++ b/app/services/forum_sections_service.rb @@ -366,7 +366,7 @@ class ForumSectionsService unless @forum_section.parent_id.present? children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums - end + #end select_section_ids.uniq # page = params[:page].to_i @@ -418,7 +418,7 @@ class ForumSectionsService unless @forum_section.parent_id.present? children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums - end + # end select_section_ids.uniq # page = params[:page].to_i @@ -461,10 +461,10 @@ class ForumSectionsService return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id]) select_section_ids = [params[:id]] - unless @forum_section.parent_id.present? + # unless @forum_section.parent_id.present? children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums - end + # end select_section_ids.uniq # page = params[:page].to_i From 9f8a55fe1250d2a6c1af346c46e8d41bc9ca4300 Mon Sep 17 00:00:00 2001 From: jasder Date: Tue, 11 May 2021 18:23:20 +0800 Subject: [PATCH 03/12] FIX code bug --- app/services/forum_sections_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/forum_sections_service.rb b/app/services/forum_sections_service.rb index 951e181d..ffc548cd 100644 --- a/app/services/forum_sections_service.rb +++ b/app/services/forum_sections_service.rb @@ -363,7 +363,7 @@ class ForumSectionsService set_forum_section(params[:id]) return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id]) select_section_ids = [params[:id]] - unless @forum_section.parent_id.present? + # unless @forum_section.parent_id.present? children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums #end @@ -374,7 +374,7 @@ class ForumSectionsService offset = page * LIMIT memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq - memos_all = Memo.where(hidden:true, published_at: nil, parent_id: nil, id: memo_forum_section_ids).order("created_at desc") + memos_all = Memo.where(hidden:true, published_at: nil, parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") # memos_all = Memo.where(hidden: true, parent_id: nil, id: memo_forum_section_ids).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})").order("created_at desc") memos_count = memos_all.size From 273a17861b476d095cb1509a3c5bd550fede1c2b Mon Sep 17 00:00:00 2001 From: jasder Date: Tue, 11 May 2021 18:29:09 +0800 Subject: [PATCH 04/12] FIX bug --- app/services/forum_sections_service.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/services/forum_sections_service.rb b/app/services/forum_sections_service.rb index ffc548cd..d8534012 100644 --- a/app/services/forum_sections_service.rb +++ b/app/services/forum_sections_service.rb @@ -373,7 +373,7 @@ class ForumSectionsService page = params[:page].to_i > 0 ? (params[:page].to_i - 1) : 0 offset = page * LIMIT - memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq + # memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq memos_all = Memo.where(hidden:true, published_at: nil, parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") # memos_all = Memo.where(hidden: true, parent_id: nil, id: memo_forum_section_ids).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})").order("created_at desc") @@ -415,7 +415,7 @@ class ForumSectionsService return {status: -1, message: "请登录"} unless check_user_permission(current_user, params[:id]) select_section_ids = [params[:id]] - unless @forum_section.parent_id.present? + # unless @forum_section.parent_id.present? children_forums = @forum_section.child_ids select_section_ids = select_section_ids + children_forums # end @@ -427,7 +427,8 @@ class ForumSectionsService offset = page * LIMIT #全部的父帖子 parent_memos_ids = Memo.where(parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})").pluck(:id).uniq - memos_all = Memo.where(hidden:true,published_at: nil, parent_id: parent_memos_ids).order("created_at ASC") + # memos_all = Memo.where(hidden:true,published_at: nil, parent_id: parent_memos_ids).order("created_at ASC") + memos_all = Memo.where(hidden:true, published_at: nil, parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") memos_count = memos_all.size memos = memos_all.limit(LIMIT).offset(offset) @@ -472,7 +473,7 @@ class ForumSectionsService offset = page * LIMIT #全部的父帖子 - memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq + # memo_forum_section_ids = MemoForum.where(forum_id: select_section_ids).pluck(:memo_id).uniq memos_all = Memo.where(hidden: false,parent_id: nil, forum_section_id: select_section_ids).order("created_at desc") # memos_all = Memo.where(hidden: false, parent_id: nil).joins(:memo_forums).where("memo_forums.forum_id in (#{select_section_ids.join(",")})") if params[:type].present? From 21b55eba83b3f07784790e8b02f0bc126ebcfa1d Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 12 May 2021 14:25:46 +0800 Subject: [PATCH 05/12] =?UTF-8?q?ADD=20=E7=89=88=E5=9D=97=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=88=E4=BA=88=E5=B9=B3=E5=8F=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/api_index_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/api_index_helper.rb b/app/helpers/api_index_helper.rb index 5138b303..f368f155 100644 --- a/app/helpers/api_index_helper.rb +++ b/app/helpers/api_index_helper.rb @@ -186,6 +186,7 @@ module ApiIndexHelper end def user_banned_permission current_user, forum_id + return true if current_user&.admin? if current_user.present? if forum_id.present? user_forum_moder = ForumModerator.where(forum_section_id: forum_id,user_id: current_user.id).exists? From f941976a78e07cd01dfb65ed6cb07eab8cec24b0 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 11 Nov 2021 17:44:02 +0800 Subject: [PATCH 06/12] fix: add memos read data not increment view count --- app/services/memos_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/memos_service.rb b/app/services/memos_service.rb index 11742cdf..1d9ac5f7 100644 --- a/app/services/memos_service.rb +++ b/app/services/memos_service.rb @@ -130,7 +130,7 @@ class MemosService :filesize => memo_image.filesize} if memo_image user_praise = PraiseTread.is_user_praise(memo.id, "Memo", current_user.try(:id)).exists? - memo.update_column(:viewed_count, memo.viewed_count + 1) + memo.update_column(:viewed_count, memo.viewed_count + 1) if params[:only_data].blank? # 帖子的回复 memos = memo.reply_for_memo unless current_user.try(:admin?) # 只有管理员和发布人能看到隐藏的回复 From b5f161f5535ab8524fbe4c2fd49547ef2e9e8c5e Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Wed, 24 Nov 2021 10:39:18 +0800 Subject: [PATCH 07/12] =?UTF-8?q?fix=20=E9=A6=96=E9=A1=B5=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/laboratory_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index 426d1a33..3f7bdf07 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -41,7 +41,7 @@ module LaboratoryHelper my_courses: "https://www.trustie.net/users/#{current_user.try(:login)}/user_courselist", my_projects: "https://forgeplus.trustie.net/users/#{current_user.try(:login)}/projects", my_organ: "https://www.trustie.net/users/#{current_user.try(:login)}/user_organizations", - default_url: "https://www.trustie.net/", + default_url: Rails.application.config_for(:configuration)['platform_url'], tiding_url: "https://www.trustie.net/users/#{current_user.try(:login)}/user_messages", register_url: "https://www.trustie.net/login?login=false" } From 53c65e9ee959521dcf4c43af3cc1a9bce02307e4 Mon Sep 17 00:00:00 2001 From: xiaoxiaoqiong Date: Wed, 24 Nov 2021 11:38:52 +0800 Subject: [PATCH 08/12] =?UTF-8?q?fix=20=E5=9F=9F=E5=90=8D=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/laboratory_helper.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index 3f7bdf07..0c0c79fa 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -35,15 +35,15 @@ module LaboratoryHelper # my_projects: "/users/#{current_user.try(:login)}/projects", # my_projects: "https://www.trustie.net/users/#{current_user.try(:login)}/user_projectlist", { - new_syllabuses: "https://www.trustie.net/syllabuses/new", - new_course: "https://www.trustie.net/courses/new", - edit_account: "https://www.trustie.net/my/account", - my_courses: "https://www.trustie.net/users/#{current_user.try(:login)}/user_courselist", - my_projects: "https://forgeplus.trustie.net/users/#{current_user.try(:login)}/projects", - my_organ: "https://www.trustie.net/users/#{current_user.try(:login)}/user_organizations", + new_syllabuses: "#{Rails.application.config_for(:configuration)['platform_url']}/syllabuses/new", + new_course: "#{Rails.application.config_for(:configuration)['platform_url']}/courses/new", + edit_account: "#{Rails.application.config_for(:configuration)['platform_url']}/my/account", + my_courses: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/user_courselist", + my_projects: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/projects", + my_organ: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/user_organizations", default_url: Rails.application.config_for(:configuration)['platform_url'], - tiding_url: "https://www.trustie.net/users/#{current_user.try(:login)}/user_messages", - register_url: "https://www.trustie.net/login?login=false" + tiding_url: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/user_messages", + register_url: "#{Rails.application.config_for(:configuration)['platform_url']}/login?login=false" } end end From e28ac9c319e76615e53bdb129d0293ff6b7f822a Mon Sep 17 00:00:00 2001 From: viletyy Date: Wed, 24 Nov 2021 14:43:25 +0800 Subject: [PATCH 09/12] add: settings personal add common --- app/controllers/settings_controller.rb | 51 +++++++++++++++++ app/models/site.rb | 79 ++++++++++++++++++++++++++ app/views/settings/show.json.jbuilder | 9 +++ 3 files changed, 139 insertions(+) create mode 100644 app/models/site.rb diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index bb031c7b..37fc47a6 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -2,5 +2,56 @@ class SettingsController < ApplicationController def show @old_projects_url = nil @old_projects_url = "https://www.trustie.net/users/#{current_user.try(:login)}/projects" if User.current.logged? + get_add_menu + get_common_menu + get_personal_menu + end + + private + def get_add_menu + @add = [] + Site.add.select(:id, :name, :url, :key).to_a.map(&:serializable_hash).each do |site| + hash = {} + site.each {|k, v| + hash.merge!("#{k}": get_site_url(k, v)) + } + @add << hash + end + end + + def get_common_menu + @common = {} + Site.common.select(:url, :key).each do |site| + next if site["url"].to_s.include?("current_user") && !User.current.logged? + @common.merge!("#{site["key"]}": append_http(reset_site_url(site["url"]))) + end + end + + def get_personal_menu + @personal = [] + if User.current.logged? + Site.personal.select(:id, :name, :url, :key).to_a.map(&:serializable_hash).each do |site| + hash = {} + site.each {|k, v| + hash.merge!("#{k}": get_site_url(k, v)) + } + @personal << hash + end + end + end + + def get_site_url(key, value) + key.to_s === "url" ? append_http(reset_site_url(value)) : reset_site_url(value) + end + + def reset_site_url(url) + return url unless url.to_s.include?("current_user") + + split_arr = url.split('current_user') + split_arr.length > 1 ? split_arr.join(current_user&.login) : (split_arr << current_user&.login).join('') + end + + def append_http(url) + url.to_s.start_with?("http") ? url : [request.protocol, request.host_with_port, url].join('') end end diff --git a/app/models/site.rb b/app/models/site.rb new file mode 100644 index 00000000..af5e7816 --- /dev/null +++ b/app/models/site.rb @@ -0,0 +1,79 @@ +# == Schema Information +# +# Table name: sites +# +# id :integer not null, primary key +# name :string(255) +# url :string(255) +# key :string(255) +# site_type :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +class Site < ApplicationRecord + # add: 添加类链接 + # personal: 个人名下类链接, + # common: 普通链接 + enum site_type: { add: 0, personal: 1, common: 2 } + + scope :by_search, -> (keyword){ where("name LIKE :keyword OR url LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? } + scope :by_site_type, -> (site_type){ where(site_type: strip_param(site_type)) unless strip_param(site_type).blank? } + + def self.set_default_menu + set_add_menu! + set_personal_menu! + set_common_menu! + end + + def self.has_notice_menu? + self.common.where(key: 'notice').present? + end + + private + def self.set_add_menu! + adds= [ + {name: '新建项目', key: 'add_mirror_project', url: '/projects/mirror/new'}, + {name: '导入项目', key: 'add_common', url: '/projects/deposit/new'}, + {name: '新建组织', key: 'add_r', url: '/organize/new'}] + + adds.each { |ele| + Site.find_or_create_by(key: ele[:key]) do |site| + site.name = ele[:name] + site.url = ele[:url] + site.site_type = Site.site_types[:add] + end + } + end + + def self.set_personal_menu! + personals = [ + {name: '个人中心', key: 'my_page', url: '/users/current_user'}, + {name: '我的组织', key: 'my_organizes', url: '/users/current_user/organizes'} + ] + + personals.each { |ele| + Site.find_or_create_by(key: ele[:key]) do |site| + site.name = ele[:name] + site.url = ele[:url] + site.site_type = Site.site_types[:personal] + end + } + end + + def self.set_common_menu! + commons = [ + {name: '通知', key: 'notice', url: '/users/current_user/user_messages'}, + {name: '找回密码', key: 'lost_password', url: '/account/lost_password'}, + {name: '注册', key: 'register', url: '/login?login=false'} + ] + + commons.each { |ele| + Site.find_or_create_by(key: ele[:key]) do |site| + site.name = ele[:name] + site.url = ele[:url] + site.site_type = Site.site_types[:common] + end + } + end +end diff --git a/app/views/settings/show.json.jbuilder b/app/views/settings/show.json.jbuilder index 8f818b47..58af296d 100644 --- a/app/views/settings/show.json.jbuilder +++ b/app/views/settings/show.json.jbuilder @@ -48,4 +48,13 @@ json.setting do json.old_projects_url @old_projects_url + json.add do + json.array! @add + end + + json.personal do + json.array! @personal + end + + json.common @common end \ No newline at end of file From f60ba8ec0765a808527921d91fba515de6534f29 Mon Sep 17 00:00:00 2001 From: viletyy Date: Wed, 24 Nov 2021 15:44:53 +0800 Subject: [PATCH 10/12] fix: change website ico --- public/favicon.ico | Bin 10415 -> 9662 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/favicon.ico b/public/favicon.ico index 75a4c3dfd46656c981907ac9d82ddce23c622d7f..ad428fa2500982875766a813ca09f3a571751a72 100644 GIT binary patch literal 9662 zcmds+eQZ=^7RIkgr?X`!P)BXBma*Cq=Dc@~1CXlg3>|&x>ElP}h6hu^#javu=WE+DB{ACc^(kZp?v**0`WA4X$r%Shk z><*cpxnJ-7&6($Y&bcp|b_4w@EY#?4MEl#XH0>5m)AH#}yR@bB=Kb>ZOFg9WFOHOC z=IhwI?>hV&1RqF8-i=Xs^gAX>j$42M?kyL) z3V>Y&OMVV!`#p9365!bUD#w2I&(D7gq0o=mJ)=YH`t>#C2j0;{Pg%gu$e-~w=YPJM zpZ#CKkKHqg-#`Co&&xzC5^~?`zu6}KarjqRrh5#X-zWb@{c_J=J^xAhbBRCOeXnHO zzzbPPkDq@gL!2)MzAdZ6>F2E9VKn-o{O=T%KP zG^E{!`m}o>Y8o-Lavo4^vDvSOe`9J9OPpKaje@9*o zcHB{lwwz%VKemP?8ydqQtPM7yA<&G~GK&&1Q)J?cW4A($hsfHMM78t1d zD^MFW89CbWuizg+{|B7@>8F3uaR)?uE+l_jLOgXK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(vJtcs>0Mz Date: Wed, 24 Nov 2021 18:33:31 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E9=93=83=E9=93=9BURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/laboratory_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index 0c0c79fa..11659fc3 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -42,7 +42,7 @@ module LaboratoryHelper my_projects: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/projects", my_organ: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/user_organizations", default_url: Rails.application.config_for(:configuration)['platform_url'], - tiding_url: "#{Rails.application.config_for(:configuration)['platform_url']}/users/#{current_user.try(:login)}/user_messages", + tiding_url: "#{Rails.application.config_for(:configuration)['platform_url']}/settings/notice", register_url: "#{Rails.application.config_for(:configuration)['platform_url']}/login?login=false" } end From d4e59e87739c3cd64af4f031a920b850bbbe07c9 Mon Sep 17 00:00:00 2001 From: viletyy Date: Thu, 25 Nov 2021 16:59:17 +0800 Subject: [PATCH 12/12] fix: change attachment code --- app/controllers/attachments_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3c5c73b8..ecbedc3a 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -97,29 +97,37 @@ class AttachmentsController < ApplicationController upload_file = params["file"] || params["#{params[:file_param_name]}"]# 这里的file_param_name是为了方便其他插件名称 raise "未上传文件" unless upload_file - folder = edu_setting('attachment_folder') + folder = file_storage_directory raise "存储目录未定义" unless folder.present? month_folder = current_month_folder save_path = File.join(folder, month_folder) - ext = SecureRandom.urlsafe_base64 + ext = file_ext(upload_file.original_filename) local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext) content_type = upload_file.content_type.presence || 'application/octet-stream' + remote_path = nil # TODO 暂时本地上传,待域名配置后方可上传至云端 + + logger.info "local_path: #{local_path}" + logger.info "remote_path: #{remote_path}" disk_filename = local_path[save_path.size + 1, local_path.size] - @attachment = Attachment.where(disk_filename: disk_filename,author_id: current_user.id).first + @attachment = Attachment.where(disk_filename: disk_filename, + author_id: current_user.id, + cloud_url: remote_path).first + if @attachment.blank? @attachment = Attachment.new @attachment.filename = upload_file.original_filename - @attachment.disk_filename = disk_filename + @attachment.disk_filename = local_path[save_path.size + 1, local_path.size] @attachment.filesize = upload_file.tempfile.size @attachment.content_type = content_type @attachment.digest = digest @attachment.author_id = current_user.id @attachment.disk_directory = month_folder + @attachment.cloud_url = remote_path @attachment.save! @status = 1 else