【7.0.4】【file】更新默认头像的预览

pull/22/head
fengshuonan 2021-06-09 17:35:02 +08:00
parent da0e01cb86
commit 5f9ab39b66
5 changed files with 26 additions and 6 deletions

View File

@ -82,6 +82,11 @@ public interface FileConstants {
*/
Long DEFAULT_AVATAR_FILE_ID = 10000L;
/**
*
*/
String DEFAULT_AVATAR_FILE_OBJ_NAME = "defaultAvatar.png";
/**
*
*/

View File

@ -81,7 +81,7 @@ public enum FileExceptionEnum implements AbstractExceptionEnum {
/**
*
*/
FILE_STREAM_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "09", "获取文件流错误"),
FILE_STREAM_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "09", "获取文件流异常,具体信息为:{}"),
/**
*

View File

@ -107,7 +107,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
fileBytes = fileOperatorApi.getFileBytes(DEFAULT_BUCKET_NAME, sysFileInfo.getFileObjectName());
} catch (Exception e) {
log.error("获取文件流异常,具体信息为:{}", e.getMessage());
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR);
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR, e.getMessage());
}
// 设置文件字节码
@ -249,7 +249,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
DownloadUtil.download(DateUtil.now() + "-打包下载" + FILE_POSTFIX_SEPARATOR + "zip", bos.toByteArray(), response);
} catch (Exception e) {
log.error("获取文件流异常,具体信息为:{}", e.getMessage());
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR);
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR, e.getMessage());
} finally {
try {
zip.closeEntry();
@ -330,13 +330,19 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
@Override
public void previewByBucketAndObjName(SysFileInfoRequest sysFileInfoRequest, HttpServletResponse response) {
// 如果是默认头像
if (FileConstants.DEFAULT_AVATAR_FILE_OBJ_NAME.equals(sysFileInfoRequest.getFileObjectName())) {
DownloadUtil.renderPreviewFile(response, Base64.decode(FileConfigExpander.getDefaultAvatarBase64()));
return;
}
// 获取文件字节码
byte[] fileBytes;
try {
fileBytes = fileOperatorApi.getFileBytes(sysFileInfoRequest.getFileBucket(), sysFileInfoRequest.getFileObjectName());
} catch (Exception e) {
log.error("获取文件流异常,具体信息为:{}", e.getMessage());
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR);
throw new FileException(FileExceptionEnum.FILE_STREAM_ERROR, e.getMessage());
}
// 获取文件后缀

View File

@ -40,6 +40,14 @@
<version>${roses.version}</version>
</dependency>
<!--文件api-->
<!--文件上传,头像上传-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>file-api</artifactId>
<version>${roses.version}</version>
</dependency>
<!--资源api模块-->
<!--用在资源控制器,资源扫描上-->
<dependency>

View File

@ -10,6 +10,7 @@ import cn.stylefeng.roses.kernel.customer.api.expander.CustomerConfigExpander;
import cn.stylefeng.roses.kernel.customer.modular.entity.Customer;
import cn.stylefeng.roses.kernel.customer.modular.request.CustomerRequest;
import cn.stylefeng.roses.kernel.email.api.pojo.SendMailParam;
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
@ -53,8 +54,8 @@ public class CustomerFactory {
customer.setVerifiedFlag(YesOrNotEnum.N.getCode());
// 设置默认头像
customer.setAvatar(10000L);
customer.setAvatarObjectName("10000.png");
customer.setAvatar(FileConstants.DEFAULT_AVATAR_FILE_ID);
customer.setAvatarObjectName(FileConstants.DEFAULT_AVATAR_FILE_OBJ_NAME);
// 设置默认积分0
customer.setScore(0);