若依开源1.0.4发布

This commit is contained in:
RuoYi 2018-03-10 15:42:08 +08:00
parent 5b2bb844c4
commit 927b1bb882
38 changed files with 595 additions and 5047 deletions

View File

@ -5,7 +5,7 @@
<groupId>com.ruoyi</groupId>
<artifactId>RuoYi</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<packaging>jar</packaging>
<name>RuoYi</name>

View File

@ -123,9 +123,9 @@ public class DruidConfig
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/monitor/druid/*");
/** 白名单 */
reg.addInitParameter("allow", "10.211.61.45,127.0.0.1,123.207.20.136");
// reg.addInitParameter("allow", "10.211.61.45,127.0.0.1,123.207.20.136");
/** IP黑名单(共同存在时deny优先于allow) */
reg.addInitParameter("deny", "10.211.61.4");
// reg.addInitParameter("deny", "10.211.61.4");
/** 是否能够重置数据 禁用HTML页面上的“Reset All”功能 */
reg.addInitParameter("resetEnable", "false");
return reg;

View File

@ -2,13 +2,16 @@ package com.ruoyi.framework.shiro.web.filter;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.session.SessionException;
import org.apache.shiro.subject.Subject;
import com.ruoyi.common.constant.CommonConstant;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SystemLogUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.user.domain.User;
import lombok.extern.slf4j.Slf4j;
@ -45,9 +48,13 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
String redirectUrl = getRedirectUrl(request, response, subject);
try
{
String loginName = ShiroUtils.getLoginName();
// 记录用户退出日志
SystemLogUtils.log(loginName, CommonConstant.LOGOUT, MessageUtils.message("user.logout.success"));
User user = (User) ShiroUtils.getSubjct().getPrincipal();
if (StringUtils.isNotNull(user))
{
String loginName = user.getLoginName();
// 记录用户退出日志
SystemLogUtils.log(loginName, CommonConstant.LOGOUT, MessageUtils.message("user.logout.success"));
}
// 退出登录
subject.logout();
}
@ -71,7 +78,7 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
protected String getRedirectUrl(ServletRequest request, ServletResponse response, Subject subject)
{
String url = getLoginUrl();
if (StringUtils.isNoneBlank(url))
if (StringUtils.isNotEmpty(url))
{
return url;
}

View File

@ -14,13 +14,14 @@ public interface IDeptDao
* 新增部门管理
*
* @param dept 部门对象
* @return 结果
*/
public int insertDept(Dept dept);
/**
* 查询部门人数
*
* @param parentId 部门ID
* @param dept 部门对象
* @return 结果
*/
public int selectDeptCount(Dept dept);

View File

@ -16,6 +16,7 @@ public interface IDeptService
* 新增部门管理
*
* @param dept 部门对象
* @return 结果
*/
public int insertDept(Dept dept);

View File

@ -2,17 +2,15 @@ package com.ruoyi.project.system.menu.controller;
import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.project.system.menu.service.IMenuService;
import com.ruoyi.project.system.role.domain.Role;
/**
* 角色信息
@ -39,11 +37,11 @@ public class MenuController extends BaseController
/**
* 加载菜单列表树
*/
@GetMapping("/treeData/{roleId}")
@GetMapping("/treeData")
@ResponseBody
public List<Map<String, Object>> treeData(@PathVariable("roleId") Long roleId)
public List<Map<String, Object>> treeData(Role role)
{
List<Map<String, Object>> tree = menuService.selectMenuTree(roleId);
List<Map<String, Object>> tree = menuService.selectMenuTree(role);
return tree;
}
}

View File

