parent
5c71aca459
commit
c6ae1eb828
@ -0,0 +1,43 @@
|
||||
package com.xit.core.oauth2.api.dao;
|
||||
|
||||
import com.xit.core.oauth2.api.entity.RefreshToken;
|
||||
import com.xit.core.util.DBUtils;
|
||||
import com.xit.core.util.mpower.MpowerUtils;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class RefreshTokenDao {
|
||||
private static final String sqlXmlFile = "sql/refreshToken-mapper";
|
||||
|
||||
public Optional<RefreshToken> findByKey(String key){
|
||||
String sql = DBUtils.getXmlSql(sqlXmlFile, "selectRefreshToken");
|
||||
sql = sql.replaceFirst(":userId", key);
|
||||
|
||||
MpowerUtils sendXml = new MpowerUtils();
|
||||
sendXml.setFeilds("key, value");
|
||||
sendXml.setQuery(sql);
|
||||
return Optional.ofNullable(sendXml.selectCustomQuery(RefreshToken.class).get(0));
|
||||
}
|
||||
|
||||
public void save(RefreshToken refreshToken){
|
||||
String sql = DBUtils.getXmlSql(sqlXmlFile, "saveRefreshToken");
|
||||
sql = sql.replaceFirst(":userId", refreshToken.getKey());
|
||||
sql = sql.replaceFirst(":tokenValue", refreshToken.getValue());
|
||||
|
||||
MpowerUtils sendXml = new MpowerUtils();
|
||||
//sendXml.setFeilds("key, value");
|
||||
//sendXml.setQuery(sql);
|
||||
//return Optional.ofNullable(sendXml.selectCustomQuery(RefreshToken.class).get(0));
|
||||
}
|
||||
|
||||
public void update(RefreshToken refreshToken){
|
||||
String sql = DBUtils.getXmlSql(sqlXmlFile, "updateRefreshToken");
|
||||
sql = sql.replaceFirst(":userId", refreshToken.getKey());
|
||||
sql = sql.replaceFirst(":tokenValue", refreshToken.getValue());
|
||||
|
||||
MpowerUtils sendXml = new MpowerUtils();
|
||||
//sendXml.setFeilds("key, value");
|
||||
//sendXml.setQuery(sql);
|
||||
//return Optional.ofNullable(sendXml.selectCustomQuery(RefreshToken.class).get(0));
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<sqlMapper>
|
||||
<selectRefreshToken>
|
||||
/* refreshToken-mapper|selectRefreshToken|julim */
|
||||
SELECT key,
|
||||
value
|
||||
FROM refresh_token
|
||||
WHERE key = :userId
|
||||
</selectRefreshToken>
|
||||
|
||||
<updateRefreshToken>
|
||||
/* refreshToken-mapper|insertRefreshToken|julim */
|
||||
INSERT
|
||||
INTO refresh_token (
|
||||
key,
|
||||
value
|
||||
) VALUE (
|
||||
:userId,
|
||||
:tokenValue
|
||||
)
|
||||
</updateRefreshToken>
|
||||
|
||||
<updateRefreshToken>
|
||||
/* refreshToken-mapper|updateRefreshToken|julim */
|
||||
UPDATE refresh_token
|
||||
SET value = :tokenValue
|
||||
WHERE key = :userId
|
||||
</updateRefreshToken>
|
||||
|
||||
</sqlMapper>
|
Loading…
Reference in New Issue