Browse Source

二维码下载路径问题

master
sunyuchao 5 years ago
parent
commit
b444117e4a
  1. 9
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java
  2. 19
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java

9
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java

@ -11,4 +11,13 @@ public interface GroupCodeConstant {
* 群二维码类型-邀请
*/
String CODE_TYPE_INVITE = "invite";
/**
* aliyun图片地址域名对应正则表达式
*/
String PATTERN = "^((http://)|(https://))?([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(/)";
/**
* 供前端下载图片jenkins转发前缀
*/
String STORAGE = "/storage/";
}

19
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java

@ -23,19 +23,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.result.CustomerTokensResultDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.modules.group.dao.ResiGroupCodeDao;
import com.epmet.modules.group.entity.ResiGroupCodeEntity;
@ -63,7 +57,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
/**
@ -277,6 +273,7 @@ public class ResiGroupCodeServiceImpl extends BaseServiceImpl<ResiGroupCodeDao,
*/
@Override
public GroupCodeBasicInfoResultDTO groupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO) {
String url = "";
//1.获取小组基本信息
GroupCodeBasicInfoResultDTO resultDTO = baseDao.selectGroupCodeBasicInfo(formDTO);
if (null == resultDTO) {
@ -286,13 +283,17 @@ public class ResiGroupCodeServiceImpl extends BaseServiceImpl<ResiGroupCodeDao,
if (null == resultDTO.getGroupCodeUrl() || "".equals(resultDTO.getGroupCodeUrl())) {
CreateGroupCodeFormDTO dto = ConvertUtils.sourceToTarget(formDTO, CreateGroupCodeFormDTO.class);
dto.setType(GroupCodeConstant.CODE_TYPE_INVITE);
String url = createGroupCode(dto, true);
url = createGroupCode(dto, true);
if (StringUtils.isBlank(url)) {
logger.error(String.format("生成小组二维码失败,小组Id:%s", formDTO.getGroupId()));
throw new RenException("获取小组码基本信息失败");
}
resultDTO.setGroupCodeUrl(url);
}else {
url = resultDTO.getGroupCodeUrl();
}
//2.图片的url只截取相对路径供前端使用
resultDTO.setGroupCodeUrl(url.replaceAll(GroupCodeConstant.PATTERN, GroupCodeConstant.STORAGE));
return resultDTO;
}

Loading…
Cancel
Save