service.xpcool.com/internal/model/entity/notice.go
夏犀麟 ad4567fc01 feat: 招聘爬虫健壮性 + 通知记录增强(归档工作区留存改动)
这两批改动此前一直压在工作区未提交,本次一并归档。go build ./... 通过。

一、招聘爬虫健壮性
- 新增 internal/service/recruitment/source_config.go:
  crawl_source.config(VARCHAR(1000) JSON)的源级抓取参数解析 —— 增量窗口天数、
  单次详情页上限、最大翻页数、详情间隔限速、自定义标准词/排除词。
  全部字段可选,JSON 解析失败即回退默认值,保证历史数据零迁移可用,
  且一个源的脏配置不会拖垮整个调度。
- 新增 internal/service/recruitment/keywords.go(含 keywords_test.go 与 testdata/):
  链接筛选由「URL 形态命中 AND 文本语义命中」改为评分制 —— URL 形态加分、
  标准词加分、排除词大幅减分,达阈值即入选。原与逻辑会系统性漏抓
  「补充工作人员的通知」「公开选调公务员简章」等标题变体,且静默无报错。
- 新增 manifest/sql/recruitment/004_crawl_source_status.sql:
  crawl_source 增加「最近一次运行状态」冗余列,抓取结束时写入,
  使 Sources() 查询零 JOIN 零扫描 —— 规避原实现全表扫描只增不减的 crawl_log、
  随运行时间线性劣化的问题。幂等,可重复执行。
- internal/service/recruitment/crawler.go:在既有「静态两级 / SPA / curl 回退」
  流程上做锚点抽取与过滤、编码回退的健壮性增强。
- internal/service/recruitment/bark.go、recruitment.go:配合上述调整。

二、通知记录增强
- api/notice、internal/controller/notice、internal/service/notice、
  internal/model/{dto,entity,do}/notice.go:通知日志查询与操作扩展 ——
  批次号、状态、重试次数、来源、耗时、详情、删除、清空。
- 新增 internal/model/dto/notice_meta.go(字典选项元数据,供前端筛选器取选项)。
- 新增 manifest/sql/017_notice_log_enhance.sql:notice_log 扩展列 +
  删除/清空/详情/字典选项接口权限,幂等(ALTER 走 information_schema 判断,
  菜单 ON DUPLICATE KEY UPDATE,角色绑定 INSERT IGNORE)。

三、仓库卫生
- .gitignore 补 rc_*.log 与 rc_verify*,挡掉本地离线验证产物
  (含 30MB 的 rc_verify.exe),避免误入库。

设计依据见 docs/recruitment-crawler-design.md。

注:017 与 recruitment/004 两个 SQL 为增量迁移,DB 结构变更不自动 DDL,
生产库需手动导入。
2026-09-14 01:22:39 +08:00

78 lines
5.2 KiB
Go
Raw 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.

