SysSettlementConfigServiceImpl.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.crm.settlement.service.impl;
  2. import com.alibaba.fastjson2.JSON;
  3. import com.crm.rely.backend.core.constant.Constants;
  4. import com.crm.rely.backend.core.exception.ServiceException;
  5. import com.crm.rely.backend.model.pojo.table.SysSettlementConfigTable;
  6. import com.crm.rely.backend.service.RedisService;
  7. import com.crm.rely.backend.util.AESUtil;
  8. import com.crm.settlement.dao.repository.SysSettlementConfigRepository;
  9. import com.crm.settlement.service.SysConfigService;
  10. import com.crm.settlement.service.SysSettlementConfigService;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. @Service
  15. public class SysSettlementConfigServiceImpl implements SysSettlementConfigService {
  16. @Autowired
  17. private SysSettlementConfigRepository sysSettlementConfigRepository;
  18. @Autowired
  19. private RedisService redisService;
  20. @Autowired
  21. private SysConfigService sysConfigService;
  22. @Override
  23. public SysSettlementConfigTable getByCode(String code){
  24. SysSettlementConfigTable cacheEntity = redisService.getEntity(code, SysSettlementConfigTable.class);
  25. SysSettlementConfigTable configTable;
  26. if (cacheEntity == null || StringUtils.isEmpty(cacheEntity.getValue())) {
  27. configTable = sysSettlementConfigRepository.getByCode(code);
  28. if (configTable == null) {
  29. throw ServiceException.exception(Constants.INFO_NOT_FOUND);
  30. } else {
  31. redisService.save(code, configTable, 24 * 60 * 60 * 1000);
  32. }
  33. } else {
  34. configTable = cacheEntity;
  35. }
  36. SysSettlementConfigTable resultTable = JSON.parseObject(JSON.toJSONString(configTable), SysSettlementConfigTable.class);
  37. String aesKey = sysConfigService.getPropertyKey();
  38. String property = AESUtil.decrypt(configTable.getValue(), aesKey);
  39. resultTable.setValue(property);
  40. return resultTable;
  41. }
  42. public static void main(String[] args) {
  43. String s = "xt4mA5tZi/4TcVck+5OPVL5to4cYAuqFtTJoyCVKl5elPCKNPYu+dGSNJOwAAqhc2SKBM0k9oxrGZJUxiNwnthSFoFAFQFP0bnWNR4E9oFZJv3xKhC8YlRWx3zd3Eed0L/Sxjm5u2vxgSLALJFxkHAxBc0GWjzcqtEIF1NRTMzMin9cV701GK6K6H9I/QbhMhQUIVh8ygcrR+wsxS2nYt6VF9GCviq4hSIXhmaSlAwrIVtvGjHST9VWdy5HsNFZHCfuSideRej3m9KE3Mz3Got7sig/dbhJ0Oj8Snl7MSLzo0Hz32+pS2vi11Uhbp9B36n1IayH9SH6BRqevJtqPvzJnDwsJN2dg8/VQulqbeFJ5bXpjFR+g808cFJzB8snVN8+LRE95PxrfPKUyzWOETgmCvGUAsKb0ixG6JFDzLa7jibXAehbVHD/tISZH6vLI71HxoSHlSE94IiAEuM9gLBCNPJVR1NaO34aKw+Yb93655YQe3A6Z5GhEiqwDMwhjzqAJaZ2qGp2OcAOJfwepb8KtiMVTKj+CBF1HXdTaI2wUgKwLYtQvWw9nYl+3RFHVTtgdD5QcHYBBeaSyuSb4D2s5nCuVmge8xH9Iz0FIWY7AI6RY7QlOGsRyuFFPI+89uZkLHcIJi3Q9itpkKfXXW4KO5YJl9mptWVhXC331KtO5lkhLSKS9jGcY3XnWjZ5Xra9z04q/MNVMRElHkSFWdwFoWkYQQYngih14Ody8IdhwMUdi81wT8c11Bq649xWqKetY7N6J4ndcNuQ8bHdNEz0kmMAGVd9NLHWpI/8lL+AAYyVDcFJaPOuBOQJZ9iHB/W7pjacAi/95lDrZWyD0tjPgReXp31efgfCnA8gR/Us=";
  44. System.out.println(AESUtil.decrypt(s, "bfa5559109f94c78af615bcf00d52060"));
  45. String ss = "{\n" +
  46. " \"privateKey\": \"MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAprqtYRwj0Aw5WPEVF8xUov5/dFb48OnNRuVfBBA+itIwEOsnNsA5cUo+uMC03/WJfuFjMDiYMQ9dgfExrtSYmwIDAQABAkA2RViPXh4IKBp4qYzAoNnB7o5lO7QvkyMnGx1pELKS896CztGxeJ6oLtdIs2KE26mzxsAroFFCICna7rGtBWydAiEAzutOVTbjjSyYYlQRsqu1607ySnn/v/c5kcBRlHqj3QUCIQDORu2MJbIbEKYVNYH8eJCja5CbAJtq+W331TnFUymRHwIhALJj0UvMH5AVk2aqXfuw6AzvKholZeVlSd+rc2nT9bPVAiEAkOkTCFmS/aB8jHnCj3LDaYqvU7Theg0wS+LnatA5a1ECIQCEKe4vVViJqs4nXFvNM1I6zqw7KJUawtnjO3OGcL4NuQ==\",\n" +
  47. " \"merchantPublicKey\": \"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKntL8BowACv+Yhe4PCCG61GR+bVxZuNhVYQs6M+gIYe0orac+7abhTy88NA7DOsQpodEwgEOHlGOGyfoV4uXDECAwEAAQ==\"\n" +
  48. "}";
  49. System.out.println(AESUtil.encrypt(ss, "bfa5559109f94c78af615bcf00d52060"));
  50. }
  51. }