Commit cad17097 authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/master'

parents eb839b71 8f0701c2
...@@ -13,6 +13,7 @@ public interface FavoritesItemsRelationDao { ...@@ -13,6 +13,7 @@ public interface FavoritesItemsRelationDao {
List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds); List<FavoritesItemsRelation> listByFavoritesId(Long favoritesId, List<Long> favoritesIds);
FavoritesItemsRelation selectByUserIdItemId(Long userId, Long itemId); FavoritesItemsRelation selectByUserIdItemId(Long userId, Long itemId);
PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size); PageInfo<FavoritesItemsRelation> pageByFavoritesId(Long favoritesId, int page, int size);
long count(Long itemId); long countByItemId(Long itemId);
boolean isCollected(Long userId, Long itemId); boolean isCollected(Long userId, Long itemId);
long countByFavoritesId(Long favoritesId);
} }
...@@ -9,6 +9,10 @@ public interface UserDao { ...@@ -9,6 +9,10 @@ public interface UserDao {
User queryById(Long id); User queryById(Long id);
boolean isExistedByNickname(Long userId, String nickname);
boolean isExistedByWechatId(Long userId, String wechatId);
int insert(User user); int insert(User user);
int updateById(User user); int updateById(User user);
......
...@@ -47,6 +47,7 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -47,6 +47,7 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria(); FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo); JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo);
JdbcHelper.ifPresent(favoritesIds, criteria::andFavoritesIdIn); JdbcHelper.ifPresent(favoritesIds, criteria::andFavoritesIdIn);
example.orderBy("add_time desc");
return favoritesItemsRelationMapper.selectByExample(example); return favoritesItemsRelationMapper.selectByExample(example);
} }
...@@ -64,13 +65,14 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -64,13 +65,14 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample(); FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria(); FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
criteria.andFavoritesIdEqualTo(favoritesId); criteria.andFavoritesIdEqualTo(favoritesId);
example.orderBy("add_time desc");
PageHelper.startPage(page, size); PageHelper.startPage(page, size);
List<FavoritesItemsRelation> list = favoritesItemsRelationMapper.selectByExample(example); List<FavoritesItemsRelation> list = favoritesItemsRelationMapper.selectByExample(example);
return new PageInfo<>(list); return new PageInfo<>(list);
} }
@Override @Override
public long count(Long itemId) { public long countByItemId(Long itemId) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample(); FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria(); FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
criteria.andItemIdEqualTo(itemId); criteria.andItemIdEqualTo(itemId);
...@@ -85,4 +87,12 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao ...@@ -85,4 +87,12 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
criteria.andItemIdEqualTo(itemId); criteria.andItemIdEqualTo(itemId);
return favoritesItemsRelationMapper.countByExample(example) > 0; return favoritesItemsRelationMapper.countByExample(example) > 0;
} }
@Override
public long countByFavoritesId(Long favoritesId) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(favoritesId, criteria::andFavoritesIdEqualTo);
return favoritesItemsRelationMapper.countByExample(example);
}
} }
...@@ -36,6 +36,20 @@ public class UserDaoImpl implements UserDao { ...@@ -36,6 +36,20 @@ public class UserDaoImpl implements UserDao {
return userMapper.selectOneByExample(example); return userMapper.selectOneByExample(example);
} }
@Override
public boolean isExistedByNickname(Long userId, String nickname) {
UserExample example = new UserExample();
example.or().andIdNotEqualTo(userId).andNicknameEqualTo(nickname).andDeletedEqualTo(false);
return userMapper.countByExample(example) > 0;
}
@Override
public boolean isExistedByWechatId(Long userId, String wechatId) {
UserExample example = new UserExample();
example.or().andIdNotEqualTo(userId).andWechatIdEqualTo(wechatId).andDeletedEqualTo(false);
return userMapper.countByExample(example) > 0;
}
@Override @Override
public int insert(User user) { public int insert(User user) {
return userMapper.insert(user); return userMapper.insert(user);
......
...@@ -9,7 +9,7 @@ import java.util.Date; ...@@ -9,7 +9,7 @@ import java.util.Date;
/** /**
* @author shiyu * @author shiyu
* @date 2023/07/26 * @date 2023/08/07
*/ */
@Data @Data
public class User implements Serializable { public class User implements Serializable {
...@@ -83,6 +83,16 @@ public class User implements Serializable { ...@@ -83,6 +83,16 @@ public class User implements Serializable {
*/ */
private String avatar; private String avatar;
/**
* 用户简介
*/
private String profile;
/**
* 用户背景图片
*/
private String background;
/** /**
* 微信登录openid * 微信登录openid
*/ */
...@@ -134,6 +144,8 @@ public class User implements Serializable { ...@@ -134,6 +144,8 @@ public class User implements Serializable {
sb.append(", nickname=").append(nickname); sb.append(", nickname=").append(nickname);
sb.append(", mobile=").append(mobile); sb.append(", mobile=").append(mobile);
sb.append(", avatar=").append(avatar); sb.append(", avatar=").append(avatar);
sb.append(", profile=").append(profile);
sb.append(", background=").append(background);
sb.append(", weixinOpenid=").append(weixinOpenid); sb.append(", weixinOpenid=").append(weixinOpenid);
sb.append(", wechatId=").append(wechatId); sb.append(", wechatId=").append(wechatId);
sb.append(", status=").append(status); sb.append(", status=").append(status);
...@@ -169,6 +181,8 @@ public class User implements Serializable { ...@@ -169,6 +181,8 @@ public class User implements Serializable {
&& (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname())) && (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
&& (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile())) && (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile()))
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar())) && (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getProfile() == null ? other.getProfile() == null : this.getProfile().equals(other.getProfile()))
&& (this.getBackground() == null ? other.getBackground() == null : this.getBackground().equals(other.getBackground()))
&& (this.getWeixinOpenid() == null ? other.getWeixinOpenid() == null : this.getWeixinOpenid().equals(other.getWeixinOpenid())) && (this.getWeixinOpenid() == null ? other.getWeixinOpenid() == null : this.getWeixinOpenid().equals(other.getWeixinOpenid()))
&& (this.getWechatId() == null ? other.getWechatId() == null : this.getWechatId().equals(other.getWechatId())) && (this.getWechatId() == null ? other.getWechatId() == null : this.getWechatId().equals(other.getWechatId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
...@@ -193,6 +207,8 @@ public class User implements Serializable { ...@@ -193,6 +207,8 @@ public class User implements Serializable {
result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode()); result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());
result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode()); result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode());
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode()); result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
result = prime * result + ((getProfile() == null) ? 0 : getProfile().hashCode());
result = prime * result + ((getBackground() == null) ? 0 : getBackground().hashCode());
result = prime * result + ((getWeixinOpenid() == null) ? 0 : getWeixinOpenid().hashCode()); result = prime * result + ((getWeixinOpenid() == null) ? 0 : getWeixinOpenid().hashCode());
result = prime * result + ((getWechatId() == null) ? 0 : getWechatId().hashCode()); result = prime * result + ((getWechatId() == null) ? 0 : getWechatId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
...@@ -233,6 +249,8 @@ public class User implements Serializable { ...@@ -233,6 +249,8 @@ public class User implements Serializable {
nickname("nickname", "nickname", "VARCHAR", false), nickname("nickname", "nickname", "VARCHAR", false),
mobile("mobile", "mobile", "VARCHAR", false), mobile("mobile", "mobile", "VARCHAR", false),
avatar("avatar", "avatar", "VARCHAR", false), avatar("avatar", "avatar", "VARCHAR", false),
profile("profile", "profile", "VARCHAR", false),
background("background", "background", "VARCHAR", false),
weixinOpenid("weixin_openid", "weixinOpenid", "VARCHAR", false), weixinOpenid("weixin_openid", "weixinOpenid", "VARCHAR", false),
wechatId("wechat_id", "wechatId", "VARCHAR", false), wechatId("wechat_id", "wechatId", "VARCHAR", false),
status("status", "status", "TINYINT", true), status("status", "status", "TINYINT", true),
......
...@@ -1687,6 +1687,290 @@ public class UserExample { ...@@ -1687,6 +1687,290 @@ public class UserExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andProfileIsNull() {
addCriterion("profile is null");
return (Criteria) this;
}
public Criteria andProfileIsNotNull() {
addCriterion("profile is not null");
return (Criteria) this;
}
public Criteria andProfileEqualTo(String value) {
addCriterion("profile =", value, "profile");
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 andProfileEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("profile = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andProfileNotEqualTo(String value) {
addCriterion("profile <>", value, "profile");
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 andProfileNotEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("profile <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andProfileGreaterThan(String value) {
addCriterion("profile >", value, "profile");
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 andProfileGreaterThanColumn(User.Column column) {
addCriterion(new StringBuilder("profile > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andProfileGreaterThanOrEqualTo(String value) {
addCriterion("profile >=", value, "profile");
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 andProfileGreaterThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("profile >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andProfileLessThan(String value) {
addCriterion("profile <", value, "profile");
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 andProfileLessThanColumn(User.Column column) {
addCriterion(new StringBuilder("profile < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andProfileLessThanOrEqualTo(String value) {
addCriterion("profile <=", value, "profile");
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 andProfileLessThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("profile <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andProfileLike(String value) {
addCriterion("profile like", value, "profile");
return (Criteria) this;
}
public Criteria andProfileNotLike(String value) {
addCriterion("profile not like", value, "profile");
return (Criteria) this;
}
public Criteria andProfileIn(List<String> values) {
addCriterion("profile in", values, "profile");
return (Criteria) this;
}
public Criteria andProfileNotIn(List<String> values) {
addCriterion("profile not in", values, "profile");
return (Criteria) this;
}
public Criteria andProfileBetween(String value1, String value2) {
addCriterion("profile between", value1, value2, "profile");
return (Criteria) this;
}
public Criteria andProfileNotBetween(String value1, String value2) {
addCriterion("profile not between", value1, value2, "profile");
return (Criteria) this;
}
public Criteria andBackgroundIsNull() {
addCriterion("background is null");
return (Criteria) this;
}
public Criteria andBackgroundIsNotNull() {
addCriterion("background is not null");
return (Criteria) this;
}
public Criteria andBackgroundEqualTo(String value) {
addCriterion("background =", value, "background");
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 andBackgroundEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("background = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andBackgroundNotEqualTo(String value) {
addCriterion("background <>", value, "background");
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 andBackgroundNotEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("background <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andBackgroundGreaterThan(String value) {
addCriterion("background >", value, "background");
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 andBackgroundGreaterThanColumn(User.Column column) {
addCriterion(new StringBuilder("background > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andBackgroundGreaterThanOrEqualTo(String value) {
addCriterion("background >=", value, "background");
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 andBackgroundGreaterThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("background >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andBackgroundLessThan(String value) {
addCriterion("background <", value, "background");
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 andBackgroundLessThanColumn(User.Column column) {
addCriterion(new StringBuilder("background < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andBackgroundLessThanOrEqualTo(String value) {
addCriterion("background <=", value, "background");
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 andBackgroundLessThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("background <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andBackgroundLike(String value) {
addCriterion("background like", value, "background");
return (Criteria) this;
}
public Criteria andBackgroundNotLike(String value) {
addCriterion("background not like", value, "background");
return (Criteria) this;
}
public Criteria andBackgroundIn(List<String> values) {
addCriterion("background in", values, "background");
return (Criteria) this;
}
public Criteria andBackgroundNotIn(List<String> values) {
addCriterion("background not in", values, "background");
return (Criteria) this;
}
public Criteria andBackgroundBetween(String value1, String value2) {
addCriterion("background between", value1, value2, "background");
return (Criteria) this;
}
public Criteria andBackgroundNotBetween(String value1, String value2) {
addCriterion("background not between", value1, value2, "background");
return (Criteria) this;
}
public Criteria andWeixinOpenidIsNull() { public Criteria andWeixinOpenidIsNull() {
addCriterion("weixin_openid is null"); addCriterion("weixin_openid is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
<result column="nickname" jdbcType="VARCHAR" property="nickname" /> <result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="mobile" jdbcType="VARCHAR" property="mobile" /> <result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="avatar" jdbcType="VARCHAR" property="avatar" /> <result column="avatar" jdbcType="VARCHAR" property="avatar" />
<result column="profile" jdbcType="VARCHAR" property="profile" />
<result column="background" jdbcType="VARCHAR" property="background" />
<result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid" /> <result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid" />
<result column="wechat_id" jdbcType="VARCHAR" property="wechatId" /> <result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
<result column="status" jdbcType="TINYINT" property="status" /> <result column="status" jdbcType="TINYINT" property="status" />
...@@ -81,8 +83,8 @@ ...@@ -81,8 +83,8 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</sql> </sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserExample" resultMap="BaseResultMap">
select select
...@@ -118,8 +120,8 @@ ...@@ -118,8 +120,8 @@
</when> </when>
<otherwise> <otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</otherwise> </otherwise>
</choose> </choose>
from user from user
...@@ -171,8 +173,8 @@ ...@@ -171,8 +173,8 @@
</when> </when>
<otherwise> <otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</otherwise> </otherwise>
</choose> </choose>
from user from user
...@@ -195,15 +197,17 @@ ...@@ -195,15 +197,17 @@
insert into user (username, `password`, gender, insert into user (username, `password`, gender,
birthday, last_login_time, last_login_ip, birthday, last_login_time, last_login_ip,
user_level, nickname, mobile, user_level, nickname, mobile,
avatar, weixin_openid, wechat_id, avatar, profile, background,
`status`, add_time, update_time, weixin_openid, wechat_id, `status`,
deleted, share_user_id) add_time, update_time, deleted,
share_user_id)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT}, values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
#{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR},
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT}) #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{shareUserId,jdbcType=BIGINT})
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.User"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.User">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
...@@ -241,6 +245,12 @@ ...@@ -241,6 +245,12 @@
<if test="avatar != null"> <if test="avatar != null">
avatar, avatar,
</if> </if>
<if test="profile != null">
profile,
</if>
<if test="background != null">
background,
</if>
<if test="weixinOpenid != null"> <if test="weixinOpenid != null">
weixin_openid, weixin_openid,
</if> </if>
...@@ -294,6 +304,12 @@ ...@@ -294,6 +304,12 @@
<if test="avatar != null"> <if test="avatar != null">
#{avatar,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR},
</if> </if>
<if test="profile != null">
#{profile,jdbcType=VARCHAR},
</if>
<if test="background != null">
#{background,jdbcType=VARCHAR},
</if>
<if test="weixinOpenid != null"> <if test="weixinOpenid != null">
#{weixinOpenid,jdbcType=VARCHAR}, #{weixinOpenid,jdbcType=VARCHAR},
</if> </if>
...@@ -359,6 +375,12 @@ ...@@ -359,6 +375,12 @@
<if test="record.avatar != null"> <if test="record.avatar != null">
avatar = #{record.avatar,jdbcType=VARCHAR}, avatar = #{record.avatar,jdbcType=VARCHAR},
</if> </if>
<if test="record.profile != null">
profile = #{record.profile,jdbcType=VARCHAR},
</if>
<if test="record.background != null">
background = #{record.background,jdbcType=VARCHAR},
</if>
<if test="record.weixinOpenid != null"> <if test="record.weixinOpenid != null">
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
</if> </if>
...@@ -398,6 +420,8 @@ ...@@ -398,6 +420,8 @@
nickname = #{record.nickname,jdbcType=VARCHAR}, nickname = #{record.nickname,jdbcType=VARCHAR},
mobile = #{record.mobile,jdbcType=VARCHAR}, mobile = #{record.mobile,jdbcType=VARCHAR},
avatar = #{record.avatar,jdbcType=VARCHAR}, avatar = #{record.avatar,jdbcType=VARCHAR},
profile = #{record.profile,jdbcType=VARCHAR},
background = #{record.background,jdbcType=VARCHAR},
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
wechat_id = #{record.wechatId,jdbcType=VARCHAR}, wechat_id = #{record.wechatId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=TINYINT}, `status` = #{record.status,jdbcType=TINYINT},
...@@ -442,6 +466,12 @@ ...@@ -442,6 +466,12 @@
<if test="avatar != null"> <if test="avatar != null">
avatar = #{avatar,jdbcType=VARCHAR}, avatar = #{avatar,jdbcType=VARCHAR},
</if> </if>
<if test="profile != null">
profile = #{profile,jdbcType=VARCHAR},
</if>
<if test="background != null">
background = #{background,jdbcType=VARCHAR},
</if>
<if test="weixinOpenid != null"> <if test="weixinOpenid != null">
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
</if> </if>
...@@ -478,6 +508,8 @@ ...@@ -478,6 +508,8 @@
nickname = #{nickname,jdbcType=VARCHAR}, nickname = #{nickname,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR}, mobile = #{mobile,jdbcType=VARCHAR},
avatar = #{avatar,jdbcType=VARCHAR}, avatar = #{avatar,jdbcType=VARCHAR},
profile = #{profile,jdbcType=VARCHAR},
background = #{background,jdbcType=VARCHAR},
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR}, weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
wechat_id = #{wechatId,jdbcType=VARCHAR}, wechat_id = #{wechatId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=TINYINT}, `status` = #{status,jdbcType=TINYINT},
...@@ -521,8 +553,8 @@ ...@@ -521,8 +553,8 @@
</when> </when>
<otherwise> <otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level, id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, wechat_id, `status`, add_time, update_time, nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
deleted, share_user_id add_time, update_time, deleted, share_user_id
</otherwise> </otherwise>
</choose> </choose>
from user from user
......
package com.wwdz.ch.wx.constant;
import java.util.HashMap;
import java.util.Map;
public class CacheCodeEnum {
public enum SmsTypeEnum {
LOGIN("LOGIN:", "登录"),
UPDATE("UPDATE:", "修改手机号"),
;
private String code;
private String name;
SmsTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static String getDesByCode(String code) {
for (SmsTypeEnum afterSaleStateEnum : SmsTypeEnum.values()) {
if (code.equals(afterSaleStateEnum.getCode())) {
return afterSaleStateEnum.getName();
}
}
return null;
}
/**
* 返回map
* @return
*/
public static Map<String, String> getSmsTypeEnumMap() {
Map<String, String> map = new HashMap<>();
for (SmsTypeEnum afterSaleStateEnum : SmsTypeEnum.values()) {
map.put(afterSaleStateEnum.getCode(), afterSaleStateEnum.getName());
}
return map;
}
}
}
...@@ -15,4 +15,7 @@ public class UserRequestDto implements Entity { ...@@ -15,4 +15,7 @@ public class UserRequestDto implements Entity {
private String wechatId; private String wechatId;
private String beforeMobile; private String beforeMobile;
private String afterMobile; private String afterMobile;
private String profile;
private String background;
private String smsType;
} }
package com.wwdz.ch.wx.impl; package com.wwdz.ch.wx.impl;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.FavoritesDao;
import com.wwdz.ch.db.dao.FavoritesItemsRelationDao;
import com.wwdz.ch.db.dao.ItemManager;
import com.wwdz.ch.db.dao.UserItemsRelationDao; import com.wwdz.ch.db.dao.UserItemsRelationDao;
import com.wwdz.ch.db.domain.Favorites; import com.wwdz.ch.db.domain.Favorites;
import com.wwdz.ch.db.domain.FavoritesItemsRelation; import com.wwdz.ch.db.domain.FavoritesItemsRelation;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.db.domain.UserItemsRelation; import com.wwdz.ch.db.domain.UserItemsRelation;
import com.wwdz.ch.db.dto.request.CoinRequestDto; import com.wwdz.ch.db.dto.request.CoinRequestDto;
import com.wwdz.ch.db.dao.FavoritesItemsRelationDao;
import com.wwdz.ch.db.dao.FavoritesDao;
import com.wwdz.ch.db.dao.ItemManager;
import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.request.FavoritesRequestDto; import com.wwdz.ch.wx.entity.request.FavoritesRequestDto;
import com.wwdz.ch.wx.entity.request.ItemRequestDto;
import com.wwdz.ch.wx.entity.vo.ItemResponseVo;
import com.wwdz.ch.wx.service.FavoritesService; import com.wwdz.ch.wx.service.FavoritesService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -150,6 +153,40 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -150,6 +153,40 @@ public class FavoritesServiceImpl implements FavoritesService {
} }
} }
@Override
public Result itemList(FavoritesRequestDto dto) {
try {
PageInfo<ItemResponseVo> page = new PageInfo<>();
page.setPageNum(dto.getPage());
page.setPageSize(dto.getSize());
page.setTotal(0L);
page.setList(new ArrayList<>());
PageInfo<FavoritesItemsRelation> relationPage = favoritesItemsRelationDao.pageByFavoritesId(dto.getId(), dto.getPage(), dto.getSize());
if (relationPage.getList().isEmpty()) {
return Result.success(page);
}
List<ItemResponseVo> list = new ArrayList<>();
for (FavoritesItemsRelation relation : relationPage.getList()) {
ItemResponseVo vo = new ItemResponseVo();
Item item = itemManager.findDetails(relation.getItemId());
vo.setId(relation.getItemId());
vo.setName(item.getName());
vo.setImages(item.getImages());
vo.setPrice(String.valueOf(item.getPrice() * 100));
vo.setDetail(item.getDetail());
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), relation.getItemId()) ? 1 : 0);
vo.setCollectCount(favoritesItemsRelationDao.countByItemId(relation.getItemId()));
list.add(vo);
}
page.setTotal(favoritesItemsRelationDao.countByFavoritesId(dto.getId()));
page.setList(list);
return Result.success(page);
} catch (Exception e) {
logger.error("查看收藏册的藏品列表失败,原因:" + e.getMessage(), e);
return Result.failed("查看收藏册的藏品列表失败");
}
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Result delete(FavoritesRequestDto dto) { public Result delete(FavoritesRequestDto dto) {
......
...@@ -73,7 +73,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -73,7 +73,7 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo.setDetail(item.getDetail()); itemResponseVo.setDetail(item.getDetail());
itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100)); itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100));
itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0); itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0);
itemResponseVo.setCollectCount(favoritesItemsRelationDao.count(footprint.getItemId())); itemResponseVo.setCollectCount(favoritesItemsRelationDao.countByItemId(footprint.getItemId()));
if (footprint.getAddTime().compareTo(today) >= 0) { if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo); todayList.add(itemResponseVo);
} }
...@@ -160,7 +160,7 @@ public class FootPrintServiceImpl implements FootPrintService { ...@@ -160,7 +160,7 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo.setDetail(item.getDetail()); itemResponseVo.setDetail(item.getDetail());
itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100)); itemResponseVo.setPrice(String.valueOf(item.getPrice() / 100));
itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0); itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), footprint.getItemId()) ? 1 : 0);
itemResponseVo.setCollectCount(favoritesItemsRelationDao.count(footprint.getItemId())); itemResponseVo.setCollectCount(favoritesItemsRelationDao.countByItemId(footprint.getItemId()));
if (footprint.getAddTime().compareTo(today) >= 0) { if (footprint.getAddTime().compareTo(today) >= 0) {
todayList.add(itemResponseVo); todayList.add(itemResponseVo);
} }
......
...@@ -65,7 +65,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -65,7 +65,7 @@ public class ItemServiceImpl implements ItemService {
vo.setPrice(String.valueOf(item.getPrice() * 100)); vo.setPrice(String.valueOf(item.getPrice() * 100));
vo.setDetail(item.getDetail()); vo.setDetail(item.getDetail());
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), item.getId()) ? 1 : 0); vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), item.getId()) ? 1 : 0);
vo.setCollectCount(favoritesItemsRelationDao.count(item.getId())); vo.setCollectCount(favoritesItemsRelationDao.countByItemId(item.getId()));
resultList.add(vo); resultList.add(vo);
} }
result.setList(resultList); result.setList(resultList);
......
...@@ -12,6 +12,7 @@ import com.wwdz.ch.core.util.CharUtil; ...@@ -12,6 +12,7 @@ import com.wwdz.ch.core.util.CharUtil;
import com.wwdz.ch.core.util.RegexUtil; import com.wwdz.ch.core.util.RegexUtil;
import com.wwdz.ch.db.dao.UserDao; import com.wwdz.ch.db.dao.UserDao;
import com.wwdz.ch.db.domain.User; import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.wx.constant.CacheCodeEnum;
import com.wwdz.ch.wx.dao.UserInfo; import com.wwdz.ch.wx.dao.UserInfo;
import com.wwdz.ch.wx.dao.UserToken; import com.wwdz.ch.wx.dao.UserToken;
import com.wwdz.ch.wx.dao.WxLoginInfo; import com.wwdz.ch.wx.dao.WxLoginInfo;
...@@ -84,7 +85,6 @@ public class UserServiceImpl implements UserService { ...@@ -84,7 +85,6 @@ public class UserServiceImpl implements UserService {
} }
User user = userDao.queryByOid(openId); User user = userDao.queryByOid(openId);
if (user == null) { if (user == null) {
user = new User(); user = new User();
user.setUsername(openId); user.setUsername(openId);
...@@ -129,16 +129,14 @@ public class UserServiceImpl implements UserService { ...@@ -129,16 +129,14 @@ public class UserServiceImpl implements UserService {
if (!StringUtils.isEmpty(user.getMobile())) {// 手机号存在则设置 if (!StringUtils.isEmpty(user.getMobile())) {// 手机号存在则设置
userInfo.setPhone(user.getMobile()); userInfo.setPhone(user.getMobile());
} }
try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String registerDate = simpleDateFormat.format(Objects.isNull(user.getAddTime()) ? new Date() : user.getAddTime());
String registerDate = simpleDateFormat.format(user.getAddTime() != null ? user.getAddTime() : new Date()); userInfo.setRegisterDate(registerDate);
userInfo.setRegisterDate(registerDate); userInfo.setStatus(user.getStatus());
userInfo.setStatus(user.getStatus()); // 用户层级
userInfo.setUserLevel(user.getUserLevel());// 用户层级 userInfo.setUserLevel(user.getUserLevel());
userInfo.setUserLevelDesc(UserTypeEnum.getInstance(user.getUserLevel()).getDesc());// 用户层级描述 // 用户层级描述
} catch (Exception e) { userInfo.setUserLevelDesc(UserTypeEnum.getInstance(user.getUserLevel()).getDesc());
logger.error("微信登录:设置用户指定信息出错:"+ e.getMessage(), e);
}
result.put("userInfo", userInfo); result.put("userInfo", userInfo);
logger.info("【请求结束】微信登录,响应结果:{}", JSONObject.toJSONString(result)); logger.info("【请求结束】微信登录,响应结果:{}", JSONObject.toJSONString(result));
...@@ -171,7 +169,7 @@ public class UserServiceImpl implements UserService { ...@@ -171,7 +169,7 @@ public class UserServiceImpl implements UserService {
} }
} }
boolean successful = CaptchaCodeManager.addToCache(dto.getMobile(), code,1); boolean successful = CaptchaCodeManager.addToCache(dto.getSmsType() + dto.getMobile(), code,1);
if (!successful) { if (!successful) {
logger.error("请求验证码出错:{}", WxResponseCode.AUTH_CAPTCHA_FREQUENCY.desc()); logger.error("请求验证码出错:{}", WxResponseCode.AUTH_CAPTCHA_FREQUENCY.desc());
return Result.failed(WxResponseCode.AUTH_CAPTCHA_FREQUENCY.desc()); return Result.failed(WxResponseCode.AUTH_CAPTCHA_FREQUENCY.desc());
...@@ -189,10 +187,12 @@ public class UserServiceImpl implements UserService { ...@@ -189,10 +187,12 @@ public class UserServiceImpl implements UserService {
@Override @Override
public Result loginByMobile(UserRequestDto dto, HttpServletRequest request) { public Result loginByMobile(UserRequestDto dto, HttpServletRequest request) {
try { try {
String mobileCode = CaptchaCodeManager.getCachedCaptcha(dto.getMobile()); String mobileCode = CaptchaCodeManager.getCachedCaptcha(CacheCodeEnum.SmsTypeEnum.LOGIN.getCode() + dto.getMobile());
if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) { if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) {
return Result.failed("验证码不正确"); return Result.failed("验证码不正确");
} }
// 获取微信授权信息
String openId = ""; String openId = "";
String sessionKey = ""; String sessionKey = "";
try { try {
...@@ -207,26 +207,39 @@ public class UserServiceImpl implements UserService { ...@@ -207,26 +207,39 @@ public class UserServiceImpl implements UserService {
if (StringUtils.isBlank(openId)) { if (StringUtils.isBlank(openId)) {
return Result.failed("手机号登录失败,获取openid失败"); return Result.failed("手机号登录失败,获取openid失败");
} }
// 判断手机号用户是否存在
User user = userDao.queryByMobile(dto.getMobile()); User user = userDao.queryByMobile(dto.getMobile());
if (Objects.isNull(user)) { if (Objects.isNull(user)) {
user = new User(); User openUser = userDao.queryByOid(openId);
user.setUsername(openId); if (Objects.isNull(openUser)) {
user.setPassword(openId); user = new User();
user.setWeixinOpenid(openId); user.setUsername(openId);
user.setMobile(dto.getMobile()); user.setPassword(openId);
user.setAvatar(dto.getAvatarUrl()); user.setWeixinOpenid(openId);
user.setNickname("微信用户" + StringUtil.generateRandomString(10)); user.setMobile(dto.getMobile());
user.setGender((byte) 0); user.setAvatar(dto.getAvatarUrl());
user.setUserLevel((byte) 0); user.setNickname("微信用户" + StringUtil.generateRandomString(10));
user.setStatus((byte) 0); user.setGender((byte) 0);
user.setLastLoginTime(new Date()); user.setUserLevel((byte) 0);
user.setLastLoginIp(IpUtil.client(request)); user.setStatus((byte) 0);
user.setShareUserId(dto.getShareUserId()); user.setLastLoginTime(new Date());
userDao.insert(user); user.setLastLoginIp(IpUtil.client(request));
user.setShareUserId(dto.getShareUserId());
userDao.insert(user);
FavoritesRequestDto favoritesRequestDto = new FavoritesRequestDto(); FavoritesRequestDto favoritesRequestDto = new FavoritesRequestDto();
favoritesRequestDto.setUserId(user.getId()); favoritesRequestDto.setUserId(user.getId());
favoritesService.addDefault(favoritesRequestDto); favoritesService.addDefault(favoritesRequestDto);
} else {
user = openUser;
user.setMobile(dto.getMobile());
user.setLastLoginTime(new Date());
user.setLastLoginIp(IpUtil.client(request));
if (userDao.updateById(user) == 0) {
return Result.failed(505, "更新用户数据失败");
}
}
} else { } else {
user.setLastLoginTime(new Date()); user.setLastLoginTime(new Date());
user.setLastLoginIp(IpUtil.client(request)); user.setLastLoginIp(IpUtil.client(request));
...@@ -255,20 +268,18 @@ public class UserServiceImpl implements UserService { ...@@ -255,20 +268,18 @@ public class UserServiceImpl implements UserService {
userInfo.setGender(user.getGender()); userInfo.setGender(user.getGender());
userInfo.setNickName(user.getNickname()); userInfo.setNickName(user.getNickname());
userInfo.setWechatId(user.getWechatId()); userInfo.setWechatId(user.getWechatId());
try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String registerDate = simpleDateFormat.format(Objects.isNull(user.getAddTime()) ? new Date() : user.getAddTime());
String registerDate = simpleDateFormat.format(user.getAddTime() != null ? user.getAddTime() : new Date()); userInfo.setRegisterDate(registerDate);
userInfo.setRegisterDate(registerDate); userInfo.setStatus(user.getStatus());
userInfo.setStatus(user.getStatus()); // 用户层级
userInfo.setUserLevel(user.getUserLevel());// 用户层级 userInfo.setUserLevel(user.getUserLevel());
userInfo.setUserLevelDesc(UserTypeEnum.getInstance(user.getUserLevel()).getDesc());// 用户层级描述 // 用户层级描述
} catch (Exception e) { userInfo.setUserLevelDesc(UserTypeEnum.getInstance(user.getUserLevel()).getDesc());
logger.error("手机号登录:设置用户指定信息出错:"+ e.getMessage(), e);
}
result.put("userInfo", userInfo); result.put("userInfo", userInfo);
logger.info("【请求结束】手机号登录,响应结果:{}", JSONObject.toJSONString(result)); logger.info("【请求结束】手机号登录,响应结果:{}", JSONObject.toJSONString(result));
return Result.success(); return Result.success(result);
} catch (Exception e) { } catch (Exception e) {
logger.error("手机号登录失败", e); logger.error("手机号登录失败", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
...@@ -276,6 +287,42 @@ public class UserServiceImpl implements UserService { ...@@ -276,6 +287,42 @@ public class UserServiceImpl implements UserService {
} }
} }
@Transactional(rollbackFor = Exception.class)
@Override
public Result updateProfile(UserRequestDto dto) {
try {
User user = userDao.queryById(dto.getUserId());
if (Objects.isNull(user)) {
return Result.failed("数据异常,用户不存在");
}
user.setProfile(dto.getProfile());
userDao.updateById(user);
return Result.success();
} catch (Exception e) {
logger.error("用户修改个性签名失败", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.failed("修改个性签名失败");
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public Result updateBackground(UserRequestDto dto) {
try {
User user = userDao.queryById(dto.getUserId());
if (Objects.isNull(user)) {
return Result.failed("数据异常,用户不存在");
}
user.setBackground(dto.getBackground());
userDao.updateById(user);
return Result.success();
} catch (Exception e) {
logger.error("用户修改背景失败", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.failed("修改背景失败");
}
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public Result updateNickname(UserRequestDto dto) { public Result updateNickname(UserRequestDto dto) {
...@@ -284,6 +331,9 @@ public class UserServiceImpl implements UserService { ...@@ -284,6 +331,9 @@ public class UserServiceImpl implements UserService {
if (Objects.isNull(user)) { if (Objects.isNull(user)) {
return Result.failed("数据异常,用户不存在"); return Result.failed("数据异常,用户不存在");
} }
if (userDao.isExistedByNickname(dto.getUserId(), dto.getNickname())) {
return Result.failed("昵称已存在");
}
user.setNickname(dto.getNickname()); user.setNickname(dto.getNickname());
userDao.updateById(user); userDao.updateById(user);
return Result.success(); return Result.success();
...@@ -320,6 +370,9 @@ public class UserServiceImpl implements UserService { ...@@ -320,6 +370,9 @@ public class UserServiceImpl implements UserService {
if (Objects.isNull(user)) { if (Objects.isNull(user)) {
return Result.failed("数据异常,用户不存在"); return Result.failed("数据异常,用户不存在");
} }
if (userDao.isExistedByWechatId(dto.getUserId(), dto.getWechatId())) {
return Result.failed("无法绑定,该微信号已被绑定");
}
user.setWechatId(dto.getWechatId()); user.setWechatId(dto.getWechatId());
userDao.updateById(user); userDao.updateById(user);
return Result.success(); return Result.success();
...@@ -341,8 +394,8 @@ public class UserServiceImpl implements UserService { ...@@ -341,8 +394,8 @@ public class UserServiceImpl implements UserService {
if (!StringUtils.equals(user.getMobile(), dto.getBeforeMobile())) { if (!StringUtils.equals(user.getMobile(), dto.getBeforeMobile())) {
return Result.failed("原手机号码不正确"); return Result.failed("原手机号码不正确");
} }
String mobileCode = CaptchaCodeManager.getCachedCaptcha(dto.getAfterMobile()); String mobileCode = CaptchaCodeManager.getCachedCaptcha(CacheCodeEnum.SmsTypeEnum.UPDATE.getCode() + dto.getAfterMobile());
if (!StringUtils.equals(dto.getCode(), mobileCode)) { if (!StringUtils.equals(dto.getSmsCode(), mobileCode)) {
return Result.failed("验证码不正确"); return Result.failed("验证码不正确");
} }
if (userDao.isExistedByMobile(dto.getBeforeMobile(), dto.getAfterMobile())) { if (userDao.isExistedByMobile(dto.getBeforeMobile(), dto.getAfterMobile())) {
......
...@@ -16,6 +16,8 @@ public interface FavoritesService { ...@@ -16,6 +16,8 @@ public interface FavoritesService {
Result info(FavoritesRequestDto dto); Result info(FavoritesRequestDto dto);
Result itemList(FavoritesRequestDto dto);
Result delete(FavoritesRequestDto dto); Result delete(FavoritesRequestDto dto);
Result batchDelete(FavoritesRequestDto dto); Result batchDelete(FavoritesRequestDto dto);
......
...@@ -13,6 +13,10 @@ public interface UserService { ...@@ -13,6 +13,10 @@ public interface UserService {
Result loginByMobile(UserRequestDto dto, HttpServletRequest request); Result loginByMobile(UserRequestDto dto, HttpServletRequest request);
Result updateProfile(UserRequestDto dto);
Result updateBackground(UserRequestDto dto);
Result updateNickname(UserRequestDto dto); Result updateNickname(UserRequestDto dto);
Result updateAvatar(UserRequestDto dto); Result updateAvatar(UserRequestDto dto);
......
...@@ -54,6 +54,12 @@ public class WxFavoritesController { ...@@ -54,6 +54,12 @@ public class WxFavoritesController {
return favoritesService.info(dto); return favoritesService.info(dto);
} }
@ApiOperation(value = "详情")
@PostMapping("/itemList")
public Result itemList(@RequestBody @Validated(Select.class) FavoritesRequestDto dto) {
return favoritesService.itemList(dto);
}
@ApiOperation(value = "单个删除") @ApiOperation(value = "单个删除")
@PostMapping("/delete") @PostMapping("/delete")
public Result delete(@RequestBody @Validated(Delete.class) FavoritesRequestDto dto) { public Result delete(@RequestBody @Validated(Delete.class) FavoritesRequestDto dto) {
......
...@@ -7,9 +7,11 @@ import com.wwdz.ch.core.util.ResponseUtil; ...@@ -7,9 +7,11 @@ import com.wwdz.ch.core.util.ResponseUtil;
import com.wwdz.ch.db.domain.UserAccountObsolete; import com.wwdz.ch.db.domain.UserAccountObsolete;
import com.wwdz.ch.db.service.DtsAccountService; import com.wwdz.ch.db.service.DtsAccountService;
import com.wwdz.ch.wx.annotation.LoginUser; import com.wwdz.ch.wx.annotation.LoginUser;
import com.wwdz.ch.wx.constant.CacheCodeEnum;
import com.wwdz.ch.wx.dao.WxLoginInfo; import com.wwdz.ch.wx.dao.WxLoginInfo;
import com.wwdz.ch.wx.entity.request.UserRequestDto; import com.wwdz.ch.wx.entity.request.UserRequestDto;
import com.wwdz.ch.wx.service.UserService; import com.wwdz.ch.wx.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* 用户服务 * 用户服务
...@@ -86,25 +89,125 @@ public class WxUserController { ...@@ -86,25 +89,125 @@ public class WxUserController {
return ResponseUtil.ok(data); return ResponseUtil.ok(data);
} }
@ApiOperation(value = "微信登录")
@PostMapping("/loginByWx") @PostMapping("/loginByWx")
public Result loginByWx(@RequestBody WxLoginInfo wxLoginInfo, HttpServletRequest request) { public Result loginByWx(@RequestBody WxLoginInfo wxLoginInfo, HttpServletRequest request) {
logger.info("【请求开始】微信登录,请求参数,wxLoginInfo:{}", JSONObject.toJSONString(wxLoginInfo)); logger.info("【请求开始】微信登录,请求参数,wxLoginInfo:{}", JSONObject.toJSONString(wxLoginInfo));
return userService.loginByWx(wxLoginInfo, request); return userService.loginByWx(wxLoginInfo, request);
} }
@PostMapping("/regCaptcha") @ApiOperation(value = "登录手机验证码")
@PostMapping("/loginRegCaptcha")
public Object registerCaptcha(@RequestBody UserRequestDto dto) { public Object registerCaptcha(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】请求验证码,请求参数,mobile:{}", dto.getMobile()); logger.info("【请求开始】请求验证码,请求参数,mobile:{}", dto.getMobile());
if (StringUtils.isBlank(dto.getMobile())) { if (StringUtils.isBlank(dto.getMobile())) {
return Result.failed("手机号不能为空"); return Result.failed("手机号不能为空");
} }
dto.setSmsType(CacheCodeEnum.SmsTypeEnum.LOGIN.getCode());
return userService.regCaptcha(dto); return userService.regCaptcha(dto);
} }
@ApiOperation(value = "手机验证码登录")
@PostMapping("/loginByMobile") @PostMapping("/loginByMobile")
public Result loginByMobile(@RequestBody UserRequestDto dto, HttpServletRequest request) { public Result loginByMobile(@RequestBody UserRequestDto dto, HttpServletRequest request) {
logger.info("【请求开始】手机号登录,请求参数,wxLoginInfo:{}", JSONObject.toJSONString(dto)); logger.info("【请求开始】手机号登录,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
return userService.loginByMobile(dto, request); return userService.loginByMobile(dto, request);
} }
@ApiOperation(value = "修改个性签名")
@PostMapping("/updateProfile")
public Result updateProfile(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改个性签名,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getProfile())) {
return Result.failed("个性签名不能为空");
}
return userService.updateProfile(dto);
}
@ApiOperation(value = "修改背景")
@PostMapping("/updateBackground")
public Result updateBackground(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改背景,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getBackground())) {
return Result.failed("背景图片路径不能为空");
}
return userService.updateBackground(dto);
}
@ApiOperation(value = "修改昵称")
@PostMapping("/updateNickname")
public Result updateNickname(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改昵称,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getNickname())) {
return Result.failed("昵称不能为空");
}
return userService.updateNickname(dto);
}
@ApiOperation(value = "修改头像")
@PostMapping("/updateAvatar")
public Result updateAvatar(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改头像,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getAvatarUrl())) {
return Result.failed("头像图片路径不能为空");
}
return userService.updateAvatar(dto);
}
@ApiOperation(value = "绑定微信号")
@PostMapping("/bindWechatId")
public Result bindWechatId(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】绑定微信号,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getWechatId())) {
return Result.failed("微信号不能为空");
}
return userService.bindWechatId(dto);
}
@ApiOperation(value = "修改手机验证码")
@PostMapping("/updateRegCaptcha")
public Object updateRegCaptcha(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】请求修改手机验证码,请求参数,mobile:{}", dto.getMobile());
if (StringUtils.isBlank(dto.getMobile())) {
return Result.failed("手机号不能为空");
}
dto.setSmsType(CacheCodeEnum.SmsTypeEnum.UPDATE.getCode());
return userService.regCaptcha(dto);
}
@ApiOperation(value = "修改手机号")
@PostMapping("/updateMobile")
public Result updateMobile(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】修改手机号,请求参数,userRequestDto:{}", JSONObject.toJSONString(dto));
if (Objects.isNull(dto.getUserId())) {
return Result.failed("用户id不能为空");
}
if (StringUtils.isBlank(dto.getBeforeMobile())) {
return Result.failed("原手机号不能为空");
}
if (StringUtils.isBlank(dto.getAfterMobile())) {
return Result.failed("新手机号不能为空");
}
if (StringUtils.isBlank(dto.getSmsCode())) {
return Result.failed("验证码不能为空");
}
return userService.updateMobile(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