// Package entity 定义通知模块与自动任务模块的表结构(手写,未跑 gf gen
package entity
// NoticeChannel 通知渠道配置。
type NoticeChannel struct {
Id uint64 `json:"id" orm:"id" description:"主键"`
Code string `json:"code" orm:"code" description:"渠道编码"`
Name string `json:"name" orm:"name" description:"渠道名称"`
Enabled int `json:"enabled" orm:"enabled" description:"是否启用"`
Config string `json:"config" orm:"config" description:"渠道配置JSON"`
Remark string `json:"remark" orm:"remark" description:"备注"`
CreatedAt string `json:"createdAt" orm:"created_at" description:"创建时间"`
UpdatedAt string `json:"updatedAt" orm:"updated_at" description:"更新时间"`
}
// NoticeRule 通知规则(事件→渠道→人员→启用→模板)。
type NoticeRule struct {
Id uint64 `json:"id" orm:"id" description:"主键"`
Name string `json:"name" orm:"name" description:"规则名称"`
EventType string `json:"eventType" orm:"event_type" description:"事件类型"`
ChannelCodes string `json:"channelCodes" orm:"channel_codes" description:"渠道编码JSON数组"`
UserIds string `json:"userIds" orm:"user_ids" description:"接收用户ID JSON数组"`
TitleTemplate string `json:"titleTemplate" orm:"title_template" description:"标题模板"`
BodyTemplate string `json:"bodyTemplate" orm:"body_template" description:"内容模板"`
Enabled int `json:"enabled" orm:"enabled" description:"是否启用"`
CreatedAt string `json:"createdAt" orm:"created_at" description:"创建时间"`
UpdatedAt string `json:"updatedAt" orm:"updated_at" description:"更新时间"`
}
// NoticeLog 通知发送记录(通知历史记录)。
type NoticeLog struct {
Id uint64 `json:"id" orm:"id" description:"主键"`
BatchId string `json:"batchId" orm:"batch_id" description:"批次号(同一次业务触发)"`
RuleId uint64 `json:"ruleId" orm:"rule_id" description:"规则ID"`
EventType string `json:"eventType" orm:"event_type" description:"事件编码"`
ChannelCode string `json:"channelCode" orm:"channel_code" description:"渠道编码"`
UserId uint64 `json:"userId" orm:"user_id" description:"接收用户ID"`
Target string `json:"target" orm:"target" description:"发送目标"`
Title string `json:"title" orm:"title" description:"标题"`
Body string `json:"body" orm:"body" description:"内容"`
Status int `json:"status" orm:"status" description:"0待发送 1成功 2失败"`
Result int `json:"result" orm:"result" description:"1成功 0失败(兼容旧字段)"`
Error string `json:"error" orm:"error" description:"错误信息"`
RetryCount int `json:"retryCount" orm:"retry_count" description:"已重试次数"`
DurationMs int `json:"durationMs" orm:"duration_ms" description:"渠道接口耗时(毫秒)"`
Source string `json:"source" orm:"source" description:"触发来源 auto/manual/test"`
Remark string `json:"remark" orm:"remark" description:"备注"`
CreatedAt string `json:"createdAt" orm:"created_at" description:"通知时间"`
}
// AutoJob 自动任务定义。
type AutoJob struct {
Id uint64 `json:"id" orm:"id" description:"主键"`
Name string `json:"name" orm:"name" description:"任务名称"`
Code string `json:"code" orm:"code" description:"任务编码"`
JobType string `json:"jobType" orm:"job_type" description:"任务类型"`
CronExpr string `json:"cronExpr" orm:"cron_expr" description:"cron表达式"`
Enabled int `json:"enabled" orm:"enabled" description:"是否启用"`
Remark string `json:"remark" orm:"remark" description:"备注"`
LastRunAt string `json:"lastRunAt" orm:"last_run_at" description:"上次运行时间"`
LastResult int `json:"lastResult" orm:"last_result" description:"0未运行 1成功 2失败"`
LastError string `json:"lastError" orm:"last_error" description:"上次错误"`
CreatedAt string `json:"createdAt" orm:"created_at" description:"创建时间"`
UpdatedAt string `json:"updatedAt" orm:"updated_at" description:"更新时间"`
}
// AutoJobLog 自动任务运行日志。
type AutoJobLog struct {
Id uint64 `json:"id" orm:"id" description:"主键"`
JobId uint64 `json:"jobId" orm:"job_id" description:"任务ID"`
RunAt string `json:"runAt" orm:"run_at" description:"运行时间"`
Result int `json:"result" orm:"result" description:"1成功 2失败"`
Error string `json:"error" orm:"error" description:"错误信息"`
Summary string `json:"summary" orm:"summary" description:"运行摘要"`
DurationMs int `json:"durationMs" orm:"duration_ms" description:"耗时毫秒"`
CreatedAt string `json:"createdAt" orm:"created_at" description:"创建时间"`
}