Skip to content

修改小程序端登录验证方式,引入JWT #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions litemall-db/sql/litemall_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ CREATE TABLE `litemall_user` (
`mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '用户手机号码',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '用户头像图片',
`weixin_openid` varchar(63) NOT NULL DEFAULT '' COMMENT '微信登录openid',
`session_key` varchar(100) NOT NULL DEFAULT '' COMMENT '微信登录会话KEY',
`status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '0 可用, 1 禁用, 2 注销',
`add_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ public class LitemallUser {
*/
private String weixinOpenid;

/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user.session_key
*
* @mbg.generated
*/
private String sessionKey;

/**
*
* This field was generated by MyBatis Generator.
Expand Down Expand Up @@ -456,6 +465,30 @@ public void setWeixinOpenid(String weixinOpenid) {
this.weixinOpenid = weixinOpenid;
}

/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user.session_key
*
* @return the value of litemall_user.session_key
*
* @mbg.generated
*/
public String getSessionKey() {
return sessionKey;
}

/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user.session_key
*
* @param sessionKey the value for litemall_user.session_key
*
* @mbg.generated
*/
public void setSessionKey(String sessionKey) {
this.sessionKey = sessionKey;
}

/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user.status
Expand Down Expand Up @@ -576,6 +609,7 @@ public String toString() {
sb.append(", mobile=").append(mobile);
sb.append(", avatar=").append(avatar);
sb.append(", weixinOpenid=").append(weixinOpenid);
sb.append(", sessionKey=").append(sessionKey);
sb.append(", status=").append(status);
sb.append(", addTime=").append(addTime);
sb.append(", updateTime=").append(updateTime);
Expand Down Expand Up @@ -614,6 +648,7 @@ public boolean equals(Object that) {
&& (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile()))
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getWeixinOpenid() == null ? other.getWeixinOpenid() == null : this.getWeixinOpenid().equals(other.getWeixinOpenid()))
&& (this.getSessionKey() == null ? other.getSessionKey() == null : this.getSessionKey().equals(other.getSessionKey()))
&& (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()))
Expand Down Expand Up @@ -642,6 +677,7 @@ public int hashCode() {
result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode());
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
result = prime * result + ((getWeixinOpenid() == null) ? 0 : getWeixinOpenid().hashCode());
result = prime * result + ((getSessionKey() == null) ? 0 : getSessionKey().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());
Expand Down Expand Up @@ -680,6 +716,7 @@ public enum Column {
mobile("mobile", "mobile", "VARCHAR", false),
avatar("avatar", "avatar", "VARCHAR", false),
weixinOpenid("weixin_openid", "weixinOpenid", "VARCHAR", false),
sessionKey("session_key", "sessionKey", "VARCHAR", false),
status("status", "status", "TINYINT", true),
addTime("add_time", "addTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,148 @@ public Criteria andWeixinOpenidNotBetween(String value1, String value2) {
return (Criteria) this;
}

public Criteria andSessionKeyIsNull() {
addCriterion("session_key is null");
return (Criteria) this;
}

public Criteria andSessionKeyIsNotNull() {
addCriterion("session_key is not null");
return (Criteria) this;
}

public Criteria andSessionKeyEqualTo(String value) {
addCriterion("session_key =", value, "sessionKey");
return (Criteria) this;
}

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSessionKeyEqualToColumn(LitemallUser.Column column) {
addCriterion(new StringBuilder("session_key = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}

public Criteria andSessionKeyNotEqualTo(String value) {
addCriterion("session_key <>", value, "sessionKey");
return (Criteria) this;
}

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSessionKeyNotEqualToColumn(LitemallUser.Column column) {
addCriterion(new StringBuilder("session_key <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}

public Criteria andSessionKeyGreaterThan(String value) {
addCriterion("session_key >", value, "sessionKey");
return (Criteria) this;
}

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSessionKeyGreaterThanColumn(LitemallUser.Column column) {
addCriterion(new StringBuilder("session_key > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}

public Criteria andSessionKeyGreaterThanOrEqualTo(String value) {
addCriterion("session_key >=", value, "sessionKey");
return (Criteria) this;
}

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSessionKeyGreaterThanOrEqualToColumn(LitemallUser.Column column) {
addCriterion(new StringBuilder("session_key >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}

public Criteria andSessionKeyLessThan(String value) {
addCriterion("session_key <", value, "sessionKey");
return (Criteria) this;
}

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSessionKeyLessThanColumn(LitemallUser.Column column) {
addCriterion(new StringBuilder("session_key < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}

public Criteria andSessionKeyLessThanOrEqualTo(String value) {
addCriterion("session_key <=", value, "sessionKey");
return (Criteria) this;
}

/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andSessionKeyLessThanOrEqualToColumn(LitemallUser.Column column) {
addCriterion(new StringBuilder("session_key <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}

public Criteria andSessionKeyLike(String value) {
addCriterion("session_key like", value, "sessionKey");
return (Criteria) this;
}

public Criteria andSessionKeyNotLike(String value) {
addCriterion("session_key not like", value, "sessionKey");
return (Criteria) this;
}

public Criteria andSessionKeyIn(List<String> values) {
addCriterion("session_key in", values, "sessionKey");
return (Criteria) this;
}

public Criteria andSessionKeyNotIn(List<String> values) {
addCriterion("session_key not in", values, "sessionKey");
return (Criteria) this;
}

public Criteria andSessionKeyBetween(String value1, String value2) {
addCriterion("session_key between", value1, value2, "sessionKey");
return (Criteria) this;
}

public Criteria andSessionKeyNotBetween(String value1, String value2) {
addCriterion("session_key not between", value1, value2, "sessionKey");
return (Criteria) this;
}

public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<result column="mobile" jdbcType="VARCHAR" property="mobile" />
<result column="avatar" jdbcType="VARCHAR" property="avatar" />
<result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid" />
<result column="session_key" jdbcType="VARCHAR" property="sessionKey" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
Expand Down Expand Up @@ -95,7 +96,8 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, `status`, add_time, update_time, deleted
nickname, mobile, avatar, weixin_openid, session_key, `status`, add_time, update_time,
deleted
</sql>
<select id="selectByExample" parameterType="org.linlinjava.litemall.db.domain.LitemallUserExample" resultMap="BaseResultMap">
<!--
Expand Down Expand Up @@ -133,8 +135,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, `status`, add_time, update_time, deleted

nickname, mobile, avatar, weixin_openid, session_key, `status`, add_time, update_time,
deleted
</otherwise>
</choose>
from litemall_user
Expand Down Expand Up @@ -194,8 +196,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, `status`, add_time, update_time, deleted

nickname, mobile, avatar, weixin_openid, session_key, `status`, add_time, update_time,
deleted
</otherwise>
</choose>
from litemall_user
Expand Down Expand Up @@ -230,15 +232,15 @@
insert into litemall_user (username, `password`, gender,
birthday, last_login_time, last_login_ip,
user_level, nickname, mobile,
avatar, weixin_openid, `status`,
add_time, update_time, deleted
)
avatar, weixin_openid, session_key,
`status`, add_time, update_time,
deleted)
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}, #{weixinOpenid,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT}
)
#{avatar,jdbcType=VARCHAR}, #{weixinOpenid,jdbcType=VARCHAR}, #{sessionKey,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="org.linlinjava.litemall.db.domain.LitemallUser">
<!--
Expand Down Expand Up @@ -283,6 +285,9 @@
<if test="weixinOpenid != null">
weixin_openid,
</if>
<if test="sessionKey != null">
session_key,
</if>
<if test="status != null">
`status`,
</if>
Expand Down Expand Up @@ -330,6 +335,9 @@
<if test="weixinOpenid != null">
#{weixinOpenid,jdbcType=VARCHAR},
</if>
<if test="sessionKey != null">
#{sessionKey,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
Expand Down Expand Up @@ -397,6 +405,9 @@
<if test="record.weixinOpenid != null">
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
</if>
<if test="record.sessionKey != null">
session_key = #{record.sessionKey,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=TINYINT},
</if>
Expand Down Expand Up @@ -432,6 +443,7 @@
mobile = #{record.mobile,jdbcType=VARCHAR},
avatar = #{record.avatar,jdbcType=VARCHAR},
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
session_key = #{record.sessionKey,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=TINYINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
Expand Down Expand Up @@ -480,6 +492,9 @@
<if test="weixinOpenid != null">
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
</if>
<if test="sessionKey != null">
session_key = #{sessionKey,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=TINYINT},
</if>
Expand Down Expand Up @@ -512,6 +527,7 @@
mobile = #{mobile,jdbcType=VARCHAR},
avatar = #{avatar,jdbcType=VARCHAR},
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
session_key = #{sessionKey,jdbcType=VARCHAR},
`status` = #{status,jdbcType=TINYINT},
add_time = #{addTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
Expand Down Expand Up @@ -550,8 +566,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, weixin_openid, `status`, add_time, update_time, deleted

nickname, mobile, avatar, weixin_openid, session_key, `status`, add_time, update_time,
deleted
</otherwise>
</choose>
from litemall_user
Expand Down
6 changes: 6 additions & 0 deletions litemall-wx-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
</dependency>

<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.1</version>
</dependency>

</dependencies>

Expand Down
Loading