Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pancaihua 2024-08-08 15:27:26 +08:00
commit d06a1a9c10
24 changed files with 538 additions and 17 deletions

View File

@ -87,5 +87,7 @@ public interface ErrorCodeConstants {
ErrorCode COMMENT_NOT_EXISTS = new ErrorCode(1_009_017_000, "评论不存在");
// ========== 我的收藏 1_009_018_000
ErrorCode STAR2_NOT_EXISTS = new ErrorCode(1_009_018_000, "收藏不存在");
// ========== 点赞管理 我的收藏 1_009_019_000 ==========
ErrorCode TBUP_NOT_EXISTS = new ErrorCode( 1_009_019_000, "点赞不存在");
}

View File

@ -31,7 +31,8 @@ public class KnowledgePageReqVO extends PageParam {
private String status;
@Schema(description = "文件路径")
private String filePath;
// private String filePath;
private String[] filePath;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)

View File

@ -54,7 +54,8 @@ public class KnowledgeRespVO {
@Schema(description = "文件路径")
@ExcelProperty("文件路径")
private String filePath;
// private String filePath;
private String[] filePath;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.controller.admin.knows.vo;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -38,7 +39,8 @@ public class KnowledgeSaveReqVO {
@Schema(description = "文件路径")
private String[] filePath;
// private List<String> filePath;
// private List<JSONObject> filePath;
// private List<String> filePath;
@Schema(description = "评论列表")

View File

@ -0,0 +1,125 @@
package cn.iocoder.yudao.module.bpm.controller.admin.tbup;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.bpm.convert.star2.Star2Convert;
import cn.iocoder.yudao.module.bpm.convert.tbup.TbupConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgeDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowtypeDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.star2.Star2DO;
import cn.iocoder.yudao.module.bpm.service.knows.KnowledgeService;
import cn.iocoder.yudao.module.bpm.service.knows.KnowtypeService;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tbup.TbupDO;
import cn.iocoder.yudao.module.bpm.service.tbup.TbupService;
@Tag(name = "管理后台 - 点赞管理")
@RestController
@RequestMapping("/bpm/tbup")
@Validated
public class TbupController {
@Resource
private TbupService tbupService;
@Resource
private KnowledgeService knowledgeService;
@Resource
private KnowtypeService knowtypeService;
@Resource
private AdminUserApi adminUserApi;
@PostMapping("/create")
@Operation(summary = "创建点赞管理")
@PreAuthorize("@ss.hasPermission('bpm:tbup:create')")
public CommonResult<Long> createTbup(@Valid @RequestBody TbupSaveReqVO createReqVO) {
return success(tbupService.createTbup(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新点赞管理")
@PreAuthorize("@ss.hasPermission('bpm:tbup:update')")
public CommonResult<Boolean> updateTbup(@Valid @RequestBody TbupSaveReqVO updateReqVO) {
tbupService.updateTbup(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除点赞管理")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('bpm:tbup:delete')")
public CommonResult<Boolean> deleteTbup(@RequestParam("id") Long id) {
tbupService.deleteTbup(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得点赞管理")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('bpm:tbup:query')")
public CommonResult<TbupRespVO> getTbup(@RequestParam("id") Long id) {
TbupDO tbup = tbupService.getTbup(id);
return success(BeanUtils.toBean(tbup, TbupRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得点赞管理分页")
@PreAuthorize("@ss.hasPermission('bpm:tbup:query')")
public CommonResult<PageResult<TbupRespVO>> getTbupPage(@Valid TbupPageReqVO pageReqVO) {
PageResult<TbupDO> pageResult = tbupService.getTbupPage(pageReqVO);
if (CollUtil.isEmpty(pageResult.getList())) {
return success(new PageResult<>(pageResult.getTotal()));
}
Map<Long, KnowtypeDO> knowTypeMap = knowtypeService.getKnowtypeMap(
convertList(pageResult.getList(), TbupDO::getKowsId)
);
Map<Long, AdminUserRespDTO> AdminUserMap = adminUserApi.getUserMap(
convertList(pageResult.getList(),TbupDO::getUserId)
);
Map<Long, KnowledgeDO> KnowledgeMap = knowledgeService.getKnowledgeMap(
convertList(pageResult.getList(),TbupDO::getKowsmId)
);
return success(new PageResult<>(TbupConvert.INSTANCE.convertList(pageResult.getList(),knowTypeMap,AdminUserMap,KnowledgeMap),pageResult.getTotal() ));
}
@GetMapping("/export-excel")
@Operation(summary = "导出点赞管理 Excel")
@PreAuthorize("@ss.hasPermission('bpm:tbup:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportTbupExcel(@Valid TbupPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<TbupDO> list = tbupService.getTbupPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "点赞管理.xls", "数据", TbupRespVO.class,
BeanUtils.toBean(list, TbupRespVO.class));
}
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 点赞管理分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TbupPageReqVO extends PageParam {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16811")
private Long id;
@Schema(description = "知识id", example = "21594")
private Long kowsmId;
@Schema(description = "用户id", example = "15290")
private Long userId;
@Schema(description = "知识分类id", example = "17885")
private Long kowsId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 点赞管理 Response VO")
@Data
@ExcelIgnoreUnannotated
public class TbupRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26396")
@ExcelProperty("id")
private Long id;
@Schema(description = "知识id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21594")
@ExcelProperty("知识id")
private Long kowsmId;
@Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15290")
@ExcelProperty("用户id")
private Long userId;
@Schema(description = "作者名称", example = "张三")
@ExcelProperty("作者名称")
private String nickName;
@Schema(description = "知识类别标题", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("知识类别标题")
private String kowTitle;
@Schema(description = "知识标题", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("知识标题")
private String kowsmTitle;
@Schema(description = "知识分类id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17885")
@ExcelProperty("知识分类id")
private Long kowsId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 点赞管理新增/修改 Request VO")
@Data
public class TbupSaveReqVO {
@Schema(description = "id", example = "16811")
private Long id;
@Schema(description = "知识id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21594")
@NotNull(message = "知识id不能为空")
private Long kowsmId;
@Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15290")
@NotNull(message = "用户id不能为空")
private Long userId;
@Schema(description = "知识分类id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17885")
@NotNull(message = "知识分类id不能为空")
private Long kowsId;
}

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.bpm.convert.tbup;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.star2.vo.Star2RespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo.TbupRespVO;
import cn.iocoder.yudao.module.bpm.convert.star2.Star2Convert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgeDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowtypeDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.star2.Star2DO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tbup.TbupDO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Mapper
public interface TbupConvert {
TbupConvert INSTANCE = Mappers.getMapper(TbupConvert.class);
default List<TbupRespVO> convertList(List<TbupDO> list, Map<Long, KnowtypeDO> knowTypeMap, Map<Long, AdminUserRespDTO> AdminUserMap, Map<Long, KnowledgeDO> KnowledgeMap){
return list.stream().map(tbup -> {
KnowtypeDO knowtypeDO = knowTypeMap.get(tbup.getKowsId());
AdminUserRespDTO adminUserDO = AdminUserMap.get(tbup.getUserId());
KnowledgeDO knowledgeDO = KnowledgeMap.get(tbup.getKowsmId());
return convert(tbup,knowtypeDO,adminUserDO,knowledgeDO);
}).collect(Collectors.toList());
}
default TbupRespVO convert(TbupDO tbUp, KnowtypeDO knowType, AdminUserRespDTO user,KnowledgeDO knowledge){
TbupRespVO tbUpVO = BeanUtils.toBean(tbUp, TbupRespVO.class);
if (knowType != null){
tbUpVO.setKowTitle(knowType.getName());
}
if (user != null){
tbUpVO.setNickName(user.getNickname());
}
if (knowledge != null){
tbUpVO.setKowsmTitle(knowledge.getKnowTitle());
}
return tbUpVO;
}
}

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.tbup;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 点赞管理 DO
*
* @author 君风
*/
@TableName("des_tbup")
@KeySequence("des_tbup_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TbupDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 知识id
*/
private Long kowsmId;
/**
* 用户id
*/
private Long userId;
/**
* 知识分类id
*/
private Long kowsId;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.bpm.dal.mysql.tbup;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tbup.TbupDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo.*;
/**
* 点赞管理 Mapper
*
* @author 君风
*/
@Mapper
public interface TbupMapper extends BaseMapperX<TbupDO> {
default PageResult<TbupDO> selectPage(TbupPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<TbupDO>()
.eqIfPresent(TbupDO::getId,reqVO.getId())
.eqIfPresent(TbupDO::getKowsmId, reqVO.getKowsmId())
.eqIfPresent(TbupDO::getUserId, reqVO.getUserId())
.eqIfPresent(TbupDO::getKowsId, reqVO.getKowsId())
.betweenIfPresent(TbupDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(TbupDO::getId));
}
}

View File

@ -41,7 +41,7 @@ public class Star2ServiceImpl implements Star2Service {
@Override
public void updateStar2(Star2SaveReqVO updateReqVO) {
// 校验存在
validateStar2Exists(updateReqVO.getKowsId());
validateStar2Exists(updateReqVO.getId());
// 更新
Star2DO updateObj = BeanUtils.toBean(updateReqVO, Star2DO.class);
star2Mapper.updateById(updateObj);

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.bpm.service.tbup;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tbup.TbupDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 点赞管理 Service 接口
*
* @author 君风
*/
public interface TbupService {
/**
* 创建点赞管理
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createTbup(@Valid TbupSaveReqVO createReqVO);
/**
* 更新点赞管理
*
* @param updateReqVO 更新信息
*/
void updateTbup(@Valid TbupSaveReqVO updateReqVO);
/**
* 删除点赞管理
*
* @param id 编号
*/
void deleteTbup(Long id);
/**
* 获得点赞管理
*
* @param id 编号
* @return 点赞管理
*/
TbupDO getTbup(Long id);
/**
* 获得点赞管理分页
*
* @param pageReqVO 分页查询
* @return 点赞管理分页
*/
PageResult<TbupDO> getTbupPage(TbupPageReqVO pageReqVO);
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.bpm.service.tbup;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.bpm.controller.admin.tbup.vo.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tbup.TbupDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.dal.mysql.tbup.TbupMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* 点赞管理 Service 实现类
*
* @author 君风
*/
@Service
@Validated
public class TbupServiceImpl implements TbupService {
@Resource
private TbupMapper tbupMapper;
@Override
public Long createTbup(TbupSaveReqVO createReqVO) {
// 插入
TbupDO tbup = BeanUtils.toBean(createReqVO, TbupDO.class);
tbupMapper.insert(tbup);
// 返回
return tbup.getId();
}
@Override
public void updateTbup(TbupSaveReqVO updateReqVO) {
// 校验存在
validateTbupExists(updateReqVO.getId());
// 更新
TbupDO updateObj = BeanUtils.toBean(updateReqVO, TbupDO.class);
tbupMapper.updateById(updateObj);
}
@Override
public void deleteTbup(Long id) {
// 校验存在
validateTbupExists(id);
// 删除
tbupMapper.deleteById(id);
}
private void validateTbupExists(Long id) {
if (tbupMapper.selectById(id) == null) {
throw exception(TBUP_NOT_EXISTS);
}
}
@Override
public TbupDO getTbup(Long id) {
return tbupMapper.selectById(id);
}
@Override
public PageResult<TbupDO> getTbupPage(TbupPageReqVO pageReqVO) {
return tbupMapper.selectPage(pageReqVO);
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.tbup.TbupMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -5,3 +5,4 @@ DELETE FROM "des_knowtype";
DELETE FROM "des_knowledge";
DELETE FROM "des_star2";
DELETE FROM "des_comment";
DELETE FROM "des_tbup";

View File

@ -98,3 +98,16 @@ CREATE TABLE IF NOT EXISTS "des_comment" (
"content" varchar,
PRIMARY KEY ("id")
) COMMENT '评论表';
CREATE TABLE IF NOT EXISTS "des_tbup" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"kowsm_id" bigint NOT NULL,
"user_id" bigint NOT NULL,
"kows_id" bigint NOT NULL,
"tenant_id" bigint NOT NULL,
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"creator" varchar DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"updater" varchar DEFAULT '',
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '点赞管理';

View File

@ -13,29 +13,29 @@ public interface FileApi {
* @param content 文件内容
* @return 文件路径
*/
default String createFile(byte[] content) {
default String[] createFile(byte[] content) {
return createFile(null, null, content);
}
/**
* 保存文件并返回文件的访问路径
*
* @param path 文件路径
* @param path 文件路径
* @param content 文件内容
* @return 文件路径
*/
default String createFile(String path, byte[] content) {
default String[] createFile(String path, byte[] content) {
return createFile(null, path, content);
}
/**
* 保存文件并返回文件的访问路径
*
* @param name 文件名称
* @param path 文件路径
* @param name 文件名称
* @param path 文件路径
* @param content 文件内容
* @return 文件路径
*/
String createFile(String name, String path, byte[] content);
String[] createFile(String name, String path, byte[] content);
}

View File

@ -19,7 +19,7 @@ public class FileApiImpl implements FileApi {
private FileService fileService;
@Override
public String createFile(String name, String path, byte[] content) {
public String[] createFile(String name, String path, byte[] content) {
return fileService.createFile(name, path, content);
}

View File

@ -40,7 +40,7 @@ public class FileController {
@PostMapping("/upload")
@Operation(summary = "上传文件", description = "模式一:后端上传文件")
public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
public CommonResult<String[]> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
MultipartFile file = uploadReqVO.getFile();
String path = uploadReqVO.getPath();
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));

View File

@ -29,7 +29,7 @@ public class AppFileController {
@PostMapping("/upload")
@Operation(summary = "上传文件")
public CommonResult<String> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
public CommonResult<String[]> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
MultipartFile file = uploadReqVO.getFile();
String path = uploadReqVO.getPath();
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));

View File

@ -29,7 +29,7 @@ public interface FileService {
* @param content 文件内容
* @return 文件路径
*/
String createFile(String name, String path, byte[] content);
String[] createFile(String name, String path, byte[] content);
/**
* 创建文件

View File

@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
@ -42,7 +43,7 @@ public class FileServiceImpl implements FileService {
@Override
@SneakyThrows
public String createFile(String name, String path, byte[] content) {
public String[] createFile(String name, String path, byte[] content) {
// 计算默认的 path
String type = FileTypeUtils.getMineType(content, name);
if (StrUtil.isEmpty(path)) {
@ -67,7 +68,16 @@ public class FileServiceImpl implements FileService {
file.setType(type);
file.setSize(content.length);
fileMapper.insert(file);
return url;
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("name",name);
// jsonObject.put("url",url);
String[] liss = new String[2];
System.out.println(name);
System.out.println(url);
liss[0] = name;
liss[1] = url;
System.out.println(Arrays.toString(liss));
return liss;
}
@Override

View File

@ -179,7 +179,7 @@ public class AdminUserServiceImpl implements AdminUserService {
public String updateUserAvatar(Long id, InputStream avatarFile) {
validateUserExists(id);
// 存储文件
String avatar = fileApi.createFile(IoUtil.readBytes(avatarFile));
String avatar = String.valueOf(fileApi.createFile(IoUtil.readBytes(avatarFile)));
// 更新路径
AdminUserDO sysUserDO = new AdminUserDO();
sysUserDO.setId(id);