新增用户管理

This commit is contained in:
RuoYi 2018-03-06 00:20:43 +08:00
parent b0bfc1df22
commit e2b1657a56
34 changed files with 730 additions and 60 deletions

View File

@ -33,13 +33,13 @@ drop table if exists sys_user;
create table sys_user ( create table sys_user (
user_id int(11) not null auto_increment comment '用户ID', user_id int(11) not null auto_increment comment '用户ID',
dept_id int(20) default null comment '部门ID', dept_id int(20) default null comment '部门ID',
login_name varchar(30) not null comment '登录名', login_name varchar(30) default '' comment '登录名',
user_name varchar(30) default '' comment '用户名称', user_name varchar(30) default '' comment '用户名称',
email varchar(100) default '' comment '用户邮箱', email varchar(100) default '' comment '用户邮箱',
phonenumber varchar(20) default '' comment '手机号码', phonenumber varchar(20) default '' comment '手机号码',
password varchar(100) not null comment '密码', password varchar(100) default '' comment '密码',
salt varchar(100) default '' comment '盐加密', salt varchar(100) default '' comment '盐加密',
status int(1) default 0 comment '帐号状态:0正常,1锁定,2黑名单,3禁止', status int(1) default 0 comment '帐号状态:0正常,1禁用',
refuse_des varchar(500) default '' comment '拒绝登录描述', refuse_des varchar(500) default '' comment '拒绝登录描述',
create_time varchar(30) default null comment '创建时间', create_time varchar(30) default null comment '创建时间',
primary key (user_id) primary key (user_id)

View File

@ -53,7 +53,7 @@ public class UserRealm extends AuthorizingRealm
Long userId = ShiroUtils.getUserId(); Long userId = ShiroUtils.getUserId();
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
// 角色加入AuthorizationInfo认证对象 // 角色加入AuthorizationInfo认证对象
info.setRoles(roleService.selectRolesByUserId(userId)); info.setRoles(roleService.selectRoleKeys(userId));
// 权限加入AuthorizationInfo认证对象 // 权限加入AuthorizationInfo认证对象
info.setStringPermissions(menuService.selectPermsByUserId(userId)); info.setStringPermissions(menuService.selectPermsByUserId(userId));
return info; return info;

View File

@ -80,9 +80,9 @@ public class DeptController
@RequiresPermissions("system:dept:save") @RequiresPermissions("system:dept:save")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public JSON save(Dept sysDept) public JSON save(Dept dept)
{ {
if (deptService.saveDept(sysDept) > 0) if (deptService.saveDept(dept) > 0)
{ {
return JSON.ok(); return JSON.ok();
} }

View File

@ -2,6 +2,8 @@ package com.ruoyi.project.system.role.dao;
import java.util.List; import java.util.List;
import com.ruoyi.project.system.role.domain.Role;
/** /**
* 角色表 数据层 * 角色表 数据层
* *
@ -16,6 +18,13 @@ public interface IRoleDao
* @param userId 用户ID * @param userId 用户ID
* @return 角色列表 * @return 角色列表
*/ */
public List<String> selectRolesByUserId(Long userId); public List<Role> selectRolesByUserId(Long userId);
/**
* 查询角色列表
*
* @return 角色列表
*/
public List<Role> selectRolesAll();
} }

View File

@ -1,10 +1,9 @@
package com.ruoyi.project.system.role.dao; package com.ruoyi.project.system.role.dao;
import java.util.List; import java.util.List;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.ruoyi.framework.web.dao.DynamicObjectBaseDao; import com.ruoyi.framework.web.dao.DynamicObjectBaseDao;
import com.ruoyi.project.system.role.domain.Role;
/** /**
* 角色 数据层处理 * 角色 数据层处理
@ -22,18 +21,39 @@ public class RoleDaoImpl extends DynamicObjectBaseDao implements IRoleDao
* @return 角色列表 * @return 角色列表
*/ */
@Override @Override
public List<String> selectRolesByUserId(Long userId) public List<Role> selectRolesByUserId(Long userId)
{ {
List<String> permsList = null; List<Role> roleList = null;
try try
{ {
permsList = this.findForList("SystemRoleMapper.selectRolesByUserId", userId); roleList = this.findForList("SystemRoleMapper.selectRolesByUserId", userId);
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
return permsList; return roleList;
}
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 角色列表
*/
@Override
public List<Role> selectRolesAll()
{
List<Role> roleList = null;
try
{
roleList = this.findForList("SystemRoleMapper.selectRolesAll");
}
catch (Exception e)
{
e.printStackTrace();
}
return roleList;
} }
} }

View File

@ -26,5 +26,7 @@ public class Role
private String updateBy; private String updateBy;
/** 备注 */ /** 备注 */
private String remark; private String remark;
/** 用户是否存在此角色标识 默认不存在 */
private boolean flag = false;
} }

