Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-yunqueyilian
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.wechat
pica-cloud-yunqueyilian
提交
ad2d92ec
提交
ad2d92ec
编写于
8月 10, 2018
作者:
chenzhehao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微信消息处理流程修改
上级
cb6342c6
变更
3
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
185 行增加
和
51 行删除
+185
-51
PWechatUserMapper.java
.../wechat/yunqueyilian/server/mapper/PWechatUserMapper.java
+6
-0
CoreServiceImpl.java
...hat/yunqueyilian/server/service/impl/CoreServiceImpl.java
+53
-18
PWechatUserMapper.xml
server/src/main/resources/mybatis/PWechatUserMapper.xml
+126
-33
未找到文件。
server/src/main/java/com/pica/cloud/wechat/yunqueyilian/server/mapper/PWechatUserMapper.java
浏览文件 @
ad2d92ec
...
...
@@ -7,4 +7,10 @@ import java.util.Map;
public
interface
PWechatUserMapper
{
PWechatUser
queryByOpenId
(
Map
map
);
int
insert
(
PWechatUser
user
);
int
updateById
(
PWechatUser
user
);
int
updateSubscribeById
(
PWechatUser
user
);
}
\ No newline at end of file
server/src/main/java/com/pica/cloud/wechat/yunqueyilian/server/service/impl/CoreServiceImpl.java
浏览文件 @
ad2d92ec
...
...
@@ -14,9 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.*
;
/**
* @author: zhehao.chen
...
...
@@ -73,27 +71,17 @@ public class CoreServiceImpl implements CoreService {
// 事件类型
String
eventType
=
requestMap
.
get
(
"Event"
);
logger
.
info
(
"eventType:"
+
eventType
);
//关注流程处理
if
(
eventType
.
equals
(
Constants
.
EVENT_TYPE_SUBSCRIBE
))
{
//获得openId
String
openId
=
fromUserName
;
//调用微信的接口,获取微信用户的详细信息
Map
map
=
userServiceClient
.
users
(
Constants
.
WECHAT_NAME_YQYL
,
openId
);
logger
.
info
(
map
.
toString
());
//1.首先处理p_wechat_user表,存在信息就补全,不存在就新增
// insertOrUpdataWechatDoctor(requestMap, map, userGet);
}
// 取消订阅
else
if
(
eventType
.
equals
(
Constants
.
EVENT_TYPE_UNSUBSCRIBE
))
{
//关注、取消关注流程处理
if
(
eventType
.
equals
(
Constants
.
EVENT_TYPE_SUBSCRIBE
)
||
eventType
.
equals
(
Constants
.
EVENT_TYPE_UNSUBSCRIBE
))
{
String
openId
=
fromUserName
;
//获得openId
Map
mapIn
=
new
HashMap
();
mapIn
.
put
(
"type"
,
1
);
//1云鹊医联
mapIn
.
put
(
"openId"
,
openId
);
PWechatUser
userGet
=
wechatUserMapper
.
queryByOpenId
(
mapIn
);
//从wechat表中获取数据
Map
map
=
userServiceClient
.
users
(
Constants
.
WECHAT_NAME_YQYL
,
openId
);
//调用微信的接口,获取微信用户的详细信息
logger
.
info
(
map
.
toString
());
logger
.
info
(
"调用微信接口获取用户信息:"
+
map
.
toString
());
//1.首先处理p_wechat_user表,存在信息就补全,不存在就新增
// insertOrUpdataWechatDoctor(requestMap, map
, userGet);
insertOrUpdataWechatUser
(
requestMap
,
(
HashMap
)
map
.
get
(
"data"
)
,
userGet
);
}
// 自定义菜单点击事件
else
if
(
eventType
.
equals
(
Constants
.
EVENT_TYPE_CLICK
))
{
...
...
@@ -121,8 +109,55 @@ public class CoreServiceImpl implements CoreService {
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
"微信消息处理流程异常"
,
e
);
}
return
respMessage
;
}
private
void
insertOrUpdataWechatUser
(
Map
<
String
,
String
>
requestMap
,
Map
map
,
PWechatUser
wechatUser
)
{
String
eventType
=
requestMap
.
get
(
"Event"
);
if
(
eventType
.
equals
(
Constants
.
EVENT_TYPE_SUBSCRIBE
))
{
//关注
boolean
newFlag
=
false
;
if
(
StringUtil
.
isNull
(
wechatUser
))
{
//新增
wechatUser
=
new
PWechatUser
();
newFlag
=
true
;
}
wechatUser
.
setOpenid
((
String
)
map
.
get
(
"openid"
));
wechatUser
.
setType
(
1
);
//1、云鹊医联
wechatUser
.
setSex
((
Integer
)
map
.
get
(
"sex"
));
wechatUser
.
setNickname
((
String
)
map
.
get
(
"nickname"
));
wechatUser
.
setProvince
((
String
)
map
.
get
(
"province"
));
wechatUser
.
setCity
((
String
)
map
.
get
(
"city"
));
wechatUser
.
setCountry
((
String
)
map
.
get
(
"country"
));
wechatUser
.
setHeadimgurl
((
String
)
map
.
get
(
"headimgurl"
));
wechatUser
.
setPrivilege
((
String
)
map
.
get
(
"privilege"
));
wechatUser
.
setUnionid
((
String
)
map
.
get
(
"unionid"
));
wechatUser
.
setSubscribe
((
Integer
)
map
.
get
(
"subscribe"
));
wechatUser
.
setLanguage
((
String
)
map
.
get
(
"language"
));
Integer
subscribe_time
=
(
Integer
)
map
.
get
(
"subscribe_time"
);
logger
.
info
(
subscribe_time
.
toString
());
wechatUser
.
setSubscribeTime
(
StringUtil
.
isNull
(
subscribe_time
)
?
new
Date
()
:
new
Date
(
subscribe_time
));
wechatUser
.
setRemark
((
String
)
map
.
get
(
"remark"
));
wechatUser
.
setGroupid
(
String
.
valueOf
(
map
.
get
(
"groupid"
)));
List
tagid_list
=
(
ArrayList
)
map
.
get
(
"tagid_list"
);
logger
.
info
(
StringUtil
.
isNull
(
tagid_list
)
?
""
:
tagid_list
.
toString
());
wechatUser
.
setTagidList
(
StringUtil
.
isNull
(
tagid_list
)
?
""
:
tagid_list
.
toString
());
wechatUser
.
setDeleteFlag
(
1
);
wechatUser
.
setCreatId
(
0
);
wechatUser
.
setModifyId
(
0
);
if
(
newFlag
)
{
//新增
wechatUserMapper
.
insert
(
wechatUser
);
}
else
{
//更新
wechatUserMapper
.
updateById
(
wechatUser
);
}
}
else
if
(
eventType
.
equals
(
Constants
.
EVENT_TYPE_UNSUBSCRIBE
))
{
//取消关注
if
(
StringUtil
.
isNull
(
wechatUser
))
{
//新增
}
wechatUser
.
setSubscribe
(
0
);
wechatUserMapper
.
updateSubscribeById
(
wechatUser
);
}
}
}
server/src/main/resources/mybatis/PWechatUserMapper.xml
浏览文件 @
ad2d92ec
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pica.cloud.wechat.yunqueyilian.server.mapper.PWechatUserMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pica.cloud.wechat.yunqueyilian.server.entity.PWechatUser"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"openid"
property=
"openid"
jdbcType=
"VARCHAR"
/>
<result
column=
"patient_id"
property=
"patientId"
jdbcType=
"INTEGER"
/>
<result
column=
"type"
property=
"type"
jdbcType=
"INTEGER"
/>
<result
column=
"sex"
property=
"sex"
jdbcType=
"INTEGER"
/>
<result
column=
"nickname"
property=
"nickname"
jdbcType=
"VARCHAR"
/>
<result
column=
"province"
property=
"province"
jdbcType=
"VARCHAR"
/>
<result
column=
"city"
property=
"city"
jdbcType=
"VARCHAR"
/>
<result
column=
"country"
property=
"country"
jdbcType=
"VARCHAR"
/>
<result
column=
"headimgurl"
property=
"headimgurl"
jdbcType=
"VARCHAR"
/>
<result
column=
"privilege"
property=
"privilege"
jdbcType=
"VARCHAR"
/>
<result
column=
"unionid"
property=
"unionid"
jdbcType=
"VARCHAR"
/>
<result
column=
"subscribe"
property=
"subscribe"
jdbcType=
"INTEGER"
/>
<result
column=
"language"
property=
"language"
jdbcType=
"VARCHAR"
/>
<result
column=
"subscribe_time"
property=
"subscribeTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"remark"
property=
"remark"
jdbcType=
"VARCHAR"
/>
<result
column=
"groupid"
property=
"groupid"
jdbcType=
"VARCHAR"
/>
<result
column=
"tagid_list"
property=
"tagidList"
jdbcType=
"VARCHAR"
/>
<result
column=
"delete_flag"
property=
"deleteFlag"
jdbcType=
"INTEGER"
/>
<result
column=
"creat_id"
property=
"creatId"
jdbcType=
"INTEGER"
/>
<result
column=
"creat_time"
property=
"creatTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"modify_id"
property=
"modifyId"
jdbcType=
"INTEGER"
/>
<result
column=
"modify_time"
property=
"modifyTime"
jdbcType=
"TIMESTAMP"
/>
<mapper
namespace=
"com.pica.cloud.wechat.yunqueyilian.server.mapper.PWechatUserMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pica.cloud.wechat.yunqueyilian.server.entity.PWechatUser"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"openid"
property=
"openid"
jdbcType=
"VARCHAR"
/>
<result
column=
"patient_id"
property=
"patientId"
jdbcType=
"INTEGER"
/>
<result
column=
"type"
property=
"type"
jdbcType=
"INTEGER"
/>
<result
column=
"sex"
property=
"sex"
jdbcType=
"INTEGER"
/>
<result
column=
"nickname"
property=
"nickname"
jdbcType=
"VARCHAR"
/>
<result
column=
"province"
property=
"province"
jdbcType=
"VARCHAR"
/>
<result
column=
"city"
property=
"city"
jdbcType=
"VARCHAR"
/>
<result
column=
"country"
property=
"country"
jdbcType=
"VARCHAR"
/>
<result
column=
"headimgurl"
property=
"headimgurl"
jdbcType=
"VARCHAR"
/>
<result
column=
"privilege"
property=
"privilege"
jdbcType=
"VARCHAR"
/>
<result
column=
"unionid"
property=
"unionid"
jdbcType=
"VARCHAR"
/>
<result
column=
"subscribe"
property=
"subscribe"
jdbcType=
"INTEGER"
/>
<result
column=
"language"
property=
"language"
jdbcType=
"VARCHAR"
/>
<result
column=
"subscribe_time"
property=
"subscribeTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"remark"
property=
"remark"
jdbcType=
"VARCHAR"
/>
<result
column=
"groupid"
property=
"groupid"
jdbcType=
"VARCHAR"
/>
<result
column=
"tagid_list"
property=
"tagidList"
jdbcType=
"VARCHAR"
/>
<result
column=
"delete_flag"
property=
"deleteFlag"
jdbcType=
"INTEGER"
/>
<result
column=
"creat_id"
property=
"creatId"
jdbcType=
"INTEGER"
/>
<result
column=
"creat_time"
property=
"creatTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"modify_id"
property=
"modifyId"
jdbcType=
"INTEGER"
/>
<result
column=
"modify_time"
property=
"modifyTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, openid, patient_id, type, sex, nickname, province, city, country, headimgurl,
privilege, unionid, subscribe, language, subscribe_time, remark, groupid, tagid_list,
delete_flag, creat_id, creat_time, modify_id, modify_time
</sql>
<select
id=
"queryByOpenId"
resultMap=
"BaseResultMap"
parameterMap=
"java.util.Map"
>
<insert
id=
"insert"
parameterType=
"com.pica.cloud.wechat.yunqueyilian.server.entity.PWechatUser"
>
insert into p_wechat_user (openid, patient_id,
type, sex, nickname,
province, city, country,
headimgurl, privilege, unionid,
subscribe, language, subscribe_time,
remark, groupid, tagid_list,
delete_flag, creat_id, creat_time,
modify_id, modify_time)
values (#{openid,jdbcType=VARCHAR}, #{patientId,jdbcType=INTEGER},
#{type,jdbcType=INTEGER}, #{sex,jdbcType=INTEGER}, #{nickname,jdbcType=VARCHAR},
#{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{country,jdbcType=VARCHAR},
#{headimgurl,jdbcType=VARCHAR}, #{privilege,jdbcType=VARCHAR}, #{unionid,jdbcType=VARCHAR},
#{subscribe,jdbcType=INTEGER}, #{language,jdbcType=VARCHAR}, #{subscribeTime,jdbcType=TIMESTAMP},
#{remark,jdbcType=VARCHAR}, #{groupid,jdbcType=VARCHAR}, #{tagidList,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=INTEGER}, #{creatId,jdbcType=INTEGER}, SYSDATE(),
#{modifyId,jdbcType=INTEGER}, SYSDATE())
</insert>
<update
id=
"updateById"
parameterType=
"com.pica.cloud.wechat.yunqueyilian.server.entity.PWechatUser"
>
update p_wechat_user
<set>
<if
test=
"openid != null"
>
openid = #{openid,jdbcType=VARCHAR},
</if>
<if
test=
"patientId != null"
>
patient_id = #{patientId,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
type = #{type,jdbcType=INTEGER},
</if>
<if
test=
"sex != null"
>
sex = #{sex,jdbcType=INTEGER},
</if>
<if
test=
"nickname != null"
>
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if
test=
"province != null"
>
province = #{province,jdbcType=VARCHAR},
</if>
<if
test=
"city != null"
>
city = #{city,jdbcType=VARCHAR},
</if>
<if
test=
"country != null"
>
country = #{country,jdbcType=VARCHAR},
</if>
<if
test=
"headimgurl != null"
>
headimgurl = #{headimgurl,jdbcType=VARCHAR},
</if>
<if
test=
"privilege != null"
>
privilege = #{privilege,jdbcType=VARCHAR},
</if>
<if
test=
"unionid != null"
>
unionid = #{unionid,jdbcType=VARCHAR},
</if>
<if
test=
"subscribe != null"
>
subscribe = #{subscribe,jdbcType=INTEGER},
</if>
<if
test=
"language != null"
>
language = #{language,jdbcType=VARCHAR},
</if>
<if
test=
"subscribeTime != null"
>
subscribe_time = #{subscribeTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"remark != null"
>
remark = #{remark,jdbcType=VARCHAR},
</if>
<if
test=
"groupid != null"
>
groupid = #{groupid,jdbcType=VARCHAR},
</if>
<if
test=
"tagidList != null"
>
tagid_list = #{tagidList,jdbcType=VARCHAR},
</if>
<if
test=
"deleteFlag != null"
>
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if
test=
"creatId != null"
>
creat_id = #{creatId,jdbcType=INTEGER},
</if>
<if
test=
"creatTime != null"
>
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"modifyId != null"
>
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if
test=
"modifyTime != null"
>
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select
id=
"queryByOpenId"
resultMap=
"BaseResultMap"
parameterType=
"java.util.Map"
>
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from p_wechat_user
where type = #{type} and openid = #{openId}
</select>
<update
id=
"updateSubscribeById"
parameterType=
"com.pica.cloud.wechat.yunqueyilian.server.entity.PWechatUser"
>
update p_wechat_user set subscribe = #{subscribe} where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录