Kaynağa Gözat

增加部门管理节点

xusl 9 ay önce
ebeveyn
işleme
8dafaf3fea

+ 202 - 0
console/src/main/java/com/jiayue/center/controller/SysDeptController.java

@@ -0,0 +1,202 @@
+package com.jiayue.center.controller;
+
+import cn.hutool.core.util.NumberUtil;
+import com.jiayue.center.annotation.OperateLog;
+import com.jiayue.center.annotation.PreventReplay;
+import com.jiayue.center.backenum.AuditType;
+import com.jiayue.center.backenum.BusinessType;
+import com.jiayue.center.constant.CustomException;
+import com.jiayue.center.constant.UserConstants;
+import com.jiayue.center.entity.SysDept;
+import com.jiayue.center.service.SysDeptService;
+import com.jiayue.center.util.ResponseVO;
+import com.jiayue.center.util.RyStringUtils;
+import com.jiayue.center.util.SecurityContextUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 部门接口
+ *
+ * @author xsl
+ * @since 2023/03/21
+ */
+@RestController
+@RequestMapping("/sysDeptController")
+@Slf4j
+public class SysDeptController {
+
+    @Autowired
+    private SysDeptService sysDeptService;
+
+    /**
+     * 获取菜单列表
+     */
+    @GetMapping("/list")
+    @PreAuthorize("@ss.hasPermi('system:dept:list')")
+    @OperateLog(title = "部门管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "查询部门")
+    @PreventReplay
+    public ResponseVO list(SysDept dept) throws CustomException {
+        try {
+            if (StringUtils.isNotEmpty(dept.getDeptName())) {
+                if (dept.getDeptName().length() > 50) {
+                    return ResponseVO.fail("部门名长度不能超过50个字符!");
+                }
+            }
+            List<SysDept> deptList = sysDeptService.selectDeptList(dept);
+            return ResponseVO.success(deptList);
+        } catch (Exception e) {
+            throw new CustomException("获取部门列表异常", e);
+        }
+    }
+
+    /**
+     * 新增菜单
+     */
+    @PostMapping(value = "/addDept")
+    @OperateLog(title = "部门管理", businessType = BusinessType.INSERT, auditType = AuditType.SYS,operdesc = "新增部门")
+    @PreAuthorize("@ss.hasPermi('system:dept:add')")
+    @PreventReplay
+    public ResponseVO addDept(@RequestBody SysDept dept) throws CustomException {
+        try {
+            if (RyStringUtils.isEmpty(dept.getDeptName()) || RyStringUtils.isEmpty(dept.getDeptName().trim())) {
+                return ResponseVO.fail("部门名称不能为空!");
+            } else {
+                String deptName = dept.getDeptName().trim();
+                if (deptName.length() > 50) {
+                    return ResponseVO.fail("部门名长度不能超过50个字符!");
+                }
+            }
+
+            if (dept.getOrderNum() == null) {
+                return ResponseVO.fail("排序不能为空!");
+            } else if (!NumberUtil.isInteger(dept.getOrderNum() + "")) {
+                return ResponseVO.fail("排序不是整型数值!");
+            }
+
+            if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptNameUnique(dept))) {
+                return ResponseVO.fail(dept.getDeptName() + "'失败,部门名称已存在!");
+            }
+
+            dept.setCreateBy(SecurityContextUtil.getSysUser().getUsername());
+            int bo = sysDeptService.insertDept(dept);
+            if (bo == 1) {
+                return ResponseVO.success("添加部门成功");
+            } else {
+                log.error("添加部门失败");
+                return ResponseVO.fail("添加部门失败");
+            }
+        } catch (Exception e) {
+            throw new CustomException("添加部门异常", e);
+        }
+    }
+
+    /**
+     * 更新系统参数
+     *
+     * @param dept 参数
+     * @return 执行结果
+     */
+    @PostMapping(value = "/updateDept")
+    @OperateLog(title = "部门管理", businessType = BusinessType.UPDATE, auditType = AuditType.SYS,operdesc = "修改部门")
+    @PreAuthorize("@ss.hasPermi('system:dept:edit')")
+    @PreventReplay
+    public ResponseVO updateDept(@RequestBody SysDept dept) throws CustomException {
+        try {
+            if (dept.getDeptId() == null) {
+                return ResponseVO.fail("主键为空不能修改!");
+            }
+
+            String deptName = dept.getDeptName().trim();
+            if (RyStringUtils.isEmpty(deptName)) {
+                return ResponseVO.fail("部门名称不能为空!");
+            } else if (deptName.length() > 50) {
+                return ResponseVO.fail("部门名长度不能超过50个字符!");
+            }
+
+            if (dept.getOrderNum() == null) {
+                return ResponseVO.fail("排序不能为空!");
+            } else if (!NumberUtil.isInteger(dept.getOrderNum() + "")) {
+                return ResponseVO.fail("排序不是整型数值!");
+            }
+
+            if (sysDeptService.selectDeptById(dept.getDeptId()) == null) {
+                return ResponseVO.fail("非法访问不能修改!");
+            }
+            if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptNameUnique(dept))) {
+                return ResponseVO.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在!");
+            }
+
+            int bo = sysDeptService.updateDept(dept);
+            if (bo == 1) {
+                return ResponseVO.success("修改部门成功");
+            } else {
+                log.error("修改部门失败");
+                return ResponseVO.fail("修改部门失败");
+            }
+        } catch (Exception e) {
+            throw new CustomException("修改部门异常", e);
+        }
+    }
+
+    /**
+     * 删除菜单信息
+     */
+    @PostMapping(value = "delDept")
+    @OperateLog(title = "部门管理", businessType = BusinessType.DELETE, auditType = AuditType.SYS,operdesc = "删除部门")
+    @PreAuthorize("@ss.hasPermi('system:dept:remove')")
+    @PreventReplay
+    public ResponseVO delDept(String deptId) throws CustomException {
+        try {
+            if (StringUtils.isEmpty(deptId)) {
+                return ResponseVO.fail("删除部门的id不能为空!");
+            }
+            if (sysDeptService.hasChildByDeptId(Long.parseLong(deptId))) {
+                return ResponseVO.fail("存在子部门,不允许删除");
+            }
+
+            int bo = sysDeptService.deleteDeptById(Long.parseLong(deptId));
+            if (bo == 1) {
+                return ResponseVO.success("删除部门成功");
+            } else {
+                log.error("删除部门失败");
+                return ResponseVO.fail("删除部门失败");
+            }
+        } catch (Exception e) {
+            throw new CustomException("删除部门异常", e);
+        }
+    }
+
+    /**
+     * 根据菜单编号获取详细信息
+     */
+    @GetMapping(value = "/{getDetailInfo}")
+    @OperateLog(title = "部门管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取部门详细信息")
+    @PreventReplay
+    public ResponseVO getDetailInfo(String deptId) throws CustomException {
+        try {
+            Long menuid;
+            if (StringUtils.isNotEmpty(deptId)) {
+                if (NumberUtil.isLong(deptId)){
+                    menuid = Long.parseLong(deptId);
+                }
+                else{
+                    return ResponseVO.fail("部门id不是类型不对!");
+                }
+            }
+            else{
+                return ResponseVO.fail("部门id不能为空!");
+            }
+            SysDept sysDept = sysDeptService.selectDeptById(menuid);
+            return ResponseVO.success(sysDept);
+        } catch (Exception e) {
+            throw new CustomException("获取部门明细异常", e);
+        }
+    }
+
+}

