首次提交

This commit is contained in:
李玉东 2025-07-16 12:53:00 +08:00
parent 34029f469b
commit 731e8f7438
6 changed files with 139 additions and 85 deletions

View File

@ -2,6 +2,7 @@
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<annotationProcessing> <annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true"> <profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" /> <sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />

View File

@ -50,7 +50,7 @@ public class Menu implements Serializable {
/** /**
* 顺序 * 顺序
*/ */
private Integer menuOrder; private Integer menuOrder ;
@TableField(exist = false) @TableField(exist = false)
private List<Menu> children = new ArrayList<>(); private List<Menu> children = new ArrayList<>();

View File

@ -1,16 +1,15 @@
package com.hshh.nation.menu.service.impl; package com.hshh.nation.menu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hshh.nation.menu.entity.Menu; import com.hshh.nation.menu.entity.Menu;
import com.hshh.nation.menu.mapper.MenuMapper; import com.hshh.nation.menu.mapper.MenuMapper;
import com.hshh.nation.menu.service.MenuService; import com.hshh.nation.menu.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hshh.nation.user.entity.User; import com.hshh.nation.user.entity.User;
import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Service;
/** /**
* <p> * <p>
@ -22,6 +21,7 @@ import java.util.Map;
*/ */
@Service @Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService { public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
/** /**
* 获取用户菜单列表 * 获取用户菜单列表
* *
@ -32,7 +32,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
public List<Menu> getMenuByUserId(User user) { public List<Menu> getMenuByUserId(User user) {
//根据用户ID查询所有菜单 //根据用户ID查询所有菜单
List<Menu> originalmenuList = this.baseMapper.getMenuByUser(user); List<Menu> originalmenuList = this.baseMapper.getMenuByUser(user);
if(originalmenuList.isEmpty()){ if (originalmenuList.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
//key为父ID,value为所有一致父ID的集合 //key为父ID,value为所有一致父ID的集合
@ -54,16 +54,27 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
for (Menu menu : topMenuList) { for (Menu menu : topMenuList) {
//递归设置子菜单 //递归设置子菜单
setChildren(menu,parentMenuMap); setChildren(menu, parentMenuMap);
} }
topMenuList.sort((a, b) -> {
if (a.getMenuOrder() == null) {
a.setMenuOrder(Integer.MAX_VALUE);
}
if (b.getMenuOrder() == null) {
b.setMenuOrder(Integer.MAX_VALUE);
}
return Integer.compare(a.getMenuOrder(), b.getMenuOrder());
}
);
return topMenuList; return topMenuList;
} }
private void setChildren(Menu menu,Map<Integer, List<Menu>> parentMenuMap) {
if(parentMenuMap.containsKey(menu.getId())) { private void setChildren(Menu menu, Map<Integer, List<Menu>> parentMenuMap) {
if (parentMenuMap.containsKey(menu.getId())) {
menu.getChildren().addAll(parentMenuMap.get(menu.getId())); menu.getChildren().addAll(parentMenuMap.get(menu.getId()));
menu.getChildren().forEach(child -> { menu.getChildren().forEach(child -> {
setChildren(child,parentMenuMap); setChildren(child, parentMenuMap);
}); });
} }
} }

View File

@ -15,10 +15,15 @@ spring:
min-idle: 0 min-idle: 0
max-wait: -1ms max-wait: -1ms
datasource: datasource:
url: jdbc:mysql://localhost:3306/nation_defence?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC # mysql
username: root # url: jdbc:mysql://localhost:3306/nation_defence?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
password: 123456 # username: root
driver-class-name: com.mysql.cj.jdbc.Driver # password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:dm://localhost:5236/NATION_DEFENCE
username: nation
password: Hshh123456
driver-class-name: dm.jdbc.driver.DmDriver
hikari: hikari:
minimum-idle: 5 minimum-idle: 5
maximum-pool-size: 20 maximum-pool-size: 20
@ -34,7 +39,8 @@ spring:
mybatis-plus: mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml mapper-locations: classpath:/mapper/**/*.xml
configuration:
database-id: dm
type-aliases-package: com.example.demo.system.**.entity type-aliases-package: com.example.demo.system.**.entity
global-config: global-config:

View File

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hshh.nation.code.mapper.CodeDictMapper"> <mapper namespace="com.hshh.nation.code.mapper.CodeDictMapper">
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.hshh.nation.code.entity.CodeDict"> <resultMap id="BaseResultMap" type="com.hshh.nation.code.entity.CodeDict">
<id column="id" property="id" /> <id column="id" property="id"/>
<result column="code_name_cn" property="codeNameCn" /> <result column="code_name_cn" property="codeNameCn"/>
<result column="code_name_en" property="codeNameEn" /> <result column="code_name_en" property="codeNameEn"/>
<result column="code_desc" property="codeDesc" /> <result column="code_desc" property="codeDesc"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
@ -15,7 +16,8 @@
id, code_name_cn, code_name_en, code_desc id, code_name_cn, code_name_en, code_desc
</sql> </sql>
<select id="list" resultType="com.hshh.nation.code.entity.CodeDict" parameterType="com.hshh.nation.code.entity.CodeDict"> <select id="list" resultType="com.hshh.nation.code.entity.CodeDict"
parameterType="com.hshh.nation.code.entity.CodeDict" databaseId="mysql">
SELECT SELECT
@rownum := @rownum + 1 AS seq, @rownum := @rownum + 1 AS seq,
t.* t.*
@ -26,10 +28,29 @@
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%') code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
</if> </if>
</where> </where>
order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit #{model.start},#{model.pageSize} order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit
</select> #{model.start},#{model.pageSize}
</select>
<select id="list" resultType="com.hshh.nation.code.entity.CodeDict"
parameterType="com.hshh.nation.code.entity.CodeDict" databaseId="dm">
SELECT
t.seq,
t.*
FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY id ASC) AS seq,
a.*
FROM sys_code_dict a
<where>
<if test="model.codeNameCn != null and model.codeNameCn !='' ">
code_name_cn LIKE '%' || #{model.codeNameCn} || '%'
</if>
</where>
) t
WHERE t.seq > #{model.start} AND t.seq &lt;= (#{model.start} + #{model.pageSize})
</select>
<select id="count" resultType="java.lang.Long"> <select id="count" resultType="java.lang.Long">
select count(id) from sys_code_dict select count(id) from sys_code_dict
<where> <where>
<if test="model.codeNameCn != null and model.codeNameCn !=''"> <if test="model.codeNameCn != null and model.codeNameCn !=''">
@ -38,7 +59,7 @@
</where> </where>
</select> </select>
</mapper> </mapper>

