Commit 08729d3f by 阮思源

个人号资源服务或分类有新增时,主动推送给好友

parent 5510192c
......@@ -427,4 +427,15 @@ public class WechatGroupConsr {
}
return map;
}
@ParamLog("查询小号信息")
public GroupRobotDTO getGroupRobotByWxId(String altId) {
GroupRobotDTO groupRobotDTO = new GroupRobotDTO();
try {
groupRobotDTO = ResponseHandleUtil.parseResponse(groupMemberService.getGroupRobotByWxId(altId), GroupRobotDTO.class);
} catch (Exception e) {
log.error("查询小号信息.[getGroupRobotByWxId]:" + e.getMessage(), e);
}
return groupRobotDTO;
}
}
......@@ -482,4 +482,29 @@ public interface BookGroupBiz {
* 社群书下二维码
*/
List<Long> getQrcodeIdsByBookGroupId(Long bookGroupId);
/**
* 更新是否邀请入群
*/
void updateIsInviteGroup(BookGroup bookGroup);
/**
* 更新1v1是否有更新
*/
void updateIsSomeUpdate(BookGroup bookGroup);
/**
* 新增推送更新
*/
void addPushBookGroupUpdate(BookGroup bookGroup);
/**
* 推送更新
*/
void pushBookGroupUpdate();
/**
* 获取是否能推送更新的各个状态
*/
Map<String,Boolean> getStatesForPushUpdate(Long bookGroupId);
}
......@@ -36,4 +36,9 @@ public interface BookGroupCipherUserDao extends BaseDao<BookGroupCipherUser> {
* @return
*/
public Integer getFriendsCountByBookGroupByTime(Long bookGroupId, String startTime, String endTime);
/**
* 查询社群书关联的用户id集合
*/
List<BookGroupCipherUser> getWxUserIdAndAltsByBookGroupId(Long bookGroupId);
}
......@@ -204,4 +204,20 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
* @return
*/
List<BookGroupAnalysisVO> listPageBookGroupAnalysis(Map<String, Object> paramMap);
/**
* 更新是否邀请入群
*/
void updateIsInviteGroup(Long id, Boolean isInviteGroup);
/**
* 更新1v1是否有更新
*/
void updateIsSomeUpdate(Long id, Boolean isSomeUpdate);
/**
* 更新上次推送时间
*/
void updateLastPushUpdateTime(Long bookGroupId);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.entity.PushBookGroupUpdate;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PushBookGroupUpdateDao extends BaseDao<PushBookGroupUpdate> {
Integer batchInsert(List<PushBookGroupUpdate> list);
PushBookGroupUpdate getEarliestPushBookGroupUpdate();
Integer updateIsPushTrue(Long id);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.entity.WeixinQrcodeGeneration;
import com.pcloud.common.core.dao.BaseDao;
/**
* @author ruansiyuan
* @date 2019/10/29 10:19
*/
public interface WeixinQrcodeGenerationDao extends BaseDao<WeixinQrcodeGeneration> {
WeixinQrcodeGeneration getByGeneration(Integer generation);
}
......@@ -45,4 +45,11 @@ public class BookGroupCipherUserDaoImpl extends BaseDaoImpl<BookGroupCipherUser>
map.put("endTime", endTime);
return getSessionTemplate().selectOne(getStatement("getFriendsCountByBookGroupByTime"), map);
}
@Override
public List<BookGroupCipherUser> getWxUserIdAndAltsByBookGroupId(Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return getSessionTemplate().selectList(getStatement("getWxUserIdAndAltsByBookGroupId"), map);
}
}
......@@ -213,4 +213,27 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
public List<BookGroupAnalysisVO> listPageBookGroupAnalysis(Map<String, Object> paramMap) {
return getSessionTemplate().selectList(getStatement("listPageBookGroupAnalysis"), paramMap);
}
@Override
public void updateIsInviteGroup(Long id, Boolean isInviteGroup) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("isInviteGroup", isInviteGroup);
super.getSqlSession().update(getStatement("updateIsInviteGroup"), paramMap);
}
@Override
public void updateIsSomeUpdate(Long id, Boolean isSomeUpdate) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("id", id);
paramMap.put("isSomeUpdate", isSomeUpdate);
super.getSqlSession().update(getStatement("updateIsSomeUpdate"), paramMap);
}
@Override
public void updateLastPushUpdateTime(Long bookGroupId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookGroupId", bookGroupId);
super.getSqlSession().update(getStatement("updateLastPushUpdateTime"), paramMap);
}
}
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.PushBookGroupUpdateDao;
import com.pcloud.book.group.entity.PushBookGroupUpdate;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/10/28 12:09
**/
@Component("pushBookGroupUpdateDao")
public class PushBookGroupUpdateDaoImpl extends BaseDaoImpl<PushBookGroupUpdate> implements PushBookGroupUpdateDao {
@Override
public Integer batchInsert(List<PushBookGroupUpdate> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public PushBookGroupUpdate getEarliestPushBookGroupUpdate() {
return super.getSqlSession().selectOne(getStatement("getEarliestPushBookGroupUpdate"));
}
@Override
public Integer updateIsPushTrue(Long id) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
return super.getSqlSession().update(getStatement("updateIsPushTrue"), map);
}
}
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.WeixinQrcodeGenerationDao;
import com.pcloud.book.group.entity.WeixinQrcodeGeneration;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/10/29 10:27
**/
@Component("weixinQrcodeGenerationDao")
public class WeixinQrcodeGenerationDaoImpl extends BaseDaoImpl<WeixinQrcodeGeneration> implements WeixinQrcodeGenerationDao {
@Override
public WeixinQrcodeGeneration getByGeneration(Integer generation) {
return this.getSqlSession().selectOne(this.getStatement("getByGeneration"),generation);
}
}
......@@ -186,6 +186,17 @@ public class BookGroupDTO extends BaseDto {
*/
private String publish;
/**
* 1v1上次推送更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lastPushUpdateTime;
/**
* 1v1是否在上次推送更新之后有新的更新
*/
private Boolean isSomeUpdate;
public String getUrl() {
return url;
......@@ -477,6 +488,22 @@ public class BookGroupDTO extends BaseDto {
this.publish = publish;
}
public Date getLastPushUpdateTime() {
return lastPushUpdateTime;
}
public void setLastPushUpdateTime(Date lastPushUpdateTime) {
this.lastPushUpdateTime = lastPushUpdateTime;
}
public Boolean getIsSomeUpdate() {
return isSomeUpdate;
}
public void setIsSomeUpdate(Boolean isSomeUpdate) {
this.isSomeUpdate = isSomeUpdate;
}
@Override
public String toString() {
return "BookGroupDTO{" +
......@@ -516,6 +543,8 @@ public class BookGroupDTO extends BaseDto {
", agentId=" + agentId +
", agentName='" + agentName + '\'' +
", publish='" + publish + '\'' +
", lastPushUpdateTime=" + lastPushUpdateTime +
", isSomeUpdate=" + isSomeUpdate +
"} " + super.toString();
}
}
\ No newline at end of file
package com.pcloud.book.group.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
/**
......@@ -127,6 +129,17 @@ public class BookGroup extends BaseEntity {
*/
private String bookGroupCipher;
/**
* 1v1上次推送更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lastPushUpdateTime;
/**
* 1v1是否在上次推送更新之后有新的更新
*/
private Boolean isSomeUpdate;
public Long getId() {
return id;
}
......@@ -311,6 +324,22 @@ public class BookGroup extends BaseEntity {
this.bookGroupCipher = bookGroupCipher;
}
public Date getLastPushUpdateTime() {
return lastPushUpdateTime;
}
public void setLastPushUpdateTime(Date lastPushUpdateTime) {
this.lastPushUpdateTime = lastPushUpdateTime;
}
public Boolean getIsSomeUpdate() {
return isSomeUpdate;
}
public void setIsSomeUpdate(Boolean isSomeUpdate) {
this.isSomeUpdate = isSomeUpdate;
}
@Override
public String toString() {
return "BookGroup{" +
......@@ -337,6 +366,8 @@ public class BookGroup extends BaseEntity {
", customerServiceName='" + customerServiceName + '\'' +
", isInviteGroup=" + isInviteGroup +
", bookGroupCipher='" + bookGroupCipher + '\'' +
", lastPushUpdateTime=" + lastPushUpdateTime +
", isSomeUpdate=" + isSomeUpdate +
"} " + super.toString();
}
}
\ No newline at end of file
package com.pcloud.book.group.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/10/28 12:03
**/
public class PushBookGroupUpdate extends BaseEntity {
private static final long serialVersionUID = 6491519885230909700L;
@ApiModelProperty("社群书id")
private Long bookGroupId;
@ApiModelProperty("用户微信id")
private String wxUserId;
@ApiModelProperty("机器人id")
private String altId;
@ApiModelProperty("是否已推送")
private Boolean isPush;
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId;
}
public String getAltId() {
return altId;
}
public void setAltId(String altId) {
this.altId = altId;
}
public Boolean getIsPush() {
return isPush;
}
public void setIsPush(Boolean isPush) {
this.isPush = isPush;
}
@Override
public String toString() {
return "PushBookGroupUpdate{" +
"bookGroupId=" + bookGroupId +
", wxUserId='" + wxUserId + '\'' +
", altId='" + altId + '\'' +
", isPush=" + isPush +
"} " + super.toString();
}
}
package com.pcloud.book.group.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
/**
* @author ruansiyuan
* @date 2019/10/29 10:21
*/
public class WeixinQrcodeGeneration extends BaseEntity {
@ApiModelProperty("版本号")
private Integer generation;
@ApiModelProperty("微信群ip")
private String wechatGroupIp;
@ApiModelProperty("虚拟机ip")
private String virtualMachineIp;
public Integer getGeneration() {
return generation;
}
public void setGeneration(Integer generation) {
this.generation = generation;
}
public String getWechatGroupIp() {
return wechatGroupIp;
}
public void setWechatGroupIp(String wechatGroupIp) {
this.wechatGroupIp = wechatGroupIp;
}
public String getVirtualMachineIp() {
return virtualMachineIp;
}
public void setVirtualMachineIp(String virtualMachineIp) {
this.virtualMachineIp = virtualMachineIp;
}
@Override
public String toString() {
return "WeixinQrcodeGeneration{" +
"generation=" + generation +
", wechatGroupIp='" + wechatGroupIp + '\'' +
", virtualMachineIp='" + virtualMachineIp + '\'' +
"} " + super.toString();
}
}
......@@ -455,4 +455,32 @@ public interface BookGroupFacade {
public ResponseDto<?>exportBookGroupAnalysis(
@RequestHeader("token") String token, @RequestBody @ApiParam BookGroupAnalysisParam bookGroupAnalysisParam) throws PermissionException;
@ApiOperation("更新是否邀请入群")
@PostMapping("updateIsInviteGroup")
ResponseDto<?> updateIsInviteGroup(
@RequestHeader("token") String token,
@RequestBody BookGroup bookGroup
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("更新1v1是否有更新")
@PostMapping("updateIsSomeUpdate")
ResponseDto<?> updateIsSomeUpdate(
@RequestHeader("token") String token,
@RequestBody BookGroup bookGroup
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("新增推送更新")
@PostMapping("addPushBookGroupUpdate")
ResponseDto<?> addPushBookGroupUpdate(
@RequestHeader("token") String token,
@RequestBody BookGroup bookGroup
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("获取是否能推送更新的各个状态")
@GetMapping("getStatesForPushUpdate")
ResponseDto<?> getStatesForPushUpdate(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") Long bookGroupId
) throws BizException, PermissionException, JsonParseException;
}
......@@ -656,4 +656,52 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
bookGroupBiz.exportBookGroupAnalysis(bookGroupAnalysisParam, partyId);
return new ResponseDto<>();
}
@ApiOperation("更新是否邀请入群")
@PostMapping("updateIsInviteGroup")
@Override
public ResponseDto<?> updateIsInviteGroup(
@RequestHeader("token") String token,
@RequestBody BookGroup bookGroup
) throws BizException, PermissionException, JsonParseException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookGroupBiz.updateIsInviteGroup(bookGroup);
return new ResponseDto<>();
}
@ApiOperation("更新1v1是否有更新")
@PostMapping("updateIsSomeUpdate")
@Override
public ResponseDto<?> updateIsSomeUpdate(
@RequestHeader("token") String token,
@RequestBody BookGroup bookGroup
) throws BizException, PermissionException, JsonParseException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookGroupBiz.updateIsSomeUpdate(bookGroup);
return new ResponseDto<>();
}
@ApiOperation("新增推送更新")
@PostMapping("addPushBookGroupUpdate")
@Override
public ResponseDto<?> addPushBookGroupUpdate(
@RequestHeader("token") String token,
@RequestBody BookGroup bookGroup
) throws BizException, PermissionException, JsonParseException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookGroupBiz.addPushBookGroupUpdate(bookGroup);
return new ResponseDto<>();
}
@ApiOperation("获取是否能推送更新的各个状态")
@GetMapping("getStatesForPushUpdate")
@Override
public ResponseDto<?> getStatesForPushUpdate(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") Long bookGroupId
) throws BizException, PermissionException, JsonParseException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(bookGroupBiz.getStatesForPushUpdate(bookGroupId));
}
}
package com.pcloud.book.group.handler;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.common.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Random;
/**
* @Description 启动时开始推送1v1更新
* @Author ruansiyuan
* @Date 2019/10/28 16:36
**/
@Component
public class PushBookGroupUpdateHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PushBookGroupUpdateHandler.class);
private static PushBookGroupUpdateHandler pushBookGroupUpdateHandler;
@Autowired
private BookGroupBiz bookGroupBiz;
private static Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
//随机睡10到15s
Long sleepMillis = Double.valueOf(new Random().nextInt(10) + 5).longValue() * 1000;
try {
//判断是否是早八点到晚八点之间
Boolean isInTime = DateUtils.isInBetweenTimes("08:00:00", "20:00:00");
if (isInTime) {
pushBookGroupUpdateHandler.bookGroupBiz.pushBookGroupUpdate();
}
Thread.currentThread();
Thread.sleep(sleepMillis);
} catch (Throwable e) {
LOGGER.error("启动时开始推送1v1更新异常" + e.getMessage(), e);
}
}
}
});
static {
thread.start();
}
@PostConstruct
public void init() {
pushBookGroupUpdateHandler = this;
pushBookGroupUpdateHandler.bookGroupBiz = this.bookGroupBiz;
}
public static Thread getInstance() {
return thread;
}
}
......@@ -131,4 +131,9 @@ public interface BookKeywordBiz {
* @return
*/
List<KeywordDTO> getListByBookGroupId(Long bookGroupId);
/**
* 按照书处理暗号回复,推送资源
*/
void dealByBookGroup(SendTextDTO sendTextDTO, Long bookGroupId, Boolean isPushUpdate);
}
......@@ -613,15 +613,16 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
BookGroup bookGroup = bookGroupDao.getByBookGroupCipher(sendTextDTO.getTextContent());
if (bookGroup != null) {
try {
dealByBookGroup(sendTextDTO, bookGroup.getId());
addBookGroupCipherUser(sendTextDTO, bookGroup.getId());
dealByBookGroup(sendTextDTO, bookGroup.getId(),false);
} catch (Exception e) {
log.error("拉群出错" + e.getMessage());
}
}
}
@ParamLog("按照书处理暗号回复")
private void dealByBookGroup(SendTextDTO sendTextDTO, Long bookGroupId) {
@ParamLog("增加暗号对应书记录")
private void addBookGroupCipherUser(SendTextDTO sendTextDTO, Long bookGroupId){
BookGroupCipherUser bookGroupCipherUser=new BookGroupCipherUser();
bookGroupCipherUser.setBookGroupCipher(sendTextDTO.getTextContent());
bookGroupCipherUser.setBookGroupId(bookGroupId);
......@@ -629,8 +630,15 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
bookGroupCipherUser.setAltId(sendTextDTO.getWxId());
//新增暗号对应记录
bookGroupCipherUserDao.insert(bookGroupCipherUser);
}
@ParamLog("按照书处理暗号回复,推送资源")
public void dealByBookGroup(SendTextDTO sendTextDTO, Long bookGroupId, Boolean isPushUpdate) {
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookGroupId);
String text = "";
if (isPushUpdate!=null&&isPushUpdate){
text=text+"有更新!\n";
}
Boolean isInviteGroup = bookGroupDTO.getIsInviteGroup();
// 获取配置的资源服务
List<BookGroupServe> bookGroupServeList = bookGroupBiz.getBookGroupServeList(bookGroupId);
......
......@@ -98,4 +98,11 @@
</if>
</select>
<!--查询社群书关联的用户id集合-->
<select id="getWxUserIdAndAltsByBookGroupId" parameterType="map" resultMap="BaseResultMap">
SELECT t.wx_user_id,t.alt_id
FROM book_group_cipher_user t
where t.book_group_id=#{bookGroupId}
GROUP BY t.wx_user_id
</select>
</mapper>
\ No newline at end of file
......@@ -25,6 +25,8 @@
<result column="customer_service_name" property="customerServiceName" jdbcType="VARCHAR"/>
<result column="is_invite_group" property="isInviteGroup" jdbcType="BOOLEAN"/>
<result column="book_group_cipher" property="bookGroupCipher" jdbcType="VARCHAR"/>
<result column="last_push_update_time" property="lastPushUpdateTime" jdbcType="TIMESTAMP"/>
<result column="is_some_update" property="isSomeUpdate" jdbcType="BOOLEAN"/>
</resultMap>
<resultMap id="BookGroupDTO" type="com.pcloud.book.group.dto.BookGroupDTO">
......@@ -55,6 +57,8 @@
<result column="customer_service_name" property="customerServiceName" jdbcType="VARCHAR"/>
<result column="is_invite_group" property="isInviteGroup" jdbcType="BOOLEAN"/>
<result column="book_group_cipher" property="bookGroupCipher" jdbcType="VARCHAR"/>
<result column="last_push_update_time" property="lastPushUpdateTime" jdbcType="TIMESTAMP"/>
<result column="is_some_update" property="isSomeUpdate" jdbcType="BOOLEAN"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -62,7 +66,7 @@
pur_label_id, join_title, join_slogan, personal_qrcode_url, product_id, create_user,
create_time,
update_time, is_delete, is_show_book_name,join_group_type,add_friend_guide,customer_service_name,
is_invite_group,book_group_cipher
is_invite_group,book_group_cipher, last_push_update_time, is_some_update
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -191,6 +195,8 @@
customer_service_name,
is_invite_group,
book_group_cipher,
last_push_update_time,
is_some_update,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{bookId,jdbcType=BIGINT},
......@@ -213,6 +219,8 @@
#{customerServiceName,jdbcType=VARCHAR},
#{isInviteGroup,jdbcType=BOOLEAN},
#{bookGroupCipher,jdbcType=VARCHAR},
#{lastPushUpdateTime,jdbcType=TIMESTAMP},
#{isSomeUpdate,jdbcType=BOOLEAN},
</trim>
</insert>
......@@ -274,6 +282,12 @@
book_group_cipher = #{bookGroupCipher},
</if>
update_time = NOW(),
<if test="lastPushUpdateTime != null">
last_push_update_time = #{lastPushUpdateTime},
</if>
<if test="isSomeUpdate != null">
is_some_update = #{isSomeUpdate},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......@@ -561,4 +575,27 @@
G.id DESC
</select>
<!--更新是否邀请入群-->
<update id="updateIsInviteGroup" parameterType="map">
update book_group set
is_invite_group=#{isInviteGroup},
update_time=now()
where id=#{id}
</update>
<!--更新1v1是否有更新-->
<update id="updateIsSomeUpdate" parameterType="map">
update book_group set
is_some_update=#{isSomeUpdate},
update_time=now()
where id=#{id}
</update>
<!--更新上次推送时间-->
<update id="updateLastPushUpdateTime" parameterType="map">
update book_group set
last_push_update_time=now(),
update_time=now()
where id=#{bookGroupId}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.PushBookGroupUpdateDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.PushBookGroupUpdate">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="wx_user_id" property="wxUserId" jdbcType="VARCHAR"/>
<result column="alt_id" property="altId" jdbcType="VARCHAR"/>
<result column="is_push" property="isPush" jdbcType="BOOLEAN"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_group_id,wx_user_id,alt_id,is_push,create_time,update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from push_book_group_update
where id = #{id,jdbcType=BIGINT}
</select>
<!--批量插入-->
<insert id="batchInsert" parameterType="com.pcloud.book.group.entity.PushBookGroupUpdate" useGeneratedKeys="true" keyProperty="id">
insert into push_book_group_update (
book_group_id,
wx_user_id,
alt_id,
is_push,
create_time,
update_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.bookGroupId,jdbcType=BIGINT},
#{item.wxUserId,jdbcType=VARCHAR},
#{item.altId,jdbcType=VARCHAR},
#{item.isPush,jdbcType=BOOLEAN},
NOW(),
NOW()
)
</foreach>
</insert>
<!--获取最早的更新推送-->
<select id="getEarliestPushBookGroupUpdate" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from push_book_group_update
where is_push=0
order by create_time asc
limit 1
</select>
<!--更新是否推送-->
<update id="updateIsPushTrue" parameterType="map">
update push_book_group_update
set is_push=1,
update_time=now()
where id=#{id}
and is_push=0
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.WeixinQrcodeGenerationDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.WeixinQrcodeGeneration">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="generation" property="generation" jdbcType="INTEGER"/>
<result column="wechat_group_ip" property="wechatGroupIp" jdbcType="VARCHAR"/>
<result column="virtual_machine_ip" property="virtualMachineIp" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, generation, wechat_group_ip, virtual_machine_ip
</sql>
<!--根据Id查询详情-->
<select id="getById" parameterType="Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from weixin_qrcode_generation
where id = #{id}
</select>
<!--根据版本号查询详情-->
<select id="getByGeneration" parameterType="Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from weixin_qrcode_generation
where generation = #{generation}
limit 1
</select>
</mapper>
\ No newline at end of file
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