+ 120 - 0
console/src/main/java/com/jiayue/center/entity/SysDept.java

@@ -0,0 +1,120 @@
+package com.jiayue.center.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 部门
+ *
+ * @author xsl
+ * @version 3.0
+ */
+public class SysDept extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /** 部门ID */
+    @TableId(type = IdType.AUTO)
+    private Long deptId;
+
+    /** 部门名称 */
+    private String deptName;
+
+    /** 父部门名称 */
+    private String parentName;
+
+    /** 父部门ID */
+    private Long parentId;
+
+    /** 显示顺序 */
+    private Integer orderNum;
+
+
+    /** 子部门 */
+    private List<SysDept> children = new ArrayList<SysDept>();
+
+    public Long getDeptId()
+    {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId)
+    {
+        this.deptId = deptId;
+    }
+
+    @NotBlank(message = "部门名称不能为空")
+    @Size(min = 0, max = 50, message = "部门名称长度不能超过50个字符")
+    public String getDeptName()
+    {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName)
+    {
+        this.deptName = deptName;
+    }
+
+    public String getParentName()
+    {
+        return parentName;
+    }
+
+    public void setParentName(String parentName)
+    {
+        this.parentName = parentName;
+    }
+
+    public Long getParentId()
+    {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId)
+    {
+        this.parentId = parentId;
+    }
+
+    @NotNull(message = "显示顺序不能为空")
+    public Integer getOrderNum()
+    {
+        return orderNum;
+    }
+
+    public void setOrderNum(Integer orderNum)
+    {
+        this.orderNum = orderNum;
+    }
+
+    public List<SysDept> getChildren()
+    {
+        return children;
+    }
+
+    public void setChildren(List<SysDept> children)
+    {
+        this.children = children;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("deptId", getDeptId())
+            .append("deptName", getDeptName())
+            .append("parentId", getParentId())
+            .append("orderNum", getOrderNum())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 84 - 0
console/src/main/java/com/jiayue/center/mapper/SysDeptMapper.java

@@ -0,0 +1,84 @@
+package com.jiayue.center.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jiayue.center.entity.SysDept;
+import com.jiayue.center.entity.SysMenu;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ *  部门管理Mapper
+ *
+ * @author xsl
+ * @since 2023-03-17
+ */
+@Mapper
+public interface SysDeptMapper extends BaseMapper<SysDept> {
+    /**
+     * 查询系统部门列表
+     *
+     * @param sysDept 部门信息
+     * @return 部门列表
+     */
+    public List<SysDept> selectDeptList(SysDept sysDept);
+
+
+    /**
+     * 根据用户ID查询菜单
+     *
+     * @return 菜单列表
+     */
+    public List<SysDept> selectDeptTreeAll();
+
+    /**
+     * 根据菜单ID查询信息
+     *
+     * @param deptId 菜单ID
+     * @return 菜单信息
+     */
+    public SysDept selectDeptById(Long deptId);
+
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param deptId 菜单ID
+     * @return 结果
+     */
+    public int hasChildByDeptId(Long deptId);
+
+    /**
+     * 新增部门信息
+     *
+     * @param sysDept 部门信息
+     * @return 结果
+     */
+    public int insertDept(SysDept sysDept);
+
+    /**
+     * 修改部门信息
+     *
+     * @param sysDept 部门信息
+     * @return 结果
+     */
+    public int updateDept(SysDept sysDept);
+
+    /**
+     * 删除部门管理信息
+     *
+     * @param updateBy 修改人
+     * @param deptId 菜单ID
+     * @return 结果
+     */
+    public int deleteDeptById(String updateBy,Long deptId);
+
+    /**
+     * 校验菜单名称是否唯一
+     *
+     * @param menuName 菜单名称
+     * @param parentId 父菜单ID
+     * @return 结果
+     */
+    public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
+}

+ 64 - 0
console/src/main/java/com/jiayue/center/service/SysDeptService.java

@@ -0,0 +1,64 @@
+package com.jiayue.center.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jiayue.center.entity.SysDept;
+
+import java.util.List;
+
+/**
+ * 部门服务类
+ * @author xsl
+ * @date 2023/2/16
+ */
+public interface SysDeptService extends IService<SysDept> {
+    /**
+     * 根据用户查询系统菜单列表
+     *
+     * @param Dept 用户ID
+     * @return 菜单列表
+     */
+    List<SysDept> selectDeptList(SysDept Dept);
+    /**
+     * 校验菜单名称是否唯一
+     *
+     * @param Dept 菜单信息
+     * @return 结果
+     */
+    String checkDeptNameUnique(SysDept Dept);
+    /**
+     * 新增保存菜单信息
+     *
+     * @param Dept 菜单信息
+     * @return 结果
+     */
+    int insertDept(SysDept Dept);
+    /**
+     * 根据菜单ID查询信息
+     *
+     * @param DeptId 菜单ID
+     * @return 菜单信息
+     */
+    SysDept selectDeptById(Long DeptId);
+    /**
+     * 修改保存菜单信息
+     *
+     * @param Dept 菜单信息
+     * @return 结果
+     */
+    int updateDept(SysDept Dept);
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param DeptId 菜单ID
+     * @return 结果
+     */
+    boolean hasChildByDeptId(Long DeptId);
+    /**
+     * 删除菜单管理信息
+     *
+     * @param DeptId 菜单ID
+     * @return 结果
+     */
+    int deleteDeptById(Long DeptId);
+
+}

+ 113 - 0
console/src/main/java/com/jiayue/center/service/impl/SysDeptServiceImpl.java

@@ -0,0 +1,113 @@
+package com.jiayue.center.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.center.constant.UserConstants;
+import com.jiayue.center.entity.SysDept;
+import com.jiayue.center.mapper.SysDeptMapper;
+import com.jiayue.center.service.SysDeptService;
+import com.jiayue.center.util.RyStringUtils;
+import com.jiayue.center.util.SecurityContextUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+/**
+ * 部门服务类
+ *
+ * @author xsl
+ * @date 2023/2/16
+ */
+@Service
+public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
+    @Autowired
+    SysDeptMapper deptMapper;
+
+    /**
+     * 查询系统菜单列表
+     *
+     * @param dept 菜单信息
+     * @return 菜单列表
+     */
+    @Override
+    public List<SysDept> selectDeptList(SysDept dept) {
+        // 管理员显示所有菜单信息
+        return deptMapper.selectDeptList(dept);
+    }
+
+    /**
+     * 校验菜单名称是否唯一
+     *
+     * @param dept 菜单信息
+     * @return 结果
+     */
+    @Override
+    public String checkDeptNameUnique(SysDept dept) {
+        Long deptId = RyStringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
+        SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
+        if (RyStringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
+
+    /**
+     * 新增保存菜单信息
+     *
+     * @param dept 菜单信息
+     * @return 结果
+     */
+    @Override
+    @Transactional(propagation= Propagation.REQUIRED, rollbackFor = Exception.class)
+    public int insertDept(SysDept dept) {
+        return deptMapper.insertDept(dept);
+    }
+
+    /**
+     * 修改保存菜单信息
+     *
+     * @param dept 菜单信息
+     * @return 结果
+     */
+    @Override
+    @Transactional(propagation= Propagation.REQUIRED, rollbackFor = Exception.class)
+    public int updateDept(SysDept dept) {
+        dept.setUpdateBy(SecurityContextUtil.getSysUser().getCreateBy());
+        return deptMapper.updateDept(dept);
+    }
+
+    /**
+     * 根据菜单ID查询信息
+     *
+     * @param deptId 菜单ID
+     * @return 菜单信息
+     */
+    @Override
+    public SysDept selectDeptById(Long deptId) {
+        return deptMapper.selectDeptById(deptId);
+    }
+    /**
+     * 是否存在菜单子节点
+     *
+     * @param DeptId 菜单ID
+     * @return 结果
+     */
+    @Override
+    public boolean hasChildByDeptId(Long DeptId) {
+        int result = deptMapper.hasChildByDeptId(DeptId);
+        return result > 0;
+    }
+    /**
+     * 删除菜单管理信息
+     *
+     * @param DeptId 菜单ID
+     * @return 结果
+     */
+    @Override
+    @Transactional(propagation= Propagation.REQUIRED, rollbackFor = Exception.class)
+    public int deleteDeptById(Long DeptId) {
+        return deptMapper.deleteDeptById(SecurityContextUtil.getSysUser().getUsername(),DeptId);
+    }
+}

+ 1 - 1
console/src/main/resources/application.yml

@@ -57,7 +57,7 @@ spring:
         debug: false
 
 mybatis-plus:
-  typeAliasesPackage: com.jiayue.ssi.entity
+  typeAliasesPackage: com.jiayue.center.entity
   configuration:
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl

+ 99 - 0
console/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -0,0 +1,99 @@
+<?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.jiayue.center.mapper.SysDeptMapper">
+
+	<resultMap type="SysDept" id="SysDeptResult">
+		<id     property="deptId"         column="dept_id"        />
+		<result property="deptName"       column="dept_name"      />
+		<result property="parentName"     column="parent_name"    />
+		<result property="parentId"       column="parent_id"      />
+		<result property="orderNum"       column="order_num"      />
+		<result property="createBy"       column="create_by"      />
+		<result property="createTime"     column="create_time"    />
+		<result property="updateTime"     column="update_time"    />
+		<result property="updateBy"       column="update_by"      />
+		<result property="remark"         column="remark"         />
+		<result property="delFlag"         column="del_flag"         />
+	</resultMap>
+
+	<sql id="selectDeptVo">
+        select dept_id, dept_name, parent_id, order_num, create_time
+		from sys_dept
+    </sql>
+
+	<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		<where>
+			del_flag=0
+			<if test="deptName != null and deptName != ''">
+				AND dept_name like concat('%', #{deptName}, '%')
+			</if>
+		</where>
+		order by parent_id, order_num
+	</select>
+
+	<select id="selectDeptTreeAll" resultMap="SysDeptResult">
+		select distinct m.dept_id, m.parent_id, m.dept_name, m.order_num, m.create_time
+		from sys_dept m where del_flag=0
+		order by m.parent_id, m.order_num
+	</select>
+
+
+	<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where dept_id = #{deptId} and del_flag=0
+	</select>
+
+
+	<select id="hasChildByDeptId" resultType="Integer">
+		select count(1) from sys_dept where parent_id = #{deptId} and del_flag=0
+	</select>
+
+	<insert id="insertDept" parameterType="SysDept">
+		insert into sys_dept(
+		<if test="deptId != null and deptId != 0">dept_id,</if>
+		<if test="parentId != null and parentId != 0">parent_id,</if>
+		<if test="deptName != null and deptName != ''">dept_name,</if>
+		<if test="orderNum != null">order_num,</if>
+		<if test="remark != null and remark != ''">remark,</if>
+		<if test="createBy != null and createBy != ''">create_by,</if>
+		create_time,
+		del_flag
+		)values(
+		<if test="deptId != null and deptId != 0">#{deptId},</if>
+		<if test="parentId != null and parentId != 0">#{parentId},</if>
+		<if test="deptName != null and deptName != ''">#{deptName},</if>
+		<if test="orderNum != null">#{orderNum},</if>
+		<if test="remark != null and remark != ''">#{remark},</if>
+		<if test="createBy != null and createBy != ''">#{createBy},</if>
+		sysdate(),
+		0
+		)
+	</insert>
+
+	<update id="updateDept" parameterType="SysDept">
+		update sys_dept
+		<set>
+			<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
+			<if test="parentId != null">parent_id = #{parentId},</if>
+			<if test="orderNum != null">order_num = #{orderNum},</if>
+			<if test="remark != null and remark != ''">remark = #{remark},</if>
+			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+			update_time = sysdate()
+		</set>
+		where dept_id = #{deptId} and del_flag=0
+	</update>
+
+
+	<delete id="deleteDeptById">
+	    update sys_dept set del_flag=1,update_by=#{updateBy},update_time=sysdate() where dept_id = #{deptId} and del_flag=0
+	</delete>
+
+
+	<select id="checkDeptNameUnique" parameterType="SysDept" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		where dept_name=#{deptName} and parent_id = #{parentId} and del_flag=0 limit 1
+	</select>
+</mapper>

+ 1 - 1
console/src/main/resources/mapper/system/SysLogininforMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysLogininforMapper">
+<mapper namespace="com.jiayue.center.mapper.SysLogininforMapper">
 
 	<resultMap type="SysLogininfor" id="SysLogininforResult">
 		<id     property="infoId"        column="info_id"           />

+ 1 - 1
console/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysMenuMapper">
+<mapper namespace="com.jiayue.center.mapper.SysMenuMapper">
 
 	<resultMap type="SysMenu" id="SysMenuResult">
 		<id     property="menuId"         column="menu_id"        />

+ 1 - 1
console/src/main/resources/mapper/system/SysOperLogMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysOperLogMapper">
+<mapper namespace="com.jiayue.center.mapper.SysOperLogMapper">
 
 	<resultMap type="SysOperLog" id="SysOperLogResult">
 		<id     property="operId"         column="oper_id"        />

+ 1 - 1
console/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysRoleMapper">
+<mapper namespace="com.jiayue.center.mapper.SysRoleMapper">
 
 	<resultMap type="SysRole" id="SysRoleResult">
 		<id     property="roleId"             column="role_id"               />

+ 1 - 1
console/src/main/resources/mapper/system/SysRoleMenuMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysRoleMenuMapper">
+<mapper namespace="com.jiayue.center.mapper.SysRoleMenuMapper">
 
 	<resultMap type="SysRoleMenu" id="SysRoleMenuResult">
 		<result property="roleId"     column="role_id"      />

+ 1 - 1
console/src/main/resources/mapper/system/SysUserMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysUserMapper">
+<mapper namespace="com.jiayue.center.mapper.SysUserMapper">
 
     <resultMap type="SysUser" id="SysUserResult">
         <id     property="id"       column="id"      />

+ 1 - 1
console/src/main/resources/mapper/system/SysUserRoleMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.jiayue.ssi.mapper.SysUserRoleMapper">
+<mapper namespace="com.jiayue.center.mapper.SysUserRoleMapper">
 
 	<resultMap type="SysUserRole" id="SysUserRoleResult">
 		<result property="userId"     column="user_id"      />

+ 4 - 3
ui/src/views/login/index.vue

@@ -33,6 +33,7 @@
           style="width: 58%"
           tabindex="3"
           maxlength="4"
+          @keyup.enter.native="handleLogin"
         >
           <svg-icon slot="prefix" icon-class="verifyCode" class="el-input__icon input-icon"/>
         </el-input>
@@ -127,7 +128,7 @@ export default {
             Fingerprint2.getV18(function (result) {
               resolve(result)
             })
-          }, 500)
+          }, 100)
         }
       })
     },
