|
@@ -1,8 +1,10 @@
|
|
|
package com.fs.qw.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.fs.common.constant.FsConstants;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCacheT;
|
|
|
+import com.fs.common.exception.base.BaseException;
|
|
|
import com.fs.qw.domain.QwFriendWelcome;
|
|
|
import com.fs.qw.mapper.QwFriendWelcomeItemMapper;
|
|
|
import com.fs.qw.mapper.QwFriendWelcomeMapper;
|
|
@@ -14,7 +16,6 @@ import com.fs.qw.vo.QwFriendWelcomeVO;
|
|
|
import com.fs.qw.vo.QwUserVO;
|
|
|
import com.fs.qwApi.Result.QwUploadImgResult;
|
|
|
import com.fs.qwApi.Result.QwUploadResult;
|
|
|
-import com.fs.qwApi.param.QwWelcomeVideoParam;
|
|
|
import com.fs.qwApi.param.SendWelcomeMsgParam;
|
|
|
import com.fs.qwApi.service.QwApiService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
@@ -30,6 +31,7 @@ import java.net.URL;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 好友欢迎语Service业务层处理
|
|
@@ -38,13 +40,12 @@ import java.util.List;
|
|
|
* @date 2024-07-20
|
|
|
*/
|
|
|
@Service
|
|
|
-public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
-{
|
|
|
+public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService {
|
|
|
@Autowired
|
|
|
private QwFriendWelcomeMapper qwFriendWelcomeMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private QwFriendWelcomeItemMapper qwFriendWelcomeItemMapper;
|
|
|
+ private QwFriendWelcomeItemMapper qwFriendWelcomeItemMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private QwUserMapper qwUserMapper;
|
|
@@ -53,7 +54,7 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
private QwApiService qwApiService;
|
|
|
|
|
|
@Autowired
|
|
|
- private RedisCacheT<QwWelcomeVideoParam> redisCache;
|
|
|
+ private RedisCacheT<Long> redisCache;
|
|
|
|
|
|
/**
|
|
|
* 查询好友欢迎语
|
|
@@ -62,8 +63,7 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
* @return 好友欢迎语
|
|
|
*/
|
|
|
@Override
|
|
|
- public QwFriendWelcomeVO selectQwFriendWelcomeById(Long id)
|
|
|
- {
|
|
|
+ public QwFriendWelcomeVO selectQwFriendWelcomeById(Long id) {
|
|
|
QwFriendWelcomeVO qwFriendWelcomeVO = qwFriendWelcomeMapper.selectQwFriendWelcomeByIdVO(id);
|
|
|
|
|
|
// 假设 qwFriendWelcomeVO 是已经初始化的对象
|
|
@@ -75,7 +75,7 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
// 将字符串转换为列表
|
|
|
List<String> qwUserIdsList = Arrays.asList(sanitizedQwUserIds.split(","));
|
|
|
|
|
|
- List<QwUserVO> qwUserByIds = qwUserMapper.getQwUserByIds(qwUserIdsList,qwFriendWelcomeVO.getCorpId());
|
|
|
+ List<QwUserVO> qwUserByIds = qwUserMapper.getQwUserByIds(qwUserIdsList, qwFriendWelcomeVO.getCorpId());
|
|
|
qwFriendWelcomeVO.setUserSelectList(qwUserByIds);
|
|
|
|
|
|
return qwFriendWelcomeVO;
|
|
@@ -88,8 +88,7 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
* @return 好友欢迎语
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<QwFriendWelcome> selectQwFriendWelcomeListVO(QwFriendWelcomeParam qwFriendWelcomeParam)
|
|
|
- {
|
|
|
+ public List<QwFriendWelcome> selectQwFriendWelcomeListVO(QwFriendWelcomeParam qwFriendWelcomeParam) {
|
|
|
return qwFriendWelcomeMapper.selectQwFriendWelcomeListVO(qwFriendWelcomeParam);
|
|
|
}
|
|
|
|
|
@@ -105,56 +104,53 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public R insertQwFriendWelcomeVO(QwFriendWelcomeParam qwFriendWelcomeParam){
|
|
|
+ public R insertQwFriendWelcomeVO(QwFriendWelcomeParam qwFriendWelcomeParam) {
|
|
|
List<SendWelcomeMsgParam.Attachment> attachmentsAll = JSON.parseArray(qwFriendWelcomeParam.getAttachments(), SendWelcomeMsgParam.Attachment.class);
|
|
|
-
|
|
|
- if(attachmentsAll!=null && !attachmentsAll.isEmpty()){
|
|
|
-
|
|
|
+ boolean video = false;
|
|
|
+ if (attachmentsAll != null && !attachmentsAll.isEmpty()) {
|
|
|
+ String corpId = qwFriendWelcomeParam.getCorpId();
|
|
|
for (SendWelcomeMsgParam.Attachment attachment : attachmentsAll) {
|
|
|
|
|
|
- if (attachment.getMsgtype().equals("image")){
|
|
|
+ if (attachment.getMsgtype().equals("image")) {
|
|
|
|
|
|
try {
|
|
|
QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), qwFriendWelcomeParam.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0) {
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getImage().setPic_url(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("图片image上传失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("图片image上传失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("图片image上传出错:"+e);
|
|
|
+ return R.error("图片image上传出错:" + e);
|
|
|
// throw new RuntimeException("insertQwFriendWelcomeVO-attachment/image:"+e);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (attachment.getMsgtype().equals("video")){
|
|
|
-
|
|
|
+ if (attachment.getMsgtype().equals("video")) {
|
|
|
+ if(!video){
|
|
|
+ video = true;
|
|
|
+ }
|
|
|
try {
|
|
|
- QwUploadResult result = qwApiService.upload(new File(""), "video", qwFriendWelcomeParam.getCorpId());
|
|
|
- if (result.getErrCode()==0) {
|
|
|
- attachment.getVideo().setMedia_id(result.getMediaId());
|
|
|
- }else {
|
|
|
- return R.error("视频上传失败:"+result.getErrMsg());
|
|
|
- }
|
|
|
+ uploadVideo(qwApiService, attachment, corpId);
|
|
|
+ } catch (BaseException e) {
|
|
|
+ return R.error(e.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("视频上传出错:"+e);
|
|
|
+ return R.error("视频上传出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (attachment.getMsgtype().equals("link")){
|
|
|
+ if (attachment.getMsgtype().equals("link")) {
|
|
|
String LinkPicUrl = attachment.getLink().getPicurl();
|
|
|
- if (LinkPicUrl!=null && !LinkPicUrl.isEmpty()){
|
|
|
+ if (LinkPicUrl != null && !LinkPicUrl.isEmpty()) {
|
|
|
try {
|
|
|
QwUploadImgResult uploadimg = qwApiService.uploadimgs(LinkPicUrl, qwFriendWelcomeParam.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0){
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getLink().setPicurl(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("图片link上传失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("图片link上传失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("图片link上传出错:"+e);
|
|
|
+ return R.error("图片link上传出错:" + e);
|
|
|
// throw new RuntimeException("insertQwFriendWelcomeVO-attachment/link:"+e);
|
|
|
}
|
|
|
}
|
|
@@ -165,50 +161,50 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
qwFriendWelcomeParam.setAttachments(JSON.toJSONString(attachmentsAll));
|
|
|
}
|
|
|
|
|
|
- if (qwFriendWelcomeParam.getIsDayparting()==1){
|
|
|
+ if (qwFriendWelcomeParam.getIsDayparting() == 1) {
|
|
|
List<QwFriendWelcomeDayPart.Schedule> schedules = JSON.parseArray(qwFriendWelcomeParam.getDaypartingItemlist(), QwFriendWelcomeDayPart.Schedule.class);
|
|
|
- if(schedules!=null && !schedules.isEmpty()){
|
|
|
+ if (schedules != null && !schedules.isEmpty()) {
|
|
|
|
|
|
for (QwFriendWelcomeDayPart.Schedule schedule : schedules) {
|
|
|
-
|
|
|
- for (SendWelcomeMsgParam.Attachment attachment: schedule.getAttachments() ) {
|
|
|
- if (attachment.getMsgtype().equals("image")){
|
|
|
+ String corpId = qwFriendWelcomeParam.getCorpId();
|
|
|
+ for (SendWelcomeMsgParam.Attachment attachment : schedule.getAttachments()) {
|
|
|
+ if (attachment.getMsgtype().equals("image")) {
|
|
|
try {
|
|
|
- QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), qwFriendWelcomeParam.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0) {
|
|
|
+ QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), corpId);
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getImage().setPic_url(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("分时段图片image上传失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("分时段图片image上传失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("分时段图片image上传出错:"+e);
|
|
|
+ return R.error("分时段图片image上传出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
- if (attachment.getMsgtype().equals("video")){
|
|
|
+ if (attachment.getMsgtype().equals("video")) {
|
|
|
+ if(!video){
|
|
|
+ video = true;
|
|
|
+ }
|
|
|
try {
|
|
|
- QwUploadResult result = qwApiService.upload(new File(""), "video", qwFriendWelcomeParam.getCorpId());
|
|
|
- if (result.getErrCode()==0) {
|
|
|
- attachment.getVideo().setMedia_id(result.getMediaId());
|
|
|
- }else {
|
|
|
- return R.error("视频上传失败:"+result.getErrMsg());
|
|
|
- }
|
|
|
+ uploadVideo(qwApiService, attachment, corpId);
|
|
|
+ } catch (BaseException e) {
|
|
|
+ return R.error(e.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("视频上传出错:"+e);
|
|
|
+ return R.error("视频上传出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
- if (attachment.getMsgtype().equals("link")){
|
|
|
+ if (attachment.getMsgtype().equals("link")) {
|
|
|
String linkPicurl = attachment.getLink().getPicurl();
|
|
|
- if (linkPicurl!=null && !linkPicurl.isEmpty()){
|
|
|
+ if (linkPicurl != null && !linkPicurl.isEmpty()) {
|
|
|
try {
|
|
|
- QwUploadImgResult uploadimg = qwApiService.uploadimgs(linkPicurl, qwFriendWelcomeParam.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0){
|
|
|
+ QwUploadImgResult uploadimg = qwApiService.uploadimgs(linkPicurl, corpId);
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getLink().setPicurl(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("分时段图片link上传失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("分时段图片link上传失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("分时段图片link上传出错:"+e);
|
|
|
+ return R.error("分时段图片link上传出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -218,16 +214,27 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
}
|
|
|
qwFriendWelcomeParam.setDaypartingItemlist(JSON.toJSONString(schedules));
|
|
|
}
|
|
|
-
|
|
|
int i = qwFriendWelcomeMapper.insertQwFriendWelcomeVO(qwFriendWelcomeParam);
|
|
|
- if (i>0){
|
|
|
+ if(video){
|
|
|
+ redisCache.setCacheObject(FsConstants.FRIEND_WELCOME_VIDEO_KEY + qwFriendWelcomeParam.getId(), qwFriendWelcomeParam.getId(), 60, TimeUnit.HOURS);
|
|
|
+ }
|
|
|
+ if (i > 0) {
|
|
|
return R.ok("新增成功");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return R.error("新增失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static void uploadVideo(QwApiService qwApiService, SendWelcomeMsgParam.Attachment attachment, String corpId) throws Exception {
|
|
|
+ QwUploadResult result = qwApiService.upload(urlToFile(attachment.getVideo().getUrl()), "video", corpId);
|
|
|
+ if (result.getErrCode() == 0) {
|
|
|
+ attachment.getVideo().setMedia_id(result.getMediaId());
|
|
|
+ } else {
|
|
|
+ throw new BaseException("视频上传失败:" + result.getErrMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改好友欢迎语
|
|
|
*
|
|
@@ -235,44 +242,55 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public R updateQwFriendWelcome(QwFriendWelcome qwFriendWelcome)
|
|
|
- {
|
|
|
+ public R updateQwFriendWelcome(QwFriendWelcome qwFriendWelcome) {
|
|
|
List<SendWelcomeMsgParam.Attachment> attachmentsAll = JSON.parseArray(qwFriendWelcome.getAttachments(), SendWelcomeMsgParam.Attachment.class);
|
|
|
-
|
|
|
- if(attachmentsAll!=null && !attachmentsAll.isEmpty()){
|
|
|
+ boolean video = false;
|
|
|
+ if (attachmentsAll != null && !attachmentsAll.isEmpty()) {
|
|
|
|
|
|
for (SendWelcomeMsgParam.Attachment attachment : attachmentsAll) {
|
|
|
+ String corpId = qwFriendWelcome.getCorpId();
|
|
|
+ if (attachment.getMsgtype().equals("image") && !attachment.getImage().getPic_url().contains("https://wework.qpic.cn")) {
|
|
|
|
|
|
- if (attachment.getMsgtype().equals("image")&&!attachment.getImage().getPic_url().contains("https://wework.qpic.cn")){
|
|
|
-
|
|
|
- try {
|
|
|
- QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), qwFriendWelcome.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0){
|
|
|
- attachment.getImage().setPic_url(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("上传好友欢迎语图片image失败:"+uploadimg.getErrMsg());
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- return R.error("上传好友欢迎语图片出错:"+e);
|
|
|
+ try {
|
|
|
+ QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), corpId);
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
+ attachment.getImage().setPic_url(uploadimg.getUrl());
|
|
|
+ } else {
|
|
|
+ return R.error("上传好友欢迎语图片image失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("上传好友欢迎语图片出错:" + e);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
+ if (attachment.getMsgtype().equals("video")) {
|
|
|
+ if(!video){
|
|
|
+ video = true;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ uploadVideo(qwApiService, attachment, corpId);
|
|
|
+ } catch (BaseException e) {
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("视频上传出错:" + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (attachment.getMsgtype().equals("link")){
|
|
|
+ if (attachment.getMsgtype().equals("link")) {
|
|
|
String LinkPicUrl = attachment.getLink().getPicurl();
|
|
|
- if (LinkPicUrl!=null && !LinkPicUrl.isEmpty()&&!LinkPicUrl.contains("https://wework.qpic.cn")){
|
|
|
+ if (LinkPicUrl != null && !LinkPicUrl.isEmpty() && !LinkPicUrl.contains("https://wework.qpic.cn")) {
|
|
|
try {
|
|
|
- QwUploadImgResult uploadimg = qwApiService.uploadimgs(LinkPicUrl, qwFriendWelcome.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0){
|
|
|
+ QwUploadImgResult uploadimg = qwApiService.uploadimgs(LinkPicUrl, corpId);
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getLink().setPicurl(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("上传好友欢迎语图片link失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("上传好友欢迎语图片link失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("上传好友欢迎语图片link出错:"+e);
|
|
|
+ return R.error("上传好友欢迎语图片link出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -282,38 +300,50 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
qwFriendWelcome.setAttachments(JSON.toJSONString(attachmentsAll));
|
|
|
}
|
|
|
|
|
|
- if (qwFriendWelcome.getIsDayparting().equals("1")){
|
|
|
+ if (qwFriendWelcome.getIsDayparting().equals("1")) {
|
|
|
List<QwFriendWelcomeDayPart.Schedule> schedules = JSON.parseArray(qwFriendWelcome.getDaypartingItemlist(), QwFriendWelcomeDayPart.Schedule.class);
|
|
|
- if(schedules!=null && !schedules.isEmpty()){
|
|
|
+ if (schedules != null && !schedules.isEmpty()) {
|
|
|
|
|
|
for (QwFriendWelcomeDayPart.Schedule schedule : schedules) {
|
|
|
-
|
|
|
- for(SendWelcomeMsgParam.Attachment attachment:schedule.getAttachments()){
|
|
|
- if (attachment.getMsgtype().equals("image")&&!attachment.getImage().getPic_url().contains("https://wework.qpic.cn")){
|
|
|
+ String corpId = qwFriendWelcome.getCorpId();
|
|
|
+ for (SendWelcomeMsgParam.Attachment attachment : schedule.getAttachments()) {
|
|
|
+ if (attachment.getMsgtype().equals("image") && !attachment.getImage().getPic_url().contains("https://wework.qpic.cn")) {
|
|
|
try {
|
|
|
- QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), qwFriendWelcome.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0){
|
|
|
+ QwUploadImgResult uploadimg = qwApiService.uploadimgs(attachment.getImage().getPic_url(), corpId);
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getImage().setPic_url(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("上传分时段好友欢迎语图片image失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("上传分时段好友欢迎语图片image失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("上传分时段好友欢迎语图片image出错:"+e);
|
|
|
+ return R.error("上传分时段好友欢迎语图片image出错:" + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (attachment.getMsgtype().equals("video")) {
|
|
|
+ if(!video){
|
|
|
+ video = true;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ uploadVideo(qwApiService, attachment, corpId);
|
|
|
+ } catch (BaseException e) {
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("视频上传出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
- if (attachment.getMsgtype().equals("link")){
|
|
|
+ if (attachment.getMsgtype().equals("link")) {
|
|
|
String linkPicurl = attachment.getLink().getPicurl();
|
|
|
- if (linkPicurl!=null && !linkPicurl.isEmpty()&&!linkPicurl.contains("https://wework.qpic.cn")){
|
|
|
+ if (linkPicurl != null && !linkPicurl.isEmpty() && !linkPicurl.contains("https://wework.qpic.cn")) {
|
|
|
try {
|
|
|
- QwUploadImgResult uploadimg = qwApiService.uploadimgs(linkPicurl, qwFriendWelcome.getCorpId());
|
|
|
- if (uploadimg.getErrcode()==0){
|
|
|
+ QwUploadImgResult uploadimg = qwApiService.uploadimgs(linkPicurl, corpId);
|
|
|
+ if (uploadimg.getErrcode() == 0) {
|
|
|
attachment.getLink().setPicurl(uploadimg.getUrl());
|
|
|
- }else {
|
|
|
- return R.error("上传分时段好友欢迎语图片link失败:"+uploadimg.getErrMsg());
|
|
|
+ } else {
|
|
|
+ return R.error("上传分时段好友欢迎语图片link失败:" + uploadimg.getErrMsg());
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- return R.error("上传分时段好友欢迎语图片link出错:"+ e);
|
|
|
+ return R.error("上传分时段好友欢迎语图片link出错:" + e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -323,7 +353,11 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
}
|
|
|
qwFriendWelcome.setDaypartingItemlist(JSON.toJSONString(schedules));
|
|
|
}
|
|
|
-
|
|
|
+ String key = FsConstants.FRIEND_WELCOME_VIDEO_KEY + qwFriendWelcome.getId();
|
|
|
+ redisCache.deleteObject(key);
|
|
|
+ if(video){
|
|
|
+ redisCache.setCacheObject(key, qwFriendWelcome.getId(), 60, TimeUnit.HOURS);
|
|
|
+ }
|
|
|
return R.ok().put("msg", qwFriendWelcomeMapper.updateQwFriendWelcome(qwFriendWelcome));
|
|
|
}
|
|
|
|
|
@@ -334,8 +368,7 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteQwFriendWelcomeByIds(Long[] ids)
|
|
|
- {
|
|
|
+ public int deleteQwFriendWelcomeByIds(Long[] ids) {
|
|
|
return qwFriendWelcomeMapper.deleteQwFriendWelcomeByIds(ids);
|
|
|
}
|
|
|
|
|
@@ -346,24 +379,23 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteQwFriendWelcomeById(Long id)
|
|
|
- {
|
|
|
+ public int deleteQwFriendWelcomeById(Long id) {
|
|
|
return qwFriendWelcomeMapper.deleteQwFriendWelcomeById(id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * url转临时文件filr
|
|
|
+ * url转临时文件filr
|
|
|
*/
|
|
|
public static File urlToFile(String fileUrl) throws Exception {
|
|
|
|
|
|
// 从URL中提取文件名,文件后缀
|
|
|
String fileExtension = getFileExtension(new File(fileUrl).getName());
|
|
|
- String fileName = extractFileName(new URL(fileUrl))+new Date().getTime();
|
|
|
- File tempFile=null;
|
|
|
- if (!StringUtil.strIsNullOrEmpty(fileExtension)){
|
|
|
+ String fileName = extractFileName(new URL(fileUrl)) + new Date().getTime();
|
|
|
+ File tempFile = null;
|
|
|
+ if (!StringUtil.strIsNullOrEmpty(fileExtension)) {
|
|
|
// 创建一个临时文件
|
|
|
- tempFile = File.createTempFile(fileName, "."+fileExtension);
|
|
|
- }else {
|
|
|
+ tempFile = File.createTempFile(fileName, "." + fileExtension);
|
|
|
+ } else {
|
|
|
tempFile = File.createTempFile(fileName, null);
|
|
|
}
|
|
|
|
|
@@ -388,8 +420,9 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
|
|
|
return tempFile;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 获取文件名
|
|
|
+ * 获取文件名
|
|
|
*/
|
|
|
private static String extractFileName(URL url) throws Exception {
|
|
|
String path = url.getPath();
|
|
@@ -410,7 +443,7 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取文件名后缀
|
|
|
+ * 获取文件名后缀
|
|
|
*/
|
|
|
|
|
|
public static String getFileExtension(String fileName) {
|
|
@@ -421,5 +454,6 @@ public class QwFriendWelcomeServiceImpl implements IQwFriendWelcomeService
|
|
|
return ""; // 如果没有扩展名,返回空字符串
|
|
|
}
|
|
|
|
|
|
- public static void uploadFileImage(MultipartFile file, String filePath){}
|
|
|
+ public static void uploadFileImage(MultipartFile file, String filePath) {
|
|
|
+ }
|
|
|
}
|