①、pom.xm文件中加入如下构建内容
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>srping-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<filtering>false</filtering>
</includes>
</resource>
<resource>
<directory>src/main/resurces</directory>
<includes>
<include>**/*.yml<include>
<include>**/*.properties<include>
<include>**/*.xml<include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
②、application.properties
mybatis-plus.mapper-locations=classpath:com/michael/ggkt/vod/mapper/xml/*.xml
=========================================================
ConfigMapper
//参数配置 数据层
@Mapper
public interface ConfigMapper{
//查询参数配置信息
Config selectConfig(Config config);
//查询参数配置列表
List<Config> selectConfigList(Config config);
//根据键名查询
Config checkConfigKeyUnique(String configKey);
//新增
int insertConfig(Config config);
//修改
int updateConfig(Config config);
//批量删除
int deleteConfigByIds(String[] configIds);
}
<?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">
<mapper namespace="com.xxxx.mapper.ConfigMapper"><!--对应类的包名-->
<resultMap type="com.xxxx.domain.Config" id="configResult"><!--类属性名和数据库字段名的对应-->
<id property="configId" column="config_id" />
<result property="configName" column="config_name" />
<result property="configKey" column="config_key" />
<result property="configValue" column="config_value" />
<result property="configType" column="config_type" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectConfigVo"> <!--提取公共sql-->
SELECT config_id,
config_name,
config_key,
config_value,
config_type,
create_by,
create_time,
update_by,
update_time,
remark
FROM sys_config
</sql>
<sql id="sqlwhereSearch"><!--提取公共查询条件-->
<where>
<if test="configId != null">
AND config_id = #{configId}
</if>
<if test="configKey !=null and configKey != ''">
AND config_key = #{configKey}
</if>
</where>
</sql>
<!--正式和接口方法对应的增删改查-->
<select id="selectConfig" parameterType="com.ruoyi.system.domain.Config" resultMap="ConfigResult">
<include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/>
</select>
<select id="selectConfigList" parameterType="com.ruoyi.system.domain.Config" resultMap="ConfigResult">
<include refid="selectConfigVo"/>
<where>
<if test="configName != null and configName != ''">
AND config_name LIKE concat('%', #{configName}, '%')
</if>
<if test="configType != null and configType != ''">
AND config_type = #{configType}
</if>
<if test="configKey != null and configKey != ''">
AND config_key LIKE concat('%', #{configKey}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
</where>
</select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="ConfigResult">
<include refid="selectConfigVo"/>
WHERE config_key = #{configKey}
</select>
<insert id="insertConfig" parameterType="com.ruoyi.system.domain.Config">
INSERT INTO sys_config (
<if test="configName != null and configName != '' ">config_name,</if>
<if test="configKey != null and configKey != '' ">config_key,</if>
<if test="configValue != null and configValue != '' ">config_value,</if>
<if test="configType != null and configType != '' ">config_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)VALUES(
<if test="configName != null and configName != ''">#{configName},</if>
<if test="configKey != null and configKey != ''">#{configKey},</if>
<if test="configValue != null and configValue != ''">#{configValue},</if>
<if test="configType != null and configType != ''">#{configType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
<update id="updateConfig" parameterType="com.ruoyi.system.domain.Config">
UPDATE sys_config
<set>
<if test="configName != null and configName != ''">config_name = #{configName},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
<if test="configValue != null and configValue != ''">config_value = #{configValue},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
WHERE config_id = #{configId}
</update>
<delete id="deleteConfigByIds" parameterType="String">
DELETE FROM sys_config WHERE config_id IN
<foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId}
</foreach>
</delete>
</mapper>
DeptMapper
@Mapper
public interface DeptMapper {
/**
* 查询部门人数
*
* @param dept 部门信息
* @return 结果
*/
int selectDeptCount(Dept dept);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
int checkDeptExistUser(Long deptId);
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
List<Dept> selectDeptList(Dept dept);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
int deleteDeptById(Long deptId);
/**
* 新增部门信息
*
* @param dept 部门信息
* @return 结果
*/
int insertDept(Dept dept);
/**
* 修改部门信息
*
* @param dept 部门信息
* @return 结果
*/
int updateDept(Dept dept);
/**
* 修改子元素关系
*
* @param depts 子元素
* @return 结果
*/
int updateDeptChildren(@Param("depts") List<Dept> depts);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
Dept selectDeptById(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param deptName 部门名称
* @param parentId 父部门ID
* @return 结果
*/
Dept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
/**
* 根据角色ID查询部门
*
* @param roleId 角色ID
* @return 部门列表
*/
List<String> selectRoleDeptTree(Long roleId);
/**
* 修改所在部门的父级部门状态
*
* @param dept 部门
*/
void updateDeptStatus(Dept dept);
/**
* 根据ID查询所有子部门
*
* @param id
* @return
*/
List<Dept> selectChildrenDeptById(Long id);
/**
* 根据角色编号查询所有部门ID
*
* @param roleId
* @return
* @author zmr
*/
Set<String> selectRoleDeptIds(Long roleId);
/**
* 清除默认
*/
void clearDefault();
/**
* 查找默认角色
*
* @return 默认角色,若不存在则返回null
*/
Dept findDefault();
}
<?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">
<mapper namespace="com.ruoyi.system.mapper.DeptMapper">
<resultMap type="com.ruoyi.system.domain.Dept" id="DeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="leaderId" column="leader_id" />
<result property="phone" column="phone" />
<result property="email" column="email" />
<result property="status" column="status" />
<result property="isDefault" column="is_default" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="parkId" column="park_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeptVo">
SELECT d.dept_id,
d.parent_id,
d.ancestors,
d.dept_name,
d.order_num,
d.leader,
d.leader_id,
d.phone,
d.email,
d.status,
d.is_default,
d.del_flag,
d.park_id,
d.create_by,
d.create_time
FROM sys_dept d
</sql>
<select id="selectRoleDeptTree" parameterType="Long" resultType="String">
SELECT concat(d.dept_id, d.dept_name) AS dept_name
FROM sys_dept d
LEFT JOIN sys_role_dept rd ON d.dept_id = rd.dept_id
WHERE d.del_flag = '0'
AND rd.role_id = #{roleId}
ORDER BY d.parent_id, d.order_num
</select>
<select id="selectDeptList" parameterType="com.ruoyi.system.domain.Dept" resultMap="DeptResult">
<include refid="selectDeptVo"/>
WHERE d.del_flag = '0'
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
ORDER BY order_num
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
SELECT COUNT(1) FROM sys_user WHERE dept_id = #{deptId} AND del_flag = '0'
</select>
<select id="selectDeptCount" parameterType="com.ruoyi.system.domain.Dept" resultType="int">
SELECT COUNT(1) FROM sys_dept WHERE del_flag = '0'
<if test="deptId != null and deptId != 0"> AND dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> AND parent_id = #{parentId} </if>
</select>
<select id="checkDeptNameUnique" resultMap="DeptResult">
<include refid="selectDeptVo"/>
WHERE dept_name=#{deptName} AND parent_id = #{parentId}
</select>
<select id="selectDeptById" parameterType="Long" resultMap="