Add:对极客商服提供查询商户详情API

master
duLingLing 5 years ago
parent ca6b6dbe24
commit f5b6fe34ff

@ -0,0 +1,52 @@
package au.com.royalpay.payment.manage.appclient.beans;
import au.com.royalpay.payment.manage.permission.utils.GeekLoginDESUtil;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import javax.validation.constraints.NotEmpty;
/**
* Created by yixian on 2016-12-14.
*/
public class ApiClientAccountLoginInfo {
@NotEmpty(message = "error.payment.valid.param_missing")
private String loginId;
@NotEmpty(message = "error.payment.valid.param_missing")
private String password;
public LoginInfo ClientAccountLoginInfo(){
LoginInfo info = new LoginInfo();
info.setLoginId(loginId);
info.setPassword(GeekLoginDESUtil.getDecryptString(password));
return info;
}
public String getPasswordHashed(String salt) {
return PasswordUtils.hashPwd(password, salt);
}
public String getLoginId() {
return loginId.toLowerCase();
}
public void setLoginId(String loginId) {
this.loginId = loginId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "ApiClientAccountLoginInfo{" +
"loginId='" + loginId + '\'' +
", password='" + password + '\'' +
'}';
}
}

@ -0,0 +1,80 @@
package au.com.royalpay.payment.manage.appclient.web;
import au.com.royalpay.payment.manage.appclient.beans.ApiClientAccountLoginInfo;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.manage.signin.events.ClientLoginEvent;
import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import au.com.royalpay.payment.manage.permission.utils.GeekLoginDESUtil;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* @Author DuLingLing
* @create 2019/11/27 0027 14:30
*/
@RestController
@RequestMapping("/api/v1.0/royalpay/client")
public class RetailClientController implements ApplicationEventPublisherAware {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private SignInStatusManager signInStatusManager;
@Resource
private ClientManager clientManager;
private ApplicationEventPublisher publisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
@PostMapping("/sigIn")
public JSONObject signIn(@RequestBody @Valid ApiClientAccountLoginInfo loginInfo) {
try {
String signKey = signInStatusManager.partnerSignIn(loginInfo.ClientAccountLoginInfo());
JSONObject account = signInStatusManager.getCurrentClient(signKey);
JSONObject clientAllInfo = clientManager.getClientInfo(account.getInteger("client_id"));
publisher.publishEvent(
new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "GEEK_PASSWORD"));
return convertResponseClientInfo(clientAllInfo);
} catch (BadRequestException be) {
return responseError(be.getMessage());
} catch (Exception e) {
return responseError(e.getMessage());
}
}
private JSONObject convertResponseClientInfo(JSONObject clientAllInfo) {
JSONObject response = new JSONObject();
response.put("status", "SUCCESS");
JSONObject industryInfo = clientManager.findByLookupCode(clientAllInfo.getString("industry"));
response.put("clientInfo", new JSONObject() {{
put("client_moniker", clientAllInfo.getString("client_moniker"));
put("company_name", clientAllInfo.getString("company_name"));
put("logo_url", clientAllInfo.getString("client_moniker"));
put("credential_code", clientAllInfo.getString("credential_code"));
put("industry_code", clientAllInfo.getString("industry"));
put("industry_label", industryInfo.getString("lookup_value"));
}});
return response;
}
private JSONObject responseError(String message) {
JSONObject response = new JSONObject();
response.put("status", "FAIL");
response.put("message", message);
return response;
}
}

@ -0,0 +1,18 @@
package au.com.royalpay.payment.manage.mappers.system;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
/**
* @Author DuLingLing
* @create 2019/11/27 0027 16:20
*/
@AutoMapper(tablename = "industry_lookup", pkName = "client_id", keyGenerator = Jdbc3KeyGenerator.class)
public interface IndustryLookupMapper {
@AutoSql(type = SqlType.SELECT)
JSONObject findByLookupCode(@Param("lookup_code") String code);
}

@ -515,4 +515,6 @@ public interface ClientManager {
*/ */
JSONObject partnerIncrementalServiceInfo(String clientMoniker, String incrementalId); JSONObject partnerIncrementalServiceInfo(String clientMoniker, String incrementalId);
JSONObject findByLookupCode(String code);
} }

@ -302,6 +302,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Resource @Resource
private ClientComplianceCompanyMapper clientComplianceCompanyMapper; private ClientComplianceCompanyMapper clientComplianceCompanyMapper;
@Resource
private IndustryLookupMapper industryLookupMapper;
@Resource @Resource
@ -6136,4 +6138,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientIncrementalMapper.update(existIncrementalService); clientIncrementalMapper.update(existIncrementalService);
} }
@Override
public JSONObject findByLookupCode(String code){
JSONObject industryInfo = industryLookupMapper.findByLookupCode(code);
if(industryInfo==null){
return new JSONObject(){{
put("lookup_code","未知行业");
}};
}
return industryInfo;
}
} }

@ -0,0 +1,94 @@
package au.com.royalpay.payment.manage.permission.utils;
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* @Author DuLingLing
* @create 2019/11/27 0027 18:32
*/
public class GeekLoginDESUtil {
private static final Logger logger = LoggerFactory.getLogger(GeekLoginDESUtil.class);
private static Key key;
//设置秘钥key
private static String KEY_STR="myKey";
private static String CHARSETNAME="UTF-8";
private static String ALGORITHM="DES";
static{
try{
//生成DES算法对象
KeyGenerator generator=KeyGenerator.getInstance(ALGORITHM);
//运用SHA1安全策略
SecureRandom secureRandom=SecureRandom.getInstance("SHA1PRNG");
//设置上密钥种子
secureRandom.setSeed(KEY_STR.getBytes());
//初始化基于SHA1的算法对象
generator.init(secureRandom);
//生成密钥对象
key=generator.generateKey();
generator=null;
}catch(Exception e){
throw new RuntimeException(e);
}
}
/**
*
* @param str
* @return
*/
public static String getEncryptString(String str){
//基于BASE64编码接收byte[]并转换成String
BASE64Encoder base64Encoder=new BASE64Encoder();
try {
// 按UTF8编码
byte[] bytes = str.getBytes(CHARSETNAME);
// 获取加密对象
Cipher cipher = Cipher.getInstance(ALGORITHM);
// 初始化密码信息
cipher.init(Cipher.ENCRYPT_MODE, key);
// 加密
byte[] doFinal = cipher.doFinal(bytes);
// byte[]to encode好的String并返回
return base64Encoder.encode(doFinal);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
*
*
* @param str
* @return
*/
public static String getDecryptString(String str) {
// 基于BASE64编码接收byte[]并转换成String
BASE64Decoder base64decoder = new BASE64Decoder();
try {
// 将字符串decode成byte[]
byte[] bytes = base64decoder.decodeBuffer(str);
// 获取解密对象
Cipher cipher = Cipher.getInstance(ALGORITHM);
// 初始化解密信息
cipher.init(Cipher.DECRYPT_MODE, key);
// 解密
byte[] doFinal = cipher.doFinal(bytes);
// 返回解密之后的信息
return new String(doFinal, CHARSETNAME);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Loading…
Cancel
Save