From e1015c43a14afa839f88f6783dc56c7b14616b07 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Thu, 13 Jun 2024 14:29:33 +0800 Subject: [PATCH] commit --- .../java/com/huoran/iasf/common/utils/R.java | 4 +- .../iasf/controller/CategoryController.java | 111 ++++++++++++++++++ .../controller/ProductDetailsController.java | 110 +++++++++++++++++ .../iasf/controller/SysColumnController.java | 2 +- .../iasf/controller/SysContentController.java | 2 +- .../SysSubjectSpecialtyController.java | 21 ++++ .../java/com/huoran/iasf/entity/Category.java | 51 ++++++++ .../huoran/iasf/entity/ProductDetails.java | 93 +++++++++++++++ .../iasf/entity/SysSubjectSpecialty.java | 44 +++++++ .../huoran/iasf/mapper/CategoryMapper.java | 16 +++ .../iasf/mapper/ProductDetailsMapper.java | 16 +++ .../iasf/mapper/SysProductDetailsMapper.java | 16 +++ .../mapper/SysSubjectSpecialtyMapper.java | 16 +++ .../huoran/iasf/mapper/xml/CategoryMapper.xml | 5 + .../iasf/mapper/xml/ProductDetailsMapper.xml | 5 + .../mapper/xml/SysProductDetailsMapper.xml | 5 + .../mapper/xml/SysSubjectSpecialtyMapper.xml | 5 + .../iasf/service/SysCategoryService.java | 19 +++ .../service/SysProductDetailsService.java | 19 +++ .../service/SysSubjectSpecialtyService.java | 17 +++ .../service/impl/CategoryServiceImpl.java | 40 +++++++ .../impl/SysProductDetailsServiceImpl.java | 37 ++++++ .../impl/SysSubjectSpecialtyServiceImpl.java | 27 +++++ src/main/resources/application-prod.yml | 18 +-- .../com/company/project/CodeGenerator.java | 4 +- 25 files changed, 684 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/huoran/iasf/controller/CategoryController.java create mode 100644 src/main/java/com/huoran/iasf/controller/ProductDetailsController.java create mode 100644 src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java create mode 100644 src/main/java/com/huoran/iasf/entity/Category.java create mode 100644 src/main/java/com/huoran/iasf/entity/ProductDetails.java create mode 100644 src/main/java/com/huoran/iasf/entity/SysSubjectSpecialty.java create mode 100644 src/main/java/com/huoran/iasf/mapper/CategoryMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/ProductDetailsMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/SysProductDetailsMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/SysSubjectSpecialtyMapper.java create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/CategoryMapper.xml create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/ProductDetailsMapper.xml create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml create mode 100644 src/main/java/com/huoran/iasf/mapper/xml/SysSubjectSpecialtyMapper.xml create mode 100644 src/main/java/com/huoran/iasf/service/SysCategoryService.java create mode 100644 src/main/java/com/huoran/iasf/service/SysProductDetailsService.java create mode 100644 src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java create mode 100644 src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java create mode 100644 src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java create mode 100644 src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.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 b23c654..7eb2634 100644 --- a/src/main/java/com/huoran/iasf/common/utils/R.java +++ b/src/main/java/com/huoran/iasf/common/utils/R.java @@ -128,5 +128,7 @@ public class R { } - + public static R result(boolean delState, String s) { + return delState ? success(s) : fail(s); + } } diff --git a/src/main/java/com/huoran/iasf/controller/CategoryController.java b/src/main/java/com/huoran/iasf/controller/CategoryController.java new file mode 100644 index 0000000..a90555e --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/CategoryController.java @@ -0,0 +1,111 @@ +package com.huoran.iasf.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +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.Category; +import com.huoran.iasf.service.SysCategoryService; +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.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 产品与课程分类表控制类 + * 提供分类管理相关接口 + * + * @author Rong + * @date 2024-06-12 + */ +@RestController +@RequestMapping("/categoryService/Category") +@Api(value = "产品与课程分类管理接口", tags = "A-产品与课程分类管理") +public class CategoryController { + + @Autowired + private SysCategoryService service; + + /** + * 保存或更新分类信息 + * + * @param category 分类对象 + * @return 操作结果 + */ + @PostMapping("/saveOrUpdate") + @ApiOperation("保存或更新分类") + @Transactional(rollbackFor = Exception.class) + public R saveOrUpdate(@RequestBody @Validated Category category) { + try { + // 增加重复检查逻辑 + boolean isDuplicate = false; + if (category.getCategoryId() != null) { + // 更新逻辑,排除当前记录自身 + isDuplicate = service.existsOtherByName(category.getName(), category.getCategoryId()); + } else { + // 新增逻辑,直接检查名称是否存在 + isDuplicate = service.existsByName(category.getName()); + } + + if (isDuplicate) { + return R.fail("分类名称已存在,请检查后重新提交"); + } + + boolean operationResult = service.saveOrUpdate(category); + + return R.result(operationResult, operationResult ? "操作成功" : "操作失败"); + } catch (Exception e) { + throw new BusinessException(BaseResponseCode.SYSTEM_BUSY); + } + } + + + /** + * 获取分类列表,支持类型筛选 + * + * @param type 类型标识,如"course"或"product" + * @return 分类列表 + */ + @PostMapping("/list") + @ApiOperation("根据类型获取分类列表") + public R categoryList(@ApiParam(value = "类型标识,区分课程或产品", allowableValues = "0:课程,1:产品") @RequestParam(required = false) Integer type) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("type", type); + List categories = service.list(queryWrapper); + return R.success(categories); + } + + /** + * 查询分类详情 + * + * @param id 分类ID + * @return 分类详情 + */ + @PostMapping("/findById") + @ApiOperation("根据ID查询分类详情") + public R findById(@ApiParam(name = "id", value = "分类ID", required = true) @RequestParam Integer id) { + Category category = service.getById(id); + return R.success(category); + } + + /** + * 批量删除分类 + * + * @param ids 分类ID列表 + * @return 操作结果 + */ + @PostMapping("/batchDelete") + @ApiOperation("批量删除分类") + public R batchDeletion(@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/ProductDetailsController.java b/src/main/java/com/huoran/iasf/controller/ProductDetailsController.java new file mode 100644 index 0000000..8bc1397 --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/ProductDetailsController.java @@ -0,0 +1,110 @@ +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 3cc5a2e..6411093 100644 --- a/src/main/java/com/huoran/iasf/controller/SysColumnController.java +++ b/src/main/java/com/huoran/iasf/controller/SysColumnController.java @@ -154,7 +154,7 @@ public class SysColumnController { // 检查缓存数据是否存在。 if (cachedFieldsObj == null) { - return null; + return R.success(); } // 检查缓存数据类型是否为String。 diff --git a/src/main/java/com/huoran/iasf/controller/SysContentController.java b/src/main/java/com/huoran/iasf/controller/SysContentController.java index 3bbcf37..f655094 100644 --- a/src/main/java/com/huoran/iasf/controller/SysContentController.java +++ b/src/main/java/com/huoran/iasf/controller/SysContentController.java @@ -277,7 +277,7 @@ public class SysContentController { Object cachedFieldsObj = redisTemplate.opsForValue().get(key); if (cachedFieldsObj == null) { - return null; + return R.success(); } if (!(cachedFieldsObj instanceof String)) { diff --git a/src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java b/src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java new file mode 100644 index 0000000..72e3720 --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/SysSubjectSpecialtyController.java @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000..b9f05ad --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/Category.java @@ -0,0 +1,51 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 产品与课程分类表 + *

+ * + * @author cheney + * @since 2024-06-12 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("sys_category") +@ApiModel(value = "Category对象", description = "产品与课程分类表") +public class Category implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "分类ID") + @TableId(value = "category_id", type = IdType.AUTO) + private Integer categoryId; + + @ApiModelProperty(value = "分类名称") + private String name; + + @ApiModelProperty(value = "类型标识,区分是课程还是产品)0:课程,1:产品(0:课程,1:产品)") + private Integer type; + + @ApiModelProperty(value = "分类描述") + private String description; + + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + + +} diff --git a/src/main/java/com/huoran/iasf/entity/ProductDetails.java b/src/main/java/com/huoran/iasf/entity/ProductDetails.java new file mode 100644 index 0000000..8ea5a7a --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/ProductDetails.java @@ -0,0 +1,93 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @描述:综合产品与课程详情信息表 + * @作者: Rong + * @日期: 2024-06-13 + */ +@Data +@ApiModel(value = "综合产品与课程详情信息表") +@TableName("sys_product_details") +public class ProductDetails implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.AUTO) + @ApiModelProperty(value = "主键ID") + private Integer id; + + @ApiModelProperty(value = "模板ID") + private Integer templateId; + + @ApiModelProperty(value = "名称,课程或产品的名称,根据类型区分") + private String name; + + @ApiModelProperty(value = "类型标识,区分是课程还是产品") + private String type; + + @ApiModelProperty(value = "课程分类id或产品分类id,根据类型使用") + private String categoryId; + + @ApiModelProperty(value = "产品分类标签id,根据类型区分使用") + private String classificationTagId; + + @ApiModelProperty(value = "封面图片URL,课程封面或产品封面") + private String coverImageUrl; + + @ApiModelProperty(value = "来源信息,仅课程详情使用,可为空") + private String source; + + @ApiModelProperty(value = "按钮跳转名称") + private String jumpButtonName; + + @ApiModelProperty(value = "按钮跳转链接") + private String jumpLinkUrl; + + @ApiModelProperty(value = "简介,课程介绍或产品简介,根据类型区分使用") + private String introduction; + + @ApiModelProperty(value = "详细描述,课程或产品的详细说明") + private String detailedDescription; + + @ApiModelProperty(value = "发布状态,0草稿,1已发布") + private Boolean publishStatus; + + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + @ApiModelProperty(value = "是否删除(1未删除;0已删除)") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "课程类型,仅课程使用,可为空") + private String courseType; + + @ApiModelProperty(value = "匹配课程,仅产品使用,可存储课程ID列表") + private String matchedCourses; + + @ApiModelProperty(value = "预计课时,仅产品使用,可为空") + private Integer estimatedHours; + + @ApiModelProperty(value = "适用场景,仅产品使用,可为空") + private String applicableScenarios; + + @ApiModelProperty(value = "学科专业类") + @TableField(exist = false) + private List subjectSpecialtyList; + + +} \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/entity/SysSubjectSpecialty.java b/src/main/java/com/huoran/iasf/entity/SysSubjectSpecialty.java new file mode 100644 index 0000000..f6f0f54 --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/SysSubjectSpecialty.java @@ -0,0 +1,44 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +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-13 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "SysSubjectSpecialty对象", description = "适用学科专业配置") +public class SysSubjectSpecialty implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "模板详情id") + private Integer templateDetailsId; + + @ApiModelProperty(value = "学科类别id,仅产品使用,可为空") + private Integer subjectCategoryId; + + @ApiModelProperty(value = "专业类别id,仅产品使用,可为空") + private Integer professionalCategoryId; + + @ApiModelProperty(value = "专业id,仅产品使用,可为空") + private Integer majorId; + + +} diff --git a/src/main/java/com/huoran/iasf/mapper/CategoryMapper.java b/src/main/java/com/huoran/iasf/mapper/CategoryMapper.java new file mode 100644 index 0000000..a8834ec --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/CategoryMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import com.huoran.iasf.entity.Category; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 产品与课程分类表 Mapper 接口 + *

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

+ * 综合产品与课程详情信息表 Mapper 接口 + *

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

+ * 综合产品与课程详情信息表 Mapper 接口 + *

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

+ * 适用学科专业配置 Mapper 接口 + *

+ * + * @author cheney + * @since 2024-06-13 + */ +public interface SysSubjectSpecialtyMapper extends BaseMapper { + +} diff --git a/src/main/java/com/huoran/iasf/mapper/xml/CategoryMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/CategoryMapper.xml new file mode 100644 index 0000000..79fac18 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/CategoryMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/mapper/xml/ProductDetailsMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/ProductDetailsMapper.xml new file mode 100644 index 0000000..1eaa7c6 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/ProductDetailsMapper.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 new file mode 100644 index 0000000..1b71784 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysProductDetailsMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysSubjectSpecialtyMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysSubjectSpecialtyMapper.xml new file mode 100644 index 0000000..f6d3db1 --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysSubjectSpecialtyMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/java/com/huoran/iasf/service/SysCategoryService.java b/src/main/java/com/huoran/iasf/service/SysCategoryService.java new file mode 100644 index 0000000..7e1c5ab --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/SysCategoryService.java @@ -0,0 +1,19 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.Category; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 产品与课程分类表 服务类 + *

+ * + * @author cheney + * @since 2024-06-12 + */ +public interface SysCategoryService extends IService { + + boolean existsOtherByName(String name, Integer categoryId); + + boolean existsByName(String name); +} diff --git a/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java b/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java new file mode 100644 index 0000000..b7c819d --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/SysProductDetailsService.java @@ -0,0 +1,19 @@ +package com.huoran.iasf.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.huoran.iasf.entity.ProductDetails; + +/** + *

+ * 综合产品与课程详情信息表 服务类 + *

+ * + * @author cheney + * @since 2024-06-12 + */ +public interface SysProductDetailsService extends IService { + + boolean existsByProductName(String name); + + boolean existsOtherByProductName(String name, Integer currentId); +} diff --git a/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java b/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java new file mode 100644 index 0000000..d044920 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/SysSubjectSpecialtyService.java @@ -0,0 +1,17 @@ +package com.huoran.iasf.service; + +import com.huoran.iasf.entity.SysSubjectSpecialty; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 适用学科专业配置 服务类 + *

