增加通知公告功能
This commit is contained in:
@@ -113,6 +113,7 @@ func Init(_ string) {
|
||||
new(BackendScheduleReminderSendLog),
|
||||
|
||||
new(OaSchedule),
|
||||
new(OaNotice),
|
||||
new(BackendOaCompensationScheme),
|
||||
new(BackendOaPayroll),
|
||||
new(BackendOaPayrollItem),
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OaNotice OA通知公告: yz_backend_oa_notice
|
||||
// 按租户 tid 隔离:租户内发布,租户内所有后台用户可见。
|
||||
// status: 0-草稿 1-已发布 2-已下架;notice_type: 0-通知 1-公告 2-活动;
|
||||
// level: 0-普通 1-重要 2-紧急;is_top: 0-否 1-是(置顶优先展示)。
|
||||
type OaNotice struct {
|
||||
ID uint64 `orm:"column(id);pk;auto" json:"id"`
|
||||
Tid int `orm:"column(tid)" json:"tid"`
|
||||
Title string `orm:"column(title);size(255)" json:"title"`
|
||||
Content string `orm:"column(content);type(text);null" json:"content"`
|
||||
NoticeType int8 `orm:"column(notice_type);default(0)" json:"notice_type"`
|
||||
Level int8 `orm:"column(level);default(0)" json:"level"`
|
||||
Status int8 `orm:"column(status);default(0)" json:"status"`
|
||||
IsTop int8 `orm:"column(is_top);default(0)" json:"is_top"`
|
||||
PublishTime *time.Time `orm:"column(publish_time);type(datetime);null" json:"publish_time"`
|
||||
PublisherID uint64 `orm:"column(publisher_id);default(0)" json:"publisher_id"`
|
||||
PublisherName string `orm:"column(publisher_name);size(100);default()" json:"publisher_name"`
|
||||
ReadCount int `orm:"column(read_count);default(0)" json:"read_count"`
|
||||
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"`
|
||||
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
|
||||
UpdateTime *time.Time `orm:"column(update_time);auto_now;type(datetime);null" json:"update_time"`
|
||||
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
|
||||
}
|
||||
|
||||
func (m *OaNotice) TableName() string {
|
||||
return "yz_backend_oa_notice"
|
||||
}
|
||||
|
||||
var oaNoticeTableOnce sync.Once
|
||||
|
||||
// EnsureOaNoticeTable 首次访问通知公告接口时自动建表(若不存在)。
|
||||
// 与日程表保持一致的"运行时自愈"策略,避免新功能上线还要手工执行建表脚本。
|
||||
func EnsureOaNoticeTable() error {
|
||||
if Orm == nil {
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
oaNoticeTableOnce.Do(func() {
|
||||
_, err = Orm.Raw(`
|
||||
CREATE TABLE IF NOT EXISTS yz_backend_oa_notice (
|
||||
id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
tid int NOT NULL DEFAULT 0 COMMENT '租户ID',
|
||||
title varchar(255) NOT NULL DEFAULT '' COMMENT '公告标题',
|
||||
content text COMMENT '公告内容',
|
||||
notice_type tinyint NOT NULL DEFAULT 0 COMMENT '类型 0-通知 1-公告 2-活动',
|
||||
level tinyint NOT NULL DEFAULT 0 COMMENT '紧急程度 0-普通 1-重要 2-紧急',
|
||||
status tinyint NOT NULL DEFAULT 0 COMMENT '状态 0-草稿 1-已发布 2-已下架',
|
||||
is_top tinyint NOT NULL DEFAULT 0 COMMENT '是否置顶 0-否 1-是',
|
||||
publish_time datetime DEFAULT NULL COMMENT '发布时间',
|
||||
publisher_id bigint unsigned NOT NULL DEFAULT 0 COMMENT '发布人ID',
|
||||
publisher_name varchar(100) NOT NULL DEFAULT '' COMMENT '发布人姓名',
|
||||
read_count int NOT NULL DEFAULT 0 COMMENT '阅读次数',
|
||||
is_deleted tinyint NOT NULL DEFAULT 0 COMMENT '是否删除 0-否 1-是',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
update_time datetime DEFAULT NULL COMMENT '更新时间',
|
||||
delete_time datetime DEFAULT NULL COMMENT '删除时间',
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_tid_status (tid, status),
|
||||
KEY idx_tid_top (tid, is_top)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='OA通知公告表'`).Exec()
|
||||
})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user