Commit 72be54da authored by shiyu's avatar shiyu

根据用户id查询

parent 6a15e86b
......@@ -11,7 +11,7 @@ import org.springframework.util.StringUtils;
/**
* @author shiyu
* @date 2023/11/01
* @date 2024/06/06
*/
@Data
public class User implements Entity {
......@@ -115,6 +115,11 @@ public class User implements Entity {
*/
private String wechatId;
/**
* 微信二维码
*/
private String wechatQrCode;
/**
* 0 可用, 1 禁用, 2 注销
*/
......@@ -245,6 +250,7 @@ public class User implements Entity {
sb.append(", weixinUnionid=").append(weixinUnionid);
sb.append(", alipayUserId=").append(alipayUserId);
sb.append(", wechatId=").append(wechatId);
sb.append(", wechatQrCode=").append(wechatQrCode);
sb.append(", status=").append(status);
sb.append(", addTime=").append(addTime);
sb.append(", updateTime=").append(updateTime);
......@@ -285,6 +291,7 @@ public class User implements Entity {
&& (this.getWeixinUnionid() == null ? other.getWeixinUnionid() == null : this.getWeixinUnionid().equals(other.getWeixinUnionid()))
&& (this.getAlipayUserId() == null ? other.getAlipayUserId() == null : this.getAlipayUserId().equals(other.getAlipayUserId()))
&& (this.getWechatId() == null ? other.getWechatId() == null : this.getWechatId().equals(other.getWechatId()))
&& (this.getWechatQrCode() == null ? other.getWechatQrCode() == null : this.getWechatQrCode().equals(other.getWechatQrCode()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
......@@ -314,6 +321,7 @@ public class User implements Entity {
result = prime * result + ((getWeixinUnionid() == null) ? 0 : getWeixinUnionid().hashCode());
result = prime * result + ((getAlipayUserId() == null) ? 0 : getAlipayUserId().hashCode());
result = prime * result + ((getWechatId() == null) ? 0 : getWechatId().hashCode());
result = prime * result + ((getWechatQrCode() == null) ? 0 : getWechatQrCode().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
......@@ -359,6 +367,7 @@ public class User implements Entity {
weixinUnionid("weixin_unionid", "weixinUnionid", "VARCHAR", false),
alipayUserId("alipay_user_id", "alipayUserId", "VARCHAR", false),
wechatId("wechat_id", "wechatId", "VARCHAR", false),
wechatQrCode("wechat_qr_code", "wechatQrCode", "VARCHAR", false),
status("status", "status", "TINYINT", true),
addTime("add_time", "addTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
......
......@@ -2539,6 +2539,148 @@ public class UserExample {
return (Criteria) this;
}
public Criteria andWechatQrCodeIsNull() {
addCriterion("wechat_qr_code is null");
return (Criteria) this;
}
public Criteria andWechatQrCodeIsNotNull() {
addCriterion("wechat_qr_code is not null");
return (Criteria) this;
}
public Criteria andWechatQrCodeEqualTo(String value) {
addCriterion("wechat_qr_code =", value, "wechatQrCode");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andWechatQrCodeEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("wechat_qr_code = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andWechatQrCodeNotEqualTo(String value) {
addCriterion("wechat_qr_code <>", value, "wechatQrCode");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andWechatQrCodeNotEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("wechat_qr_code <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andWechatQrCodeGreaterThan(String value) {
addCriterion("wechat_qr_code >", value, "wechatQrCode");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andWechatQrCodeGreaterThanColumn(User.Column column) {
addCriterion(new StringBuilder("wechat_qr_code > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andWechatQrCodeGreaterThanOrEqualTo(String value) {
addCriterion("wechat_qr_code >=", value, "wechatQrCode");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andWechatQrCodeGreaterThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("wechat_qr_code >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andWechatQrCodeLessThan(String value) {
addCriterion("wechat_qr_code <", value, "wechatQrCode");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andWechatQrCodeLessThanColumn(User.Column column) {
addCriterion(new StringBuilder("wechat_qr_code < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andWechatQrCodeLessThanOrEqualTo(String value) {
addCriterion("wechat_qr_code <=", value, "wechatQrCode");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andWechatQrCodeLessThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("wechat_qr_code <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andWechatQrCodeLike(String value) {
addCriterion("wechat_qr_code like", value, "wechatQrCode");
return (Criteria) this;
}
public Criteria andWechatQrCodeNotLike(String value) {
addCriterion("wechat_qr_code not like", value, "wechatQrCode");
return (Criteria) this;
}
public Criteria andWechatQrCodeIn(List<String> values) {
addCriterion("wechat_qr_code in", values, "wechatQrCode");
return (Criteria) this;
}
public Criteria andWechatQrCodeNotIn(List<String> values) {
addCriterion("wechat_qr_code not in", values, "wechatQrCode");
return (Criteria) this;
}
public Criteria andWechatQrCodeBetween(String value1, String value2) {
addCriterion("wechat_qr_code between", value1, value2, "wechatQrCode");
return (Criteria) this;
}
public Criteria andWechatQrCodeNotBetween(String value1, String value2) {
addCriterion("wechat_qr_code not between", value1, value2, "wechatQrCode");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
......
......@@ -7,7 +7,7 @@ import lombok.Data;
public class UserRequestDto implements Entity {
private String user;
private Long id;
// 用户id
private Long userId;
// 手机号
......@@ -55,7 +55,10 @@ public class UserRequestDto implements Entity {
* 备注
*/
private String remark;
/**
* 微信二维码
*/
private String wechatQrCode;
/**
* 玩物得志登录后token
......
......@@ -19,6 +19,7 @@
<result column="weixin_unionid" jdbcType="VARCHAR" property="weixinUnionid" />
<result column="alipay_user_id" jdbcType="VARCHAR" property="alipayUserId" />
<result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
<result column="wechat_qr_code" jdbcType="VARCHAR" property="wechatQrCode" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
......@@ -87,7 +88,8 @@
<sql id="Base_Column_List">
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time, update_time, deleted, share_user_id, remark
wechat_id, wechat_qr_code, `status`, add_time, update_time, deleted, share_user_id,
remark
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserExample" resultMap="BaseResultMap">
select
......@@ -124,7 +126,8 @@
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time, update_time, deleted, share_user_id, remark
wechat_id, wechat_qr_code, `status`, add_time, update_time, deleted, share_user_id,
remark
</otherwise>
</choose>
from user
......@@ -177,7 +180,8 @@
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time, update_time, deleted, share_user_id, remark
wechat_id, wechat_qr_code, `status`, add_time, update_time, deleted, share_user_id,
remark
</otherwise>
</choose>
from user
......@@ -202,17 +206,17 @@
user_level, nickname, mobile,
avatar, profile, background,
weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time,
update_time, deleted, share_user_id,
remark)
wechat_id, wechat_qr_code, `status`,
add_time, update_time, deleted,
share_user_id, remark)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
#{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR},
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{weixinOpenid,jdbcType=VARCHAR}, #{weixinUnionid,jdbcType=VARCHAR}, #{alipayUserId,jdbcType=VARCHAR},
#{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT},
#{remark,jdbcType=VARCHAR})
#{wechatId,jdbcType=VARCHAR}, #{wechatQrCode,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{shareUserId,jdbcType=BIGINT}, #{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertBySelfId" parameterType="com.wwdz.ch.db.domain.User">
......@@ -221,7 +225,7 @@
user_level, nickname, mobile,
avatar, profile, background,
weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time,
wechat_id, wechat_qr_code,`status`, add_time,
update_time, deleted, share_user_id,
remark)
values (#{id,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
......@@ -229,7 +233,7 @@
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{weixinOpenid,jdbcType=VARCHAR}, #{weixinUnionid,jdbcType=VARCHAR}, #{alipayUserId,jdbcType=VARCHAR},
#{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP},
#{wechatId,jdbcType=VARCHAR}, #{wechatQrCode,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT},
#{remark,jdbcType=VARCHAR})
</insert>
......@@ -289,6 +293,9 @@
<if test="wechatId != null">
wechat_id,
</if>
<if test="wechatQrCode != null">
wechat_qr_code,
</if>
<if test="status != null">
`status`,
</if>
......@@ -357,6 +364,9 @@
<if test="wechatId != null">
#{wechatId,jdbcType=VARCHAR},
</if>
<if test="wechatQrCode != null">
#{wechatQrCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
......@@ -437,6 +447,9 @@
<if test="record.wechatId != null">
wechat_id = #{record.wechatId,jdbcType=VARCHAR},
</if>
<if test="record.wechatQrCode != null">
wechat_qr_code = #{record.wechatQrCode,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=TINYINT},
</if>
......@@ -479,6 +492,7 @@
weixin_unionid = #{record.weixinUnionid,jdbcType=VARCHAR},
alipay_user_id = #{record.alipayUserId,jdbcType=VARCHAR},
wechat_id = #{record.wechatId,jdbcType=VARCHAR},
wechat_qr_code = #{record.wechatQrCode,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=TINYINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
......@@ -540,6 +554,9 @@
<if test="wechatId != null">
wechat_id = #{wechatId,jdbcType=VARCHAR},
</if>
<if test="wechatQrCode != null">
wechat_qr_code = #{wechatQrCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=TINYINT},
</if>
......@@ -579,6 +596,7 @@
weixin_unionid = #{weixinUnionid,jdbcType=VARCHAR},
alipay_user_id = #{alipayUserId,jdbcType=VARCHAR},
wechat_id = #{wechatId,jdbcType=VARCHAR},
wechat_qr_code = #{wechatQrCode,jdbcType=VARCHAR},
`status` = #{status,jdbcType=TINYINT},
add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
......@@ -622,7 +640,8 @@
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, weixin_unionid, alipay_user_id,
wechat_id, `status`, add_time, update_time, deleted, share_user_id, remark
wechat_id, wechat_qr_code, `status`, add_time, update_time, deleted, share_user_id,
remark
</otherwise>
</choose>
from user
......@@ -654,5 +673,4 @@
update user set deleted = 1
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
package com.wwdz.ch.wx.dao;
import com.wwdz.ch.core.consts.FollowFansEnum;
import lombok.Data;
import java.io.Serializable;
......@@ -54,5 +55,18 @@ public class UserInfo implements Serializable {
private Integer returnOrderNumber;
/**
* 关系(已关注,互相关注,未关注)
*/
private String relation;
/**
* 关系(已关注,互相关注,未关注)
*/
private Integer relationCode;
/**
* 微信二维码
*/
private String wechatQrCode;
}
......@@ -282,12 +282,16 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
//查询当前用户关注的人
FollowFansRecordRequestDto currentFollowDto = new FollowFansRecordRequestDto();
currentFollowDto.setFansId(dto.getCurrentUserId());
currentFollowDto.setPage(1);
currentFollowDto.setLimit(9999);
List<FollowFansRecord> currentFollowFansRecordList = followFansRecordDao.findList(currentFollowDto);
List<Long> currentFollowIdList = currentFollowFansRecordList.stream().map(FollowFansRecord::getFollowerId).collect(Collectors.toList());
//查询当前用户的粉丝
FollowFansRecordRequestDto currentFansDto = new FollowFansRecordRequestDto();
currentFansDto.setFollowerId(dto.getCurrentUserId());
currentFansDto.setPage(1);
currentFansDto.setLimit(9999);
List<FollowFansRecord> currentFansRecordList = followFansRecordDao.findList(currentFansDto);
List<Long> currentFansIdList = currentFansRecordList.stream().map(FollowFansRecord::getFansId).collect(Collectors.toList());
......
......@@ -19,6 +19,7 @@ import com.wwdz.ch.core.util.bcrypt.BCryptPasswordEncoder;
import com.wwdz.ch.db.dao.*;
import com.wwdz.ch.db.dao.distribution.ShopWhiteListDao;
import com.wwdz.ch.db.domain.AiAssistant;
import com.wwdz.ch.db.domain.FollowFansRecord;
import com.wwdz.ch.db.domain.Switch;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.distribution.ShopWhiteList;
......@@ -539,6 +540,29 @@ public class UserServiceImpl implements UserService {
}
}
@Override
public Result updateQrCode(UserRequestDto dto) {
try {
User user = userDao.queryById(dto.getUserId());
if (Objects.isNull(user)) {
return Result.failed("数据异常,用户不存在");
}
user.setWechatQrCode(dto.getWechatQrCode());
userDao.updateById(user);
// 更新用户缓存
User resultUser = userDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
redisUtil.set(userKey, resultUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改微信二维码成功");
return Result.success();
} catch (Exception e) {
logger.error("用户修改微信二维码失败", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.failed("用户修改微信二维码失败");
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public Result updateMobile(UserRequestDto dto) {
......@@ -824,4 +848,38 @@ public class UserServiceImpl implements UserService {
return result;
}
@Override
public Result findById(UserRequestDto dto) {
try {
User user = userDao.queryById(dto.getId());
if (user == null) {
return Result.failed("查询不到该用户信息");
}
UserInfo userInfo = new UserInfo();
userInfo.setUserId(dto.getUserId());
userInfo.setNickName(user.getNickname());
userInfo.setAvatarUrl(user.getAvatar());
userInfo.setProfile(user.getProfile());
userInfo.setBackground(user.getBackground());
userInfo.setIsFollowed(false);
userInfo.setFollowedId(null);
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(dto.getId());
followFansRecordRequestDto.setFansId(dto.getUserId());
Result result = followFansRecordService.findFollowRelation(followFansRecordRequestDto);
if (result.getSuccess()) {
HashMap<String, Object> map = (HashMap<String, Object>) result.getData();
userInfo.setIsFollowed((Boolean) map.get("isFollowed"));
if (Objects.nonNull(map.get("id"))) {
userInfo.setFollowedId((Integer) map.get("id"));
}
}
return Result.success(userInfo);
} catch (Exception e) {
logger.error("查询用户信息失败", e);
return Result.failed("查询用户信息失败");
}
}
}
......@@ -74,6 +74,8 @@ public interface UserService {
*/
Result updateAvatar(UserRequestDto dto);
Result updateQrCode(UserRequestDto dto);
/**
* 修改手机号
*
......@@ -115,4 +117,6 @@ public interface UserService {
* @return
*/
Result pageViews(UserRequestDto dto);
Result findById(UserRequestDto dto);
}
......@@ -191,6 +191,21 @@ public class WxUserController {
return userService.regCaptcha(dto);
}
@ApiOperation(value = "上传微信二维码")
@PostMapping("/updateQrCode")
public Result updateQrCode(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改头像,请求参数:{}", JSON.toJSONString(true));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getWechatQrCode())) {
return Result.failed("请微信二维码");
}
return userService.updateQrCode(dto);
}
@ApiOperation(value = "修改手机号")
@PostMapping("/updateMobile")
public Result updateMobile(@RequestBody UserRequestDto dto) {
......@@ -230,4 +245,12 @@ public class WxUserController {
logger.info("【请求开始】查询关注粉丝浏览量,请求参数:{}", JSON.toJSONString(dto));
return userService.pageViews(dto);
}
@ApiOperation(value = "根据用户id查询用户信息")
@PostMapping("/findById")
public Result findById(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】根据用户id查询用户信息,请求参数:{}", JSON.toJSONString(dto));
return userService.findById(dto);
}
}
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