feat: add highgo support
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>hcframe-base</artifactId>
|
<artifactId>hcframe-base</artifactId>
|
||||||
<version>1.2.3-SNAPSHOT</version>
|
<version>1.2.4-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
@@ -48,6 +48,13 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.highgo/HgdbJdbc -->
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.highgo/HgdbJdbc -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.highgo</groupId>
|
||||||
|
<artifactId>HgdbJdbc</artifactId>
|
||||||
|
<version>6.2.3</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
if (dataType.contains("sqlite")) {
|
if (dataType.contains("sqlite")) {
|
||||||
datasourceConfig.setCommonType(DataUnit.SQLITE);
|
datasourceConfig.setCommonType(DataUnit.SQLITE);
|
||||||
}
|
}
|
||||||
|
if(dataType.contains("highgo")) {
|
||||||
|
datasourceConfig.setCommonType(DataUnit.HANGO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JudgesNull(dataMap.getData(), "data can not be null!");
|
JudgesNull(dataMap.getData(), "data can not be null!");
|
||||||
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
JudgesNull(dataMap.getTableName(), "tableName can not be null!");
|
||||||
@@ -65,7 +68,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
dataMap.setPkName("ID");
|
dataMap.setPkName("ID");
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
if (DataUnit.ORACLE.equals(datasourceConfig.getCommonType()) || DataUnit.DAMENG.equals(datasourceConfig.getCommonType())) {
|
if (DataUnit.ORACLE.equals(datasourceConfig.getCommonType()) || DataUnit.DAMENG.equals(datasourceConfig.getCommonType()) || DataUnit.HANGO.equals(datasourceConfig.getCommonType())) {
|
||||||
if (org.springframework.util.StringUtils.isEmpty(dataMap.get(dataMap.getPkName()))) {
|
if (org.springframework.util.StringUtils.isEmpty(dataMap.get(dataMap.getPkName()))) {
|
||||||
Object id = getSequence(dataMap.getTableName(), dataMap.getPkName());
|
Object id = getSequence(dataMap.getTableName(), dataMap.getPkName());
|
||||||
dataMap.toBuilder().add(dataMap.getPkName(), id);
|
dataMap.toBuilder().add(dataMap.getPkName(), id);
|
||||||
@@ -82,10 +85,14 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatTable(String tableName) {
|
||||||
|
return "`"+tableName+"`";
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public int save(String tableName, String pkName, Map<String, Object> data) {
|
public int save(String tableName, String pkName, Map<String, Object> data) {
|
||||||
JudgesNull(tableName, "data can not be null!");
|
JudgesNull(tableName, "data can not be null!");
|
||||||
JudgesNull(data, "tableName can not be null!");
|
JudgesNull(data, "tableName can not be null!");
|
||||||
|
tableName = formatTable(tableName);
|
||||||
String key;
|
String key;
|
||||||
DatasourceConfig datasourceConfig = new DatasourceConfig();
|
DatasourceConfig datasourceConfig = new DatasourceConfig();
|
||||||
try {
|
try {
|
||||||
@@ -132,6 +139,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
private int updateByWhere(Condition condition, String tableName, Map<String, Object> data) {
|
private int updateByWhere(Condition condition, String tableName, Map<String, Object> data) {
|
||||||
Map<String, Object> params = condition.getParamMap();
|
Map<String, Object> params = condition.getParamMap();
|
||||||
|
tableName = formatTable(tableName);
|
||||||
params.put("tableName", tableName);
|
params.put("tableName", tableName);
|
||||||
params.put("info", data);
|
params.put("info", data);
|
||||||
params.put("sql", condition.getSql());
|
params.put("sql", condition.getSql());
|
||||||
@@ -244,6 +252,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
|
|
||||||
private int deleteByWhere(Condition condition, String tableName) {
|
private int deleteByWhere(Condition condition, String tableName) {
|
||||||
Map<String, Object> params = condition.getParamMap();
|
Map<String, Object> params = condition.getParamMap();
|
||||||
|
tableName = formatTable(tableName);
|
||||||
params.put("tableName", tableName);
|
params.put("tableName", tableName);
|
||||||
params.put("sql", condition.getSql());
|
params.put("sql", condition.getSql());
|
||||||
return sqlSessionTemplate.delete(TABLE_MAPPER_PACKAGE + "deleteByWhere", params);
|
return sqlSessionTemplate.delete(TABLE_MAPPER_PACKAGE + "deleteByWhere", params);
|
||||||
@@ -330,6 +339,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> selectAll(String tableName) {
|
public List<Map<String, Object>> selectAll(String tableName) {
|
||||||
JudgesNull(tableName, "tableName can not be null!");
|
JudgesNull(tableName, "tableName can not be null!");
|
||||||
|
tableName = formatTable(tableName);
|
||||||
return tableMapper.useSql(SelectCondition.builder().tableName(tableName).build().getSql());
|
return tableMapper.useSql(SelectCondition.builder().tableName(tableName).build().getSql());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,7 +744,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
if (!key.equals(pkName) && value != null && !(value instanceof String && ((String) value).isEmpty())) {
|
if (!key.equals(pkName) && value != null && !(value instanceof String && ((String) value).isEmpty())) {
|
||||||
sql.append(key).append(" = #{item").append(index).append("_").append(key).append("}, ");
|
sql.append("`").append(key).append("`").append(" = #{item").append(index).append("_").append(key).append("}, ");
|
||||||
paramMap.put("item" + index + "_" + key, value);
|
paramMap.put("item" + index + "_" + key, value);
|
||||||
hasSetClause = true;
|
hasSetClause = true;
|
||||||
}
|
}
|
||||||
@@ -746,7 +756,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
// 如果没有要更新的字段,跳过这条记录
|
// 如果没有要更新的字段,跳过这条记录
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sql.append(" WHERE ").append(pkName).append(" = #{item").append(index).append("_").append(pkName).append("};");
|
sql.append(" WHERE ").append("`").append(pkName).append("`").append(" = #{item").append(index).append("_").append(pkName).append("};");
|
||||||
paramMap.put("item" + index + "_" + pkName, item.get(pkName));
|
paramMap.put("item" + index + "_" + pkName, item.get(pkName));
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@@ -769,7 +779,7 @@ public class BaseMapperImpl implements BaseMapper {
|
|||||||
try {
|
try {
|
||||||
id = tableMapper.getSequence(tableName);
|
id = tableMapper.getSequence(tableName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MyPageHelper.start(WebPageInfo.builder().pageNum(1).pageSize(1).order(WebPageInfo.DESC).sortField(pkName).build());
|
MyPageHelper.noCount(WebPageInfo.builder().pageNum(1).pageSize(1).order(WebPageInfo.DESC).sortField(pkName).build());
|
||||||
DataMap<Object> dataMap = DataMap.builder().tableName(tableName).pkName(pkName).fields(pkName).build();
|
DataMap<Object> dataMap = DataMap.builder().tableName(tableName).pkName(pkName).fields(pkName).build();
|
||||||
Condition condition = Condition.creatCriteria(dataMap).build();
|
Condition condition = Condition.creatCriteria(dataMap).build();
|
||||||
Map<String, Object> map = selectOneByCondition(condition);
|
Map<String, Object> map = selectOneByCondition(condition);
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ public class Condition implements Serializable {
|
|||||||
value = value.toString().replaceAll("\"", "");
|
value = value.toString().replaceAll("\"", "");
|
||||||
}
|
}
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.conditionSql += " " + key + EQUAL + "#{" + sqlKey + "}";
|
this.conditionSql += " `" + key +"` "+ EQUAL + "#{" + sqlKey + "}";
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ public class Condition implements Serializable {
|
|||||||
|
|
||||||
public ConditionBuilder like(String key, Object value) {
|
public ConditionBuilder like(String key, Object value) {
|
||||||
sqlCheckLike(value);
|
sqlCheckLike(value);
|
||||||
this.conditionSql += " " + key + " " + LIKE + " '" + value + "'";
|
this.conditionSql += " `" + key +"` "+ " " + LIKE + " '" + value + "'";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ public class Condition implements Serializable {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
inStr.append(R_CURVES);
|
inStr.append(R_CURVES);
|
||||||
this.conditionSql += " " + key + " " + IN + " " + inStr.toString();
|
this.conditionSql += " `" + key +"` "+ " " + IN + " " + inStr.toString();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ public class Condition implements Serializable {
|
|||||||
String sqlKey2 = "item_" + IdUtil.fastUUID();
|
String sqlKey2 = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, start);
|
this.paramMap.put(sqlKey, start);
|
||||||
this.paramMap.put(sqlKey2, end);
|
this.paramMap.put(sqlKey2, end);
|
||||||
this.conditionSql += " " + key + " " + BETWEEN + " #{" + sqlKey + "} " + AND + " #{" + sqlKey2 + "} ";
|
this.conditionSql += " `" + key +"` "+ " " + BETWEEN + " #{" + sqlKey + "} " + AND + " #{" + sqlKey2 + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ public class Condition implements Serializable {
|
|||||||
public ConditionBuilder lt(String key, Object value) {
|
public ConditionBuilder lt(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, value);
|
||||||
this.conditionSql += " " + key + " " + LT + " #{" + sqlKey + "} ";
|
this.conditionSql += " `" + key +"` "+ " " + LT + " #{" + sqlKey + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ public class Condition implements Serializable {
|
|||||||
public ConditionBuilder notEqual(String key, Object value) {
|
public ConditionBuilder notEqual(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, value);
|
||||||
this.conditionSql += " " + key + " " + NOT_EQUAL + " #{" + sqlKey + "} ";
|
this.conditionSql += " `" + key +"` "+ " " + NOT_EQUAL + " #{" + sqlKey + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ public class Condition implements Serializable {
|
|||||||
public ConditionBuilder gt(String key, Object value) {
|
public ConditionBuilder gt(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, value);
|
||||||
this.conditionSql += " " + key + " " + GT + " #{" + sqlKey + "} ";
|
this.conditionSql += " `" + key +"` "+ " " + GT + " #{" + sqlKey + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +410,7 @@ public class Condition implements Serializable {
|
|||||||
public ConditionBuilder lte(String key, Object value) {
|
public ConditionBuilder lte(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, value);
|
||||||
this.conditionSql += " " + key + " " + LTE + " #{" + value.toString() + "} ";
|
this.conditionSql += " `" + key +"` "+ " " + LTE + " #{" + value.toString() + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ public class Condition implements Serializable {
|
|||||||
public ConditionBuilder gte(String key, Object value) {
|
public ConditionBuilder gte(String key, Object value) {
|
||||||
String sqlKey = "item_" + IdUtil.fastUUID();
|
String sqlKey = "item_" + IdUtil.fastUUID();
|
||||||
this.paramMap.put(sqlKey, value);
|
this.paramMap.put(sqlKey, value);
|
||||||
this.conditionSql += " " + key + " " + GTE + " #{" + value.toString() + "} ";
|
this.conditionSql += " `" + key +"` "+ " " + GTE + " #{" + value.toString() + "} ";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class SelectCondition implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SelectBuilder tableName(String tableName) {
|
public SelectBuilder tableName(String tableName) {
|
||||||
this.tableName = tableName;
|
this.tableName = "`"+tableName+"`";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class DataUnit {
|
|||||||
public static final String MYSQL = "Mysql";
|
public static final String MYSQL = "Mysql";
|
||||||
public static final String ORACLE = "Oracle";
|
public static final String ORACLE = "Oracle";
|
||||||
public static final String DAMENG = "Dameng";
|
public static final String DAMENG = "Dameng";
|
||||||
|
public static final String HANGO= "HanGO";
|
||||||
public static final String MASTERBEAN = "masterDataSource";
|
public static final String MASTERBEAN = "masterDataSource";
|
||||||
public static final String DYNAMICBEAN = "dynamicDataSource";
|
public static final String DYNAMICBEAN = "dynamicDataSource";
|
||||||
public static final String PASSWORD = "******";
|
public static final String PASSWORD = "******";
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package com.taixingyiji.base.module.shiro.service;
|
|||||||
import com.taixingyiji.base.common.ResultVO;
|
import com.taixingyiji.base.common.ResultVO;
|
||||||
import com.taixingyiji.base.common.ServiceException;
|
import com.taixingyiji.base.common.ServiceException;
|
||||||
import com.taixingyiji.base.common.config.FrameConfig;
|
import com.taixingyiji.base.common.config.FrameConfig;
|
||||||
|
import com.taixingyiji.base.module.data.exception.SqlException;
|
||||||
|
import com.taixingyiji.base.module.data.module.BaseMapper;
|
||||||
|
import com.taixingyiji.base.module.data.module.Condition;
|
||||||
import com.taixingyiji.base.module.shiro.dao.FtTokenDao;
|
import com.taixingyiji.base.module.shiro.dao.FtTokenDao;
|
||||||
import com.taixingyiji.base.module.shiro.FtToken;
|
import com.taixingyiji.base.module.shiro.FtToken;
|
||||||
import com.taixingyiji.base.common.utils.TokenProccessor;
|
import com.taixingyiji.base.common.utils.TokenProccessor;
|
||||||
@@ -35,7 +38,8 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
FtTokenDao tokenMapper;
|
FtTokenDao tokenMapper;
|
||||||
|
@Resource
|
||||||
|
BaseMapper baseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
@@ -52,10 +56,11 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
FtToken tokenEntity = new FtToken();
|
FtToken tokenEntity = new FtToken();
|
||||||
|
Map<String, Object> resultEntity = new HashMap<>();
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
// 是否使用redis存入token
|
// 是否使用redis存入token
|
||||||
if (isRedisLogin) {
|
if (isRedisLogin) {
|
||||||
boolean flag = redisUtil.set("session:"+userId, token, EXPIRE / 1000);
|
boolean flag = redisUtil.set("session:" + userId, token, EXPIRE / 1000);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
Map<String, Object> map = new HashMap<>(2);
|
Map<String, Object> map = new HashMap<>(2);
|
||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
@@ -72,25 +77,42 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
throw new ServiceException("登陆失败");
|
throw new ServiceException("登陆失败");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tokenEntity.setUserId(userId);
|
// tokenEntity.setUserId(userId);
|
||||||
//判断是否生成过token
|
//判断是否生成过token
|
||||||
tokenEntity = tokenMapper.selectOne(tokenEntity);
|
Condition condition = Condition.creatCriteria().andEqual("USER_ID", userId).build();
|
||||||
if (tokenEntity == null) {
|
resultEntity = baseMapper.selectOneByCondition("FT_TOKEN", condition);
|
||||||
tokenEntity = new FtToken();
|
if (resultEntity == null || resultEntity.isEmpty()) {
|
||||||
tokenEntity.setTokenId(UUID.randomUUID().toString() + System.currentTimeMillis());
|
resultEntity = new HashMap<>();
|
||||||
tokenEntity.setUserId(userId);
|
resultEntity.put("TOKEN_ID", UUID.randomUUID().toString() + System.currentTimeMillis());
|
||||||
tokenEntity.setToken(token);
|
resultEntity.put("USER_ID", userId);
|
||||||
tokenEntity.setUpdateTime(now);
|
resultEntity.put("TOKEN", token);
|
||||||
tokenEntity.setExpireTime(expireTime);
|
resultEntity.put("UPDATE_TIME", now);
|
||||||
//保存token
|
resultEntity.put("EXPIRE_TIME", expireTime);
|
||||||
tokenMapper.insertSelective(tokenEntity);
|
baseMapper.save("FT_TOKEN", "TOKEN_ID", resultEntity);
|
||||||
} else {
|
} else {
|
||||||
tokenEntity.setToken(token);
|
resultEntity.put("TOKEN", token);
|
||||||
tokenEntity.setUpdateTime(now);
|
resultEntity.put("UPDATE_TIME", now);
|
||||||
tokenEntity.setExpireTime(expireTime);
|
resultEntity.put("EXPIRE_TIME", expireTime);
|
||||||
//更新token
|
int i = baseMapper.updateByPk("FT_TOKEN", "TOKEN_ID", resultEntity);
|
||||||
int i = tokenMapper.updateByPrimaryKey(tokenEntity);
|
SqlException.base(i, "登录失败");
|
||||||
}
|
}
|
||||||
|
// tokenEntity = tokenMapper.selectOne(tokenEntity);
|
||||||
|
// if (tokenEntity == null) {
|
||||||
|
// tokenEntity = new FtToken();
|
||||||
|
// tokenEntity.setTokenId(UUID.randomUUID().toString() + System.currentTimeMillis());
|
||||||
|
// tokenEntity.setUserId(userId);
|
||||||
|
// tokenEntity.setToken(token);
|
||||||
|
// tokenEntity.setUpdateTime(now);
|
||||||
|
// tokenEntity.setExpireTime(expireTime);
|
||||||
|
// //保存token
|
||||||
|
// tokenMapper.insertSelective(tokenEntity);
|
||||||
|
// } else {
|
||||||
|
// tokenEntity.setToken(token);
|
||||||
|
// tokenEntity.setUpdateTime(now);
|
||||||
|
// tokenEntity.setExpireTime(expireTime);
|
||||||
|
// //更新token
|
||||||
|
// int i = tokenMapper.updateByPrimaryKey(tokenEntity);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
//返回token给前端
|
//返回token给前端
|
||||||
result.put("token", token);
|
result.put("token", token);
|
||||||
@@ -104,8 +126,8 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
// Map<Object, Object> map = (Map<Object, Object>) redisUtil.get("tokenSession:"+accessToken);
|
// Map<Object, Object> map = (Map<Object, Object>) redisUtil.get("tokenSession:"+accessToken);
|
||||||
String userId = (String) redisUtil.hget("tokenSession:" + accessToken, "userId");
|
String userId = (String) redisUtil.hget("tokenSession:" + accessToken, "userId");
|
||||||
// String userId = (String) map.get("userId");
|
// String userId = (String) map.get("userId");
|
||||||
redisUtil.del("tokenSession:"+accessToken);
|
redisUtil.del("tokenSession:" + accessToken);
|
||||||
redisUtil.del("session:"+userId);
|
redisUtil.del("session:" + userId);
|
||||||
return ResultVO.getSuccess();
|
return ResultVO.getSuccess();
|
||||||
} else {
|
} else {
|
||||||
//生成一个token
|
//生成一个token
|
||||||
@@ -113,11 +135,15 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
//生成一个token
|
//生成一个token
|
||||||
String token = tokenProccessor.makeToken();
|
String token = tokenProccessor.makeToken();
|
||||||
//修改token
|
//修改token
|
||||||
FtToken tokenEntity = new FtToken();
|
// FtToken tokenEntity = new FtToken();
|
||||||
tokenEntity.setToken(token);
|
// tokenEntity.setToken(token);
|
||||||
Example example = new Example(FtToken.class);
|
// Example example = new Example(FtToken.class);
|
||||||
example.createCriteria().andEqualTo("token", accessToken);
|
// example.createCriteria().andEqualTo("token", accessToken);
|
||||||
int i = tokenMapper.updateByExampleSelective(tokenEntity, example);
|
// int i = tokenMapper.updateByExampleSelective(tokenEntity, example);
|
||||||
|
Map<String, Object> resultEntity = new HashMap<>();
|
||||||
|
resultEntity.put("TOKEN", token);
|
||||||
|
Condition condition = Condition.creatCriteria().andEqual("TOKEN", accessToken).build();
|
||||||
|
int i = baseMapper.updateByCondition("FT_TOKEN", resultEntity, condition);
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
return ResultVO.getSuccess();
|
return ResultVO.getSuccess();
|
||||||
} else {
|
} else {
|
||||||
@@ -129,8 +155,15 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
@Override
|
@Override
|
||||||
public FtToken findByToken(String accessToken) {
|
public FtToken findByToken(String accessToken) {
|
||||||
FtToken osToken = new FtToken();
|
FtToken osToken = new FtToken();
|
||||||
osToken.setToken(accessToken);
|
// osToken.setToken(accessToken);
|
||||||
return tokenMapper.selectOne(osToken);
|
Condition condition = Condition.creatCriteria().equal("TOKEN", accessToken).build();
|
||||||
|
Map<String, Object> map = baseMapper.selectOneByCondition("FT_TOKEN", condition);
|
||||||
|
osToken.setToken((String) map.get("TOKEN"));
|
||||||
|
osToken.setTokenId((String) map.get("TOKEN_ID"));
|
||||||
|
osToken.setUserId((String) map.get("USER_ID"));
|
||||||
|
osToken.setExpireTime((Date) map.get("EXPIRE_TIME"));
|
||||||
|
osToken.setUpdateTime((Date) map.get("UPDATE_TIME"));
|
||||||
|
return osToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user