View File

@ -1,6 +1,8 @@
package com.ruoyi.project.system.role.service; package com.ruoyi.project.system.role.service;
import java.util.List;
import java.util.Set; import java.util.Set;
import com.ruoyi.project.system.role.domain.Role;
/** /**
* 角色业务层 * 角色业务层
@ -16,6 +18,14 @@ public interface IRoleService
* @param userId 用户ID * @param userId 用户ID
* @return 权限列表 * @return 权限列表
*/ */
public Set<String> selectRolesByUserId(Long userId); public Set<String> selectRoleKeys(Long userId);
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 权限列表
*/
public List<Role> selectRolesByUserId(Long userId);
} }

View File

@ -4,10 +4,11 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.system.role.dao.IRoleDao; import com.ruoyi.project.system.role.dao.IRoleDao;
import com.ruoyi.project.system.role.domain.Role;
/** /**
* 角色 业务层处理 * 角色 业务层处理
@ -28,18 +29,42 @@ public class RoleServiceImpl implements IRoleService
* @return 权限列表 * @return 权限列表
*/ */
@Override @Override
public Set<String> selectRolesByUserId(Long userId) public Set<String> selectRoleKeys(Long userId)
{ {
List<String> perms = roleDao.selectRolesByUserId(userId); List<Role> perms = roleDao.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
for (String perm : perms) for (Role perm : perms)
{ {
if (StringUtils.isNotBlank(perm)) if (StringUtils.isNotNull(perms))
{ {
permsSet.addAll(Arrays.asList(perm.trim().split(","))); permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
} }
} }
return permsSet; return permsSet;
} }
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 权限列表
*/
public List<Role> selectRolesByUserId(Long userId)
{
List<Role> userRoles = roleDao.selectRolesByUserId(userId);
List<Role> roles = roleDao.selectRolesAll();
for (Role role : roles)
{
for (Role userRole : userRoles)
{
if (role.getRoleId() == userRole.getRoleId())
{
role.setFlag(true);
break;
}
}
}
return roles;
}
} }

View File

