diff --git a/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java b/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java index b41faea..d2b5c07 100644 --- a/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java +++ b/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java @@ -54,6 +54,8 @@ public enum BaseResponseCode implements ResponseCodeInterface { ROLE_ERROR(401017, "账号角色被删,请联系管理员添加角色后再试"), EXCEL_FILE_NULL(40006, "导入失败,导入数据为空!"), + DATA_DUPLICATION(40007, "方案存在重复"), + DATA_DOES_NOT_EXIST(500, "当前数据不存在"), ; 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 8336db6..b23c654 100644 --- a/src/main/java/com/huoran/iasf/common/utils/R.java +++ b/src/main/java/com/huoran/iasf/common/utils/R.java @@ -113,4 +113,20 @@ public class R { } + /** + * 返回警告信息的R对象,通常用于前端展示警告但不完全阻止操作的场景。 + * + * @param warnMsg 警告信息 + * @return 包含警告信息的R对象实例 + */ + public static R warn(String warnMsg) { + // 这里直接使用字符串信息作为警告,如果您有专门的警告响应码,可以使用如下形式: + // return new R(BaseResponseCode.WARNING_CODE, warnMsg); + + // 或者,如果只想传递消息而不改变响应码(保持成功响应码,但附带警告信息): + return new R(300, warnMsg); + } + + + } diff --git a/src/main/java/com/huoran/iasf/controller/SeoController.java b/src/main/java/com/huoran/iasf/controller/SeoController.java new file mode 100644 index 0000000..182377f --- /dev/null +++ b/src/main/java/com/huoran/iasf/controller/SeoController.java @@ -0,0 +1,68 @@ +package com.huoran.iasf.controller; + + +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.iasf.common.utils.R; +import com.huoran.iasf.entity.Seo; +import com.huoran.iasf.service.SeoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + *
+ * 前端控制器 + *
+ * + * @author cheney + * @since 2023-08-24 + */ +@Api(tags = "seo管理") +@RestController +@RequestMapping("/seo") +public class SeoController { + + @Autowired + private SeoService seoService; + + @PostMapping("/add") + @ApiOperation(value = "新增seo") + public R addUserGroup(@RequestBody Seo seo) { + Seo one = seoService.getOne(new QueryWrapper+ * + *
+ * + * @author cheney + * @since 2023-08-24 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("sys_seo") +@ApiModel(value = "Seo对象", description = "") +public class Seo implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "关键词") + private String keyword; + + @ApiModelProperty(value = "描述") + private String description; + + @ApiModelProperty(value = "站点") + private Integer siteId; + +} diff --git a/src/main/java/com/huoran/iasf/entity/SysFloatingColumnScheme.java b/src/main/java/com/huoran/iasf/entity/SysFloatingColumnScheme.java new file mode 100644 index 0000000..8692045 --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/SysFloatingColumnScheme.java @@ -0,0 +1,76 @@ +package com.huoran.iasf.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +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; +import java.util.Date; +import java.util.List; + +/** + *+ * 悬浮栏方案 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "SysFloatingColumnScheme对象", description = "悬浮栏方案") +public class SysFloatingColumnScheme implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "悬浮栏方案名称") + private String schemeName; + + @ApiModelProperty(value = "状态(0默认草稿箱 1为已发布)") + private Integer status; + + @ApiModelProperty(value = "悬浮栏样式id(关联样式表id)") + private Integer floatingBarStyle; + + @ApiModelProperty(value = "是否禁用(默认1不启用,0启用 1禁用)") + private Integer isDisable; + + @ApiModelProperty(value = "站点id") + private Integer siteId; + + @ApiModelProperty(value = "创建人id") + private Integer founderId; + + @ApiModelProperty(value = "编辑人id") + private Integer editorId; + + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + @ApiModelProperty(value = "表示是否为全局应用,便于快速判断是否存在全局悬浮栏,0表示不是全局悬浮栏,1表示是全局悬浮栏") + private Integer isGlobal; + + + @ApiModelProperty(value = "悬浮栏方案模块") + @TableField(exist = false) + private List+ * 悬浮栏方案设置 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "SysFloatingColumnSchemeModule对象", description = "悬浮栏方案设置") +public class SysFloatingColumnSchemeModule implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "悬浮栏方案id") + private Integer floatingBarSchemeId; + + @ApiModelProperty(value = "图片地址") + private String pictureAddress; + + @ApiModelProperty(value = "方案标题") + private String schemeTitle; + + @ApiModelProperty(value = "方案内容(json)") + private String schemeContentJson; + + @ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)") + private Integer isDisable; + + +} diff --git a/src/main/java/com/huoran/iasf/entity/SysFloatingColumnSchemeScopeOfApplication.java b/src/main/java/com/huoran/iasf/entity/SysFloatingColumnSchemeScopeOfApplication.java new file mode 100644 index 0000000..e1de98a --- /dev/null +++ b/src/main/java/com/huoran/iasf/entity/SysFloatingColumnSchemeScopeOfApplication.java @@ -0,0 +1,38 @@ +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-04 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "SysFloatingColumnSchemeScopeOfApplication对象", description = "悬浮栏应用范围") +public class SysFloatingColumnSchemeScopeOfApplication implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "悬浮栏方案id") + private Integer floatingBarSchemeId; + + @ApiModelProperty(value = "应用范围id(为0表示网站全局,其余为栏目表主键),如果为父级子级栏目一起选中,则显示为多个,以逗号隔开:1,3,45,49") + private String applicationScopeId; + + +} diff --git a/src/main/java/com/huoran/iasf/mapper/SeoMapper.java b/src/main/java/com/huoran/iasf/mapper/SeoMapper.java new file mode 100644 index 0000000..a39ae7a --- /dev/null +++ b/src/main/java/com/huoran/iasf/mapper/SeoMapper.java @@ -0,0 +1,16 @@ +package com.huoran.iasf.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.huoran.iasf.entity.Seo; + +/** + *+ * Mapper 接口 + *
+ * + * @author cheney + * @since 2023-08-24 + */ +public interface SeoMapper extends BaseMapper+ * 悬浮栏方案 Mapper 接口 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +public interface SysFloatingColumnSchemeMapper extends BaseMapper+ * 悬浮栏方案设置 Mapper 接口 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +public interface SysFloatingColumnSchemeModuleMapper extends BaseMapper+ * 悬浮栏应用范围 Mapper 接口 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +public interface SysFloatingColumnSchemeScopeOfApplicationMapper extends BaseMapper+ * 服务类 + *
+ * + * @author cheney + * @since 2023-08-24 + */ +public interface SeoService extends IService+ * 悬浮栏方案设置 服务类 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +public interface SysFloatingColumnSchemeModuleService extends IService+ * 悬浮栏应用范围 服务类 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +public interface SysFloatingColumnSchemeScopeOfApplicationService extends IService+ * 悬浮栏方案 服务类 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +public interface SysFloatingColumnSchemeService extends IService+ * 服务实现类 + *
+ * + * @author cheney + * @since 2023-08-24 + */ +@Service +public class SeoServiceImpl extends ServiceImpl+ * 悬浮栏方案设置 服务实现类 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +@Service +public class SysFloatingColumnSchemeModuleServiceImpl extends ServiceImpl+ * 悬浮栏应用范围 服务实现类 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +@Service +public class SysFloatingColumnSchemeScopeOfApplicationServiceImpl extends ServiceImpl+ * 悬浮栏方案 服务实现类 + *
+ * + * @author cheney + * @since 2024-06-04 + */ +@Service +public class SysFloatingColumnSchemeServiceImpl extends ServiceImpl+ *
+ *
+ * 应用全部权限最高。
+ * 1.只要是启用应用全部的,除了没有启用的悬浮栏,包含全部,不论是应用全部还是部分应用的情况下,都会弹窗提示:"当前已启用了的悬浮栏方案将会被取消!"
+ * 2.如果当前操作的悬浮栏是要为启用状态,且当前的悬浮栏应用类型为为部分应用的情况下下,需要判断当前站点下是否存在已经启用了应用全部的,如果存在,则弹窗提示:"当前已启用全局悬浮栏,无法启用部分应用的悬浮栏,请先禁用全局悬浮栏!"
+ * 3.部分启用vs部分启用,且有重合的,提示"当前选择的栏目范围与已启用的悬浮栏方案有冲突,请移除冲突的栏目后再试:{后边展示的是冲突的栏目名称}"
+ *
+ * @param schemeId 悬浮栏目id
+ * @param enable 是否禁用(0默认,0启用 1禁用)
+ * @return
+ */
+ @Transactional
+ @Override
+ public R enableOrDisableScheme(Integer schemeId, Integer enable) {
+ /* SysFloatingColumnScheme scheme = floatingColumnSchemeMapper.selectById(schemeId);
+ scheme.setFloatingColumnSchemeScopeOfApplications(scopeOfApplicationMapper.selectList(new QueryWrapper
+ * --所有操作里面应用全部权限最高。
+ * 1.只要是启用应用全部的,除了没有启用的悬浮栏,包含全部,不论是应用全部还是部分应用的情况下,都会弹窗提示:"当前已启用了的悬浮栏方案将会被取消!"
+ * 2.如果当前操作的悬浮栏是要为启用状态,且当前的悬浮栏应用类型为为部分应用的情况下下,需要判断当前站点下是否存在已经启用了应用全部的,如果存在,则弹窗提示:"当前已启用全局悬浮栏,无法启用部分应用的悬浮栏,请先禁用全局悬浮栏!"
+ * 3.部分启用vs部分启用,且有重合的,提示"当前选择的栏目范围与已启用的悬浮栏方案有冲突,请移除冲突的栏目后再试:{后边展示的是冲突的栏目名称}"
+ *
+ * @param schemeId 悬浮栏目id
+ * @param enable 是否禁用(0启用 1禁用)
+ * @return 包含操作结果或警告信息的对象
+ */
+
+ public R checkEnableOrDisable(Integer schemeId, Integer enable) {
+ SysFloatingColumnScheme scheme = floatingColumnSchemeMapper.selectById(schemeId);
+ if (scheme == null) {
+ return R.fail("悬浮窗方案不存在");
+ }
+
+ Integer siteId = scheme.getSiteId();
+
+ // 1. 当前操作为启用时,检查逻辑
+ if (enable == 0) {
+ // 全局悬浮栏启用逻辑
+ // 对于启用操作,先检查是否是全局应用
+ if (scheme.getIsGlobal() == 1) {
+ // 检查站点下是否存在任何已启用的悬浮栏方案,不论全局还是部分应用
+ long enabledCount = floatingColumnSchemeMapper.selectCount(new LambdaQueryWrapper
+ * 悬浮栏方案
+ *
+ * 悬浮栏方案
+ *