From 3819d8bb4fb2636a24b6bbdd8e9f58a1f7fecd55 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Mon, 5 Aug 2019 14:50:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=99=E5=AD=A6=E6=A1=88?=
=?UTF-8?q?=E4=BE=8B=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/libraries_controller.rb | 4 ++--
app/controllers/shixuns_controller.rb | 4 ++--
app/services/libraries/save_service.rb | 2 +-
...05010545_modify_ke_contents_for_markdown.rb | 18 ++++++++++++++++++
4 files changed, 23 insertions(+), 5 deletions(-)
create mode 100644 db/migrate/20190805010545_modify_ke_contents_for_markdown.rb
diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb
index c7c6029da..d0765fcbf 100644
--- a/app/controllers/libraries_controller.rb
+++ b/app/controllers/libraries_controller.rb
@@ -38,7 +38,7 @@ class LibrariesController < ApplicationController
def create
library = current_user.libraries.new
Libraries::SaveService.call(library, current_user, save_params)
- render_ok
+ render_ok({id: library})
rescue Libraries::SaveService::Error => ex
render_error(ex.message)
end
@@ -47,7 +47,7 @@ class LibrariesController < ApplicationController
return render_forbidden unless library_manageable?(current_library)
Libraries::SaveService.call(current_library, current_user, save_params)
- render_ok
+ render_ok({id: current_library.id})
rescue Libraries::SaveService::Error => ex
render_error(ex.message)
end
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index a0377e4e4..a707536bb 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -782,8 +782,8 @@ class ShixunsController < ApplicationController
school_name = "%#{params[:school_name].to_s.strip}%"
if user_name.present? || school_name.present?
@users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND
- (LOWER(users.lastname) LIKE ? or users.phone like ?) AND LOWER(schools.name) LIKE
- ?", user_name, user_name, school_name)
+ (LOWER(concat(users.lastname, users.firstname)) LIKE ? or users.phone like ?)
+ AND LOWER(schools.name) LIKE ?", user_name, user_name, school_name)
else
@users = User.none
end
diff --git a/app/services/libraries/save_service.rb b/app/services/libraries/save_service.rb
index 45cd033dd..4e1accc3b 100644
--- a/app/services/libraries/save_service.rb
+++ b/app/services/libraries/save_service.rb
@@ -56,7 +56,7 @@ class Libraries::SaveService < ApplicationService
destroy_ids = old_attachment_id - attachment_ids
library.attachments.where(id: destroy_ids).delete_all
- Attachment.where(id: attachment_ids, author_id: user.id).update_all(container: library)
+ Attachment.where(id: attachment_ids, author_id: user.id).update_all(container_type: library)
end
def library_params
diff --git a/db/migrate/20190805010545_modify_ke_contents_for_markdown.rb b/db/migrate/20190805010545_modify_ke_contents_for_markdown.rb
new file mode 100644
index 000000000..93d69726a
--- /dev/null
+++ b/db/migrate/20190805010545_modify_ke_contents_for_markdown.rb
@@ -0,0 +1,18 @@
+class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
+ # include ActionView::Helpers::SanitizeHelper
+ def change
+ # def ke_transform_to_md content
+ # sanitize(content, tags: %w(img a span), attributes: %w(src href target style))
+ # .gsub(/^(\n)/, "").gsub(/(\n)+/, "
").gsub(/$(\n)/, "")
+ # .gsub(/(\n)+/, "
").gsub("\t", " ")
+ # end
+ #
+ # MessageDetail.find_each do |m|
+ # content = ke_transform_to_md m.content
+ # puts("content:#{content}")
+ # m.update_column(:content, content)
+ # end
+
+
+ end
+end