增加会员系统/会员管理/部门管理

This commit is contained in:
zhujunjieit 2018-12-08 18:37:34 +08:00
parent 101f7a7041
commit 8cad0e868d
26 changed files with 3381 additions and 0 deletions

30
ruoyi-vip/pom.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-vip</artifactId>
<description>
会员管理
</description>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId>
<version>${ruoyi.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,153 @@
package com.ruoyi.vip.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.framework.web.util.ShiroUtils;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.vip.domain.VipDept;
import com.ruoyi.vip.service.IVipDeptService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 部门信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/vip/dept")
public class VipDeptController extends BaseController
{
private String prefix = "vip/dept";
@Autowired
private IVipDeptService deptService;
@RequiresPermissions("vip:dept:view")
@GetMapping()
public String dept()
{
return prefix + "/dept";
}
@RequiresPermissions("vip:dept:list")
@GetMapping("/list")
@ResponseBody
public List<VipDept> list(VipDept dept)
{
List<VipDept> deptList = deptService.selectDeptList(dept);
return deptList;
}
/**
* 新增部门
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(parentId));
return prefix + "/add";
}
/**
* 新增保存部门
*/
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@RequiresPermissions("vip:dept:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(VipDept dept)
{
dept.setCreateBy(ShiroUtils.getLoginName());
return toAjax(deptService.insertDept(dept));
}
/**
* 修改
*/
@GetMapping("/edit/{deptId}")
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
VipDept dept = deptService.selectDeptById(deptId);
if (StringUtils.isNotNull(dept) && 100L == deptId)
{
dept.setParentName("");
}
mmap.put("dept", dept);
return prefix + "/edit";
}
/**
* 保存
*/
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@RequiresPermissions("vip:dept:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(VipDept dept)
{
dept.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(deptService.updateDept(dept));
}
/**
* 删除
*/
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@RequiresPermissions("vip:dept:remove")
@PostMapping("/remove/{deptId}")
@ResponseBody
public AjaxResult remove(@PathVariable("deptId") Long deptId)
{
if (deptService.selectDeptCount(deptId) > 0)
{
return error(1, "存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return error(1, "部门存在用户,不允许删除");
}
return toAjax(deptService.deleteDeptById(deptId));
}
/**
* 校验部门名称
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
public String checkDeptNameUnique(VipDept dept)
{
return deptService.checkDeptNameUnique(dept);
}
/**
* 选择部门树
*/
@GetMapping("/selectDeptTree/{deptId}")
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(deptId));
return prefix + "/tree";
}
/**
* 加载部门列表树
*/
@GetMapping("/treeData")
@ResponseBody
public List<Map<String, Object>> treeData()
{
List<Map<String, Object>> tree = deptService.selectDeptTree();
return tree;
}
}

View File

@ -0,0 +1,167 @@
package com.ruoyi.vip.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ExcelUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.vip.domain.VipUser;
import com.ruoyi.vip.service.IVipUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 用户信息
*
* @author ruoyi
*/
@Controller
@RequestMapping("/vip/user")
public class VipUserController extends BaseController {
private String prefix = "vip/user";
@Autowired
private IVipUserService userService;
@Autowired
private SysPasswordService passwordService;
@RequiresPermissions("vip:user:view")
@GetMapping()
public String user() {
return prefix + "/user";
}
@RequiresPermissions("vip:user:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(VipUser user) {
List<VipUser> list = userService.selectUserList( user );
return getDataTable( list );
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("vip:user:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(VipUser user) {
List<VipUser> list = userService.selectUserList( user );
ExcelUtil<VipUser> util = new ExcelUtil<VipUser>( VipUser.class );
return util.exportExcel( list, "user" );
}
/**
* 新增用户
*/
@GetMapping("/add")
public String add(ModelMap mmap) {
return prefix + "/add";
}
/**
* 新增保存用户
*/
@RequiresPermissions("vip:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult addSave(VipUser user) {
user.setSalt( ShiroUtils.randomSalt() );
user.setPassword( passwordService.encryptPassword( user.getLoginName(), user.getPassword(), user.getSalt() ) );
user.setCreateBy( ShiroUtils.getLoginName() );
return toAjax( userService.insertUser( user ) );
}
/**
* 修改用户
*/
@GetMapping("/edit/{userId}")
public String edit(@PathVariable("userId") Long userId, ModelMap mmap) {
mmap.put( "user", userService.selectUserById( userId ) );
return prefix + "/edit";
}
/**
* 修改保存用户
*/
@RequiresPermissions("vip:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult editSave(VipUser user) {
user.setUpdateBy( ShiroUtils.getLoginName() );
return toAjax( userService.updateUser( user ) );
}
@RequiresPermissions("vip:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@GetMapping("/resetPwd/{userId}")
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap) {
mmap.put( "user", userService.selectUserById( userId ) );
return prefix + "/resetPwd";
}
@RequiresPermissions("vip:user:resetPwd")
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwdSave(VipUser user) {
user.setSalt( ShiroUtils.randomSalt() );
user.setPassword( passwordService.encryptPassword( user.getLoginName(), user.getPassword(), user.getSalt() ) );
return toAjax( userService.resetUserPwd( user ) );
}
@RequiresPermissions("vip:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
try {
return toAjax( userService.deleteUserByIds( ids ) );
} catch (Exception e) {
return error( e.getMessage() );
}
}
/**
* 校验用户名
*/
@PostMapping("/checkLoginNameUnique")
@ResponseBody
public String checkLoginNameUnique(VipUser user) {
return userService.checkLoginNameUnique( user.getLoginName() );
}
/**
* 校验手机号码
*/
@PostMapping("/checkPhoneUnique")
@ResponseBody
public String checkPhoneUnique(VipUser user) {
return userService.checkPhoneUnique( user );
}
/**
* 校验email邮箱
*/
@PostMapping("/checkEmailUnique")
@ResponseBody
public String checkEmailUnique(VipUser user) {
return userService.checkEmailUnique( user );
}
}

View File

@ -0,0 +1,124 @@
package com.ruoyi.vip.domain;
import com.ruoyi.common.base.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
/**
* 部门表 sys_dept
*
* @author ruoyi
*/
public class VipDept extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 部门ID */
@Id
private Long deptId;
/** 父部门ID */
private Long parentId;
/** 祖级列表 */
private String parentIds;
/** 部门名称 */
private String deptName;
/** 显示顺序 */
private String orderNum;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 父部门名称 */
private String parentName;
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public String getParentIds() {
return parentIds;
}
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
public String getDeptName()
{
return deptName;
}
public void setDeptName(String deptName)
{
this.deptName = deptName;
}
public String getOrderNum()
{
return orderNum;
}
public void setOrderNum(String orderNum)
{
this.orderNum = orderNum;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("parentId", getParentId())
.append("ancestors", getParentIds())
.append("deptName", getDeptName())
.append("orderNum", getOrderNum())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,263 @@
package com.ruoyi.vip.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import com.ruoyi.system.domain.SysRole;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
import java.util.Date;
import java.util.List;
/**
* 用户对象 sys_user
*
* @author ruoyi
*/
public class VipUser extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 用户ID */
@Excel(name = "用户序号")
@Id
private Long id;
/** 部门ID */
private Long deptId;
/** 部门父ID */
private Long parentId;
/** 登录名称 */
@Excel(name = "登录名称")
private String loginName;
/** 用户名称 */
@Excel(name = "用户名称")
private String userName;
/** 用户邮箱 */
@Excel(name = "用户邮箱")
private String email;
/** 手机号码 */
@Excel(name = "手机号码")
private String phonenumber;
/** 用户性别 */
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String sex;
/** 用户头像 */
private String avatar;
/** 密码 */
private String password;
/** 盐加密 */
private String salt;
/** 帐号状态0正常 1停用 */
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 最后登陆IP */
@Excel(name = "最后登陆IP")
private String loginIp;
/** 最后登陆时间 */
@Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date loginDate;
/** 部门对象 */
private VipDept dept;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public String getLoginName()
{
return loginName;
}
public void setLoginName(String loginName)
{
this.loginName = loginName;
}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
public String getPhonenumber()
{
return phonenumber;
}
public void setPhonenumber(String phonenumber)
{
this.phonenumber = phonenumber;
}
public String getSex()
{
return sex;
}
public void setSex(String sex)
{
this.sex = sex;
}
public String getAvatar()
{
return avatar;
}
public void setAvatar(String avatar)
{
this.avatar = avatar;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getSalt()
{
return salt;
}
public void setSalt(String salt)
{
this.salt = salt;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getLoginIp()
{
return loginIp;
}
public void setLoginIp(String loginIp)
{
this.loginIp = loginIp;
}
public Date getLoginDate()
{
return loginDate;
}
public void setLoginDate(Date loginDate)
{
this.loginDate = loginDate;
}
public VipDept getDept()
{
return dept;
}
public void setDept(VipDept dept)
{
this.dept = dept;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("userId", getId())
.append("deptId", getDeptId())
.append("loginName", getLoginName())
.append("userName", getUserName())
.append("email", getEmail())
.append("phonenumber", getPhonenumber())
.append("sex", getSex())
.append("avatar", getAvatar())
.append("password", getPassword())
.append("salt", getSalt())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("loginIp", getLoginIp())
.append("loginDate", getLoginDate())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.vip.mapper;
import com.ruoyi.framework.web.base.MyMapper;
import com.ruoyi.vip.domain.VipDept;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 部门管理 数据层
*
* @author ruoyi
*/
public interface VipDeptMapper extends MyMapper<VipDept>
{
/**
* 查询部门人数
*
* @param dept 部门信息
* @return 结果
*/
public int selectDeptCount(VipDept dept);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
public int checkDeptExistUser(Long deptId);
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<VipDept> selectDeptList(VipDept dept);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 新增部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int insertDept(VipDept dept);
/**
* 修改部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int updateDept(VipDept dept);
/**
* 修改子元素关系
*
* @param depts 子元素
* @return 结果
*/
public int updateDeptChildren(@Param("depts") List<VipDept> depts);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public VipDept selectDeptById(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param deptName 部门名称
* @param parentId 父部门ID
* @return 结果
*/
public VipDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
/**
* 根据角色ID查询部门
*
* @param roleId 角色ID
* @return 部门列表
*/
public List<String> selectRoleDeptTree(Long roleId);
}

View File

@ -0,0 +1,110 @@
package com.ruoyi.vip.mapper;
import com.ruoyi.framework.web.base.MyMapper;
import com.ruoyi.vip.domain.VipUser;
import java.util.List;
/**
* 用户表 数据层
*
* @author ruoyi
*/
public interface VipUserMapper extends MyMapper<VipUser>
{
/**
* 根据条件分页查询用户对象
*
* @param sysUser 用户信息
* @return 用户信息集合信息
*/
public List<VipUser> selectUserList(VipUser sysUser);
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
public VipUser selectUserByLoginName(String userName);
/**
* 通过手机号码查询用户
*
* @param phoneNumber 手机号码
* @return 用户对象信息
*/
public VipUser selectUserByPhoneNumber(String phoneNumber);
/**
* 通过邮箱查询用户
*
* @param email 邮箱
* @return 用户对象信息
*/
public VipUser selectUserByEmail(String email);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public VipUser selectUserById(Long userId);
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
public int deleteUserById(Long userId);
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteUserByIds(Long[] ids);
/**
* 修改用户信息
*
* @param user 用户信息
* @return 结果
*/
public int updateUser(VipUser user);
/**
* 新增用户信息
*
* @param user 用户信息
* @return 结果
*/
public int insertUser(VipUser user);
/**
* 校验用户名称是否唯一
*
* @param loginName 登录名称
* @return 结果
*/
public int checkLoginNameUnique(String loginName);
/**
* 校验手机号码是否唯一
*
* @param phonenumber 手机号码
* @return 结果
*/
public VipUser checkPhoneUnique(String phonenumber);
/**
* 校验email是否唯一
*
* @param email 用户邮箱
* @return 结果
*/
public VipUser checkEmailUnique(String email);
}

View File

@ -0,0 +1,89 @@
package com.ruoyi.vip.service;
import com.ruoyi.framework.web.base.AbstractBaseService;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.vip.domain.VipDept;
import java.util.List;
import java.util.Map;
/**
* 部门管理 服务层
*
* @author ruoyi
*/
public interface IVipDeptService extends AbstractBaseService<VipDept>
{
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<VipDept> selectDeptList(VipDept dept);
/**
* 查询部门管理树
*
* @return 所有部门信息
*/
public List<Map<String, Object>> selectDeptTree();
/**
* 查询部门人数
*
* @param parentId 父部门ID
* @return 结果
*/
public int selectDeptCount(Long parentId);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
public boolean checkDeptExistUser(Long deptId);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int insertDept(VipDept dept);
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
public int updateDept(VipDept dept);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
public VipDept selectDeptById(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
public String checkDeptNameUnique(VipDept dept);
}

View File

@ -0,0 +1,128 @@
package com.ruoyi.vip.service;
import com.ruoyi.framework.web.base.AbstractBaseService;
import com.ruoyi.vip.domain.VipUser;
import java.util.List;
/**
* 用户 业务层
*
* @author ruoyi
*/
public interface IVipUserService extends AbstractBaseService<VipUser>
{
/**
* 根据条件分页查询用户对象
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public List<VipUser> selectUserList(VipUser user);
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
public VipUser selectUserByLoginName(String userName);
/**
* 通过手机号码查询用户
*
* @param phoneNumber 手机号码
* @return 用户对象信息
*/
public VipUser selectUserByPhoneNumber(String phoneNumber);
/**
* 通过邮箱查询用户
*
* @param email 邮箱
* @return 用户对象信息
*/
public VipUser selectUserByEmail(String email);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public VipUser selectUserById(Long userId);
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
public int deleteUserById(Long userId);
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
* @throws Exception 异常
*/
public int deleteUserByIds(String ids) throws Exception;
/**
* 保存用户信息
*
* @param user 用户信息
* @return 结果
*/
public int insertUser(VipUser user);
/**
* 保存用户信息
*
* @param user 用户信息
* @return 结果
*/
public int updateUser(VipUser user);
/**
* 修改用户详细信息
*
* @param user 用户信息
* @return 结果
*/
public int updateUserInfo(VipUser user);
/**
* 修改用户密码信息
*
* @param user 用户信息
* @return 结果
*/
public int resetUserPwd(VipUser user);
/**
* 校验用户名称是否唯一
*
* @param loginName 登录名称
* @return 结果
*/
public String checkLoginNameUnique(String loginName);
/**
* 校验手机号码是否唯一
*
* @param user 用户信息
* @return 结果
*/
public String checkPhoneUnique(VipUser user);
/**
* 校验email是否唯一
*
* @param user 用户信息
* @return 结果
*/
public String checkEmailUnique(VipUser user);
}

View File

@ -0,0 +1,193 @@
package com.ruoyi.vip.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.vip.domain.VipDept;
import com.ruoyi.vip.mapper.VipDeptMapper;
import com.ruoyi.vip.service.IVipDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 部门管理 服务实现
*
* @author ruoyi
*/
@Service
public class VipDeptServiceImpl extends AbstractBaseServiceImpl<VipDeptMapper, VipDept> implements IVipDeptService {
@Autowired
private VipDeptMapper deptMapper;
/**
* 查询部门管理数据
*
* @return 部门信息集合
*/
@Override
@DataScope(tableAlias = "d")
public List<VipDept> selectDeptList(VipDept dept) {
return mapper.selectDeptList( dept );
}
/**
* 查询部门管理树
*
* @return 所有部门信息
*/
@Override
public List<Map<String, Object>> selectDeptTree() {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
List<VipDept> deptList = selectDeptList( new VipDept() );
trees = getTrees( deptList, false, null );
return trees;
}
/**
* 对象转部门树
*
* @param deptList 部门列表
* @param isCheck 是否需要选中
* @param roleDeptList 角色已存在菜单列表
* @return
*/
public List<Map<String, Object>> getTrees(List<VipDept> deptList, boolean isCheck, List<String> roleDeptList) {
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
for (VipDept dept : deptList) {
if (UserConstants.DEPT_NORMAL.equals( dept.getDelFlag() )) {
Map<String, Object> deptMap = new HashMap<String, Object>();
deptMap.put( "id", dept.getDeptId() );
deptMap.put( "pId", dept.getParentId() );
deptMap.put( "name", dept.getDeptName() );
deptMap.put( "title", dept.getDeptName() );
if (isCheck) {
deptMap.put( "checked", roleDeptList.contains( dept.getDeptId() + dept.getDeptName() ) );
} else {
deptMap.put( "checked", false );
}
trees.add( deptMap );
}
}
return trees;
}
/**
* 查询部门人数
*
* @param parentId 部门ID
* @return 结果
*/
@Override
public int selectDeptCount(Long parentId) {
VipDept dept = new VipDept();
dept.setParentId( parentId );
return deptMapper.selectDeptCount( dept );
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId) {
int result = deptMapper.checkDeptExistUser( deptId );
return result > 0 ? true : false;
}
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public int deleteDeptById(Long deptId) {
return deptMapper.deleteDeptById( deptId );
}
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int insertDept(VipDept dept) {
VipDept info = deptMapper.selectDeptById( dept.getParentId() );
dept.setParentIds( info.getParentIds() + "," + dept.getParentId() );
return deptMapper.insertDept( dept );
}
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int updateDept(VipDept dept) {
VipDept info = deptMapper.selectDeptById( dept.getParentId() );
if (StringUtils.isNotNull( info )) {
String ancestors = info.getParentIds() + "," + dept.getParentId();
dept.setParentIds( ancestors );
updateDeptChildren( dept.getDeptId(), ancestors );
}
return deptMapper.updateDept( dept );
}
/**
* 修改子元素关系
*
* @param deptId 部门ID
* @param ancestors 元素列表
*/
public void updateDeptChildren(Long deptId, String ancestors) {
VipDept dept = new VipDept();
dept.setParentId( deptId );
List<VipDept> childrens = deptMapper.selectDeptList( dept );
for (VipDept children : childrens) {
children.setParentIds( ancestors + "," + dept.getParentId() );
}
if (childrens.size() > 0) {
deptMapper.updateDeptChildren( childrens );
}
}
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
@Override
public VipDept selectDeptById(Long deptId) {
return deptMapper.selectDeptById( deptId );
}
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
@Override
public String checkDeptNameUnique(VipDept dept) {
Long deptId = StringUtils.isNull( dept.getDeptId() ) ? -1L : dept.getDeptId();
VipDept info = deptMapper.checkDeptNameUnique( dept.getDeptName(), dept.getParentId() );
if (StringUtils.isNotNull( info ) && info.getDeptId().longValue() != deptId.longValue()) {
return UserConstants.DEPT_NAME_NOT_UNIQUE;
}
return UserConstants.DEPT_NAME_UNIQUE;
}
}

View File

@ -0,0 +1,223 @@
package com.ruoyi.vip.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.vip.domain.VipUser;
import com.ruoyi.vip.mapper.VipUserMapper;
import com.ruoyi.vip.service.IVipUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 用户 业务层处理
*
* @author ruoyi
*/
@Service
public class VipUserServiceImpl extends AbstractBaseServiceImpl<VipUserMapper, VipUser> implements IVipUserService {
@Autowired
private VipUserMapper userMapper;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysPostMapper postMapper;
@Autowired
private SysUserPostMapper userPostMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
/**
* 根据条件分页查询用户对象
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
@DataScope(tableAlias = "u")
public List<VipUser> selectUserList(VipUser user) {
startPage();
return userMapper.selectUserList( user );
}
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
@Override
public VipUser selectUserByLoginName(String userName) {
return userMapper.selectUserByLoginName( userName );
}
/**
* 通过手机号码查询用户
*
* @param phoneNumber 手机号码
* @return 用户对象信息
*/
@Override
public VipUser selectUserByPhoneNumber(String phoneNumber) {
return userMapper.selectUserByPhoneNumber( phoneNumber );
}
/**
* 通过邮箱查询用户
*
* @param email 邮箱
* @return 用户对象信息
*/
@Override
public VipUser selectUserByEmail(String email) {
return userMapper.selectUserByEmail( email );
}
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
@Override
public VipUser selectUserById(Long userId) {
return userMapper.selectUserById( userId );
}
/**
* 通过用户ID删除用户
*
* @param userId 用户ID
* @return 结果
*/
@Override
public int deleteUserById(Long userId) {
// 删除用户与角色关联
userRoleMapper.deleteUserRoleByUserId( userId );
// 删除用户与岗位表
userPostMapper.deleteUserPostByUserId( userId );
return userMapper.deleteUserById( userId );
}
/**
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int deleteUserByIds(String ids) throws Exception {
Long[] userIds = Convert.toLongArray( ids );
return userMapper.deleteUserByIds( userIds );
}
/**
* 新增保存用户信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public int insertUser(VipUser user) {
// 新增用户信息
int rows = userMapper.insertUser( user );
return rows;
}
/**
* 修改保存用户信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public int updateUser(VipUser user) {
Long userId = user.getId();
return userMapper.updateUser( user );
}
/**
* 修改用户个人详细信息
*
* @param user 用户信息
* @return 结果
*/
@Override
public int updateUserInfo(VipUser user) {
return userMapper.updateUser( user );
}
/**
* 修改用户密码
*
* @param user 用户信息
* @return 结果
*/
@Override
public int resetUserPwd(VipUser user) {
return updateUserInfo( user );
}
/**
* 校验用户名称是否唯一
*
* @param loginName 用户名
* @return
*/
@Override
public String checkLoginNameUnique(String loginName) {
int count = userMapper.checkLoginNameUnique( loginName );
if (count > 0) {
return UserConstants.USER_NAME_NOT_UNIQUE;
}
return UserConstants.USER_NAME_UNIQUE;
}
/**
* 校验用户名称是否唯一
*
* @param user 用户信息
* @return
*/
@Override
public String checkPhoneUnique(VipUser user) {
Long userId = StringUtils.isNull( user.getId() ) ? -1L : user.getId();
VipUser info = userMapper.checkPhoneUnique( user.getPhonenumber() );
if (StringUtils.isNotNull( info ) && info.getId().longValue() != userId.longValue()) {
return UserConstants.USER_PHONE_NOT_UNIQUE;
}
return UserConstants.USER_PHONE_UNIQUE;
}
/**
* 校验email是否唯一
*
* @param user 用户信息
* @return
*/
@Override
public String checkEmailUnique(VipUser user) {
Long userId = StringUtils.isNull( user.getId() ) ? -1L : user.getId();
VipUser info = userMapper.checkEmailUnique( user.getEmail() );
if (StringUtils.isNotNull( info ) && info.getId().longValue() != userId.longValue()) {
return UserConstants.USER_EMAIL_NOT_UNIQUE;
}
return UserConstants.USER_EMAIL_UNIQUE;
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="cacheEnabled" value="true" /> <!-- 全局映射器启用缓存 -->
<setting name="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 -->
<setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 -->
<setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
</settings>
</configuration>

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.vip.mapper.VipDeptMapper">
<resultMap type="VipDept" id="VipDeptResult">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="parentIds" column="parent_ids" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="delFlag" column="del_flag" />
<result property="parentName" column="parent_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.parent_ids, d.dept_name, d.order_num, d.del_flag, d.create_by, d.create_time
from vip_dept d
</sql>
<select id="selectRoleDeptTree" parameterType="Long" resultType="String">
select concat(d.dept_id, d.dept_name) as dept_name
from vip_dept d
left join sys_role_dept rd on d.dept_id = rd.dept_id
where d.del_flag = '0' and rd.role_id = #{roleId}
order by d.parent_id, d.order_num
</select>
<select id="selectDeptList" parameterType="VipDept" resultMap="VipDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select>
<select id="selectDeptCount" parameterType="VipDept" resultType="int">
select count(1) from vip_dept
where del_flag = '0'
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>
</select>
<select id="checkDeptNameUnique" resultMap="VipDeptResult">
<include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId}
</select>
<select id="selectDeptById" parameterType="Long" resultMap="VipDeptResult">
select d.dept_id, d.parent_id, d.parent_ids, d.dept_name, d.order_num,
(select dept_name from vip_dept where dept_id = d.parent_id) parent_name
from vip_dept d
where d.dept_id = #{deptId}
</select>
<insert id="insertDept" parameterType="VipDept">
insert into vip_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="parentIds != null and parentIds != ''">parent_ids,</if>
<if test="orderNum != null and orderNum != ''">order_num,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)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="parentIds != null and parentIds != ''">#{parentIds},</if>
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDept" parameterType="VipDept">
update vip_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="parentIds != null and parentIds != ''">parent_ids = #{parentIds},</if>
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
<update id="updateDeptChildren" parameterType="java.util.List">
update vip_dept set parent_ids =
<foreach collection="depts" item="item" index="index"
separator=" " open="case dept_id" close="end">
when #{item.deptId} then #{item.parent_ids}
</foreach>
where dept_id in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{item.deptId}
</foreach>
</update>
<delete id="deleteDeptById" parameterType="Long">
update vip_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
</mapper>

View File

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.vip.mapper.VipUserMapper">
<resultMap type="VipUser" id="VipUserResult">
<id property="id" column="id" />
<result property="deptId" column="dept_id" />
<result property="loginName" column="login_name" />
<result property="userName" column="user_name" />
<result property="email" column="email" />
<result property="phonenumber" column="phonenumber" />
<result property="sex" column="sex" />
<result property="avatar" column="avatar" />
<result property="password" column="password" />
<result property="salt" column="salt" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="loginIp" column="login_ip" />
<result property="loginDate" column="login_date" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="dept" column="dept_id" javaType="VipDept" resultMap="deptResult" />
</resultMap>
<resultMap id="deptResult" type="VipDept">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="status" column="dept_status" />
</resultMap>
<sql id="selectUserVo">
select u.id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_time, u.remark,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from vip_user u
left join sys_dept d on u.dept_id = d.dept_id
</sql>
<select id="selectUserList" parameterType="VipUser" resultMap="VipUserResult">
select u.id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.password, u.sex, u.avatar, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name from vip_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="loginName != null and loginName != ''">
AND u.login_name like concat('%', #{loginName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) ))
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUserByLoginName" parameterType="String" resultMap="VipUserResult">
<include refid="selectUserVo"/>
where u.login_name = #{userName}
</select>
<select id="selectUserByPhoneNumber" parameterType="String" resultMap="VipUserResult">
<include refid="selectUserVo"/>
where u.phonenumber = #{phonenumber}
</select>
<select id="selectUserByEmail" parameterType="String" resultMap="VipUserResult">
<include refid="selectUserVo"/>
where u.email = #{email}
</select>
<select id="checkLoginNameUnique" parameterType="String" resultType="int">
select count(1) from vip_user where login_name=#{loginName}
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="VipUserResult">
select id, phonenumber from vip_user where phonenumber=#{phonenumber}
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="VipUserResult">
select id, email from vip_user where email=#{email}
</select>
<select id="selectUserById" parameterType="Long" resultMap="VipUserResult">
<include refid="selectUserVo"/>
where u.id = #{id}
</select>
<delete id="deleteUserById" parameterType="Long">
delete from vip_user where id = #{id}
</delete>
<delete id="deleteUserByIds" parameterType="Long">
update vip_user set del_flag = '2' where id in
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="updateUser" parameterType="VipUser">
update vip_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="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="salt != null and salt != ''">salt = #{salt},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
<if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
update_time = sysdate()
</set>
where id = #{id}
</update>
<insert id="insertUser" parameterType="VipUser" useGeneratedKeys="true" keyProperty="id">
insert into vip_user(
<if test="id != null and id != 0">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="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="salt != null and salt != ''">salt,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="id != null and id != ''">#{id},</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="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="salt != null and salt != ''">#{salt},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
</mapper>

View File

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-add">
<input id="treeId" name="parentId" type="hidden" th:value="${dept.deptId}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级部门:</label>
<div class="col-sm-8">
<input class="form-control" type="text" onclick="selectDeptTree()" id="treeName" readonly="true" th:value="${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="deptName" id="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="orderNum">
</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="leader">
</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="phone">
</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">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.isDefault == 'Y' ? true : false}">
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "vip/dept";
$("#form-dept-add").validate({
rules:{
deptName:{
required:true,
remote: {
url: prefix + "/checkDeptNameUnique",
type: "post",
dataType: "json",
data: {
"parentId": function() {
return $("input[name='parentId']").val();
},
"deptName" : function() {
return $.common.trim($("#deptName").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
orderNum:{
required:true,
digits:true
},
email:{
email:true,
},
phone:{
isPhone:true,
},
},
messages: {
"deptName": {
remote: "部门已经存在"
}
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-dept-add').serialize());
}
}
/*部门管理-新增-选择父部门树*/
function selectDeptTree() {
var options = {
title: '部门选择',
width: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
</script>
</body>
</html>

View File

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html lang="zh" 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="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="dept-form">
<div class="select-list">
<ul>
<li>
部门名称:<input type="text" name="deptName"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="vip:dept:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary" onclick="$.operate.editTree()" shiro:hasPermission="vip:dept:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-info" id="expandAllBtn">
<i class="fa fa-exchange"></i> 展开/折叠
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
var addFlag = [[${@permission.hasPermi('vip:dept:add')}]];
var editFlag = [[${@permission.hasPermi('vip:dept:edit')}]];
var removeFlag = [[${@permission.hasPermi('vip:dept:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "vip/dept"
$(function() {
var options = {
code: "deptId",
parentCode: "parentId",
uniqueId: "deptId",
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove/{id}",
modalName: "部门",
columns: [{
field: 'selectItem',
radio: true
},
{
field: 'deptName',
title: '部门名称',
align: "left"
},
{
field: 'orderNum',
title: '排序',
align: "left"
},
{
field: 'createTime',
title: '创建时间',
align: "left"
},
{
title: '操作',
align: 'left',
formatter: function(value, row, index) {
if (row.parentId != 0) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.deptId + '\')"><i class="fa fa-edit">编辑</i></a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="#" onclick="$.operate.add(\'' + row.deptId + '\')"><i class="fa fa-plus">新增</i></a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="remove(\'' + row.deptId + '\')"><i class="fa fa-remove">删除</i></a>');
return actions.join('');
} else {
return "";
}
}
}]
};
$.treeTable.init(options);
});
function remove(id) {
$.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗?", function() {
$.ajax({
type : 'post',
url: prefix + "/remove/" + id,
success : function(result) {
if (result.code == web_status.SUCCESS) {
$.modal.msgSuccess(result.msg);
$.treeTable.refresh();
} else {
$.modal.msgError(result.msg);
}
}
});
});
}
</script>
</body>
</html>

View File

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
<input name="deptId" type="hidden" th:field="*{deptId}" />
<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级部门:</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="treeName" onclick="selectDeptTree()" readonly="true" th:field="*{parentName}"/>
</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="deptName" th:field="*{deptName}" id="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="orderNum" th:field="*{orderNum}">
</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="leader" th:field="*{leader}">
</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="phone" th:field="*{phone}">
</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" th:field="*{email}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">部门状态:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "vip/dept";
$("#form-dept-edit").validate({
rules:{
deptName:{
required:true,
remote: {
url: prefix + "/checkDeptNameUnique",
type: "post",
dataType: "json",
data: {
"deptId": function() {
return $("#deptId").val();
},
"parentId": function() {
return $("input[name='parentId']").val();
},
"deptName": function() {
return $.common.trim($("#deptName").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
orderNum:{
required:true,
digits:true
},
email:{
email:true,
},
phone:{
isPhone:true,
},
},
messages: {
"deptName": {
remote: "部门已经存在"
}
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-dept-edit').serialize());
}
}
/*部门管理-修改-选择部门树*/
function selectDeptTree() {
var deptId = $("#treeId").val();
if(deptId > 0) {
var options = {
title: '部门选择',
width: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(),
callBack: doSubmit
};
$.modal.openOptions(options);
} else {
$.modal.alertError("父部门不能选择");
}
}
function doSubmit(index, layero){
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
</script>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<style>
body{height:auto;font-family: "Microsoft YaHei";}
button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
</style>
<body class="hold-transition box box-main">
<input id="treeId" name="treeId" type="hidden" th:value="${dept.deptId}"/>
<input id="treeName" name="treeName" type="hidden" th:value="${dept.deptName}"/>
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
<label id="btnShow" title="显示搜索" style="display:none;"></label>
<label id="btnHide" title="隐藏搜索"></label>
</div>
<div class="treeSearchInput" id="search">
<label for="keyword">关键字:</label><input type="text" class="empty" id="keyword" maxlength="50">
<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
</div>
<div class="treeExpandCollapse">
<a href="#" onclick="$.tree.expand()">展开</a> /
<a href="#" onclick="$.tree.collapse()">折叠</a>
</div>
<div id="tree" class="ztree treeselect"></div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
$(function() {
var url = ctx + "vip/dept/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
});
function zOnClick(event, treeId, treeNode) {
var treeId = treeNode.id;
var treeName = treeNode.name;
$("#treeId").val(treeId);
$("#treeName").val(treeName);
}
</script>
</body>
</html>

View File

@ -0,0 +1,236 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-add">
<input name="deptId" type="hidden" id="treeId"/>
<div class="form-group">
<label class="col-sm-3 control-label ">登录名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="loginName" name="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" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName">
</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">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">密码:</label>
<div class="col-sm-8">
<input class="form-control" type="password" name="password" id="password" th:value="${@config.getKey('sys.user.initPassword')}">
</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" id="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">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">性别:</label>
<div class="col-sm-8">
<select id="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</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">
<select id="post" name="post" class="form-control select2-hidden-accessible" multiple="">
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:disabled="${post.status == '1'}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script>
$("#form-user-add").validate({
rules:{
loginName:{
required:true,
minlength: 2,
maxlength: 20,
remote: {
url: ctx + "vip/user/checkLoginNameUnique",
type: "post",
dataType: "json",
data: {
name : function() {
return $.common.trim($("#loginName").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
userName:{
required:true,
},
deptName:{
required:true,
},
password:{
required:true,
minlength: 5,
maxlength: 20
},
email:{
required:true,
email:true,
remote: {
url: ctx + "vip/user/checkEmailUnique",
type: "post",
dataType: "json",
data: {
name: function () {
return $.common.trim($("#email").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},
phonenumber:{
required:true,
isPhone:true,
remote: {
url: ctx + "vip/user/checkPhoneUnique",
type: "post",
dataType: "json",
data: {
name: function () {
return $.common.trim($("#phonenumber").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},
},
messages: {
"loginName": {
remote: "用户已经存在"
},
"email": {
remote: "Email已经存在"
},
"phonenumber":{
remote: "手机号码已经存在"
}
}
});
function submitHandler() {
if ($.validate.form()) {
add();
}
}
function add() {
var userId = $("input[name='userId']").val();
var deptId = $("input[name='deptId']").val();
var loginName = $("input[name='loginName']").val();
var userName = $("input[name='userName']").val();
var password = $("input[name='password']").val();
var email = $("input[name='email']").val();
var phonenumber = $("input[name='phonenumber']").val();
var sex = $("#sex option:selected").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
var roleIds = $.form.selectCheckeds("role");
var postIds = $.form.selectSelects("post");
$.ajax({
cache : true,
type : "POST",
url : ctx + "vip/user/add",
data : {
"userId": userId,
"deptId": deptId,
"loginName": loginName,
"userName": userName,
"password": password,
"email": email,
"phonenumber": phonenumber,
"sex": sex,
"status": status,
"roleIds": roleIds,
"postIds": postIds
},
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
$.operate.successCallback(data);
}
});
}
/*用户管理-新增-选择部门树*/
function selectDeptTree() {
var treeId = $("#treeId").val();
var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
var url = ctx + "vip/dept/selectDeptTree/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: ctx + "vip/dept/selectDeptTree/" + deptId,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
if ($.tree.notAllowParents(tree)) {
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,209 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-edit" th:object="${user}">
<input name="userId" type="hidden" th:field="*{userId}" />
<input name="deptId" type="hidden" th:field="*{deptId}" id="treeId"/>
<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:field="*{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" name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName" th:field="*{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:field="*{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" id="email" th:field="*{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:field="*{phonenumber}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">性别:</label>
<div class="col-sm-8">
<select id="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>
</select>
</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">
<select id="post" name="post" class="form-control select2-hidden-accessible" multiple="">
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">角色:</label>
<div class="col-sm-8">
<label th:each="role:${roles}" class="check-box">
<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.status == '1'}">
</label>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script>
$("#form-user-edit").validate({
rules:{
userName:{
required:true,
},
deptName:{
required:true,
},
email:{
required:true,
email:true,
remote: {
url: ctx + "vip/user/checkEmailUnique",
type: "post",
dataType: "json",
data: {
"userId": function() {
return $("#userId").val();
},
"email": function() {
return $.common.trim($("#email").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},
phonenumber:{
required:true,
isPhone:true,
remote: {
url: ctx + "vip/user/checkPhoneUnique",
type: "post",
dataType: "json",
data: {
"userId": function() {
return $("#userId").val();
},
"phonenumber": function() {
return $.common.trim($("#phonenumber").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},
},
messages: {
"email": {
remote: "Email已经存在"
},
"phonenumber":{
remote: "手机号码已经存在"
}
},
submitHandler:function(form){
edit();
}
});
function submitHandler() {
if ($.validate.form()) {
edit();
}
}
function edit() {
var userId = $("input[name='userId']").val();
var deptId = $("input[name='deptId']").val();
var userName = $("input[name='userName']").val();
var email = $("input[name='email']").val();
var phonenumber = $("input[name='phonenumber']").val();
var sex = $("#sex option:selected").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
var roleIds = $.form.selectCheckeds("role");
var postIds = $.form.selectSelects("post");
$.ajax({
cache : true,
type : "POST",
url : ctx + "vip/user/edit",
data : {
"userId": userId,
"deptId": deptId,
"userName": userName,
"email": email,
"phonenumber": phonenumber,
"sex": sex,
"status": status,
"roleIds": roleIds,
"postIds": postIds
},
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
$.operate.successCallback(data);
}
});
}
/*用户管理-修改-选择部门树*/
function selectDeptTree() {
var deptId = $("#treeId").val();
var url = ctx + "vip/dept/selectDeptTree/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
if ($.tree.notAllowParents(tree)) {
var body = layer.getChildFrame('body', index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
layer.close(index);
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<title>用户头像修改</title>
<link th:href="@{/ajax/libs/cropbox/cropbox.css}" rel="stylesheet"/>
<body class="white-bg">
<input name="userId" id="userId" type="hidden" th:value="${user.userId}" />
<div class="container">
<div class="imageBox">
<div class="thumbBox"></div>
<div class="spinner" style="display: none">Loading...</div>
</div>
<div class="action">
<div class="new-contentarea tc">
<a href="javascript:void(0)" class="upload-img"> <label for="avatar">上传图像</label> </a>
<input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
</div>
<input type="button" id="btnCrop" class="Btnsty_peyton" value="裁切" />
<input type="button" id="btnZoomIn" class="Btnsty_peyton" value="+" />
<input type="button" id="btnZoomOut" class="Btnsty_peyton" value="-" />
</div>
<div class="cropped"></div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/cropbox/cropbox.js}"></script>
<script type="text/javascript">
var cropper;
$(window).load(function() {
var avatar = '[[${user.avatar}]]';
var options = {
thumbBox: '.thumbBox',
spinner: '.spinner',
imgSrc: $.common.isEmpty(avatar) ? ctx + 'img/profile.jpg' : ctx + 'profile/avatar/' + avatar
}
cropper = $('.imageBox').cropbox(options);
$('#avatar').on('change', function() {
var reader = new FileReader();
reader.onload = function(e) {
options.imgSrc = e.target.result;
//根据MIME判断上传的文件是不是图片类型
if((options.imgSrc).indexOf("image/")==-1){
parent.layer.alert("文件格式错误,请上传图片类型,如JPG,JEPGPNG后缀的文件。", {icon: 2,title:"系统提示"});
} else {
cropper = $('.imageBox').cropbox(options);
}
}
reader.readAsDataURL(this.files[0]);
})
$('#btnCrop').on('click', function(){
var img = cropper.getDataURL();
$('.cropped').html('');
$('.cropped').append('<img src="'+img+'" align="absmiddle" style="width:64px;margin-top:4px;border-radius:64px;box-shadow:0px 0px 12px #7E7E7E;" ><p>64px*64px</p>');
$('.cropped').append('<img src="'+img+'" align="absmiddle" style="width:128px;margin-top:4px;border-radius:128px;box-shadow:0px 0px 12px #7E7E7E;"><p>128px*128px</p>');
$('.cropped').append('<img src="'+img+'" align="absmiddle" style="width:180px;margin-top:4px;border-radius:180px;box-shadow:0px 0px 12px #7E7E7E;"><p>180px*180px</p>');
})
$('#btnZoomIn').on('click', function(){
cropper.zoomIn();
})
$('#btnZoomOut').on('click', function(){
cropper.zoomOut();
})
});
function submitHandler() {
var img = cropper.getBlob();
var formdata = new FormData();
formdata.append("avatarfile", img);
formdata.append("userId", $("#userId").val());
$.ajax({
url: ctx + "vip/user/profile/updateAvatar",
data: formdata,
type: "post",
processData: false,
contentType: false,
success: function(result) {
$.operate.saveSuccess(result);
}
})
}
</script>
</body>
</html>

View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-edit" th:object="${user}">
<input name="userId" type="hidden" th:field="*{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:field="*{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" th:field="*{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:field="*{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" th:field="*{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:field="*{phonenumber}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">性别:</label>
<div class="col-sm-8">
<div class="radio-box">
<input type="radio" id="radio1" th:field="*{sex}" name="sex" value="0">
<label for="radio1"></label>
</div>
<div class="radio-box">
<input type="radio" id="radio2" th:field="*{sex}" name="sex" value="1">
<label for="radio2"></label>
</div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script>
$("#form-user-edit").validate({
rules:{
userName:{
required:true,
},
email:{
required:true,
email:true,
remote: {
url: ctx + "vip/user/checkEmailUnique",
type: "post",
dataType: "json",
data: {
"userId": function() {
return $("#userId").val();
},
"email": function() {
return $.common.trim($("#email").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},
phonenumber:{
required:true,
isPhone:true,
remote: {
url: ctx + "vip/user/checkPhoneUnique",
type: "post",
dataType: "json",
data: {
"userId": function() {
return $("#userId").val();
},
"phonenumber": function() {
return $.common.trim($("#phonenumber").val());
}
},
dataFilter: function (data, type) {
return $.validate.unique(data);
}
}
},
},
messages: {
"email": {
remote: "Email已经存在"
},
"phonenumber":{
remote: "手机号码已经存在"
}
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(ctx + "vip/user/profile/update", $('#form-user-edit').serialize());
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--360浏览器优先以webkit内核解析-->
<title>个人信息</title>
<link rel="shortcut icon" href="favicon.ico">
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
<link th:href="@{/css/main/animate.min.css}" rel="stylesheet"/>
<link th:href="@{/css/main/style.min862f.css}" rel="stylesheet"/>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
<div class="row animated fadeInRight">
<div class="col-sm-6">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>个人信息</h5>
<div class="ibox-tools">
<a class="dropdown-toggle" data-toggle="dropdown" href="profile.html#">
<i class="fa fa-edit"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="javascript:edit()">修改信息</a></li>
<li><a href="javascript:resetPwd()">修改密码</a></li>
<li><a href="javascript:avatar()">修改头像</a></li>
</ul>
</div>
</div>
<div class="contact-box">
<div class="col-sm-4">
<div class="text-center">
<img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{/profile/avatar/} + ${user.avatar}">
<div class="m-t-xs font-bold">[[${user.loginIp}]]</div>
</div>
</div>
<div class="col-sm-8">
<h3><strong>[[${user.loginName}]]</strong></h3>
<p><i class="fa fa-user"></i> [[${user.userName}]] / [[${#strings.defaultString(roleGroup,'无角色')}]]
<p><i class="fa fa-phone"></i> [[${user.phonenumber}]]</p>
<p><i class="fa fa-group"></i> [[${user.dept?.deptName}]] / [[${#strings.defaultString(postGroup,'无岗位')}]]</p>
<p><i class="fa fa-transgender"></i> 性别:[[${user.sex}]]</p>
<p><i class="fa fa-envelope-o"></i> [[${user.email}]]</p>
<p><i class="fa fa-calendar"></i> [[${#dates.format(user.createTime, 'yyyy-MM-dd HH:mm:ss')}]]</p>
</div>
<div class="clearfix"></div>
</a>
</div>
</div>
</div>
</div>
</div>
<div th:include="include::footer"></div>
<script>
var userId = [[${user.userId}]];
/*用户信息-修改*/
function edit() {
var url = ctx + "vip/user/profile/edit/" + userId;
$.modal.open("修改用户", url);
}
/*用户管理-重置密码*/
function resetPwd() {
var url = ctx + 'vip/user/profile/resetPwd/' + userId;
$.modal.open("重置密码", url, '800', '500');
}
/*用户管理-头像*/
function avatar() {
var url = ctx + 'vip/user/profile/avatar/' + userId;
$.modal.open("修改头像", url);
}
</script>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-resetPwd">
<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" name="loginName" 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="password" name="oldPassword" id="oldPassword">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">新密码:</label>
<div class="col-sm-8">
<input class="form-control" type="password" name="password" id="password">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">再次确认:</label>
<div class="col-sm-8">
<input class="form-control" type="password" name="confirm" id="confirm">
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
</div>
</div>
</form>
</div>
<div th:include="include :: footer"></div>
<script>
$("#form-user-resetPwd").validate({
rules:{
oldPassword:{
required:true,
remote: {
url: ctx + "vip/user/profile/checkPassword",
type: "get",
dataType: "json",
data: {
password: function() {
return $("input[name='oldPassword']").val();
}
}
}
},
password: {
required: true,
minlength: 5,
maxlength: 20
},
confirm: {
required: true,
equalTo: "#password"
}
},
messages: {
oldPassword: {
required: "请输入原密码",
remote: "原密码错误"
},
password: {
required: "请输入新密码",
minlength: "密码不能小于6个字符",
maxlength: "密码不能大于20个字符"
},
confirm: {
required: "请再次输入新密码",
equalTo: "两次密码输入不一致"
}
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(ctx + "vip/user/profile/resetPwd", $('#form-user-resetPwd').serialize());
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-user-resetPwd">
<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" name="loginName" 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="password" name="password" id="password" th:value="${@config.getKey('sys.user.initPassword')}">
</div>
</div>
</form>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript">
$("#form-user-resetPwd").validate({
rules:{
password:{
required:true,
minlength: 5,
maxlength: 20
},
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(ctx + "vip/user/resetPwd", $('#form-user-resetPwd').serialize());
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<body class="gray-bg">
<div class="ui-layout-west">
<div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 组织机构
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
</div>
<div class="container-div ui-layout-center">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="user-form">
<input type="hidden" id="deptId" name="deptId">
<input type="hidden" id="parentId" name="parentId">
<div class="select-list">
<ul>
<li>
登录名称:<input type="text" name="loginName"/>
</li>
<li>
手机号码:<input type="text" name="phonenumber"/>
</li>
<li>
用户状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li class="select-time">
<label>创建时间: </label>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
<span>-</span>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="vip:user:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="vip:user:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="vip:user:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="vip:user:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table" data-mobile-responsive="true"></table>
</div>
</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('vip:user:edit')}]];
var removeFlag = [[${@permission.hasPermi('vip:user:remove')}]];
var resetPwdFlag = [[${@permission.hasPermi('vip:user:resetPwd')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "vip/user";
$(function() {
$('body').layout({ west__size: 185 });
queryUserList();
queryDeptTree();
});
function queryUserList() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
sortName: "createTime",
sortOrder: "desc",
modalName: "用户",
search: false,
showExport: false,
columns: [{
checkbox: true
},
{
field: 'userId',
title: '用户ID'
},
{
field: 'loginName',
title: '登录名称',
sortable: true
},
{
field: 'userName',
title: '用户名称'
},
{
field: 'dept.deptName',
title: '部门'
},
{
field: 'email',
title: '邮箱',
visible: false
},
{
field: 'phonenumber',
title: '手机'
},
{
field: 'status',
title: '状态',
align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(datas, value);
}
},
{
field: 'createTime',
title: '创建时间',
sortable: true
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-info btn-xs ' + resetPwdFlag + '" href="#" onclick="resetPwd(\'' + row.userId + '\')"><i class="fa fa-key"></i>重置</a>');
return actions.join('');
}
}]
};
$.table.init(options);
}
function queryDeptTree()
{
var url = ctx + "system/dept/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#deptId").val(treeNode.id);
$("#parentId").val(treeNode.pId);
$.table.search();
}
}
$('#btnExpand').click(function() {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function() {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function() {
queryDeptTree();
});
/*用户管理-部门*/
function dept() {
var url = ctx + "vip/dept";
createMenuItem(url, "部门管理");
}
/*用户管理-重置密码*/
function resetPwd(userId) {
var url = prefix + '/resetPwd/' + userId;
$.modal.open("重置密码", url, '800', '300');
}
</script>
</body>
</html>