Commit 2f9f5dc1 authored by 王亮's avatar 王亮

remove unused code(LKB push)

parent 15c41b2d
package cn.quantgroup.xyqb.event;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.exception.PushUserToLkbException;
import cn.quantgroup.xyqb.model.UserRegisterParam;
import cn.quantgroup.xyqb.service.user.ILkbUserService;
import cn.quantgroup.xyqb.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
/**
* 注册成功之后lkb
*
* @author ag
*/
@Slf4j
//@Component
public class LkbRegisteredEventListener implements ApplicationListener<RegisterEvent> {
@Autowired
private ILkbUserService lkbUserService;
//todo 这里重试机制补齐
@Override
public void onApplicationEvent(RegisterEvent event) {
UserRegisterParam userRegisterParam = event.getUserRegisterParam();
User user = userRegisterParam.getUser();
String uuid = user.getUuid();
boolean pushResult = lkbUserService.pushUser(uuid, userRegisterParam.getPhoneNo(),
userRegisterParam.getName());
if (!pushResult) {
log.error("[userRegisterHandler][baseUserRegisterHandler]同步用户至Lkb出错,userRegisterParam:{}", JsonUtil.toJson(userRegisterParam));
throw new PushUserToLkbException("同步用户至Lkb出错");
}
}
}
package cn.quantgroup.xyqb.service.user;
/**
* @author mengfan.feng
* @time 2015-08-19 17:44
*/
public interface ILkbUserService {
/**
* 同步用戶信息
*
* @param uuid
* @param phoneNo
* @param name
*/
boolean pushUser(String uuid, String phoneNo, String name);
}
package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.user.ILkbUserService;
import cn.quantgroup.xyqb.util.JsonUtil;
import cn.quantgroup.xyqb.util.PasswordUtil;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Optional;
/**
* @author mengfan.feng
* @time 2015-08-19 18:20
*/
@Service
@Slf4j
public class LkbUserviceImpl implements ILkbUserService {
private static final String TOKEN_PATTERN = "timeunit=%sappkey=lkb010203#$%%";
private static final String LKB_CODE = "0002";
@Autowired
private IHttpService httpService;
@Value("${lkb.client.url}")
private String clientUrl;
@Override
public boolean pushUser(String uuid, String phoneNo, String name) {
String timeunit = System.currentTimeMillis() + "";
String token = PasswordUtil.MD5(String.format(TOKEN_PATTERN, timeunit));
Map<String, String> parameters = Maps.newHashMap();
parameters.put("appId", LKB_CODE);
parameters.put("timeunit", timeunit);
parameters.put("token", token);
parameters.put("userId", uuid);
parameters.put("loginName", phoneNo);
if (StringUtils.isNotBlank(name)) {
parameters.put("realName", name);
}
String response = httpService.post(clientUrl + "/user/push.json", parameters);
Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class);
if (!resultOptional.isPresent() || !Constants.SUCCESS_CODE.equals(resultOptional.get().get(Constants.RESULT_CODE))) {
log.error("[lkb_user_push]向LKB同步用户失败,phoneNo:{},response={}", phoneNo, response);
return false;
}
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment