src/main/java/com/moral/entity/Account.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/entity/JwtTokenVersion.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/mapper/AccountMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/mapper/JwtTokenVersionMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/impl/AccountServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/AccountMapper.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/com/moral/entity/Account.java
@@ -74,6 +74,8 @@ private String userName; @Transient private JwtTokenVersion jwtTokenVersion; @Transient private List<Role> Roles; // TODO 临时角色 public List<Role> getRoles(){ src/main/java/com/moral/entity/JwtTokenVersion.java
New file @@ -0,0 +1,15 @@ package com.moral.entity; import lombok.Data; import java.util.Date; @Data public class JwtTokenVersion { private Integer id; private Integer accountName; private Date updateTime; } src/main/java/com/moral/mapper/AccountMapper.java
@@ -8,4 +8,5 @@ public interface AccountMapper extends BaseMapper<Account> { List<Map<String, Object>> getRoleNameByAccountId(Integer accountId); Account getByAccountName(String name); } src/main/java/com/moral/mapper/JwtTokenVersionMapper.java
New file @@ -0,0 +1,7 @@ package com.moral.mapper; import com.moral.common.mapper.BaseMapper; import com.moral.entity.JwtTokenVersion; public interface JwtTokenVersionMapper extends BaseMapper<JwtTokenVersion> { } src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -170,8 +170,10 @@ @Override public Optional<Account> queryAccountByName(String accountName) { Account account = new Account(); account.setAccountName(accountName); return Optional.ofNullable(accountMapper.selectOne(account)); Account account = accountMapper.getByAccountName(accountName); if(account!=null){ } return Optional.ofNullable(account); } } src/main/resources/mapper/AccountMapper.xml
@@ -1,6 +1,34 @@ <?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.moral.mapper.AccountMapper"> <resultMap id="BaseResultMap" type="com.moral.entity.Account"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="account_name" jdbcType="VARCHAR" property="accountName" /> <result column="password" jdbcType="VARCHAR" property="password" /> <result column="organization_id" jdbcType="INTEGER" property="organizationId" /> <result column="email" jdbcType="VARCHAR" property="email" /> <result column="mobile" jdbcType="VARCHAR" property="mobile" /> <result column="weixin" jdbcType="VARCHAR" property="weixin" /> <result column="is_delete" jdbcType="CHAR" property="isDelete" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" /> <result column="user_name" jdbcType="VARCHAR" property="userName" /> <association property="jwtTokenVersion" javaType="com.moral.entity.JwtTokenVersion"> <result column="jwt_token_version_id" property="id" jdbcType="INTEGER" /> <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> </association> </resultMap> <sql id="Base_Column_List"> id, account_name, password, organization_id, email, mobile, weixin, is_delete, create_time, expire_time, user_name </sql> <select id="getByAccountName" parameterType="java.lang.String" resultMap="BaseResultMap"> select acc.*,jtv.id as jwt_token_version_id,jtv.update_time as update_time from account acc left join jwt_token_version jtv on acc.account_name = jtv.account_name where acc.account_name = #{name,jdbcType=VARCHAR} </select> <select id="getRoleNameByAccountId" resultType="java.util.Map"> SELECT r.role_name