记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
e40a2ac6
Commit
e40a2ac6
authored
Jul 27, 2021
by
jiangxiulong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模版消息
parent
841c2a4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
2 deletions
+138
-2
SweetTemplateController.java
...net/service/sweet/controller/SweetTemplateController.java
+59
-0
SweetLoginServiceImpl.java
...net/service/sweet/service/impl/SweetLoginServiceImpl.java
+2
-2
SweetTemplateServiceImpl.java
.../service/sweet/service/impl/SweetTemplateServiceImpl.java
+77
-0
No files found.
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/controller/SweetTemplateController.java
0 → 100644
View file @
e40a2ac6
package
com
.
liquidnet
.
service
.
sweet
.
controller
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.sweet.service.impl.SweetTemplateServiceImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@Api
(
tags
=
"公众号模版消息"
)
@RestController
@RequestMapping
(
"/sweet-template"
)
public
class
SweetTemplateController
{
@Autowired
private
SweetTemplateServiceImpl
sweetTemplateService
;
@GetMapping
(
"send"
)
@ApiOperation
(
"code获取用户信息"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"code"
,
value
=
"微信code"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"encryptedData"
,
value
=
"encryptedData"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"iv"
,
value
=
"iv"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"Integer"
,
name
=
"type"
,
value
=
"1草莓 2五百里 3mdsk"
),
})
public
ResponseDto
send
(
@RequestParam
()
String
code
,
@RequestParam
()
String
encryptedData
,
@RequestParam
()
String
iv
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
type
)
{
sweetTemplateService
.
sendMsg
();
return
ResponseDto
.
success
();
}
@GetMapping
(
"remind"
)
@ApiOperation
(
"提醒记录"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"code"
,
value
=
"微信code"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"encryptedData"
,
value
=
"encryptedData"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"String"
,
name
=
"iv"
,
value
=
"iv"
,
required
=
true
),
@ApiImplicitParam
(
type
=
"query"
,
dataType
=
"Integer"
,
name
=
"type"
,
value
=
"1草莓 2五百里 3mdsk"
),
})
public
ResponseDto
remind
(
@RequestParam
()
String
code
,
@RequestParam
()
String
encryptedData
,
@RequestParam
()
String
iv
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
type
)
{
sweetTemplateService
.
sendMsg
();
return
ResponseDto
.
success
();
}
}
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/service/impl/SweetLoginServiceImpl.java
View file @
e40a2ac6
...
@@ -16,11 +16,11 @@ import java.util.Objects;
...
@@ -16,11 +16,11 @@ import java.util.Objects;
/**
/**
* <p>
* <p>
* 登陆 服务实现类
*
小程序
登陆 服务实现类
* </p>
* </p>
*
*
* @author liquidnet
* @author liquidnet
* @since 2021-07-2
3
* @since 2021-07-2
7
*/
*/
@Service
@Service
public
class
SweetLoginServiceImpl
{
public
class
SweetLoginServiceImpl
{
...
...
liquidnet-bus-service/liquidnet-service-sweet/src/main/java/com/liquidnet/service/sweet/service/impl/SweetTemplateServiceImpl.java
0 → 100644
View file @
e40a2ac6
package
com
.
liquidnet
.
service
.
sweet
.
service
.
impl
;
import
com.liquidnet.service.base.ResponseDto
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.impl.WxMpServiceImpl
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateData
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage
;
import
me.chanjar.weixin.mp.config.WxMpConfigStorage
;
import
me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
/**
* <p>
* 公众号模版消息 服务实现类
* </p>
*
* @author liquidnet
* @since 2021-07-27
*/
@Service
public
class
SweetTemplateServiceImpl
{
@Value
(
"${liquidnet.wechat.zhengzai.service.appid}"
)
private
String
appid
;
@Value
(
"${liquidnet.wechat.zhengzai.service.secret}"
)
private
String
secret
;
public
ResponseDto
send
(
String
openId
,
String
templateId
)
{
// 发送模板消息接口
WxMpTemplateMessage
templateMessage
=
WxMpTemplateMessage
.
builder
()
// 接收者openid
.
toUser
(
openId
)
// 模板id
.
templateId
(
templateId
)
// 模板跳转链接
.
url
(
"http://www.baidu.com"
)
.
build
();
// 添加模板数据
templateMessage
.
addData
(
new
WxMpTemplateData
(
"first"
,
"您好"
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"keyword1"
,
"这是个测试"
,
"#A9A9A9"
))
.
addData
(
new
WxMpTemplateData
(
"keyword2"
,
"这又是个测试"
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"remark"
,
"这还是个测试"
,
"#000000"
));
String
msgId
=
null
;
try
{
// 发送模板消息
WxMpConfigStorage
wxMpConfig
=
wxMpConfig
(
appid
,
secret
);
WxMpService
wxMpService
=
wxMpService
(
wxMpConfig
);
msgId
=
wxMpService
.
getTemplateMsgService
().
sendTemplateMsg
(
templateMessage
);
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
msgId
);
return
ResponseDto
.
success
();
}
public
void
sendMsg
()
{
String
openId
=
""
;
String
templateId
=
""
;
send
(
openId
,
templateId
);
}
private
WxMpConfigStorage
wxMpConfig
(
String
appId
,
String
appSecret
)
{
WxMpDefaultConfigImpl
config
=
new
WxMpDefaultConfigImpl
();
config
.
setAppId
(
appId
);
config
.
setSecret
(
appSecret
);
return
config
;
}
private
WxMpService
wxMpService
(
WxMpConfigStorage
mpConfig
)
{
WxMpService
service
=
new
WxMpServiceImpl
();
service
.
setWxMpConfigStorage
(
mpConfig
);
return
service
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment