18 changed files with 411 additions and 30 deletions
-
1src/main/java/com/example/demo/DemoApplication.java
-
100src/main/java/com/example/demo/Util/BaseDES2.java
-
10src/main/java/com/example/demo/config/Mysql1DataSourceConfig.java
-
10src/main/java/com/example/demo/config/Mysql2DataSourceConfig.java
-
46src/main/java/com/example/demo/config/Mysql3DataSourceConfig.java
-
33src/main/java/com/example/demo/controller/DouController.java
-
2src/main/java/com/example/demo/domain/dou/Member.java
-
31src/main/java/com/example/demo/domain/dou/Pay.java
-
2src/main/java/com/example/demo/domain/vo/Page.java
-
2src/main/java/com/example/demo/domain/vo/RechargeVo.java
-
2src/main/java/com/example/demo/mapperLink/DouMapper.java
-
13src/main/java/com/example/demo/mapperPay/PayMapper.java
-
93src/main/java/com/example/demo/serviceImpl/DouServiceImpl.java
-
8src/main/java/com/example/demo/sevice/DouService.java
-
15src/main/resources/application.yml
-
6src/main/resources/mapper/RechargeMapper.xml
-
20src/main/resources/mapperLink/DouMapper.xml
-
37src/main/resources/mapperPay/PayMapper.xml
@ -0,0 +1,100 @@ |
|||
package com.example.demo.Util; |
|||
|
|||
|
|||
import javax.crypto.Cipher; |
|||
import java.security.Key; |
|||
|
|||
|
|||
public class BaseDES2 { |
|||
private static String strDefaultKey = "gold20@)"; |
|||
|
|||
private Cipher encryptCipher = null; |
|||
|
|||
private Cipher decryptCipher = null; |
|||
|
|||
public static String byteArr2HexStr(byte[] arrB) throws Exception { |
|||
int iLen = arrB.length; |
|||
|
|||
StringBuffer sb = new StringBuffer(iLen * 2); |
|||
for (int i = 0; i < iLen; i++) { |
|||
int intTmp = arrB[i]; |
|||
|
|||
while (intTmp < 0) { |
|||
intTmp = intTmp + 256; |
|||
} |
|||
|
|||
if (intTmp < 16) { |
|||
sb.append("0"); |
|||
} |
|||
sb.append(Integer.toString(intTmp, 16)); |
|||
} |
|||
return sb.toString(); |
|||
} |
|||
|
|||
public static byte[] hexStr2ByteArr(String strIn) { |
|||
byte[] arrB = strIn.getBytes(); |
|||
int iLen = arrB.length; |
|||
|
|||
byte[] arrOut = new byte[iLen / 2]; |
|||
for (int i = 0; i < iLen; i = i + 2) { |
|||
String strTmp = new String(arrB, i, 2); |
|||
arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16); |
|||
} |
|||
return arrOut; |
|||
} |
|||
|
|||
public BaseDES2() throws Exception { |
|||
this(strDefaultKey); |
|||
} |
|||
|
|||
public BaseDES2(String strKey) throws Exception { |
|||
|
|||
Key key = getKey(strKey.getBytes()); |
|||
|
|||
encryptCipher = Cipher.getInstance("DES"); |
|||
encryptCipher.init(Cipher.ENCRYPT_MODE, key); |
|||
|
|||
decryptCipher = Cipher.getInstance("DES"); |
|||
decryptCipher.init(Cipher.DECRYPT_MODE, key); |
|||
} |
|||
|
|||
public byte[] encrypt(byte[] arrB) throws Exception { |
|||
return encryptCipher.doFinal(arrB); |
|||
} |
|||
|
|||
public String encrypt(String strIn) throws Exception { |
|||
return byteArr2HexStr(encrypt(strIn.getBytes())); |
|||
} |
|||
|
|||
public byte[] decrypt(byte[] arrB) throws Exception { |
|||
return decryptCipher.doFinal(arrB); |
|||
} |
|||
|
|||
public String decrypt(String strIn) throws Exception { |
|||
return new String(decrypt(hexStr2ByteArr(strIn))); |
|||
} |
|||
|
|||
private Key getKey(byte[] arrBTmp) { |
|||
|
|||
byte[] arrB = new byte[8]; |
|||
|
|||
for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) { |
|||
arrB[i] = arrBTmp[i]; |
|||
} |
|||
|
|||
Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES"); |
|||
|
|||
return key; |
|||
} |
|||
|
|||
|
|||
public static void main(String args[]) { |
|||
try { |
|||
BaseDES2 d = new BaseDES2(); |
|||
String encryptedText = d.encrypt("30003761"); |
|||
System.out.println("加密结果:" + encryptedText); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.example.demo.config; |
|||
|
|||
import com.zaxxer.hikari.HikariDataSource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.ibatis.session.SqlSessionFactory; |
|||
import org.mybatis.spring.SqlSessionFactoryBean; |
|||
import org.mybatis.spring.SqlSessionTemplate; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.boot.jdbc.DataSourceBuilder; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Slf4j |
|||
@Configuration |
|||
public class Mysql3DataSourceConfig { |
|||
|
|||
@Bean(name = "mysql3DataSource") |
|||
@ConfigurationProperties(prefix = "spring.datasource.mysql3") |
|||
public DataSource mysql3DataSource() { |
|||
return DataSourceBuilder.create().type(HikariDataSource.class).build(); |
|||
} |
|||
@Bean(name = "mysql3SqlSessionFactory") |
|||
public SqlSessionFactory mysql3SqlSessionFactory(@Qualifier("mysql3DataSource") DataSource dataSource, |
|||
@Qualifier("globalConfiguration3") org.apache.ibatis.session.Configuration globalConfiguration3) throws Exception { |
|||
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); |
|||
sessionFactory.setDataSource(dataSource); |
|||
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapperPay/*.xml")); |
|||
sessionFactory.setConfiguration(globalConfiguration3); |
|||
return sessionFactory.getObject(); |
|||
} |
|||
|
|||
@Bean(name = "mysql3SqlSessionTemplate") |
|||
public SqlSessionTemplate mysql3SqlSessionTemplate(@Qualifier("mysql3SqlSessionFactory") SqlSessionFactory sqlSessionFactory) { |
|||
return new SqlSessionTemplate(sqlSessionFactory); |
|||
} |
|||
@Bean |
|||
@ConfigurationProperties(prefix = "mybatis.configuration.mysql3") |
|||
public org.apache.ibatis.session.Configuration globalConfiguration3() { |
|||
return new org.apache.ibatis.session.Configuration(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.example.demo.domain.dou; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class Pay { |
|||
private String token; |
|||
private Integer jwcode; |
|||
private String OrderNo; |
|||
private String type; |
|||
private String merchantId; |
|||
private BigDecimal price; |
|||
private Integer count; |
|||
private Integer payStyle; |
|||
private Integer state; |
|||
private Integer platfrom; |
|||
private Integer successTime; |
|||
private String name; |
|||
private String deptName; |
|||
private String shopName; |
|||
private Date startTime; |
|||
private Date endTime; |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.example.demo.mapperPay; |
|||
|
|||
import com.example.demo.domain.dou.Pay; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface PayMapper { |
|||
List<Pay> getPay(Pay pay); |
|||
List<String> getPayIp(); |
|||
List<String> getStyle(); |
|||
} |
@ -0,0 +1,37 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.example.demo.mapperPay.PayMapper"> |
|||
<select id="getPay" resultType="com.example.demo.domain.dou.Pay"> |
|||
SELECT go.jwcode,mi.name,mi.deptName,mi.shopName,go.type,go.order_no,go.price,go.count,gps.`name`,go.success_time from g_order as go |
|||
LEFT JOIN member_info as mi on go.jwcode = mi.jwcode |
|||
LEFT JOIN g_pay_style gps on go.pay_style=gps.id |
|||
<where> |
|||
<if test="jwcode != null and jwcode.length > 0"> |
|||
go.jwcode = #{jwcode} |
|||
</if> |
|||
<if test="orderNo != null and orderNo.length > 0"> |
|||
go.order_no = #{orderNo} |
|||
</if> |
|||
<if test="type != null and type.length > 0"> |
|||
go.type = #{type} |
|||
</if> |
|||
<if test="payStyle != null and payStyle.length > 0"> |
|||
go.pay_style = #{payStyle} |
|||
</if> |
|||
<if test="deptName !=null and deptName.length > 0"> |
|||
mi.deptName = #{deptName} |
|||
</if> |
|||
<if test="startTime != null and endTime != null"> |
|||
and go.success_time BETWEEN #{startTime} AND #{endTime} |
|||
</if> |
|||
</where> |
|||
</select> |
|||
<select id="getPayIp" resultType="java.lang.String"> |
|||
SELECT DISTINCT deptName FROM member_info |
|||
</select> |
|||
<select id="getStyle" resultType="java.lang.String"> |
|||
SELECT DISTINCT `name` FROM g_pay_style |
|||
</select> |
|||
</mapper> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue