Commit 5b88e65a by 水库浪子

修改群发图片资源相关BUG

1 parent 8966396c
Showing 19 changed files with 141 additions and 120 deletions
...@@ -21,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -21,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/** /**
* 通用请求处理 * 通用请求处理
...@@ -124,7 +125,7 @@ public class CommonController { ...@@ -124,7 +125,7 @@ public class CommonController {
= fileService.upload(file); = fileService.upload(file);
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", sysFile.getFileName()); ajax.put("fileName", sysFile.getFileName());
ajax.put("url", sysFile.getImgUrlPrefix()+sysFile.getFileName()); ajax.put("url", sysFile.getFileName());
return ajax; return ajax;
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error(e.getMessage()); return AjaxResult.error(e.getMessage());
...@@ -133,11 +134,11 @@ public class CommonController { ...@@ -133,11 +134,11 @@ public class CommonController {
/** /**
* 本地图片下载 * 获取图片
*/ */
@GetMapping("/findFile") @GetMapping("/common/findImage")
public void findFile(HttpServletResponse response,String fileName){ public void findImage(HttpServletResponse response,String fileName){
fileService.findFile(fileName,response); fileService.findImage(fileName,response);
} }
......
...@@ -15,7 +15,10 @@ import com.linkwechat.wecom.service.IWeCustomerMessagePushService; ...@@ -15,7 +15,10 @@ import com.linkwechat.wecom.service.IWeCustomerMessagePushService;
import com.linkwechat.wecom.service.IWeCustomerMessgaeResultService; import com.linkwechat.wecom.service.IWeCustomerMessgaeResultService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.ParseException; import java.text.ParseException;
...@@ -33,6 +36,7 @@ public class WeCustomerMessagePushController extends BaseController { ...@@ -33,6 +36,7 @@ public class WeCustomerMessagePushController extends BaseController {
@Autowired @Autowired
@Lazy
private IWeCustomerMessagePushService weCustomerMessagePushService; private IWeCustomerMessagePushService weCustomerMessagePushService;
@Autowired @Autowired
...@@ -50,7 +54,11 @@ public class WeCustomerMessagePushController extends BaseController { ...@@ -50,7 +54,11 @@ public class WeCustomerMessagePushController extends BaseController {
@PostMapping(value = "add") @PostMapping(value = "add")
public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) { public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) {
try { try {
SecurityContext context = SecurityContextHolder.getContext();
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
SecurityContextHolder.setContext(context);
weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto); weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto);
} catch (JsonProcessingException | ParseException e) { } catch (JsonProcessingException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
return AjaxResult.error("群发失败"); return AjaxResult.error("群发失败");
......
...@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -99,7 +100,9 @@ public class WeMaterialController extends BaseController { ...@@ -99,7 +100,9 @@ public class WeMaterialController extends BaseController {
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除素材信息") @ApiOperation("删除素材信息")
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(materialService.deleteWeMaterialByIds(ids)); materialService.deleteWeMaterialByIds(ids);
return AjaxResult.success();
} }
...@@ -136,7 +139,7 @@ public class WeMaterialController extends BaseController { ...@@ -136,7 +139,7 @@ public class WeMaterialController extends BaseController {
//@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')") //@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')")
@Log(title = "获取素材media_id", businessType = BusinessType.OTHER) @Log(title = "获取素材media_id", businessType = BusinessType.OTHER)
@GetMapping("/temporaryMaterialMediaId") @GetMapping("/temporaryMaterialMediaId")
@ApiOperation("获取素材media_id") @ApiOperation("H5端发送获取素材media_id")
public AjaxResult temporaryMaterialMediaId(String url,String type,String name){ public AjaxResult temporaryMaterialMediaId(String url,String type,String name){
WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url, WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url,
type type
...@@ -145,13 +148,32 @@ public class WeMaterialController extends BaseController { ...@@ -145,13 +148,32 @@ public class WeMaterialController extends BaseController {
} }
//@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')")
@Log(title = "获取素材media_id", businessType = BusinessType.OTHER)
@PostMapping("/temporaryMaterialMediaIdForWeb")
@ApiOperation("web端发送获取素材media_id")
public AjaxResult temporaryMaterialMediaIdForWeb(@RequestBody TemporaryMaterialDto temporaryMaterialDto){
WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(temporaryMaterialDto.getUrl(),
MediaType.of( temporaryMaterialDto.getType()).get().getMediaType()
,temporaryMaterialDto.getName());
return AjaxResult.success(weMediaDto);
}
@Log(title = "上传素材图片", businessType = BusinessType.OTHER) @Log(title = "上传素材图片", businessType = BusinessType.OTHER)
@PostMapping("/uploadimg") @PostMapping("/uploadimg")
@ApiOperation("上传素材图片") @ApiOperation("上传素材图片")
public AjaxResult<WeMediaDto> uploadImg(MultipartFile file){ public AjaxResult<WeMediaDto> uploadImg(MultipartFile file, HttpServletRequest request){
System.out.println(request.getServerName());
WeMediaDto weMediaDto=new WeMediaDto(); WeMediaDto weMediaDto=new WeMediaDto();
// WeMediaDto weMediaDto = materialService.uploadImg(file); // WeMediaDto weMediaDto = materialService.uploadImg(file);
// weMediaDto.setFileName(file.getResource().getFilename()); // weMediaDto.setFileName(file.getResource().getFilename()); weMaterialFileVO.getMaterialUrl()+
WeMaterialFileVO weMaterialFileVO = materialService.uploadWeMaterialFile(file, MediaType.IMAGE.getType()); WeMaterialFileVO weMaterialFileVO = materialService.uploadWeMaterialFile(file, MediaType.IMAGE.getType());
weMediaDto.setFileName(weMaterialFileVO.getMaterialName()); weMediaDto.setFileName(weMaterialFileVO.getMaterialName());
weMediaDto.setUrl(weMaterialFileVO.getMaterialUrl()+weMaterialFileVO.getMaterialName()); weMediaDto.setUrl(weMaterialFileVO.getMaterialUrl()+weMaterialFileVO.getMaterialName());
......
...@@ -229,7 +229,7 @@ public class WeTaskFissionController extends BaseController { ...@@ -229,7 +229,7 @@ public class WeTaskFissionController extends BaseController {
public AjaxResult<JSONObject> upload(@RequestParam(value = "file") MultipartFile file) throws IOException { public AjaxResult<JSONObject> upload(@RequestParam(value = "file") MultipartFile file) throws IOException {
String url = FileUploadUtils.upload2Cos(file, cosConfig); String url = FileUploadUtils.upload2Cos(file, cosConfig);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("rewardImageUrl", cosConfig.getImgUrlPrefix()+url); json.put("rewardImageUrl", cosConfig.getCosImgUrlPrefix()+url);
return AjaxResult.success(json); return AjaxResult.success(json);
} }
......
...@@ -12,13 +12,20 @@ ruoyi: ...@@ -12,13 +12,20 @@ ruoyi:
# 是否开启文件云上传(使用的是腾讯云,如果开启了,则需要配置腾讯云存储相关信息;如果关闭了则文件存储再本地,需要配置本地路径) # 是否开启文件云上传(使用的是腾讯云,如果开启了,则需要配置腾讯云存储相关信息;如果关闭了则文件存储再本地,需要配置本地路径)
file: file:
startCosUpload: true startCosUpload: true
#图片在系统中的访问前缀,图片无论是上传云端还是服务器本地,都通过本地读取资源,然后返回前端
imgUrlPrefix: imgUrlPrefix:
#腾讯云对象存储 #腾讯云对象存储
cos: cos:
#id
secretId: secretId:
#密钥
secretKey: secretKey:
#地区
region: region:
#区块空间
bucketName: bucketName:
#访问前缀
cosImgUrlPrefix:
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /app/project/pic) # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /app/project/pic)
#profile: /data/jenkins_home/app/project/ #profile: /data/jenkins_home/app/project/
# 获取ip地址开关 # 获取ip地址开关
...@@ -59,6 +66,7 @@ ruoyi: ...@@ -59,6 +66,7 @@ ruoyi:
- /wecom/community/h5/** - /wecom/community/h5/**
- /weixin/auth/** - /weixin/auth/**
- /wecom/material/temporaryMaterialMediaId - /wecom/material/temporaryMaterialMediaId
- /common/findImage
# 开发环境配置 # 开发环境配置
server: server:
...@@ -86,9 +94,9 @@ path: ...@@ -86,9 +94,9 @@ path:
#H5地址路径 #H5地址路径
H5: H5:
url: url: http://h5.linkwechat.cn/index.html
fissionUrl: fissionUrl: http://h5.linkwechat.cn/index.html
fissionGroupUrl: fissionGroupUrl: http://h5.linkwechat.cn/fission.html
# Spring配置 # Spring配置
spring: spring:
# 资源信息 # 资源信息
...@@ -101,7 +109,7 @@ spring: ...@@ -101,7 +109,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://127.0.0.1:10179/lw-test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://127.0.0.1:10179/link-wechat?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: root password: root
# 从库数据源 # 从库数据源
...@@ -210,14 +218,6 @@ mybatis-plus: ...@@ -210,14 +218,6 @@ mybatis-plus:
logic-delete-value: 1 logic-delete-value: 1
logic-not-delete-value: 0 logic-not-delete-value: 0
## MyBatis配置
#mybatis:
# # 搜索指定包别名
# typeAliasesPackage: com.linkwechat.**.domain
# # 配置mapper的扫描,找到所有的mapper.xml映射文件
# mapperLocations: classpath*:mapper/**/*Mapper.xml
# # 加载全局的配置文件
# configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件 # PageHelper分页插件
pagehelper: pagehelper:
...@@ -246,8 +246,8 @@ xss: ...@@ -246,8 +246,8 @@ xss:
elasticsearch: elasticsearch:
schema: http schema: http
address: address:
userName: userName: "elastic"
password: password: "0p-0p-0p-"
connectTimeout: 10000 connectTimeout: 10000
socketTimeout: 10000 socketTimeout: 10000
connectionRequestTimeout: 10000 connectionRequestTimeout: 10000
...@@ -331,5 +331,5 @@ wecome: ...@@ -331,5 +331,5 @@ wecome:
authorizeRedirectUrl: authorizeRedirectUrl:
weixin: weixin:
appid:
secret:
\ No newline at end of file \ No newline at end of file
appid: wxa57479bcd3f15461
secret: f23f4becdcac9819f292a3754fd8f84e
\ No newline at end of file \ No newline at end of file
...@@ -20,6 +20,6 @@ public class CosConfig { ...@@ -20,6 +20,6 @@ public class CosConfig {
private String bucketName; private String bucketName;
private String imgUrlPrefix; private String cosImgUrlPrefix;
} }
...@@ -196,11 +196,10 @@ public class FileUploadUtils { ...@@ -196,11 +196,10 @@ public class FileUploadUtils {
COSClient cosClient = new COSClient(cred, clientConfig); COSClient cosClient = new COSClient(cred, clientConfig);
// 指定要上传到 COS 上对象键 // 指定要上传到 COS 上对象键
String key = "exampleobject";
ObjectMetadata objectMetadata = new ObjectMetadata(); ObjectMetadata objectMetadata = new ObjectMetadata();
PutObjectRequest putObjectRequest = new PutObjectRequest(cosConfig.getBucketName(), fileName,file.getInputStream(),objectMetadata); PutObjectRequest putObjectRequest = new PutObjectRequest(cosConfig.getBucketName(), fileName,file.getInputStream(),objectMetadata);
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info("{}","https://link-wechat-1251309172.cos.ap-nanjing.myqcloud.com/"+fileName); log.info("{}",cosConfig.getCosImgUrlPrefix()+fileName);
log.info("腾讯cos上传信息:{}",new ObjectMapper().writeValueAsString(putObjectResult)); log.info("腾讯cos上传信息:{}",new ObjectMapper().writeValueAsString(putObjectResult));
cosClient.shutdown(); cosClient.shutdown();
......
...@@ -286,7 +286,7 @@ public class FinanceUtils { ...@@ -286,7 +286,7 @@ public class FinanceUtils {
getMediaData(sdkfileid, "", "", filePath, fileName); getMediaData(sdkfileid, "", "", filePath, fileName);
CosConfig cosConfig = SpringUtils.getBean(CosConfig.class); CosConfig cosConfig = SpringUtils.getBean(CosConfig.class);
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
StringBuilder cosUrl = new StringBuilder(cosConfig.getImgUrlPrefix()); StringBuilder cosUrl = new StringBuilder(cosConfig.getCosImgUrlPrefix());
String cosFilePath = FileUploadUtils.upload2Cos(new FileInputStream(new File(filePath, fileName)), suffix, cosConfig); String cosFilePath = FileUploadUtils.upload2Cos(new FileInputStream(new File(filePath, fileName)), suffix, cosConfig);
cosUrl.append(cosFilePath); cosUrl.append(cosFilePath);
data.put("attachment", cosUrl.toString()); data.put("attachment", cosUrl.toString());
......
...@@ -108,7 +108,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -108,7 +108,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers(ruoYiConfig.getAnonUrl()).anonymous() .antMatchers(ruoYiConfig.getAnonUrl()).anonymous()
// .antMatchers("/login", "/captchaImage", "/findWxQrLoginInfo", "/wxQrLogin").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/*.html", "/*.html",
...@@ -116,34 +115,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -116,34 +115,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/**/*.css", "/**/*.css",
"/**/*.js" "/**/*.js"
).permitAll() ).permitAll()
// .antMatchers("/profile/**").anonymous()
// .antMatchers("/common/download**").anonymous()
// .antMatchers("/common/download/resource**").anonymous()
// .antMatchers("/common/download/url**").anonymous()
// .antMatchers("/swagger-ui.html").anonymous()
// .antMatchers("/swagger-resources/**").anonymous()
// .antMatchers("/webjars/**").anonymous()
// .antMatchers("/*/api-docs").anonymous()
// .antMatchers("/druid/**").anonymous()
// .antMatchers("/wecom/callback/**").anonymous()
//
// .antMatchers("/wecom/chat/item/list").anonymous()
// .antMatchers("/wecom/chat/collection/list").anonymous()
// .antMatchers("/wecom/chat/collection/cancleCollection").anonymous()
// .antMatchers("/wecom/chat/collection/addCollection").anonymous()
// .antMatchers("/wecom/chat/side/h5List").anonymous()
// .antMatchers("/wecom/ticket/**").anonymous()
//
// .antMatchers("/wecom/user/getUserInfo").anonymous()
// // .antMatchers("/common/uploadFile2Cos").anonymous()
//// .antMatchers("/wecom/material/temporaryMaterialMediaId").anonymous()
// .antMatchers("/wecom/portrait/**").anonymous()
// .antMatchers("/wecom/fission/poster", "/wecom/fission/*/progress/*", "/wecom/reward/getRewardByFissionId/**").anonymous()
// // 获取实际群活码和社群运营H5页面不需要登录
// .antMatchers("/wecom/groupCode/getActualCode/**").anonymous()
// .antMatchers("/wecom/community/h5/**").anonymous()
// //微信授权接口
// .antMatchers("/weixin/auth/**").anonymous()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
......
...@@ -34,8 +34,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter ...@@ -34,8 +34,6 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
throws ServletException, IOException throws ServletException, IOException
{ {
LoginUser loginUser = tokenService.getLoginUser(request); LoginUser loginUser = tokenService.getLoginUser(request);
Enumeration<String> parameterNames = request.getParameterNames();
if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
{ {
......
package com.linkwechat.framework.web.service; package com.linkwechat.framework.web.service;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.utils.OsUtils; import com.linkwechat.common.utils.OsUtils;
import com.linkwechat.common.utils.file.FileUploadUtils; import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.framework.web.domain.server.SysFile; import com.linkwechat.framework.web.domain.server.SysFile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
/** /**
* 文件服务 * 文件服务
*/ */
@Component @Component
@Slf4j
public class FileService { public class FileService {
...@@ -59,39 +61,26 @@ public class FileService { ...@@ -59,39 +61,26 @@ public class FileService {
} }
/**
public void findFile(String fileName, HttpServletResponse rp){ * 获取图片(本地,或者网络图片)
String fileDownUrl=""; * @param fileName
// if(ruoYiConfig.getFile().isStartCosUpload()) {//开启云上传 * @param rp
// fileDownUrl= ruoYiConfig.getFile().getImgUrlPrefix(); */
// }else{ public void findImage(String fileName, HttpServletResponse rp){
fileDownUrl=OsUtils.isWindows()?WINDOWSFILEPATH+fileName:LINUXFILEPATH+fileName; try {
// } String fileDownUrl="";
File file=new File(fileDownUrl); rp.setContentType("image/png");
if (file.exists()) { if(ruoYiConfig.getFile().isStartCosUpload()) {//开启云上传
FileInputStream fis = null; fileDownUrl= ruoYiConfig.getFile().getCos().getCosImgUrlPrefix();
OutputStream os = null; FileUtils.downloadFile(fileDownUrl+fileName,rp.getOutputStream());
try { }else{
fis = new FileInputStream(file); fileDownUrl=OsUtils.isWindows()?WINDOWSFILEPATH+"/"+fileName:LINUXFILEPATH+"/"+fileName;
os = rp.getOutputStream(); FileUtils.writeBytes(fileDownUrl,rp.getOutputStream());
int count = 0; }
byte[] buffer = new byte[1024 * 8]; }catch (Exception e){
while ((count = fis.read(buffer)) != -1) { log.error("图片获取异常:"+e.getMessage());
os.write(buffer, 0, count);
os.flush(); }
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fis.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
......
package com.linkwechat.framework.web.service; package com.linkwechat.framework.web.service;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.linkwechat.common.config.RuoYiConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -41,6 +44,9 @@ public class TokenService ...@@ -41,6 +44,9 @@ public class TokenService
@Value("${token.expireTime}") @Value("${token.expireTime}")
private int expireTime; private int expireTime;
@Autowired
private RuoYiConfig ruoYiConfig;
protected static final long MILLIS_SECOND = 1000; protected static final long MILLIS_SECOND = 1000;
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
...@@ -208,11 +214,19 @@ public class TokenService ...@@ -208,11 +214,19 @@ public class TokenService
*/ */
private String getToken(HttpServletRequest request) private String getToken(HttpServletRequest request)
{ {
String token = request.getHeader(header); String token = "";
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) //移除匿名接口中请求头的token
{ if(!Arrays.asList(ruoYiConfig.getAnonUrl()).contains(request.getRequestURI())){
token = token.replace(Constants.TOKEN_PREFIX, ""); // request.removeAttribute(header);
// request.
token = request.getHeader(header);
if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX))
{
token = token.replace(Constants.TOKEN_PREFIX, "");
}
} }
return token; return token;
} }
......
...@@ -103,18 +103,18 @@ public class RyTask { ...@@ -103,18 +103,18 @@ public class RyTask {
} }
public void WeCustomers() { public void WeCustomers() {
//查询系统所有客户 // //查询系统所有客户
List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY); // List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if (CollectionUtils.isEmpty(cacheList)) { // if (CollectionUtils.isEmpty(cacheList)) {
List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null); // List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null);
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers); // redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
} else { // } else {
List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null); // List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null);
List<WeCustomer> weCustomers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY); // List<WeCustomer> weCustomers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if (CollectionUtils.isNotEmpty(weCustomers) && weCustomers.size() < customers.size()) { // if (CollectionUtils.isNotEmpty(weCustomers) && weCustomers.size() < customers.size()) {
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers); // redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
} // }
} // }
} }
private void setRedisCacheSeqValue(AtomicLong index) { private void setRedisCacheSeqValue(AtomicLong index) {
......
...@@ -166,7 +166,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -166,7 +166,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
// 新客拉群创建的员工活码欢迎语图片(群活码图片) // 新客拉群创建的员工活码欢迎语图片(群活码图片)
String codeUrl = weGroupCodeService.selectGroupCodeUrlByEmplCodeState(state); String codeUrl = weGroupCodeService.selectGroupCodeUrlByEmplCodeState(state);
if (StringUtils.isNotNull(codeUrl)) { if (StringUtils.isNotNull(codeUrl)) {
buildWelcomeMsgImg(weWelcomeMsgBuilder, codeUrl, codeUrl.replaceAll(cosConfig.getImgUrlPrefix(), "")); buildWelcomeMsgImg(weWelcomeMsgBuilder, codeUrl, codeUrl.replaceAll(cosConfig.getCosImgUrlPrefix(), ""));
} }
// 普通员工活码欢迎语图片 // 普通员工活码欢迎语图片
else if (StringUtils.isNotEmpty(messageMap.getCategoryId())) { else if (StringUtils.isNotEmpty(messageMap.getCategoryId())) {
......
...@@ -48,7 +48,7 @@ public interface IWeMaterialService { ...@@ -48,7 +48,7 @@ public interface IWeMaterialService {
* @param ids id列表 * @param ids id列表
* @return {@link int} * @return {@link int}
*/ */
int deleteWeMaterialByIds(Long[] ids); void deleteWeMaterialByIds(Long[] ids);
/** /**
* 更新素材信息 * 更新素材信息
......
...@@ -21,6 +21,7 @@ import com.linkwechat.wecom.service.*; ...@@ -21,6 +21,7 @@ import com.linkwechat.wecom.service.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -72,6 +73,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -72,6 +73,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Async
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException, ParseException { public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException, ParseException {
// if ((null != customerMessagePushDto.getSettingTime() && !"".equals(customerMessagePushDto.getSettingTime())) // if ((null != customerMessagePushDto.getSettingTime() && !"".equals(customerMessagePushDto.getSettingTime()))
......
...@@ -78,8 +78,9 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -78,8 +78,9 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
} }
//构造返回结果 //构造返回结果
// return WeMaterialFileVO.builder().materialUrl(url).materialName(file.getOriginalFilename()).build(); // return WeMaterialFileVO.builder().materialUrl(url).materialName(file.getOriginalFilename()).build();
return WeMaterialFileVO.builder().materialUrl(ruoYiConfig.getFile().getCos().getCosImgUrlPrefix()).materialName(FileUploadUtils.upload2Cos(file, ruoYiConfig.getFile().getCos())).build();
return WeMaterialFileVO.builder().materialUrl(ruoYiConfig.getFile().getImgUrlPrefix()).materialName(FileUploadUtils.upload2Cos(file, ruoYiConfig.getFile().getCos())).build(); // return WeMaterialFileVO.builder().materialUrl(ruoYiConfig.getFile().getCos().getCosImgUrlPrefix()+"/common/findImage?fileName=/").materialName(FileUploadUtils.upload2Cos(file, ruoYiConfig.getFile().getCos())).build();
} catch (Exception e) { } catch (Exception e) {
throw new WeComException(e.getMessage()); throw new WeComException(e.getMessage());
} }
...@@ -99,8 +100,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -99,8 +100,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
} }
@Override @Override
public int deleteWeMaterialByIds(Long[] ids) { public void deleteWeMaterialByIds(Long[] ids) {
return weMaterialMapper.deleteWeMaterialByIds(ids); weMaterialMapper.deleteWeMaterialByIds(ids);
} }
@Override @Override
......
...@@ -125,6 +125,8 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i ...@@ -125,6 +125,8 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
return poster.getBackgroundImgPath(); return poster.getBackgroundImgPath();
} }
Set<String> existFontId = new HashSet<>(); Set<String> existFontId = new HashSet<>();
Map<String, Font> fontMap = poster.getPosterSubassemblyList().stream().filter(wePosterSubassembly -> wePosterSubassembly.getType().equals(1)) Map<String, Font> fontMap = poster.getPosterSubassemblyList().stream().filter(wePosterSubassembly -> wePosterSubassembly.getType().equals(1))
.peek(wePosterSubassembly -> { .peek(wePosterSubassembly -> {
if (wePosterSubassembly.getFontId() == null) { if (wePosterSubassembly.getFontId() == null) {
...@@ -149,17 +151,29 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i ...@@ -149,17 +151,29 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
fileCallableMap = new HashMap<>(); fileCallableMap = new HashMap<>();
} }
fileCallableMap.put(poster.getBackgroundImgPath(), NetFileUtils.getNetFile(poster.getBackgroundImgPath())); fileCallableMap.put(poster.getBackgroundImgPath(), NetFileUtils.getNetFile(poster.getBackgroundImgPath()));
Map<String, BufferedImage> bufferedImageMap = fileCallableMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, stringFileCallableEntry -> { Map<String, BufferedImage> bufferedImageMap = fileCallableMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, stringFileCallableEntry -> {
try { try {
return ImageUtils.copyBufferedImage(ImageIO.read(new ByteArrayInputStream(Objects.requireNonNull(NetFileUtils.getByteArrayOutputStream(stringFileCallableEntry.getValue(), false)).toByteArray())), BufferedImage.TYPE_INT_ARGB); return ImageUtils.copyBufferedImage(ImageIO.read(new ByteArrayInputStream(Objects.requireNonNull(NetFileUtils.getByteArrayOutputStream(stringFileCallableEntry.getValue(), false)).toByteArray())),
BufferedImage.TYPE_INT_ARGB);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("图片读取错误"); throw new RuntimeException("图片读取错误");
} }
})); }));
BufferedImage backgroundImg = bufferedImageMap.get(poster.getBackgroundImgPath()); BufferedImage backgroundImg = bufferedImageMap.get(poster.getBackgroundImgPath());
poster.setWidth(backgroundImg.getWidth()); poster.setWidth(backgroundImg.getWidth());
poster.setHeight(backgroundImg.getHeight()); poster.setHeight(backgroundImg.getHeight());
poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> { poster.getPosterSubassemblyList().forEach(wePosterSubassembly -> {
if (wePosterSubassembly.getType().equals(1)) { if (wePosterSubassembly.getType().equals(1)) {
Font font = fontMap.get(wePosterSubassembly.getFontId() + "_" + wePosterSubassembly.getFontSize() + "_" + wePosterSubassembly.getFontStyle()); Font font = fontMap.get(wePosterSubassembly.getFontId() + "_" + wePosterSubassembly.getFontSize() + "_" + wePosterSubassembly.getFontStyle());
...@@ -196,13 +210,15 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i ...@@ -196,13 +210,15 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
} }
}); });
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try { try {
ImageIO.write(backgroundImg, "png", byteArrayOutputStream); ImageIO.write(backgroundImg, "png", byteArrayOutputStream);
NetFileUtils.StreamMultipartFile streamMultipartFile = new NetFileUtils.StreamMultipartFile(System.currentTimeMillis() + ".jpg", byteArrayOutputStream.toByteArray()); NetFileUtils.StreamMultipartFile streamMultipartFile = new NetFileUtils.StreamMultipartFile(System.currentTimeMillis() + ".jpg", byteArrayOutputStream.toByteArray());
byteArrayOutputStream.close(); byteArrayOutputStream.close();
String path = FileUploadUtils.upload2Cos(streamMultipartFile, ruoYiConfig.getFile().getCos()); String path = FileUploadUtils.upload2Cos(streamMultipartFile, ruoYiConfig.getFile().getCos());
poster.setSampleImgPath(ruoYiConfig.getFile().getImgUrlPrefix() + path); poster.setSampleImgPath(ruoYiConfig.getFile().getCos().getCosImgUrlPrefix() + path);
return poster.getSampleImgPath(); return poster.getSampleImgPath();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -453,7 +453,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W ...@@ -453,7 +453,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
throw new WeComException("生成二维码异常"); throw new WeComException("生成二维码异常");
} }
} }
return cosConfig.getImgUrlPrefix() + qrCode; return cosConfig.getCosImgUrlPrefix() + qrCode;
} else { } else {
throw new WeComException("生成二维码异常,用户信息不存在"); throw new WeComException("生成二维码异常,用户信息不存在");
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!