@@ -144,7 +145,7 @@ export default {
       }).catch((error) => {
 
       })
-    }, 1000),
+    }, 200),
     updateCaptcha() {
       // 更新验证码
       this.getCaptcha()
@@ -193,7 +194,7 @@ export default {
           return false
         }
       })
-    }, 1000)
+    }, 200)
   }
 }
 </script>

+ 339 - 0
ui/src/views/sysManager/sysDept/index.vue

@@ -0,0 +1,339 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
+      <el-form-item label="部门名称" prop="deptName">
+        <el-input
+          maxlength="50"
+          v-model="queryParams.deptName"
+          placeholder="请输入部门名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          plain
+          icon="el-icon-sort"
+          size="mini"
+          @click="toggleExpandAll"
+        >展开/折叠</el-button>
+      </el-col>
+    </el-row>
+
+    <el-table
+      v-if="refreshTable"
+      v-loading="loading"
+      :data="deptList"
+      row-key="deptId"
+      :default-expand-all="isExpandAll"
+      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
+    >
+      <el-table-column prop="deptName" label="部门名称" :show-overflow-tooltip="true" width="360"></el-table-column>
+      <el-table-column prop="orderNum" label="排序" width="60"></el-table-column>
+      <el-table-column label="创建时间" align="center" prop="createTime">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.createTime) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-plus"
+            @click="handleAdd(scope.row)"
+          >新增</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <!-- 添加或修改菜单对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="680px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="上级部门" prop="parentId">
+              <treeselect
+                v-model="form.parentId"
+                :options="deptOptions"
+                :normalizer="normalizer"
+                :show-count="true"
+                placeholder="选择上级部门"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="部门名称" prop="deptName">
+              <el-input v-model="form.deptName" placeholder="请输入部门名称" maxlength="50"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="显示排序" prop="orderNum">
+              <el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import IconSelect from "@/components/IconSelect";
+import { debounce } from 'lodash'
+export default {
+  name: "Menu",
+  dicts: ['sys_show_hide', 'sys_normal_disable'],
+  components: { Treeselect, IconSelect },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 部门表格树数据
+      deptList: [],
+      // 菜单树选项
+      deptOptions: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 是否展开,默认全部折叠
+      isExpandAll: false,
+      // 重新渲染表格状态
+      refreshTable: true,
+      // 查询参数
+      queryParams: {
+        deptName: undefined,
+        visible: undefined
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        deptName: [
+          { required: true, message: "部门名称不能为空", trigger: "blur" }
+        ],
+        orderNum: [
+          { required: true, message: "部门顺序不能为空", trigger: "blur" }
+        ],
+      }
+    };
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    /** 查询部门列表 */
+    async getList(){
+      this.loading = true;
+      await this.$axios.get('/sysDeptController/list',{params: this.queryParams}).then((res) => {
+        this.deptList = this.handleTree(res.data, "deptId")
+        this.loading = false;
+      }).catch((error) => {
+        this.loading = false;
+      })
+    },
+    /** 转换菜单数据结构 */
+    normalizer(node) {
+      if (node.children && !node.children.length) {
+        delete node.children
+      }
+      return {
+        id: node.deptId,
+        label: node.deptName,
+        children: node.children
+      };
+    },
+    /** 查询菜单下拉树结构 */
+    async getTreeselect() {
+      await this.$axios.get('/sysDeptController/list').then((res) => {
+        this.deptOptions = []
+        const dept = { deptId: 0, deptName: '根节点', children: [] }
+        dept.children = this.handleTree(res.data, "deptId")
+        this.deptOptions.push(dept)
+      })
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false
+      this.reset()
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        deptId: undefined,
+        parentId: 0,
+        deptName: undefined,
+        orderNum: undefined,
+      };
+      this.resetForm("form")
+    },
+    /** 搜索按钮操作 */
+    handleQuery:debounce(function(){
+      this.getList()
+    },200),
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm")
+    },
+    /** 新增按钮操作 */
+    handleAdd:debounce(function(row){
+      this.reset()
+      this.getTreeselect();
+      if (row != null && row.deptId) {
+        this.form.parentId = row.deptId
+      } else {
+        this.form.parentId = 0
+      }
+      this.open = true
+      this.title = "添加部门"
+    },200),
+    /** 展开/折叠操作 */
+    toggleExpandAll() {
+      this.refreshTable = false
+      this.isExpandAll = !this.isExpandAll
+      this.$nextTick(() => {
+        this.refreshTable = true
+      });
+    },
+    /** 修改按钮操作 */
+    handleUpdate:debounce(async function(row){
+      this.reset()
+      this.getTreeselect()
+      var searchParams = {
+        deptId: row.deptId,
+      }
+      await this.$axios.get('/sysDeptController/getDetailInfo',
+        {params: searchParams}).then((res) => {
+        this.form = res.data
+        this.open = true
+        this.title = "修改部门"
+      }).catch((error) => {
+        // this.$message.error('获取数据出错' + error)
+      })
+    },200),
+    /** 提交按钮 */
+    submitForm:debounce(function(){
+      this.$refs["form"].validate(async valid => {
+        if (valid) {
+          if (this.form.deptId != undefined) {
+            await this.$axios.post('/sysDeptController/updateDept', this.form).then((res) => {
+              if (res.code == 0) {
+                this.$message.success('修改成功')
+              }
+              if (res.code == 1) {
+                this.$message.error(res.data)
+              }
+              this.open = false;
+              this.getList();
+            }).catch((error) => {
+              // this.$message.error(error)
+            })
+          } else {
+            await this.$axios.post('/sysDeptController/addDept', this.form).then((res) => {
+              if (res.code == 0) {
+                this.$message.success('新增成功')
+              }
+              if (res.code == 1) {
+                this.$message.error(res.data)
+              }
+              this.open = false;
+              this.getList();
+            }).catch((error) => {
+              // this.$message.error(error)
+            })
+          }
+        }
+      });
+    },200),
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      this.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+        beforeClose(action, instance, done) {
+          if (action === "confirm") {
+            instance.$refs["confirm"].$el.onclick = (function (e) {
+              e = e || window.event;
+              if (e.detail != 0) {
+                done();
+              }
+            })();
+          } else {
+            done();
+          }
+        }
+      }).then(() => {
+        this.doDelete(row)
+      }).catch(() => {
+      });
+    },
+    /**
+     * 删除提交
+     */
+    doDelete:debounce(async function(row){
+      const param = {
+        deptId: row.deptId,
+      }
+      await this.$axios.post('/sysDeptController/delDept', param).then((res) => {
+        if (res.code == 0) {
+          this.$message({
+            type: 'success',
+            message: '删除成功!'
+          });
+        } else {
+          this.$message({
+            type: 'error',
+            message: res.data
+          });
+        }
+        this.getList();
+      }).catch((error) => {
+        this.$message({
+          type: 'error',
+          message: '删除失败!'
+        });
+        this.loading = false
+      })
+    },200)
+  }
+}
+</script>

