Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DuibaTestToolV2.1
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
赵然
DuibaTestToolV2.1
Commits
b368f500
Commit
b368f500
authored
Jul 06, 2020
by
赵然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zr
parent
3c5bb45a
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
436 additions
and
14 deletions
+436
-14
RankModule.java
src/main/com/atguigu/springmvc/handlers/RankModule.java
+217
-14
WechatInfoModule.java
...main/com/atguigu/springmvc/handlers/WechatInfoModule.java
+219
-0
No files found.
src/main/com/atguigu/springmvc/handlers/RankModule.java
View file @
b368f500
This diff is collapsed.
Click to expand it.
src/main/com/atguigu/springmvc/handlers/WechatInfoModule.java
0 → 100644
View file @
b368f500
package
main
.
com
.
atguigu
.
springmvc
.
handlers
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
io.restassured.response.Response
;
import
main.com.atguigu.springmvc.service.Authorization
;
import
main.com.atguigu.springmvc.service.NewActivityService
;
import
main.com.atguigu.springmvc.service.SqlService
;
import
main.com.atguigu.springmvc.service.ViewService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
@Controller
public
class
WechatInfoModule
{
@Autowired
NewActivityService
newActivityService
;
@Autowired
Authorization
authorization
;
@Autowired
SqlService
sqlService
;
@Autowired
ViewService
viewService
;
/**
* 功能:通过actId和appId查询配置的关注带参二维码公众号后发送的消息
* @return
*/
@RequestMapping
(
value
=
"/qrcodeInfo"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
qrcodeInfo
(
HttpServletRequest
request
)
throws
Exception
{
String
appId
=
request
.
getParameter
(
"appId"
);
String
actId
=
request
.
getParameter
(
"actId"
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"SELECT id,act_id,app_id,reply_text,reply_url,gmt_modified FROM wechat.tb_wx_reply_config where "
);
if
(
StringUtils
.
isNotBlank
(
actId
))
{
//如果actId是星宿台项目,则将actId转化成10进制字符串
if
(
actId
.
startsWith
(
"p"
)){
actId
=
decodeHEX
(
actId
.
substring
(
1
,
actId
.
length
()));
}
sb
.
append
(
"act_id='"
).
append
(
actId
).
append
(
"' and "
);
}
if
(
StringUtils
.
isNotBlank
(
appId
))
{
sb
.
append
(
"app_id='"
).
append
(
appId
).
append
(
"' and "
);
}
sb
.
append
(
"1=1 order by id desc"
);
//System.out.println(sb.toString());
Response
response
=
sqlService
.
findModeResult
(
sb
.
toString
());
if
(
response
.
asString
().
equals
(
"[]"
))
{
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"未查询到消息"
);
}
else
{
JSONArray
ar
=
JSONArray
.
parseArray
(
response
.
asString
());
map
.
put
(
"success"
,
"true"
);
map
.
put
(
"message"
,
ar
);
}
return
map
;
}
/**
* 功能:新增关注带参二维码公众号后发送的消息
* @return
*/
@RequestMapping
(
value
=
"/createqrcodeInfo"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
createqrcodeInfo
(
HttpServletRequest
request
)
throws
Exception
{
String
originalActId
=
request
.
getParameter
(
"actId"
);
//如果actId是星宿台项目,则将actId转化成10进制字符串
if
(
originalActId
.
startsWith
(
"p"
)){
originalActId
=
decodeHEX
(
originalActId
.
substring
(
1
,
originalActId
.
length
()));
}
String
actId
=
originalActId
;
String
appId
=
request
.
getParameter
(
"appId"
);
String
actType
=
request
.
getParameter
(
"actType"
);
String
replyText
=
request
.
getParameter
(
"replyText"
);
String
replyText0
=
"<a href=\"{1}\">"
+
replyText
+
"</a>"
;
String
replyUrl
=
request
.
getParameter
(
"replyUrl"
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
String
sql1
=
"SELECT act_id,app_id FROM wechat.tb_wx_reply_config"
;
Response
response1
=
sqlService
.
findModeResult
(
sql1
);
//System.out.println(response1.asString());
List
<
InfoVO
>
infoVOList
=
Collections
.
emptyList
();
if
(
response1
.
asString
()
!=
null
&&
StringUtils
.
isNotBlank
(
response1
.
asString
()))
{
infoVOList
=
JSON
.
parseArray
(
response1
.
asString
(),
InfoVO
.
class
);
}
if
(
StringUtils
.
isBlank
(
actId
)||
StringUtils
.
isBlank
(
appId
)||
StringUtils
.
isBlank
(
actType
)||
StringUtils
.
isBlank
(
replyText
)||
StringUtils
.
isBlank
(
replyUrl
)){
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"请填写所有信息!"
);
}
else
if
(
infoVOList
.
stream
().
anyMatch
(
infoVO
->
Objects
.
equals
(
actId
,
infoVO
.
getActId
())
&&
Objects
.
equals
(
appId
,
infoVO
.
getAppId
())))
{
//判断输入的appid下已有该actid的消息,则不执行插入;否则执行插入
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"当前appid下已有该actid的消息"
);
}
else
{
String
sql2
=
"insert into wechat.tb_wx_reply_config (act_id,app_id,act_type,reply_text,reply_url)values("
+
actId
+
",'"
+
appId
+
"','"
+
actType
+
"','"
+
replyText0
+
"','"
+
replyUrl
+
"')"
;
sqlService
.
update
(
sql2
);
map
.
put
(
"success"
,
"true"
);
map
.
put
(
"message"
,
"消息配置成功!"
);
}
return
map
;
}
public
static
class
InfoVO
{
private
String
actId
;
private
String
appId
;
public
String
getActId
()
{
return
actId
;
}
public
void
setActId
(
String
actId
)
{
this
.
actId
=
actId
;
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
}
/**
* 功能:修改关注带参二维码公众号后发送的消息
* @return
*/
@RequestMapping
(
value
=
"/updateqrcodeInfo"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Map
updateqrcodeInfo
(
HttpServletRequest
request
)
throws
Exception
{
String
id
=
request
.
getParameter
(
"id"
);
String
originalActId
=
request
.
getParameter
(
"actId"
);
//如果actId是星宿台项目,则将actId转化成10进制字符串
if
(
originalActId
.
startsWith
(
"p"
)){
originalActId
=
decodeHEX
(
originalActId
.
substring
(
1
,
originalActId
.
length
()));
}
String
actId
=
originalActId
;
String
appId
=
request
.
getParameter
(
"appId"
);
String
actType
=
request
.
getParameter
(
"actType"
);
String
replyText
=
request
.
getParameter
(
"replyText"
);
String
replyText0
=
"<a href=\"{1}\">"
+
replyText
+
"</a>"
;
String
replyUrl
=
request
.
getParameter
(
"replyUrl"
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
StringUtils
.
isBlank
(
id
)){
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"请输入id!"
);
}
else
{
boolean
needUpdate
=
false
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"update wechat.tb_wx_reply_config set "
);
if
(
StringUtils
.
isNotBlank
(
actId
))
{
needUpdate
=
true
;
sb
.
append
(
"act_id='"
).
append
(
actId
).
append
(
"',"
);
}
if
(
StringUtils
.
isNotBlank
(
appId
))
{
needUpdate
=
true
;
sb
.
append
(
"app_id='"
).
append
(
appId
).
append
(
"',"
);
}
if
(
StringUtils
.
isNotBlank
(
actType
))
{
needUpdate
=
true
;
sb
.
append
(
"act_type='"
).
append
(
actType
).
append
(
"',"
);
}
if
(
StringUtils
.
isNotBlank
(
replyText
))
{
needUpdate
=
true
;
sb
.
append
(
"reply_text='"
).
append
(
replyText0
).
append
(
"',"
);
}
if
(
StringUtils
.
isNotBlank
(
replyUrl
))
{
needUpdate
=
true
;
sb
.
append
(
"reply_url='"
).
append
(
replyUrl
).
append
(
"',"
);
}
sb
.
append
(
"id='"
).
append
(
id
).
append
(
"'"
);
sb
.
append
(
" where id="
).
append
(
id
);
//System.out.println(sb.toString());
String
sql3
=
"SELECT act_id,app_id FROM wechat.tb_wx_reply_config"
;
Response
response3
=
sqlService
.
findModeResult
(
sql3
);
List
<
InfoVO
>
infoVOList
=
Collections
.
emptyList
();
if
(
response3
.
asString
()
!=
null
&&
StringUtils
.
isNotBlank
(
response3
.
asString
()))
{
infoVOList
=
JSON
.
parseArray
(
response3
.
asString
(),
InfoVO
.
class
);
}
if
(!
needUpdate
)
{
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"请输入要修改的内容!"
);
}
else
if
(
infoVOList
.
stream
().
anyMatch
(
infoVO
->
Objects
.
equals
(
actId
,
infoVO
.
getActId
())
&&
Objects
.
equals
(
appId
,
infoVO
.
getAppId
())))
{
//判断输入的appid下已有该actid的消息,则不执行插入;否则执行插入
map
.
put
(
"success"
,
"false"
);
map
.
put
(
"message"
,
"当前appid下已有该actid的消息"
);
}
else
{
sqlService
.
update
(
sb
.
toString
());
map
.
put
(
"success"
,
"true"
);
map
.
put
(
"message"
,
"消息修改成功!"
);
}
}
return
map
;
}
//将16进制字符串转化为10进制数字的字符串
public
static
String
decodeHEX
(
String
hexs
){
int
numb
=
Integer
.
parseInt
(
hexs
,
16
);
String
actID
=
Integer
.
toString
(
numb
);
return
actID
;
}
}
\ No newline at end of file
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