master
rong.liu 5 months ago
parent 32502a5b32
commit 9b29319c5d
  1. 5
      src/main/java/com/huoran/iasf/common/utils/R.java
  2. 12
      src/main/java/com/huoran/iasf/controller/CategoryController.java
  3. 67
      src/main/java/com/huoran/iasf/controller/DisciplineController.java
  4. 110
      src/main/java/com/huoran/iasf/controller/ProductDetailsController.java
  5. 12
      src/main/java/com/huoran/iasf/controller/SysColumnController.java
  6. 214
      src/main/java/com/huoran/iasf/controller/SysProductDetailsController.java
  7. 21
      src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java
  8. 7
      src/main/java/com/huoran/iasf/entity/Category.java
  9. 37
      src/main/java/com/huoran/iasf/entity/Discipline.java
  10. 57
      src/main/java/com/huoran/iasf/entity/ProductDetails.java
  11. 40
      src/main/java/com/huoran/iasf/entity/Professional.java
  12. 40
      src/main/java/com/huoran/iasf/entity/ProfessionalClass.java
  13. 16
      src/main/java/com/huoran/iasf/mapper/DisciplineMapper.java
  14. 16
      src/main/java/com/huoran/iasf/mapper/ProfessionalClassMapper.java
  15. 16
      src/main/java/com/huoran/iasf/mapper/ProfessionalMapper.java
  16. 21
      src/main/java/com/huoran/iasf/mapper/SysProductDetailsMapper.java
  17. 5
      src/main/java/com/huoran/iasf/mapper/xml/DisciplineMapper.xml
  18. 5
      src/main/java/com/huoran/iasf/mapper/xml/ProfessionalClassMapper.xml
  19. 5
      src/main/java/com/huoran/iasf/mapper/xml/ProfessionalMapper.xml
  20. 250
      src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml
  21. 19
      src/main/java/com/huoran/iasf/service/DisciplineService.java
  22. 16
      src/main/java/com/huoran/iasf/service/ProfessionalClassService.java
  23. 16
      src/main/java/com/huoran/iasf/service/ProfessionalService.java
  24. 4
      src/main/java/com/huoran/iasf/service/SysCategoryService.java
  25. 13
      src/main/java/com/huoran/iasf/service/SysProductDetailsService.java
  26. 4
      src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java
  27. 6
      src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java
  28. 26
      src/main/java/com/huoran/iasf/service/impl/DisciplineServiceImpl.java
  29. 20
      src/main/java/com/huoran/iasf/service/impl/ProfessionalClassServiceImpl.java
  30. 20
      src/main/java/com/huoran/iasf/service/impl/ProfessionalServiceImpl.java
  31. 40
      src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java
  32. 96
      src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java
  33. 9
      src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java
  34. 34
      src/main/java/com/huoran/iasf/vo/DisciplineAndSpecialtyVO.java
  35. 38
      src/main/java/com/huoran/iasf/vo/req/PageCourseProductReq.java
  36. 3
      src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java
  37. 59
      src/main/java/com/huoran/iasf/vo/resp/PageCourseProductRespVO.java
  38. 4
      src/main/resources/application-test.yml
  39. 8
      src/test/java/com/company/project/CodeGenerator.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);
}
}

@ -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<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.eq("site_id", siteId);
List<Category> categories = service.list(queryWrapper);
return R.success(categories);
}

@ -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<Discipline> 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<ProfessionalClass> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("discipline_id", disciplineId);
List<ProfessionalClass> 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<Professional> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("professional_class_id", professionalClassId);
List<Professional> list = professionalService.list(queryWrapper);
return R.success(list);
}
}

@ -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<Integer> ids) {
if (ids == null || ids.isEmpty()) {
return R.fail("请选择要删除的记录");
}
boolean delState = service.removeByIds(ids);
return R.result(delState, delState ? "批量删除成功" : "批量删除失败");
}
}

@ -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)

@ -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<ProductDetails> 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<Integer> 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<ProductDetails> 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);
}
}

