Commit a8bdc354 authored by 贷前—徐菲's avatar 贷前—徐菲

用户微信禁用

parent 6e6d8c7f
...@@ -92,4 +92,6 @@ public interface Constants { ...@@ -92,4 +92,6 @@ public interface Constants {
String BINDCARD_SMS = "用户您好,您已绑卡成功,将会在1-5个工作日内收到借款,请耐心等待。如有疑问,请致电400-002-0061,感谢您对我们的支持";//绑卡成功后的短信文案 String BINDCARD_SMS = "用户您好,您已绑卡成功,将会在1-5个工作日内收到借款,请耐心等待。如有疑问,请致电400-002-0061,感谢您对我们的支持";//绑卡成功后的短信文案
String REPAY_SMS = "用户您好,您在信用钱包的本期账单已还款成功,保持良好的信用可升级为VIP用户,享更多特权,感谢您对信用钱包的支持"; String REPAY_SMS = "用户您好,您在信用钱包的本期账单已还款成功,保持良好的信用可升级为VIP用户,享更多特权,感谢您对信用钱包的支持";
} }
String aesKey = "ScnmRBhuQpo9kBdn";
} }
package cn.quantgroup.xyqb.controller.external.user; package cn.quantgroup.xyqb.controller.external.user;
import cn.quantgroup.user.enums.Relation; import cn.quantgroup.user.enums.Relation;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.limit.PasswordFreeAccessValidator; import cn.quantgroup.xyqb.aspect.limit.PasswordFreeAccessValidator;
import cn.quantgroup.xyqb.aspect.logcaller.LogHttpCaller; import cn.quantgroup.xyqb.aspect.logcaller.LogHttpCaller;
import cn.quantgroup.xyqb.controller.IBaseController; import cn.quantgroup.xyqb.controller.IBaseController;
...@@ -13,6 +14,7 @@ import cn.quantgroup.xyqb.service.http.IHttpService; ...@@ -13,6 +14,7 @@ import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.user.*; import cn.quantgroup.xyqb.service.user.*;
import cn.quantgroup.xyqb.service.wechat.IWechatService; import cn.quantgroup.xyqb.service.wechat.IWechatService;
import cn.quantgroup.xyqb.util.AESUtil;
import cn.quantgroup.xyqb.util.IPUtil; import cn.quantgroup.xyqb.util.IPUtil;
import cn.quantgroup.xyqb.util.MqUtils; import cn.quantgroup.xyqb.util.MqUtils;
import cn.quantgroup.xyqb.util.ValidationUtil; import cn.quantgroup.xyqb.util.ValidationUtil;
...@@ -954,4 +956,24 @@ public class InnerController implements IBaseController { ...@@ -954,4 +956,24 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult(null, userList); return JsonResult.buildSuccessResult(null, userList);
} }
@RequestMapping("/forbiddenUserWeChat")
public JsonResult forbiddenUserWeChat(@RequestParam Long userId, @RequestParam String reason,@RequestParam String content,
HttpServletRequest request) {
LOGGER.info("请求的ip:IPUtil.getRemoteIP(request):{}", IPUtil.getRemoteIP(request));
if (null!=content){
content=content.replace(" ","+");
}
LOGGER.info(content);
String str= AESUtil.decryptAfterBase64Decode(content, Constants.aesKey);
if (null==str ||!str.equals(userId.toString())){
return JsonResult.buildErrorStateResult("参数有误", null);
}
if (null == userId || userId <= 0 || StringUtils.isEmpty(reason)) {
return JsonResult.buildErrorStateResult("参数有误", null);
}
wechatService.forbiddenUserWeChat(userId);
return JsonResult.buildSuccessResult("用户禁用微信成功", null);
}
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package cn.quantgroup.xyqb.repository; ...@@ -3,6 +3,8 @@ package cn.quantgroup.xyqb.repository;
import cn.quantgroup.xyqb.entity.WechatUserInfo; import cn.quantgroup.xyqb.entity.WechatUserInfo;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Created by 11 on 2017/1/18. * Created by 11 on 2017/1/18.
...@@ -13,4 +15,8 @@ public interface IWeChatUserRepository extends JpaRepository<WechatUserInfo, Lon ...@@ -13,4 +15,8 @@ public interface IWeChatUserRepository extends JpaRepository<WechatUserInfo, Lon
WechatUserInfo findByPhoneNo(String phoneNo); WechatUserInfo findByPhoneNo(String phoneNo);
WechatUserInfo findByUserId(Long userId); WechatUserInfo findByUserId(Long userId);
@Transactional
@Modifying
void removeByUserId(Long userId);
} }
...@@ -18,4 +18,6 @@ public interface IWechatService { ...@@ -18,4 +18,6 @@ public interface IWechatService {
WechatUserInfo saveWechatUserInfo(WechatUserInfo userInfo); WechatUserInfo saveWechatUserInfo(WechatUserInfo userInfo);
WechatUserInfo queryOpenIdByUserId(Long userId); WechatUserInfo queryOpenIdByUserId(Long userId);
void forbiddenUserWeChat(Long userId);
} }
...@@ -138,4 +138,10 @@ public class WechatServiceImpl implements IWechatService { ...@@ -138,4 +138,10 @@ public class WechatServiceImpl implements IWechatService {
public WechatUserInfo queryOpenIdByUserId(Long userId) { public WechatUserInfo queryOpenIdByUserId(Long userId) {
return weChatUserRepository.findByUserId(userId); return weChatUserRepository.findByUserId(userId);
} }
@Override
public void forbiddenUserWeChat(Long userId) {
weChatUserRepository.removeByUserId(userId);
}
} }
package cn.quantgroup.xyqb.util;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
/**
* AES编码器工具
* 使用AES加密解密 AES-128-ECB加密
* @version 1.0
*/
public class AESUtil {
/**
* KEY算法
*/
private static final String KEY_ALGORITHM = "AES";
/**
* 加密算法
* "/算法/模式/补码方式"
*/
private static final String CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
/**
* 编码格式
*/
private static final String data_encoding = "utf-8";
/**
* 数据加密
* @param data 待加密的数据
* @param key 加密使用的KEY
* @return 加密之后的数据
*/
public static String encryptAndBase64Encode(String data, String key) {
try {
return encryptAndBase64Encode(data.getBytes(data_encoding), key);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 对字节数组加密
* @param data
* @param key
* @return
*/
public static String encryptAndBase64Encode(byte[] data, String key) {
try {
if (key == null || "".equals(key.trim().length())) {
return null;
}
byte[] raw = key.getBytes(data_encoding);
SecretKeySpec skeySpec = new SecretKeySpec(raw, KEY_ALGORITHM);
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(data);
return new Base64().encodeToString(encrypted);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 数据解密,返回字符串
* @param data 待解密的数据
* @param key 解密使用的KEY
* @return 解密之后的数据
*/
public static String decryptAfterBase64Decode(String data, String key) {
try {
byte[] bytes = decryptAfterBase64DecodeToByte(data, key);
if (bytes != null && bytes.length > 0){
return new String(bytes, data_encoding);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 数据解密,返回字节数据
* @param data
* @param key
* @return
*/
public static byte[] decryptAfterBase64DecodeToByte(String data, String key) {
try {
if (key == null || "".equals(key.trim().length())) {
return null;
}
byte[] raw = key.getBytes(data_encoding);
SecretKeySpec skeySpec = new SecretKeySpec(raw, KEY_ALGORITHM);
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] encrypted1 = new Base64().decode(data);
byte[] original = cipher.doFinal(encrypted1);
return original;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
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