Commit f3320628 authored by shiyu's avatar shiyu

公众号订阅

parent baee6e33
......@@ -8,7 +8,6 @@ import com.wwdz.ch.db.mapper.OfficialAccountSubscribeRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.Date;
@Repository
public class OfficialAccountSubscribeRecordDaoImpl implements OfficialAccountSubscribeRecordDao {
......
<?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.wwdz.ch.db.mapper.OfficialAccountSubscribeRecordMapper">
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="openid" jdbcType="VARCHAR" property="openid" />
<result column="platform_type" jdbcType="INTEGER" property="platformType" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="enabled" jdbcType="INTEGER" property="enabled" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, openid, platform_type, phone, create_time, update_time, enabled
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecordExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from official_account_subscribe_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<if test="example.distinct">
distinct
</if>
<choose>
<when test="selective != null and selective.length > 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, openid, platform_type, phone, create_time, update_time, enabled
</otherwise>
</choose>
from official_account_subscribe_record
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from official_account_subscribe_record
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when test="selective != null and selective.length > 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, openid, platform_type, phone, create_time, update_time, enabled
</otherwise>
</choose>
from official_account_subscribe_record
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from official_account_subscribe_record
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecordExample">
delete from official_account_subscribe_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into official_account_subscribe_record (openid, platform_type, phone,
create_time, update_time, enabled
)
values (#{openid,jdbcType=VARCHAR}, #{platformType,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{enabled,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into official_account_subscribe_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="openid != null">
openid,
</if>
<if test="platformType != null">
platform_type,
</if>
<if test="phone != null">
phone,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="enabled != null">
enabled,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openid != null">
#{openid,jdbcType=VARCHAR},
</if>
<if test="platformType != null">
#{platformType,jdbcType=INTEGER},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="enabled != null">
#{enabled,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecordExample" resultType="java.lang.Long">
select count(*) from official_account_subscribe_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update official_account_subscribe_record
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.openid != null">
openid = #{record.openid,jdbcType=VARCHAR},
</if>
<if test="record.platformType != null">
platform_type = #{record.platformType,jdbcType=INTEGER},
</if>
<if test="record.phone != null">
phone = #{record.phone,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.enabled != null">
enabled = #{record.enabled,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update official_account_subscribe_record
set id = #{record.id,jdbcType=INTEGER},
openid = #{record.openid,jdbcType=VARCHAR},
platform_type = #{record.platformType,jdbcType=INTEGER},
phone = #{record.phone,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
enabled = #{record.enabled,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord">
update official_account_subscribe_record
<set>
<if test="openid != null">
openid = #{openid,jdbcType=VARCHAR},
</if>
<if test="platformType != null">
platform_type = #{platformType,jdbcType=INTEGER},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="enabled != null">
enabled = #{enabled,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecord">
update official_account_subscribe_record
set openid = #{openid,jdbcType=VARCHAR},
platform_type = #{platformType,jdbcType=INTEGER},
phone = #{phone,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
enabled = #{enabled,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.OfficialAccountSubscribeRecordExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<include refid="Base_Column_List" />
from official_account_subscribe_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
limit 1
</select>
<select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
'true' as QUERYID,
<choose>
<when test="selective != null and selective.length > 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, openid, platform_type, phone, create_time, update_time, enabled
</otherwise>
</choose>
from official_account_subscribe_record
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
<if test="example.orderByClause != null">
order by ${example.orderByClause}
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
......@@ -92,14 +92,14 @@ public class OfficialAccountCallbackController {
//新增或更新订阅记录
OfficialAccountSubscribeRecord officialAccountSubscribeRecord = new OfficialAccountSubscribeRecord();
officialAccountSubscribeRecord.setOpenid(userOpenId);
//查询有无历史订阅记录
boolean isExisted = officialAccountSubscribeRecordService.isExisted(userOpenId);
if (isExisted) {
if (SUBSCRIBE_EVENT.equals(event)) {
officialAccountSubscribeRecord.setEnabled(1);
} else {
officialAccountSubscribeRecord.setEnabled(0);
}
//查询有无历史订阅记录
boolean isExisted = officialAccountSubscribeRecordService.isExisted(userOpenId);
if (isExisted) {
officialAccountSubscribeRecord.setUpdateTime(date);
officialAccountSubscribeRecordService.update(officialAccountSubscribeRecord);
} else {
......@@ -110,7 +110,6 @@ public class OfficialAccountCallbackController {
}
officialAccountSubscribeRecord.setCreateTime(date);
officialAccountSubscribeRecord.setUpdateTime(date);
officialAccountSubscribeRecord.setEnabled(1);
officialAccountSubscribeRecord.setPlatformType(OfficalAccountEnum.PlatformTypeEnum.WECHAT.getCode());
officialAccountSubscribeRecordService.insert(officialAccountSubscribeRecord);
}
......
......@@ -8,8 +8,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment