From 9b29319c5dfa3f0a0f30e902ea2af45b80741026 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Tue, 18 Jun 2024 15:31:02 +0800 Subject: [PATCH] commit --- .../java/com/huoran/iasf/common/utils/R.java | 5 + .../iasf/controller/CategoryController.java | 12 +- .../iasf/controller/DisciplineController.java | 67 +++++ .../controller/ProductDetailsController.java | 110 -------- .../iasf/controller/SysColumnController.java | 12 +- .../SysProductDetailsController.java | 214 +++++++++++++++ .../SysSubjectSpecialtyController.java | 21 -- .../java/com/huoran/iasf/entity/Category.java | 7 +- .../com/huoran/iasf/entity/Discipline.java | 37 +++ .../huoran/iasf/entity/ProductDetails.java | 57 +++- .../com/huoran/iasf/entity/Professional.java | 40 +++ .../huoran/iasf/entity/ProfessionalClass.java | 40 +++ .../huoran/iasf/mapper/DisciplineMapper.java | 16 ++ .../iasf/mapper/ProfessionalClassMapper.java | 16 ++ .../iasf/mapper/ProfessionalMapper.java | 16 ++ .../iasf/mapper/SysProductDetailsMapper.java | 21 ++ .../iasf/mapper/xml/DisciplineMapper.xml | 5 + .../mapper/xml/ProfessionalClassMapper.xml | 5 + .../iasf/mapper/xml/ProfessionalMapper.xml | 5 + .../mapper/xml/SysProductDetailsMapper.xml | 250 ++++++++++++++++++ .../iasf/service/DisciplineService.java | 19 ++ .../service/ProfessionalClassService.java | 16 ++ .../iasf/service/ProfessionalService.java | 16 ++ .../iasf/service/SysCategoryService.java | 4 +- .../service/SysProductDetailsService.java | 13 +- .../service/SysSubjectSpecialtyService.java | 4 + .../service/impl/CategoryServiceImpl.java | 6 +- .../service/impl/DisciplineServiceImpl.java | 26 ++ .../impl/ProfessionalClassServiceImpl.java | 20 ++ .../service/impl/ProfessionalServiceImpl.java | 20 ++ .../service/impl/SysContentServiceImpl.java | 40 ++- .../impl/SysProductDetailsServiceImpl.java | 96 ++++++- .../impl/SysSubjectSpecialtyServiceImpl.java | 9 + .../iasf/vo/DisciplineAndSpecialtyVO.java | 34 +++ .../iasf/vo/req/PageCourseProductReq.java | 38 +++ .../iasf/vo/resp/PageContentRespVO.java | 3 + .../iasf/vo/resp/PageCourseProductRespVO.java | 59 +++++ src/main/resources/application-test.yml | 4 +- .../com/company/project/CodeGenerator.java | 8 +- 39 files changed, 1217 insertions(+), 174 deletions(-) create mode 100644 src/main/java/com/huoran/iasf/controller/DisciplineController.java delete mode 100644 src/main/java/com/huoran/iasf/controller/ProductDetailsController.java create mode 100644 src/main/java/com/huoran/iasf/controller/SysProductDetailsController.java delete mode 100644 src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java create mode 100644 src/main/java/com/huoran/iasf/entity/Discipline.java create mode 100644 src/main/java/com/huoran/iasf/entity/Professional.java create mode 100644 src/main/java/com/huoran/iasf/entity/ProfessionalClass.java create mode 100644 src/main/java/com/huoran/iasf/mapper/DisciplineMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/ProfessionalClassMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/ProfessionalMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/DisciplineMapper.xml create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/ProfessionalClassMapper.xml create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/ProfessionalMapper.xml create mode 100644 src/main/java/com/huoran/iasf/service/DisciplineService.java create mode 100644 src/main/java/com/huoran/iasf/service/ProfessionalClassService.java create mode 100644 src/main/java/com/huoran/iasf/service/ProfessionalService.java create mode 100644 src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java create mode 100644 src/main/java/com/huoran/iasf/service/impl/ProfessionalClassServiceImpl.java create mode 100644 src/main/java/com/huoran/iasf/service/impl/ProfessionalServiceImpl.java create mode 100644 src/main/java/com/huoran/iasf/vo/DisciplineAndSpecialtyVO.java create mode 100644 src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java create mode 100644 src/main/java/com/huoran/iasf/vo/resp/PageCourseProductRespVO.java diff --git a/src/main/java/com/huoran/iasf/common/utils/R.java b/src/main/java/com/huoran/iasf/common/utils/R.java index 7eb2634..14d5966 100644 --- a/src/main/java/com/huoran/iasf/common/utils/R.java +++ b/src/main/java/com/huoran/iasf/common/utils/R.java @@ -131,4 +131,9 @@ public class R { public static R result(boolean delState, String s) { return delState ? success(s) : fail(s); } + + public static R success(Object data, String message) { + return new R(200, message, data); + } + } diff --git a/src/main/java/com/huoran/iasf/controller/CategoryController.java b/src/main/java/com/huoran/iasf/controller/CategoryController.java index a90555e..4d267cf 100644 --- a/src/main/java/com/huoran/iasf/controller/CategoryController.java +++ b/src/main/java/com/huoran/iasf/controller/CategoryController.java @@ -31,6 +31,7 @@ public class CategoryController { @Autowired private SysCategoryService service; + /** * 保存或更新分类信息 * @@ -46,10 +47,10 @@ public class CategoryController { boolean isDuplicate = false; if (category.getCategoryId() != null) { // 更新逻辑,排除当前记录自身 - isDuplicate = service.existsOtherByName(category.getName(), category.getCategoryId()); + isDuplicate = service.existsOtherByName(category.getName(), category.getCategoryId(), category.getSiteId()); } else { // 新增逻辑,直接检查名称是否存在 - isDuplicate = service.existsByName(category.getName()); + isDuplicate = service.existsByName(category.getName(), category.getSiteId()); } if (isDuplicate) { @@ -58,7 +59,9 @@ public class CategoryController { boolean operationResult = service.saveOrUpdate(category); - return R.result(operationResult, operationResult ? "操作成功" : "操作失败"); + // 在执行操作并获取新ID之后 + long newId = category.getCategoryId();// 这里是从数据库操作中获取到的新插入记录的ID + return operationResult ? R.success(newId, "操作成功,新增记录ID为: " + newId) : R.fail("操作失败"); } catch (Exception e) { throw new BusinessException(BaseResponseCode.SYSTEM_BUSY); } @@ -73,9 +76,10 @@ public class CategoryController { */ @PostMapping("/list") @ApiOperation("根据类型获取分类列表") - public R categoryList(@ApiParam(value = "类型标识,区分课程或产品", allowableValues = "0:课程,1:产品") @RequestParam(required = false) Integer type) { + public R categoryList(@ApiParam(value = "类型标识") @RequestParam(required = false) Integer type, @ApiParam(value = "站点id") @RequestParam(required = false) Integer siteId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("type", type); + queryWrapper.eq("site_id", siteId); List categories = service.list(queryWrapper); return R.success(categories); } diff --git a/src/main/java/com/huoran/iasf/controller/DisciplineController.java b/src/main/java/com/huoran/iasf/controller/DisciplineController.java new file mode 100644 index 0000000..db522cf --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/DisciplineController.java @@ -0,0 +1,67 @@ +package com.huoran.iasf.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.entity.Discipline; +import com.huoran.iasf.entity.Professional; +import com.huoran.iasf.entity.ProfessionalClass; +import com.huoran.iasf.service.DisciplineService; +import com.huoran.iasf.service.ProfessionalClassService; +import com.huoran.iasf.service.ProfessionalService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @描述:学科控制类 + * @作者: Rong + * @日期: 2024-06-17 + */ +@RestController +@RequestMapping("/subject") +@Api(value = "学科类相关", tags = "学科类相关") +public class DisciplineController { + + @Autowired + public DisciplineService disciplineService; + @Autowired + public ProfessionalService professionalService; + + @Autowired + public ProfessionalClassService classService; + + @GetMapping("/courseDiscipline") + @ApiOperation(value = "课程学科类别", response = Discipline.class) + public R courseDiscipline() { + List list = disciplineService.subjectCategory(); + return R.success(list); + } + + @GetMapping("/courseProfessionalClass") + @ApiOperation(value = "课程专业类", response = ProfessionalClass.class) + public R disciplineList(@ApiParam(value = "disciplineId", required = true) @RequestParam("disciplineId") Integer disciplineId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("discipline_id", disciplineId); + List list = classService.list(queryWrapper); + return R.success(list); + } + + + @GetMapping("/courseProfessional") + @ApiOperation(value = "课程专业", response = Professional.class) + public R courseProfessional(@ApiParam(value = "professionalClassId", required = true) @RequestParam("professionalClassId") Integer professionalClassId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("professional_class_id", professionalClassId); + List list = professionalService.list(queryWrapper); + return R.success(list); + } + +} + diff --git a/src/main/java/com/huoran/iasf/controller/ProductDetailsController.java b/src/main/java/com/huoran/iasf/controller/ProductDetailsController.java deleted file mode 100644 index 8bc1397..0000000 --- a/src/main/java/com/huoran/iasf/controller/ProductDetailsController.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.huoran.iasf.controller; - -import com.huoran.iasf.common.exception.BusinessException; -import com.huoran.iasf.common.exception.code.BaseResponseCode; -import com.huoran.iasf.common.utils.R; -import com.huoran.iasf.entity.ProductDetails; -import com.huoran.iasf.service.SysProductDetailsService; -import com.huoran.iasf.service.SysSubjectSpecialtyService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 综合产品与课程详情信息表控制类 - */ -@RestController -@RequestMapping("/productDetails") -@Api(value = "A-综合产品与课程详情", tags = "A-综合产品与课程详情") -@Slf4j -public class ProductDetailsController { - - @Autowired - private SysProductDetailsService service; - - @Autowired - private SysSubjectSpecialtyService subjectSpecialtyService; - - - /** - * 保存或更新综合产品与课程详情信息 - * 根据实体中的ID判断是保存还是更新 - * - * @param productDetails 要保存或更新的实体 - * @return 操作结果 - */ - @PostMapping("/saveOrUpdate") - @ApiOperation("保存或更新综合产品与课程详情信息") - @Transactional(rollbackFor = Exception.class) - public R saveOrUpdate(@RequestBody @Validated ProductDetails productDetails) { - try { - // 增加重复检查逻辑 - boolean isDuplicate = false; - if (productDetails.getId() != null) { - // 更新逻辑,排除当前记录自身 - isDuplicate = service.existsOtherByProductName(productDetails.getName(), productDetails.getId()); - } else { - // 新增逻辑,直接检查名称是否存在 - isDuplicate = service.existsByProductName(productDetails.getName()); - } - - if (isDuplicate) { - return R.fail("名称已存在,请检查后重新提交"); - } - - boolean addState = service.saveOrUpdate(productDetails); - - if (addState && productDetails.getSubjectSpecialtyList() != null && !productDetails.getSubjectSpecialtyList().isEmpty()) { - // 确保每个subjectSpecialty都关联到正确的templateDetailsId - productDetails.getSubjectSpecialtyList().forEach(subjectSpecialty -> subjectSpecialty.setTemplateDetailsId(productDetails.getId())); - subjectSpecialtyService.removeByTemplateDetailsId(productDetails.getId()); - subjectSpecialtyService.saveBatch(productDetails.getSubjectSpecialtyList()); - } - - return R.result(addState, addState ? "操作成功" : "操作失败"); - } catch (Exception e) { - log.error("保存或更新产品详情时发生错误", e); - throw new BusinessException(BaseResponseCode.SYSTEM_BUSY); - } - } - - - - /** - * 根据ID查询详情 - * - * @param id 主键ID - * @return 查询结果 - */ - @PostMapping("/findById") - @ApiOperation("根据ID查询详情") - public R findById(@RequestParam("id") Integer id) { - ProductDetails productDetails = service.getById(id); - return R.success(productDetails); - } - - - - - /** - * 批量删除记录 - * - * @param ids 主键ID列表 - * @return 操作结果 - */ - @PostMapping("/batchDelete") - @ApiOperation("批量删除记录") - public R batchDelete(@RequestBody List ids) { - if (ids == null || ids.isEmpty()) { - return R.fail("请选择要删除的记录"); - } - boolean delState = service.removeByIds(ids); - return R.result(delState, delState ? "批量删除成功" : "批量删除失败"); - } -} diff --git a/src/main/java/com/huoran/iasf/controller/SysColumnController.java b/src/main/java/com/huoran/iasf/controller/SysColumnController.java index 6411093..62b63cf 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -1,5 +1,6 @@ package com.huoran.iasf.controller; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.huoran.iasf.common.aop.annotation.NoRepeatSubmit; @@ -75,20 +76,23 @@ public class SysColumnController { @PostMapping("/findById") @ApiOperation(value = "查询详情", response = SysColumn.class) - public R findById(@RequestParam("id") @ApiParam(value = "序号") Integer id) { + public R findById(@RequestParam("id") @ApiParam(value = "主键ID") Integer id) { SysColumn sysColumn = service.getById(id); if (sysColumn == null) { throw new NotFoundException(BaseResponseCode.DATA_DOES_NOT_EXIST); } SysTemplateStyle sysTemplateStyle = styleService.getById(sysColumn.getListStyleId()); - if (sysTemplateStyle.getPath() != null) { - sysColumn.setPath(sysTemplateStyle.getPath()); - } + if (!ObjectUtil.isEmpty(sysTemplateStyle)){ + if (!ObjectUtil.isEmpty(sysTemplateStyle.getPath())) { + sysColumn.setPath(sysTemplateStyle.getPath()); + } + } return R.success(sysColumn); } + @NoRepeatSubmit @PostMapping("/save") @ApiOperation(value = "新增", response = SysColumn.class) diff --git a/src/main/java/com/huoran/iasf/controller/SysProductDetailsController.java b/src/main/java/com/huoran/iasf/controller/SysProductDetailsController.java new file mode 100644 index 0000000..a7e6371 --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/SysProductDetailsController.java @@ -0,0 +1,214 @@ +package com.huoran.iasf.controller; + +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.huoran.iasf.common.exception.BusinessException; +import com.huoran.iasf.common.exception.code.BaseResponseCode; +import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.entity.ProductDetails; +import com.huoran.iasf.entity.SysColumn; +import com.huoran.iasf.service.SysColumnService; +import com.huoran.iasf.service.SysProductDetailsService; +import com.huoran.iasf.service.SysSubjectSpecialtyService; +import com.huoran.iasf.vo.req.PageCourseProductReq; +import com.huoran.iasf.vo.resp.PageContentRespVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.Date; +import java.util.List; + +/** + * 综合产品与课程详情信息表控制类 + */ +@RestController +@RequestMapping("/productDetails") +@Api(value = "A-综合产品与课程详情", tags = "A-综合产品与课程详情") +@Slf4j +public class SysProductDetailsController { + + @Autowired + private SysProductDetailsService service; + + @Autowired + private SysSubjectSpecialtyService subjectSpecialtyService; + + @Autowired + private SysColumnService columnService; + + @PostMapping("/checkIfTheTitleIsRepeat") + @ApiOperation(value = "标题判重——适用于新增、编辑及发布前的校验", response = Boolean.class) + public R checkIfTheTitleIsRepeat(@RequestBody @Valid ProductDetails content) { + boolean isDuplicate = false; + + // 如果ID不为空,说明是编辑操作,需要排除当前记录自身 + if (content.getId() != null) { + isDuplicate = service.existsOtherByProductName(content.getName(), content.getId(), content.getSiteId()); + } else { + // ID为空,说明是新增操作 + isDuplicate = service.existsByProductName(content.getName(), content.getSiteId()); + } + + return R.result(!isDuplicate, !isDuplicate ? "标题可用" : "该标题已重复!"); + } + + public static void main(String[] args) { + // 获取当前日期时间 + LocalDate currentDate = LocalDate.now(); + + // 输出当前日期,此时已经去除了时分秒信息 + System.out.println("当前日期(去除时分秒): " + currentDate); + } + + /** + * 保存或更新综合产品与课程详情信息 + * 根据实体中的ID判断是保存还是更新 + * + * @param productDetails 要保存或更新的实体 + * @return 操作结果 + */ + @PostMapping("/saveOrUpdate") + @ApiOperation("保存或更新综合产品与课程详情信息") + @Transactional(rollbackFor = Exception.class) + public R saveOrUpdate(@RequestBody @Validated ProductDetails productDetails) { + try { + + SysColumn column = columnService.getById(productDetails.getColumnId()); + if (column == null) { + throw new BusinessException(BaseResponseCode.DATA_DOES_NOT_EXIST); + } + + + if (productDetails.getPublishStatus()) { + // 获取当前日期时间 + Date currentDate = new Date(); + // 创建SimpleDateFormat对象,指定日期时间格式 + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 格式化当前日期时间 + String formattedDateTime = formatter.format(currentDate); + // 输出格式化后的日期时间 + productDetails.setReleaseTime(formattedDateTime); + } else { + productDetails.setReleaseTime("—"); + } + boolean addState = service.saveOrUpdate(productDetails); + + + if (addState && productDetails.getSubjectSpecialtyList() != null && !productDetails.getSubjectSpecialtyList().isEmpty()) { + // 确保每个subjectSpecialty都关联到正确的templateDetailsId + productDetails.getSubjectSpecialtyList().forEach(subjectSpecialty -> subjectSpecialty.setTemplateDetailsId(productDetails.getId())); + subjectSpecialtyService.removeByTemplateDetailsId(productDetails.getId()); + subjectSpecialtyService.saveBatch(productDetails.getSubjectSpecialtyList()); + } + + //新增成功后返回id + return R.result(addState, addState ? String.valueOf(productDetails.getId()) : "操作失败"); + } catch (Exception e) { + log.error("保存或更新产品详情时发生错误", e); + throw new BusinessException(BaseResponseCode.SYSTEM_BUSY); + } + } + + + /** + * 根据ID查询详情 + * + * @param id 主键ID + * @return 查询结果 + */ + @PostMapping("/findById") + @ApiOperation("根据ID查询详情") + public R findById(@RequestParam("id") Integer id) { + ProductDetails productDetails = service.getById(id); + + //查询详情的时候也要查询学科专业 + productDetails.setSubjectSpecialtyList(subjectSpecialtyService.getByTemplateDetailsId(id)); + + return R.success(productDetails); + } + + + //前台预览 + @PostMapping("/foregroundPreview") + @ApiOperation("前台预览") + public R foregroundPreview(@RequestParam("id") Integer id) { + ProductDetails productDetails = service.foregroundPreview(id); + return R.success(productDetails); + } + + @PostMapping("/articlePreview") + @ApiOperation(value = "增加文章浏览量(点击一次算一次)", response = ProductDetails.class) + public R articlePreview(@ApiParam(name = "contentId", value = "文章id", required = true) @RequestParam Integer contentId) { + return R.success(service.statisticsOfPageViews(contentId)); + } + + + @PostMapping("/articleEnableOrDisable") + @ApiOperation(value = "文章启用禁用", response = ProductDetails.class) + public R articleEnableOrDisable(@ApiParam(name = "id", value = "文章id", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用(0默认,0启用 1禁用)", required = true) @RequestParam Integer isDisable) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("is_disable", isDisable); + updateWrapper.eq("id", id); + boolean ret = service.update(updateWrapper); + return ret ? R.success() : R.fail("禁用/启用失败"); + } + + + /** + * 批量删除记录 + * + * @param ids 主键ID列表 + * @return 操作结果 + */ + @PostMapping("/batchDelete") + @ApiOperation("批量删除记录") + public R batchDelete(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List ids) { + if (ids == null || ids.isEmpty()) { + return R.fail("请选择要删除的记录"); + } + boolean delState = service.removeByIds(ids); + return R.result(delState, delState ? "批量删除成功" : "批量删除失败"); + } + + + @PostMapping("/courseProductTopOperation") + @ApiOperation(value = "课程产品置顶/取消置顶", response = ProductDetails.class) + public R courseProductTopOperation(@ApiParam(name = "isTop", value = "是否置顶(默认为0 不置顶 1为置顶)", required = true) @RequestParam Integer isTop, @ApiParam(name = "articleId", value = "课程产品id", required = true) @RequestParam Integer articleId) { + //是否置顶(默认为0 不置顶 1为置顶) + UpdateWrapper updateWrap = new UpdateWrapper<>(); + + if (isTop == 1) { + //置顶时间(置顶一次更新一次) + updateWrap.set("top_time", new Date()); + } else { + updateWrap.set("top_time", null); + } + updateWrap.set("is_top", isTop); + updateWrap.eq("id", articleId); + updateWrap.eq("deleted", 1); + boolean ret = service.update(updateWrap); + return R.result(ret, ret ? "操作除成功" : "操作失败"); + + } + + + /** + * 根据前端传的栏目id,只查询栏目下启用且未删除的数据 + * + * @param sysContent + * @return + */ + @PostMapping("/courseProduct") + @ApiOperation(value = "前台课程产品", response = PageContentRespVO.class) + public R courseProduct(@RequestBody @Valid @ApiParam(name = "分页查询参数", value = "传入json格式", required = true) PageCourseProductReq sysContent) { + return service.courseProduct(sysContent); + } +} diff --git a/src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java b/src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java deleted file mode 100644 index 72e3720..0000000 --- a/src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.huoran.iasf.controller; - - -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; - -/** - *

- * 适用学科专业配置 前端控制器 - *

- * - * @author cheney - * @since 2024-06-13 - */ -@RestController -@RequestMapping("//sys-subject-specialty") -public class SysSubjectSpecialtyController { - -} - diff --git a/src/main/java/com/huoran/iasf/entity/Category.java b/src/main/java/com/huoran/iasf/entity/Category.java index b9f05ad..3588852 100644 --- a/src/main/java/com/huoran/iasf/entity/Category.java +++ b/src/main/java/com/huoran/iasf/entity/Category.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -32,7 +33,8 @@ public class Category implements Serializable { @ApiModelProperty(value = "分类名称") private String name; - @ApiModelProperty(value = "类型标识,区分是课程还是产品)0:课程,1:产品(0:课程,1:产品)") + // @ApiModelProperty(value = "类型标识,区分是课程还是产品)0:课程,1:产品(0:课程,1:产品)") + @ApiModelProperty(value = "类型区分,0:课程分类,1:产品分类标签,2.产品类型") private Integer type; @ApiModelProperty(value = "分类描述") @@ -46,6 +48,9 @@ public class Category implements Serializable { @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; + @ApiModelProperty(value = "站点id") + @NotNull(message = "站点id不能为空") + private Integer siteId; } diff --git a/src/main/java/com/huoran/iasf/entity/Discipline.java b/src/main/java/com/huoran/iasf/entity/Discipline.java new file mode 100644 index 0000000..7c80786 --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/Discipline.java @@ -0,0 +1,37 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + *

+ * 学科 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("s_discipline") +@ApiModel(value = "Discipline对象", description = "学科") +public class Discipline implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键id") + @TableId(value = "discipline_id", type = IdType.AUTO) + private Integer disciplineId; + + @ApiModelProperty(value = "学科名称") + private String disciplineName; + + +} diff --git a/src/main/java/com/huoran/iasf/entity/ProductDetails.java b/src/main/java/com/huoran/iasf/entity/ProductDetails.java index 8ea5a7a..39a2c9c 100644 --- a/src/main/java/com/huoran/iasf/entity/ProductDetails.java +++ b/src/main/java/com/huoran/iasf/entity/ProductDetails.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; import java.util.List; @@ -25,14 +26,14 @@ public class ProductDetails implements Serializable { @ApiModelProperty(value = "主键ID") private Integer id; - @ApiModelProperty(value = "模板ID") - private Integer templateId; + @ApiModelProperty(value = "栏目id") + private Integer columnId; @ApiModelProperty(value = "名称,课程或产品的名称,根据类型区分") private String name; - @ApiModelProperty(value = "类型标识,区分是课程还是产品") - private String type; + /* @ApiModelProperty(value = "类型标识,区分是课程还是产品") + private String type;*/ @ApiModelProperty(value = "课程分类id或产品分类id,根据类型使用") private String categoryId; @@ -52,10 +53,10 @@ public class ProductDetails implements Serializable { @ApiModelProperty(value = "按钮跳转链接") private String jumpLinkUrl; - @ApiModelProperty(value = "简介,课程介绍或产品简介,根据类型区分使用") + @ApiModelProperty(value = "简介") private String introduction; - @ApiModelProperty(value = "详细描述,课程或产品的详细说明") + @ApiModelProperty(value = "详细描述") private String detailedDescription; @ApiModelProperty(value = "发布状态,0草稿,1已发布") @@ -73,21 +74,61 @@ public class ProductDetails implements Serializable { @TableLogic private Integer deleted; - @ApiModelProperty(value = "课程类型,仅课程使用,可为空") + @ApiModelProperty(value = "课程类型(免费、付费),仅课程使用,可为空") private String courseType; @ApiModelProperty(value = "匹配课程,仅产品使用,可存储课程ID列表") private String matchedCourses; @ApiModelProperty(value = "预计课时,仅产品使用,可为空") - private Integer estimatedHours; + private String estimatedHours; @ApiModelProperty(value = "适用场景,仅产品使用,可为空") private String applicableScenarios; + @ApiModelProperty(value = "创建人id") + private Integer founderId; + + @ApiModelProperty(value = "编辑人id") + private Integer editorId; + + @ApiModelProperty(value = "文章总浏览量") + private Integer totalBrowsing; + + @ApiModelProperty(value = "站点id") + @NotNull(message = "站点id不能为空") + private Integer siteId; + + @ApiModelProperty(value = "文章模板(前端自定义)") + private Integer articleTemplate; + + @ApiModelProperty(value = "模板状态(0禁用;1启用)") + private Integer templateStatus; + + @ApiModelProperty(value = "是否置顶(默认为0 不置顶 1为置顶)") + private Integer isTop; + + @ApiModelProperty(value = "置顶时间") + private Date topTime; + + @ApiModelProperty(value = "发布时间") + private String releaseTime; + @ApiModelProperty(value = "学科专业类") @TableField(exist = false) private List subjectSpecialtyList; + @ApiModelProperty(value = "学科类别") + @TableField(exist = false) + private String disciplineName; + + @ApiModelProperty(value = "专业类") + @TableField(exist = false) + private String professionalClassName; + + @ApiModelProperty(value = "专业") + @TableField(exist = false) + private String professionalName; + } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/entity/Professional.java b/src/main/java/com/huoran/iasf/entity/Professional.java new file mode 100644 index 0000000..b6425e3 --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/Professional.java @@ -0,0 +1,40 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + *

+ * 专业 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("s_professional") +@ApiModel(value = "Professional对象", description = "专业") +public class Professional implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "专业主键id") + @TableId(value = "professional_id", type = IdType.AUTO) + private Integer professionalId; + + @ApiModelProperty(value = "专业名称") + private String professionalName; + + @ApiModelProperty(value = "专业类id") + private Integer professionalClassId; + + +} diff --git a/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java b/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java new file mode 100644 index 0000000..e10b0be --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/ProfessionalClass.java @@ -0,0 +1,40 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + *

+ * 专业类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("s_professional_class") +@ApiModel(value = "ProfessionalClass对象", description = "专业类") +public class ProfessionalClass implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "专业类主键id") + @TableId(value = "professional_class_id", type = IdType.AUTO) + private Integer professionalClassId; + + @ApiModelProperty(value = "专业类名称") + private String professionalClassName; + + @ApiModelProperty(value = "学科层次id") + private Integer disciplineId; + + +} diff --git a/src/main/java/com/huoran/iasf/mapper/DisciplineMapper.java b/src/main/java/com/huoran/iasf/mapper/DisciplineMapper.java new file mode 100644 index 0000000..a70ad3e --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/DisciplineMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import com.huoran.iasf.entity.Discipline; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 学科 Mapper 接口 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +public interface DisciplineMapper extends BaseMapper { + +} diff --git a/src/main/java/com/huoran/iasf/mapper/ProfessionalClassMapper.java b/src/main/java/com/huoran/iasf/mapper/ProfessionalClassMapper.java new file mode 100644 index 0000000..2255334 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/ProfessionalClassMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import com.huoran.iasf.entity.ProfessionalClass; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 专业类 Mapper 接口 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +public interface ProfessionalClassMapper extends BaseMapper { + +} diff --git a/src/main/java/com/huoran/iasf/mapper/ProfessionalMapper.java b/src/main/java/com/huoran/iasf/mapper/ProfessionalMapper.java new file mode 100644 index 0000000..dae6ac3 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/ProfessionalMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import com.huoran.iasf.entity.Professional; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 专业 Mapper 接口 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +public interface ProfessionalMapper extends BaseMapper { + +} diff --git a/src/main/java/com/huoran/iasf/mapper/SysProductDetailsMapper.java b/src/main/java/com/huoran/iasf/mapper/SysProductDetailsMapper.java index 9de0c4f..b947392 100644 --- a/src/main/java/com/huoran/iasf/mapper/SysProductDetailsMapper.java +++ b/src/main/java/com/huoran/iasf/mapper/SysProductDetailsMapper.java @@ -1,7 +1,18 @@ package com.huoran.iasf.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huoran.iasf.entity.Category; import com.huoran.iasf.entity.ProductDetails; +import com.huoran.iasf.vo.DisciplineAndSpecialtyVO; +import com.huoran.iasf.vo.req.PageContentReqVO; +import com.huoran.iasf.vo.req.PageCourseProductReq; +import com.huoran.iasf.vo.resp.PageContentRespVO; +import com.huoran.iasf.vo.resp.PageCourseProductRespVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** *

@@ -12,5 +23,15 @@ import com.huoran.iasf.entity.ProductDetails; * @since 2024-06-12 */ public interface SysProductDetailsMapper extends BaseMapper { + IPage productCourseList(Page page, @Param("req") PageContentReqVO req); + + IPage courseProduct(Page page, @Param("req") PageCourseProductReq req); + + String queryTypeByCategoryId(@Param("classificationTagId") String classificationTagId); + ProductDetails foregroundPreview(@Param("id") Integer id); + + + DisciplineAndSpecialtyVO queryDisciplineAndSpecialty(@Param("id") Integer id); } + diff --git a/src/main/java/com/huoran/iasf/mapper/xml/DisciplineMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/DisciplineMapper.xml new file mode 100644 index 0000000..cf0d1f5 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/DisciplineMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/mapper/xml/ProfessionalClassMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/ProfessionalClassMapper.xml new file mode 100644 index 0000000..bb60423 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/ProfessionalClassMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/mapper/xml/ProfessionalMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/ProfessionalMapper.xml new file mode 100644 index 0000000..f8cb327 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/ProfessionalMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml index 1b71784..1dac205 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml @@ -1,5 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/huoran/iasf/service/DisciplineService.java b/src/main/java/com/huoran/iasf/service/DisciplineService.java new file mode 100644 index 0000000..e7536e3 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/DisciplineService.java @@ -0,0 +1,19 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.Discipline; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + *

+ * 学科 服务类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +public interface DisciplineService extends IService { + + List subjectCategory(); +} diff --git a/src/main/java/com/huoran/iasf/service/ProfessionalClassService.java b/src/main/java/com/huoran/iasf/service/ProfessionalClassService.java new file mode 100644 index 0000000..62a0835 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/ProfessionalClassService.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.ProfessionalClass; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 专业类 服务类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +public interface ProfessionalClassService extends IService { + +} diff --git a/src/main/java/com/huoran/iasf/service/ProfessionalService.java b/src/main/java/com/huoran/iasf/service/ProfessionalService.java new file mode 100644 index 0000000..a527a81 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/ProfessionalService.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.Professional; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 专业 服务类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +public interface ProfessionalService extends IService { + +} diff --git a/src/main/java/com/huoran/iasf/service/SysCategoryService.java b/src/main/java/com/huoran/iasf/service/SysCategoryService.java index 7e1c5ab..97ae4c2 100644 --- a/src/main/java/com/huoran/iasf/service/SysCategoryService.java +++ b/src/main/java/com/huoran/iasf/service/SysCategoryService.java @@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface SysCategoryService extends IService { - boolean existsOtherByName(String name, Integer categoryId); + boolean existsOtherByName(String name, Integer categoryId,Integer siteId); - boolean existsByName(String name); + boolean existsByName(String name,Integer siteId); } diff --git a/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java b/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java index b7c819d..0451125 100644 --- a/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java +++ b/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java @@ -1,7 +1,10 @@ package com.huoran.iasf.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.ProductDetails; +import com.huoran.iasf.vo.req.PageContentReqVO; +import com.huoran.iasf.vo.req.PageCourseProductReq; /** *

@@ -13,7 +16,13 @@ import com.huoran.iasf.entity.ProductDetails; */ public interface SysProductDetailsService extends IService { - boolean existsByProductName(String name); + boolean existsByProductName(String name,Integer siteId); - boolean existsOtherByProductName(String name, Integer currentId); + boolean existsOtherByProductName(String name, Integer currentId,Integer siteId); + + Integer statisticsOfPageViews(Integer id); + + R courseProduct(PageCourseProductReq sysContent); + + ProductDetails foregroundPreview(Integer id); } diff --git a/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java b/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java index d044920..1bcdf7e 100644 --- a/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java +++ b/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java @@ -3,6 +3,8 @@ package com.huoran.iasf.service; import com.huoran.iasf.entity.SysSubjectSpecialty; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 适用学科专业配置 服务类 @@ -14,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService; public interface SysSubjectSpecialtyService extends IService { void removeByTemplateDetailsId(Integer id); + + List getByTemplateDetailsId(Integer id); } diff --git a/src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java index 6878709..444445b 100644 --- a/src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java @@ -19,9 +19,10 @@ import org.springframework.stereotype.Service; public class CategoryServiceImpl extends ServiceImpl implements SysCategoryService { @Override - public boolean existsOtherByName(String name, Integer categoryId) { + public boolean existsOtherByName(String name, Integer categoryId,Integer siteId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("name", name); + queryWrapper.eq("site_id", siteId); if (categoryId != null) { queryWrapper.ne("category_id", categoryId); } @@ -29,9 +30,10 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override - public boolean existsByName(String name) { + public boolean existsByName(String name,Integer siteId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("name", name); + queryWrapper.eq("site_id", siteId); if (baseMapper.selectCount(queryWrapper) > 0) { return true; } diff --git a/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java new file mode 100644 index 0000000..0cc9a51 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java @@ -0,0 +1,26 @@ +package com.huoran.iasf.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huoran.iasf.entity.Discipline; +import com.huoran.iasf.mapper.DisciplineMapper; +import com.huoran.iasf.service.DisciplineService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 学科 服务实现类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Service +public class DisciplineServiceImpl extends ServiceImpl implements DisciplineService { + + @Override + public List subjectCategory() { + return baseMapper.selectList(null); + } +} diff --git a/src/main/java/com/huoran/iasf/service/impl/ProfessionalClassServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/ProfessionalClassServiceImpl.java new file mode 100644 index 0000000..2c69929 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/ProfessionalClassServiceImpl.java @@ -0,0 +1,20 @@ +package com.huoran.iasf.service.impl; + +import com.huoran.iasf.entity.ProfessionalClass; +import com.huoran.iasf.mapper.ProfessionalClassMapper; +import com.huoran.iasf.service.ProfessionalClassService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 专业类 服务实现类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Service +public class ProfessionalClassServiceImpl extends ServiceImpl implements ProfessionalClassService { + +} diff --git a/src/main/java/com/huoran/iasf/service/impl/ProfessionalServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/ProfessionalServiceImpl.java new file mode 100644 index 0000000..7bd469a --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/ProfessionalServiceImpl.java @@ -0,0 +1,20 @@ +package com.huoran.iasf.service.impl; + +import com.huoran.iasf.entity.Professional; +import com.huoran.iasf.mapper.ProfessionalMapper; +import com.huoran.iasf.service.ProfessionalService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 专业 服务实现类 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Service +public class ProfessionalServiceImpl extends ServiceImpl implements ProfessionalService { + +} diff --git a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java index a28e016..25bd903 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java @@ -2,30 +2,30 @@ package com.huoran.iasf.service.impl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.huoran.iasf.common.utils.Constant; import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.entity.SysColumn; import com.huoran.iasf.entity.SysContent; import com.huoran.iasf.entity.SysContentFile; +import com.huoran.iasf.mapper.SysColumnMapper; import com.huoran.iasf.mapper.SysContentFileMapper; import com.huoran.iasf.mapper.SysContentMapper; +import com.huoran.iasf.mapper.SysProductDetailsMapper; import com.huoran.iasf.service.SysContentService; -import com.huoran.iasf.vo.req.ArticleModifiedSortReq; +import com.huoran.iasf.service.SysProductDetailsService; import com.huoran.iasf.vo.req.ContentHeavyTitleReqVO; import com.huoran.iasf.vo.req.PageContentReqVO; import com.huoran.iasf.vo.resp.PageContentRespVO; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.beans.factory.annotation.Autowired; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; -import java.util.*; -import java.util.concurrent.TimeUnit; +import java.util.List; /** * @描述:文章管理 服务类 @@ -39,6 +39,12 @@ public class SysContentServiceImpl extends ServiceImpl page = new Page(reqVO.getPageNum(), reqVO.getPageSize()); + // 初始化分页参数 + Page page = new Page<>(reqVO.getPageNum(), reqVO.getPageSize()); + + // 当栏目ID集合不为空且有特定模板ID需求时,调用相应方法获取分页列表 + if (!reqVO.getColumnIds().isEmpty()) { + Integer columnId = reqVO.getColumnIds().get(0); + SysColumn column = columnMapper.selectById(columnId); + if (!ObjectUtil.isEmpty(column) && (column.getTemplateId() == 12||(column.getTemplateId() == 9 &&column.getListStyleId()==73))) { + // 根据模板ID为12的特定情况调用相应方法 + IPage pageList = productDetailsMapper.productCourseList(page, reqVO); + return R.success(pageList); + } + } + + // 默认情况下调用baseMapper获取分页列表 IPage pageList = baseMapper.articlePaginationList(page, reqVO); return R.success(pageList); } + + @Override public R newlyPublishedArticles(PageContentReqVO reqVO) { if (reqVO.getRole() == null) { diff --git a/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java index 3696495..8be3372 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java @@ -1,10 +1,20 @@ package com.huoran.iasf.service.impl; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.ProductDetails; +import com.huoran.iasf.mapper.SysColumnMapper; import com.huoran.iasf.mapper.SysProductDetailsMapper; import com.huoran.iasf.service.SysProductDetailsService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huoran.iasf.vo.DisciplineAndSpecialtyVO; +import com.huoran.iasf.vo.req.PageCourseProductReq; +import com.huoran.iasf.vo.resp.PageCourseProductRespVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; /** @@ -18,20 +28,96 @@ import org.springframework.stereotype.Service; @Service public class SysProductDetailsServiceImpl extends ServiceImpl implements SysProductDetailsService { + @Autowired + private SysColumnMapper columnMapper; + @Autowired + private StringRedisTemplate redisTemplate; @Override - public boolean existsByProductName(String name) { - if (this.count(new QueryWrapper().eq("product_name", name)) > 0) { + public boolean existsByProductName(String name, Integer siteId) { + if (this.count(new QueryWrapper().eq("name", name).eq("site_id", siteId)) > 0) { return true; } return false; } @Override - public boolean existsOtherByProductName(String name, Integer currentId) { - if (this.count(new QueryWrapper().eq("product_name", name).ne("id", currentId)) > 0) { + public boolean existsOtherByProductName(String name, Integer currentId, Integer siteId) { + if (this.count(new QueryWrapper().eq("name", name).ne("id", currentId).eq("site_id", siteId)) > 0) { return true; } return false; } + + @Override + public Integer statisticsOfPageViews(Integer id) { + String key = "courseProductPreview:contentId:" + id; + //查看缓存是否有数据 + String returnValue = redisTemplate.opsForValue().get(key); + if (returnValue == null) { + returnValue = "0"; + } + returnValue = Integer.valueOf(returnValue) + 1 + ""; + //保存到缓存中 + redisTemplate.opsForValue().set(key, returnValue + ""); + + ProductDetails sysContent = new ProductDetails(); + sysContent.setId(id); + sysContent.setTotalBrowsing(Integer.valueOf(returnValue)); + baseMapper.updateById(sysContent); + + return Integer.valueOf(returnValue); + } + + @Override + public R courseProduct(PageCourseProductReq reqVO) { + + /*// 当栏目ID集合不为空且有特定模板ID需求时,调用相应方法获取分页列表 + if (!ObjectUtil.isEmpty(reqVO.getColumnId())) { + SysColumn column = columnMapper.selectById(reqVO.getColumnId()); + if (!ObjectUtil.isEmpty(column) && column.getTemplateId() == 12) { + // 根据模板ID为12的特定情况调用相应方法 + IPage pageList = productDetailsMapper.productCourseList(page, reqVO); + return R.success(pageList); + } + }*/ + + // 初始化分页参数 + Page page = new Page<>(reqVO.getPageNum(), reqVO.getPageSize()); + // 默认情况下调用baseMapper获取分页列表 + IPage pageList = baseMapper.courseProduct(page, reqVO); + + //查询类型/标签 + pageList.getRecords().forEach(item -> { + item.setTag(baseMapper.queryTypeByCategoryId(item.getCategoryId())); + }); + + + //全部:就是展示未删除的且已发布的 + // + + + return R.success(pageList); + } + + @Override + public ProductDetails foregroundPreview(Integer id) { + //预览增加次数 + statisticsOfPageViews(id); + + DisciplineAndSpecialtyVO disciplineAndSpecialtyVO = baseMapper.queryDisciplineAndSpecialty(id); + ProductDetails productDetails = baseMapper.foregroundPreview(id); + + + if (ObjectUtil.isNotEmpty(productDetails)) { + if (ObjectUtil.isNotEmpty(disciplineAndSpecialtyVO)) { + productDetails.setDisciplineName(disciplineAndSpecialtyVO.getDisciplineName()); + productDetails.setProfessionalClassName(disciplineAndSpecialtyVO.getProfessionalClassName()); + productDetails.setProfessionalName(disciplineAndSpecialtyVO.getProfessionalName()); + } + } + return productDetails; + } + + } diff --git a/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java index f8ffc1f..dc76ad3 100644 --- a/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java @@ -7,6 +7,8 @@ import com.huoran.iasf.service.SysSubjectSpecialtyService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 适用学科专业配置 服务实现类 @@ -24,4 +26,11 @@ public class SysSubjectSpecialtyServiceImpl extends ServiceImpl getByTemplateDetailsId(Integer id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("template_details_id", id); + return baseMapper.selectList(queryWrapper); + } } diff --git a/src/main/java/com/huoran/iasf/vo/DisciplineAndSpecialtyVO.java b/src/main/java/com/huoran/iasf/vo/DisciplineAndSpecialtyVO.java new file mode 100644 index 0000000..ead0e99 --- /dev/null +++ b/src/main/java/com/huoran/iasf/vo/DisciplineAndSpecialtyVO.java @@ -0,0 +1,34 @@ +package com.huoran.iasf.vo; + +import com.huoran.iasf.entity.ProductDetails; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + *

+ * 学科 + *

+ * + * @author cheney + * @since 2024-06-17 + */ +@Data +public class DisciplineAndSpecialtyVO { + + @ApiModelProperty(value = "综合产品与课程详情") + private ProductDetails productDetails; + + @ApiModelProperty(value = "学科名称") + private String disciplineName; + + @ApiModelProperty(value = "专业类名称") + private String professionalClassName; + + @ApiModelProperty(value = "专业名称") + private String professionalName; + + + +} diff --git a/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java b/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java new file mode 100644 index 0000000..35a7696 --- /dev/null +++ b/src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java @@ -0,0 +1,38 @@ +package com.huoran.iasf.vo.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class PageCourseProductReq extends PageReqVO { + + //栏目id + @ApiModelProperty(value = "栏目id", name = "columnId", example = "1", required = true) + private Integer columnId; + + //站点id + @ApiModelProperty(value = "站点id", name = "siteId", example = "1", required = true) + private Integer siteId; + + @ApiModelProperty(value = "类型") + private Integer categoryId; + + @ApiModelProperty(value = "分类(多选)") + private Integer classificationTagId; + + @ApiModelProperty("排序筛选参数(1.综合排序2.热销排序3.发布时间)") + private Integer sortFiltering; + + @ApiModelProperty("时间排序(asc,desc)") + private String timeOrdering; + + //搜索条件 + @ApiModelProperty(value = "搜索条件") + private String keyWord; + + //筛选条件:官方精选 + @ApiModelProperty(value = "筛选条件:官方精选") + private Integer selection; + + +} \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java b/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java index e6067d4..86a1ebf 100644 --- a/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java +++ b/src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java @@ -83,6 +83,9 @@ public class PageContentRespVO { @ApiModelProperty(value = "文章总浏览量") private Integer totalBrowsing; + @ApiModelProperty(value = "1是课程产品") + private Integer isCourseProduct; + @ApiModelProperty(value = "父id(第一级为0)") private Integer fatherId; diff --git a/src/main/java/com/huoran/iasf/vo/resp/PageCourseProductRespVO.java b/src/main/java/com/huoran/iasf/vo/resp/PageCourseProductRespVO.java new file mode 100644 index 0000000..df2e234 --- /dev/null +++ b/src/main/java/com/huoran/iasf/vo/resp/PageCourseProductRespVO.java @@ -0,0 +1,59 @@ +package com.huoran.iasf.vo.resp; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.huoran.iasf.entity.Category; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @描述:文章管理 + * @作者: Rong + * @日期: 2022-08-05 + */ +@Data +public class PageCourseProductRespVO { + + + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "主键") + private Integer id; + + @ApiModelProperty(value = "名称,课程或产品的名称,根据类型区分") + private String name; + + + @ApiModelProperty(value = "封面图片URL,课程封面或产品封面") + private String coverImageUrl; + + @ApiModelProperty(value = "来源信息,仅课程详情使用,可为空") + private String source; + + + @ApiModelProperty(value = "简介") + private String introduction; + + @ApiModelProperty(value = "详细描述") + private String detailedDescription; + + @ApiModelProperty(value = "文章总浏览量") + private Integer totalBrowsing; + + @ApiModelProperty(value = "课程分类id或产品分类id") + private String categoryId; + + @ApiModelProperty(value = "类型(多选)") + private String classificationTagId; + + + @ApiModelProperty(value = "分类(单选)") + private String category; + + @ApiModelProperty(value = "标签") + private String tag; + + @ApiModelProperty(value = "是否置顶(0否,1是)") + private Integer isTop; +} \ No newline at end of file diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index c2d41ef..fdd2d8d 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -6,9 +6,9 @@ spring: datasource: master: username: root - password: HuoRan@2021 + password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://139.9.47.170:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 + url: jdbc:mysql://localhost:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 redis: host: localhost # Redis服务器地址 database: 0 # Redis数据库索引(默认为0) diff --git a/src/test/java/com/company/project/CodeGenerator.java b/src/test/java/com/company/project/CodeGenerator.java index 8535c1c..decda4a 100644 --- a/src/test/java/com/company/project/CodeGenerator.java +++ b/src/test/java/com/company/project/CodeGenerator.java @@ -41,10 +41,10 @@ public class CodeGenerator { // 3、数据源配置 DataSourceConfig dsc = new DataSourceConfig(); - dsc.setUrl("jdbc:mysql://139.9.47.170:3306/iasf?serverTimezone=GMT%2B8"); + dsc.setUrl("jdbc:mysql://localhost:3306/iasf?serverTimezone=GMT%2B8"); dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setUsername("root"); - dsc.setPassword("HuoRan@2021"); + dsc.setPassword("123456"); dsc.setDbType(DbType.MYSQL); mpg.setDataSource(dsc); @@ -61,9 +61,9 @@ public class CodeGenerator { // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); - strategy.setInclude("sys_subject_specialty"); + strategy.setInclude("s_discipline","s_professional","s_professional_class"); strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 - //strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀 + strategy.setTablePrefix("s"); //生成实体时去掉表前缀 strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略 strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作