+ 6 - 6
ui/src/views/sysManager/sysMenu/index.vue

@@ -386,7 +386,7 @@ export default {
     async getTreeselect() {
       await this.$axios.get('/sysMenuController/list').then((res) => {
         this.menuOptions = []
-        const menu = { menuId: 0, menuName: '主类目', children: [] }
+        const menu = { menuId: 0, menuName: '根节点', children: [] }
         menu.children = this.handleTree(res.data, "menuId")
         this.menuOptions.push(menu)
       })
@@ -415,7 +415,7 @@ export default {
     /** 搜索按钮操作 */
     handleQuery:debounce(function(){
       this.getList()
-    },1000),
+    },200),
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm("queryForm")
@@ -431,7 +431,7 @@ export default {
       }
       this.open = true
       this.title = "添加菜单"
-    },500),
+    },200),
     /** 展开/折叠操作 */
     toggleExpandAll() {
       this.refreshTable = false
@@ -459,7 +459,7 @@ export default {
       }).catch((error) => {
         // this.$message.error('获取数据出错' + error)
       })
-    },500),
+    },200),
     /** 提交按钮 */
     submitForm:debounce(function(){
       this.$refs["form"].validate(async valid => {
@@ -496,7 +496,7 @@ export default {
           }
         }
       });
-    },1000),
+    },200),
     /** 删除按钮操作 */
     handleDelete(row) {
       this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?', '提示', {
@@ -547,7 +547,7 @@ export default {
         });
         this.loading = false
       })
-    },1000)
+    },200)
   }
 }
 </script>