2026-08-03-004-screen-newsroom-entry-article.sql 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. SET NAMES utf8mb4;
  2. USE sp_gzhx_apps;
  3. START TRANSACTION;
  4. SET @screen_website_id := (
  5. SELECT w.websiteid
  6. FROM website w
  7. JOIN website_template wt ON wt.wtid = w.wtid
  8. WHERE w.dcode = 61
  9. AND wt.config = 'ffkjscreen02'
  10. AND FIND_IN_SET(
  11. 'hxcs.feifan.net',
  12. REPLACE(TRIM(BOTH ';' FROM IFNULL(w.domains, '')), ';', ',')
  13. ) > 0
  14. ORDER BY w.websiteid DESC
  15. LIMIT 1
  16. );
  17. SET @screen_unit_id := (
  18. SELECT unitid
  19. FROM website
  20. WHERE websiteid = @screen_website_id
  21. LIMIT 1
  22. );
  23. SET @news2026_website_id := (
  24. SELECT websiteid
  25. FROM website
  26. WHERE dcode = 61
  27. AND name = '新闻网-2026'
  28. AND FIND_IN_SET(
  29. 'xinwen2026.hxcs.feifan.net',
  30. REPLACE(TRIM(BOTH ';' FROM IFNULL(domains, '')), ';', ',')
  31. ) > 0
  32. ORDER BY websiteid DESC
  33. LIMIT 1
  34. );
  35. SET @school_news_navigation_id := (
  36. SELECT navigationid
  37. FROM website_navigation
  38. WHERE websiteid = @screen_website_id
  39. AND wnccode = 10000
  40. AND idcard = 'FFKJ_SCHOOL_NEWS'
  41. AND dcode = 61
  42. ORDER BY navigationid
  43. LIMIT 1
  44. );
  45. SET @entry_title := '进入新闻网';
  46. SET @entry_url := 'https://xinwen2026.hxcs.feifan.net/';
  47. SET @entry_desc := '首页校园新闻区“进入新闻网”按钮入口。';
  48. SET @entry_content_path := '/web/upload/ffkj-template/content/portal-demo.html';
  49. SET @operator_pid := 10000;
  50. SET @guard_sql := IF(
  51. @screen_website_id IS NOT NULL
  52. AND @screen_unit_id IS NOT NULL
  53. AND @news2026_website_id IS NOT NULL
  54. AND @school_news_navigation_id IS NOT NULL,
  55. 'SELECT 1',
  56. 'SELECT * FROM __screen_newsroom_entry_guard_failed__'
  57. );
  58. PREPARE guard_stmt FROM @guard_sql;
  59. EXECUTE guard_stmt;
  60. DEALLOCATE PREPARE guard_stmt;
  61. SET @entry_article_id := (
  62. SELECT articleid
  63. FROM article
  64. WHERE websiteid = @screen_website_id
  65. AND navigationid = @school_news_navigation_id
  66. AND title = @entry_title
  67. AND dcode <> 72
  68. ORDER BY articleid DESC
  69. LIMIT 1
  70. );
  71. INSERT INTO article (
  72. dcode, websiteid, unitid, ascode, navigationid, title, ajtcode, `desc`,
  73. source, thumbnail, sticktop, sticktop_end_time, sticktop_schedulesid,
  74. `release`, release_time, release_task_schedulesid, content, edit_content,
  75. url, read_count, create_time, last_change_time, create_pid, last_change_pid,
  76. guest_access_flag, sort_number
  77. )
  78. SELECT
  79. 61, @screen_website_id, @screen_unit_id, 10010, @school_news_navigation_id,
  80. @entry_title, 10020, @entry_desc, '广州华夏职业学院',
  81. NULL, 0, NULL, NULL, 1, NOW(), NULL, @entry_content_path,
  82. @entry_content_path, @entry_url, 1, NOW(), NOW(), @operator_pid,
  83. @operator_pid, 0, 1
  84. FROM DUAL
  85. WHERE @entry_article_id IS NULL;
  86. SET @entry_article_id := COALESCE(
  87. @entry_article_id,
  88. (
  89. SELECT articleid
  90. FROM article
  91. WHERE websiteid = @screen_website_id
  92. AND navigationid = @school_news_navigation_id
  93. AND title = @entry_title
  94. AND dcode <> 72
  95. ORDER BY articleid DESC
  96. LIMIT 1
  97. )
  98. );
  99. UPDATE article
  100. SET dcode = 61,
  101. websiteid = @screen_website_id,
  102. unitid = @screen_unit_id,
  103. ascode = 10010,
  104. navigationid = @school_news_navigation_id,
  105. title = @entry_title,
  106. ajtcode = 10020,
  107. `desc` = @entry_desc,
  108. source = '广州华夏职业学院',
  109. thumbnail = NULL,
  110. sticktop = 0,
  111. sticktop_end_time = NULL,
  112. sticktop_schedulesid = NULL,
  113. `release` = 1,
  114. release_time = COALESCE(release_time, NOW()),
  115. release_task_schedulesid = NULL,
  116. content = @entry_content_path,
  117. edit_content = @entry_content_path,
  118. url = @entry_url,
  119. read_count = COALESCE(read_count, 1),
  120. last_change_time = NOW(),
  121. last_change_pid = @operator_pid,
  122. guest_access_flag = 0,
  123. sort_number = 1
  124. WHERE articleid = @entry_article_id;
  125. COMMIT;