切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
ad740a18d4ba0833844814ecd289eb58bf1ff230
1 个父辈
9230f6df
更新 短信消息相关
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
107 行增加
和
0 行删除
pkg/domain/log_sms.go
pkg/infrastructure/pg/models/log_sms.go
pkg/infrastructure/repository/pg_log_sms_repository.go
pkg/infrastructure/serviceGateway/httplib_sms_service.go
pkg/domain/log_sms.go
0 → 100644
查看文件 @
ad740a1
package
domain
import
"time"
//记录 发送的短信消息
type
LogSms
struct
{
Id
int
Phone
string
TemplateId
string
Template
string
Value
map
[
string
]
string
CreatedAt
time
.
Time
}
// 周期综合自评 短信消息提醒
func
(
sms
*
LogSms
)
SummaryEvaluationMessage
(
phone
string
,
name
string
)
{
*
sms
=
LogSms
{
Id
:
0
,
Phone
:
phone
,
TemplateId
:
"5475050"
,
Template
:
"您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦"
,
Value
:
map
[
string
]
string
{
"name"
:
name
,
},
CreatedAt
:
time
.
Now
(),
}
}
...
...
pkg/infrastructure/pg/models/log_sms.go
0 → 100644
查看文件 @
ad740a1
package
models
import
"time"
type
LogSms
struct
{
tableName
struct
{}
`comment:"记录短信消息" pg:"log_sms"`
Id
int
`pg:",pk"`
Phone
string
``
TemplateId
string
``
Template
string
``
Value
map
[
string
]
string
``
CreatedAt
time
.
Time
``
}
...
...
pkg/infrastructure/repository/pg_log_sms_repository.go
0 → 100644
查看文件 @
ad740a1
package
repository
...
...
pkg/infrastructure/serviceGateway/httplib_sms_service.go
0 → 100644
查看文件 @
ad740a1
package
serviceGateway
import
(
"bytes"
"encoding/json"
"errors"
"net/http"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/serviceGateway/reply"
)
// 调用接口 发送短信消息
type
SmsService
struct
{
}
const
(
sendNoticeSms
string
=
"https://sms.fjmaimaimai.com:9897/service/sendNoticeSms"
)
// SendNoticeSms 发送短信消息
// phone 手机号
// tplId 短信模板id
// tplValues 短信模板中带的参数 具体根据定义的模板参数
func
(
ssrv
SmsService
)
SendNoticeSms
(
phone
string
,
tplId
int
,
tplValues
map
[
string
]
string
)
error
{
param
:=
map
[
string
]
interface
{}{
"phone"
:
phone
,
"tplId"
:
tplId
,
"tplValues"
:
tplValues
,
}
buf
:=
bytes
.
NewBuffer
(
nil
)
jEncode
:=
json
.
NewEncoder
(
buf
)
err
:=
jEncode
.
Encode
(
param
)
if
err
!=
nil
{
return
err
}
req
,
err
:=
http
.
NewRequest
(
http
.
MethodPost
,
sendNoticeSms
,
buf
)
if
err
!=
nil
{
return
err
}
req
.
Header
=
map
[
string
][]
string
{
"Content-Type"
:
{
"application/json"
},
}
httpclient
:=
http
.
Client
{
Timeout
:
30
*
time
.
Second
,
}
resp
,
err
:=
httpclient
.
Do
(
req
)
if
err
!=
nil
{
return
err
}
defer
resp
.
Body
.
Close
()
var
result
reply
.
BaseReply
jDecoder
:=
json
.
NewDecoder
(
resp
.
Body
)
err
=
jDecoder
.
Decode
(
&
result
)
if
err
!=
nil
{
return
err
}
if
result
.
Code
!=
0
{
return
errors
.
New
(
result
.
Msg
)
}
return
nil
}
...
...
请
注册
或
登录
后发表评论