diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/UserDto.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/UserDto.java index c01c150..a92cac0 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/UserDto.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/UserDto.java @@ -73,6 +73,6 @@ public class UserDto { @ApiModel("公众号的设备id") public static class Official{ @ApiModelProperty("设备id") - private Long id; + private Long appId; } } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/WxOfficialDao.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/WxOfficialDao.java index d4fae0e..d7b9b86 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/WxOfficialDao.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/WxOfficialDao.java @@ -1,6 +1,7 @@ package com.ccsens.ptos_tall.persist.dao; import com.ccsens.ptos_tall.bean.po.WxOfficial; +import com.ccsens.ptos_tall.bean.vo.UserVo; import com.ccsens.ptos_tall.persist.mapper.WxOfficialMapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -17,4 +18,12 @@ public interface WxOfficialDao extends WxOfficialMapper { * @return 公众号信息 */ WxOfficial getByEquipmentId(@Param("equipmentId") String equipmentId); + + /** + * 查询用户是否关注公众号 + * @param appId 公众号appID + * @param userId 用户ID + * @return 关注状态 无,则未关注 + */ + UserVo.UserOfficial getUserOfficial(@Param("appId") Long appId, @Param("userId") Long userId); } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java index ead8e92..5eb9305 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java @@ -178,12 +178,18 @@ public class WxUserService implements IWxUserService { public UserVo.UserOfficial getByOfficialId(Long userId, UserDto.Official param) { UserVo.UserOfficial userOfficial = new UserVo.UserOfficial(); //根据用户id和公众号id查询关联信息 - WxOfficialUserExample wxOfficialUserExample = new WxOfficialUserExample(); - wxOfficialUserExample.createCriteria().andUserIdEqualTo(userId).andOfficialIdEqualTo(param.getId()); - List wxOfficialUsers = wxOfficialUserMapper.selectByExample(wxOfficialUserExample); - if(CollectionUtil.isNotEmpty(wxOfficialUsers)){ - userOfficial.setUserId(wxOfficialUsers.get(0).getUserId()); - userOfficial.setStatus(wxOfficialUsers.get(0).getAttentionStatus()); +// WxOfficialUserExample wxOfficialUserExample = new WxOfficialUserExample(); +// wxOfficialUserExample.createCriteria().andUserIdEqualTo(userId).andOfficialIdEqualTo(param.getId()); +// List wxOfficialUsers = wxOfficialUserMapper.selectByExample(wxOfficialUserExample); +// if(CollectionUtil.isNotEmpty(wxOfficialUsers)){ +// userOfficial.setUserId(wxOfficialUsers.get(0).getUserId()); +// userOfficial.setStatus(wxOfficialUsers.get(0).getAttentionStatus()); +// } + UserVo.UserOfficial official = wxOfficialDao.getUserOfficial(param.getAppId(), userId); + if (official == null) { + userOfficial.setUserId(userId); + } else { + userOfficial = official; } return userOfficial; } diff --git a/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml b/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml index 410e12c..f3b0d08 100644 --- a/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml +++ b/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml @@ -15,4 +15,18 @@ and e.rec_status = 0 and e.id = #{equipmentId} + \ No newline at end of file