@ -1,21 +0,0 @@
package com.huoran.iasf.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 适用学科专业配置 前端控制器
* </p>
*
* @author cheney
* @since 2024-06-13
*/
@RestController
@RequestMapping("//sys-subject-specialty")
public class SysSubjectSpecialtyController {
}

@ -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;
}

@ -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;
/**
* <p>
* 学科
* </p>
*
* @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;
}

@ -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<SysSubjectSpecialty> 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;
}

@ -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;
/**
* <p>
* 专业
* </p>
*
* @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;
}

@ -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;
/**
* <p>
* 专业类
* </p>
*
* @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;
}

@ -0,0 +1,16 @@
package com.huoran.iasf.mapper;
import com.huoran.iasf.entity.Discipline;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 学科 Mapper 接口
* </p>
*
* @author cheney
* @since 2024-06-17
*/
public interface DisciplineMapper extends BaseMapper<Discipline> {
}

@ -0,0 +1,16 @@
package com.huoran.iasf.mapper;
import com.huoran.iasf.entity.ProfessionalClass;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 专业类 Mapper 接口
* </p>
*
* @author cheney
* @since 2024-06-17
*/
public interface ProfessionalClassMapper extends BaseMapper<ProfessionalClass> {
}

@ -0,0 +1,16 @@
package com.huoran.iasf.mapper;
import com.huoran.iasf.entity.Professional;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 专业 Mapper 接口
* </p>
*
* @author cheney
* @since 2024-06-17
*/
public interface ProfessionalMapper extends BaseMapper<Professional> {
}

@ -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;
/**
* <p>
@ -12,5 +23,15 @@ import com.huoran.iasf.entity.ProductDetails;
* @since 2024-06-12
*/
public interface SysProductDetailsMapper extends BaseMapper<ProductDetails> {
IPage<PageContentRespVO> productCourseList(Page<PageContentRespVO> page, @Param("req") PageContentReqVO req);
IPage<PageCourseProductRespVO> courseProduct(Page<PageCourseProductRespVO> page, @Param("req") PageCourseProductReq req);
String queryTypeByCategoryId(@Param("classificationTagId") String classificationTagId);
ProductDetails foregroundPreview(@Param("id") Integer id);
DisciplineAndSpecialtyVO queryDisciplineAndSpecialty(@Param("id") Integer id);
}

@ -0,0 +1,5 @@
<?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="com.huoran.iasf.mapper.DisciplineMapper">
</mapper>

@ -0,0 +1,5 @@
<?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="com.huoran.iasf.mapper.ProfessionalClassMapper">
</mapper>

@ -0,0 +1,5 @@
<?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="com.huoran.iasf.mapper.ProfessionalMapper">
</mapper>

@ -1,5 +1,255 @@
<?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="com.huoran.iasf.mapper.SysProductDetailsMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.huoran.iasf.entity.ProductDetails">
<id column="id" property="id"/>
<result column="column_id" property="columnId"/>
<result column="name" property="name"/>
<result column="category_id" property="categoryId"/>
<result column="classification_tag_id" property="classificationTagId"/>
<result column="cover_image_url" property="coverImageUrl"/>
<result column="source" property="source"/>
<result column="jump_button_name" property="jumpButtonName"/>
<result column="jump_link_url" property="jumpLinkUrl"/>
<result column="introduction" property="introduction"/>
<result column="detailed_description" property="detailedDescription"/>
<result column="publish_status" property="publishStatus"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="deleted" property="deleted"/>
<result column="course_type" property="courseType"/>
<result column="matched_courses" property="matchedCourses"/>
<result column="estimated_hours" property="estimatedHours"/>
<result column="applicable_scenarios" property="applicableScenarios"/>
<result column="founder_id" property="founderId"/>
<result column="editor_id" property="editorId"/>
<result column="total_browsing" property="totalBrowsing"/>
<result column="site_id" property="siteId"/>
<result column="article_template" property="articleTemplate"/>
<result column="template_status" property="templateStatus"/>
<result column="is_top" property="isTop"/>
<result column="is_disable" property="isDisable"/>
<result column="top_time" property="topTime"/>
</resultMap>
<select id="productCourseList" resultType="com.huoran.iasf.vo.resp.PageContentRespVO">
SELECT
d.id,
d.NAME AS title,
d.column_id,
d.cover_image_url AS titleImg,
d.source AS source,
d.publish_status AS isRelease,
d.total_browsing AS totalBrowsing,
d.is_disable AS isDisable,
sc.column_name AS columnName,
fu.real_name AS founderName,
eu.real_name AS editorName,
sc.type_id AS typeId,
d.release_time AS releaseTime,
COALESCE ( ( SELECT cc.classification_name FROM sys_content_classification cc WHERE cc.id = d.category_id ),
'暂无' ) AS classificationName,
'1' as isCourseProduct,
d.is_top AS isTop,
d.update_time as updateTime
FROM
sys_product_details d
LEFT JOIN sys_column sc ON sc.id = d.column_id
LEFT JOIN sys_user fu ON fu.id = d.founder_id
LEFT JOIN sys_user eu ON eu.id = d.editor_id
WHERE
d.deleted = 1
<if test="req.columnIds.size() > 0">
AND d.column_id IN
<foreach item="item" index="index" collection="req.columnIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
AND d.site_id = #{req.siteId}
<if test="req.title != null and req.title != ''">
AND d.name LIKE CONCAT('%',#{req.title},'%')
</if>
<if test="req.founder != null and req.founder != ''">
AND fu.real_name LIKE CONCAT('%',#{req.founder},'%')
</if>
<if test="req.editor != null and req.editor !=''">
AND eu.real_name LIKE CONCAT('%',#{req.editor},'%')
</if>
<if test="req.column != null and req.column !=''">
AND sc.column_name LIKE CONCAT('%',#{req.column},'%')
</if>
<if test="req.isDisable != null">
AND d.is_disable = #{req.isDisable}
</if>
<choose>
<when test="req.modifiedTimeSort ==0">
ORDER BY d.update_time desc
</when>
<when test="req.modifiedTimeSort ==1">
ORDER BY d.update_time asc
</when>
<when test="req.publicationTimeSort ==0">
ORDER BY d.release_time desc
</when>
<when test="req.publicationTimeSort ==1">
ORDER BY d.release_time asc
</when>
<when test="req.topSort ==0">
ORDER BY is_top asc,
top_time asc
</when>
<when test="req.topSort ==1">
ORDER BY is_top desc,
top_time DESC
</when>
<otherwise>
ORDER BY
CASE
WHEN d.release_time = '—' THEN
1 ELSE 0
END,
d.release_time desc,d.create_time desc
</otherwise>
</choose>
</select>
<!--<select id="courseProduct" resultType="com.huoran.iasf.vo.resp.PageCourseProductRespVO">
SELECT
id,
d.NAME,
d.cover_image_url,
d.source,
d.total_browsing,
d.column_id,
d.category_id,
d.classification_tag_id,
c.NAME AS category
FROM
sys_product_details d
left JOIN sys_category c ON c.category_id = d.classification_tag_id
WHERE
d.deleted = 1
AND d.site_id = #{req.siteId}
and d.column_id = #{req.columnId}
<if test="req.categoryId!=null and req.categoryId !=''">
and find_in_set(#{req.categoryId},d.category_id)
</if>
<if test="req.classificationTagId!=null and req.classificationTagId!=''">
and d.classification_tag_id = #{req.classificationTagId}
</if>
and d.publish_status = 1
</select>-->
<select id="courseProduct" resultType="com.huoran.iasf.vo.resp.PageCourseProductRespVO">
SELECT
id,
d.NAME,
d.cover_image_url,
d.source,
d.total_browsing,
d.column_id,
d.category_id,
d.classification_tag_id,
d.is_top,
d.introduction,
d.detailed_description,
c.NAME AS category
FROM
sys_product_details d
LEFT JOIN sys_category c ON c.category_id = d.classification_tag_id
WHERE
d.deleted = 1
AND d.site_id = #{req.siteId}
AND d.column_id = #{req.columnId}
<if test="req.selection == 1">
AND is_top = 1
</if>
<if test="req.keyWord!=null and req.keyWord!=''">
and d.NAME LIKE CONCAT('%',#{req.keyWord},'%')
</if>
<if test="req.categoryId != null and req.categoryId != ''">
AND FIND_IN_SET(#{req.categoryId}, d.category_id)
</if>
<if test="req.classificationTagId != null and req.classificationTagId != ''">
AND d.classification_tag_id = #{req.classificationTagId}
</if>
AND d.publish_status = 1
ORDER BY
<choose>
<when test="req.sortFiltering == 1">
ISNULL(d.is_top) DESC, d.release_time DESC
</when>
<when test="req.sortFiltering == 2">
d.total_browsing DESC
</when>
<when test="req.sortFiltering == 3">
<choose>
<when test="req.timeOrdering == 'asc'">
d.release_time ASC
</when>
<otherwise>
d.release_time DESC
</otherwise>
</choose>
</when>
<otherwise>
d.release_time DESC
</otherwise>
</choose>
</select>
<select id="foregroundPreview" resultType="com.huoran.iasf.entity.ProductDetails">
SELECT
d.*
FROM
sys_product_details d
WHERE
d.deleted = 1
and d.id = #{id}
</select>
<select id="queryDisciplineAndSpecialty" resultType="com.huoran.iasf.vo.DisciplineAndSpecialtyVO">
SELECT
GROUP_CONCAT(DISTINCT d.discipline_name) as disciplineName,
GROUP_CONCAT(DISTINCT c.professional_class_name) as professionalClassName,
GROUP_CONCAT(DISTINCT p.professional_name ) as professionalName
FROM
sys_subject_specialty s
INNER JOIN s_discipline d ON s.subject_category_id = d.discipline_id
INNER JOIN s_professional_class c ON c.professional_class_id = s.professional_category_id
INNER JOIN s_professional p ON p.professional_id = s.major_id
WHERE
s.template_details_id = #{id};
</select>
<select id="queryTypeByCategoryId" resultType="java.lang.String">
SELECT
GROUP_CONCAT( DISTINCT NAME )
FROM
sys_category s
WHERE
FIND_IN_SET( s.category_id, #{classificationTagId} )
</select>
</mapper>

@ -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;
/**
* <p>
* 学科 服务类
* </p>
*
* @author cheney
* @since 2024-06-17
*/
public interface DisciplineService extends IService<Discipline> {
List<Discipline> subjectCategory();
}

@ -0,0 +1,16 @@
package com.huoran.iasf.service;
import com.huoran.iasf.entity.ProfessionalClass;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 专业类 服务类
* </p>
*
* @author cheney
* @since 2024-06-17
*/
public interface ProfessionalClassService extends IService<ProfessionalClass> {
}

@ -0,0 +1,16 @@
package com.huoran.iasf.service;
import com.huoran.iasf.entity.Professional;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 专业 服务类
* </p>
*
* @author cheney
* @since 2024-06-17
*/
public interface ProfessionalService extends IService<Professional> {
}

@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface SysCategoryService extends IService<Category> {
boolean existsOtherByName(String name, Integer categoryId);
boolean existsOtherByName(String name, Integer categoryId,Integer siteId);
boolean existsByName(String name);
boolean existsByName(String name,Integer siteId);
}

@ -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;
/**
* <p>
@ -13,7 +16,13 @@ import com.huoran.iasf.entity.ProductDetails;
*/
public interface SysProductDetailsService extends IService<ProductDetails> {
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);
}

@ -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;
/**
* <p>
* 适用学科专业配置 服务类
@ -14,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
public interface SysSubjectSpecialtyService extends IService<SysSubjectSpecialty> {
void removeByTemplateDetailsId(Integer id);
List<SysSubjectSpecialty> getByTemplateDetailsId(Integer id);
}

@ -19,9 +19,10 @@ import org.springframework.stereotype.Service;
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements SysCategoryService {
@Override
public boolean existsOtherByName(String name, Integer categoryId) {
public boolean existsOtherByName(String name, Integer categoryId,Integer siteId) {
QueryWrapper<Category> 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<CategoryMapper, Category> i
}
@Override
public boolean existsByName(String name) {
public boolean existsByName(String name,Integer siteId) {
QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name", name);
queryWrapper.eq("site_id", siteId);
if (baseMapper.selectCount(queryWrapper) > 0) {
return true;
}

@ -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;
/**
* <p>
* 学科 服务实现类
* </p>
*
* @author cheney
* @since 2024-06-17
*/
@Service
public class DisciplineServiceImpl extends ServiceImpl<DisciplineMapper, Discipline> implements DisciplineService {
@Override
public List<Discipline> subjectCategory() {
return baseMapper.selectList(null);
}
}

@ -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;
/**
* <p>
* 专业类 服务实现类
* </p>
*
* @author cheney
* @since 2024-06-17
*/
@Service
public class ProfessionalClassServiceImpl extends ServiceImpl<ProfessionalClassMapper, ProfessionalClass> implements ProfessionalClassService {
}

@ -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;
/**
* <p>
* 专业 服务实现类
* </p>
*
* @author cheney
* @since 2024-06-17
*/
@Service
public class ProfessionalServiceImpl extends ServiceImpl<ProfessionalMapper, Professional> implements ProfessionalService {
}

@ -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<SysContentMapper, SysCont
@Autowired
private SysContentMapper mapper;
@Autowired
private SysColumnMapper columnMapper;
@Autowired
private SysProductDetailsMapper productDetailsMapper;
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
@ -67,11 +73,27 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
@Override
public R articlePaginationList(PageContentReqVO reqVO) {
Page<PageContentRespVO> page = new Page<PageContentRespVO>(reqVO.getPageNum(), reqVO.getPageSize());
// 初始化分页参数
Page<PageContentRespVO> 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<PageContentRespVO> pageList = productDetailsMapper.productCourseList(page, reqVO);
return R.success(pageList);
}
}
// 默认情况下调用baseMapper获取分页列表
IPage<PageContentRespVO> pageList = baseMapper.articlePaginationList(page, reqVO);
return R.success(pageList);
}
@Override
public R newlyPublishedArticles(PageContentReqVO reqVO) {
if (reqVO.getRole() == null) {

@ -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<SysProductDetailsMapper, ProductDetails> implements SysProductDetailsService {
@Autowired
private SysColumnMapper columnMapper;
@Autowired
private StringRedisTemplate redisTemplate;
@Override
public boolean existsByProductName(String name) {
if (this.count(new QueryWrapper<ProductDetails>().eq("product_name", name)) > 0) {
public boolean existsByProductName(String name, Integer siteId) {
if (this.count(new QueryWrapper<ProductDetails>().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<ProductDetails>().eq("product_name", name).ne("id", currentId)) > 0) {
public boolean existsOtherByProductName(String name, Integer currentId, Integer siteId) {
if (this.count(new QueryWrapper<ProductDetails>().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<PageContentRespVO> pageList = productDetailsMapper.productCourseList(page, reqVO);
return R.success(pageList);
}
}*/
// 初始化分页参数
Page<PageCourseProductRespVO> page = new Page<>(reqVO.getPageNum(), reqVO.getPageSize());
// 默认情况下调用baseMapper获取分页列表
IPage<PageCourseProductRespVO> 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;
}
}

@ -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;
/**
* <p>
* 适用学科专业配置 服务实现类
@ -24,4 +26,11 @@ public class SysSubjectSpecialtyServiceImpl extends ServiceImpl<SysSubjectSpecia
queryWrapper.eq("template_details_id", id);
this.remove(queryWrapper);
}
@Override
public List<SysSubjectSpecialty> getByTemplateDetailsId(Integer id) {
QueryWrapper<SysSubjectSpecialty> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("template_details_id", id);
return baseMapper.selectList(queryWrapper);
}
}

@ -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;
/**
* <p>
* 学科
* </p>
*
* @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;
}

@ -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;
}

@ -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;

@ -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;
}

@ -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)

@ -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链式操作

Loading…
Cancel
Save