Files
yunzerwebsiteallinone/go/docs/sql/create_oa_dailyreport_history.sql
2026-10-22 00:27:26 +08:00

39 lines
2.2 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================
-- OA 工作日报 —— 修改痕迹表
--
-- 对应代码:
-- models/oa_daily_report.go(OaDailyReportHistory)
-- services/dailyreport/report.go(Withdraw / Save / GetDetail)
-- controllers/backend_oa_dailyreport.go(后台 PC 端)
-- controllers/app_oa_dailyreport.go(小程序端)
--
-- 设计要点:
-- 1. 日报提交后锁定(status=1),不允许直接修改;
-- 需要修改时必须先「撤销提交」退回草稿(status=0),改完再重新提交。
-- 2. 每次撤销提交写入一条 action=1 的痕迹,保存本次提交时的内容快照;
-- 撤销后重新提交写入一条 action=2 的痕迹,保存新版本内容快照。
-- 3. 痕迹只增不改:日报删除后痕迹保留(report_id 仍可追溯),不做软删除。
-- 4. 不显式指定 COLLATE,沿用数据库默认排序规则,避免 JOIN 时排序规则冲突。
-- =============================================================
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `yz_backend_oa_daily_report_history` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`tid` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '租户ID',
`report_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '日报ID(yz_backend_oa_daily_report.id)',
`user_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '操作人uid(yz_system_tenant_user.uid)',
`user_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '操作人姓名快照',
`report_date` DATE NOT NULL COMMENT '日报日期',
`action` TINYINT NOT NULL DEFAULT 1 COMMENT '1撤销提交 2重新提交',
`today_done` TEXT COMMENT '快照:今日完成',
`tomorrow_plan` TEXT COMMENT '快照:明日计划',
`issues` TEXT COMMENT '快照:问题与建议',
`attachments` TEXT COMMENT '快照:附件JSON数组',
`submit_time` DATETIME DEFAULT NULL COMMENT '快照:提交时间',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_tid_report` (`tid`, `report_id`, `id`),
KEY `idx_tid_date` (`tid`, `report_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='OA-工作日报修改痕迹';