导航图标相关接口

master
rong.liu 5 months ago
parent b355a3cd9c
commit 6a86e43115
  1. 34
      src/main/java/com/huoran/iasf/controller/SysNavigationIconController.java
  2. 3
      src/main/java/com/huoran/iasf/entity/SysNavigationIcon.java
  3. 9
      src/main/java/com/huoran/iasf/mapper/SysNavigationIconMapper.java
  4. 19
      src/main/java/com/huoran/iasf/mapper/xml/SysNavigationIconMapper.xml
  5. 6
      src/main/java/com/huoran/iasf/service/SysNavigationIconService.java
  6. 28
      src/main/java/com/huoran/iasf/service/impl/SysNavigationIconServiceImpl.java

@ -1,5 +1,6 @@
package com.huoran.iasf.controller;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysNavigationIcon;
import com.huoran.iasf.service.SysNavigationIconService;
@ -10,6 +11,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
@ -26,6 +28,22 @@ public class SysNavigationIconController {
public SysNavigationIconService service;
@PostMapping("/checkIfTheTitleIsRepeat")
@ApiOperation(value = "标题判重——适用于新增、编辑及发布前的校验", response = Boolean.class)
public R checkIfTheTitleIsRepeat(@RequestBody @Valid SysNavigationIcon icon) {
boolean isDuplicate = false;
// 如果ID不为空,说明是编辑操作,需要排除当前记录自身
if (icon.getId() != null) {
isDuplicate = service.existsOtherByTitle(icon.getTitle(), icon.getId(), icon.getSiteId());
} else {
// ID为空,说明是新增操作
isDuplicate = service.existsByTitle(icon.getTitle(), icon.getSiteId());
}
return R.result(!isDuplicate, !isDuplicate ? "标题可用" : "该标题已重复!");
}
/**
* 保存或更新导航图标设置记录
* 如果ID为空则执行保存操作如果ID有值则视为更新操作
@ -61,8 +79,9 @@ public class SysNavigationIconController {
@PostMapping("/list")
@ApiOperation(value = "根据站点ID查询列表数据,可选过滤禁用状态", response = SysNavigationIcon.class, responseContainer = "List")
public R listSysNavigationIconsByCondition(@ApiParam(value = "站点ID", required = true) @RequestParam Integer siteId, @ApiParam(value = "禁用状态:0-启用,1-禁用,默认查询所有状态") @RequestParam(required = false) Integer isDisable) {
List<SysNavigationIcon> sysNavigationIcons = service.listBySiteIdAndStatus(siteId, isDisable);
public R listSysNavigationIconsByCondition(@ApiParam(value = "站点ID", required = true) @RequestParam Integer siteId, @ApiParam(value = "禁用状态:0-启用,1-禁用,默认查询所有状态") @RequestParam(required = false) Integer isDisable,
@ApiParam(value = "查询关键词") @RequestParam(required = false) String search) {
List<SysNavigationIcon> sysNavigationIcons = service.listBySiteIdAndStatus(siteId, isDisable,search);
return R.success(sysNavigationIcons);
}
@ -81,5 +100,16 @@ public class SysNavigationIconController {
boolean delState = service.removeByIds(ids);
return delState ? R.success() : R.fail("删除失败");
}
@PostMapping("/enableDisable")
@ApiOperation(value = "启用禁用", response = SysNavigationIcon.class)
public R enableDisable(@ApiParam(name = "id", value = "主键id", required = true) @RequestParam Integer id, @ApiParam(name = "isDisable", value = "是否禁用:0-启用,1-禁用", required = true) @RequestParam Integer isDisable) {
UpdateWrapper<SysNavigationIcon> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("is_disable", isDisable);
updateWrapper.eq("id", id);
boolean ret = service.update(updateWrapper);
return ret ? R.success() : R.fail("禁用/启用失败");
}
}

@ -85,5 +85,6 @@ public class SysNavigationIcon implements Serializable {
@ApiModelProperty(value = "排序顺序")
private Integer sortOrder;
@ApiModelProperty(value = "编辑人姓名")
private String editorSName;
}

@ -1,10 +1,12 @@
package com.huoran.iasf.mapper;
import com.huoran.iasf.entity.SysNavigationIcon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huoran.iasf.entity.SysNavigationIcon;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* <p>
* 导航图标设置 Mapper 接口
@ -18,4 +20,9 @@ public interface SysNavigationIconMapper extends BaseMapper<SysNavigationIcon> {
@Update("UPDATE sys_navigation_icon SET sort_order = #{sortOrder} WHERE id = #{id}")
void updateSortOrder(@Param("id") Integer id, @Param("sortOrder") Integer sortOrder);
List<SysNavigationIcon> listBySiteIdAndStatus(@Param("siteId") Integer siteId,
@Param("isDisable") Integer disableStatus,
@Param("search") String search);
}

@ -2,4 +2,23 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huoran.iasf.mapper.SysNavigationIconMapper">
<select id="listBySiteIdAndStatus" resultType="com.huoran.iasf.entity.SysNavigationIcon">
SELECT
i.*,
u.username AS editorSName
FROM
sys_navigation_icon i
INNER JOIN sys_user u ON u.id = i.editor_id
WHERE
i.deleted = 1
AND i.site_id = #{siteId}
<if test='isDisable != null'>
AND i.is_disable = #{isDisable}
</if>
<if test='search != null and search != ""'>
AND (i.title LIKE CONCAT('%', #{search}, '%') OR i.button_text LIKE CONCAT('%', #{search}, '%'))
</if>
</select>
</mapper>

@ -15,8 +15,12 @@ import java.util.List;
* @since 2024-07-04
*/
public interface SysNavigationIconService extends IService<SysNavigationIcon> {
List<SysNavigationIcon> listBySiteIdAndStatus(Integer siteId, Integer disableStatus);
List<SysNavigationIcon> listBySiteIdAndStatus(Integer siteId, Integer disableStatus,String search);
void batchUpdateSortOrder(List<SortOrderReq> sortOrderRequests);
boolean existsOtherByTitle(String title, Integer id, Integer siteId);
boolean existsByTitle(String title, Integer siteId);
}

@ -1,10 +1,10 @@
package com.huoran.iasf.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.iasf.entity.SysNavigationIcon;
import com.huoran.iasf.mapper.SysNavigationIconMapper;
import com.huoran.iasf.service.SysNavigationIconService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.iasf.vo.req.SortOrderReq;
import org.springframework.stereotype.Service;
@ -22,13 +22,9 @@ import java.util.List;
public class SysNavigationIconServiceImpl extends ServiceImpl<SysNavigationIconMapper, SysNavigationIcon> implements SysNavigationIconService {
@Override
public List<SysNavigationIcon> listBySiteIdAndStatus(Integer siteId, Integer disableStatus) {
QueryWrapper<SysNavigationIcon> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("site_id", siteId);
if (disableStatus != null) {
queryWrapper.eq("disable_status", disableStatus);
}
return this.list(queryWrapper);
public List<SysNavigationIcon> listBySiteIdAndStatus(Integer siteId, Integer disableStatus,String search) {
return baseMapper.listBySiteIdAndStatus(siteId, disableStatus,search);
}
@Override
@ -38,4 +34,20 @@ public class SysNavigationIconServiceImpl extends ServiceImpl<SysNavigationIconM
baseMapper.updateSortOrder(request.getId(), request.getSortOrder());
}
}
@Override
public boolean existsOtherByTitle(String title, Integer id, Integer siteId) {
if (this.count(new QueryWrapper<SysNavigationIcon>().eq("title", title).ne("id", id).eq("site_id", siteId)) > 0) {
return true;
}
return false;
}
@Override
public boolean existsByTitle(String title, Integer siteId) {
if (this.count(new QueryWrapper<SysNavigationIcon>().eq("title", title).eq("site_id", siteId)) > 0) {
return true;
}
return false;
}
}

Loading…
Cancel
Save