Browse Source

20220321

master
zy_Java 3 years ago
parent
commit
b26d72d4a8
  1. 10
      ptos_tall/src/main/java/com/ccsens/ptos_tall/api/WxUserController.java
  2. 11
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUser.java
  3. 70
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/po/WxOfficialUserExample.java
  4. 8
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/UserVo.java
  5. 8
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java
  6. 6
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java
  7. 3
      ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml
  8. 25
      ptos_tall/src/main/resources/mapper_raw/WxOfficialUserMapper.xml

10
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<UserVo.UserOpenId> getOpenIdByUserId(@ApiParam @Validated @RequestBody QueryDto<UserDto.Official> params) {
// log.info("根据appId和userId查询openId:{}",params);
// UserVo.UserOpenId userOpenId = wxUserService.getOpenIdByUserId(params.getUserId(),params.getParam().getAppId());
//
// return JsonResponse.newInstance().ok(userOpenId);
// }
}

11
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();
}

70
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<String> values) {
addCriterion("open_id in", values, "openId");
return (Criteria) this;
}
public Criteria andOpenIdNotIn(List<String> 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 {

8
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;
}
}

8
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);
}

6
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());
}
}

3
ptos_tall/src/main/resources/mapper_dao/WxOfficialDao.xml

@ -18,7 +18,8 @@
<select id="getUserOfficial" resultType="com.ccsens.ptos_tall.bean.vo.UserVo$UserOfficial">
SELECT
u.user_id,
u.attention_status AS STATUS
u.attention_status AS STATUS,
u.open_id AS openId
FROM
t_wx_official o,
t_wx_official_user u

25
ptos_tall/src/main/resources/mapper_raw/WxOfficialUserMapper.xml

@ -9,6 +9,7 @@
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
<result column="open_id" jdbcType="VARCHAR" property="openId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -69,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, official_id, user_id, attention_status, created_at, updated_at, rec_status
id, official_id, user_id, attention_status, created_at, updated_at, rec_status, open_id
</sql>
<select id="selectByExample" parameterType="com.ccsens.ptos_tall.bean.po.WxOfficialUserExample" resultMap="BaseResultMap">
select
@ -104,10 +105,10 @@
<insert id="insert" parameterType="com.ccsens.ptos_tall.bean.po.WxOfficialUser">
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>
<insert id="insertSelective" parameterType="com.ccsens.ptos_tall.bean.po.WxOfficialUser">
insert into t_wx_official_user
@ -133,6 +134,9 @@
<if test="recStatus != null">
rec_status,
</if>
<if test="openId != null">
open_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -156,6 +160,9 @@
<if test="recStatus != null">
#{recStatus,jdbcType=TINYINT},
</if>
<if test="openId != null">
#{openId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.ptos_tall.bean.po.WxOfficialUserExample" resultType="java.lang.Long">
@ -188,6 +195,9 @@
<if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT},
</if>
<if test="record.openId != null">
open_id = #{record.openId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -201,7 +211,8 @@
attention_status = #{record.attentionStatus,jdbcType=TINYINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
rec_status = #{record.recStatus,jdbcType=TINYINT},
open_id = #{record.openId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -227,6 +238,9 @@
<if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT},
</if>
<if test="openId != null">
open_id = #{openId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
@ -237,7 +251,8 @@
attention_status = #{attentionStatus,jdbcType=TINYINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}
rec_status = #{recStatus,jdbcType=TINYINT},
open_id = #{openId,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
Loading…
Cancel
Save