Commit 0b85032c by 杜龙少

Merge remote-tracking branch 'ruoyi-orgin/master'

parents 6d115e60 9c54c5c3
......@@ -112,6 +112,11 @@ public class SysDeptController extends BaseController
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
{
return AjaxResult.error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(deptService.updateDept(dept));
}
......@@ -148,11 +153,16 @@ public class SysDeptController extends BaseController
/**
* 选择部门树
*
* @param deptId 部门ID
* @param excludeId 排除ID
*/
@GetMapping("/selectDeptTree/{deptId}")
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap)
@GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
public String selectDeptTree(@PathVariable("deptId") Long deptId,
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(deptId));
mmap.put("excludeId", excludeId);
return prefix + "/tree";
}
......@@ -168,6 +178,19 @@ public class SysDeptController extends BaseController
}
/**
* 加载部门列表树(排除下级)
*/
@GetMapping("/treeData/{excludeId}")
@ResponseBody
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
{
SysDept dept = new SysDept();
dept.setDeptId(excludeId);
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
return ztrees;
}
/**
* 加载角色部门(数据权限)列表树
*/
@GetMapping("/roleDeptTreeData")
......
......@@ -192,7 +192,7 @@ public class SysUserController extends BaseController
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
if (userService.resetUserPwd(user) > 0)
{
if (ShiroUtils.getUserId() == user.getUserId())
if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue())
{
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
}
......
......@@ -11,7 +11,7 @@ ruoyi:
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: true
addressEnabled: false
# 开发环境配置
server:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -900,6 +900,16 @@ label {
z-index:100;
}
/** 表格全屏样式 **/
.bootstrap-table.fullscreen {
position: fixed;
top: 0;
left: 0;
z-index: 1050;
width: 100%!important;
background: #FFF;
}
/** 表格树样式 **/
.bootstrap-tree-table .treetable-indent {width:16px; height: 16px; display: inline-block; position: relative;}
.bootstrap-tree-table .treetable-expander {width:16px; height: 16px; display: inline-block; position: relative; cursor: pointer;}
......
......@@ -8,6 +8,7 @@ layer.config({
});
var isMobile = $.common.isMobile() || $(window).width() < 769;
var sidebarHeight = isMobile ? '100%' : '96%';
$(function() {
// MetsiMenu
......@@ -15,7 +16,7 @@ $(function() {
// 固定菜单栏
$('.sidebar-collapse').slimScroll({
height: '96%',
height: sidebarHeight,
railOpacity: 0.9,
alwaysVisible: false
});
......@@ -371,6 +372,7 @@ $(function() {
});
}
scrollToTab($('.menuTab.active'));
setIframeUrl($('.page-tabs-content').find('.active').attr('data-id'));
return false;
}
......@@ -428,6 +430,7 @@ $(function() {
$(this).remove();
});
$('.page-tabs-content').css("margin-left", "0");
setIframeUrl($('.page-tabs-content').find('.active').attr('data-id'));
}
// 关闭全部选项卡
......@@ -441,6 +444,7 @@ $(function() {
$(this).addClass("active");
});
$('.page-tabs-content').css("margin-left", "0");
setIframeUrl($('.page-tabs-content').find('.active').attr('data-id'));
}
......
......@@ -53,6 +53,13 @@ $(function() {
if (!$(".popover:hover").length) $(_this).popover("hide");
}, 100);
});
// 取消回车自动提交表单
$(document).on("keypress", ":input:not(textarea):not([type=submit])", function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
// laydate 时间控件绑定
if ($(".select-time").length > 0) {
......
......@@ -43,6 +43,7 @@ var table = {
sortName: "",
sortOrder: "asc",
pagination: true,
paginationLoop: false,
pageSize: 10,
pageList: [10, 25, 50],
toolbar: "toolbar",
......@@ -85,6 +86,7 @@ var table = {
sortName: options.sortName, // 排序列名称
sortOrder: options.sortOrder, // 排序方式 asc 或者 desc
pagination: options.pagination, // 是否显示分页(*)
paginationLoop: options.paginationLoop, // 是否启用分页条无限循环的功能
pageNumber: 1, // 初始化加载第一页,默认第一页
pageSize: options.pageSize, // 每页的记录行数(*)
pageList: options.pageList, // 可供选择的每页的行数(*)
......@@ -103,10 +105,12 @@ var table = {
showToggle: options.showToggle, // 是否显示详细视图和列表视图的切换按钮
showExport: options.showExport, // 是否支持导出文件
showHeader: options.showHeader, // 是否显示表头
showFullscreen: options.showFullscreen, // 是否显示全屏按钮
uniqueId: options.uniqueId, // 唯 一的标识符
clickToSelect: options.clickToSelect, // 是否启用点击选中行
singleSelect: options.singleSelect, // 是否单选checkbox
mobileResponsive: options.mobileResponsive, // 是否支持移动端适配
cardView: options.cardView, // 是否启用显示卡片视图
detailView: options.detailView, // 是否启用显示细节视图
onClickRow: options.onClickRow, // 点击某行触发的事件
onDblClickRow: options.onDblClickRow, // 双击某行触发的事件
......@@ -286,7 +290,7 @@ var table = {
_value = _value.replace(/\'/g,"&apos;");
_value = _value.replace(/\"/g,"&quot;");
var actions = [];
actions.push($.common.sprintf('<input id="tooltip-show" style="opacity: 0;position: absolute;z-index:-1" type="text" value="%s"/>', _value));
actions.push($.common.sprintf('<input style="opacity: 0;position: absolute;z-index:-1" type="text" value="%s"/>', _value));
actions.push($.common.sprintf('<a href="###" class="tooltip-show" data-toggle="tooltip" data-target="%s" title="%s">%s</a>', _target, _value, _text));
return actions.join('');
} else {
......@@ -504,6 +508,16 @@ var table = {
hideColumn: function(column, tableId) {
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
$("#" + currentId).bootstrapTable('hideColumn', column);
},
// 显示所有表格列
showAllColumns: function(tableId) {
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
$("#" + currentId).bootstrapTable('showAllColumns');
},
// 隐藏所有表格列
hideAllColumns: function(tableId) {
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
$("#" + currentId).bootstrapTable('hideAllColumns');
}
},
// 表格树封装处理
......
......@@ -22,7 +22,7 @@
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<!-- bootstrap-table 表格插件 -->
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20191219}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20200423}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js}"></script>
......
......@@ -33,7 +33,7 @@
<ul class="nav" id="side-menu">
<li>
<div class="user-panel">
<a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
<a class="menuItem noactive" title="个人中心" th:href="@{/system/user/profile}">
<div class="hide" th:text="个人中心"></div>
<div class="pull-left image">
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="img-circle" alt="User Image">
......@@ -288,7 +288,9 @@ function switchSkin() {
/** 刷新时访问路径页签 */
function applyPath(url) {
$('a[href$="' + decodeURI(url) + '"]').click();
$('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li :not(.user-panel)").addClass("active").end().parents("ul").addClass("in");
if (!$('a[href$="' + url + '"]').hasClass("noactive")) {
$('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li").addClass("active").end().parents("ul").addClass("in");
}
}
$(function() {
......
......@@ -113,11 +113,12 @@
/*部门管理-修改-选择部门树*/
function selectDeptTree() {
var deptId = $("#treeId").val();
var excludeId = $("input[name='deptId']").val();
if(deptId > 0) {
var options = {
title: '部门选择',
width: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(),
url: prefix + "/selectDeptTree/" + $("#treeId").val() + "/" + excludeId,
callBack: doSubmit
};
$.modal.openOptions(options);
......
......@@ -28,8 +28,11 @@
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
var prefix = ctx + "system/dept"
var deptId = [[${deptId}]];
var excludeId = [[${excludeId}]];
$(function() {
var url = ctx + "system/dept/treeData";
var url = $.common.isEmpty(excludeId) ? prefix + "/treeData": prefix + "/treeData/" + excludeId;
var options = {
url: url,
expandLevel: 2,
......
......@@ -13,6 +13,11 @@ public class Constants
public static final String UTF8 = "UTF-8";
/**
* GBK 字符集
*/
public static final String GBK = "GBK";
/**
* 通用成功标识
*/
public static final String SUCCESS = "0";
......@@ -31,7 +36,7 @@ public class Constants
* 注销
*/
public static final String LOGOUT = "Logout";
/**
* 注册
*/
......
......@@ -19,14 +19,17 @@ public class UserConstants
public static final String EXCEPTION = "1";
/** 用户封禁状态 */
public static final String USER_BLOCKED = "1";
public static final String USER_DISABLE = "1";
/** 角色封禁状态 */
public static final String ROLE_BLOCKED = "1";
public static final String ROLE_DISABLE = "1";
/** 部门正常状态 */
public static final String DEPT_NORMAL = "0";
/** 部门停用状态 */
public static final String DEPT_DISABLE = "1";
/** 字典正常状态 */
public static final String DICT_NORMAL = "0";
......
......@@ -22,7 +22,7 @@ public class TableDataInfo implements Serializable
private int code;
/** 消息内容 */
private int msg;
private String msg;
/**
* 表格数据对象
......@@ -73,12 +73,12 @@ public class TableDataInfo implements Serializable
this.code = code;
}
public int getMsg()
public String getMsg()
{
return msg;
}
public void setMsg(int msg)
public void setMsg(String msg)
{
this.msg = msg;
}
......
......@@ -2,9 +2,9 @@ package com.ruoyi.common.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.json.JSON;
import com.ruoyi.common.json.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.http.HttpUtils;
/**
......@@ -16,12 +16,15 @@ public class AddressUtils
{
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
public static final String IP_URL = "http://ip.taobao.com/service/getIpInfo.php";
// IP地址查询
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
// 未知地址
public static final String UNKNOWN = "XX XX";
public static String getRealAddressByIP(String ip)
{
String address = "XX XX";
String address = UNKNOWN;
// 内网不查询
if (IpUtils.internalIp(ip))
{
......@@ -29,24 +32,22 @@ public class AddressUtils
}
if (Global.isAddressEnabled())
{
String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip);
if (StringUtils.isEmpty(rspStr))
{
log.error("获取地理位置异常 {}", ip);
return address;
}
JSONObject obj;
try
{
obj = JSON.unmarshal(rspStr, JSONObject.class);
JSONObject data = obj.getObj("data");
String region = data.getStr("region");
String city = data.getStr("city");
address = region + " " + city;
String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
if (StringUtils.isEmpty(rspStr))
{
log.error("获取地理位置异常 {}", ip);
return UNKNOWN;
}
JSONObject obj = JSONObject.parseObject(rspStr);
String region = obj.getString("pro");
String city = obj.getString("city");
return String.format("%s %s", region, city);
}
catch (Exception e)
{
log.error("获取地理位置异常 {}", ip);
log.error("获取地理位置异常 {}", e);
}
}
return address;
......
......@@ -18,6 +18,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.Constants;
/**
* 通用http发送方法
......@@ -37,6 +38,19 @@ public class HttpUtils
*/
public static String sendGet(String url, String param)
{
return sendGet(url, param, Constants.UTF8);
}
/**
* 向指定 URL 发送GET方法的请求
*
* @param url 发送请求的 URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @param contentType 编码类型
* @return 所代表远程资源的响应结果
*/
public static String sendGet(String url, String param, String contentType)
{
StringBuilder result = new StringBuilder();
BufferedReader in = null;
try
......@@ -49,7 +63,7 @@ public class HttpUtils
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
String line;
while ((line = in.readLine()) != null)
{
......
......@@ -174,7 +174,7 @@ public class ExcelUtil<T>
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
{
Cell cell = heard.getCell(i);
if (StringUtils.isNotNull(cell != null))
if (StringUtils.isNotNull(cell))
{
String value = this.getCellValue(heard, i).toString();
cellMap.put(value, i);
......@@ -835,7 +835,7 @@ public class ExcelUtil<T>
try
{
Cell cell = row.getCell(column);
if (cell != null)
if (StringUtils.isNotNull(cell))
{
if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA)
{
......
package ${packageName}.domain;
#foreach ($import in $importList)
import ${import};
#end
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
......@@ -8,9 +11,6 @@ import com.ruoyi.common.core.domain.BaseEntity;
#elseif($table.tree)
import com.ruoyi.common.core.domain.TreeEntity;
#end
#foreach ($import in $importList)
import ${import};
#end
/**
* ${functionName}对象 ${tableName}
......
......@@ -101,8 +101,17 @@ public interface SysDeptMapper
/**
* 根据ID查询所有子部门
*
* @param deptId 部门ID
* @return 部门列表
*/
public List<SysDept> selectChildrenDeptById(Long deptId);
/**
* 根据ID查询所有子部门(正常状态)
*
* @param deptId 部门ID
* @return 子部门数
*/
public int selectNormalChildrenDeptById(Long deptId);
}
......@@ -29,6 +29,14 @@ public interface ISysDeptService
public List<Ztree> selectDeptTree(SysDept dept);
/**
* 查询部门管理树(排除下级)
*
* @param dept 部门信息
* @return 所有部门信息
*/
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept);
/**
* 根据角色ID查询菜单
*
* @param role 角色对象
......@@ -85,6 +93,14 @@ public interface ISysDeptService
public SysDept selectDeptById(Long deptId);
/**
* 根据ID查询所有子部门(正常状态)
*
* @param deptId 部门ID
* @return 子部门数
*/
public int selectNormalChildrenDeptById(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
......
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -55,6 +57,32 @@ public class SysDeptServiceImpl implements ISysDeptService
}
/**
* 查询部门管理树(排除下级)
*
* @param deptId 部门ID
* @return 所有部门信息
*/
@Override
@DataScope(deptAlias = "d")
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept)
{
Long deptId = dept.getDeptId();
List<SysDept> deptList = deptMapper.selectDeptList(dept);
Iterator<SysDept> it = deptList.iterator();
while (it.hasNext())
{
SysDept d = (SysDept) it.next();
if (d.getDeptId().intValue() == deptId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
{
it.remove();
}
}
List<Ztree> ztrees = initZtree(deptList);
return ztrees;
}
/**
* 根据角色ID查询部门(数据权限)
*
* @param role 角色对象
......@@ -252,6 +280,18 @@ public class SysDeptServiceImpl implements ISysDeptService
}
/**
* 根据ID查询所有子部门(正常状态)
*
* @param deptId 部门ID
* @return 子部门数
*/
@Override
public int selectNormalChildrenDeptById(Long deptId)
{
return deptMapper.selectNormalChildrenDeptById(deptId);
}
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
......
......@@ -79,6 +79,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from sys_dept where find_in_set(#{deptId}, ancestors)
</select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
</select>
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment