作者 朱兆平

卡口用户登录验证OK

package com.tianbo.warehouse.dao;
import com.tianbo.warehouse.model.KakoUser;
import java.util.List;
public interface KakoUserMapper {
int deleteByPrimaryKey(String id);
int insert(KakoUser record);
int insertSelective(KakoUser record);
KakoUser selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(KakoUser record);
int updateByPrimaryKey(KakoUser record);
List<KakoUser> selectByUsername(String userName);
int lockUser(KakoUser record);
}
\ No newline at end of file
... ...
package com.tianbo.warehouse.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
public class KakoUser implements UserDetails {
private String id;
private String companyId;
private String officeId;
private String loginName;
private String password;
private String no;
private String name;
private String email;
private String phone;
private String mobile;
private String userType;
private String photo;
private String loginIp;
private Date loginDate;
private String loginFlag;
private String createBy;
private Date createDate;
private String updateBy;
private Date updateDate;
private String remarks;
private String delFlag;
private String token;
@JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty})
private List<ROLE> roles;
@JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty})
private List<PERMISSION> permissions;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId == null ? null : companyId.trim();
}
public String getOfficeId() {
return officeId;
}
public void setOfficeId(String officeId) {
this.officeId = officeId == null ? null : officeId.trim();
}
public String getLoginName() {
return loginName;
}
@Override
public String getUsername() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName == null ? null : loginName.trim();
}
@Override
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no == null ? null : no.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile == null ? null : mobile.trim();
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType == null ? null : userType.trim();
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo == null ? null : photo.trim();
}
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp == null ? null : loginIp.trim();
}
public Date getLoginDate() {
return loginDate;
}
public void setLoginDate(Date loginDate) {
this.loginDate = loginDate;
}
public String getLoginFlag() {
return loginFlag;
}
public void setLoginFlag(String loginFlag) {
this.loginFlag = loginFlag == null ? null : loginFlag.trim();
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy == null ? null : updateBy.trim();
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks == null ? null : remarks.trim();
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag == null ? null : delFlag.trim();
}
public List<ROLE> getRoles() {
return roles;
}
public void setRoles(List<ROLE> roles) {
this.roles = roles;
}
public List<PERMISSION> getPermissions() {
return permissions;
}
public void setPermissions(List<PERMISSION> permissions) {
this.permissions = permissions;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
/**
*
* @return 账户未过期
*/
@Override
public boolean isAccountNonExpired(){
return true;
}
/**
*
* @return 账户未锁定
*/
@Override
public boolean isAccountNonLocked(){
return true;
}
/**
*
* @return 密码未过期
*/
@Override
public boolean isCredentialsNonExpired(){
return true;
}
/**
*
* @return 账户可用
*/
@Override
public boolean isEnabled(){
if(loginFlag!=null && !loginFlag.isEmpty() && loginFlag.equals("1")){
return true;
}
return false;
}
/**
*
* @return user的权限列表
*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities(){
List<GrantedAuthority> auths = new ArrayList<>();
if(roles!=null && !roles.isEmpty()){
for (ROLE role : roles) {
if (null != role){
auths.add(new SimpleGrantedAuthority(role.getAuthority()));
}
}
}
return auths;
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.tianbo.warehouse.dao.KakoUserMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.KakoUser" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="company_id" property="companyId" jdbcType="VARCHAR" />
<result column="office_id" property="officeId" jdbcType="VARCHAR" />
<result column="login_name" property="loginName" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="no" property="no" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="user_type" property="userType" jdbcType="CHAR" />
<result column="photo" property="photo" jdbcType="VARCHAR" />
<result column="login_ip" property="loginIp" jdbcType="VARCHAR" />
<result column="login_date" property="loginDate" jdbcType="TIMESTAMP" />
<result column="login_flag" property="loginFlag" jdbcType="VARCHAR" />
<result column="create_by" property="createBy" jdbcType="VARCHAR" />
<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
<result column="update_by" property="updateBy" jdbcType="VARCHAR" />
<result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
<result column="remarks" property="remarks" jdbcType="VARCHAR" />
<result column="del_flag" property="delFlag" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, company_id, office_id, login_name, password, no, name, email, phone, mobile,
user_type, photo, login_ip, login_date, login_flag, create_by, create_date, update_by,
update_date, remarks, del_flag
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from sys_user
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="selectByUsername" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from sys_user
where login_name = #{login_name,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from sys_user
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.KakoUser" >
insert into sys_user (id, company_id, office_id,
login_name, password, no,
name, email, phone,
mobile, user_type, photo,
login_ip, login_date, login_flag,
create_by, create_date, update_by,
update_date, remarks, del_flag
)
values (#{id,jdbcType=VARCHAR}, #{companyId,jdbcType=VARCHAR}, #{officeId,jdbcType=VARCHAR},
#{loginName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{no,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
#{mobile,jdbcType=VARCHAR}, #{userType,jdbcType=CHAR}, #{photo,jdbcType=VARCHAR},
#{loginIp,jdbcType=VARCHAR}, #{loginDate,jdbcType=TIMESTAMP}, #{loginFlag,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.KakoUser" >
insert into sys_user
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="companyId != null" >
company_id,
</if>
<if test="officeId != null" >
office_id,
</if>
<if test="loginName != null" >
login_name,
</if>
<if test="password != null" >
password,
</if>
<if test="no != null" >
no,
</if>
<if test="name != null" >
name,
</if>
<if test="email != null" >
email,
</if>
<if test="phone != null" >
phone,
</if>
<if test="mobile != null" >
mobile,
</if>
<if test="userType != null" >
user_type,
</if>
<if test="photo != null" >
photo,
</if>
<if test="loginIp != null" >
login_ip,
</if>
<if test="loginDate != null" >
login_date,
</if>
<if test="loginFlag != null" >
login_flag,
</if>
<if test="createBy != null" >
create_by,
</if>
<if test="createDate != null" >
create_date,
</if>
<if test="updateBy != null" >
update_by,
</if>
<if test="updateDate != null" >
update_date,
</if>
<if test="remarks != null" >
remarks,
</if>
<if test="delFlag != null" >
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=VARCHAR},
</if>
<if test="companyId != null" >
#{companyId,jdbcType=VARCHAR},
</if>
<if test="officeId != null" >
#{officeId,jdbcType=VARCHAR},
</if>
<if test="loginName != null" >
#{loginName,jdbcType=VARCHAR},
</if>
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="no != null" >
#{no,jdbcType=VARCHAR},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="phone != null" >
#{phone,jdbcType=VARCHAR},
</if>
<if test="mobile != null" >
#{mobile,jdbcType=VARCHAR},
</if>
<if test="userType != null" >
#{userType,jdbcType=CHAR},
</if>
<if test="photo != null" >
#{photo,jdbcType=VARCHAR},
</if>
<if test="loginIp != null" >
#{loginIp,jdbcType=VARCHAR},
</if>
<if test="loginDate != null" >
#{loginDate,jdbcType=TIMESTAMP},
</if>
<if test="loginFlag != null" >
#{loginFlag,jdbcType=VARCHAR},
</if>
<if test="createBy != null" >
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null" >
#{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null" >
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null" >
#{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null" >
#{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null" >
#{delFlag,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.KakoUser" >
update sys_user
<set >
<if test="companyId != null" >
company_id = #{companyId,jdbcType=VARCHAR},
</if>
<if test="officeId != null" >
office_id = #{officeId,jdbcType=VARCHAR},
</if>
<if test="loginName != null" >
login_name = #{loginName,jdbcType=VARCHAR},
</if>
<if test="password != null" >
password = #{password,jdbcType=VARCHAR},
</if>
<if test="no != null" >
no = #{no,jdbcType=VARCHAR},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="email != null" >
email = #{email,jdbcType=VARCHAR},
</if>
<if test="phone != null" >
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="mobile != null" >
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="userType != null" >
user_type = #{userType,jdbcType=CHAR},
</if>
<if test="photo != null" >
photo = #{photo,jdbcType=VARCHAR},
</if>
<if test="loginIp != null" >
login_ip = #{loginIp,jdbcType=VARCHAR},
</if>
<if test="loginDate != null" >
login_date = #{loginDate,jdbcType=TIMESTAMP},
</if>
<if test="loginFlag != null" >
login_flag = #{loginFlag,jdbcType=VARCHAR},
</if>
<if test="createBy != null" >
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null" >
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null" >
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null" >
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null" >
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null" >
del_flag = #{delFlag,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.KakoUser" >
update sys_user
set company_id = #{companyId,jdbcType=VARCHAR},
office_id = #{officeId,jdbcType=VARCHAR},
login_name = #{loginName,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
no = #{no,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
email = #{email,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
user_type = #{userType,jdbcType=CHAR},
photo = #{photo,jdbcType=VARCHAR},
login_ip = #{loginIp,jdbcType=VARCHAR},
login_date = #{loginDate,jdbcType=TIMESTAMP},
login_flag = #{loginFlag,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_date = #{createDate,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_date = #{updateDate,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR},
del_flag = #{delFlag,jdbcType=CHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="lockUser" parameterType="com.tianbo.warehouse.model.KakoUser" >
update sys_user
set
login_flag = #{loginFlag,jdbcType=VARCHAR}
where login_name = #{loginName,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...