| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | |
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.FileUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | |
|
| | | import net.coobird.thumbnailator.Thumbnails;
|
| | |
|
| | | @Service
|
| | | public class UserInfoExtraServiceImpl implements UserInfoExtraService {
|
| | |
| | | new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip, new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void uploadERCode(MultipartFile file, Long uid) {
|
| | | UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | if (extra == null)
|
| | | return;
|
| | | |
| | | // 压缩
|
| | | String targetPath = FileUtil.getCacheDir() + "/erCode_" + uid + "_" + System.currentTimeMillis()+ ".jpg";
|
| | | try {
|
| | | Thumbnails.of(file.getInputStream()).size(200, 200).toFile(targetPath);
|
| | | } catch (IOException e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | return;
|
| | | }
|
| | | |
| | | // 执行上传
|
| | | String filePath = "/img/user/erCode/" + UUID.randomUUID().toString().replace("-", "") + ".jpg";
|
| | | String fileLink = COSManager.getInstance().uploadFile(new File(targetPath), filePath).getUrl();
|
| | | |
| | | // 删除本地图片
|
| | | if (new File(targetPath).exists()) {
|
| | | new File(targetPath).delete();
|
| | | }
|
| | |
|
| | | // 原二维码
|
| | | String erCode = extra.getErCode();
|
| | | |
| | | UserInfoExtra update = new UserInfoExtra();
|
| | | update.setId(extra.getId());
|
| | | update.setErCode(fileLink);
|
| | | userInfoExtraMapper.updateByPrimaryKeySelective(update);
|
| | |
|
| | | // 原二维码
|
| | | if (!StringUtil.isNullOrEmpty(erCode)) {
|
| | | COSManager.getInstance().deleteFile(erCode);
|
| | | }
|
| | | }
|
| | | }
|