diff --git a/app/controllers/admins/laboratory_settings_controller.rb b/app/controllers/admins/laboratory_settings_controller.rb index d522a479b..681965f7c 100644 --- a/app/controllers/admins/laboratory_settings_controller.rb +++ b/app/controllers/admins/laboratory_settings_controller.rb @@ -23,7 +23,7 @@ class Admins::LaboratorySettingsController < Admins::BaseController def form_params params.permit(:identifier, :name, - :nav_logo, :login_logo, :tab_logo, :oj_banner, + :nav_logo, :login_logo, :tab_logo, :oj_banner, :index_logo, :subject_banner, :course_banner, :competition_banner, :moop_cases_banner, :footer, navbar: %i[name link hidden index]) end diff --git a/app/controllers/admins/topics_controller.rb b/app/controllers/admins/topics_controller.rb new file mode 100644 index 000000000..ffdc63175 --- /dev/null +++ b/app/controllers/admins/topics_controller.rb @@ -0,0 +1,76 @@ +class Admins::TopicsController < Admins::Topic::BaseController + before_action :require_business + before_action :find_topic, only: [:edit, :update, :destroy, :show] + + def index + scope = ::Topic.with_mutil_type(params[:topic_type]) + scope = scope.where(location: params[:location]) if params[:location].present? + scope = scope.where(type: params[:type]) if params[:type].present? + scope = scope.ransack(title_cont: params[:search]) + topics = scope.result(distinct: true) + @topics = paginate(topics) + end + + def new + @topic = ::Topic.new + end + + def create + @topic = topic_model.new(topic_params) + params[:topic_type] = @topic.type_group_name + if @topic.save + save_image_file(params[:image], @topic) if params[:image].present? + redirect_to admins_topics_path(topic_type: params[:topic_type]) + flash[:success] = "新增成功" + else + redirect_to admins_topics_path(topic_type: params[:topic_type]) + flash[:danger] = "新增失败" + end + end + + def show + end + + def edit + end + + def update + @topic.attributes = topic_params + if @topic.save! + save_image_file(params[:image], @topic) if params[:image].present? + redirect_to admins_topics_path(topic_type: params[:topic_type]) + flash[:success] = "更新成功" + return + else + redirect_to admins_topics_path(topic_type: params[:topic_type]) + flash[:danger] = "更新失败" + return + end + end + + def destroy + if @topic.destroy + redirect_to admins_topics_path(topic_type: params[:topic_type]) + flash[:success] = "删除成功" + else + redirect_to admins_topics_path(topic_type: params[:topic_type]) + flash[:danger] = "删除失败" + end + end + + private + + def find_topic + @topic = topic_model.find(params[:id]) + params[:topic_type] = @topic.type_group_name + end + + def topic_model + ::Topic + end + + def topic_params + params.require(:topic).permit(:type, :title, :uuid, :url, :order_index, + :location, :identifier, :labels, :description, :date) + end +end \ No newline at end of file diff --git a/app/controllers/competition_infos_controller.rb b/app/controllers/competition_infos_controller.rb index c762451b8..036f60f17 100644 --- a/app/controllers/competition_infos_controller.rb +++ b/app/controllers/competition_infos_controller.rb @@ -136,6 +136,14 @@ class CompetitionInfosController < ApplicationController end if params[:apply_status].present? competition_users = competition_users.where(ext3: params[:apply_status].to_s.split(",")) + else + if ["yys2025", "tzb2025"].include?(@competition_info.identifier) + if params[:type]=="un_file" + competition_users = competition_users.where("leader is not null and phone is not null and org_name is not null") + else + competition_users = competition_users.where("competition_users.enroll_template_id is not null") + end + end end if params[:upload].to_s == "true" # competition_users = competition_users.joins("join attachments on attachments.container_type='CompetitionUser' and attachments.container_id = competition_users.id") @@ -159,7 +167,7 @@ class CompetitionInfosController < ApplicationController enroll_fields = @competition_info.enroll_fields enroll_fields = enroll_fields.delete_if { |key, value| ["sub_item", "works_name", "works_url"].include?(value) } if params[:upload].to_s != "true" @table_columns = enroll_fields.keys - @table_columns = @table_columns + %w(参赛报名表下载链接) + # @table_columns = @table_columns + %w(参赛报名表下载链接) @table_columns = @table_columns + %w(作品下载链接) if params[:upload].to_s == "true" && !enroll_fields.values.include?("works_url") @table_columns = @table_columns + %w(申请表下载链接) if params[:apply_status].present? @table_columns = @table_columns + %w(bm审查下载链接) if @competition_info.identifier == "KXSYSJ-2024" && params[:upload].to_s == "true" @@ -171,8 +179,8 @@ class CompetitionInfosController < ApplicationController competition_users.each do |u| info_array = [] file_array = [] - file = Attachment.where_id_or_uuid(u.enroll_template_id).first - file_array = file_array + [file.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(file)}"] + # file = Attachment.where_id_or_uuid(u.enroll_template_id).first + # file_array = file_array + [file.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(file)}"] if params[:upload].to_s == "true" && !enroll_fields.values.include?("works_url") file_array = file_array + [u.attachments.blank? ? "" : "#{EduSetting.get('host_name')}/#{download_url(u.attachments.first)}"] end @@ -321,6 +329,7 @@ class CompetitionInfosController < ApplicationController competition_user.members = params[:members] competition_user.status = 1 competition_user.status = 2 if @competition_info.identifier.include?("qz202") + competition_user.status = 2 if @competition_info.identifier.include?("tzb2025") competition_user.save render_ok end @@ -332,6 +341,7 @@ class CompetitionInfosController < ApplicationController competition_user.members = params[:members] competition_user.status = 1 competition_user.status = 2 if @competition_info.identifier.include?("qz202") + competition_user.status = 2 if @competition_info.identifier.include?("tzb2025") competition_user.save render_ok end @@ -346,7 +356,16 @@ class CompetitionInfosController < ApplicationController def upload_apply_template competition_user = CompetitionUser.find_by(competition_info: @competition_info.id, user_id: current_user.id) - tip_exception "未报名,请先报名" if competition_user.blank? + # tip_exception "未报名,请先报名" if competition_user.blank? + if competition_user.blank? && ["yys2025", "tzb2025"].include?(@competition_info.identifier) + competition_user = CompetitionUser.new + competition_user.competition_info = @competition_info + competition_user.user = current_user + competition_user.status = 2 + competition_user.save + else + tip_exception "未报名,请先报名" unless competition_user.present? + end tip_exception "附件参数apply_template_id不能为空" if params[:apply_template_id].blank? competition_user.update_attributes!(ext2: params[:apply_template_id], ext3: 1) render_ok @@ -481,6 +500,18 @@ class CompetitionInfosController < ApplicationController end end + def tzb_actived + tip_exception "请输入激活码" if params[:code].blank? + SyncCompetitionTzbUserJob.perform_later("code") + tzb_user = CompetitionTzbUser.find_by(activation_code: params[:code]) + tip_exception "激活码正在同步确认中,请稍后再试" if tzb_user.blank? + tip_exception "激活码正在同步确认中,请稍后再试" if tzb_user.user_id.blank? + user = User.find_by(id: tzb_user.user_id) + successful_authentication(user) + tzb_user.update_attributes!(actived: true) + render_ok({ user: { login: user.login, mail: user.mail, password: tzb_user.pwd } }) + end + def destroy if @competition_info.destroy! flash[:success] = '删除成功' diff --git a/app/jobs/sync_competition_tzb_user_job.rb b/app/jobs/sync_competition_tzb_user_job.rb new file mode 100644 index 000000000..ab4af2866 --- /dev/null +++ b/app/jobs/sync_competition_tzb_user_job.rb @@ -0,0 +1,69 @@ +class SyncCompetitionTzbUserJob < ApplicationJob + queue_as :default + + def perform(code=nil) + url = EduSetting.get("SyncCompetitionTzbUserUrl") || "https://2025.tiaozhanbei.net/api/v1/ai_contest/3579510184/project_list/" + uri = URI.parse(url) + http = Net::HTTP.new(uri.hostname, uri.port) + if uri.scheme == 'https' + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + http.use_ssl = true + end + response = http.send_request('GET', uri.path, nil, {'Content-Type' => 'application/json','Authorization' => 'Bearer sk-CQ5oe9UI14nlwYnMtsNV4MBMDLwQ67bQXIa2fDy5m0bSQ5Ts'}) + # Rails.logger.info("SyncCompetitionTzbUserJob body===#{response.body}") + result = JSON.parse(response.body) +# data = '{"Code":"Ok","Message":"成功","Data":[{"corp_id":123456,"match_id":666,"user_uid":"uid_y0gqNR3EesqZVgA", +# "project_pid":"pid_123001","activation_code":"V2nyoEYzl2zRaVySpldc","project_status":"not_finished", +# "project_status_text":"未提交","status_level":"school","status_level_text":"校级","school_code":"10003", +# "school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_JHnTBdt8GA3tziq","project_pid":"pid_123002","activation_code":"nde8u5HNQ7qqXjkBIQG0","project_status":"submit_to","project_status_text":"已提交","status_level":"school","status_level_text":"校级","school_code":"10003","school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_2tCNcoKX8T8oHvk","project_pid":"pid_123003","activation_code":"iZQCh3mfuJ8ESrUPwGRo","project_status":"pass_by","project_status_text":"审核通过","status_level":"school","status_level_text":"校级","school_code":"10001","school_name":"北京大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_DziaXaNTkyS1M05","project_pid":"pid_123004","activation_code":"c42BKyehYWAxeAqjLdc8","project_status":"not_pass_by","project_status_text":"审核未通过","status_level":"province","status_level_text":"省级","school_code":"10001","school_name":"北京大学","province_name":"北京"}]}' +# result = JSON.parse(data) + Rails.logger.info("SyncCompetitionTzbUserJob size===#{result["Data"].size}") + result["Data"].each do |row| + tzb_user = CompetitionTzbUser.find_by(user_uid: row["user_uid"]) + if tzb_user.blank? + tzb_user = CompetitionTzbUser.new + tzb_user.user_uid = row["user_uid"] + tzb_user.user_email = row["user_email"] + tzb_user.activation_code = row["activation_code"] + tzb_user.info_json = row.to_json + tzb_user.save + end + if tzb_user.present? && tzb_user.user_id.blank? + password = generate_user_login('') + user_id = register_user(tzb_user, password) + tzb_user.update_attributes!(user_id: user_id, pwd: password) + end + end + end + + + def register_user(tzb_user, pwd) + user = User.find_by(mail: tzb_user.user_email) + return user.id if user.present? + username = generate_user_login('p') + email = tzb_user.user_email + email = "#{username}@example.org" if email.blank? + company_name = tzb_user.user_info("school_name") + user_type = company_name.present? && company_name.include?("大学") ? 4 : 6 + password = pwd + user = User.new(login: username, mail: email, password: password, type: 'User', company_name: company_name) + interactor = Gitea::RegisterInteractor.call({ username: username, email: email, password: password }) + gitea_user = interactor.result + result = Gitea::User::GenerateTokenService.call(username, password) + user.gitea_token = result['sha1'] + user.gitea_uid = gitea_user[:body]['id'] + user.user_type = user_type + user.save! + UserExtension.create!(user_id: user.id) + user.id + end + + + # 生成邀请码 + def generate_user_login type + code = %W(0 1 2 3 4 5 6 7 8 9).sample(8).join + code = type + code.to_s + return generate_user_login(type) if User.where(login: code).present? + code + end +end \ No newline at end of file diff --git a/app/libs/util/file_manage.rb b/app/libs/util/file_manage.rb index 2f87a3e86..fd7fccee7 100644 --- a/app/libs/util/file_manage.rb +++ b/app/libs/util/file_manage.rb @@ -15,6 +15,7 @@ module Util::FileManage end def source_disk_filename(source, suffix=nil) + Rails.logger.info "11111111111=========+#{source.class.name}" disk_filename(source.class.name, source.id, suffix) end diff --git a/app/models/competition_tzb_user.rb b/app/models/competition_tzb_user.rb new file mode 100644 index 000000000..da2137a2a --- /dev/null +++ b/app/models/competition_tzb_user.rb @@ -0,0 +1,12 @@ + +class CompetitionTzbUser < ApplicationRecord + + def user_info(attr) + return "" if self.info_json.blank? + data = JSON.parse(self.info_json) + data["#{attr}"] + rescue => err + Rails.logger.info("info_json is not json,error:#{err}") + "" + end +end diff --git a/app/models/laboratory_setting.rb b/app/models/laboratory_setting.rb index 61c677def..9e6eb44f4 100644 --- a/app/models/laboratory_setting.rb +++ b/app/models/laboratory_setting.rb @@ -35,6 +35,10 @@ class LaboratorySetting < ApplicationRecord image_url('nav') end + def index_logo_url + image_url('index') + end + def tab_logo_url image_url('tab') end diff --git a/app/models/topic.rb b/app/models/topic.rb index 4642fa3ed..0db0087ce 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -18,6 +18,105 @@ class Topic < ApplicationRecord default_scope { order(order_index: :desc)} scope :with_single_type, ->(type){where(type: trans_simpletype_to_classtype(type))} + scope :with_mutil_type, ->(type){where(type: group_class_type_names(type))} + # self.inheritance_column = nil + + def self.has_templates?(type) + type_simple_name = Topic.type_simple_name(type) + ["ck_case", "scientific_organization"].include?(type_simple_name) + end + + def self.base_types + [ + # ["forums", "Topic::ActivityForum", "首页平台动态"], + # ["forums", "Topic::ExcellentProject", "首页优秀项目"], + # ["forums", "Topic::ExperienceForum", "首页经验分享"], + # ["forums", "Topic::TechnicalDiscussion", "首页技术讨论"], + # ["forums", "Topic::PinnedForum", "首页精选文章"], + # ["forums", "Topic::CkForum", "创客首页-创客内容"], + # ["forums", "Topic::JsForum", "创客首页-竞赛内容"], + # ["forums", "Topic::GlccNews", "GLCC新闻稿"], + ["forums", "Topic::JoinUs", "底部加入我们"], + + ["banners", "Topic::Banner", "首页banner"], + ["banners", "Topic::Card", "开源首页卡片"], + ["banners", "Topic::CkBanner", "创客空间卡片"], + ["banners", "Topic::AppletBanner", "小程序首页banner"], + + # ["logos", "Topic::Cooperator", "首页合作伙伴"], + ["logos", "Topic::Organization", "项目首页组织logo"], + ["logos", "Topic::ScientificOrganization", "首页/友情链接-科研机构logo"], + ["logos", "Topic::School", "首页/友情链接-高校logo"], + # ["logos", "Topic::FriendlyLink", "首页友情链接-科研机构logo"], + + ["others", "Topic::ServiceTerm", "服务条款"], + ] + end + + def self.group_class_types(type) + Topic.base_types.select { |s| s[0] == type } + end + + def self.group_class_type_names(type) + Topic.group_class_types(type).map{|s| s[1]} + end + + def self.group_types_options(type) + Topic.group_class_types(type).map{|s| [s[2],s[1]]} + end + + def self.sub_types + [ + ["Topic::ActivityForum", "activity_forum", "首页平台动态"], + ["Topic::Banner", "banner", "首页banner"], + ["Topic::Card", "card", "首页卡片内容"], + ["Topic::Cooperator", "cooperator", "首页合作伙伴"], + ["Topic::Organization", "organization", "首页组织logo"], + ["Topic::ScientificOrganization", "scientific_organization", "科研机构logo"], + ["Topic::School", "school", "首页高校logo"], + ["Topic::ExcellentProject", "excellent_project", "首页优秀项目"], + ["Topic::ExperienceForum", "experience_forum", "首页经验分享"], + ["Topic::GlccNews", "glcc_news", "GLCC新闻稿"], + ["Topic::PinnedForum", "pinned_forum", "首页精选文章"], + ["Topic::AppletBanner", "applet_banner", "Applet首页banner"], + ["Topic::FriendlyLink", "friendly_link", "底部友情链接"], + ["Topic::JoinUs", "Join_us", "底部加入我们"], + ["Topic::CkBanner", "ck_banner", "创客空间卡片内容"], + ["Topic::TechnicalDiscussion", "technical_discussion", "首页技术讨论"], + ["Topic::CkForum", "ck_forum", "创客首页-创客内容"], + ["Topic::JsForum", "js_forum", "创客首页-竞赛内容"], + ["Topic::ServiceTerm", "service_term", "服务条款"], + ["Topic::CkCase", "ck_case", "创客案例"], + ] + end + + def self.opt_select + Topic.sub_types.map{|s| [s[2],s[0]]} + end + + def type_cn_name + filter = Topic.base_types.select { |s| s[1] == self.type } + filter.blank? ? self.type : filter.first[2] + end + + def self.type_simple_name(type) + filter = Topic.sub_types.select { |s| s[0] == type } + filter.blank? ? type : filter.first[1] + end + + + + def self.type_filter_cn_name(type) + filter = Topic.sub_types.select { |s| s[0] == type } + filter.blank? ? type : filter.first[2] + end + + + def type_group_name + filter = Topic.base_types.select { |s| s[1] == self.type } + filter.blank? ? self.type : filter.first[0] + end + def image image_url('image') @@ -59,6 +158,12 @@ class Topic < ApplicationRecord ['Topic::CkForum', 'Topic::JsForum'] when 'service_term' 'Topic::ServiceTerm' + when 'scientific_organization' + 'Topic::ScientificOrganization' + when 'ck_case' + 'Topic::CkCase' + else + type end end diff --git a/app/models/topic/ck_forum.rb b/app/models/topic/ck_forum.rb index f65d05dda..b0cc6bd9f 100644 --- a/app/models/topic/ck_forum.rb +++ b/app/models/topic/ck_forum.rb @@ -11,6 +11,6 @@ # location :integer default("0") # -# Applet首页banner +# 创客首页-创客内容 class Topic::CkForum < Topic end diff --git a/app/models/topic/js_forum.rb b/app/models/topic/js_forum.rb index da4bde5f1..284077a81 100644 --- a/app/models/topic/js_forum.rb +++ b/app/models/topic/js_forum.rb @@ -11,6 +11,6 @@ # location :integer default("0") # -# Applet首页banner +# 创客首页-竞赛内容 class Topic::JsForum < Topic end diff --git a/app/models/topic/scientific_organization.rb b/app/models/topic/scientific_organization.rb new file mode 100644 index 000000000..e8172542f --- /dev/null +++ b/app/models/topic/scientific_organization.rb @@ -0,0 +1,3 @@ +# 科研机构 +class Topic::ScientificOrganization < Topic +end \ No newline at end of file diff --git a/app/models/topic/service_term.rb b/app/models/topic/service_term.rb index 364e4968f..6bea4986a 100644 --- a/app/models/topic/service_term.rb +++ b/app/models/topic/service_term.rb @@ -11,6 +11,6 @@ # location :integer default("0") # -# 首页组织logo +# 服务条款 class Topic::ServiceTerm < Topic end \ No newline at end of file diff --git a/app/services/admins/save_laboratory_setting_service.rb b/app/services/admins/save_laboratory_setting_service.rb index ad040585f..c79f5bcfd 100644 --- a/app/services/admins/save_laboratory_setting_service.rb +++ b/app/services/admins/save_laboratory_setting_service.rb @@ -40,6 +40,7 @@ class Admins::SaveLaboratorySettingService < ApplicationService save_image_file(params[:nav_logo], 'nav') save_image_file(params[:login_logo], 'login') save_image_file(params[:tab_logo], 'tab') + save_image_file(params[:index_logo], 'index') save_image_file(params[:subject_banner], '_subject_banner') save_image_file(params[:course_banner], '_course_banner') save_image_file(params[:competition_banner], '_competition_banner') diff --git a/app/views/admins/laboratory_settings/show.html.erb b/app/views/admins/laboratory_settings/show.html.erb index 6fa3b6adf..b08a5ca12 100644 --- a/app/views/admins/laboratory_settings/show.html.erb +++ b/app/views/admins/laboratory_settings/show.html.erb @@ -46,7 +46,20 @@
Logo设置
-
+
+ <% nav_logo_img = setting.index_logo_url %> + +
+
网站首页logo
+
格式:PNG、JPG
+
尺寸:高度38px以内,宽等比例缩放
+
+
+
<% nav_logo_img = setting.nav_logo_url %>
-
+
<% login_logo_img = setting.login_logo_url %>
-
+
<% tab_logo_img = setting.tab_logo_url %>
diff --git a/app/views/admins/topics/_form_modal.html.erb b/app/views/admins/topics/_form_modal.html.erb new file mode 100644 index 000000000..33bd1d85f --- /dev/null +++ b/app/views/admins/topics/_form_modal.html.erb @@ -0,0 +1,91 @@ + \ No newline at end of file diff --git a/app/views/admins/topics/_form_modal_banners.html.erb b/app/views/admins/topics/_form_modal_banners.html.erb new file mode 100644 index 000000000..f82c39858 --- /dev/null +++ b/app/views/admins/topics/_form_modal_banners.html.erb @@ -0,0 +1,72 @@ + \ No newline at end of file diff --git a/app/views/admins/topics/_form_modal_ck_case.html.erb b/app/views/admins/topics/_form_modal_ck_case.html.erb new file mode 100644 index 000000000..a20248e64 --- /dev/null +++ b/app/views/admins/topics/_form_modal_ck_case.html.erb @@ -0,0 +1,57 @@ + \ No newline at end of file diff --git a/app/views/admins/topics/_form_modal_forums.html.erb b/app/views/admins/topics/_form_modal_forums.html.erb new file mode 100644 index 000000000..c444abd24 --- /dev/null +++ b/app/views/admins/topics/_form_modal_forums.html.erb @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/app/views/admins/topics/_form_modal_logos.html.erb b/app/views/admins/topics/_form_modal_logos.html.erb new file mode 100644 index 000000000..f82c39858 --- /dev/null +++ b/app/views/admins/topics/_form_modal_logos.html.erb @@ -0,0 +1,72 @@ + \ No newline at end of file diff --git a/app/views/admins/topics/_form_modal_scientific_organization.html.erb b/app/views/admins/topics/_form_modal_scientific_organization.html.erb new file mode 100644 index 000000000..4ad731426 --- /dev/null +++ b/app/views/admins/topics/_form_modal_scientific_organization.html.erb @@ -0,0 +1,60 @@ + \ No newline at end of file diff --git a/app/views/admins/topics/_list.html.erb b/app/views/admins/topics/_list.html.erb new file mode 100644 index 000000000..1b1cb8ca6 --- /dev/null +++ b/app/views/admins/topics/_list.html.erb @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + <% if topics.present? %> + <% topics.each_with_index do |topic, index| %> + + + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号类型标题跳转地址内容信息ID显示位置标识标签排序等级操作
<%= list_index_no((params[:page] || 1).to_i, index) %><%= topic.type_cn_name %><%= topic.title %><%= topic.url %><%= topic.uuid %><%= ["首页", "竞赛", "底部"][Topic.locations[topic.location]] %><%= topic.identifier %> + <% if topic.labels.present? %> + <% topic.labels.split(",").each do |label| %> + <%= label %> + <% end %> + <% end %> + <%= topic.order_index %> + <%= link_to "编辑", edit_admins_topic_path(topic), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %> \ No newline at end of file diff --git a/app/views/admins/topics/_list_banners.html.erb b/app/views/admins/topics/_list_banners.html.erb new file mode 100644 index 000000000..2075648f0 --- /dev/null +++ b/app/views/admins/topics/_list_banners.html.erb @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + <% if topics.present? %> + <% topics.each_with_index do |topic, index| %> + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号类型标题跳转地址图片位置排序等级操作
<%= list_index_no((params[:page] || 1).to_i, index) %><%= topic.type_cn_name %><%= topic.title %><%= topic.url %><%= ["首页", "竞赛", "底部"][Topic.locations[topic.location]] %><%= topic.order_index %> + <%= link_to "编辑", edit_admins_topic_path(topic, topic_type: params[:topic_type]), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %> \ No newline at end of file diff --git a/app/views/admins/topics/_list_ck_case.html.erb b/app/views/admins/topics/_list_ck_case.html.erb new file mode 100644 index 000000000..ff75c5297 --- /dev/null +++ b/app/views/admins/topics/_list_ck_case.html.erb @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + <% if topics.present? %> + <% topics.each_with_index do |topic, index| %> + + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号领域标题描述id金额排序等级操作
<%= list_index_no((params[:page] || 1).to_i, index) %><%= topic.labels %><%= topic.title %><%= topic.description %><%= topic.uuid %><%= topic.identifier %><%= topic.order_index %> + <%= link_to "编辑", edit_admins_topic_path(topic), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %> \ No newline at end of file diff --git a/app/views/admins/topics/_list_forums.html.erb b/app/views/admins/topics/_list_forums.html.erb new file mode 100644 index 000000000..56bdd42f1 --- /dev/null +++ b/app/views/admins/topics/_list_forums.html.erb @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + <% if topics.present? %> + <% topics.each_with_index do |topic, index| %> + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号类型标题跳转地址内容信息ID排序等级操作
<%= list_index_no((params[:page] || 1).to_i, index) %><%= topic.type_cn_name %><%= topic.title %><%= topic.url %><%= topic.uuid %><%= topic.order_index %> + <%= link_to "编辑", edit_admins_topic_path(topic, topic_type: params[:topic_type]), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %> \ No newline at end of file diff --git a/app/views/admins/topics/_list_logos.html.erb b/app/views/admins/topics/_list_logos.html.erb new file mode 100644 index 000000000..2075648f0 --- /dev/null +++ b/app/views/admins/topics/_list_logos.html.erb @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + <% if topics.present? %> + <% topics.each_with_index do |topic, index| %> + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号类型标题跳转地址图片位置排序等级操作
<%= list_index_no((params[:page] || 1).to_i, index) %><%= topic.type_cn_name %><%= topic.title %><%= topic.url %><%= ["首页", "竞赛", "底部"][Topic.locations[topic.location]] %><%= topic.order_index %> + <%= link_to "编辑", edit_admins_topic_path(topic, topic_type: params[:topic_type]), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %> \ No newline at end of file diff --git a/app/views/admins/topics/_list_scientific_organization.html.erb b/app/views/admins/topics/_list_scientific_organization.html.erb new file mode 100644 index 000000000..2206aea0f --- /dev/null +++ b/app/views/admins/topics/_list_scientific_organization.html.erb @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + <% if topics.present? %> + <% topics.each_with_index do |topic, index| %> + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号标题跳转地址图片排序等级操作
<%= list_index_no((params[:page] || 1).to_i, index) %><%= topic.title %><%= topic.url %><%= topic.order_index %> + <%= link_to "编辑", edit_admins_topic_path(topic), remote: true, class: "action" %> + <%= link_to "删除", admins_topic_path(topic), method: :delete, data: { confirm: "确认删除的吗?" }, class: "action" %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: topics } %> \ No newline at end of file diff --git a/app/views/admins/topics/edit.js.erb b/app/views/admins/topics/edit.js.erb new file mode 100644 index 000000000..6be69878f --- /dev/null +++ b/app/views/admins/topics/edit.js.erb @@ -0,0 +1,23 @@ +<%if params[:topic_type].present? %> +$("#activity-forum-modals").html("<%= j render(partial: "admins/topics/form_modal_#{params[:topic_type]}", locals: {type: 'update'}) %>") +<%else %> +$("#activity-forum-modals").html("<%= j render(partial: 'admins/topics/form_modal', locals: {type: 'update'}) %>") +<%end %> +$(".activity-forum-change-modal").modal('show'); + + +$('.logo-item-left').on("change", 'input[type="file"]', function () { + var $fileInput = $(this); + var file = this.files[0]; + var imageType = /image.*/; + if (file && file.type.match(imageType)) { + var reader = new FileReader(); + reader.onload = function () { + var $box = $fileInput.parent(); + $box.find('img').attr('src', reader.result).css('display', 'block'); + $box.addClass('has-img'); + }; + reader.readAsDataURL(file); + } else { + } +}); \ No newline at end of file diff --git a/app/views/admins/topics/index.html.erb b/app/views/admins/topics/index.html.erb new file mode 100644 index 000000000..157b11f07 --- /dev/null +++ b/app/views/admins/topics/index.html.erb @@ -0,0 +1,34 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb("#{Topic.type_filter_cn_name(@type)}") %> +<% end %> + +
+ <%= form_tag(admins_topics_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '标题检索') %> + + +
+ + <% user_type_options = [['全部', '']] | Topic.group_types_options(params[:topic_type]) %> + <%= select_tag(:type, options_for_select(user_type_options), class: 'form-control') %> +
+
+ + <% location_options = [['全部', ''], ['首页', 'home'], ['竞赛', 'competition'], ['底部', 'footer']] %> + <%= select_tag(:location, options_for_select(location_options), class: 'form-control') %> +
+ <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_admins_topic_path(topic_type: params[:topic_type]), remote: true, class: "btn btn-primary pull-right", "data-disabled-with": "...新增" %> +
+ +
+ <% if params[:topic_type].present? %> + <%= render partial: "admins/topics/list_#{params[:topic_type]}", locals: { topics: @topics } %> + <% else %> + <%= render partial: 'admins/topics/list', locals: { topics: @topics } %> + <% end %> +
+
+
diff --git a/app/views/admins/topics/index.js.erb b/app/views/admins/topics/index.js.erb new file mode 100644 index 000000000..d6c5f3e23 --- /dev/null +++ b/app/views/admins/topics/index.js.erb @@ -0,0 +1,5 @@ +<%if params[:topic_type].present? %> +$('.activity-forum-list-container').html("<%= j( render partial: "admins/topics/list_#{params[:topic_type]}", locals: { topics: @topics } ) %>"); +<%else %> +$('.activity-forum-list-container').html("<%= j( render partial: 'admins/topics/list', locals: { topics: @topics } ) %>"); +<%end %> diff --git a/app/views/admins/topics/new.js.erb b/app/views/admins/topics/new.js.erb new file mode 100644 index 000000000..75ee49b03 --- /dev/null +++ b/app/views/admins/topics/new.js.erb @@ -0,0 +1,23 @@ +<%if params[:topic_type].present? %> +$("#activity-forum-modals").html("<%= j render(partial: "admins/topics/form_modal_#{params[:topic_type]}", locals: {type: 'create'}) %>") +<%else %> +$("#activity-forum-modals").html("<%= j render(partial: 'admins/topics/form_modal', locals: {type: 'create'}) %>") +<%end %> + +$(".activity-forum-change-modal").modal('show'); + +$('.logo-item-left').on("change", 'input[type="file"]', function () { + var $fileInput = $(this); + var file = this.files[0]; + var imageType = /image.*/; + if (file && file.type.match(imageType)) { + var reader = new FileReader(); + reader.onload = function () { + var $box = $fileInput.parent(); + $box.find('img').attr('src', reader.result).css('display', 'block'); + $box.addClass('has-img'); + }; + reader.readAsDataURL(file); + } else { + } +}); diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index b9febc107..ba26fb57e 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -16,7 +16,7 @@ end if trend.trend_type == "Issue" json.partial! "issues/simple_issue_item", locals: {issue: trend.trend} -elsif trend.trend_type == "VersionRelease" +elsif trend.trend_type == "VersionRelease" && trend.trend.present? json.partial! "version_releases/simple_version_release", locals: {version: trend.trend} elsif trend.trend_type == "CommitLog" commit_log = trend.trend diff --git a/app/views/settings/show.json.jbuilder b/app/views/settings/show.json.jbuilder index 7b6e8fe8f..799d21aba 100644 --- a/app/views/settings/show.json.jbuilder +++ b/app/views/settings/show.json.jbuilder @@ -6,6 +6,7 @@ json.setting do json.name default_setting.name json.nav_logo_url default_setting.nav_logo_url&.[](1..-1) json.login_logo_url default_setting.login_logo_url&.[](1..-1) + json.index_logo_url default_setting.index_logo_url&.[](1..-1) json.tab_logo_url default_setting.tab_logo_url.present? ? default_setting.tab_logo_url&.[](1..-1) : "favicon.ico" json.site_page_deploy_domain @deploy_domain diff --git a/app/views/topics/_all.json.jbuilder b/app/views/topics/_all.json.jbuilder new file mode 100644 index 000000000..2323199fc --- /dev/null +++ b/app/views/topics/_all.json.jbuilder @@ -0,0 +1 @@ +json.(topic, :id, :type, :title, :uuid, :url, :description, :identifier, :image, :location, :labels, :date) diff --git a/app/views/topics/index.json.jbuilder b/app/views/topics/index.json.jbuilder index e6a374507..79fbc8b2a 100644 --- a/app/views/topics/index.json.jbuilder +++ b/app/views/topics/index.json.jbuilder @@ -34,7 +34,7 @@ json.topics do when 'Topic::ServiceTerm' json.partial! 'service_term', locals: {service_term: topic} else - json.nil! + json.partial! 'all', locals: {topic: topic} end end end @@ -72,7 +72,7 @@ json.topics do when 'Topic::ServiceTerm' json.partial! 'service_term', locals: {service_term: topic} else - json.nil! + json.partial! 'all', locals: {topic: topic} end end end diff --git a/config/routes.rb b/config/routes.rb index 2e81b6dc2..12daa1cfb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -480,6 +480,7 @@ Rails.application.routes.draw do get :recommend, on: :collection post :auto_score, on: :collection post :update_expert_audit, on: :collection + post :tzb_actived, on: :collection member do get :enroll_list get :ranking_list @@ -867,6 +868,7 @@ Rails.application.routes.draw do get '/', to: 'dashboards#index' get '/baidu_tongji', to: 'dashboards#baidu_tongji' get '/baidu_tongji_auth', to: 'dashboards#baidu_tongji_auth' + resources :topics namespace :topic do resources :service_terms resources :technical_discussions diff --git a/config/sidekiq_cron.yml b/config/sidekiq_cron.yml index 5dc45f1a1..9ae814d74 100644 --- a/config/sidekiq_cron.yml +++ b/config/sidekiq_cron.yml @@ -33,3 +33,8 @@ cache_async_reset: queue: cache args: - "platform_statistic_service" + +sync_competition_tzb_user: + cron: "*/5 * * * *" + class: "SyncCompetitionTzbUserJob" + queue: default diff --git a/db/migrate/202505132525119_create_competition_tzb_users.rb b/db/migrate/202505132525119_create_competition_tzb_users.rb new file mode 100644 index 000000000..95a94f1d0 --- /dev/null +++ b/db/migrate/202505132525119_create_competition_tzb_users.rb @@ -0,0 +1,21 @@ +class CreateCompetitionTzbUsers < ActiveRecord::Migration[5.2] + def change + # data = '{"Code":"Ok","Message":"成功","Data":[{"corp_id":123456,"match_id":666,"user_uid":"uid_y0gqNR3EesqZVgA","project_pid":"pid_123001","activation_code":"V2nyoEYzl2zRaVySpldc","project_status":"not_finished","project_status_text":"未提交", + # "status_level":"school","status_level_text":"校级","school_code":"10003","school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_JHnTBdt8GA3tziq","project_pid":"pid_123002","activation_code":"nde8u5HNQ7qqXjkBIQG0","project_status":"submit_to","project_status_text":"已提交","status_level":"school","status_level_text":"校级","school_code":"10003","school_name":"清华大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_2tCNcoKX8T8oHvk","project_pid":"pid_123003","activation_code":"iZQCh3mfuJ8ESrUPwGRo","project_status":"pass_by","project_status_text":"审核通过","status_level":"school","status_level_text":"校级","school_code":"10001","school_name":"北京大学","province_name":"北京"},{"corp_id":123456,"match_id":666,"user_uid":"uid_DziaXaNTkyS1M05","project_pid":"pid_123004","activation_code":"c42BKyehYWAxeAqjLdc8","project_status":"not_pass_by","project_status_text":"审核未通过","status_level":"province","status_level_text":"省级","school_code":"10001","school_name":"北京大学","province_name":"北京"}]}' + + create_table :competition_tzb_users do |t| + t.string :user_uid + t.string :user_email + t.string :activation_code + t.text :info_json + t.integer :user_id + t.string :pwd + t.boolean :actived, default: false + t.timestamps + end + + add_index :competition_tzb_users, :user_uid + add_index :competition_tzb_users, :activation_code + add_index :competition_tzb_users, :user_id + end +end