|
|
|
@ -111,26 +111,36 @@ public class SceneManageServiceImpl implements ISceneManageService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ZDResponse generateQRCode(SceneManage sceneManage) throws Exception { |
|
|
|
|
|
|
|
String accessToken = getAccessToken(); |
|
|
|
String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
|
|
|
public ZDResponse getQRCode() throws Exception { |
|
|
|
ZdxtFileBean zdxtFileBean = new ZdxtFileBean(); |
|
|
|
zdxtFileBean.setBusinessId(APPID); |
|
|
|
List<ZdxtFileBean> zdxtFileBeans = zdxtFileCommonApi.selectZdxtFileList(zdxtFileBean); |
|
|
|
if (CollectionUtils.isEmpty(zdxtFileBeans)) { |
|
|
|
InputStream inputStream = generateQRCode(APPID); |
|
|
|
//存入本地数据库
|
|
|
|
File file = File.createTempFile("temp", ".png"); |
|
|
|
FileUtils.copyInputStreamToFile(inputStream, file); |
|
|
|
MultipartFile multipartFile = new LocalFileMultipartFile(file); |
|
|
|
String uploadPath = fileUploadApi.upload(multipartFile); |
|
|
|
zdxtFileCommonApi.deleteZdxtFileByIds(APPID); |
|
|
|
//zdxtFileCommonApi.insertZdxtFile(multipartFile, APPID, uploadPath);
|
|
|
|
ZdxtFileCommon zdxtFileCommon = new ZdxtFileCommon(); |
|
|
|
zdxtFileCommon.setUploadPersonId("0000"); |
|
|
|
zdxtFileCommon.setUploadPersonName("System"); |
|
|
|
zdxtFileCommon.setUploadPath(uploadPath); |
|
|
|
zdxtFileCommon.setGuid(StringUtils.getUUID()); |
|
|
|
zdxtFileCommon.setBusinessId(APPID); |
|
|
|
zdxtFileCommonApi.insertZdxtFileToApp(multipartFile,zdxtFileCommon); |
|
|
|
file.deleteOnExit(); |
|
|
|
return ZDResponse.success("成功", uploadPath); |
|
|
|
} |
|
|
|
return ZDResponse.success("成功", zdxtFileBeans.get(0) != null ? zdxtFileBeans.get(0).getUploadPath() : ""); |
|
|
|
} |
|
|
|
|
|
|
|
// 发送请求参数
|
|
|
|
JSONObject paramJson = new JSONObject(); |
|
|
|
paramJson.set("path", "subpkg/role/role"); |
|
|
|
//paramJson.set("check_path", false);
|
|
|
|
paramJson.set("width", 280); |
|
|
|
//paramJson.set("auto_color", false);
|
|
|
|
//paramJson.set("is_hyaline", false);
|
|
|
|
//scene数据不能中文
|
|
|
|
paramJson.set("scene", sceneManage.getGuid()); |
|
|
|
//设置小程序码版本
|
|
|
|
//paramJson.set("env_version","release"); 默认正式
|
|
|
|
//paramJson.set("env_version", "trial"); //体验版
|
|
|
|
paramJson.set("env_version", "develop"); //开发版
|
|
|
|
@Override |
|
|
|
public ZDResponse generateQRCode(SceneManage sceneManage) throws Exception { |
|
|
|
|
|
|
|
InputStream inputStream = HttpUtils.postInputStream(url, paramJson); |
|
|
|
InputStream inputStream = generateQRCode(sceneManage.getGuid()); |
|
|
|
//存入本地数据库
|
|
|
|
File file = File.createTempFile("temp", ".png"); |
|
|
|
FileUtils.copyInputStreamToFile(inputStream, file); |
|
|
|
@ -148,6 +158,25 @@ public class SceneManageServiceImpl implements ISceneManageService { |
|
|
|
return ZDResponse.error("生成二维码失败"); |
|
|
|
} |
|
|
|
|
|
|
|
public InputStream generateQRCode(String guid) throws Exception { |
|
|
|
String accessToken = getAccessToken(); |
|
|
|
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken; |
|
|
|
|
|
|
|
// 发送请求参数
|
|
|
|
JSONObject paramJson = new JSONObject(); |
|
|
|
paramJson.set("path", "pages/index/index"); |
|
|
|
paramJson.set("check_path", false); |
|
|
|
paramJson.set("width", 280); |
|
|
|
//scene数据不能中文
|
|
|
|
paramJson.set("scene", guid); |
|
|
|
//设置小程序码版本
|
|
|
|
//paramJson.set("env_version","release"); 默认正式
|
|
|
|
//paramJson.set("env_version", "trial"); //体验版
|
|
|
|
paramJson.set("env_version", "develop"); //开发版
|
|
|
|
|
|
|
|
return HttpUtils.postInputStream(url, paramJson); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ZDResponse createQrCode(SceneManage sceneManage) { |
|
|
|
try { |
|
|
|
@ -160,8 +189,6 @@ public class SceneManageServiceImpl implements ISceneManageService { |
|
|
|
|
|
|
|
MultipartFile multipartFile = new LocalFileMultipartFile(file); |
|
|
|
String uploadPath = fileUploadApi.upload(multipartFile); |
|
|
|
zdxtFileCommonApi.deleteZdxtFileByIds(sceneManage.getGuid() + "0000"); |
|
|
|
zdxtFileCommonApi.insertZdxtFile(multipartFile, sceneManage.getGuid() + "0000", uploadPath); |
|
|
|
sceneManage.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
sceneManage.setUrl(uploadPath); |
|
|
|
sceneManageMapper.updateSceneManage(sceneManage); |
|
|
|
@ -184,21 +211,6 @@ public class SceneManageServiceImpl implements ISceneManageService { |
|
|
|
return jsonObject.get("access_token").toString(); |
|
|
|
} |
|
|
|
|
|
|
|
// public static MultipartFile toMultipartFile(String fieldName, File file) throws Exception {
|
|
|
|
// DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
|
|
|
|
// String contentType = new MimetypesFileTypeMap().getContentType(file);
|
|
|
|
// FileItem fileItem = diskFileItemFactory.createItem(fieldName, contentType, false, file.getName());
|
|
|
|
// try (
|
|
|
|
// InputStream inputStream = new ByteArrayInputStream(FileCopyUtils.copyToByteArray(file));
|
|
|
|
// OutputStream outputStream = fileItem.getOutputStream()
|
|
|
|
// ) {
|
|
|
|
// FileCopyUtils.copy(inputStream, outputStream);
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// throw e;
|
|
|
|
// }
|
|
|
|
// MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
|
|
|
|
// return multipartFile;
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 新增【请填写功能名称】 |
|
|
|
|