feat(menu): 添加菜单排序功能

- 在HwWebMenu实体类中新增order字段及对应的getter/setter方法
- 更新数据库映射文件中的resultMap,添加order字段映射
- 在查询SQL中增加order字段的查询条件和排序规则
- 在插入和更新操作中添加对order字段的处理
- 修复了XML文件格式化问题
main
zangch@mesnac.com 2 weeks ago
parent 8d88e6a950
commit 5cbd7130df

File diff suppressed because it is too large Load Diff

@ -1,5 +1,6 @@
package com.ruoyi;
import org.dromara.easyes.starter.register.EsMapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -9,6 +10,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
*
* @author ruoyi
*/
@EsMapperScan("com.ruoyi.portal.search.es.mapper")
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{

@ -142,3 +142,20 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# easy-es
easy-es:
enable: true
banner: false
address: 127.0.0.1:9200
global-config:
process-index-mode: manual
db-config:
refresh-policy: immediate
# portal search engine switch
search:
engine: mysql
es:
enabled: true

@ -133,6 +133,45 @@
<version>3.5.10</version>
</dependency>
<!-- SpringBoot Web容器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</exclusion>
<exclusion>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.14.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.dromara.easy-es</groupId>
<artifactId>easy-es-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</project>

@ -8,7 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.portal.mapper.HwWebDocumentMapper;
import com.ruoyi.portal.domain.HwWebDocument;
import com.ruoyi.portal.service.IHwSearchRebuildService;
import com.ruoyi.portal.service.IHwWebDocumentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* HwService
@ -19,9 +22,14 @@ import com.ruoyi.portal.service.IHwWebDocumentService;
@Service
public class HwWebDocumentServiceImpl implements IHwWebDocumentService
{
private static final Logger log = LoggerFactory.getLogger(HwWebDocumentServiceImpl.class);
@Autowired
private HwWebDocumentMapper hwWebDocumentMapper;
@Autowired(required = false)
private IHwSearchRebuildService hwSearchRebuildService;
/**
* Hw
*
@ -56,7 +64,12 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService
public int insertHwWebDocument(HwWebDocument hwWebDocument)
{
hwWebDocument.setCreateTime(DateUtils.getNowDate());
return hwWebDocumentMapper.insertHwWebDocument(hwWebDocument);
int rows = hwWebDocumentMapper.insertHwWebDocument(hwWebDocument);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -74,7 +87,12 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService
hwWebDocument.setSecretKey("");
}
return hwWebDocumentMapper.updateHwWebDocument(hwWebDocument);
int rows = hwWebDocumentMapper.updateHwWebDocument(hwWebDocument);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -86,7 +104,12 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService
@Override
public int deleteHwWebDocumentByDocumentIds(String[] documentIds)
{
return hwWebDocumentMapper.deleteHwWebDocumentByDocumentIds(documentIds);
int rows = hwWebDocumentMapper.deleteHwWebDocumentByDocumentIds(documentIds);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -98,7 +121,12 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService
@Override
public int deleteHwWebDocumentByDocumentId(String documentId)
{
return hwWebDocumentMapper.deleteHwWebDocumentByDocumentId(documentId);
int rows = hwWebDocumentMapper.deleteHwWebDocumentByDocumentId(documentId);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
@Override
@ -128,6 +156,22 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService
}
}
private void rebuildSearchIndexQuietly()
{
if (hwSearchRebuildService == null)
{
return;
}
try
{
hwSearchRebuildService.rebuildAll();
}
catch (Exception e)
{
log.error("rebuild portal search index failed after hw_web_document changed", e);
}
}
}

@ -7,6 +7,9 @@ import java.util.stream.Collectors;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.portal.domain.HwProductInfoDetail;
import com.ruoyi.portal.service.IHwSearchRebuildService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.portal.mapper.HwWebMenuMapper;
@ -22,9 +25,14 @@ import com.ruoyi.portal.service.IHwWebMenuService;
@Service
public class HwWebMenuServiceImpl implements IHwWebMenuService
{
private static final Logger log = LoggerFactory.getLogger(HwWebMenuServiceImpl.class);
@Autowired
private HwWebMenuMapper hwWebMenuMapper;
@Autowired(required = false)
private IHwSearchRebuildService hwSearchRebuildService;
/**
* haiwei
*
@ -69,7 +77,12 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService
@Override
public int insertHwWebMenu(HwWebMenu hwWebMenu)
{
return hwWebMenuMapper.insertHwWebMenu(hwWebMenu);
int rows = hwWebMenuMapper.insertHwWebMenu(hwWebMenu);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -81,7 +94,12 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService
@Override
public int updateHwWebMenu(HwWebMenu hwWebMenu)
{
return hwWebMenuMapper.updateHwWebMenu(hwWebMenu);
int rows = hwWebMenuMapper.updateHwWebMenu(hwWebMenu);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -93,7 +111,12 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService
@Override
public int deleteHwWebMenuByWebMenuIds(Long[] webMenuIds)
{
return hwWebMenuMapper.deleteHwWebMenuByWebMenuIds(webMenuIds);
int rows = hwWebMenuMapper.deleteHwWebMenuByWebMenuIds(webMenuIds);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -105,7 +128,12 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService
@Override
public int deleteHwWebMenuByWebMenuId(Long webMenuId)
{
return hwWebMenuMapper.deleteHwWebMenuByWebMenuId(webMenuId);
int rows = hwWebMenuMapper.deleteHwWebMenuByWebMenuId(webMenuId);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -165,5 +193,21 @@ public class HwWebMenuServiceImpl implements IHwWebMenuService
private boolean hasChild(List<HwWebMenu> list, HwWebMenu t) {
return !getChildList(list, t).isEmpty();
}
private void rebuildSearchIndexQuietly()
{
if (hwSearchRebuildService == null)
{
return;
}
try
{
hwSearchRebuildService.rebuildAll();
}
catch (Exception e)
{
log.error("rebuild portal search index failed after hw_web_menu changed", e);
}
}
}

@ -6,6 +6,9 @@ import org.springframework.stereotype.Service;
import com.ruoyi.portal.mapper.HwWebMapper;
import com.ruoyi.portal.domain.HwWeb;
import com.ruoyi.portal.service.IHwWebService;
import com.ruoyi.portal.service.IHwSearchRebuildService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
/**
@ -17,9 +20,14 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class HwWebServiceImpl implements IHwWebService
{
private static final Logger log = LoggerFactory.getLogger(HwWebServiceImpl.class);
@Autowired
private HwWebMapper hwWebMapper;
@Autowired(required = false)
private IHwSearchRebuildService hwSearchRebuildService;
/**
* haiweijson
*
@ -55,7 +63,12 @@ public class HwWebServiceImpl implements IHwWebService
@Override
public int insertHwWeb(HwWeb hwWeb)
{
return hwWebMapper.insertHwWeb(hwWeb);
int rows = hwWebMapper.insertHwWeb(hwWeb);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -80,7 +93,12 @@ public class HwWebServiceImpl implements IHwWebService
// 插入新记录,避免复用旧主键
// hwWeb.setWebId(null);
hwWeb.setIsDelete("0");
return hwWebMapper.insertHwWeb(hwWeb);
int rows = hwWebMapper.insertHwWeb(hwWeb);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -92,7 +110,12 @@ public class HwWebServiceImpl implements IHwWebService
@Override
public int deleteHwWebByWebIds(Long[] webIds)
{
return hwWebMapper.deleteHwWebByWebIds(webIds);
int rows = hwWebMapper.deleteHwWebByWebIds(webIds);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -104,7 +127,28 @@ public class HwWebServiceImpl implements IHwWebService
@Override
public int deleteHwWebByWebId(Long webId)
{
return hwWebMapper.deleteHwWebByWebId(webId);
int rows = hwWebMapper.deleteHwWebByWebId(webId);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
private void rebuildSearchIndexQuietly()
{
if (hwSearchRebuildService == null)
{
return;
}
try
{
hwSearchRebuildService.rebuildAll();
}
catch (Exception e)
{
log.error("rebuild portal search index failed after hw_web changed", e);
}
}
}

@ -2,7 +2,10 @@ package com.ruoyi.portal.service.impl;
import com.ruoyi.portal.mapper.HwWebMapper1;
import com.ruoyi.portal.service.IHwSearchRebuildService;
import com.ruoyi.portal.service.IHwWebService1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@ -19,9 +22,14 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class HwWebServiceImpl1 implements IHwWebService1
{
private static final Logger log = LoggerFactory.getLogger(HwWebServiceImpl1.class);
@Autowired
private HwWebMapper1 hwWebMapper1;
@Autowired(required = false)
private IHwSearchRebuildService hwSearchRebuildService;
/**
* haiweijson
*
@ -62,7 +70,12 @@ public class HwWebServiceImpl1 implements IHwWebService1
@Override
public int insertHwWeb(HwWeb1 hwWeb1)
{
return hwWebMapper1.insertHwWeb(hwWeb1);
int rows = hwWebMapper1.insertHwWeb(hwWeb1);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -89,7 +102,12 @@ public class HwWebServiceImpl1 implements IHwWebService1
// 插入新记录,避免复用旧主键
// hwWeb1.setWebId(null);
hwWeb1.setIsDelete("0");
return hwWebMapper1.insertHwWeb(hwWeb1);
int rows = hwWebMapper1.insertHwWeb(hwWeb1);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -101,7 +119,12 @@ public class HwWebServiceImpl1 implements IHwWebService1
@Override
public int deleteHwWebByWebIds(Long[] webIds)
{
return hwWebMapper1.deleteHwWebByWebIds(webIds);
int rows = hwWebMapper1.deleteHwWebByWebIds(webIds);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
/**
@ -113,7 +136,28 @@ public class HwWebServiceImpl1 implements IHwWebService1
@Override
public int deleteHwWebByWebId(Long webId)
{
return hwWebMapper1.deleteHwWebByWebId(webId);
int rows = hwWebMapper1.deleteHwWebByWebId(webId);
if (rows > 0)
{
rebuildSearchIndexQuietly();
}
return rows;
}
private void rebuildSearchIndexQuietly()
{
if (hwSearchRebuildService == null)
{
return;
}
try
{
hwSearchRebuildService.rebuildAll();
}
catch (Exception e)
{
log.error("rebuild portal search index failed after hw_web1 changed", e);
}
}
}

@ -42,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<insert id="insertNotice" parameterType="SysNotice">
<insert id="insertNotice" parameterType="SysNotice" useGeneratedKeys="true" keyProperty="noticeId">
insert into sys_notice (
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
<if test="noticeType != null and noticeType != '' ">notice_type, </if>

Loading…
Cancel
Save