View File

@ -34,7 +34,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<select id="list" resultType="com.hshh.nation.transport.entity.TransportBoat" parameterType="com.hshh.nation.transport.entity.TransportBoat"> <select id="list" resultType="com.hshh.nation.transport.entity.TransportBoat" parameterType="com.hshh.nation.transport.entity.TransportBoat" databaseId="mysql">
SELECT SELECT
@rownum := @rownum + 1 AS seq, @rownum := @rownum + 1 AS seq,
t.* t.*
@ -47,7 +47,22 @@
</where> </where>
order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit #{model.start},#{model.pageSize} order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit #{model.start},#{model.pageSize}
</select> </select>
<select id="list" resultType="com.hshh.nation.transport.entity.TransportBoat" parameterType="com.hshh.nation.transport.entity.TransportBoat" databaseId="dm">
SELECT * FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY id ASC) AS seq,
t.*
FROM defence_transport_boat t
<where>
<if test="model.equipName != null and model.equipName !=''">
t.equip_name LIKE '%' || #{model.equipName} || '%'
</if>
</where>
) tmp
WHERE seq > #{model.start} AND seq &lt;= #{model.start} + #{model.pageSize}
</select>
<select id="count" resultType="java.lang.Long"> <select id="count" resultType="java.lang.Long">
select count(id) from defence_transport_boat select count(id) from defence_transport_boat
<where> <where>