Merge remote-tracking branch 'origin/master' into songpengmaster
commit
0ae52b9e39
|
@ -40,8 +40,8 @@ public class ShiroRealm extends AuthorizingRealm {
|
|||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
|
||||
SysUserDTO user = (SysUserDTO) principalCollection.getPrimaryPrincipal();
|
||||
Set<String> perms = new HashSet<>();
|
||||
if (CollectionUtils.isNotEmpty(user.getSysRoleDtos())) {
|
||||
for (SysRoleDTO sr : user.getSysRoleDtos()) {
|
||||
if (CollectionUtils.isNotEmpty(user.getSysRoleDTOs())) {
|
||||
for (SysRoleDTO sr : user.getSysRoleDTOs()) {
|
||||
if (CollectionUtils.isEmpty(sr.getSysMenuDtos())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class ShiroRealm extends AuthorizingRealm {
|
|||
}
|
||||
|
||||
// 账号锁定
|
||||
if (!user.getDeleted().equals(SysUserEnum.STATUS_NORMAL.getCode())) {
|
||||
if (!user.getDeleted().equals(SysUserEnum.DELETED_NORMAL.getCode())) {
|
||||
log.error("账号已被锁定,请联系管理员");
|
||||
throw new LockedAccountException("账号已被锁定,请联系管理员");
|
||||
}
|
||||
|
|
|
@ -1,21 +1,71 @@
|
|||
package com.songpeng.sparchetype.system.controller.admin;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.songpeng.sparchetype.common.BaseController;
|
||||
import com.songpeng.sparchetype.common.Result;
|
||||
import com.songpeng.sparchetype.system.entity.SysDepartment;
|
||||
import com.songpeng.sparchetype.system.entity.SysDict;
|
||||
import com.songpeng.sparchetype.system.service.ISysDepartmentService;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 系统部门前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-03
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/dept/sp-sys-department")
|
||||
@RequestMapping("/admin/sys/department")
|
||||
public class SysDepartmentController extends BaseController {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(SysDepartmentController.class);
|
||||
|
||||
@Autowired
|
||||
private ISysDepartmentService sysDepartmentService;
|
||||
|
||||
@ApiOperation("系统部门信息列表UI")
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "model", value = "模型", defaultValue = "模型")})
|
||||
@GetMapping("/list-ui")
|
||||
public String listUI(Model model) {
|
||||
return "admin/system/department/list";
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
@ResponseBody
|
||||
public Result page(Page page) {
|
||||
IPage result = sysDepartmentService.page(page);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/add-or-update-ui")
|
||||
public String addOrUpdateUI(Model model, SysDict record) {
|
||||
if (StringUtils.isNotEmpty(record.getId())) {
|
||||
SysDepartment sysDepartment = sysDepartmentService.getById(record.getId());
|
||||
model.addAttribute("department", sysDepartment);
|
||||
}
|
||||
return "admin/system/department/addOrUpdate";
|
||||
}
|
||||
|
||||
@PostMapping("/add-or-update")
|
||||
@ResponseBody
|
||||
public Result addOrUpdate(SysDepartment record) {
|
||||
sysDepartmentService.saveOrUpdate(record);
|
||||
return Result.success(record.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.songpeng.sparchetype.common.BaseController;
|
||||
import com.songpeng.sparchetype.common.Result;
|
||||
import com.songpeng.sparchetype.system.dto.SysRoleDTO;
|
||||
import com.songpeng.sparchetype.system.dto.SysUserDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysUser;
|
||||
import com.songpeng.sparchetype.system.request.SysUserPageReq;
|
||||
import com.songpeng.sparchetype.system.service.ISysRoleService;
|
||||
import com.songpeng.sparchetype.system.service.ISysUserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
|
@ -36,6 +41,9 @@ public class SysUserController extends BaseController {
|
|||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
@GetMapping("/list-ui")
|
||||
public String listUI(Model model) {
|
||||
return "admin/system/user/list";
|
||||
|
@ -43,27 +51,32 @@ public class SysUserController extends BaseController {
|
|||
|
||||
@PostMapping("/page")
|
||||
@ResponseBody
|
||||
public Result page(SysUserPageReq req) {
|
||||
getSysUser();
|
||||
public Result page(SysUserPageReq req) throws Exception {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.orderByDesc(req.getOrderBy());
|
||||
IPage result = sysUserService.page(req, qw);
|
||||
return Result.success(result);
|
||||
IPage page = sysUserService.page(req, qw);
|
||||
return Result.success(page);
|
||||
}
|
||||
|
||||
@GetMapping("/add-or-update-ui")
|
||||
public String addOrUpdateUI(SysUser record, Model model) {
|
||||
public String addOrUpdateUI(SysUser record, Model model) throws Exception {
|
||||
if (StringUtils.isNotEmpty(record.getId())) {
|
||||
SysUser result = sysUserService.getById(record.getId());
|
||||
model.addAttribute("result", result);
|
||||
}
|
||||
List<SysRoleDTO> sysRoles = sysRoleService.listByUserId(record.getId());
|
||||
model.addAttribute("sysRoles", sysRoles);
|
||||
return "admin/system/user/addOrUpdate";
|
||||
}
|
||||
|
||||
@PostMapping("/add-or-update")
|
||||
@ResponseBody
|
||||
public Result addOrUpdate(SysUser record) {
|
||||
sysUserService.saveOrUpdate(record);
|
||||
public Result addOrUpdate(SysUserDTO record) throws Exception {
|
||||
if (StringUtils.isEmpty(record.getId())) {
|
||||
sysUserService.save(record);
|
||||
} else {
|
||||
sysUserService.update(record);
|
||||
}
|
||||
return Result.success(record.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SysLoginController {
|
|||
*/
|
||||
@GetMapping({"/", ""})
|
||||
public String welcomeUI(Model model) {
|
||||
return "redirect:/blog";
|
||||
return "redirect:/client/company";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,11 +14,24 @@ import java.util.List;
|
|||
*/
|
||||
public class SysRoleDTO extends SysRole {
|
||||
|
||||
/**
|
||||
* 角色是否选中
|
||||
*/
|
||||
private boolean checked;
|
||||
|
||||
/**
|
||||
* 菜单列表
|
||||
*/
|
||||
List<SysMenuDTO> sysMenuDtos;
|
||||
|
||||
public boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public List<SysMenuDTO> getSysMenuDtos() {
|
||||
return sysMenuDtos;
|
||||
}
|
||||
|
|
|
@ -10,18 +10,31 @@ import java.util.List;
|
|||
*/
|
||||
public class SysUserDTO extends SysUser {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID列表
|
||||
*/
|
||||
private String[] sysRoleIds;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*/
|
||||
List<SysRoleDTO> sysRoleDtos;
|
||||
private List<SysRoleDTO> sysRoleDTOs;
|
||||
|
||||
public List<SysRoleDTO> getSysRoleDtos() {
|
||||
return sysRoleDtos;
|
||||
}
|
||||
public List<SysRoleDTO> getSysRoleDTOs() {
|
||||
return sysRoleDTOs;
|
||||
}
|
||||
|
||||
public void setSysRoleDtos(List<SysRoleDTO> sysRoleDtos) {
|
||||
this.sysRoleDtos = sysRoleDtos;
|
||||
}
|
||||
public void setSysRoleDTOs(List<SysRoleDTO> sysRoleDTOs) {
|
||||
this.sysRoleDTOs = sysRoleDTOs;
|
||||
}
|
||||
|
||||
public String[] getSysRoleIds() {
|
||||
return sysRoleIds;
|
||||
}
|
||||
|
||||
public void setSysRoleIds(String[] sysRoleIds) {
|
||||
this.sysRoleIds = sysRoleIds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.songpeng.sparchetype.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.songpeng.sparchetype.common.BaseEntity;
|
||||
|
||||
/**
|
||||
|
@ -10,6 +11,7 @@ import com.songpeng.sparchetype.common.BaseEntity;
|
|||
* @author SongPeng
|
||||
* @since 2020-03-03
|
||||
*/
|
||||
@TableName("sp_sys_department")
|
||||
public class SysDepartment extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -25,5 +27,35 @@ public class SysDepartment extends BaseEntity {
|
|||
*/
|
||||
private String isDeleted;
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getSortNum() {
|
||||
return sortNum;
|
||||
}
|
||||
|
||||
public void setSortNum(Integer sortNum) {
|
||||
this.sortNum = sortNum;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return isDeleted;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String isDeleted) {
|
||||
this.isDeleted = isDeleted;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.songpeng.sparchetype.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.songpeng.sparchetype.common.BaseEntity;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色菜单表
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
@TableName("sp_sys_role_menu")
|
||||
public class SysRoleMenu extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 菜单id
|
||||
*/
|
||||
private String menuId;
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getMenuId() {
|
||||
return menuId;
|
||||
}
|
||||
|
||||
public void setMenuId(String menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.songpeng.sparchetype.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.songpeng.sparchetype.common.BaseEntity;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色表
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
@TableName("sp_sys_user_role")
|
||||
public class SysUserRole extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.songpeng.sparchetype.system.enums;
|
||||
|
||||
/**
|
||||
* 系统用户枚举
|
||||
*
|
||||
* @author SongPeng
|
||||
* @date 2019/10/17 9:45
|
||||
*/
|
||||
public enum SysRoleEnum {
|
||||
|
||||
DELETED_NORMAL("0", "正常"),
|
||||
|
||||
DELETED_DEL("1", "删除"),
|
||||
|
||||
DELETED_DISABLED("2", "禁用");
|
||||
|
||||
/**
|
||||
* The Code
|
||||
*/
|
||||
String code;
|
||||
/**
|
||||
* The Desc
|
||||
*/
|
||||
String desc;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
SysRoleEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
|
@ -8,11 +8,11 @@ package com.songpeng.sparchetype.system.enums;
|
|||
*/
|
||||
public enum SysUserEnum {
|
||||
|
||||
STATUS_NORMAL("0", "正常"),
|
||||
DELETED_NORMAL("0", "正常"),
|
||||
|
||||
STATUS_DEL("1", "删除"),
|
||||
DELETED_DEL("1", "删除"),
|
||||
|
||||
STATUS_DISABLED("2", "禁用");
|
||||
DELETED_DISABLED("2", "禁用");
|
||||
|
||||
/**
|
||||
* The Code
|
||||
|
|
|
@ -23,5 +23,5 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<SysMenuDTO> selectMenuByRoleId(String roleId) throws Exception;
|
||||
List<SysMenuDTO> listByRoleId(String roleId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
|||
/**
|
||||
* 根据用户 id 获取角色列表
|
||||
*
|
||||
* @param username
|
||||
* @param userId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<SysRole> getRolesByUserId(String userId) throws Exception;
|
||||
List<SysRole> listByUserId(String userId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.songpeng.sparchetype.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.songpeng.sparchetype.system.entity.SysRoleMenu;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.songpeng.sparchetype.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.songpeng.sparchetype.system.entity.SysUserRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.songpeng.sparchetype.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.songpeng.sparchetype.system.dto.SysMenuDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysMenu;
|
||||
import com.songpeng.sparchetype.system.vo.TreeVO;
|
||||
|
||||
|
@ -17,6 +18,16 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ISysMenuService extends IService<SysMenu> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据角色id查询菜单列表
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<SysMenuDTO> listByRoleId(String roleId) throws Exception;
|
||||
|
||||
/**
|
||||
* 系统首页初始化菜单树数据
|
||||
*
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.songpeng.sparchetype.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.songpeng.sparchetype.system.entity.SysRoleMenu;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
public interface ISysRoleMenuService extends IService<SysRoleMenu> {
|
||||
|
||||
}
|
|
@ -2,8 +2,11 @@ package com.songpeng.sparchetype.system.service;
|
|||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.songpeng.sparchetype.system.dto.SysRoleDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
|
@ -14,4 +17,12 @@ import com.songpeng.sparchetype.system.entity.SysRole;
|
|||
*/
|
||||
public interface ISysRoleService extends IService<SysRole> {
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色列表信息
|
||||
*
|
||||
* @param userId 系统用户ID
|
||||
* @return 角色列表
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
List<SysRoleDTO> listByUserId(String userId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.songpeng.sparchetype.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.songpeng.sparchetype.system.entity.SysUserRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
public interface ISysUserRoleService extends IService<SysUserRole> {
|
||||
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package com.songpeng.sparchetype.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.songpeng.sparchetype.system.dto.SysUserDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysUser;
|
||||
import com.songpeng.sparchetype.system.request.SysUserPageReq;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -14,12 +16,28 @@ import com.songpeng.sparchetype.system.entity.SysUser;
|
|||
*/
|
||||
public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
/**
|
||||
* 获取用户角色菜单
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
SysUserDTO getUserAndRoleAndMenuByUsername(String username) throws Exception;
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param record 用户信息
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
void save(SysUserDTO record) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param record 用户信息
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
void update(SysUserDTO record) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取用户角色菜单
|
||||
*
|
||||
* @param username 系统用户名
|
||||
* @return 返回结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
SysUserDTO getUserAndRoleAndMenuByUsername(String username) throws Exception;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.songpeng.sparchetype.system.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.songpeng.sparchetype.common.util.TreeUtil;
|
||||
import com.songpeng.sparchetype.system.dto.SysMenuDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysMenu;
|
||||
import com.songpeng.sparchetype.system.mapper.SysMenuMapper;
|
||||
import com.songpeng.sparchetype.system.service.ISysMenuService;
|
||||
|
@ -25,6 +26,18 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
@Autowired
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
|
||||
/**
|
||||
* 根据角色id查询菜单列表
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenuDTO> listByRoleId(String roleId) throws Exception {
|
||||
return sysMenuMapper.listByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统首页初始化菜单树数据
|
||||
*
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.songpeng.sparchetype.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.songpeng.sparchetype.system.entity.SysRole;
|
||||
import com.songpeng.sparchetype.system.entity.SysRoleMenu;
|
||||
import com.songpeng.sparchetype.system.mapper.SysRoleMapper;
|
||||
import com.songpeng.sparchetype.system.mapper.SysRoleMenuMapper;
|
||||
import com.songpeng.sparchetype.system.service.ISysRoleMenuService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {
|
||||
|
||||
}
|
|
@ -1,11 +1,19 @@
|
|||
package com.songpeng.sparchetype.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.songpeng.sparchetype.system.dto.SysRoleDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysRole;
|
||||
import com.songpeng.sparchetype.system.enums.SysRoleEnum;
|
||||
import com.songpeng.sparchetype.system.mapper.SysRoleMapper;
|
||||
import com.songpeng.sparchetype.system.service.ISysRoleService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
|
@ -17,4 +25,36 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色列表信息
|
||||
*
|
||||
* @param userId 系统用户ID
|
||||
* @return 角色列表
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
public List<SysRoleDTO> listByUserId(String userId) throws Exception {
|
||||
List<SysRoleDTO> result = new ArrayList<>();
|
||||
|
||||
List<SysRole> sysRoles = sysRoleMapper.listByUserId(userId);
|
||||
|
||||
QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("delete", SysRoleEnum.DELETED_NORMAL.getCode());
|
||||
List<SysRole> sysRolesAll = sysRoleMapper.selectList(null);
|
||||
|
||||
for (SysRole role : sysRolesAll) {
|
||||
SysRoleDTO roleDTO = new SysRoleDTO();
|
||||
BeanUtils.copyProperties(role, roleDTO);
|
||||
for (SysRole r : sysRoles) {
|
||||
if (role.getId().equals(r.getId())) {
|
||||
roleDTO.setChecked(true);
|
||||
}
|
||||
}
|
||||
result.add(roleDTO);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.songpeng.sparchetype.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.songpeng.sparchetype.system.entity.SysUser;
|
||||
import com.songpeng.sparchetype.system.entity.SysUserRole;
|
||||
import com.songpeng.sparchetype.system.mapper.SysUserMapper;
|
||||
import com.songpeng.sparchetype.system.mapper.SysUserRoleMapper;
|
||||
import com.songpeng.sparchetype.system.service.ISysUserRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2020-03-05
|
||||
*/
|
||||
@Service
|
||||
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {
|
||||
|
||||
}
|
|
@ -1,16 +1,24 @@
|
|||
package com.songpeng.sparchetype.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.songpeng.sparchetype.system.dto.SysMenuDTO;
|
||||
import com.songpeng.sparchetype.system.dto.SysRoleDTO;
|
||||
import com.songpeng.sparchetype.system.dto.SysUserDTO;
|
||||
import com.songpeng.sparchetype.system.entity.SysUser;
|
||||
import com.songpeng.sparchetype.system.mapper.SysMenuMapper;
|
||||
import com.songpeng.sparchetype.system.entity.SysUserRole;
|
||||
import com.songpeng.sparchetype.system.mapper.SysUserMapper;
|
||||
import com.songpeng.sparchetype.system.request.SysUserPageReq;
|
||||
import com.songpeng.sparchetype.system.service.ISysMenuService;
|
||||
import com.songpeng.sparchetype.system.service.ISysUserRoleService;
|
||||
import com.songpeng.sparchetype.system.service.ISysUserService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,29 +33,82 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
@Autowired
|
||||
private ISysMenuService sysMenuService;
|
||||
|
||||
/**
|
||||
* 获取用户角色菜单
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public SysUserDTO getUserAndRoleAndMenuByUsername(String username) throws Exception {
|
||||
SysUserDTO result = sysUserMapper.selectUserAndRoleByUsername(username);
|
||||
if (CollectionUtils.isNotEmpty(result.getSysRoleDtos())) {
|
||||
for (SysRoleDTO rDto : result.getSysRoleDtos()) {
|
||||
List<SysMenuDTO> menus = sysMenuMapper.selectMenuByRoleId(rDto.getId());
|
||||
rDto.setSysMenuDtos(menus);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Autowired
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param record 用户信息
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(SysUserDTO record) throws Exception {
|
||||
sysUserMapper.insert(record);
|
||||
// rebuild
|
||||
if (ArrayUtils.isNotEmpty(record.getSysRoleIds())) {
|
||||
for (String roleId : record.getSysRoleIds()) {
|
||||
if (StringUtils.isEmpty(roleId)) {
|
||||
continue;
|
||||
}
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setUserId(record.getId());
|
||||
sysUserRole.setRoleId(roleId);
|
||||
sysUserRoleService.save(sysUserRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param record 用户信息
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void update(SysUserDTO record) throws Exception {
|
||||
sysUserMapper.updateById(record);
|
||||
QueryWrapper<SysUserRole> deleteWrapper = new QueryWrapper<>();
|
||||
deleteWrapper.eq("user_id", record.getId());
|
||||
sysUserRoleService.remove(deleteWrapper);
|
||||
if (ArrayUtils.isNotEmpty(record.getSysRoleIds())) {
|
||||
for (String roleId : record.getSysRoleIds()) {
|
||||
if (StringUtils.isEmpty(roleId)) {
|
||||
continue;
|
||||
}
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setUserId(record.getId());
|
||||
sysUserRole.setRoleId(roleId);
|
||||
sysUserRoleService.save(sysUserRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户角色菜单
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public SysUserDTO getUserAndRoleAndMenuByUsername(String username) throws Exception {
|
||||
SysUserDTO result = sysUserMapper.selectUserAndRoleByUsername(username);
|
||||
if (CollectionUtils.isNotEmpty(result.getSysRoleDTOs())) {
|
||||
for (SysRoleDTO rDto : result.getSysRoleDTOs()) {
|
||||
List<SysMenuDTO> menus = sysMenuService.listByRoleId(rDto.getId());
|
||||
rDto.setSysMenuDtos(menus);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</resultMap>
|
||||
|
||||
<!--根据角色id查询菜单列表-->
|
||||
<select id="selectMenuByRoleId" parameterType="java.lang.String" resultMap="dtoResultMap">
|
||||
<select id="listByRoleId" parameterType="java.lang.String" resultMap="dtoResultMap">
|
||||
SELECT t.* FROM sp_sys_menu t
|
||||
LEFT JOIN sp_sys_role_menu ssrm
|
||||
ON ssrm.role_id = #{roleId}
|
||||
|
|
|
@ -2,11 +2,24 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.songpeng.sparchetype.system.mapper.SysRoleMapper">
|
||||
|
||||
<resultMap id="resultMap" type="com.songpeng.sparchetype.system.entity.SysRole">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="code" jdbcType="VARCHAR" property="code" />
|
||||
<result column="descr" jdbcType="VARCHAR" property="descr" />
|
||||
<result column="is_deleted" jdbcType="VARCHAR" property="deleted" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="create_username" jdbcType="VARCHAR" property="createUsername" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="update_username" jdbcType="VARCHAR" property="updateUsername" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getRolesByUserId" parameterType="java.lang.String" resultType="com.songpeng.sparchetype.system.entity.SysRole">
|
||||
<!--根据用户ID获取用户权限列表-->
|
||||
<select id="listByUserId" parameterType="java.lang.String" resultMap="resultMap">
|
||||
SELECT t.*
|
||||
FROM sp_sys_role t,
|
||||
sp_sys_user_role sur
|
||||
WHERE t.id = sur.role_id AND sur.user_id = #{userId}
|
||||
WHERE t.id = sur.role_id
|
||||
AND sur.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?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.songpeng.sparchetype.system.mapper.SysRoleMenuMapper">
|
||||
|
||||
</mapper>
|
|
@ -30,7 +30,7 @@
|
|||
</resultMap>
|
||||
|
||||
<resultMap id="userRoleResultMap" extends="resultMap" type="com.songpeng.sparchetype.system.dto.SysUserDTO">
|
||||
<collection property="sysRoleDtos" ofType="com.songpeng.sparchetype.system.dto.SysRoleDTO">
|
||||
<collection property="sysRoleDTOs" ofType="com.songpeng.sparchetype.system.dto.SysRoleDTO">
|
||||
<id column="role_id" property="id"/>
|
||||
<result column="role_name" property="name"/>
|
||||
<result column="code" property="code"/>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?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.songpeng.sparchetype.system.mapper.SysUserRoleMapper">
|
||||
|
||||
</mapper>
|
|
@ -76,6 +76,7 @@ layui.define(["element", "jquery"], function (exports) {
|
|||
* @param data
|
||||
*/
|
||||
this.initHome = function (data) {
|
||||
console.log(data)
|
||||
sessionStorage.setItem('splayuiHomeHref', data.url);
|
||||
$('#splayuiHomeTabId').html('<i class="' + data.icon + '"></i> <span>' + data.name + '</span>');
|
||||
$('#splayuiHomeTabId').attr('lay-id', data.url);
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>添加部门</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<#include "${request.contextPath}/common/common.ftl">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="splayui-container">
|
||||
<div class="splayui-main">
|
||||
<form class="layui-form splayui-form">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
|
||||
<div class="layui-form-item">
|
||||
<label for="js-name" class="layui-form-label sp-required">姓名
|
||||
</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="js-name" name="name" lay-verify="required" autocomplete="off" class="layui-input" value="${result.name}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="js-descr" class="layui-form-label sp-required">描述</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="js-descr" name="descr" lay-verify="" autocomplete="off" class="layui-input" value="${result.descr}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="js-is-deleted" class="layui-form-label sp-required">状态</label>
|
||||
<div class="layui-input-block" id="js-is-deleted">
|
||||
<input type="radio" name="deleted" value="0" title="正常" <#if result.deleted == "0" || !(result??)>checked</#if>>
|
||||
<input type="radio" name="deleted" value="1" title="已删除" <#if result.deleted == "1">checked</#if>>
|
||||
<input type="radio" name="deleted" value="2" title="已禁用" <#if result.deleted == "2">checked</#if>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<div class="layui-input-block">
|
||||
<input id="js-id" name="id" value="${result.id}"/>
|
||||
<button id="js-submit" class="layui-btn" lay-submit lay-filter="js-submit-filter">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
layui.use(['form', 'util'], function () {
|
||||
var form = layui.form,
|
||||
util = layui.util;
|
||||
|
||||
//失去焦点时判断值为空不验证,一旦填写必须验证
|
||||
$('input[name="email"]').blur(function () {
|
||||
//这里是失去焦点时的事件
|
||||
if ($('input[name="email"]').val()) {
|
||||
$('input[name="email"]').attr('lay-verify', 'email');
|
||||
} else {
|
||||
$('input[name="email"]').removeAttr('lay-verify');
|
||||
}
|
||||
});
|
||||
|
||||
//监听提交
|
||||
form.on('submit(js-submit-filter)', function (data) {
|
||||
spUtil.submitForm({
|
||||
url: "${request.contextPath}/admin/sys/department/add-or-update",
|
||||
data: data.field
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,201 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>系统部门列表</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<#include "${request.contextPath}/common/common.ftl">
|
||||
</head>
|
||||
<body>
|
||||
<div class="splayui-container">
|
||||
<div class="splayui-main">
|
||||
<!--查询参数-->
|
||||
<form id="js-search-form" class="layui-form" lay-filter="js-q-form-filter">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="nameLike" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">用户名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="usernameLike" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<a class="layui-btn" lay-submit lay-filter="js-search-filter"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!--表格-->
|
||||
<table class="layui-hide" id="js-record-table" lay-filter="js-record-table-filter"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--表格头操作模板-->
|
||||
<script type="text/html" id="js-record-table-toolbar-top">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch"><i class="layui-icon"></i>批量删除</button>
|
||||
<@shiro.hasPermission name="user:add">
|
||||
<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i>添加</button>
|
||||
</@shiro.hasPermission>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!--行操作模板-->
|
||||
<script type="text/html" id="js-record-table-toolbar-right">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>
|
||||
</script>
|
||||
|
||||
<!--js逻辑-->
|
||||
<script>
|
||||
layui.use(['form', 'table', 'splayer', 'sptable'], function () {
|
||||
var form = layui.form,
|
||||
table = layui.table,
|
||||
splayer = layui.splayer,
|
||||
sptable = layui.sptable;
|
||||
|
||||
// 表格及数据初始化
|
||||
var tableIns = sptable.render({
|
||||
height: 'full-' + ($('#js-search-form').height() + 40),
|
||||
page: true,
|
||||
url: '${request.contextPath}/admin/sys/department/page',
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox'
|
||||
}, {
|
||||
field: 'name', title: '姓名', width: 120
|
||||
}, {
|
||||
field: 'username', title: '用户名', width: 130
|
||||
}, {
|
||||
field: 'password', title: '密码', width: 90
|
||||
}, {
|
||||
field: 'deptId', title: '部门id', width: 90
|
||||
}, {
|
||||
field: 'email', title: '邮箱', width: 90
|
||||
}, {
|
||||
field: 'mobile', title: '手机号', width: 120
|
||||
}, {
|
||||
field: 'tel', title: '固定电话', width: 120
|
||||
}, {
|
||||
field: 'sex', title: '性别', width: 60
|
||||
}, {
|
||||
field: 'birthday', title: '出生年月日', width: 120
|
||||
}, {
|
||||
field: 'picId', title: '图片id', width: 90
|
||||
}, {
|
||||
field: 'idCard', title: '身份证', width: 120
|
||||
}, {
|
||||
field: 'hobby', title: '爱好', width: 90
|
||||
}, {
|
||||
field: 'province', title: '省份', width: 90
|
||||
}, {
|
||||
field: 'city', title: '城市', width: 90
|
||||
}, {
|
||||
field: 'district', title: '区县', width: 90
|
||||
}, {
|
||||
field: 'street', title: '街道', width: 90
|
||||
}, {
|
||||
field: 'streetNumber', title: '门牌号', width: 90
|
||||
}, {
|
||||
field: 'descr', title: '描述', width: 90
|
||||
}, {
|
||||
field: 'deleted', title: '状态', width: 90, templet: function (d) {
|
||||
return spConfig.isDeletedDict[d.deleted];
|
||||
}
|
||||
}, {
|
||||
fixed: 'right', field: 'operate', title: '操作', toolbar: '#js-record-table-toolbar-right', unresize: true, width: 150
|
||||
}]
|
||||
],
|
||||
done: function (res, curr, count) {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* 数据表格中form表单元素是动态插入,所以需要更新渲染下
|
||||
* http://www.layui.com/doc/modules/form.html#render
|
||||
*/
|
||||
$(function () {
|
||||
form.render();
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索按钮事件
|
||||
*/
|
||||
form.on('submit(js-search-filter)', function (data) {
|
||||
tableIns.reload({
|
||||
where: data.field,
|
||||
page: {
|
||||
// 重新从第 1 页开始
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
|
||||
// 阻止表单跳转。如果需要表单跳转,去掉这段即可。
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 头工具栏事件
|
||||
*/
|
||||
table.on('toolbar(js-record-table-filter)', function (obj) {
|
||||
var checkStatus = table.checkStatus(obj.config.id);
|
||||
|
||||
// 批量删除
|
||||
if (obj.event === 'deleteBatch') {
|
||||
var checkStatus = table.checkStatus('js-record-table'),
|
||||
data = checkStatus.data;
|
||||
if (data.length > 0) {
|
||||
layer.confirm('确认要删除吗?', function (index) {
|
||||
|
||||
});
|
||||
} else {
|
||||
layer.msg("请先选择需要删除的数据!");
|
||||
}
|
||||
}
|
||||
|
||||
// 添加
|
||||
if (obj.event === 'add') {
|
||||
var index = splayer.open({
|
||||
title: '添加',
|
||||
area: ['90%', '90%'],
|
||||
content: '${request.contextPath}/admin/sys/department/add-or-update-ui'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听行工具事件
|
||||
*/
|
||||
table.on('tool(js-record-table-filter)', function (obj) {
|
||||
var data = obj.data;
|
||||
|
||||
// 编辑
|
||||
if (obj.event === 'edit') {
|
||||
splayer.open({
|
||||
title: '编辑',
|
||||
area: ['90%', '90%'],
|
||||
// 请求url参数
|
||||
spWhere: {id: data.id},
|
||||
content: '${request.contextPath}/admin/sys/department/add-or-update-ui'
|
||||
});
|
||||
}
|
||||
|
||||
// 删除
|
||||
if (obj.event === 'delete') {
|
||||
layer.confirm('确认要删除吗?', function (index) {
|
||||
obj.del();
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -102,10 +102,12 @@
|
|||
*/
|
||||
treeTable.on('tool(js-record-table)', function (obj) {
|
||||
var event = obj.event;
|
||||
|
||||
if (event == 'del') {
|
||||
layer.msg('点击了删除', {icon: 1});
|
||||
} else if (event == 'edit') {
|
||||
layer.msg('点击了修改', {icon: 1});
|
||||
}
|
||||
|
||||
if (event == 'edit') {
|
||||
splayer.open({
|
||||
title: '编辑',
|
||||
area: ['800px', '500px'],
|
||||
|
@ -114,6 +116,16 @@
|
|||
content: '${request.contextPath}/admin/sys/menu/add-or-update-ui'
|
||||
});
|
||||
}
|
||||
|
||||
if (event == 'add') {
|
||||
splayer.open({
|
||||
title: '新增',
|
||||
area: ['800px', '500px'],
|
||||
// 请求url参数
|
||||
spWhere: {},
|
||||
content: '${request.contextPath}/admin/sys/menu/add-or-update-ui'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 全部展开、折叠标记
|
||||
|
|
|
@ -182,6 +182,17 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
|
||||
<div class="layui-form-item" pane="">
|
||||
<label class="layui-form-label">分配权限</label>
|
||||
<div class="layui-input-block">
|
||||
<#list sysRoles as sysRole>
|
||||
<input type="checkbox" name="sysRoleIds[]" title="${sysRole.name}" value="${sysRole.id}" <#if sysRole.checked >checked</#if>>
|
||||
</#list>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<div class="layui-input-block">
|
||||
<input id="js-id" name="id" value="${result.id}"/>
|
||||
|
@ -209,6 +220,9 @@
|
|||
|
||||
//监听提交
|
||||
form.on('submit(js-submit-filter)', function (data) {
|
||||
console.log(data.field)
|
||||
//return false;
|
||||
|
||||
spUtil.submitForm({
|
||||
url: "${request.contextPath}/admin/sys/user/add-or-update",
|
||||
data: data.field
|
||||
|
|
Loading…
Reference in New Issue