@ -1,17 +1,24 @@
package com.ruoyi.project.system.user.controller; package com.ruoyi.project.system.user.controller;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; 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.controller.BaseController;
import com.ruoyi.framework.web.domain.JSON;
import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.service.IRoleService;
import com.ruoyi.project.system.user.domain.User; import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.service.IUserService; import com.ruoyi.project.system.user.service.IUserService;
@ -30,19 +37,83 @@ public class UserController extends BaseController
@Autowired @Autowired
private IUserService userService; private IUserService userService;
@GetMapping("/getUserlist") @Autowired
private IRoleService roleService;
@RequiresPermissions("system:user:view")
@GetMapping()
public String user()
{
return prefix + "/user";
}
@RequiresPermissions("system:user:view")
@GetMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo queryUserlist() public TableDataInfo list()
{ {
TableDataInfo rows = userService.pageInfoQuery(getPageUtilEntity()); TableDataInfo rows = userService.pageInfoQuery(getPageUtilEntity());
return rows; return rows;
} }
@RequiresPermissions("system:user:list") /**
@GetMapping("/userList") * 修改
public String userList() */
@Log(title = "系统管理", action = "用户管理-修改用户")
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Long userId, Model model)
{ {
return prefix + "/test"; User user = userService.selectUserById(userId);
List<Role> roles = roleService.selectRolesByUserId(userId);
model.addAttribute("roles", roles);
model.addAttribute("user", user);
return prefix + "/edit";
}
@Log(title = "系统管理", action = "用户管理-删除用户")
@RequestMapping("/remove/{userId}")
@ResponseBody
public JSON remove(@PathVariable("userId") Long userId)
{
User user = userService.selectUserById(userId);
if (user == null)
{
return JSON.error("用户不存在");
}
if (userService.deleteUserById(userId) > 0)
{
return JSON.ok();
}
return JSON.error();
}
@Log(title = "系统管理", action = "用户管理-批量删除")
@PostMapping("/batchRemove")
@ResponseBody
public JSON batchRemove(@RequestParam("ids[]") Long[] ids)
{
int rows = userService.batchDeleteUser(ids);
if (rows > 0)
{
return JSON.ok();
}
return JSON.error();
}
/**
* 保存
*/
@Log(title = "系统管理", action = "部门管理-保存部门")
@RequiresPermissions("system:dept:save")
@PostMapping("/save")
@ResponseBody
public JSON save(User user)
{
if (userService.saveUser(user) > 0)
{
return JSON.ok();
}
return JSON.error();
} }
} }

View File

@ -28,4 +28,36 @@ public interface IUserDao
*/ */
public User selectUserByName(String userName); public User selectUserByName(String userName);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public User selectUserById(Long userId);
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
public int deleteUserById(Long userId);
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int batchDeleteUser(Long[] ids);
/**
* 保存用户信息
*
* @param user 用户信息
* @return 结果
*/
public int updateUser(User user);
} }

View File

@ -24,7 +24,7 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
@Override @Override
public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity) public TableDataInfo pageInfoQuery(PageUtilEntity pageUtilEntity)
{ {
return this.findForList("SystemUserMapper.queryUserListByCond", pageUtilEntity); return this.findForList("SystemUserMapper.pageInfoQuery", pageUtilEntity);
} }
/** /**
@ -39,4 +39,50 @@ public class UserDaoImpl extends DynamicObjectBaseDao implements IUserDao
return this.findForObject("SystemUserMapper.selectUserByName", username); return this.findForObject("SystemUserMapper.selectUserByName", username);
} }
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
@Override
public User selectUserById(Long userId)
{
return this.findForObject("SystemUserMapper.selectUserById", userId);
}
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
@Override
public int deleteUserById(Long userId)
{
return this.delete("SystemUserMapper.deleteUserById", userId);
}
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int batchDeleteUser(Long[] ids)
{
return this.delete("SystemUserMapper.batchDeleteUser", ids);
}
/**
* 保存用户信息
*
* @param user 用户信息
* @return 结果
*/
public int updateUser(User user)
{
return this.save("SystemUserMapper.updateUser", user);
}
} }

View File

@ -1,5 +1,7 @@
package com.ruoyi.project.system.user.domain; package com.ruoyi.project.system.user.domain;
import java.util.Date;
import com.ruoyi.project.system.dept.domain.Dept; import com.ruoyi.project.system.dept.domain.Dept;
import lombok.Data; import lombok.Data;
@ -27,12 +29,12 @@ public class User
private String password; private String password;
/** 盐加密 */ /** 盐加密 */
private String salt; private String salt;
/** 帐号状态:0正常,1锁定,2黑名单,3禁止 */ /** 帐号状态:0正常,1禁用 */
private String status; private int status;
/** 拒绝登录描述 */ /** 拒绝登录描述 */
private String refuseDes; private String refuseDes;
/** 创建时间 */ /** 创建时间 */
private String createTime; private Date createTime;
/** 部门对象 */ /** 部门对象 */
private Dept dept; private Dept dept;

View File

@ -27,4 +27,37 @@ public interface IUserService
* @return 用户对象信息 * @return 用户对象信息
*/ */
public User selectUserByName(String userName); public User selectUserByName(String userName);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public User selectUserById(Long userId);
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
public int deleteUserById(Long userId);
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int batchDeleteUser(Long[] ids);
/**
* 保存用户信息
*
* @param user 用户信息
* @return 结果
*/
public int saveUser(User user);
} }