@ -63,6 +63,7 @@ public class MenuDaoImpl extends DynamicObjectBaseDao implements IMenuDao
* @param roleId 角色ID
* @return 菜单列表
*/
@Override
public List<String> selectMenuTree(Long roleId)
{
List<String> menuList = null;

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.ruoyi.project.system.menu.domain.Menu;
import com.ruoyi.project.system.role.domain.Role;
/**
* 菜单 业务层
@ -32,10 +33,10 @@ public interface IMenuService
/**
* 根据角色ID查询菜单
*
* @param roleId 角色ID
* @param role 角色对象
* @return 菜单列表
*/
public List<Map<String, Object>> selectMenuTree(Long roleId);
public List<Map<String, Object>> selectMenuTree(Role role);
/**
* 查询系统所有权限

View File

@ -17,6 +17,7 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.TreeUtils;
import com.ruoyi.project.system.menu.dao.IMenuDao;
import com.ruoyi.project.system.menu.domain.Menu;
import com.ruoyi.project.system.role.domain.Role;
/**
* 菜单 业务层处理
@ -68,22 +69,23 @@ public class MenuServiceImpl implements IMenuService
/**
* 根据角色ID查询菜单
*
* @param roleId 角色ID
* @param role 角色对象
* @return 菜单列表
*/
public List<Map<String, Object>> selectMenuTree(Long roleId)
@Override
public List<Map<String, Object>> selectMenuTree(Role role)
{
Long roleId = role.getRoleId();
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<String> roleMenuList = menuDao.selectMenuTree(roleId);
List<Menu> menuList = menuDao.selectPermsAll();
for (Menu menu : menuList)
if (StringUtils.isNotNull(roleId))
{
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put("id", menu.getMenuId());
deptMap.put("pId", menu.getParentId());
deptMap.put("name", menu.getMenuName());
deptMap.put("checked", roleMenuList.contains(menu.getMenuId() + menu.getPerms()));
trees.add(deptMap);
List<String> roleMenuList = menuDao.selectMenuTree(roleId);
trees = getTrees(menuList, true, roleMenuList);
}
else
{
trees = getTrees(menuList, false, null);
}
return trees;
}
@ -108,13 +110,29 @@ public class MenuServiceImpl implements IMenuService
return section;
}
public static void main(String[] args)
/**
* 获取菜单树
*/
public List<Map<String, Object>> getTrees(List<Menu> menuList, boolean isCheck, List<String> roleMenuList)
{
List<Long> list = new ArrayList<Long>();
list.add(1L);
list.add(2L);
list.add(3L);
System.out.println(list.contains(Long.valueOf(1)));
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
for (Menu menu : menuList)
{
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put("id", menu.getMenuId());
deptMap.put("pId", menu.getParentId());
deptMap.put("name", menu.getMenuName());
if (isCheck)
{
deptMap.put("checked", roleMenuList.contains(menu.getMenuId() + menu.getPerms()));
}
else
{
deptMap.put("checked", false);
}
trees.add(deptMap);
}
return trees;
}
}

View File

@ -1,5 +1,7 @@
package com.ruoyi.project.system.role.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -10,10 +12,13 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.menu.domain.Menu;
import com.ruoyi.project.system.menu.service.IMenuService;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.service.IRoleService;
@ -32,6 +37,9 @@ public class RoleController extends BaseController
@Autowired
private IRoleService roleService;
@Autowired
private IMenuService menuService;
@RequiresPermissions("system:role:view")
@GetMapping()
public String user()
@ -47,6 +55,16 @@ public class RoleController extends BaseController
TableDataInfo rows = roleService.pageInfoQuery(getPageUtilEntity());
return rows;
}
/**
* 新增角色
*/
@Log(title = "系统管理", action = "角色管理-新增角色")
@GetMapping("/add")
public String add(Model model)
{
return prefix + "/add";
}
/**
* 修改角色
@ -60,6 +78,21 @@ public class RoleController extends BaseController
return prefix + "/edit";
}
/**
* 修改角色
*/
@Log(title = "系统管理", action = "角色管理-保存角色")
@PostMapping("/save")
@ResponseBody
public JSON save(Role role)
{
if (roleService.saveRole(role) > 0)
{
return JSON.ok();
}
return JSON.error();
}
@Log(title = "系统管理", action = "角色管理-删除角色")
@RequestMapping("/remove/{roleId}")
@ResponseBody

View File

@ -1,10 +1,10 @@
package com.ruoyi.project.system.role.dao;
import java.util.List;
import com.ruoyi.framework.web.page.PageUtilEntity;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.domain.RoleMenu;
/**
* 角色表 数据层
@ -61,4 +61,36 @@ public interface IRoleDao
*/
public int batchDeleteRole(Long[] ids);
/**
* 通过角色ID删除角色和菜单关联
*
* @param roleId 角色ID
* @return 结果
*/
public int deleteRoleMenuByRoleId(Long roleId);
/**
* 修改角色信息
*
* @param role 角色信息
* @return 结果
*/
public int updateRole(Role role);
/**
* 新增角色信息
*
* @param role 角色信息
* @return 结果
*/
public int insertRole(Role role);
/**
* 批量新增角色菜单信息
*
* @param roleMenuList 角色菜单列表
* @return 结果
*/
public int batchRoleMenu(List<RoleMenu> roleMenuList);
}

View File

@ -6,6 +6,7 @@ import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
import com.ruoyi.framework.web.page.PageUtilEntity;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.domain.RoleMenu;
/**
* 角色 数据层处理
@ -22,6 +23,7 @@ public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
* @param pageUtilEntity 分页对象
* @return 用户信息集合信息
*/
@Override
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity)
{
return this.findForList("SystemRoleMapper.pageInfoQuery", pageUtilEntity);
@ -75,6 +77,7 @@ public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public Role selectRoleById(Long roleId)
{
return this.findForObject("SystemRoleMapper.selectRoleById", roleId);
@ -86,6 +89,7 @@ public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
* @param roleId 角色ID
* @return 结果
*/
@Override
public int deleteRoleById(Long roleId)
{
return this.delete("SystemRoleMapper.deleteRoleById", roleId);
@ -97,9 +101,57 @@ public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int batchDeleteRole(Long[] ids)
{
return this.delete("SystemRoleMapper.batchDeleteRole", ids);
}
/**
* 通过角色ID删除角色和菜单关联
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public int deleteRoleMenuByRoleId(Long roleId)
{
return this.delete("SystemRoleMenuMapper.deleteRoleMenuByRoleId", roleId);
}
/**
* 保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int updateRole(Role role)
{
return this.update("SystemRoleMapper.updateRole", role);
}
/**
* 新增角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int insertRole(Role role)
{
return this.update("SystemRoleMapper.insertRole", role);
}
/**
* 批量新增角色菜单信息
*
* @param roleMenuList 角色菜单列表
* @return 结果
*/
@Override
public int batchRoleMenu(List<RoleMenu> roleMenuList)
{
return this.batchSave("SystemRoleMenuMapper.batchRoleMenu", roleMenuList);
}
}

View File

@ -31,5 +31,7 @@ public class Role
private String remark;
/** 用户是否存在此角色标识 默认不存在 */
private boolean flag = false;
/** 菜单组 */
private Long[] menuIds;
}

View File

@ -0,0 +1,17 @@
package com.ruoyi.project.system.role.domain;
import lombok.Data;
/**
* 角色和菜单关联 sys_role_menu
*
* @author ruoyi
*/
@Data
public class RoleMenu
{
/** 角色ID */
private Long roleId;
/** 菜单ID */
private Long menuId;
}

View File

@ -2,7 +2,6 @@ package com.ruoyi.project.system.role.service;
import java.util.List;
import java.util.Set;
import com.ruoyi.framework.web.page.PageUtilEntity;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.role.domain.Role;
@ -70,4 +69,12 @@ public interface IRoleService
*/
public int batchDeleteRole(Long[] ids);
/**
* 保存角色信息
*
* @param role 角色信息
* @return 结果
*/
public int saveRole(Role role);
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.project.system.role.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@ -11,6 +12,7 @@ import com.ruoyi.framework.web.page.PageUtilEntity;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.role.dao.IRoleDao;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.domain.RoleMenu;
/**
* 角色 业务层处理
@ -30,6 +32,7 @@ public class RoleServiceImpl implements IRoleService
* @param pageUtilEntity 分页对象
* @return 角色信息集合信息
*/
@Override
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity)
{
return roleDao.pageInfoQuery(pageUtilEntity);
@ -98,6 +101,7 @@ public class RoleServiceImpl implements IRoleService
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public Role selectRoleById(Long roleId)
{
return roleDao.selectRoleById(roleId);
@ -109,6 +113,7 @@ public class RoleServiceImpl implements IRoleService
* @param roleId 角色ID
* @return 结果
*/
@Override
public int deleteRoleById(Long roleId)
{
return roleDao.deleteRoleById(roleId);
@ -120,9 +125,57 @@ public class RoleServiceImpl implements IRoleService
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int batchDeleteRole(Long[] ids)
{
return roleDao.batchDeleteRole(ids);
}
/**
* 保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int saveRole(Role role)
{
Long roleId = role.getRoleId();
if (StringUtils.isNotNull(roleId))
{
// 删除角色与菜单关联
roleDao.deleteRoleMenuByRoleId(roleId);
}
else
{
// 新增角色信息
roleDao.insertRole(role);
}
insertRoleMenu(role);
return roleDao.updateRole(role);
}
/**
* 新增角色菜单信息
*
* @param user 角色对象
*/
public void insertRoleMenu(Role role)
{
// 新增用户与角色管理
List<RoleMenu> list = new ArrayList<RoleMenu>();
for (Long menuId : role.getMenuIds())
{
RoleMenu rm = new RoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0)
{
roleDao.batchRoleMenu(list);
}
}
}

View File

@ -82,7 +82,7 @@ public interface IUserDao
/**
* 批量新增用户角色信息
*
* @param user 用户信息
* @param userRoleList 用户角色列表
* @return 结果
*/
public int batchUserRole(List<UserRole> userRoleList);
@ -90,7 +90,7 @@ public interface IUserDao
/**
* 校验用户名称是否唯一
*
* @param userName 用户名
* @param loginName 登录名称
* @return 结果
*/
public int checkNameUnique(String loginName);

View File

@ -114,16 +114,10 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
return this.save("SystemUserMapper.insertUser", user);
}
/**
* 新增用户信息
*
* @param user 用户信息
* @return 结果
*/
/**
* 批量新增用户角色信息
*
* @param user 用户信息
* @param userRoleList 用户角色列表
* @return 结果
*/
@Override

View File

@ -63,7 +63,7 @@ public interface IUserService
/**
* 校验用户名称是否唯一
*
* @param userName 用户名
* @param loginName 登录名称
* @return 结果
*/
public String checkNameUnique(String loginName);

View File

@ -120,7 +120,7 @@ public class UserServiceImpl implements IUserService
public void insertUserRole(User user)
{
// 新增用户与角色管理
List<UserRole> list = new ArrayList<>();
List<UserRole> list = new ArrayList<UserRole>();
for (Long roleId : user.getRoleIds())
{
UserRole ur = new UserRole();

View File

@ -8,9 +8,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
#url: jdbc:mysql://10.213.24.45:3306/ry?useUnicode=true&characterEncoding=utf8
url: jdbc:mysql://123.207.20.136:3306/ry?useUnicode=true&characterEncoding=utf8
username: ruoyi
password: 123456
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8
username: root
password: password
# 初始化大小,最小,最大
initialSize: 1
minIdle: 3

View File

@ -53,5 +53,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{roleId}
</foreach>
</delete>
<update id="updateRole" parameterType="Role">
update sys_role
<set>
<if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
<if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
<if test="status !=null">status = #{status},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
</set>
where 1=1
<if test="roleId != null">and role_id = #{roleId}</if>
</update>
<insert id="insertRole" parameterType="Role" useGeneratedKeys="true" keyProperty="roleId">
insert into sys_role(
<if test="roleId != null and roleId != 0">role_id,</if>
<if test="roleName != null and roleName != 0">role_name,</if>
<if test="roleKey != null and roleKey != ''">role_key,</if>
<if test="roleSort != null and roleSort != ''">role_sort,</if>
<if test="status !=null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="roleId != null and roleId != ''">#{roleId},</if>
<if test="roleName != null and roleName != ''">#{roleName},</if>
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
<if test="roleSort != null and roleSort != ''">#{roleSort},</if>
<if test="status !=null and status != ''">status,</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
</mapper>

View File

@ -0,0 +1,23 @@
<?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="SystemRoleMenuMapper">
<resultMap type="RoleMenu" id="RoleMenuResult">
<result property="roleId" column="role_id" />
<result property="menuId" column="menu_id" />
</resultMap>
<delete id="deleteRoleMenuByRoleId">
delete from sys_role_menu where role_id=#{roleId}
</delete>
<insert id="batchRoleMenu">
insert into sys_role_menu(role_id, menu_id) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.roleId},#{item.menuId})
</foreach>
</insert>
</mapper>

View File

@ -15,8 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchUserRole">
insert into sys_user_role(user_id, role_id) values
<foreach item="item" index="index" collection="list"
separator=",">
<foreach item="item" index="index" collection="list" separator=",">
(#{item.userId},#{item.roleId})
</foreach>
</insert>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,83 @@
// 树结构初始化加载
var setting = {
check:{enable:true,nocheckInherit:true,chkboxType:{"Y":"ps","N":"ps"}},
view:{selectedMulti:false,nameIsHTML: true},
data:{simpleData:{enable:true},key:{title:"title"}},
callback:{
beforeClick: function (treeId, treeNode, clickFlag) {
var menuTrees = $.fn.zTree.getZTreeObj(treeId);
menuTrees.checkNode(treeNode, !treeNode.checked, true, true);
return false;
}
}
}, menuTrees, loadTree = function(){
$.get("/system/menu/treeData", function(data) {
menuTrees = $.fn.zTree.init($("#menuTrees"), setting, data); //.expandAll(true);
}, null, null, "正在加载,请稍后...");
};loadTree();
$("#form-role-add").validate({
rules:{
roleName:{
required:true,
},
roleKey:{
required:true,
},
roleSort:{
required:true,
},
},
submitHandler:function(form){
add();
}
});
function getIsChecked() {
var menuIds = "";
var treeNodes = menuTrees.getCheckedNodes(true);
for (var i = 0; i < treeNodes.length; i++) {
if (0 == i) {
menuIds = treeNodes[i].id;
} else {
menuIds += ("," + treeNodes[i].id);
}
}
return menuIds;
}
function add() {
var roleName = $("input[name='roleName']").val();
var roleKey = $("input[name='roleKey']").val();
var roleSort = $("input[name='roleSort']").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
var remark = $("input[name='remark']").val();
var menuIds = getIsChecked();
$.ajax({
cache : true,
type : "POST",
url : "/system/role/save",
data : {
"roleName": roleName,
"roleKey": roleKey,
"roleSort": roleSort,
"status": status,
"remark": remark,
"menuIds": menuIds
},
async : false,
error : function(request) {
parent.layer.alert("系统错误");
},
success : function(data) {
if (data.code == 0) {
parent.layer.msg('新增成功',{icon:1,time:1000});
layer_close();
window.parent.location.reload();
} else {
parent.layer.alert(data.m , {icon: 2,title:"系统提示"});
}
}
});
}

View File

@ -1,6 +1,31 @@
$(document).ready(function(){
queryMenuTreeDaTa();
});
// 树结构初始化加载
var setting = {
check:{enable:true,nocheckInherit:true,chkboxType:{"Y":"ps","N":"ps"}},
view:{selectedMulti:false,nameIsHTML: true},
data:{simpleData:{enable:true},key:{title:"title"}},
callback:{
beforeClick: function (treeId, treeNode, clickFlag) {
var menuTrees = $.fn.zTree.getZTreeObj(treeId);
menuTrees.checkNode(treeNode, !treeNode.checked, true, true);
return false;
},
onCheck: function (event, treeId, treeNode){
var tid = treeNode.tId;
if(!treeNode.checked){
$(".checkall[value="+treeId+"]").each(function(){
if(this.checked){
$(this).removeAttr("checked").iCheck('update');
}
return false;
});
}
}
}
}, menuTrees, loadTree = function(){
$.get("/system/menu/treeData?roleId=" + $("#roleId").val(), function(data) {
menuTrees = $.fn.zTree.init($("#menuTrees"), setting, data); //.expandAll(true);
}, null, null, "正在加载,请稍后...");
};loadTree();
$("#form-role-edit").validate({
rules:{
@ -19,12 +44,27 @@ $("#form-role-edit").validate({
}
});
function getIsChecked() {
var menuIds = "";
var treeNodes = menuTrees.getCheckedNodes(true);
for (var i = 0; i < treeNodes.length; i++) {
if (0 == i) {
menuIds = treeNodes[i].id;
} else {
menuIds += ("," + treeNodes[i].id);
}
}
return menuIds;
}
function update() {
var roleId = $("input[name='roleId']").val();
var roleName = $("input[name='roleName']").val();
var roleKey = $("input[name='roleKey']").val();
var roleSort = $("input[name='roleSort']").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
var remark = $("input[name='remark']").val();
var menuIds = getIsChecked();
$.ajax({
cache : true,
type : "POST",
@ -34,7 +74,9 @@ function update() {
"roleName": roleName,
"roleKey": roleKey,
"roleSort": roleSort,
"status": status
"status": status,
"remark": remark,
"menuIds": menuIds
},
async : false,
error : function(request) {
@ -52,40 +94,3 @@ function update() {
}
});
}
function queryMenuTreeDaTa()
{
// 树结构初始化加载
var setting = {
check:{enable:true,nocheckInherit:true,chkboxType:{"Y":"ps","N":"ps"}},
view:{selectedMulti:false,nameIsHTML: true},
data:{simpleData:{enable:true},key:{title:"title"}},
callback:{
beforeClick: function (treeId, treeNode, clickFlag) {
var tree = $.fn.zTree.getZTreeObj(treeId);
tree.checkNode(treeNode, !treeNode.checked, true, true);
return false;
},
onCheck: function (event, treeId, treeNode){
var tid = treeNode.tId;
if(!treeNode.checked){
$(".checkall[value="+treeId+"]").each(function(){
if(this.checked){
$(this).removeAttr("checked").iCheck('update');
}
return false;
});
}
}
}
}, tree, loadTree = function(){
$.get("/system/menu/treeData/" + $("#roleId").val(), function(data) {
tree = $.fn.zTree.init($("#tree"), setting, data); //.expandAll(true);
// 展开第一级节点
var nodes = tree.getNodesByParam("level", 0);
for (var i = 0; i < nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
}
}, null, null, "正在加载,请稍后...");
};loadTree();
}

View File

@ -50,10 +50,16 @@ $(function() {
initTable(columns, url);
});
/*角色管理-新增*/
function add() {
var url = prefix + '/add';
layer_show("新增角色", url, '800', '550');
}
/*角色管理-修改*/
function edit(roleId) {
var url = prefix + '/edit/' + roleId;
layer_show("修改角色", url, '800', '400');
layer_show("修改角色", url, '800', '550');
}
// 单条删除

View File

@ -16,15 +16,15 @@ $("#form-user-edit").validate({
});
function getIsChecked(_name) {
var adIds = "";
$('input:checkbox[name="'+_name+'"]:checked').each(function(i) {
if (0 == i) {
adIds = $(this).val();
} else {
adIds += ("," + $(this).val());
}
});
return adIds;
var roleIds = "";
$('input:checkbox[name="' + _name + '"]:checked').each(function(i) {
if (0 == i) {
roleIds = $(this).val();
} else {
roleIds += ("," + $(this).val());
}
});
return roleIds;
}
function update() {

View File

@ -1,33 +1,33 @@
// 树结构初始化加载
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
callback:{onClick:function(event, treeId, treeNode){
var deptId = treeNode.id;
var deptName = treeNode.name;
$("#deptId").val(deptId);
$("#deptName").val(deptName);
}}
}, tree, loadTree = function(){
$.get("/system/dept/treeData", function(data) {
tree = $.fn.zTree.init($("#tree"), setting, data);
// 展开第一级节点
var nodes = tree.getNodesByParam("level", 0);
for (var i = 0; i < nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
}
// 展开第二级节点
nodes = tree.getNodesByParam("level", 1);
for (var i = 0; i < nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
}
}, null, null, "正在加载,请稍后...");
};loadTree();
$('#btnExpand').click(function() {
tree.expandAll(true);
});
$('#btnCollapse').click(function() {
tree.expandAll(false);
});
// 树结构初始化加载
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
callback:{onClick:function(event, treeId, treeNode){
var deptId = treeNode.id;
var deptName = treeNode.name;
$("#deptId").val(deptId);
$("#deptName").val(deptName);
}}
}, tree, loadTree = function(){
$.get("/system/dept/treeData", function(data) {
tree = $.fn.zTree.init($("#tree"), setting, data);
// 展开第一级节点
var nodes = tree.getNodesByParam("level", 0);
for (var i = 0; i < nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
}
// 展开第二级节点
nodes = tree.getNodesByParam("level", 1);
for (var i = 0; i < nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
}
}, null, null, "正在加载,请稍后...");
};loadTree();
$('#btnExpand').click(function() {
tree.expandAll(true);
});
$('#btnCollapse').click(function() {
tree.expandAll(false);
});
function loadUser(){
var deptId = $("#deptId").val();

View File

@ -35,7 +35,7 @@
<h2>若依后台管理框架</h2>
<p>一直想做一款后台管理系统看了很多优秀的开源项目但是发现没有合适自己的。于是利用空闲休息时间开始自己写一套后台系统。如此有了若依管理系统。她可以用于所有的Web应用程序<b>网站管理后台</b><b>网站会员中心</b><b>CMS</b><b>CRM</b><b>OA</b>等等,当然,您也可以对她进行深度定制,以做出更强系统。所有前端后台代码封装过后十分精简易上手,出错效率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。</p>
<p>
<b>当前版本:</b>v1.0.3
<b>当前版本:</b>v1.0.4
</p>
<p>
<span class="label label-warning">&yen;免费开源</span>
@ -94,13 +94,27 @@
<div class="ibox-content no-padding">
<div class="panel-body">
<div class="panel-group" id="version">
<div class="panel panel-default">
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v04">v1.0.4</a><code class="pull-right">2018.03.11</code>
</h5>
</div>
<div id="v04" class="panel-collapse collapse in">
<div class="panel-body">
<ol>
<li>新增角色管理(新增、删除、修改、查询、菜单选择)</li>
</ol>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h5 class="panel-title">
<a data-toggle="collapse" data-parent="#version" href="#v03">v1.0.3</a><code class="pull-right">2018.03.08</code>
</h5>
</div>
<div id="v03" class="panel-collapse collapse in">
<div id="v03" class="panel-collapse collapse">
<div class="panel-body">
<ol>
<li>新增用户管理(新增、删除、修改、查询、部门选择)</li>

View File

@ -15,8 +15,6 @@
data-sort-name="last_access_time" data-sort-order="desc">
</table>
</div>
<!-- <a shiro:hasPermission="system:user:list" href="#">测试菜单</a> -->
<!-- <a shiro:hasRole="admin" href="#">测试角色</a> -->
<div th:include="include :: footer"></div>
<script type="text/javascript" src="/ruoyi/monitor/online/online.js"></script>
</body>

View File

@ -37,12 +37,11 @@
</div>
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link href="/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" rel="stylesheet">
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-add">
<div class="form-group">
<label class="col-sm-3 control-label ">角色名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="roleName" id="roleName"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权限字符:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="roleKey" id="roleKey">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示顺序:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="roleSort" id="roleSort">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<div class="onoffswitch">
<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="status" name="status">
<label class="onoffswitch-label" for="status">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<input id="remark" name="remark" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单权限</label>
<div class="col-sm-8">
<div id="menuTrees" class="ztree"></div>
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>
<button th:onclick="'javascript:layer_close()'" class="btn btn-danger" type="button">关闭</button>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script src="/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
<script type="text/javascript" src="/ruoyi/system/role/add.js">
</script>
</body>
</html>

View File

@ -38,12 +38,17 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单权限</label>
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<div id="tree" class="ztree"></div>
<input id="remark" name="remark" class="form-control" type="text" th:value="${role.remark}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单权限</label>
<div class="col-sm-8">
<div id="menuTrees" class="ztree"></div>
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>

View File

@ -6,6 +6,9 @@
<body class="gray-bg">
<div class="wrapper wrapper-content">
<div class="btn-group hidden-xs" id="tableToolbar" role="group">
<button type="button" class="btn btn-outline btn-default" th:onclick="'javascript:add()'">
<i class="glyphicon glyphicon-plus"></i>
</button>
<button type="button" class="btn btn-outline btn-default" th:onclick="'javascript:batchRemove()'">
<i class="glyphicon glyphicon-trash"></i>
</button>