提交 34cd118e authored 作者: 吴德鹏's avatar 吴德鹏

Merge branch 'dev'

server.servlet.context-path=/zion server.servlet.context-path=/zion
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
server.port=8083 server.port=8083
spring.profiles.active=test spring.profiles.active=dev
#spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC #spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
#spring.datasource.username=root #spring.datasource.username=root
#spring.datasource.password=Diaoyunnuli.8 #spring.datasource.password=Diaoyunnuli.8
......
//package com.example.afrishop_v3; package com.example.afrishop_v3;
//
//import com.example.afrishop_v3.models.*; import com.example.afrishop_v3.models.*;
//import com.example.afrishop_v3.repository.*; import com.example.afrishop_v3.repository.*;
//import com.example.afrishop_v3.util.IdUtil; import com.example.afrishop_v3.util.IdUtil;
//import com.example.afrishop_v3.util.OssUtil; import com.example.afrishop_v3.util.OssUtil;
//import com.example.afrishop_v3.util.PicUtils; import com.example.afrishop_v3.util.PicUtils;
//import com.google.gson.JsonObject; import com.google.gson.JsonObject;
//import net.sf.json.JSONArray; import net.sf.json.JSONArray;
//import net.sf.json.JSONObject; import net.sf.json.JSONObject;
//import org.junit.Test; import org.junit.Test;
//import org.junit.runner.Result; import org.junit.runner.Result;
//import org.junit.runner.RunWith; import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
//import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
//import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
//
//import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
//import java.io.IOException; import java.io.IOException;
//import java.io.InputStream; import java.io.InputStream;
//import java.net.HttpURLConnection; import java.net.HttpURLConnection;
//import java.net.URL; import java.net.URL;
//import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
//import java.time.LocalDateTime; import java.time.LocalDateTime;
//import java.util.*; import java.util.*;
//import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors; import java.util.concurrent.Executors;
//import java.util.concurrent.Future; import java.util.concurrent.Future;
//import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
//import java.util.stream.Collectors; import java.util.stream.Collectors;
//
//@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
//@SpringBootTest @SpringBootTest
//public class AfrishopV3ApplicationTests { public class AfrishopV3ApplicationTests {
//
// RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
//
// @Test @Test
// public void contextLoads() { public void contextLoads() {
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
// String now = format.format(new Date()); String now = format.format(new Date());
// System.out.println(now); System.out.println(now);
// } }
//
// private String url = "http://localhost:8099/afrishop/discover/bonus/saveNetworkMarketing"; private String url = "http://localhost:8099/afrishop/discover/bonus/saveNetworkMarketing";
// @Autowired @Autowired
// private TbCfOrderRepository orderRepository; private TbCfOrderRepository orderRepository;
//
//// post35789572fbf643cdab55901d1dc511a6 // post35789572fbf643cdab55901d1dc511a6
//// userInfo00297bf300ed45e092a5182dececad21 // userInfo00297bf300ed45e092a5182dececad21
//// productSharervv32GmG4q // productSharervv32GmG4q
//// amount0.9 // amount0.9
//// orderId008272b1fb994aef9b199449f46d5aa5 // orderId008272b1fb994aef9b199449f46d5aa5
//
// @Test @Test
// public void test1() { public void test1() {
//
// Optional<TbCfOrder> byId = orderRepository.findById("12a9d7d1042348278c97980a00fc67c4"); Optional<TbCfOrder> byId = orderRepository.findById("12a9d7d1042348278c97980a00fc67c4");
// JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
// json.put("userInfo", "32dcda5a709c4265a6f01686ae9b1c1c"); json.put("userInfo", "32dcda5a709c4265a6f01686ae9b1c1c");
// json.put("amount", byId.get().getItemsPrice()); json.put("amount", byId.get().getItemsPrice());
// json.put("orderId", "12a9d7d1042348278c97980a00fc67c4"); json.put("orderId", "12a9d7d1042348278c97980a00fc67c4");
// System.out.println(json); System.out.println(json);
// ResponseEntity<Result> resultResponseEntity = restTemplate.postForEntity(url, json, Result.class); ResponseEntity<Result> resultResponseEntity = restTemplate.postForEntity(url, json, Result.class);
// System.err.println(resultResponseEntity); System.err.println(resultResponseEntity);
// } }
//
// @Autowired @Autowired
// private TokenRepository tokenRepository; private TokenRepository tokenRepository;
//
// @Autowired @Autowired
// private CountryRepository countryRepository; private CountryRepository countryRepository;
//
//
// @Test @Test
// public void test2() { public void test2() {
// List list = new ArrayList(); List list = new ArrayList();
// list.add(2); list.add(2);
// list.add(1); list.add(1);
// list.add(3); list.add(3);
// list.forEach(System.out::println); list.forEach(System.out::println);
//
// } }
//
// private ReentrantLock reentrantLock = new ReentrantLock(); private ReentrantLock reentrantLock = new ReentrantLock();
//
// @Test @Test
// public void testImport() { public void testImport() {
// ExecutorService executorService = Executors.newCachedThreadPool(); ExecutorService executorService = Executors.newCachedThreadPool();
//
// for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
// executorService.execute(() -> importCountry()); executorService.execute(() -> importCountry());
// } }
//
// } }
//
// @Test @Test
// public void importCountry() { public void importCountry() {
//
// String url = "https://api.jisuapi.com/country/query?name=&continent=非洲&language=&iscountry=&appkey=732afb9ddae9eef8"; String url = "https://api.jisuapi.com/country/query?name=&continent=非洲&language=&iscountry=&appkey=732afb9ddae9eef8";
// ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class); ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
// String body = forEntity.getBody(); String body = forEntity.getBody();
// System.err.println(body); System.err.println(body);
// JSONObject jsonObject = JSONObject.fromObject(body); JSONObject jsonObject = JSONObject.fromObject(body);
// String status = jsonObject.getString("status"); String status = jsonObject.getString("status");
// if ("0".equals(status)) { if ("0".equals(status)) {
// JSONArray jsonArray = jsonObject.getJSONArray("result"); JSONArray jsonArray = jsonObject.getJSONArray("result");
// for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
// Country country = new Country(); Country country = new Country();
// JSONObject object = jsonArray.getJSONObject(i); JSONObject object = jsonArray.getJSONObject(i);
// String ename = object.getString("ename"); String ename = object.getString("ename");
// String cname = object.getString("cname"); String cname = object.getString("cname");
// String areaCode = object.getString("areacode"); String areaCode = object.getString("areacode");
// String nationalFlag = object.getString("nationalflag"); String nationalFlag = object.getString("nationalflag");
// country.setAreaCode(areaCode); country.setAreaCode(areaCode);
// country.setCountryCname(cname); country.setCountryCname(cname);
// country.setCountryName(ename); country.setCountryName(ename);
// country.setNationalFlag(nationalFlag); country.setNationalFlag(nationalFlag);
// country.setId(IdUtil.createIdbyUUID()); country.setId(IdUtil.createIdbyUUID());
// countryRepository.save(country); countryRepository.save(country);
//
// } }
// } }
//
//
// } }
//
// private volatile int count = 1; private volatile int count = 1;
// @Autowired @Autowired
// private TbCfStationItemRepository tbCfStationItemRepository; private TbCfStationItemRepository tbCfStationItemRepository;
//
// @Test @Test
// public void testImg() { public void testImg() {
// List<TbCfStationItem> list = tbCfStationItemRepository.queryItemsAll(); List<TbCfStationItem> list = tbCfStationItemRepository.queryItemsAll();
// try { try {
//
// for (TbCfStationItem item : list) { for (TbCfStationItem item : list) {
// System.out.println("压缩数量:" + count++); System.out.println("压缩数量:" + count++);
// System.err.println("商品ID:" + item.getItemId()); System.err.println("商品ID:" + item.getItemId());
//
// String itemImg = item.getItemImg(); String itemImg = item.getItemImg();
// String[] urlArr = itemImg.split(";"); String[] urlArr = itemImg.split(";");
// List<String> strList = new ArrayList<>(); List<String> strList = new ArrayList<>();
// for (String url : urlArr) { for (String url : urlArr) {
//
// InputStream stream = getImageStream(url); InputStream stream = getImageStream(url);
// if (stream == null) { if (stream == null) {
// continue; continue;
// } }
// byte[] bytes = new byte[0]; byte[] bytes = new byte[0];
// try { try {
// bytes = toByteArray(stream); bytes = toByteArray(stream);
// byte[] by = PicUtils.compressPicForScale(bytes, 70); byte[] by = PicUtils.compressPicForScale(bytes, 70);
// long l = System.currentTimeMillis(); long l = System.currentTimeMillis();
// String urlName = UUID.randomUUID() + "-" + String.valueOf(l).substring(6) + ".jpg"; String urlName = UUID.randomUUID() + "-" + String.valueOf(l).substring(6) + ".jpg";
//
// String compressedUrl = OssUtil.upload(by, urlName, "afrishop_new"); String compressedUrl = OssUtil.upload(by, urlName, "afrishop_new");
// strList.add(compressedUrl); strList.add(compressedUrl);
// } catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); e.printStackTrace();
// } }
// } }
// tbCfStationItemRepository.updateItmeImg(strList.stream().collect(Collectors.joining(";")), item.getItemId()); tbCfStationItemRepository.updateItmeImg(strList.stream().collect(Collectors.joining(";")), item.getItemId());
// } }
//
// } catch (Exception e) { } catch (Exception e) {
//
// } finally { } finally {
//
//
// } }
// } }
//
// /** /**
// * 通过URL获取网络图片 * 通过URL获取网络图片
// * 获取网络图片流 * 获取网络图片流
// * *
// * @param url 传入的 URL 必须是以 http:// 开头的,因为我们使用了 HttpURLConnection * @param url 传入的 URL 必须是以 http:// 开头的,因为我们使用了 HttpURLConnection
// * @return 输入流 * @return 输入流
// */ */
// public static InputStream getImageStream(String url) { public static InputStream getImageStream(String url) {
// try { try {
// HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
// connection.setReadTimeout(10000); connection.setReadTimeout(10000);
// connection.setConnectTimeout(10000); connection.setConnectTimeout(10000);
// connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
// if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
// return connection.getInputStream(); return connection.getInputStream();
// } }
// } catch (IOException e) { } catch (IOException e) {
// System.out.println("获取网络图片出现异常,图片路径为:" + url); System.out.println("获取网络图片出现异常,图片路径为:" + url);
// e.printStackTrace(); e.printStackTrace();
// } }
// return null; return null;
// } }
//
// /** /**
// * 将 InputStream 流转换为 byte[] * 将 InputStream 流转换为 byte[]
// * *
// * @param input InputStream * @param input InputStream
// * @return byte[] * @return byte[]
// * @throws IOException IO流异常 * @throws IOException IO流异常
// */ */
// public static byte[] toByteArray(InputStream input) throws IOException { public static byte[] toByteArray(InputStream input) throws IOException {
// ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();
// byte[] buffer = new byte[1024 * 4]; byte[] buffer = new byte[1024 * 4];
// int n = 0; int n = 0;
// while (-1 != (n = input.read(buffer))) { while (-1 != (n = input.read(buffer))) {
// output.write(buffer, 0, n); output.write(buffer, 0, n);
// } }
// return output.toByteArray(); return output.toByteArray();
// } }
//
@Test
//} public void test001(){
System.out.println("test001");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论