View File

@ -44,4 +44,50 @@ public class UserServiceImpl implements IUserService
return userDao.selectUserByName(userName); return userDao.selectUserByName(userName);
} }
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public User selectUserById(Long userId)
{
return userDao.selectUserById(userId);
}
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
public int deleteUserById(Long userId)
{
return userDao.deleteUserById(userId);
}
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int batchDeleteUser(Long[] ids)
{
return userDao.batchDeleteUser(ids);
}
/**
* 保存用户信息
*
* @param user 用户信息
* @return 结果
*/
public int saveUser(User user)
{
// 删除用户与角色关联
// 新增用户与角色管理
return userDao.updateUser(user);
}
} }

View File

@ -23,13 +23,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="pageInfoQueryLogininfor" parameterType="PageUtilEntity" resultMap="LogininforResult"> <select id="pageInfoQueryLogininfor" parameterType="PageUtilEntity" resultMap="LogininforResult">
select * from sys_logininfor select * from sys_logininfor
<where> <where>
<if test="searchValue != null"> <if test="searchValue != null and searchValue != ''">
AND login_name = #{searchValue} AND login_name = #{searchValue}
</if> </if>
</where> </where>
</select> </select>
<delete id="batchDeleteLogininfor" parameterType="java.lang.String"> <delete id="batchDeleteLogininfor" parameterType="String">
delete from sys_logininfor where info_id in delete from sys_logininfor where info_id in
<foreach collection="array" item="infoId" open="(" separator="," close=")"> <foreach collection="array" item="infoId" open="(" separator="," close=")">
#{infoId} #{infoId}

View File

@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="pageInfoQueryUserOnline" parameterType="PageUtilEntity" resultMap="UserOnlineResult"> <select id="pageInfoQueryUserOnline" parameterType="PageUtilEntity" resultMap="UserOnlineResult">
select * from sys_user_online select * from sys_user_online
<where> <where>
<if test="searchValue != null"> <if test="searchValue != null and searchValue != ''">
AND login_name = #{searchValue} AND login_name = #{searchValue}
</if> </if>
</where> </where>

View File

@ -28,13 +28,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="pageInfoQueryOperLog" parameterType="PageUtilEntity" resultMap="OperLogResult"> <select id="pageInfoQueryOperLog" parameterType="PageUtilEntity" resultMap="OperLogResult">
select * from sys_oper_log select * from sys_oper_log
<where> <where>
<if test="searchValue != null"> <if test="searchValue != null and searchValue != ''">
AND login_name = #{searchValue} AND login_name = #{searchValue}
</if> </if>
</where> </where>
</select> </select>
<delete id="batchDeleteOperLog" parameterType="java.lang.String"> <delete id="batchDeleteOperLog" parameterType="String">
delete from sys_oper_log where oper_id in delete from sys_oper_log where oper_id in
<foreach collection="array" item="operId" open="(" separator="," close=")"> <foreach collection="array" item="operId" open="(" separator="," close=")">
#{operId} #{operId}

View File

@ -15,12 +15,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<select id="selectRolesByUserId" parameterType="Long" resultType="String"> <select id="selectRolesByUserId" parameterType="Long" resultMap="RoleResult">
select distinct r.role_key SELECT r.role_id, r.role_name, r.role_key
from sys_user u FROM sys_user u
left join sys_user_role ur on u.user_id = ur.user_id LEFT JOIN sys_user_role ur ON u.user_id = ur.user_id
left join sys_role r on ur.role_id = r.role_id LEFT JOIN sys_role r ON ur.role_id = r.role_id
where ur.user_id = #{userId} WHERE ur.user_id = #{userId}
</select>
<select id="selectRolesAll" resultMap="RoleResult">
SELECT * FROM sys_role
</select> </select>
</mapper> </mapper>

View File