+ * + * @author cheney + * @since 2024-06-13 + */ +public interface SysSubjectSpecialtyService extends IService { + + void removeByTemplateDetailsId(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 new file mode 100644 index 0000000..6878709 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/CategoryServiceImpl.java @@ -0,0 +1,40 @@ +package com.huoran.iasf.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.iasf.entity.Category; +import com.huoran.iasf.mapper.CategoryMapper; +import com.huoran.iasf.service.SysCategoryService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 产品与课程分类表 服务实现类 + *

+ * + * @author cheney + * @since 2024-06-12 + */ +@Service +public class CategoryServiceImpl extends ServiceImpl implements SysCategoryService { + + @Override + public boolean existsOtherByName(String name, Integer categoryId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("name", name); + if (categoryId != null) { + queryWrapper.ne("category_id", categoryId); + } + return false; + } + + @Override + public boolean existsByName(String name) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("name", name); + if (baseMapper.selectCount(queryWrapper) > 0) { + return true; + } + return false; + } +} diff --git a/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java new file mode 100644 index 0000000..3696495 --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/SysProductDetailsServiceImpl.java @@ -0,0 +1,37 @@ +package com.huoran.iasf.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.iasf.entity.ProductDetails; +import com.huoran.iasf.mapper.SysProductDetailsMapper; +import com.huoran.iasf.service.SysProductDetailsService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 综合产品与课程详情信息表 服务实现类 + *

+ * + * @author cheney + * @since 2024-06-12 + */ +@Service +public class SysProductDetailsServiceImpl extends ServiceImpl implements SysProductDetailsService { + + + @Override + public boolean existsByProductName(String name) { + if (this.count(new QueryWrapper().eq("product_name", name)) > 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) { + return true; + } + return false; + } +} diff --git a/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java new file mode 100644 index 0000000..f8ffc1f --- /dev/null +++ b/src/main/java/com/huoran/iasf/service/impl/SysSubjectSpecialtyServiceImpl.java @@ -0,0 +1,27 @@ +package com.huoran.iasf.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.iasf.entity.SysSubjectSpecialty; +import com.huoran.iasf.mapper.SysSubjectSpecialtyMapper; +import com.huoran.iasf.service.SysSubjectSpecialtyService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 适用学科专业配置 服务实现类 + *

+ * + * @author cheney + * @since 2024-06-13 + */ +@Service +public class SysSubjectSpecialtyServiceImpl extends ServiceImpl implements SysSubjectSpecialtyService { + + @Override + public void removeByTemplateDetailsId(Integer id) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("template_details_id", id); + this.remove(queryWrapper); + } +} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 349b649..245700d 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,4 +1,4 @@ -# 生产环境配置 +# 开发环境配置 spring: datasource: dynamic: @@ -8,11 +8,9 @@ spring: username: root password: HuoRan@2021 driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://139.9.47.170:3306/iasf?serverTimezone=GMT%2B8 - cache: - type: redis + url: jdbc:mysql://139.9.47.170:3306/iasf?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8 redis: - host: 127.0.0.1 # Redis服务器地址 + host: localhost # Redis服务器地址 database: 0 # Redis数据库索引(默认为0) port: 6379 # Redis服务器连接端口 password: HuoRan@2021 # Redis服务器连接密码(默认为空) @@ -22,18 +20,10 @@ spring: max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) max-idle: 8 # 连接池中的最大空闲连接 min-idle: 0 # 连接池中的最小空闲连接 - timeout: 3000ms # 连接超时时间(毫秒) - -singleServerConfig: - address: "redis://127.0.0.1:6379" - password: HuoRan@2021 - + timeout: 3000ms # 连接超时时间(毫秒 file: #文件上传目录 绝对路径 末尾请加 / linux path: /usr/local/huoran/huorantech_website/files/ #文件预览url url: /iasf/sysFiles/preview/ ip: https://huorantech.com - -knife4j: - production: true #生成环境禁用查看文档 \ No newline at end of file diff --git a/src/test/java/com/company/project/CodeGenerator.java b/src/test/java/com/company/project/CodeGenerator.java index c5788c8..8535c1c 100644 --- a/src/test/java/com/company/project/CodeGenerator.java +++ b/src/test/java/com/company/project/CodeGenerator.java @@ -61,9 +61,9 @@ public class CodeGenerator { // 5、策略配置 StrategyConfig strategy = new StrategyConfig(); - strategy.setInclude("sys_footer_setup","sys_footer_setup_scope_of_application"); + strategy.setInclude("sys_subject_specialty"); strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 -// strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀 + //strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀 strategy.setColumnNaming(NamingStrategy.underline_to_camel);//数据库表字段映射到实体的命名策略 strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作