提醒关注微信公众号
parent
fe0837c486
commit
384d05eabe
@ -0,0 +1,65 @@
|
||||
package com.flossom.common.core.mapper;
|
||||
|
||||
import com.flossom.common.core.domain.entity.WxNoRemindRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 微信用户关闭提醒记录Mapper接口
|
||||
*
|
||||
* @author flossom
|
||||
* @date 2023-12-16
|
||||
*/
|
||||
public interface WxNoRemindRecordMapper {
|
||||
/**
|
||||
* 查询微信用户关闭提醒记录
|
||||
*
|
||||
* @param id 微信用户关闭提醒记录主键
|
||||
* @return 微信用户关闭提醒记录
|
||||
*/
|
||||
public WxNoRemindRecord selectWxNoRemindRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 查询微信用户关闭提醒记录列表
|
||||
*
|
||||
* @param wxNoRemindRecord 微信用户关闭提醒记录
|
||||
* @return 微信用户关闭提醒记录集合
|
||||
*/
|
||||
public List<WxNoRemindRecord> selectWxNoRemindRecordList(WxNoRemindRecord wxNoRemindRecord);
|
||||
|
||||
/**
|
||||
* 新增微信用户关闭提醒记录
|
||||
*
|
||||
* @param wxNoRemindRecord 微信用户关闭提醒记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertWxNoRemindRecord(WxNoRemindRecord wxNoRemindRecord);
|
||||
|
||||
/**
|
||||
* 修改微信用户关闭提醒记录
|
||||
*
|
||||
* @param wxNoRemindRecord 微信用户关闭提醒记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateWxNoRemindRecord(WxNoRemindRecord wxNoRemindRecord);
|
||||
|
||||
/**
|
||||
* 删除微信用户关闭提醒记录
|
||||
*
|
||||
* @param id 微信用户关闭提醒记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWxNoRemindRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除微信用户关闭提醒记录
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWxNoRemindRecordByIds(Long[] ids);
|
||||
|
||||
int selectWxNoRemindRecordByOpenid(@Param("openid") String openid);
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
<?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.flossom.common.core.mapper.WxNoRemindRecordMapper">
|
||||
|
||||
<resultMap type="WxNoRemindRecord" id="WxNoRemindRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="openid" column="openid" />
|
||||
<result property="type" column="type" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectWxNoRemindRecordVo">
|
||||
select id, openid, type, create_time from wx_no_remind_record
|
||||
</sql>
|
||||
|
||||
<select id="selectWxNoRemindRecordList" parameterType="WxNoRemindRecord" resultMap="WxNoRemindRecordResult">
|
||||
<include refid="selectWxNoRemindRecordVo"/>
|
||||
<where>
|
||||
<if test="openid != null and openid != ''"> and openid = #{openid}</if>
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectWxNoRemindRecordById" parameterType="Long" resultMap="WxNoRemindRecordResult">
|
||||
<include refid="selectWxNoRemindRecordVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectWxNoRemindRecordByOpenid" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
`wx_no_remind_record`
|
||||
WHERE
|
||||
openid = #{openid}
|
||||
AND YEAR (create_time) = YEAR (sysdate())
|
||||
</select>
|
||||
|
||||
<insert id="insertWxNoRemindRecord" parameterType="WxNoRemindRecord" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into wx_no_remind_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="openid != null">openid,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="openid != null">#{openid},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateWxNoRemindRecord" parameterType="WxNoRemindRecord">
|
||||
update wx_no_remind_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="openid != null">openid = #{openid},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteWxNoRemindRecordById" parameterType="Long">
|
||||
delete from wx_no_remind_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteWxNoRemindRecordByIds" parameterType="String">
|
||||
delete from wx_no_remind_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,43 @@
|
||||
package com.flossom.miniProgram.controller;
|
||||
|
||||
|
||||
import com.flossom.common.core.domain.R;
|
||||
import com.flossom.common.core.web.controller.BaseController;
|
||||
import com.flossom.common.core.web.domain.AjaxResult;
|
||||
import com.flossom.miniProgram.service.IWxNoRemindService;
|
||||
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.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/noRemind")
|
||||
public class WxNoRemindController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWxNoRemindService wxNoRemindService;
|
||||
|
||||
/**
|
||||
* 查询用户是否关闭了 ·提醒关注微信公众号·
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/getOfficialAccount")
|
||||
public R officialAccount() {
|
||||
return R.ok(wxNoRemindService.officialAccount() > 0 ? true : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭 ·提醒关注微信公众号·
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/closeOfficialAccount")
|
||||
public AjaxResult closeOfficialAccount() {
|
||||
wxNoRemindService.closeOfficialAccount();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.flossom.miniProgram.service;
|
||||
|
||||
import com.flossom.common.core.domain.entity.WxNoRemindRecord;
|
||||
|
||||
public interface IWxNoRemindService {
|
||||
|
||||
Integer officialAccount();
|
||||
|
||||
void closeOfficialAccount();
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.flossom.miniProgram.service.impl;
|
||||
|
||||
import com.flossom.common.core.domain.R;
|
||||
import com.flossom.common.core.domain.entity.WxNoRemindRecord;
|
||||
import com.flossom.common.core.mapper.WxNoRemindRecordMapper;
|
||||
import com.flossom.common.core.utils.DateUtils;
|
||||
import com.flossom.common.core.web.domain.AjaxResult;
|
||||
import com.flossom.common.security.utils.SecurityUtils;
|
||||
import com.flossom.miniProgram.service.IWxNoRemindService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class WxNoRemindServiceImpl implements IWxNoRemindService {
|
||||
|
||||
@Autowired
|
||||
private WxNoRemindRecordMapper wxNoRemindRecordMapper;
|
||||
|
||||
@Override
|
||||
public Integer officialAccount() {
|
||||
return wxNoRemindRecordMapper.selectWxNoRemindRecordByOpenid(SecurityUtils.getLoginUser().getWxUserMember().getOpenid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeOfficialAccount() {
|
||||
WxNoRemindRecord wxNoRemindRecord = new WxNoRemindRecord();
|
||||
wxNoRemindRecord.setOpenid(SecurityUtils.getLoginUser().getWxUserMember().getOpenid());
|
||||
wxNoRemindRecord.setCreateTime(DateUtils.getNowDate());
|
||||
wxNoRemindRecordMapper.insertWxNoRemindRecord(wxNoRemindRecord);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue