线索信息+ oss sts + 添加标签
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.request.AddTagsRequest;
|
||||
import com.cool.store.request.LineListRequest;
|
||||
import com.cool.store.vo.LineInfoVO;
|
||||
import com.cool.store.vo.LineListVO;
|
||||
@@ -31,4 +32,12 @@ public interface LineService {
|
||||
PageInfo<LineListVO> getLineList(LineListRequest lineListRequest, LoginUserInfo loginUserInfo,Boolean teamFlag);
|
||||
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
* @param userInfo
|
||||
* @param addTagsRequest
|
||||
* @return
|
||||
*/
|
||||
Boolean addTags(LoginUserInfo userInfo, AddTagsRequest addTagsRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.vo.oss.OssUploadConfigVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2024/3/28 14:27
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface OSSService {
|
||||
/**
|
||||
* 上传文件
|
||||
* @return
|
||||
*/
|
||||
OssUploadConfigVO getUploadFileConfig();
|
||||
}
|
||||
@@ -1,32 +1,38 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.HyOpenAreaInfoDAO;
|
||||
import com.cool.store.dao.HyPartnerUserChannelDAO;
|
||||
import com.cool.store.dao.LineInfoDAO;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.HyOpenAreaInfoDO;
|
||||
import com.cool.store.entity.HyPartnerLabelDO;
|
||||
import com.cool.store.entity.LineInfoDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.OperateTypeEnum;
|
||||
import com.cool.store.enums.WorkflowStageEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.RegionMapper;
|
||||
import com.cool.store.request.AddTagsRequest;
|
||||
import com.cool.store.request.LineListRequest;
|
||||
import com.cool.store.service.DeskService;
|
||||
import com.cool.store.service.LineService;
|
||||
import com.cool.store.service.RegionService;
|
||||
import com.cool.store.utils.CoolDateUtils;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.utils.poi.DateUtils;
|
||||
import com.cool.store.vo.BaseInfoVO;
|
||||
import com.cool.store.vo.LineInfoVO;
|
||||
import com.cool.store.vo.LineListVO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -47,6 +53,10 @@ public class LineServiceImpl implements LineService {
|
||||
HyPartnerUserChannelDAO hyPartnerUserChannelDAO;
|
||||
@Resource
|
||||
EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
RegionService regionService;
|
||||
@Resource
|
||||
RegionDao regionDao;
|
||||
|
||||
@Override
|
||||
public LineInfoVO getLineInfo(Long lineId) {
|
||||
@@ -56,6 +66,28 @@ public class LineServiceImpl implements LineService {
|
||||
if (lineInfo==null){
|
||||
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
|
||||
}
|
||||
if (lineInfo.getLineSource()!=null){
|
||||
Map<Integer, String> channelMapByIds = hyPartnerUserChannelDAO.getChannelMapByIds(Arrays.asList(lineInfo.getLineSource()));
|
||||
result.setLineSourceName(channelMapByIds.get(lineInfo.getLineSource()));
|
||||
}
|
||||
if (StringUtil.isNotEmpty(lineInfo.getInvestmentManager())){
|
||||
EnterpriseUserDO user = enterpriseUserDAO.getUserInfoById(lineInfo.getInvestmentManager());
|
||||
result.setInvestmentManagerName(user.getName());
|
||||
result.setInvestmentManagerMobile(user.getMobile());
|
||||
}
|
||||
if(lineInfo.getRegionId()!=null){
|
||||
Long bigRegionIdByAreaId = regionService.getBigRegionIdByAreaId(lineInfo.getWantShopAreaId());
|
||||
Map<Long, String> regionNameMap = regionDao.getRegionNameMap(Arrays.asList(bigRegionIdByAreaId, lineInfo.getRegionId()));
|
||||
result.setRegionId(lineInfo.getRegionId());
|
||||
result.setRegionName(regionNameMap.get(lineInfo.getRegionId()));
|
||||
result.setLargeRegionId(bigRegionIdByAreaId);
|
||||
result.setLargeRegionName(regionNameMap.get(bigRegionIdByAreaId));
|
||||
}
|
||||
Map<Long, HyPartnerLabelDO> userPortraitMap = deskService.getUserPortraitMap(Arrays.asList(lineInfo));
|
||||
Map<Long, String> wantShopAreaMap = hyOpenAreaInfoDAO.selectNameMapByIds(Arrays.asList(lineInfo.getWantShopAreaId()));
|
||||
BaseInfoVO baseInfoVO = deskService.convertToBaseInfoVO(lineInfo, userPortraitMap, wantShopAreaMap);
|
||||
result.setWantShopAreaName(baseInfoVO.getWantShopAreaName());
|
||||
result.setUserPortraitList(baseInfoVO.getUserPortraitList());
|
||||
BeanUtil.copyProperties(lineInfo,result);
|
||||
return result;
|
||||
}
|
||||
@@ -90,4 +122,18 @@ public class LineServiceImpl implements LineService {
|
||||
page.setList(result);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addTags(LoginUserInfo user, AddTagsRequest addTagsRequest) {
|
||||
LineInfoDO lineInfo = lineInfoDAO.getLineInfo(addTagsRequest.getLineId());
|
||||
if (lineInfo==null){
|
||||
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
|
||||
}
|
||||
|
||||
lineInfo.setUserPortrait(CollectionUtils.isNotEmpty(addTagsRequest.getTags())?
|
||||
addTagsRequest.getTags().stream().map(Object::toString).collect(Collectors.joining(CommonConstants.COMMA, CommonConstants.COMMA, CommonConstants.COMMA)):"");
|
||||
lineInfoDAO.updateLineInfo(lineInfo);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.common.utils.BinaryUtil;
|
||||
import com.aliyun.oss.model.MatchMode;
|
||||
import com.aliyun.oss.model.PolicyConditions;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.OSSService;
|
||||
import com.cool.store.vo.oss.OssUploadConfigVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author suzhuhong
|
||||
* @Date 2024/3/28 14:29
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OSSServiceImpl implements OSSService {
|
||||
|
||||
@Value("${oss.accessKeyId:null}")
|
||||
private String accessKeyId;
|
||||
@Value("${oss.accessKeySecret:null}")
|
||||
private String accessKeySecret;
|
||||
@Value("${oss.endpoint:null}")
|
||||
private String endpoint;
|
||||
@Value("${oss.bucket:null}")
|
||||
private String bucket;
|
||||
@Value("${cdn.url:null}")
|
||||
private String cdnUrl;
|
||||
@Value("${oss.file.dir:null}")
|
||||
private String dir;
|
||||
|
||||
@Override
|
||||
public OssUploadConfigVO getUploadFileConfig() {
|
||||
// host的格式为 bucketname.endpoint
|
||||
String host = "https://" + bucket + "." + endpoint;
|
||||
OSS client = null;
|
||||
try {
|
||||
client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
long expireTime = 300;
|
||||
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
||||
Date expiration = new Date(expireEndTime);
|
||||
PolicyConditions policyConds = new PolicyConditions();
|
||||
policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
|
||||
policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
|
||||
String postPolicy = client.generatePostPolicy(expiration, policyConds);
|
||||
byte[] binaryData = postPolicy.getBytes("utf-8");
|
||||
String encodedPolicy = BinaryUtil.toBase64String(binaryData);
|
||||
String signature = client.calculatePostSignature(postPolicy);
|
||||
OssUploadConfigVO result = new OssUploadConfigVO(accessKeyId, encodedPolicy, signature, dir, host, String.valueOf(expireEndTime / 1000), cdnUrl);
|
||||
return result;
|
||||
}catch (Exception e){
|
||||
log.info("exception", e);
|
||||
throw new ServiceException(ErrorCodeEnum.GET_INFO_ERROR);
|
||||
}finally {
|
||||
if(Objects.nonNull(client)){
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user