Merge branch 'dev_trustie_forum' of https://gitlink.org.cn/Trustie/forgeplus into dev_trustie_forum

This commit is contained in:
xxq250 2024-10-25 09:56:07 +08:00
commit 13ceee3b97
5 changed files with 26 additions and 2 deletions

View File

@ -27,6 +27,11 @@ class MemosController < ApplicationController
render json: targets
end
def show_simple
targets = MemosService.new.show_simple params, current_user
render json: targets
end
def show
targets = MemosService.new.show params, current_user
render json: targets

View File

@ -20,7 +20,7 @@ class Memo < ApplicationRecord
validates_presence_of :author_id, :subject,:content
# 若是主题帖,则内容可以是空
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
validates_length_of :subject, maximum: 50
validates_length_of :subject, maximum: 200
validate :cannot_reply_to_locked_topic, :on => :create
validate :validate_sensitive_string

View File

@ -73,6 +73,7 @@ class MemosService
# elsif params[:memo][:content].length > 2000
# {status: -1, message: "不能超过2000个字符"}
return {status: -1, message: "您的账户已被禁言,如有疑问请联系版主或论坛管理员"} if user_is_banned?(current_user)
return {status: 1, message: "帖子创建成功,请等待管理员审核。。。"} if ["智库百科", "新百胜", "第一财经", "秒懂百科"].select { |t| params[:memo][:subject].to_s.include?(t) }.size > 0
begin
memo = Memo.new(params[:memo])
memo.author = current_user
@ -99,6 +100,17 @@ class MemosService
end
end
def show_simple params, current_user
memo = Memo.find(params[:id])
memo_info = {id: memo.id,
subject: memo.subject,
published_time: rename_time_minute(memo.published_at),
viewed_count: memo.viewed_count, #浏览
}
{status: 0, memo: memo_info}
end
# params
# :id 帖子id
# return
@ -738,7 +750,8 @@ 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
# forum_id = MemoForum&.where(is_children: false, memo_id: memo_id)&.first.try(:forum_id).to_s
forum_id = Memo.find_by_id(memo_id).try(:forum_section_id)
user_banned_permission current_user, forum_id
end

View File

@ -73,6 +73,7 @@ Rails.application.routes.draw do
get :more_reply
post :confirm_delete
post :plus
get :show_simple
end
end
# resources :sync_forge, only: [:create] do

View File

@ -0,0 +1,5 @@
class ChangeMemosContentSize < ActiveRecord::Migration[5.2]
def change
execute("ALTER TABLE `memos` MODIFY `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
end
end