Compare commits
No commits in common. "731e8f74385a6cf6345fc0a9883b19af34da334b" and "af692b7cdf0865a45b50f5945eebf8e624d84826" have entirely different histories.
731e8f7438
...
af692b7cdf
|
@ -2,7 +2,6 @@
|
|||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="CheckStyle-IDEA-Module" serialisationVersion="2">
|
||||
<option name="activeLocationsIds" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
pom.xml
14
pom.xml
|
@ -92,6 +92,10 @@
|
|||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-generator</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
|
@ -100,6 +104,7 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -138,14 +143,7 @@
|
|||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>1.5.13</version> <!-- 或 1.7.0 -->
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/dm.jdbc.driver/dm8 -->
|
||||
<dependency>
|
||||
<groupId>com.dm</groupId>
|
||||
<artifactId>dmjdbc</artifactId>
|
||||
<version>8.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/DmJdbcDriver8.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class Menu implements Serializable {
|
|||
/**
|
||||
* 顺序
|
||||
*/
|
||||
private Integer menuOrder ;
|
||||
private Integer menuOrder;
|
||||
@TableField(exist = false)
|
||||
private List<Menu> children = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
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.mapper.MenuMapper;
|
||||
import com.hshh.nation.menu.service.MenuService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.hshh.nation.user.entity.User;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -21,67 +22,55 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
|
||||
|
||||
/**
|
||||
* 获取用户菜单列表
|
||||
*
|
||||
* @param user 用户
|
||||
* @return 用户菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> getMenuByUserId(User user) {
|
||||
//根据用户ID查询所有菜单
|
||||
List<Menu> originalmenuList = this.baseMapper.getMenuByUser(user);
|
||||
if (originalmenuList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//key为父ID,value为所有一致父ID的集合
|
||||
Map<Integer, List<Menu>> parentMenuMap = new HashMap<>();
|
||||
originalmenuList.forEach(originalmenu -> {
|
||||
if (originalmenu.getParentId() == null) {
|
||||
originalmenu.setParentId(0);
|
||||
}
|
||||
if (!parentMenuMap.containsKey(originalmenu.getParentId())) {
|
||||
List<Menu> innerList = new ArrayList<>();
|
||||
innerList.add(originalmenu);
|
||||
parentMenuMap.put(originalmenu.getParentId(), innerList);
|
||||
} else {
|
||||
parentMenuMap.get(originalmenu.getParentId()).add(originalmenu);
|
||||
}
|
||||
});
|
||||
//获取顶级菜单
|
||||
List<Menu> topMenuList = parentMenuMap.get(0);
|
||||
|
||||
for (Menu menu : topMenuList) {
|
||||
//递归设置子菜单
|
||||
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());
|
||||
/**
|
||||
* 获取用户菜单列表
|
||||
*
|
||||
* @param user 用户
|
||||
* @return 用户菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Menu> getMenuByUserId(User user) {
|
||||
//根据用户ID查询所有菜单
|
||||
List<Menu> originalmenuList = this.baseMapper.getMenuByUser(user);
|
||||
if(originalmenuList.isEmpty()){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
);
|
||||
return topMenuList;
|
||||
}
|
||||
//key为父ID,value为所有一致父ID的集合
|
||||
Map<Integer, List<Menu>> parentMenuMap = new HashMap<>();
|
||||
originalmenuList.forEach(originalmenu -> {
|
||||
if (originalmenu.getParentId() == null) {
|
||||
originalmenu.setParentId(0);
|
||||
}
|
||||
if (!parentMenuMap.containsKey(originalmenu.getParentId())) {
|
||||
List<Menu> innerList = new ArrayList<>();
|
||||
innerList.add(originalmenu);
|
||||
parentMenuMap.put(originalmenu.getParentId(), innerList);
|
||||
} else {
|
||||
parentMenuMap.get(originalmenu.getParentId()).add(originalmenu);
|
||||
}
|
||||
});
|
||||
//获取顶级菜单
|
||||
List<Menu> topMenuList = parentMenuMap.get(0);
|
||||
|
||||
private void setChildren(Menu menu, Map<Integer, List<Menu>> parentMenuMap) {
|
||||
|
||||
if (parentMenuMap.containsKey(menu.getId())) {
|
||||
menu.getChildren().addAll(parentMenuMap.get(menu.getId()));
|
||||
menu.getChildren().forEach(child -> {
|
||||
setChildren(child, parentMenuMap);
|
||||
});
|
||||
for (Menu menu : topMenuList) {
|
||||
//递归设置子菜单
|
||||
setChildren(menu,parentMenuMap);
|
||||
}
|
||||
return topMenuList;
|
||||
}
|
||||
}
|
||||
private void setChildren(Menu menu,Map<Integer, List<Menu>> parentMenuMap) {
|
||||
|
||||
@Override
|
||||
public List<Menu> getAllMenu() {
|
||||
if(parentMenuMap.containsKey(menu.getId())) {
|
||||
menu.getChildren().addAll(parentMenuMap.get(menu.getId()));
|
||||
menu.getChildren().forEach(child -> {
|
||||
setChildren(child,parentMenuMap);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return this.list();
|
||||
}
|
||||
@Override
|
||||
public List<Menu> getAllMenu() {
|
||||
|
||||
return this.list();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,15 +15,10 @@ spring:
|
|||
min-idle: 0
|
||||
max-wait: -1ms
|
||||
datasource:
|
||||
# mysql
|
||||
# url: jdbc:mysql://localhost:3306/nation_defence?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
|
||||
# username: root
|
||||
# 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
|
||||
url: jdbc:mysql://localhost:3306/nation_defence?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
|
||||
username: root
|
||||
password: 123456
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
hikari:
|
||||
minimum-idle: 5
|
||||
maximum-pool-size: 20
|
||||
|
@ -39,8 +34,7 @@ spring:
|
|||
mybatis-plus:
|
||||
|
||||
mapper-locations: classpath:/mapper/**/*.xml
|
||||
configuration:
|
||||
database-id: dm
|
||||
|
||||
type-aliases-package: com.example.demo.system.**.entity
|
||||
|
||||
global-config:
|
||||
|
|
|
@ -1,65 +1,44 @@
|
|||
<?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">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.hshh.nation.code.entity.CodeDict">
|
||||
<id column="id" property="id"/>
|
||||
<result column="code_name_cn" property="codeNameCn"/>
|
||||
<result column="code_name_en" property="codeNameEn"/>
|
||||
<result column="code_desc" property="codeDesc"/>
|
||||
</resultMap>
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.hshh.nation.code.entity.CodeDict">
|
||||
<id column="id" property="id" />
|
||||
<result column="code_name_cn" property="codeNameCn" />
|
||||
<result column="code_name_en" property="codeNameEn" />
|
||||
<result column="code_desc" property="codeDesc" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, code_name_cn, code_name_en, code_desc
|
||||
</sql>
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, code_name_cn, code_name_en, code_desc
|
||||
</sql>
|
||||
|
||||
<select id="list" resultType="com.hshh.nation.code.entity.CodeDict"
|
||||
parameterType="com.hshh.nation.code.entity.CodeDict" databaseId="mysql">
|
||||
<select id="list" resultType="com.hshh.nation.code.entity.CodeDict" parameterType="com.hshh.nation.code.entity.CodeDict">
|
||||
SELECT
|
||||
@rownum := @rownum + 1 AS seq,
|
||||
t.*
|
||||
FROM (
|
||||
SELECT * FROM sys_code_dict
|
||||
<where>
|
||||
<if test="model.codeNameCn != null and model.codeNameCn !='' ">
|
||||
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
|
||||
</if>
|
||||
<if test="model.codeNameCn != null and model.codeNameCn !='' ">
|
||||
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit
|
||||
#{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 <= (#{model.start} + #{model.pageSize})
|
||||
</select>
|
||||
order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit #{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
|
||||
<where>
|
||||
<if test="model.codeNameCn != null and model.codeNameCn !=''">
|
||||
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
|
||||
</if>
|
||||
<if test="model.codeNameCn != null and model.codeNameCn !=''">
|
||||
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
|
||||
</if>
|
||||
</where>
|
||||
|
||||
|
||||
</select>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<!-- 通用查询结果列 -->
|
||||
|
||||
|
||||
<select id="list" resultType="com.hshh.nation.transport.entity.TransportBoat" parameterType="com.hshh.nation.transport.entity.TransportBoat" databaseId="mysql">
|
||||
<select id="list" resultType="com.hshh.nation.transport.entity.TransportBoat" parameterType="com.hshh.nation.transport.entity.TransportBoat">
|
||||
SELECT
|
||||
@rownum := @rownum + 1 AS seq,
|
||||
t.*
|
||||
|
@ -47,29 +47,14 @@
|
|||
</where>
|
||||
order by id asc ) t, ( SELECT @rownum := #{model.start} ) r limit #{model.start},#{model.pageSize}
|
||||
</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 <= #{model.start} + #{model.pageSize}
|
||||
|
||||
|
||||
</select>
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(id) from defence_transport_boat
|
||||
<where>
|
||||
<if test="model.equipName != null and model.equipName !=''">
|
||||
equip_name like concat('%',#{model.equipName},'%')
|
||||
</if>
|
||||
</where>
|
||||
select count(id) from defence_transport_boat
|
||||
<where>
|
||||
<if test="model.equipName != null and model.equipName !=''">
|
||||
equip_name like concat('%',#{model.equipName},'%')
|
||||
</if>
|
||||
</where>
|
||||
|
||||
|
||||
</select>
|
||||
|
|
Loading…
Reference in New Issue
Block a user