diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java index 7f02294..358fa14 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java @@ -102,4 +102,14 @@ public class WxUserController { return JsonResponse.newInstance().ok(userOfficial); } +// +// @MustLogin +// @ApiOperation(value = "根据appId和userId查询opneId", notes = "") +// @RequestMapping(value = "/openId", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) +// public JsonResponse getOpenIdByUserId(@ApiParam @Validated @RequestBody QueryDto params) { +// log.info("根据appId和userId查询openId:{}",params); +// UserVo.UserOpenId userOpenId = wxUserService.getOpenIdByUserId(params.getUserId(),params.getParam().getAppId()); +// +// return JsonResponse.newInstance().ok(userOpenId); +// } } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUser.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUser.java index bf746d4..31290e1 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUser.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUser.java @@ -18,6 +18,8 @@ public class WxOfficialUser implements Serializable { private Byte recStatus; + private String openId; + private static final long serialVersionUID = 1L; public Long getId() { @@ -76,6 +78,14 @@ public class WxOfficialUser implements Serializable { this.recStatus = recStatus; } + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId == null ? null : openId.trim(); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -89,6 +99,7 @@ public class WxOfficialUser implements Serializable { sb.append(", createdAt=").append(createdAt); sb.append(", updatedAt=").append(updatedAt); sb.append(", recStatus=").append(recStatus); + sb.append(", openId=").append(openId); sb.append("]"); return sb.toString(); } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUserExample.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUserExample.java index 3295af6..78c7c7c 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUserExample.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUserExample.java @@ -524,6 +524,76 @@ public class WxOfficialUserExample { addCriterion("rec_status not between", value1, value2, "recStatus"); return (Criteria) this; } + + public Criteria andOpenIdIsNull() { + addCriterion("open_id is null"); + return (Criteria) this; + } + + public Criteria andOpenIdIsNotNull() { + addCriterion("open_id is not null"); + return (Criteria) this; + } + + public Criteria andOpenIdEqualTo(String value) { + addCriterion("open_id =", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdNotEqualTo(String value) { + addCriterion("open_id <>", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdGreaterThan(String value) { + addCriterion("open_id >", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdGreaterThanOrEqualTo(String value) { + addCriterion("open_id >=", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdLessThan(String value) { + addCriterion("open_id <", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdLessThanOrEqualTo(String value) { + addCriterion("open_id <=", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdLike(String value) { + addCriterion("open_id like", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdNotLike(String value) { + addCriterion("open_id not like", value, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdIn(List values) { + addCriterion("open_id in", values, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdNotIn(List values) { + addCriterion("open_id not in", values, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdBetween(String value1, String value2) { + addCriterion("open_id between", value1, value2, "openId"); + return (Criteria) this; + } + + public Criteria andOpenIdNotBetween(String value1, String value2) { + addCriterion("open_id not between", value1, value2, "openId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/UserVo.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/UserVo.java index f1bbd6a..0b4eb20 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/UserVo.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/UserVo.java @@ -106,8 +106,16 @@ public class UserVo { public static class UserOfficial{ @ApiModelProperty("用户id") private Long userId; + @ApiModelProperty("openId") + private String openId; @ApiModelProperty("是否关注公众号 0未关注 1已关注") private byte status; } + @Data + @ApiModel("用户在公众号里的openId") + public static class UserOpenId{ + @ApiModelProperty("openId") + private String openId; + } } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java index 72abb16..b3cff40 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java @@ -39,4 +39,12 @@ public interface IWxUserService { * @return 返回用户id和是否关注 */ UserVo.UserOfficial getByOfficialId(Long userId, UserDto.Official param); +// +// /** +// * 根据appId和userId获取openId +// * @param userId userID +// * @param appId appId +// * @return 返回openId +// */ +// UserVo.UserOpenId getOpenIdByUserId(Long userId, String appId); } 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 2fba8cb..a2cc783 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 @@ -117,7 +117,7 @@ public class WxUserService implements IWxUserService { saveUser(notice, userSign, wxUserInfo); } //添加用户和公众号的关联关系 - saveOfficialsUser(userSign,wxOfficial); + saveOfficialsUser(userSign,wxOfficial,notice); //生成token UserVo.TokenBean tokenBean = userService.generateToken(userSign.getUserId(), userSign.getAuthId()); tokenBean.setId(userSign.getUserId()); @@ -203,7 +203,7 @@ public class WxUserService implements IWxUserService { return userOfficial; } - private void saveOfficialsUser(UserVo.UserSign userSign,WxOfficial wxOfficial) { + private void saveOfficialsUser(UserVo.UserSign userSign,WxOfficial wxOfficial,NoticeDto.Notice notice) { if(ObjectUtil.isNotNull(wxOfficial)){ //查找用户和公众号的关联关系 @@ -222,6 +222,7 @@ public class WxUserService implements IWxUserService { wxOfficialUser.setUserId(userSign.getUserId()); wxOfficialUser.setOfficialId(wxOfficial.getId()); wxOfficialUser.setAttentionStatus((byte) 1); + wxOfficialUser.setOpenId(notice.getFromUserName()); wxOfficialUserMapper.insertSelective(wxOfficialUser); } } @@ -249,4 +250,5 @@ public class WxUserService implements IWxUserService { userSign.setUserId(newUser.getId()); userSign.setAuthId(newAuth.getId()); } + } diff --git a/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml b/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml index f3b0d08..c1911c3 100644 --- a/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml +++ b/ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml @@ -18,7 +18,8 @@ select @@ -104,10 +105,10 @@ insert into t_wx_official_user (id, official_id, user_id, attention_status, created_at, updated_at, - rec_status) + rec_status, open_id) values (#{id,jdbcType=BIGINT}, #{officialId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{attentionStatus,jdbcType=TINYINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, - #{recStatus,jdbcType=TINYINT}) + #{recStatus,jdbcType=TINYINT}, #{openId,jdbcType=VARCHAR}) insert into t_wx_official_user @@ -133,6 +134,9 @@ rec_status, + + open_id, + @@ -156,6 +160,9 @@ #{recStatus,jdbcType=TINYINT}, + + #{openId,jdbcType=VARCHAR}, +