Compare commits
2 Commits
af692b7cdf
...
731e8f7438
Author | SHA1 | Date | |
---|---|---|---|
![]() |
731e8f7438 | ||
![]() |
34029f469b |
|
@ -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" />
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
6
hshh-defence.iml
Normal file
6
hshh-defence.iml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="CheckStyle-IDEA-Module" serialisationVersion="2">
|
||||||
|
<option name="activeLocationsIds" />
|
||||||
|
</component>
|
||||||
|
</module>
|
BIN
lib/DmJdbcDriver11.jar
Normal file
BIN
lib/DmJdbcDriver11.jar
Normal file
Binary file not shown.
BIN
lib/DmJdbcDriver6.jar
Normal file
BIN
lib/DmJdbcDriver6.jar
Normal file
Binary file not shown.
BIN
lib/DmJdbcDriver7.jar
Normal file
BIN
lib/DmJdbcDriver7.jar
Normal file
Binary file not shown.
BIN
lib/DmJdbcDriver8.jar
Normal file
BIN
lib/DmJdbcDriver8.jar
Normal file
Binary file not shown.
14
pom.xml
14
pom.xml
|
@ -92,10 +92,6 @@
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.baomidou</groupId>-->
|
|
||||||
<!-- <artifactId>mybatis-plus-generator</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
@ -104,7 +100,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -143,7 +138,14 @@
|
||||||
<artifactId>springdoc-openapi-ui</artifactId>
|
<artifactId>springdoc-openapi-ui</artifactId>
|
||||||
<version>1.5.13</version> <!-- 或 1.7.0 -->
|
<version>1.5.13</version> <!-- 或 1.7.0 -->
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|
||||||
|
|
|
@ -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<>();
|
||||||
|
|
||||||
|
|
|
@ -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,55 +21,67 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
|
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
|
||||||
/**
|
|
||||||
* 获取用户菜单列表
|
/**
|
||||||
*
|
* 获取用户菜单列表
|
||||||
* @param user 用户
|
*
|
||||||
* @return 用户菜单列表
|
* @param user 用户
|
||||||
*/
|
* @return 用户菜单列表
|
||||||
@Override
|
*/
|
||||||
public List<Menu> getMenuByUserId(User user) {
|
@Override
|
||||||
//根据用户ID查询所有菜单
|
public List<Menu> getMenuByUserId(User user) {
|
||||||
List<Menu> originalmenuList = this.baseMapper.getMenuByUser(user);
|
//根据用户ID查询所有菜单
|
||||||
if(originalmenuList.isEmpty()){
|
List<Menu> originalmenuList = this.baseMapper.getMenuByUser(user);
|
||||||
return new ArrayList<>();
|
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());
|
||||||
}
|
}
|
||||||
//key为父ID,value为所有一致父ID的集合
|
);
|
||||||
Map<Integer, List<Menu>> parentMenuMap = new HashMap<>();
|
return topMenuList;
|
||||||
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) {
|
private void setChildren(Menu menu, Map<Integer, List<Menu>> parentMenuMap) {
|
||||||
//递归设置子菜单
|
|
||||||
setChildren(menu,parentMenuMap);
|
if (parentMenuMap.containsKey(menu.getId())) {
|
||||||
}
|
menu.getChildren().addAll(parentMenuMap.get(menu.getId()));
|
||||||
return topMenuList;
|
menu.getChildren().forEach(child -> {
|
||||||
|
setChildren(child, parentMenuMap);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
private void setChildren(Menu menu,Map<Integer, List<Menu>> parentMenuMap) {
|
}
|
||||||
|
|
||||||
if(parentMenuMap.containsKey(menu.getId())) {
|
@Override
|
||||||
menu.getChildren().addAll(parentMenuMap.get(menu.getId()));
|
public List<Menu> getAllMenu() {
|
||||||
menu.getChildren().forEach(child -> {
|
|
||||||
setChildren(child,parentMenuMap);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return this.list();
|
||||||
public List<Menu> getAllMenu() {
|
}
|
||||||
|
|
||||||
return this.list();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -1,44 +1,65 @@
|
||||||
<?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>
|
||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
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.*
|
||||||
FROM (
|
FROM (
|
||||||
SELECT * FROM sys_code_dict
|
SELECT * FROM sys_code_dict
|
||||||
<where>
|
<where>
|
||||||
<if test="model.codeNameCn != null and model.codeNameCn !='' ">
|
<if test="model.codeNameCn != null and model.codeNameCn !='' ">
|
||||||
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 <= (#{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 !=''">
|
||||||
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
|
code_name_cn LIKE CONCAT('%', #{model.codeNameCn}, '%')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
|
@ -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,14 +47,29 @@
|
||||||
</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 <= #{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>
|
||||||
<if test="model.equipName != null and model.equipName !=''">
|
<if test="model.equipName != null and model.equipName !=''">
|
||||||
equip_name like concat('%',#{model.equipName},'%')
|
equip_name like concat('%',#{model.equipName},'%')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user