-
Notifications
You must be signed in to change notification settings - Fork 0
/
tip.go
66 lines (59 loc) · 2.34 KB
/
tip.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package OrgTip
import (
Router2SystemConfig "github.com/fotomxq/weeekj_core/v5/router2/system_config"
"time"
CoreSQL "github.com/fotomxq/weeekj_core/v5/core/sql"
CoreSQLConfig "github.com/fotomxq/weeekj_core/v5/core/sql/config"
CoreSQLFrom "github.com/fotomxq/weeekj_core/v5/core/sql/from"
"github.com/lib/pq"
)
//行政专用的提醒模块
// 外部行政类模块可以任意使用,将数据写入该列队
// 列队将不断巡逻,如果发现需要提醒的数据,将自动发送给目标来源系统
// ArgsCreate 创建推送计划参数
type ArgsCreate struct {
//组织ID
OrgID int64 `db:"org_id" json:"orgID"`
//创建来源
CreateInfo CoreSQLFrom.FieldsFrom `db:"create_info" json:"createInfo"`
//推送目标系统
FromInfo CoreSQLFrom.FieldsFrom `db:"from_info" json:"fromInfo"`
//计划提醒时间
TipAt time.Time `db:"tip_at" json:"tipAt"`
//提醒标题
Title string `db:"title" json:"title"`
//提醒内容
Content string `db:"content" json:"content"`
//附加文件
Files pq.Int64Array `db:"files" json:"files"`
//是否需要短信
NeedSMS bool `db:"need_sms" json:"needSMS"`
//短信配置
SMSConfigID int64 `db:"sms_config_id" json:"smsConfigID"`
//短信模版参数
SMSParams CoreSQLConfig.FieldsConfigsType `db:"sms_params" json:"smsParams"`
//扩展数据
Params CoreSQLConfig.FieldsConfigsType `db:"params" json:"params"`
}
// Create 创建推送计划
func Create(args *ArgsCreate) (err error) {
_, err = CoreSQL.CreateOne(Router2SystemConfig.MainDB.DB, "INSERT INTO org_tip (org_id, create_info, from_info, tip_at, title, content, files, need_sms, sms_config_id, sms_params, params, allow_send) VALUES (:org_id, :create_info, :from_info, :tip_at, :title, :content, :files, :need_sms, :sms_config_id, :sms_params, :params, false)", args)
return
}
// ArgsDeleteByCreateFrom 删除某个来源的所有推送参数
type ArgsDeleteByCreateFrom struct {
//创建来源
CreateInfo CoreSQLFrom.FieldsFrom
}
// DeleteByCreateFrom 删除某个来源的所有推送
func DeleteByCreateFrom(args *ArgsDeleteByCreateFrom) (err error) {
var createData string
createData, err = args.CreateInfo.GetRaw()
if err != nil {
return
}
_, err = CoreSQL.UpdateOne(Router2SystemConfig.MainDB.DB, "UPDATE org_tip SET delete_at = NOW() WHERE create_info @> :create_info", map[string]interface{}{
"create_info": createData,
})
return
}