@ -27,8 +27,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="dept_status" /> <result property="status" column="dept_status" />
</resultMap> </resultMap>
<select id="queryUserListByCond" parameterType="User" resultMap="UserResult"> <select id="pageInfoQuery" parameterType="User" resultMap="UserResult">
select * from sys_user select * from sys_user
<where>
<if test="searchValue != null and searchValue != ''">
AND login_name = #{searchValue}
</if>
</where>
</select> </select>
<select id="selectUserByName" parameterType="String" resultMap="UserResult"> <select id="selectUserByName" parameterType="String" resultMap="UserResult">
@ -37,7 +42,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id left join sys_user_role ur on u.user_id = ur.user_id
where u.login_name = #{username} where u.login_name = #{userName}
</select> </select>
<select id="selectUserById" parameterType="Long" resultMap="UserResult">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.password, u.salt, u.status, u.refuse_des, u.create_time,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
where u.user_id = #{userId}
</select>
<delete id="deleteUserById" parameterType="Long">
delete from sys_user where user_id = #{userId}
</delete>
<delete id="batchDeleteUser" parameterType="String">
delete from sys_user where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
<update id="updateUser" parameterType="User">
update sys_user
<set>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="loginName != null and loginName != ''">login_name = #{loginName},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="email != null and email != ''">email = #{email},</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber = #{phonenumber},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status !=null">status = #{status},</if>
<if test="refuseDes != null and refuseDes != ''">refuse_des = #{refuseDes},</if>
</set>
where 1=1
<if test="userId != null and userId != ''">and user_id = #{userId}</if>
</update>
<insert id="insertUser" parameterType="User">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="loginName != null and loginName != ''">login_name,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="password != null and password != ''">password,</if>
<if test="status !=null and status != ''">status,</if>
<if test="refuseDes != null and refuseDes != ''">refuse_des,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="loginName != null and loginName != ''">#{loginName},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status !=null and status != ''">status,</if>
<if test="refuseDes != null and refuseDes != ''">#{refuseDes},</if>
sysdate()
)
</insert>
</mapper> </mapper>

View File

@ -59,9 +59,19 @@ function refresh() {
$('.bootstrap-table').bootstrapTable('refresh'); $('.bootstrap-table').bootstrapTable('refresh');
} }
// 获取选中数组 // 获取表单选中数组
function getIdSelections(_id) { function getIdSelections(_id) {
return $.map($('.bootstrap-table').bootstrapTable('getSelections'), function (row) { return $.map($('.bootstrap-table').bootstrapTable('getSelections'), function (row) {
return row[_id]; return row[_id];
}); });
} }
// 获取新增或修改选中复选框
function getIsChecked(_name) {
var checkArr = [];
$('input[name="'+_name+'"]:checked').each(function() {
checkArr.push($(this).val());
});
return checkArr;
}

View File

