diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java index abe1bb2..f37462e 100644 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java +++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java @@ -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, "点赞不存在"); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgePageReqVO.java index c5fea1a..5889720 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgePageReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgePageReqVO.java @@ -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) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeRespVO.java index 970250c..450e3be 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeRespVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeRespVO.java @@ -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("创建时间") diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeSaveReqVO.java index 42e8345..d2e2609 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeSaveReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/knows/vo/KnowledgeSaveReqVO.java @@ -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 filePath; +// private List filePath; +// private List filePath; @Schema(description = "评论列表") diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/TbupController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/TbupController.java new file mode 100644 index 0000000..13b5abe --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/TbupController.java @@ -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 createTbup(@Valid @RequestBody TbupSaveReqVO createReqVO) { + return success(tbupService.createTbup(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新点赞管理") + @PreAuthorize("@ss.hasPermission('bpm:tbup:update')") + public CommonResult 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 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 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> getTbupPage(@Valid TbupPageReqVO pageReqVO) { + PageResult pageResult = tbupService.getTbupPage(pageReqVO); + if (CollUtil.isEmpty(pageResult.getList())) { + return success(new PageResult<>(pageResult.getTotal())); + } + Map knowTypeMap = knowtypeService.getKnowtypeMap( + convertList(pageResult.getList(), TbupDO::getKowsId) + ); + Map AdminUserMap = adminUserApi.getUserMap( + convertList(pageResult.getList(),TbupDO::getUserId) + ); + Map 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 list = tbupService.getTbupPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "点赞管理.xls", "数据", TbupRespVO.class, + BeanUtils.toBean(list, TbupRespVO.class)); + } + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupPageReqVO.java new file mode 100644 index 0000000..cce971b --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupPageReqVO.java @@ -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; + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupRespVO.java new file mode 100644 index 0000000..a99122b --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupRespVO.java @@ -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; + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupSaveReqVO.java new file mode 100644 index 0000000..f4a6f89 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/tbup/vo/TbupSaveReqVO.java @@ -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; + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/tbup/TbupConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/tbup/TbupConvert.java new file mode 100644 index 0000000..fa5f83a --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/tbup/TbupConvert.java @@ -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 convertList(List list, Map knowTypeMap, Map AdminUserMap, Map 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; + } +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/tbup/TbupDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/tbup/TbupDO.java new file mode 100644 index 0000000..3cdf416 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/tbup/TbupDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; + +} \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/tbup/TbupMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/tbup/TbupMapper.java new file mode 100644 index 0000000..713a84d --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/tbup/TbupMapper.java @@ -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 { + + default PageResult selectPage(TbupPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .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)); + } + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/star2/Star2ServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/star2/Star2ServiceImpl.java index 6f1b353..515f84d 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/star2/Star2ServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/star2/Star2ServiceImpl.java @@ -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); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/tbup/TbupService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/tbup/TbupService.java new file mode 100644 index 0000000..5dc48dc --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/tbup/TbupService.java @@ -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 getTbupPage(TbupPageReqVO pageReqVO); + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/tbup/TbupServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/tbup/TbupServiceImpl.java new file mode 100644 index 0000000..857994e --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/tbup/TbupServiceImpl.java @@ -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 getTbupPage(TbupPageReqVO pageReqVO) { + return tbupMapper.selectPage(pageReqVO); + } + +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/tbup/TbupMapper.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/tbup/TbupMapper.xml new file mode 100644 index 0000000..64d2e83 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/tbup/TbupMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql index 4f23b5c..d3bee85 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/clean.sql @@ -5,3 +5,4 @@ DELETE FROM "des_knowtype"; DELETE FROM "des_knowledge"; DELETE FROM "des_star2"; DELETE FROM "des_comment"; +DELETE FROM "des_tbup"; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql index 193c758..caa1db5 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/sql/create_tables.sql @@ -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 '点赞管理'; diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java index c41c6e0..278b94f 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java @@ -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); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java index 05fb946..662a574 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java @@ -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); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java index 8b2ce4f..84df786 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java @@ -40,7 +40,7 @@ public class FileController { @PostMapping("/upload") @Operation(summary = "上传文件", description = "模式一:后端上传文件") - public CommonResult uploadFile(FileUploadReqVO uploadReqVO) throws Exception { + public CommonResult uploadFile(FileUploadReqVO uploadReqVO) throws Exception { MultipartFile file = uploadReqVO.getFile(); String path = uploadReqVO.getPath(); return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java index 62755fc..a55c0f2 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java @@ -29,7 +29,7 @@ public class AppFileController { @PostMapping("/upload") @Operation(summary = "上传文件") - public CommonResult uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception { + public CommonResult uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception { MultipartFile file = uploadReqVO.getFile(); String path = uploadReqVO.getPath(); return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java index 3ca9a24..6168d3d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java @@ -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); /** * 创建文件 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java index 8efa5fe..1c4b16e 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java @@ -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 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index d37e093..a50d7f4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -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);