mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-03 07:56:38 +00:00
上传后台管理系统代码
This commit is contained in:
@ -0,0 +1,160 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.common.domain.DictDO;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
|
||||
import com.java2nb.system.domain.DataPermDO;
|
||||
import com.java2nb.system.service.DataPermService;
|
||||
import com.java2nb.common.utils.PageBean;
|
||||
import com.java2nb.common.utils.Query;
|
||||
import com.java2nb.common.utils.R;
|
||||
|
||||
/**
|
||||
* 数据权限管理
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:40:03
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/system/dataPerm")
|
||||
public class DataPermController {
|
||||
@Autowired
|
||||
private DataPermService dataPermService;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("system:dataPerm:dataPerm")
|
||||
String DataPerm() {
|
||||
return "system/dataPerm/dataPerm";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取数据权限管理列表", notes = "获取数据权限管理列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("system:dataPerm:dataPerm")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
//查询列表数据
|
||||
Query query = new Query(params);
|
||||
List<DataPermDO> dataPermList = dataPermService.list(query);
|
||||
int total = dataPermService.count(query);
|
||||
PageBean pageBean = new PageBean(dataPermList, total);
|
||||
return R.ok().put("data", pageBean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增数据权限管理页面", notes = "新增数据权限管理页面")
|
||||
@GetMapping("/add")
|
||||
@RequiresPermissions("system:dataPerm:add")
|
||||
String add() {
|
||||
return "system/dataPerm/add";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改数据权限管理页面", notes = "修改数据权限管理页面")
|
||||
@GetMapping("/edit/{id}")
|
||||
@RequiresPermissions("system:dataPerm:edit")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
DataPermDO dataPerm = dataPermService.get(id);
|
||||
model.addAttribute("dataPerm", dataPerm);
|
||||
return "system/dataPerm/edit";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看数据权限管理页面", notes = "查看数据权限管理页面")
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequiresPermissions("system:dataPerm:detail")
|
||||
String detail(@PathVariable("id") Long id, Model model) {
|
||||
DataPermDO dataPerm = dataPermService.get(id);
|
||||
model.addAttribute("dataPerm", dataPerm);
|
||||
return "system/dataPerm/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation(value = "新增数据权限管理", notes = "新增数据权限管理")
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:dataPerm:add")
|
||||
public R save( DataPermDO dataPerm) {
|
||||
if (dataPermService.save(dataPerm) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation(value = "修改数据权限管理", notes = "修改数据权限管理")
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("system:dataPerm:edit")
|
||||
public R update( DataPermDO dataPerm) {
|
||||
dataPermService.update(dataPerm);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "删除数据权限管理", notes = "删除数据权限管理")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("system:dataPerm:remove")
|
||||
public R remove( Long id) {
|
||||
if (dataPermService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "批量删除数据权限管理", notes = "批量删除数据权限管理")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("system:dataPerm:batchRemove")
|
||||
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||
dataPermService.batchRemove(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/moduleName")
|
||||
@ResponseBody
|
||||
public List<DataPermDO> listModuleName() {
|
||||
return dataPermService.listModuleName();
|
||||
};
|
||||
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ResponseBody
|
||||
Tree<DataPermDO> tree() {
|
||||
Tree<DataPermDO> tree = dataPermService.getTree();
|
||||
return tree;
|
||||
}
|
||||
|
||||
@GetMapping("/tree/{roleId}")
|
||||
@ResponseBody
|
||||
Tree<DataPermDO> tree(@PathVariable("roleId") Long roleId) {
|
||||
Tree<DataPermDO> tree = dataPermService.getTree(roleId);
|
||||
return tree;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import com.java2nb.common.config.Constant;
|
||||
import com.java2nb.common.controller.BaseController;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.utils.R;
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
import com.java2nb.system.service.DeptService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-09-27 14:40:36
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/system/sysDept")
|
||||
public class DeptController extends BaseController {
|
||||
private String prefix = "system/dept";
|
||||
@Autowired
|
||||
private DeptService sysDeptService;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("system:sysDept:sysDept")
|
||||
String dept() {
|
||||
return prefix + "/dept";
|
||||
}
|
||||
|
||||
@ApiOperation(value="获取部门列表", notes="获取部门列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("system:sysDept:sysDept")
|
||||
public List<DeptDO> list() {
|
||||
Map<String, Object> query = new HashMap<>(16);
|
||||
List<DeptDO> sysDeptList = sysDeptService.list(query);
|
||||
return sysDeptList;
|
||||
}
|
||||
|
||||
@GetMapping("/add/{pId}")
|
||||
@RequiresPermissions("system:sysDept:add")
|
||||
String add(@PathVariable("pId") Long pId, Model model) {
|
||||
model.addAttribute("pId", pId);
|
||||
if (pId == 0) {
|
||||
model.addAttribute("pName", "总部门");
|
||||
} else {
|
||||
model.addAttribute("pName", sysDeptService.get(pId).getName());
|
||||
}
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
@GetMapping("/edit/{deptId}")
|
||||
@RequiresPermissions("system:sysDept:edit")
|
||||
String edit(@PathVariable("deptId") Long deptId, Model model) {
|
||||
DeptDO sysDept = sysDeptService.get(deptId);
|
||||
model.addAttribute("sysDept", sysDept);
|
||||
if(Constant.DEPT_ROOT_ID.equals(sysDept.getParentId())) {
|
||||
model.addAttribute("parentDeptName", "无");
|
||||
}else {
|
||||
DeptDO parDept = sysDeptService.get(sysDept.getParentId());
|
||||
model.addAttribute("parentDeptName", parDept.getName());
|
||||
}
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:sysDept:add")
|
||||
public R save(DeptDO sysDept) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (sysDeptService.save(sysDept) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("system:sysDept:edit")
|
||||
public R update(DeptDO sysDept) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (sysDeptService.update(sysDept) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("system:sysDept:remove")
|
||||
public R remove(Long deptId) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("parentId", deptId);
|
||||
if(sysDeptService.count(map)>0) {
|
||||
return R.error(1, "包含下级部门,不允许修改");
|
||||
}
|
||||
if(sysDeptService.checkDeptHasUser(deptId)) {
|
||||
if (sysDeptService.remove(deptId) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
return R.error(1, "部门包含用户,不允许修改");
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("system:sysDept:batchRemove")
|
||||
public R remove(@RequestParam("ids[]") Long[] deptIds) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
sysDeptService.batchRemove(deptIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ResponseBody
|
||||
public Tree<DeptDO> tree() {
|
||||
Tree<DeptDO> tree = new Tree<DeptDO>();
|
||||
tree = sysDeptService.getTree();
|
||||
return tree;
|
||||
}
|
||||
|
||||
@GetMapping("/treeView")
|
||||
String treeView() {
|
||||
return prefix + "/deptTree";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import com.java2nb.common.annotation.Log;
|
||||
import com.java2nb.common.config.JnConfig;
|
||||
import com.java2nb.common.controller.BaseController;
|
||||
import com.java2nb.common.domain.FileDO;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.service.FileService;
|
||||
import com.java2nb.common.utils.*;
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
import com.java2nb.system.service.MenuService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
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.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class LoginController extends BaseController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
MenuService menuService;
|
||||
@Autowired
|
||||
FileService fileService;
|
||||
@Autowired
|
||||
JnConfig jnConfig;
|
||||
|
||||
|
||||
@Log("请求访问主页")
|
||||
@GetMapping({"","/","/index"})
|
||||
String index(Model model) {
|
||||
List<Tree<MenuDO>> menus = menuService.listMenuTree(getUserId());
|
||||
model.addAttribute("menus", menus);
|
||||
model.addAttribute("name", getUser().getName());
|
||||
FileDO fileDO = fileService.get(getUser().getPicId());
|
||||
if (fileDO != null && fileDO.getUrl() != null) {
|
||||
if (fileService.isExist(fileDO.getUrl())) {
|
||||
model.addAttribute("picUrl", fileDO.getUrl());
|
||||
} else {
|
||||
model.addAttribute("picUrl", "/img/photo_s.jpg");
|
||||
}
|
||||
} else {
|
||||
model.addAttribute("picUrl", "/img/photo_s.jpg");
|
||||
}
|
||||
model.addAttribute("username", getUser().getUsername());
|
||||
return "index";
|
||||
}
|
||||
|
||||
@GetMapping("/login")
|
||||
String login(Model model) {
|
||||
model.addAttribute("username", jnConfig.getUsername());
|
||||
model.addAttribute("password", jnConfig.getPassword());
|
||||
return "login";
|
||||
}
|
||||
|
||||
@Log("登录")
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
R ajaxLogin(String username, String password,String verify,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
//从session中获取随机数
|
||||
String random = (String) request.getSession().getAttribute(RandomValidateCodeUtil.RANDOMCODEKEY);
|
||||
if (StringUtils.isBlank(verify)) {
|
||||
return R.error("请输入验证码");
|
||||
}
|
||||
if (random.equals(verify)) {
|
||||
} else {
|
||||
return R.error("请输入正确的验证码");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("验证码校验失败", e);
|
||||
return R.error("验证码校验失败");
|
||||
}
|
||||
password = MD5Utils.encrypt(username, password);
|
||||
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
try {
|
||||
subject.login(token);
|
||||
return R.ok();
|
||||
} catch (AuthenticationException e) {
|
||||
return R.error("用户或密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
String logout() {
|
||||
ShiroUtils.logout();
|
||||
return "redirect:/login";
|
||||
}
|
||||
|
||||
@GetMapping("/main")
|
||||
String main() {
|
||||
return "main";
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
*/
|
||||
@GetMapping(value = "/getVerify")
|
||||
public void getVerify(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
|
||||
response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expire", 0);
|
||||
RandomValidateCodeUtil randomValidateCode = new RandomValidateCodeUtil();
|
||||
randomValidateCode.getRandcode(request, response);//输出验证码图片方法
|
||||
} catch (Exception e) {
|
||||
logger.error("获取验证码失败>>>> ", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import com.java2nb.common.annotation.Log;
|
||||
import com.java2nb.common.config.Constant;
|
||||
import com.java2nb.common.controller.BaseController;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.utils.R;
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
import com.java2nb.system.service.MenuService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiongxy
|
||||
*/
|
||||
@RequestMapping("/sys/menu")
|
||||
@Controller
|
||||
public class MenuController extends BaseController {
|
||||
String prefix = "system/menu";
|
||||
@Autowired
|
||||
MenuService menuService;
|
||||
|
||||
@RequiresPermissions("sys:menu:menu")
|
||||
@GetMapping()
|
||||
String menu(Model model) {
|
||||
return prefix+"/menu";
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:menu:menu")
|
||||
@RequestMapping("/list")
|
||||
@ResponseBody
|
||||
List<MenuDO> list(@RequestParam Map<String, Object> params) {
|
||||
List<MenuDO> menus = menuService.list(params);
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Log("添加菜单")
|
||||
@RequiresPermissions("sys:menu:add")
|
||||
@GetMapping("/add/{pId}")
|
||||
String add(Model model, @PathVariable("pId") Long pId) {
|
||||
model.addAttribute("pId", pId);
|
||||
if (pId == 0) {
|
||||
model.addAttribute("pName", "根目录");
|
||||
} else {
|
||||
model.addAttribute("pName", menuService.get(pId).getName());
|
||||
}
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
@Log("编辑菜单")
|
||||
@RequiresPermissions("sys:menu:edit")
|
||||
@GetMapping("/edit/{id}")
|
||||
String edit(Model model, @PathVariable("id") Long id) {
|
||||
MenuDO mdo = menuService.get(id);
|
||||
Long pId = mdo.getParentId();
|
||||
model.addAttribute("pId", pId);
|
||||
if (pId == 0) {
|
||||
model.addAttribute("pName", "根目录");
|
||||
} else {
|
||||
model.addAttribute("pName", menuService.get(pId).getName());
|
||||
}
|
||||
model.addAttribute("menu", mdo);
|
||||
return prefix+"/edit";
|
||||
}
|
||||
|
||||
@Log("保存菜单")
|
||||
@RequiresPermissions("sys:menu:add")
|
||||
@PostMapping("/save")
|
||||
@ResponseBody
|
||||
R save(MenuDO menu) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (menuService.save(menu) > 0) {
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.error(1, "保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Log("更新菜单")
|
||||
@RequiresPermissions("sys:menu:edit")
|
||||
@PostMapping("/update")
|
||||
@ResponseBody
|
||||
R update(MenuDO menu) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (menuService.update(menu) > 0) {
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.error(1, "更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Log("删除菜单")
|
||||
@RequiresPermissions("sys:menu:remove")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
R remove(Long id) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (menuService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.error(1, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ResponseBody
|
||||
Tree<MenuDO> tree() {
|
||||
Tree<MenuDO> tree = menuService.getTree();
|
||||
return tree;
|
||||
}
|
||||
|
||||
@GetMapping("/tree/{roleId}")
|
||||
@ResponseBody
|
||||
Tree<MenuDO> tree(@PathVariable("roleId") Long roleId) {
|
||||
Tree<MenuDO> tree = menuService.getTree(roleId);
|
||||
return tree;
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import com.java2nb.common.annotation.Log;
|
||||
import com.java2nb.common.config.Constant;
|
||||
import com.java2nb.common.controller.BaseController;
|
||||
import com.java2nb.common.utils.R;
|
||||
import com.java2nb.system.domain.RoleDO;
|
||||
import com.java2nb.system.service.RoleService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/sys/role")
|
||||
@Controller
|
||||
public class RoleController extends BaseController {
|
||||
String prefix = "system/role";
|
||||
@Autowired
|
||||
RoleService roleService;
|
||||
|
||||
@RequiresPermissions("sys:role:role")
|
||||
@GetMapping()
|
||||
String role() {
|
||||
return prefix + "/role";
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:role:role")
|
||||
@GetMapping("/list")
|
||||
@ResponseBody()
|
||||
List<RoleDO> list() {
|
||||
List<RoleDO> roles = roleService.list();
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Log("添加角色")
|
||||
@RequiresPermissions("sys:role:add")
|
||||
@GetMapping("/add")
|
||||
String add() {
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
@Log("编辑角色")
|
||||
@RequiresPermissions("sys:role:edit")
|
||||
@GetMapping("/edit/{id}")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
RoleDO roleDO = roleService.get(id);
|
||||
model.addAttribute("role", roleDO);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
@Log("保存角色")
|
||||
@RequiresPermissions("sys:role:add")
|
||||
@PostMapping("/save")
|
||||
@ResponseBody()
|
||||
R save(RoleDO role) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (roleService.save(role) > 0) {
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.error(1, "保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Log("更新角色")
|
||||
@RequiresPermissions("sys:role:edit")
|
||||
@PostMapping("/update")
|
||||
@ResponseBody()
|
||||
R update(RoleDO role) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (roleService.update(role) > 0) {
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.error(1, "保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Log("删除角色")
|
||||
@RequiresPermissions("sys:role:remove")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody()
|
||||
R save(Long id) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (roleService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.error(1, "删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:role:batchRemove")
|
||||
@Log("批量删除角色")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
R batchRemove(@RequestParam("ids[]") Long[] ids) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
int r = roleService.batchremove(ids);
|
||||
if (r > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
|
||||
import com.java2nb.system.domain.RoleDataPermDO;
|
||||
import com.java2nb.system.service.RoleDataPermService;
|
||||
import com.java2nb.common.utils.PageBean;
|
||||
import com.java2nb.common.utils.Query;
|
||||
import com.java2nb.common.utils.R;
|
||||
|
||||
/**
|
||||
* 角色与数据权限对应关系
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:32:49
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/system/roleDataPerm")
|
||||
public class RoleDataPermController {
|
||||
@Autowired
|
||||
private RoleDataPermService roleDataPermService;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("system:roleDataPerm:roleDataPerm")
|
||||
String RoleDataPerm() {
|
||||
return "system/roleDataPerm/roleDataPerm";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取角色与数据权限对应关系列表", notes = "获取角色与数据权限对应关系列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("system:roleDataPerm:roleDataPerm")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
//查询列表数据
|
||||
Query query = new Query(params);
|
||||
List<RoleDataPermDO> roleDataPermList = roleDataPermService.list(query);
|
||||
int total = roleDataPermService.count(query);
|
||||
PageBean pageBean = new PageBean(roleDataPermList, total);
|
||||
return R.ok().put("data", pageBean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增角色与数据权限对应关系页面", notes = "新增角色与数据权限对应关系页面")
|
||||
@GetMapping("/add")
|
||||
@RequiresPermissions("system:roleDataPerm:add")
|
||||
String add() {
|
||||
return "system/roleDataPerm/add";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改角色与数据权限对应关系页面", notes = "修改角色与数据权限对应关系页面")
|
||||
@GetMapping("/edit/{id}")
|
||||
@RequiresPermissions("system:roleDataPerm:edit")
|
||||
String edit(@PathVariable("id") Long id, Model model) {
|
||||
RoleDataPermDO roleDataPerm = roleDataPermService.get(id);
|
||||
model.addAttribute("roleDataPerm", roleDataPerm);
|
||||
return "system/roleDataPerm/edit";
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看角色与数据权限对应关系页面", notes = "查看角色与数据权限对应关系页面")
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequiresPermissions("system:roleDataPerm:detail")
|
||||
String detail(@PathVariable("id") Long id, Model model) {
|
||||
RoleDataPermDO roleDataPerm = roleDataPermService.get(id);
|
||||
model.addAttribute("roleDataPerm", roleDataPerm);
|
||||
return "system/roleDataPerm/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@ApiOperation(value = "新增角色与数据权限对应关系", notes = "新增角色与数据权限对应关系")
|
||||
@ResponseBody
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:roleDataPerm:add")
|
||||
public R save( RoleDataPermDO roleDataPerm) {
|
||||
if (roleDataPermService.save(roleDataPerm) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@ApiOperation(value = "修改角色与数据权限对应关系", notes = "修改角色与数据权限对应关系")
|
||||
@ResponseBody
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("system:roleDataPerm:edit")
|
||||
public R update( RoleDataPermDO roleDataPerm) {
|
||||
roleDataPermService.update(roleDataPerm);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "删除角色与数据权限对应关系", notes = "删除角色与数据权限对应关系")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("system:roleDataPerm:remove")
|
||||
public R remove( Long id) {
|
||||
if (roleDataPermService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@ApiOperation(value = "批量删除角色与数据权限对应关系", notes = "批量删除角色与数据权限对应关系")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
@RequiresPermissions("system:roleDataPerm:batchRemove")
|
||||
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||
roleDataPermService.batchRemove(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.java2nb.common.utils.R;
|
||||
import com.java2nb.system.domain.UserOnline;
|
||||
import com.java2nb.system.service.SessionService;
|
||||
|
||||
@RequestMapping("/sys/online")
|
||||
@Controller
|
||||
public class SessionController {
|
||||
@Autowired
|
||||
SessionService sessionService;
|
||||
|
||||
@GetMapping()
|
||||
public String online() {
|
||||
return "system/online/online";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/list")
|
||||
public List<UserOnline> list() {
|
||||
return sessionService.list();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/forceLogout/{sessionId}")
|
||||
public R forceLogout(@PathVariable("sessionId") String sessionId, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
sessionService.forceLogout(sessionId);
|
||||
return R.ok();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/sessionList")
|
||||
public Collection<Session> sessionList() {
|
||||
return sessionService.sessionList();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,244 @@
|
||||
package com.java2nb.system.controller;
|
||||
|
||||
import com.java2nb.common.annotation.Log;
|
||||
import com.java2nb.common.config.Constant;
|
||||
import com.java2nb.common.controller.BaseController;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.service.DictService;
|
||||
import com.java2nb.common.utils.*;
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
import com.java2nb.system.domain.RoleDO;
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import com.java2nb.system.service.RoleService;
|
||||
import com.java2nb.system.service.UserService;
|
||||
import com.java2nb.system.vo.UserVO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("/sys/user")
|
||||
@Controller
|
||||
public class UserController extends BaseController {
|
||||
private String prefix="system/user" ;
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
RoleService roleService;
|
||||
@Autowired
|
||||
DictService dictService;
|
||||
@Autowired
|
||||
RedisUtil redisUtil;
|
||||
|
||||
@RequiresPermissions("sys:user:user")
|
||||
@GetMapping("")
|
||||
String user(Model model) {
|
||||
return prefix + "/user";
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ResponseBody
|
||||
PageBean list(@RequestParam Map<String, Object> params) {
|
||||
// 查询列表数据
|
||||
Query query = new Query(params);
|
||||
List<UserDO> sysUserList = userService.list(query);
|
||||
int total = userService.count(query);
|
||||
PageBean pageUtil = new PageBean(sysUserList, total);
|
||||
return pageUtil;
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:user:add")
|
||||
@Log("添加用户")
|
||||
@GetMapping("/add")
|
||||
String add(Model model) {
|
||||
List<RoleDO> roles = roleService.list();
|
||||
model.addAttribute("roles", roles);
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:user:edit")
|
||||
@Log("编辑用户")
|
||||
@GetMapping("/edit/{id}")
|
||||
String edit(Model model, @PathVariable("id") Long id) {
|
||||
UserDO userDO = userService.get(id);
|
||||
model.addAttribute("user", userDO);
|
||||
List<RoleDO> roles = roleService.list(id);
|
||||
model.addAttribute("roles", roles);
|
||||
return prefix+"/edit";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(MD5Utils.encrypt("admin", "admin"));
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:user:add")
|
||||
@Log("保存用户")
|
||||
@PostMapping("/save")
|
||||
@ResponseBody
|
||||
R save(UserDO user) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
user.setPassword(MD5Utils.encrypt(user.getUsername(), user.getPassword()));
|
||||
if (userService.save(user) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:user:edit")
|
||||
@Log("更新用户")
|
||||
@PostMapping("/update")
|
||||
@ResponseBody
|
||||
R update(UserDO user) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (userService.update(user) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
|
||||
@RequiresPermissions("sys:user:edit")
|
||||
@Log("更新用户")
|
||||
@PostMapping("/updatePeronal")
|
||||
@ResponseBody
|
||||
R updatePeronal(UserDO user) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (userService.updatePersonal(user) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
|
||||
@RequiresPermissions("sys:user:remove")
|
||||
@Log("删除用户")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
R remove(Long id) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
if (userService.remove(id) > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:user:batchRemove")
|
||||
@Log("批量删除用户")
|
||||
@PostMapping("/batchRemove")
|
||||
@ResponseBody
|
||||
R batchRemove(@RequestParam("ids[]") Long[] userIds) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
int r = userService.batchremove(userIds);
|
||||
if (r > 0) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error();
|
||||
}
|
||||
|
||||
@PostMapping("/exit")
|
||||
@ResponseBody
|
||||
boolean exit(@RequestParam Map<String, Object> params) {
|
||||
// 存在,不通过,false
|
||||
return !userService.exit(params);
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:user:resetPwd")
|
||||
@Log("请求更改用户密码")
|
||||
@GetMapping("/resetPwd/{id}")
|
||||
String resetPwd(@PathVariable("id") Long userId, Model model) {
|
||||
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setUserId(userId);
|
||||
model.addAttribute("user", userDO);
|
||||
return prefix + "/reset_pwd";
|
||||
}
|
||||
|
||||
@Log("提交更改用户密码")
|
||||
@PostMapping("/resetPwd")
|
||||
@ResponseBody
|
||||
R resetPwd(UserVO userVO) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
try{
|
||||
userService.resetPwd(userVO,getUser());
|
||||
return R.ok();
|
||||
}catch (Exception e){
|
||||
return R.error(1,e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@RequiresPermissions("sys:user:resetPwd")
|
||||
@Log("admin提交更改用户密码")
|
||||
@PostMapping("/adminResetPwd")
|
||||
@ResponseBody
|
||||
R adminResetPwd(UserVO userVO) {
|
||||
if (Constant.DEMO_ACCOUNT.equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
try{
|
||||
userService.adminResetPwd(userVO);
|
||||
return R.ok();
|
||||
}catch (Exception e){
|
||||
return R.error(1,e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("/tree")
|
||||
@ResponseBody
|
||||
public Tree<DeptDO> tree() {
|
||||
Tree<DeptDO> tree = new Tree<DeptDO>();
|
||||
tree = userService.getTree();
|
||||
return tree;
|
||||
}
|
||||
|
||||
@GetMapping("/treeView")
|
||||
String treeView() {
|
||||
return prefix + "/userTree";
|
||||
}
|
||||
|
||||
@GetMapping("/personal")
|
||||
String personal(Model model) {
|
||||
UserDO userDO = userService.get(getUserId());
|
||||
model.addAttribute("user",userDO);
|
||||
model.addAttribute("hobbyList",dictService.getHobbyList(userDO));
|
||||
model.addAttribute("sexList",dictService.getSexList());
|
||||
return prefix + "/personal";
|
||||
}
|
||||
@ResponseBody
|
||||
@PostMapping("/uploadImg")
|
||||
R uploadImg(@RequestParam("avatar_file") MultipartFile file, String avatar_data, HttpServletRequest request) {
|
||||
if ("test".equals(getUsername())) {
|
||||
return R.error(1, "演示系统不允许修改,完整体验请部署程序");
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
result = userService.updatePersonalImg(file, avatar_data, getUserId());
|
||||
} catch (Exception e) {
|
||||
return R.error("更新图像失败!");
|
||||
}
|
||||
if(result!=null && result.size()>0){
|
||||
return R.ok(result);
|
||||
}else {
|
||||
return R.error("更新图像失败!");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.DataPermDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 数据权限管理
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:40:03
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataPermDao {
|
||||
|
||||
DataPermDO get(Long id);
|
||||
|
||||
List<DataPermDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(DataPermDO dataPerm);
|
||||
|
||||
int update(DataPermDO dataPerm);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<DataPermDO> listModuleName();
|
||||
|
||||
List<DataPermDO> selectDataPermsByUserId(@Param("userId") Long userId);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-03 15:35:39
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeptDao {
|
||||
|
||||
DeptDO get(Long deptId);
|
||||
|
||||
List<DeptDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(DeptDO dept);
|
||||
|
||||
int update(DeptDO dept);
|
||||
|
||||
int remove(Long deptId);
|
||||
|
||||
int batchRemove(Long[] deptIds);
|
||||
|
||||
Long[] listParentDept();
|
||||
|
||||
int getDeptUserNumber(Long deptId);
|
||||
|
||||
String getDeptIdsByParentId(@Param("deptId") Long deptId);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-03 09:45:09
|
||||
*/
|
||||
@Mapper
|
||||
public interface MenuDao {
|
||||
|
||||
MenuDO get(Long menuId);
|
||||
|
||||
List<MenuDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(MenuDO menu);
|
||||
|
||||
int update(MenuDO menu);
|
||||
|
||||
int remove(Long menuId);
|
||||
|
||||
int batchRemove(Long[] menuIds);
|
||||
|
||||
List<MenuDO> listMenuByUserId(Long id);
|
||||
|
||||
List<String> listUserPerms(Long id);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.RoleDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-02 20:24:47
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleDao {
|
||||
|
||||
RoleDO get(Long roleId);
|
||||
|
||||
List<RoleDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(RoleDO role);
|
||||
|
||||
int update(RoleDO role);
|
||||
|
||||
int remove(Long roleId);
|
||||
|
||||
int batchRemove(Long[] roleIds);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.RoleDataPermDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 角色与数据权限对应关系
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:32:49
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleDataPermDao {
|
||||
|
||||
RoleDataPermDO get(Long id);
|
||||
|
||||
List<RoleDataPermDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(RoleDataPermDO roleDataPerm);
|
||||
|
||||
int update(RoleDataPermDO roleDataPerm);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
void removeByRoleId(Long roleId);
|
||||
|
||||
void batchSave(List<RoleDataPermDO> rps);
|
||||
|
||||
List<Long> listPermIdByRoleId(Long roleId);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.RoleMenuDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 角色与菜单对应关系
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-03 11:08:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMenuDao {
|
||||
|
||||
RoleMenuDO get(Long id);
|
||||
|
||||
List<RoleMenuDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(RoleMenuDO roleMenu);
|
||||
|
||||
int update(RoleMenuDO roleMenu);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<Long> listMenuIdByRoleId(Long roleId);
|
||||
|
||||
int removeByRoleId(Long roleId);
|
||||
|
||||
int removeByMenuId(Long menuId);
|
||||
|
||||
int batchSave(List<RoleMenuDO> list);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-03 09:45:11
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserDao {
|
||||
|
||||
UserDO get(Long userId);
|
||||
|
||||
List<UserDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(UserDO user);
|
||||
|
||||
int update(UserDO user);
|
||||
|
||||
int remove(Long userId);
|
||||
|
||||
int batchRemove(Long[] userIds);
|
||||
|
||||
Long[] listAllDept();
|
||||
|
||||
List<UserDO> listByPerm(Map<String, Object> map);
|
||||
|
||||
int countByPerm(Map<String,Object> map);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.java2nb.system.dao;
|
||||
|
||||
import com.java2nb.system.domain.UserRoleDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 用户与角色对应关系
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-10-03 11:08:59
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserRoleDao {
|
||||
|
||||
UserRoleDO get(Long id);
|
||||
|
||||
List<UserRoleDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(UserRoleDO userRole);
|
||||
|
||||
int update(UserRoleDO userRole);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<Long> listRoleId(Long userId);
|
||||
|
||||
int removeByUserId(Long userId);
|
||||
|
||||
int removeByRoleId(Long roleId);
|
||||
|
||||
int batchSave(List<UserRoleDO> list);
|
||||
|
||||
int batchRemoveByUserId(Long[] ids);
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
||||
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 数据权限管理
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:40:03
|
||||
*/
|
||||
public class DataPermDO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
//
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long id;
|
||||
//权限名称
|
||||
private String name;
|
||||
//数据表名称
|
||||
private String tableName;
|
||||
//所属模块
|
||||
private String moduleName;
|
||||
//用户权限控制属性名
|
||||
private String crlAttrName;
|
||||
//数据表权限控制列名
|
||||
private String crlColumnName;
|
||||
//权限code,all_开头表示查看所有数据的权限,sup_开头表示查看下级数据的权限,own_开头表示查看本级数据的权限
|
||||
private String permCode;
|
||||
//排序
|
||||
private Integer orderNum;
|
||||
//创建时间
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
//修改时间
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtModified;
|
||||
|
||||
/**
|
||||
* 设置:
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* 获取:
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* 设置:权限名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* 获取:权限名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* 设置:数据表名称
|
||||
*/
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
/**
|
||||
* 获取:数据表名称
|
||||
*/
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
/**
|
||||
* 设置:所属模块
|
||||
*/
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
/**
|
||||
* 获取:所属模块
|
||||
*/
|
||||
public String getModuleName() {
|
||||
return moduleName;
|
||||
}
|
||||
/**
|
||||
* 设置:用户权限控制属性名
|
||||
*/
|
||||
public void setCrlAttrName(String crlAttrName) {
|
||||
this.crlAttrName = crlAttrName;
|
||||
}
|
||||
/**
|
||||
* 获取:用户权限控制属性名
|
||||
*/
|
||||
public String getCrlAttrName() {
|
||||
return crlAttrName;
|
||||
}
|
||||
/**
|
||||
* 设置:数据表权限控制列名
|
||||
*/
|
||||
public void setCrlColumnName(String crlColumnName) {
|
||||
this.crlColumnName = crlColumnName;
|
||||
}
|
||||
/**
|
||||
* 获取:数据表权限控制列名
|
||||
*/
|
||||
public String getCrlColumnName() {
|
||||
return crlColumnName;
|
||||
}
|
||||
/**
|
||||
* 设置:权限code,all_开头表示查看所有数据的权限,sup_开头表示查看下级数据的权限,own_开头表示查看本级数据的权限
|
||||
*/
|
||||
public void setPermCode(String permCode) {
|
||||
this.permCode = permCode;
|
||||
}
|
||||
/**
|
||||
* 获取:权限code,all_开头表示查看所有数据的权限,sup_开头表示查看下级数据的权限,own_开头表示查看本级数据的权限
|
||||
*/
|
||||
public String getPermCode() {
|
||||
return permCode;
|
||||
}
|
||||
/**
|
||||
* 设置:排序
|
||||
*/
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
/**
|
||||
* 获取:排序
|
||||
*/
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
/**
|
||||
* 设置:创建时间
|
||||
*/
|
||||
public void setGmtCreate(Date gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
/**
|
||||
* 获取:创建时间
|
||||
*/
|
||||
public Date getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
/**
|
||||
* 设置:修改时间
|
||||
*/
|
||||
public void setGmtModified(Date gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
/**
|
||||
* 获取:修改时间
|
||||
*/
|
||||
public Date getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-09-27 14:28:36
|
||||
*/
|
||||
public class DeptDO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//
|
||||
private Long deptId;
|
||||
//上级部门ID,一级部门为0
|
||||
private Long parentId;
|
||||
//部门名称
|
||||
private String name;
|
||||
//排序
|
||||
private Integer orderNum;
|
||||
//是否删除 -1:已删除 0:正常
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 设置:
|
||||
*/
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
/**
|
||||
* 获取:
|
||||
*/
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
/**
|
||||
* 设置:上级部门ID,一级部门为0
|
||||
*/
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
/**
|
||||
* 获取:上级部门ID,一级部门为0
|
||||
*/
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
/**
|
||||
* 设置:部门名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* 获取:部门名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* 设置:排序
|
||||
*/
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
/**
|
||||
* 获取:排序
|
||||
*/
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
/**
|
||||
* 设置:是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
/**
|
||||
* 获取:是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeptDO{" +
|
||||
"deptId=" + deptId +
|
||||
", parentId=" + parentId +
|
||||
", name='" + name + '\'' +
|
||||
", orderNum=" + orderNum +
|
||||
", delFlag=" + delFlag +
|
||||
'}';
|
||||
}
|
||||
}
|
184
novel-admin/src/main/java/com/java2nb/system/domain/MenuDO.java
Normal file
184
novel-admin/src/main/java/com/java2nb/system/domain/MenuDO.java
Normal file
@ -0,0 +1,184 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class MenuDO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//
|
||||
private Long menuId;
|
||||
// 父菜单ID,一级菜单为0
|
||||
private Long parentId;
|
||||
// 菜单名称
|
||||
private String name;
|
||||
// 菜单URL
|
||||
private String url;
|
||||
// 授权(多个用逗号分隔,如:user:list,user:create)
|
||||
private String perms;
|
||||
// 类型 0:目录 1:菜单 2:按钮
|
||||
private Integer type;
|
||||
// 菜单图标
|
||||
private String icon;
|
||||
// 排序
|
||||
private Integer orderNum;
|
||||
// 创建时间
|
||||
private Date gmtCreate;
|
||||
// 修改时间
|
||||
private Date gmtModified;
|
||||
|
||||
/**
|
||||
* 设置:
|
||||
*/
|
||||
public void setMenuId(Long menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:
|
||||
*/
|
||||
public Long getMenuId() {
|
||||
return menuId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:父菜单ID,一级菜单为0
|
||||
*/
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:父菜单ID,一级菜单为0
|
||||
*/
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:菜单名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:菜单名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:菜单URL
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:菜单URL
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:授权(多个用逗号分隔,如:user:list,user:create)
|
||||
*/
|
||||
public void setPerms(String perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:授权(多个用逗号分隔,如:user:list,user:create)
|
||||
*/
|
||||
public String getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:类型 0:目录 1:菜单 2:按钮
|
||||
*/
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:类型 0:目录 1:菜单 2:按钮
|
||||
*/
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:菜单图标
|
||||
*/
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:菜单图标
|
||||
*/
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:排序
|
||||
*/
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:排序
|
||||
*/
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:创建时间
|
||||
*/
|
||||
public void setGmtCreate(Date gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:创建时间
|
||||
*/
|
||||
public Date getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:修改时间
|
||||
*/
|
||||
public void setGmtModified(Date gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:修改时间
|
||||
*/
|
||||
public Date getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MenuDO{" +
|
||||
"menuId=" + menuId +
|
||||
", parentId=" + parentId +
|
||||
", name='" + name + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", perms='" + perms + '\'' +
|
||||
", type=" + type +
|
||||
", icon='" + icon + '\'' +
|
||||
", orderNum=" + orderNum +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModified=" + gmtModified +
|
||||
'}';
|
||||
}
|
||||
}
|
104
novel-admin/src/main/java/com/java2nb/system/domain/RoleDO.java
Normal file
104
novel-admin/src/main/java/com/java2nb/system/domain/RoleDO.java
Normal file
@ -0,0 +1,104 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
public class RoleDO {
|
||||
|
||||
private Long roleId;
|
||||
private String roleName;
|
||||
private String roleSign;
|
||||
private String remark;
|
||||
private Long userIdCreate;
|
||||
private Timestamp gmtCreate;
|
||||
private Timestamp gmtModified;
|
||||
private List<Long> menuIds;
|
||||
|
||||
private List<Long> permIds;
|
||||
|
||||
public List<Long> getPermIds() {
|
||||
return permIds;
|
||||
}
|
||||
|
||||
public void setPermIds(List<Long> permIds) {
|
||||
this.permIds = permIds;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getRoleSign() {
|
||||
return roleSign;
|
||||
}
|
||||
|
||||
public void setRoleSign(String roleSign) {
|
||||
this.roleSign = roleSign;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Long getUserIdCreate() {
|
||||
return userIdCreate;
|
||||
}
|
||||
|
||||
public void setUserIdCreate(Long userIdCreate) {
|
||||
this.userIdCreate = userIdCreate;
|
||||
}
|
||||
|
||||
public Timestamp getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Timestamp gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public Timestamp getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
|
||||
public void setGmtModified(Timestamp gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public List<Long> getMenuIds() {
|
||||
return menuIds;
|
||||
}
|
||||
|
||||
public void setMenuIds(List<Long> menuIds) {
|
||||
this.menuIds = menuIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RoleDO{" +
|
||||
"roleId=" + roleId +
|
||||
", roleName='" + roleName + '\'' +
|
||||
", roleSign='" + roleSign + '\'' +
|
||||
", remark='" + remark + '\'' +
|
||||
", userIdCreate=" + userIdCreate +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModified=" + gmtModified +
|
||||
", menuIds=" + menuIds +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
||||
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 角色与数据权限对应关系
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:32:49
|
||||
*/
|
||||
public class RoleDataPermDO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
//
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long id;
|
||||
//角色ID
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long roleId;
|
||||
//权限ID
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long permId;
|
||||
|
||||
/**
|
||||
* 设置:
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* 获取:
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* 设置:角色ID
|
||||
*/
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
/**
|
||||
* 获取:角色ID
|
||||
*/
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
/**
|
||||
* 设置:权限ID
|
||||
*/
|
||||
public void setPermId(Long permId) {
|
||||
this.permId = permId;
|
||||
}
|
||||
/**
|
||||
* 获取:权限ID
|
||||
*/
|
||||
public Long getPermId() {
|
||||
return permId;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
public class RoleMenuDO {
|
||||
private Long id;
|
||||
private Long roleId;
|
||||
private Long menuId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
public Long getMenuId() {
|
||||
return menuId;
|
||||
}
|
||||
public void setMenuId(Long menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RoleMenuDO{" +
|
||||
"id=" + id +
|
||||
", roleId=" + roleId +
|
||||
", menuId=" + menuId +
|
||||
'}';
|
||||
}
|
||||
}
|
269
novel-admin/src/main/java/com/java2nb/system/domain/UserDO.java
Normal file
269
novel-admin/src/main/java/com/java2nb/system/domain/UserDO.java
Normal file
@ -0,0 +1,269 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserDO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//
|
||||
private Long userId;
|
||||
// 用户名
|
||||
private String username;
|
||||
// 用户真实姓名
|
||||
private String name;
|
||||
// 密码
|
||||
private String password;
|
||||
// 部门
|
||||
private Long deptId;
|
||||
//下级部门
|
||||
private String supDeptIds;
|
||||
private String deptName;
|
||||
// 邮箱
|
||||
private String email;
|
||||
// 手机号
|
||||
private String mobile;
|
||||
// 状态 0:禁用,1:正常
|
||||
private Integer status;
|
||||
// 创建用户id
|
||||
private Long userIdCreate;
|
||||
// 创建时间
|
||||
private Date gmtCreate;
|
||||
// 修改时间
|
||||
private Date gmtModified;
|
||||
//角色
|
||||
private List<Long> roleIds;
|
||||
//数据权限(table_name->dataPerms)
|
||||
private Map<String,List<DataPermDO>> dataPerms;
|
||||
//性别
|
||||
private Long sex;
|
||||
//出身日期
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date birth;
|
||||
//图片ID
|
||||
private Long picId;
|
||||
//现居住地
|
||||
private String liveAddress;
|
||||
//爱好
|
||||
private String hobby;
|
||||
//省份
|
||||
private String province;
|
||||
//所在城市
|
||||
private String city;
|
||||
//所在地区
|
||||
private String district;
|
||||
|
||||
public String getSupDeptIds() {
|
||||
return supDeptIds;
|
||||
}
|
||||
|
||||
public void setSupDeptIds(String supDeptIds) {
|
||||
this.supDeptIds = supDeptIds;
|
||||
}
|
||||
|
||||
public Map<String, List<DataPermDO>> getDataPerms() {
|
||||
return dataPerms;
|
||||
}
|
||||
|
||||
public void setDataPerms(Map<String, List<DataPermDO>> dataPerms) {
|
||||
this.dataPerms = dataPerms;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getUserIdCreate() {
|
||||
return userIdCreate;
|
||||
}
|
||||
|
||||
public void setUserIdCreate(Long userIdCreate) {
|
||||
this.userIdCreate = userIdCreate;
|
||||
}
|
||||
|
||||
public Date getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Date gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public Date getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
|
||||
public void setGmtModified(Date gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public List<Long> getRoleIds() {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(List<Long> roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public Long getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(Long sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public Date getBirth() {
|
||||
return birth;
|
||||
}
|
||||
|
||||
public void setBirth(Date birth) {
|
||||
this.birth = birth;
|
||||
}
|
||||
|
||||
public Long getPicId() {
|
||||
return picId;
|
||||
}
|
||||
|
||||
public void setPicId(Long picId) {
|
||||
this.picId = picId;
|
||||
}
|
||||
|
||||
public String getLiveAddress() {
|
||||
return liveAddress;
|
||||
}
|
||||
|
||||
public void setLiveAddress(String liveAddress) {
|
||||
this.liveAddress = liveAddress;
|
||||
}
|
||||
|
||||
public String getHobby() {
|
||||
return hobby;
|
||||
}
|
||||
|
||||
public void setHobby(String hobby) {
|
||||
this.hobby = hobby;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDO{" +
|
||||
"userId=" + userId +
|
||||
", username='" + username + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", deptId=" + deptId +
|
||||
", deptName='" + deptName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", status=" + status +
|
||||
", userIdCreate=" + userIdCreate +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModified=" + gmtModified +
|
||||
", roleIds=" + roleIds +
|
||||
", sex=" + sex +
|
||||
", birth=" + birth +
|
||||
", picId=" + picId +
|
||||
", liveAddress='" + liveAddress + '\'' +
|
||||
", hobby='" + hobby + '\'' +
|
||||
", province='" + province + '\'' +
|
||||
", city='" + city + '\'' +
|
||||
", district='" + district + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UserOnline {
|
||||
|
||||
/**
|
||||
*/
|
||||
private String id;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户主机地址
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 用户登录时系统IP
|
||||
*/
|
||||
private String systemHost;
|
||||
|
||||
/**
|
||||
* 用户浏览器类型
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 在线状态
|
||||
*/
|
||||
private String status = "on_line";
|
||||
|
||||
/**
|
||||
* session创建时间
|
||||
*/
|
||||
private Date startTimestamp;
|
||||
/**
|
||||
* session最后访问时间
|
||||
*/
|
||||
private Date lastAccessTime;
|
||||
|
||||
/**
|
||||
* 超时时间
|
||||
*/
|
||||
private Long timeout;
|
||||
|
||||
/**
|
||||
* 备份的当前用户会话
|
||||
*/
|
||||
private String onlineSession;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getStartTimestamp() {
|
||||
return startTimestamp;
|
||||
}
|
||||
|
||||
public void setStartTimestamp(Date startTimestamp) {
|
||||
this.startTimestamp = startTimestamp;
|
||||
}
|
||||
|
||||
public Date getLastAccessTime() {
|
||||
return lastAccessTime;
|
||||
}
|
||||
|
||||
public void setLastAccessTime(Date lastAccessTime) {
|
||||
this.lastAccessTime = lastAccessTime;
|
||||
}
|
||||
|
||||
public Long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(Long timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
public void setUserAgent(String userAgent) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOnlineSession() {
|
||||
return onlineSession;
|
||||
}
|
||||
|
||||
public void setOnlineSession(String onlineSession) {
|
||||
this.onlineSession = onlineSession;
|
||||
}
|
||||
|
||||
|
||||
public String getSystemHost() {
|
||||
return systemHost;
|
||||
}
|
||||
|
||||
public void setSystemHost(String systemHost) {
|
||||
this.systemHost = systemHost;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
public class UserRoleDO {
|
||||
private Long id;
|
||||
private Long userId;
|
||||
private Long roleId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserRoleDO{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", roleId=" + roleId +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.java2nb.system.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xiongxy
|
||||
* @version V1.0
|
||||
*/
|
||||
public class UserToken implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long userId;
|
||||
private String username;
|
||||
private String name;
|
||||
private String password;
|
||||
private Long deptId;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import com.java2nb.common.domain.DictDO;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.system.domain.DataPermDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据权限管理
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:40:03
|
||||
*/
|
||||
public interface DataPermService {
|
||||
|
||||
DataPermDO get(Long id);
|
||||
|
||||
List<DataPermDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(DataPermDO dataPerm);
|
||||
|
||||
int update(DataPermDO dataPerm);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<DataPermDO> listModuleName();
|
||||
|
||||
Tree<DataPermDO> getTree();
|
||||
|
||||
Tree<DataPermDO> getTree(Long roleId);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-09-27 14:28:36
|
||||
*/
|
||||
public interface DeptService {
|
||||
|
||||
DeptDO get(Long deptId);
|
||||
|
||||
List<DeptDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(DeptDO sysDept);
|
||||
|
||||
int update(DeptDO sysDept);
|
||||
|
||||
int remove(Long deptId);
|
||||
|
||||
int batchRemove(Long[] deptIds);
|
||||
|
||||
Tree<DeptDO> getTree();
|
||||
|
||||
boolean checkDeptHasUser(Long deptId);
|
||||
|
||||
List<Long> listChildrenIds(Long parentId);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
|
||||
@Service
|
||||
public interface MenuService {
|
||||
Tree<MenuDO> getSysMenuTree(Long id);
|
||||
|
||||
List<Tree<MenuDO>> listMenuTree(Long id);
|
||||
|
||||
Tree<MenuDO> getTree();
|
||||
|
||||
Tree<MenuDO> getTree(Long id);
|
||||
|
||||
List<MenuDO> list(Map<String, Object> params);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int save(MenuDO menu);
|
||||
|
||||
int update(MenuDO menu);
|
||||
|
||||
MenuDO get(Long id);
|
||||
|
||||
Set<String> listPerms(Long userId);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import com.java2nb.system.domain.RoleDataPermDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 角色与数据权限对应关系
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2019-11-25 11:32:49
|
||||
*/
|
||||
public interface RoleDataPermService {
|
||||
|
||||
RoleDataPermDO get(Long id);
|
||||
|
||||
List<RoleDataPermDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(RoleDataPermDO roleDataPerm);
|
||||
|
||||
int update(RoleDataPermDO roleDataPerm);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.system.domain.RoleDO;
|
||||
|
||||
@Service
|
||||
public interface RoleService {
|
||||
|
||||
RoleDO get(Long id);
|
||||
|
||||
List<RoleDO> list();
|
||||
|
||||
int save(RoleDO role);
|
||||
|
||||
int update(RoleDO role);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
List<RoleDO> list(Long userId);
|
||||
|
||||
int batchremove(Long[] ids);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.security.Principal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.system.domain.UserOnline;
|
||||
|
||||
@Service
|
||||
public interface SessionService {
|
||||
List<UserOnline> list();
|
||||
|
||||
List<UserDO> listOnlineUser();
|
||||
|
||||
Collection<Session> sessionList();
|
||||
|
||||
boolean forceLogout(String sessionId);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.java2nb.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.java2nb.system.vo.UserVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
public interface UserService {
|
||||
UserDO get(Long id);
|
||||
|
||||
List<UserDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(UserDO user);
|
||||
|
||||
int update(UserDO user);
|
||||
|
||||
int remove(Long userId);
|
||||
|
||||
int batchremove(Long[] userIds);
|
||||
|
||||
boolean exit(Map<String, Object> params);
|
||||
|
||||
Set<String> listRoles(Long userId);
|
||||
|
||||
int resetPwd(UserVO userVO,UserDO userDO) throws Exception;
|
||||
int adminResetPwd(UserVO userVO) throws Exception;
|
||||
Tree<DeptDO> getTree();
|
||||
|
||||
/**
|
||||
* 更新个人信息
|
||||
* @param userDO
|
||||
* @return
|
||||
*/
|
||||
int updatePersonal(UserDO userDO);
|
||||
|
||||
/**
|
||||
* 更新个人图片
|
||||
* @param file 图片
|
||||
* @param avatar_data 裁剪信息
|
||||
* @param userId 用户ID
|
||||
* @throws Exception
|
||||
*/
|
||||
Map<String, Object> updatePersonalImg(MultipartFile file, String avatar_data, Long userId) throws Exception;
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
import com.java2nb.common.domain.DictDO;
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.utils.BuildTree;
|
||||
import com.java2nb.common.utils.IdWorker;
|
||||
import com.java2nb.system.dao.RoleDataPermDao;
|
||||
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;
|
||||
|
||||
import com.java2nb.system.dao.DataPermDao;
|
||||
import com.java2nb.system.domain.DataPermDO;
|
||||
import com.java2nb.system.service.DataPermService;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
public class DataPermServiceImpl implements DataPermService {
|
||||
@Autowired
|
||||
private DataPermDao dataPermDao;
|
||||
|
||||
@Autowired
|
||||
private RoleDataPermDao roleDataPermDao;
|
||||
|
||||
@Override
|
||||
public DataPermDO get(Long id){
|
||||
return dataPermDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataPermDO> list(Map<String, Object> map){
|
||||
return dataPermDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map){
|
||||
return dataPermDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(DataPermDO dataPerm){
|
||||
return dataPermDao.save(dataPerm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(DataPermDO dataPerm){
|
||||
return dataPermDao.update(dataPerm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return dataPermDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return dataPermDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataPermDO> listModuleName() {
|
||||
return dataPermDao.listModuleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree<DataPermDO> getTree() {
|
||||
List<Tree<DataPermDO>> trees = new ArrayList<Tree<DataPermDO>>();
|
||||
List<DataPermDO> permDOs = dataPermDao.list(new HashMap<>(16));
|
||||
Map<String,String> topTree = new HashMap<>();
|
||||
for (DataPermDO permDO : permDOs) {
|
||||
Tree<DataPermDO> tree = new Tree<>();
|
||||
tree.setId(permDO.getId().toString());
|
||||
if(!topTree.containsKey(permDO.getModuleName())){
|
||||
Tree<DataPermDO> parentTree = new Tree<>();
|
||||
String id = new IdWorker().nextId()+"";
|
||||
parentTree.setId(id);
|
||||
parentTree.setParentId(0+"");
|
||||
parentTree.setText(permDO.getModuleName());
|
||||
topTree.put(permDO.getModuleName(),id);
|
||||
trees.add(parentTree);
|
||||
}
|
||||
tree.setParentId(topTree.get(permDO.getModuleName()));
|
||||
tree.setText(permDO.getName());
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<DataPermDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree<DataPermDO> getTree(Long roleId) {
|
||||
List<Tree<DataPermDO>> trees = new ArrayList<Tree<DataPermDO>>();
|
||||
List<DataPermDO> permDOs = dataPermDao.list(new HashMap<>(16));
|
||||
List<Long> permIds = roleDataPermDao.listPermIdByRoleId(roleId);
|
||||
Map<String,String> topTree = new HashMap<>();
|
||||
for (DataPermDO permDO : permDOs) {
|
||||
Tree<DataPermDO> tree = new Tree<>();
|
||||
tree.setId(permDO.getId().toString());
|
||||
if(!topTree.containsKey(permDO.getModuleName())){
|
||||
Tree<DataPermDO> parentTree = new Tree<>();
|
||||
String id = new IdWorker().nextId()+"";
|
||||
parentTree.setId(id);
|
||||
parentTree.setParentId(0+"");
|
||||
parentTree.setText(permDO.getModuleName());
|
||||
topTree.put(permDO.getModuleName(),id);
|
||||
trees.add(parentTree);
|
||||
}
|
||||
tree.setParentId(topTree.get(permDO.getModuleName()));
|
||||
tree.setText(permDO.getName());
|
||||
Map<String, Object> state = new HashMap<>(16);
|
||||
if (permIds.contains(permDO.getId())) {
|
||||
state.put("selected", true);
|
||||
} else {
|
||||
state.put("selected", false);
|
||||
}
|
||||
tree.setState(state);
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<DataPermDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
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;
|
||||
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.utils.BuildTree;
|
||||
import com.java2nb.system.dao.DeptDao;
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
import com.java2nb.system.service.DeptService;
|
||||
|
||||
|
||||
@Service
|
||||
public class DeptServiceImpl implements DeptService {
|
||||
@Autowired
|
||||
private DeptDao sysDeptMapper;
|
||||
|
||||
@Override
|
||||
public DeptDO get(Long deptId) {
|
||||
return sysDeptMapper.get(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDO> list(Map<String, Object> map) {
|
||||
return sysDeptMapper.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return sysDeptMapper.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(DeptDO sysDept) {
|
||||
return sysDeptMapper.save(sysDept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(DeptDO sysDept) {
|
||||
return sysDeptMapper.update(sysDept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long deptId) {
|
||||
return sysDeptMapper.remove(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] deptIds) {
|
||||
return sysDeptMapper.batchRemove(deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree<DeptDO> getTree() {
|
||||
List<Tree<DeptDO>> trees = new ArrayList<Tree<DeptDO>>();
|
||||
List<DeptDO> sysDepts = sysDeptMapper.list(new HashMap<String, Object>(16));
|
||||
for (DeptDO sysDept : sysDepts) {
|
||||
Tree<DeptDO> tree = new Tree<DeptDO>();
|
||||
tree.setId(sysDept.getDeptId().toString());
|
||||
tree.setParentId(sysDept.getParentId().toString());
|
||||
tree.setText(sysDept.getName());
|
||||
Map<String, Object> state = new HashMap<>(16);
|
||||
state.put("opened", true);
|
||||
tree.setState(state);
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<DeptDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkDeptHasUser(Long deptId) {
|
||||
// TODO Auto-generated method stub
|
||||
//查询部门以及此部门的下级部门
|
||||
int result = sysDeptMapper.getDeptUserNumber(deptId);
|
||||
return result == 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listChildrenIds(Long parentId) {
|
||||
List<DeptDO> deptDOS = list(null);
|
||||
return treeMenuList(deptDOS, parentId);
|
||||
}
|
||||
|
||||
List<Long> treeMenuList(List<DeptDO> menuList, long pid) {
|
||||
List<Long> childIds = new ArrayList<>();
|
||||
for (DeptDO mu : menuList) {
|
||||
//遍历出父id等于参数的id,add进子节点集合
|
||||
if (mu.getParentId() == pid) {
|
||||
//递归遍历下一级
|
||||
treeMenuList(menuList, mu.getDeptId());
|
||||
childIds.add(mu.getDeptId());
|
||||
}
|
||||
}
|
||||
return childIds;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.common.utils.BuildTree;
|
||||
import com.java2nb.system.dao.MenuDao;
|
||||
import com.java2nb.system.dao.RoleMenuDao;
|
||||
import com.java2nb.system.domain.MenuDO;
|
||||
import com.java2nb.system.service.MenuService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true,rollbackFor = Exception.class)
|
||||
public class MenuServiceImpl implements MenuService {
|
||||
@Autowired
|
||||
MenuDao menuMapper;
|
||||
@Autowired
|
||||
RoleMenuDao roleMenuMapper;
|
||||
|
||||
/**
|
||||
* @param
|
||||
* @return 树形菜单
|
||||
*/
|
||||
@Cacheable
|
||||
@Override
|
||||
public Tree<MenuDO> getSysMenuTree(Long id) {
|
||||
List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
|
||||
List<MenuDO> menuDOs = menuMapper.listMenuByUserId(id);
|
||||
for (MenuDO sysMenuDO : menuDOs) {
|
||||
Tree<MenuDO> tree = new Tree<MenuDO>();
|
||||
tree.setId(sysMenuDO.getMenuId().toString());
|
||||
tree.setParentId(sysMenuDO.getParentId().toString());
|
||||
tree.setText(sysMenuDO.getName());
|
||||
Map<String, Object> attributes = new HashMap<>(16);
|
||||
attributes.put("url", sysMenuDO.getUrl());
|
||||
attributes.put("icon", sysMenuDO.getIcon());
|
||||
tree.setAttributes(attributes);
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<MenuDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuDO> list(Map<String, Object> params) {
|
||||
List<MenuDO> menus = menuMapper.list(params);
|
||||
return menus;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = false,rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
int result = menuMapper.remove(id);
|
||||
return result;
|
||||
}
|
||||
@Transactional(readOnly = false,rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int save(MenuDO menu) {
|
||||
int r = menuMapper.save(menu);
|
||||
return r;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = false,rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int update(MenuDO menu) {
|
||||
int r = menuMapper.update(menu);
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuDO get(Long id) {
|
||||
MenuDO menuDO = menuMapper.get(id);
|
||||
return menuDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree<MenuDO> getTree() {
|
||||
List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
|
||||
List<MenuDO> menuDOs = menuMapper.list(new HashMap<>(16));
|
||||
for (MenuDO sysMenuDO : menuDOs) {
|
||||
Tree<MenuDO> tree = new Tree<MenuDO>();
|
||||
tree.setId(sysMenuDO.getMenuId().toString());
|
||||
tree.setParentId(sysMenuDO.getParentId().toString());
|
||||
tree.setText(sysMenuDO.getName());
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<MenuDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree<MenuDO> getTree(Long id) {
|
||||
// 根据roleId查询权限
|
||||
List<MenuDO> menus = menuMapper.list(new HashMap<String, Object>(16));
|
||||
List<Long> menuIds = roleMenuMapper.listMenuIdByRoleId(id);
|
||||
List<Long> temp = menuIds;
|
||||
for (MenuDO menu : menus) {
|
||||
if (temp.contains(menu.getParentId())) {
|
||||
menuIds.remove(menu.getParentId());
|
||||
}
|
||||
}
|
||||
List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
|
||||
List<MenuDO> menuDOs = menuMapper.list(new HashMap<String, Object>(16));
|
||||
for (MenuDO sysMenuDO : menuDOs) {
|
||||
Tree<MenuDO> tree = new Tree<MenuDO>();
|
||||
tree.setId(sysMenuDO.getMenuId().toString());
|
||||
tree.setParentId(sysMenuDO.getParentId().toString());
|
||||
tree.setText(sysMenuDO.getName());
|
||||
Map<String, Object> state = new HashMap<>(16);
|
||||
Long menuId = sysMenuDO.getMenuId();
|
||||
if (menuIds.contains(menuId)) {
|
||||
state.put("selected", true);
|
||||
} else {
|
||||
state.put("selected", false);
|
||||
}
|
||||
tree.setState(state);
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<MenuDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> listPerms(Long userId) {
|
||||
List<String> perms = menuMapper.listUserPerms(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotBlank(perm)) {
|
||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tree<MenuDO>> listMenuTree(Long id) {
|
||||
List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
|
||||
List<MenuDO> menuDOs = menuMapper.listMenuByUserId(id);
|
||||
for (MenuDO sysMenuDO : menuDOs) {
|
||||
Tree<MenuDO> tree = new Tree<MenuDO>();
|
||||
tree.setId(sysMenuDO.getMenuId().toString());
|
||||
tree.setParentId(sysMenuDO.getParentId().toString());
|
||||
tree.setText(sysMenuDO.getName());
|
||||
Map<String, Object> attributes = new HashMap<>(16);
|
||||
attributes.put("url", sysMenuDO.getUrl());
|
||||
attributes.put("icon", sysMenuDO.getIcon());
|
||||
tree.setAttributes(attributes);
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
List<Tree<MenuDO>> list = BuildTree.buildList(trees, "0");
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.system.dao.RoleDataPermDao;
|
||||
import com.java2nb.system.domain.RoleDataPermDO;
|
||||
import com.java2nb.system.service.RoleDataPermService;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
public class RoleDataPermServiceImpl implements RoleDataPermService {
|
||||
@Autowired
|
||||
private RoleDataPermDao roleDataPermDao;
|
||||
|
||||
@Override
|
||||
public RoleDataPermDO get(Long id){
|
||||
return roleDataPermDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RoleDataPermDO> list(Map<String, Object> map){
|
||||
return roleDataPermDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map){
|
||||
return roleDataPermDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(RoleDataPermDO roleDataPerm){
|
||||
return roleDataPermDao.save(roleDataPerm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(RoleDataPermDO roleDataPerm){
|
||||
return roleDataPermDao.update(roleDataPerm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return roleDataPermDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return roleDataPermDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.java2nb.system.dao.*;
|
||||
import com.java2nb.system.domain.RoleDataPermDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.java2nb.system.domain.RoleDO;
|
||||
import com.java2nb.system.domain.RoleMenuDO;
|
||||
import com.java2nb.system.service.RoleService;
|
||||
|
||||
|
||||
@Service
|
||||
public class RoleServiceImpl implements RoleService {
|
||||
|
||||
public static final String ROLE_ALL_KEY = "\"role_all\"";
|
||||
|
||||
public static final String DEMO_CACHE_NAME = "role";
|
||||
|
||||
@Autowired
|
||||
RoleDao roleMapper;
|
||||
@Autowired
|
||||
RoleMenuDao roleMenuMapper;
|
||||
@Autowired
|
||||
UserDao userMapper;
|
||||
@Autowired
|
||||
UserRoleDao userRoleMapper;
|
||||
@Autowired
|
||||
RoleDataPermDao roleDataPermDao;
|
||||
|
||||
@Override
|
||||
public List<RoleDO> list() {
|
||||
List<RoleDO> roles = roleMapper.list(new HashMap<>(16));
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<RoleDO> list(Long userId) {
|
||||
List<Long> rolesIds = userRoleMapper.listRoleId(userId);
|
||||
List<RoleDO> roles = roleMapper.list(new HashMap<>(16));
|
||||
for (RoleDO roleDO : roles) {
|
||||
roleDO.setRoleSign("false");
|
||||
for (Long roleId : rolesIds) {
|
||||
if (Objects.equals(roleDO.getRoleId(), roleId)) {
|
||||
roleDO.setRoleSign("true");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
@Transactional
|
||||
@Override
|
||||
public int save(RoleDO role) {
|
||||
int count = roleMapper.save(role);
|
||||
List<Long> menuIds = role.getMenuIds();
|
||||
Long roleId = role.getRoleId();
|
||||
List<RoleMenuDO> rms = new ArrayList<>();
|
||||
for (Long menuId : menuIds) {
|
||||
RoleMenuDO rmDo = new RoleMenuDO();
|
||||
rmDo.setRoleId(roleId);
|
||||
rmDo.setMenuId(menuId);
|
||||
rms.add(rmDo);
|
||||
}
|
||||
roleMenuMapper.removeByRoleId(roleId);
|
||||
if (rms.size() > 0) {
|
||||
roleMenuMapper.batchSave(rms);
|
||||
}
|
||||
List<Long> permIds = role.getPermIds();
|
||||
if(permIds!=null) {
|
||||
List<RoleDataPermDO> rps = new ArrayList<>();
|
||||
for (Long permId : permIds) {
|
||||
RoleDataPermDO rpDo = new RoleDataPermDO();
|
||||
rpDo.setRoleId(roleId);
|
||||
rpDo.setPermId(permId);
|
||||
rps.add(rpDo);
|
||||
}
|
||||
roleDataPermDao.removeByRoleId(roleId);
|
||||
if (rps.size() > 0) {
|
||||
roleDataPermDao.batchSave(rps);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
int count = roleMapper.remove(id);
|
||||
userRoleMapper.removeByRoleId(id);
|
||||
roleMenuMapper.removeByRoleId(id);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDO get(Long id) {
|
||||
RoleDO roleDO = roleMapper.get(id);
|
||||
return roleDO;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int update(RoleDO role) {
|
||||
int r = roleMapper.update(role);
|
||||
List<Long> menuIds = role.getMenuIds();
|
||||
Long roleId = role.getRoleId();
|
||||
roleMenuMapper.removeByRoleId(roleId);
|
||||
List<RoleMenuDO> rms = new ArrayList<>();
|
||||
for (Long menuId : menuIds) {
|
||||
RoleMenuDO rmDo = new RoleMenuDO();
|
||||
rmDo.setRoleId(roleId);
|
||||
rmDo.setMenuId(menuId);
|
||||
rms.add(rmDo);
|
||||
}
|
||||
if (rms.size() > 0) {
|
||||
roleMenuMapper.batchSave(rms);
|
||||
}
|
||||
List<Long> permIds = role.getPermIds();
|
||||
if(permIds!=null) {
|
||||
List<RoleDataPermDO> rps = new ArrayList<>();
|
||||
for (Long permId : permIds) {
|
||||
RoleDataPermDO rpDo = new RoleDataPermDO();
|
||||
rpDo.setRoleId(roleId);
|
||||
rpDo.setPermId(permId);
|
||||
rps.add(rpDo);
|
||||
}
|
||||
roleDataPermDao.removeByRoleId(roleId);
|
||||
if (rps.size() > 0) {
|
||||
roleDataPermDao.batchSave(rps);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchremove(Long[] ids) {
|
||||
int r = roleMapper.batchRemove(ids);
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import com.java2nb.system.domain.UserOnline;
|
||||
import com.java2nb.system.service.SessionService;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.session.mgt.eis.SessionDAO;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 待完善
|
||||
*
|
||||
* @author xiongxy
|
||||
*/
|
||||
@Service
|
||||
public class SessionServiceImpl implements SessionService {
|
||||
private final SessionDAO sessionDAO;
|
||||
|
||||
@Autowired
|
||||
public SessionServiceImpl(SessionDAO sessionDAO) {
|
||||
this.sessionDAO = sessionDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserOnline> list() {
|
||||
List<UserOnline> list = new ArrayList<>();
|
||||
Collection<Session> sessions = sessionDAO.getActiveSessions();
|
||||
for (Session session : sessions) {
|
||||
UserOnline userOnline = new UserOnline();
|
||||
if (session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY) == null) {
|
||||
continue;
|
||||
} else {
|
||||
SimplePrincipalCollection principalCollection = (SimplePrincipalCollection) session
|
||||
.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
UserDO userDO = (UserDO) principalCollection.getPrimaryPrincipal();
|
||||
userOnline.setUsername(userDO.getUsername());
|
||||
}
|
||||
userOnline.setId((String) session.getId());
|
||||
userOnline.setHost(session.getHost());
|
||||
userOnline.setStartTimestamp(session.getStartTimestamp());
|
||||
userOnline.setLastAccessTime(session.getLastAccessTime());
|
||||
userOnline.setTimeout(session.getTimeout());
|
||||
list.add(userOnline);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDO> listOnlineUser() {
|
||||
List<UserDO> list = new ArrayList<>();
|
||||
UserDO userDO;
|
||||
Collection<Session> sessions = sessionDAO.getActiveSessions();
|
||||
for (Session session : sessions) {
|
||||
SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
|
||||
if (session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY) == null) {
|
||||
continue;
|
||||
} else {
|
||||
principalCollection = (SimplePrincipalCollection) session
|
||||
.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
userDO = (UserDO) principalCollection.getPrimaryPrincipal();
|
||||
list.add(userDO);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Session> sessionList() {
|
||||
return sessionDAO.getActiveSessions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forceLogout(String sessionId) {
|
||||
Session session = sessionDAO.readSession(sessionId);
|
||||
session.setTimeout(0);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
package com.java2nb.system.service.impl;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.*;
|
||||
|
||||
import com.java2nb.common.config.JnConfig;
|
||||
import com.java2nb.common.domain.FileDO;
|
||||
import com.java2nb.common.service.FileService;
|
||||
import com.java2nb.common.utils.*;
|
||||
import com.java2nb.system.service.DeptService;
|
||||
import com.java2nb.system.vo.UserVO;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.java2nb.common.domain.Tree;
|
||||
import com.java2nb.system.dao.DeptDao;
|
||||
import com.java2nb.system.dao.UserDao;
|
||||
import com.java2nb.system.dao.UserRoleDao;
|
||||
import com.java2nb.system.domain.DeptDO;
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import com.java2nb.system.domain.UserRoleDO;
|
||||
import com.java2nb.system.service.UserService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
@Transactional
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
UserDao userMapper;
|
||||
@Autowired
|
||||
UserRoleDao userRoleMapper;
|
||||
@Autowired
|
||||
DeptDao deptMapper;
|
||||
@Autowired
|
||||
private FileService sysFileService;
|
||||
@Autowired
|
||||
private JnConfig jnConfig;
|
||||
@Autowired
|
||||
DeptService deptService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||
|
||||
@Override
|
||||
// @Cacheable(value = "user",key = "#id")
|
||||
public UserDO get(Long id) {
|
||||
List<Long> roleIds = userRoleMapper.listRoleId(id);
|
||||
UserDO user = userMapper.get(id);
|
||||
user.setDeptName(deptMapper.get(user.getDeptId()).getName());
|
||||
user.setRoleIds(roleIds);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDO> list(Map<String, Object> map) {
|
||||
String deptId = map.get("deptId").toString();
|
||||
if (StringUtils.isNotBlank(deptId)) {
|
||||
Long deptIdl = Long.valueOf(deptId);
|
||||
List<Long> childIds = deptService.listChildrenIds(deptIdl);
|
||||
childIds.add(deptIdl);
|
||||
map.put("deptId", null);
|
||||
map.put("deptIds",childIds);
|
||||
}
|
||||
return userMapper.listByPerm(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return userMapper.countByPerm(map);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int save(UserDO user) {
|
||||
int count = userMapper.save(user);
|
||||
Long userId = user.getUserId();
|
||||
List<Long> roles = user.getRoleIds();
|
||||
userRoleMapper.removeByUserId(userId);
|
||||
List<UserRoleDO> list = new ArrayList<>();
|
||||
for (Long roleId : roles) {
|
||||
UserRoleDO ur = new UserRoleDO();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
userRoleMapper.batchSave(list);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(UserDO user) {
|
||||
int r = userMapper.update(user);
|
||||
Long userId = user.getUserId();
|
||||
List<Long> roles = user.getRoleIds();
|
||||
userRoleMapper.removeByUserId(userId);
|
||||
List<UserRoleDO> list = new ArrayList<>();
|
||||
for (Long roleId : roles) {
|
||||
UserRoleDO ur = new UserRoleDO();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
userRoleMapper.batchSave(list);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
// @CacheEvict(value = "user")
|
||||
@Override
|
||||
public int remove(Long userId) {
|
||||
userRoleMapper.removeByUserId(userId);
|
||||
return userMapper.remove(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exit(Map<String, Object> params) {
|
||||
boolean exit;
|
||||
exit = userMapper.list(params).size() > 0;
|
||||
return exit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> listRoles(Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resetPwd(UserVO userVO, UserDO userDO) throws Exception {
|
||||
if (Objects.equals(userVO.getUserDO().getUserId(), userDO.getUserId())) {
|
||||
if (Objects.equals(MD5Utils.encrypt(userDO.getUsername(), userVO.getPwdOld()), userDO.getPassword())) {
|
||||
userDO.setPassword(MD5Utils.encrypt(userDO.getUsername(), userVO.getPwdNew()));
|
||||
return userMapper.update(userDO);
|
||||
} else {
|
||||
throw new Exception("输入的旧密码有误!");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("你修改的不是你登录的账号!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int adminResetPwd(UserVO userVO) throws Exception {
|
||||
UserDO userDO = get(userVO.getUserDO().getUserId());
|
||||
if ("admin".equals(userDO.getUsername())) {
|
||||
throw new Exception("超级管理员的账号不允许直接重置!");
|
||||
}
|
||||
userDO.setPassword(MD5Utils.encrypt(userDO.getUsername(), userVO.getPwdNew()));
|
||||
return userMapper.update(userDO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int batchremove(Long[] userIds) {
|
||||
int count = userMapper.batchRemove(userIds);
|
||||
userRoleMapper.batchRemoveByUserId(userIds);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree<DeptDO> getTree() {
|
||||
List<Tree<DeptDO>> trees = new ArrayList<Tree<DeptDO>>();
|
||||
List<DeptDO> depts = deptMapper.list(new HashMap<String, Object>(16));
|
||||
Long[] pDepts = deptMapper.listParentDept();
|
||||
Long[] uDepts = userMapper.listAllDept();
|
||||
Long[] allDepts = (Long[]) ArrayUtils.addAll(pDepts, uDepts);
|
||||
for (DeptDO dept : depts) {
|
||||
if (!ArrayUtils.contains(allDepts, dept.getDeptId())) {
|
||||
continue;
|
||||
}
|
||||
Tree<DeptDO> tree = new Tree<DeptDO>();
|
||||
tree.setId(dept.getDeptId().toString());
|
||||
tree.setParentId(dept.getParentId().toString());
|
||||
tree.setText(dept.getName());
|
||||
Map<String, Object> state = new HashMap<>(16);
|
||||
state.put("opened", true);
|
||||
state.put("mType", "dept");
|
||||
tree.setState(state);
|
||||
trees.add(tree);
|
||||
}
|
||||
List<UserDO> users = userMapper.list(new HashMap<String, Object>(16));
|
||||
for (UserDO user : users) {
|
||||
Tree<DeptDO> tree = new Tree<DeptDO>();
|
||||
tree.setId(user.getUserId().toString());
|
||||
tree.setParentId(user.getDeptId().toString());
|
||||
tree.setText(user.getName());
|
||||
Map<String, Object> state = new HashMap<>(16);
|
||||
state.put("opened", true);
|
||||
state.put("mType", "user");
|
||||
tree.setState(state);
|
||||
trees.add(tree);
|
||||
}
|
||||
// 默认顶级菜单为0,根据数据库实际情况调整
|
||||
Tree<DeptDO> t = BuildTree.build(trees);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updatePersonal(UserDO userDO) {
|
||||
return userMapper.update(userDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updatePersonalImg(MultipartFile file, String avatar_data, Long userId) throws Exception {
|
||||
String fileName = file.getOriginalFilename();
|
||||
fileName = FileUtil.renameToUUID(fileName);
|
||||
FileDO sysFile = new FileDO(FileType.fileType(fileName), "/files/" + fileName, new Date());
|
||||
//获取图片后缀
|
||||
String prefix = fileName.substring((fileName.lastIndexOf(".") + 1));
|
||||
String[] str = avatar_data.split(",");
|
||||
//获取截取的x坐标
|
||||
int x = (int) Math.floor(Double.parseDouble(str[0].split(":")[1]));
|
||||
//获取截取的y坐标
|
||||
int y = (int) Math.floor(Double.parseDouble(str[1].split(":")[1]));
|
||||
//获取截取的高度
|
||||
int h = (int) Math.floor(Double.parseDouble(str[2].split(":")[1]));
|
||||
//获取截取的宽度
|
||||
int w = (int) Math.floor(Double.parseDouble(str[3].split(":")[1]));
|
||||
//获取旋转的角度
|
||||
int r = Integer.parseInt(str[4].split(":")[1].replaceAll("}", ""));
|
||||
try {
|
||||
BufferedImage cutImage = ImageUtils.cutImage(file, x, y, w, h, prefix);
|
||||
BufferedImage rotateImage = ImageUtils.rotateImage(cutImage, r);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
boolean flag = ImageIO.write(rotateImage, prefix, out);
|
||||
//转换后存入数据库
|
||||
byte[] b = out.toByteArray();
|
||||
FileUtil.uploadFile(b, jnConfig.getUploadPath(), fileName);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("图片裁剪错误!!");
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (sysFileService.save(sysFile) > 0) {
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setUserId(userId);
|
||||
userDO.setPicId(sysFile.getId());
|
||||
if (userMapper.update(userDO) > 0) {
|
||||
result.put("url", sysFile.getUrl());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.java2nb.system.shiro;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.java2nb.common.config.ApplicationContextRegister;
|
||||
import com.java2nb.system.dao.DataPermDao;
|
||||
import com.java2nb.system.dao.DeptDao;
|
||||
import com.java2nb.system.domain.DataPermDO;
|
||||
import com.java2nb.system.domain.UserToken;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.authc.IncorrectCredentialsException;
|
||||
import org.apache.shiro.authc.LockedAccountException;
|
||||
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
||||
import org.apache.shiro.authc.UnknownAccountException;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.java2nb.common.utils.ShiroUtils;
|
||||
import com.java2nb.system.dao.UserDao;
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
import com.java2nb.system.service.MenuService;
|
||||
|
||||
public class UserRealm extends AuthorizingRealm {
|
||||
/* @Autowired
|
||||
UserDao userMapper;
|
||||
@Autowired
|
||||
MenuService menuService;*/
|
||||
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {
|
||||
Long userId = ShiroUtils.getUserId();
|
||||
MenuService menuService = ApplicationContextRegister.getBean(MenuService.class);
|
||||
Set<String> perms = menuService.listPerms(userId);
|
||||
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
|
||||
info.setStringPermissions(perms);
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
|
||||
String username = (String) token.getPrincipal();
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
map.put("username", username);
|
||||
String password = new String((char[]) token.getCredentials());
|
||||
|
||||
UserDao userMapper = ApplicationContextRegister.getBean(UserDao.class);
|
||||
// 查询用户信息
|
||||
UserDO user = userMapper.list(map).get(0);
|
||||
|
||||
// 账号不存在
|
||||
if (user == null) {
|
||||
throw new UnknownAccountException("账号或密码不正确");
|
||||
}
|
||||
|
||||
// 密码错误
|
||||
if (!password.equals(user.getPassword())) {
|
||||
throw new IncorrectCredentialsException("账号或密码不正确");
|
||||
}
|
||||
|
||||
// 账号锁定
|
||||
if (user.getStatus() == 0) {
|
||||
throw new LockedAccountException("账号已被锁定,请联系管理员");
|
||||
}
|
||||
|
||||
//查询下级部门
|
||||
DeptDao deptDao = ApplicationContextRegister.getBean(DeptDao.class);
|
||||
user.setSupDeptIds(deptDao.getDeptIdsByParentId(user.getDeptId()));
|
||||
//查询数据权限
|
||||
DataPermDao dataPermDao = ApplicationContextRegister.getBean(DataPermDao.class);
|
||||
List<DataPermDO> dataPerms = dataPermDao.selectDataPermsByUserId(user.getUserId());
|
||||
Map<String, List<DataPermDO>> permsMap = new HashMap<>();
|
||||
for (DataPermDO perm : dataPerms) {
|
||||
String key = perm.getTableName();
|
||||
List<DataPermDO> value = permsMap.get(key);
|
||||
if (value == null) {
|
||||
value = new ArrayList<>();
|
||||
permsMap.put(key, value);
|
||||
}
|
||||
value.add(perm);
|
||||
|
||||
}
|
||||
user.setDataPerms(permsMap);
|
||||
|
||||
|
||||
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName());
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
46
novel-admin/src/main/java/com/java2nb/system/vo/UserVO.java
Normal file
46
novel-admin/src/main/java/com/java2nb/system/vo/UserVO.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.java2nb.system.vo;
|
||||
|
||||
import com.java2nb.system.domain.UserDO;
|
||||
|
||||
/**
|
||||
* @author xiongxy
|
||||
* @date 2019-09-25 15:09:21
|
||||
*/
|
||||
public class UserVO {
|
||||
/**
|
||||
* 更新的用户对象
|
||||
*/
|
||||
private UserDO userDO = new UserDO();
|
||||
/**
|
||||
* 旧密码
|
||||
*/
|
||||
private String pwdOld;
|
||||
/**
|
||||
* 新密码
|
||||
*/
|
||||
private String pwdNew;
|
||||
|
||||
public UserDO getUserDO() {
|
||||
return userDO;
|
||||
}
|
||||
|
||||
public void setUserDO(UserDO userDO) {
|
||||
this.userDO = userDO;
|
||||
}
|
||||
|
||||
public String getPwdOld() {
|
||||
return pwdOld;
|
||||
}
|
||||
|
||||
public void setPwdOld(String pwdOld) {
|
||||
this.pwdOld = pwdOld;
|
||||
}
|
||||
|
||||
public String getPwdNew() {
|
||||
return pwdNew;
|
||||
}
|
||||
|
||||
public void setPwdNew(String pwdNew) {
|
||||
this.pwdNew = pwdNew;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user