@ -0,0 +1,59 @@
/* iCheck plugin Square skin, green
----------------------------------- */
.icheckbox_square-green,
.iradio_square-green {
display: inline-block;
*display: inline;
vertical-align: middle;
margin: 0;
padding: 0;
width: 22px;
height: 22px;
background: url(green.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_square-green {
background-position: 0 0;
}
.icheckbox_square-green.hover {
background-position: -24px 0;
}
.icheckbox_square-green.checked {
background-position: -48px 0;
}
.icheckbox_square-green.disabled {
background-position: -72px 0;
cursor: default;
}
.icheckbox_square-green.checked.disabled {
background-position: -96px 0;
}
.iradio_square-green {
background-position: -120px 0;
}
.iradio_square-green.hover {
background-position: -144px 0;
}
.iradio_square-green.checked {
background-position: -168px 0;
}
.iradio_square-green.disabled {
background-position: -192px 0;
cursor: default;
}
.iradio_square-green.checked.disabled {
background-position: -216px 0;
}
/* HiDPI support */
@media (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
.icheckbox_square-green,
.iradio_square-green {
background-image: url(green%402x.png);
-webkit-background-size: 240px 24px;
background-size: 240px 24px;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -0,0 +1,11 @@
/*! iCheck v1.0.2 by Damir Sultanov, http://git.io/arlzeA, MIT Licensed */
(function(f){function A(a,b,d){var c=a[0],g=/er/.test(d)?_indeterminate:/bl/.test(d)?n:k,e=d==_update?{checked:c[k],disabled:c[n],indeterminate:"true"==a.attr(_indeterminate)||"false"==a.attr(_determinate)}:c[g];if(/^(ch|di|in)/.test(d)&&!e)x(a,g);else if(/^(un|en|de)/.test(d)&&e)q(a,g);else if(d==_update)for(var f in e)e[f]?x(a,f,!0):q(a,f,!0);else if(!b||"toggle"==d){if(!b)a[_callback]("ifClicked");e?c[_type]!==r&&q(a,g):x(a,g)}}function x(a,b,d){var c=a[0],g=a.parent(),e=b==k,u=b==_indeterminate,
v=b==n,s=u?_determinate:e?y:"enabled",F=l(a,s+t(c[_type])),B=l(a,b+t(c[_type]));if(!0!==c[b]){if(!d&&b==k&&c[_type]==r&&c.name){var w=a.closest("form"),p='input[name="'+c.name+'"]',p=w.length?w.find(p):f(p);p.each(function(){this!==c&&f(this).data(m)&&q(f(this),b)})}u?(c[b]=!0,c[k]&&q(a,k,"force")):(d||(c[b]=!0),e&&c[_indeterminate]&&q(a,_indeterminate,!1));D(a,e,b,d)}c[n]&&l(a,_cursor,!0)&&g.find("."+C).css(_cursor,"default");g[_add](B||l(a,b)||"");g.attr("role")&&!u&&g.attr("aria-"+(v?n:k),"true");
g[_remove](F||l(a,s)||"")}function q(a,b,d){var c=a[0],g=a.parent(),e=b==k,f=b==_indeterminate,m=b==n,s=f?_determinate:e?y:"enabled",q=l(a,s+t(c[_type])),r=l(a,b+t(c[_type]));if(!1!==c[b]){if(f||!d||"force"==d)c[b]=!1;D(a,e,s,d)}!c[n]&&l(a,_cursor,!0)&&g.find("."+C).css(_cursor,"pointer");g[_remove](r||l(a,b)||"");g.attr("role")&&!f&&g.attr("aria-"+(m?n:k),"false");g[_add](q||l(a,s)||"")}function E(a,b){if(a.data(m)){a.parent().html(a.attr("style",a.data(m).s||""));if(b)a[_callback](b);a.off(".i").unwrap();
f(_label+'[for="'+a[0].id+'"]').add(a.closest(_label)).off(".i")}}function l(a,b,f){if(a.data(m))return a.data(m).o[b+(f?"":"Class")]}function t(a){return a.charAt(0).toUpperCase()+a.slice(1)}function D(a,b,f,c){if(!c){if(b)a[_callback]("ifToggled");a[_callback]("ifChanged")[_callback]("if"+t(f))}}var m="iCheck",C=m+"-helper",r="radio",k="checked",y="un"+k,n="disabled";_determinate="determinate";_indeterminate="in"+_determinate;_update="update";_type="type";_click="click";_touch="touchbegin.i touchend.i";
_add="addClass";_remove="removeClass";_callback="trigger";_label="label";_cursor="cursor";_mobile=/ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);f.fn[m]=function(a,b){var d='input[type="checkbox"], input[type="'+r+'"]',c=f(),g=function(a){a.each(function(){var a=f(this);c=a.is(d)?c.add(a):c.add(a.find(d))})};if(/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(a))return a=a.toLowerCase(),g(this),c.each(function(){var c=
f(this);"destroy"==a?E(c,"ifDestroyed"):A(c,!0,a);f.isFunction(b)&&b()});if("object"!=typeof a&&a)return this;var e=f.extend({checkedClass:k,disabledClass:n,indeterminateClass:_indeterminate,labelHover:!0},a),l=e.handle,v=e.hoverClass||"hover",s=e.focusClass||"focus",t=e.activeClass||"active",B=!!e.labelHover,w=e.labelHoverClass||"hover",p=(""+e.increaseArea).replace("%","")|0;if("checkbox"==l||l==r)d='input[type="'+l+'"]';-50>p&&(p=-50);g(this);return c.each(function(){var a=f(this);E(a);var c=this,
b=c.id,g=-p+"%",d=100+2*p+"%",d={position:"absolute",top:g,left:g,display:"block",width:d,height:d,margin:0,padding:0,background:"#fff",border:0,opacity:0},g=_mobile?{position:"absolute",visibility:"hidden"}:p?d:{position:"absolute",opacity:0},l="checkbox"==c[_type]?e.checkboxClass||"icheckbox":e.radioClass||"i"+r,z=f(_label+'[for="'+b+'"]').add(a.closest(_label)),u=!!e.aria,y=m+"-"+Math.random().toString(36).substr(2,6),h='<div class="'+l+'" '+(u?'role="'+c[_type]+'" ':"");u&&z.each(function(){h+=
'aria-labelledby="';this.id?h+=this.id:(this.id=y,h+=y);h+='"'});h=a.wrap(h+"/>")[_callback]("ifCreated").parent().append(e.insert);d=f('<ins class="'+C+'"/>').css(d).appendTo(h);a.data(m,{o:e,s:a.attr("style")}).css(g);e.inheritClass&&h[_add](c.className||"");e.inheritID&&b&&h.attr("id",m+"-"+b);"static"==h.css("position")&&h.css("position","relative");A(a,!0,_update);if(z.length)z.on(_click+".i mouseover.i mouseout.i "+_touch,function(b){var d=b[_type],e=f(this);if(!c[n]){if(d==_click){if(f(b.target).is("a"))return;
A(a,!1,!0)}else B&&(/ut|nd/.test(d)?(h[_remove](v),e[_remove](w)):(h[_add](v),e[_add](w)));if(_mobile)b.stopPropagation();else return!1}});a.on(_click+".i focus.i blur.i keyup.i keydown.i keypress.i",function(b){var d=b[_type];b=b.keyCode;if(d==_click)return!1;if("keydown"==d&&32==b)return c[_type]==r&&c[k]||(c[k]?q(a,k):x(a,k)),!1;if("keyup"==d&&c[_type]==r)!c[k]&&x(a,k);else if(/us|ur/.test(d))h["blur"==d?_remove:_add](s)});d.on(_click+" mousedown mouseup mouseover mouseout "+_touch,function(b){var d=
b[_type],e=/wn|up/.test(d)?t:v;if(!c[n]){if(d==_click)A(a,!1,!0);else{if(/wn|er|in/.test(d))h[_add](e);else h[_remove](e+" "+t);if(z.length&&B&&e==v)z[/ut|nd/.test(d)?_remove:_add](w)}if(_mobile)b.stopPropagation();else return!1}})})}})(window.jQuery||window.Zepto);

View File

@ -63,7 +63,7 @@ $(function() {
// 单条强退 // 单条强退
function forceLogout(id) { function forceLogout(id) {
layer.confirm("确定要强制选中用户下线吗?",{icon: 3, title:'提示'},function(index){ layer.confirm("确定要强制选中用户下线吗?",{icon: 3, title:'提示'},function(index){
_ajax(prefix + "/forceLogout/" + id, { 'id': id }, "post"); _ajax(prefix + "/forceLogout/" + id, , "", "post");
}) })
} }

View File

@ -54,13 +54,13 @@ function loading() {
/*部门管理-新增*/ /*部门管理-新增*/
function add(deptId) { function add(deptId) {
var url = prefix + '/add/' + deptId; var url = prefix + '/add/' + deptId;
layer_show("新增部门管理", url, '800', '500'); layer_show("新增部门", url, '800', '500');
} }
/*部门管理-修改*/ /*部门管理-修改*/
function edit(deptId) { function edit(deptId) {
var url = prefix + '/edit/' + deptId; var url = prefix + '/edit/' + deptId;
layer_show("修改部门管理", url, '800', '400'); layer_show("修改部门", url, '800', '400');
} }
/*部门管理-删除*/ /*部门管理-删除*/

View File

@ -0,0 +1,52 @@
$("#form-user-edit").validate({
rules:{
userName:{
required:true,
},
email:{
required:true,
},
phonenumber:{
required:true,
},
},
submitHandler:function(form){
update();
}
});
function update() {
var userId = $("input[name='userId']").val();
var userName = $("input[name='userName']").val();
var email = $("input[name='email']").val();
var phonenumber = $("input[name='phonenumber']").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
var roleIds = getIsChecked("role");
$.ajax({
cache : true,
type : "POST",
url : "/system/user/save",
data : {
"userId": userId,
"userName": userName,
"email": email,
"phonenumber": phonenumber,
"status": status,
"roleIds": roleIds
},
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

@ -0,0 +1,79 @@
var prefix = "/system/user"
$(function() {
var columns = [{
checkbox: true
},
{
field: 'userId',
title: '用户ID'
},
{
field: 'loginName',
title: '登录名称'
},
{
field: 'userName',
title: '用户名称'
},
{
field: 'email',
title: '邮箱'
},
{
field: 'phonenumber',
title: '手机'
},
{
field: 'status',
title: '状态',
align: 'center',
formatter: function(value, row, index) {
if (value == '0') {
return '<span class="label label-success">正常</span>';
} else if (value == '1') {
return '<span class="label label-danger">禁用</span>';
}
}
},
{
field: 'createTime',
title: '创建时间'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var edit = '<a class="btn btn-primary btn-sm" href="#" title="编辑" mce_href="#" onclick="edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i></a> ';
var del = '<a class="btn btn-warning btn-sm" href="#" title="删除" onclick="remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i></a> ';
return edit + del;
}
}];
var url = prefix + "/list";
initTable(columns, url);
});
/*用户管理-删除*/
function remove(userId) {
layer.confirm("确定要删除选中用户吗?",{icon: 3, title:'提示'},function(index){
_ajax(prefix + "/remove/" + userId, "", "post");
})
}
/*用户管理-修改*/
function edit(deptId) {
var url = prefix + '/edit/' + deptId;
layer_show("修改用户", url, '800', '500');
}
// 批量强退
function batchRemove() {
var rows = getIdSelections("userId");
if (rows.length == 0) {
layer.msg("请选择要删除的数据");
return;
}
layer.confirm("确认要删除选中的" + rows.length + "条数据吗?",{icon: 3, title:'提示'},function(index){
_ajax(prefix + '/batchRemove', { "ids": rows }, "post");
});
}

View File

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

View File

@ -43,7 +43,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="form-control-static col-sm-offset-9"> <div class="form-control-static col-sm-offset-9">
<button class="btn btn-danger" type="submit">关闭</button> <button th:onclick="'javascript:layer_close()'" class="btn btn-danger" type="button">关闭</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link href="/ajax/libs/iCheck/custom.css" rel="stylesheet">
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-edit">
<input name="userId" type="hidden" th:value="${user.userId}" />
<div class="form-group">
<label class="col-sm-3 control-label ">登录名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" readonly="true" th:value="${user.loginName}"/>
</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" readonly="true" name="deptName" id="deptName" th:value="${user.dept.deptName}">
</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="userName" id="userName" th:value="${user.userName}">
</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="email" name="email" th:value="${user.email}">
</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="phonenumber" id="phonenumber" th:value="${user.phonenumber}">
</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="${user.status == 0 ? true : false}" 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">
<div class="checkbox i-checks">
<label th:each="role:${roles}" class="checkbox-inline">
<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}">
</label>
</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 type="text/javascript" src="/ruoyi/system/user/edit.js">
</script>
<script src="/ajax/libs/iCheck/icheck.min.js"></script>
<script>
$(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
</script>
</body>
</html>

View File

@ -1,3 +0,0 @@
<html>
test
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<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:batchRemove()'">
<i class="glyphicon glyphicon-trash"></i>
</button>
</div>
<table class="bootstrap-table" data-mobile-responsive="true"
data-sort-name="create_time" data-sort-order="desc">
</table>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript" src="/ruoyi/system/user/user.js"></script>
</body>
</html>