diff --git a/src/main/java/com/zcloud/controller/bus/CorpInfoController.java b/src/main/java/com/zcloud/controller/bus/CorpInfoController.java index a66edc34..1308325e 100644 --- a/src/main/java/com/zcloud/controller/bus/CorpInfoController.java +++ b/src/main/java/com/zcloud/controller/bus/CorpInfoController.java @@ -237,6 +237,7 @@ public class CorpInfoController extends BaseController { * @throws Exception */ @RequestMapping(value="/goEdit") + @RequiresPermissions("corpinfo_edit_self:list") @ResponseBody public Object goEdit() throws Exception{ Map map = new HashMap(); diff --git a/src/main/java/com/zcloud/controller/corpsystem/CorpMenuController.java b/src/main/java/com/zcloud/controller/corpsystem/CorpMenuController.java new file mode 100644 index 00000000..093831c0 --- /dev/null +++ b/src/main/java/com/zcloud/controller/corpsystem/CorpMenuController.java @@ -0,0 +1,231 @@ +package com.zcloud.controller.corpsystem; + +import com.zcloud.controller.base.BaseController; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Menu; +import com.zcloud.service.system.FHlogService; +import com.zcloud.service.system.corpsystem.CorpMenuService; +import com.zcloud.util.Const; +import com.zcloud.util.Jurisdiction; +import com.zcloud.util.RightsHelper; +import com.zcloud.util.Tools; +import net.sf.json.JSONArray; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 说明:菜单管理处理类 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +@Controller +@RequestMapping("/corpMenu") +public class CorpMenuController extends BaseController { + + @Autowired + private CorpMenuService corpMenuService; + @Autowired + private FHlogService FHLOG; + + /** + * 菜单列表ztree(菜单管理) + * @return + */ + @RequestMapping(value="/listAllMenu") + @ResponseBody + public Object listAllMenu()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + JSONArray arr = JSONArray.fromObject(corpMenuService.listAllMenu("0")); + String json = arr.toString(); + json = json.replaceAll("MENU_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("MENU_NAME", "name").replaceAll("subMenu", "nodes").replaceAll("hasMenu", "checked").replaceAll("MENU_URL", "url"); + map.put("zTreeNodes", json); + map.put("result", errInfo); + return map; + } + + /** + * 菜单列表 + * @return + */ + @RequestMapping(value="/list") + @ResponseBody + public Object list(String MENU_ID)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + MENU_ID = Tools.isEmpty(MENU_ID)?"0":MENU_ID; + List menuList = corpMenuService.listSubMenuByParentId(MENU_ID); + map.put("pd", corpMenuService.getMenuById(pd)); //传入父菜单所有信息 + map.put("MSG", null == pd.get("MSG")?"'list'":pd.get("MSG").toString()); //MSG=change 则为编辑或删除后跳转过来的 + map.put("menuList", menuList); + map.put("result", errInfo); + return map; + } + + /** + * 请求新增菜单页面 + * @return + */ + @RequestMapping(value="/toAdd") + @ResponseBody + public Object toAdd()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String MENU_ID = (null == pd.get("MENU_ID") || "".equals(pd.get("MENU_ID").toString()))?"0":pd.get("MENU_ID").toString();//接收传过来的上级菜单ID,如果上级为顶级就取值“0” + pd.put("MENU_ID",MENU_ID); + map.put("pds", corpMenuService.getMenuById(pd)); //传入父菜单所有信息 + map.put("result", errInfo); + return map; + } + + /** + * 新增菜单 + * @param menu + * @return + */ + @RequestMapping(value="/add") + @ResponseBody + public Object add(Menu menu)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + menu.setMENU_ID(String.valueOf(Integer.parseInt(corpMenuService.findMaxId(pd).get("MID").toString())+1)); + menu.setMENU_ICON(""); //默认无菜单图标 + corpMenuService.addMenu(menu); //新增菜单 + FHLOG.save(Jurisdiction.getUsername(), "新增菜单:"+menu.getMENU_NAME()); //记录日志 + map.put("result", errInfo); + return map; + } + + /** + * 请求编辑菜单页面 + * @param + * @return + */ + @RequestMapping(value="/toEdit") + @ResponseBody + public Object toEdit(String MENU_ID)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd = corpMenuService.getMenuById(pd); //读取此ID的菜单数据 + map.put("pd", pd); + pd.put("MENU_ID",pd.get("PARENT_ID").toString()); //用作读取父菜单信息 + map.put("pds", corpMenuService.getMenuById(pd)); //传入父菜单所有信息 + map.put("result", errInfo); + return map; + } + + /** + * 保存编辑 + * @param + * @return + */ + @RequestMapping(value="/edit") + @ResponseBody + public Object edit(Menu menu)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + corpMenuService.edit(menu); + FHLOG.save(Jurisdiction.getUsername(), "修改菜单:"+menu.getMENU_NAME()); //记录日志 + map.put("result", errInfo); + return map; + } + + /** + * 删除菜单 + * @param MENU_ID + * @param out + */ + @RequestMapping(value="/delete") + @ResponseBody + public Object delete(@RequestParam String MENU_ID)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + if(corpMenuService.listSubMenuByParentId(MENU_ID).size() > 0){//判断是否有子菜单,是:不允许删除 + errInfo = "error"; + }else{ + corpMenuService.deleteMenuById(MENU_ID); + errInfo = "success"; + FHLOG.save(Jurisdiction.getUsername(), "删除的菜单ID为:"+MENU_ID); //记录日志 + } + map.put("result", errInfo); + return map; + } + + /** + * 保存菜单图标 + * @param + * @return + */ + @RequestMapping(value="/editicon") + @ResponseBody + public Object editicon()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + corpMenuService.editicon(pd); + map.put("result", errInfo); + return map; + } + + /** + * 显示菜单列表ztree(拓展左侧四级菜单) + * @return + */ + @RequestMapping(value="/otherlistMenu") + @ResponseBody + public Object otherlistMenu(String MENU_ID)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd.put("MENU_ID", MENU_ID); + String MENU_URL = corpMenuService.getMenuById(pd).getString("MENU_URL"); + if("#".equals(MENU_URL.trim()) || "".equals(MENU_URL.trim()) || null == MENU_URL){ + MENU_URL = "../index/default.html"; + } + String roleRights = Jurisdiction.getSession().getAttribute(Jurisdiction.getUsername() + Const.SESSION_ROLE_RIGHTS).toString(); //获取本角色菜单权限 + List athmenuList = corpMenuService.listAllMenuQx(MENU_ID); //获取某菜单下所有子菜单 + athmenuList = this.readMenu(athmenuList, roleRights); //根据权限分配菜单 + JSONArray arr = JSONArray.fromObject(athmenuList); + String json = arr.toString(); + json = json.replaceAll("MENU_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("MENU_NAME", "name").replaceAll("subMenu", "nodes").replaceAll("hasMenu", "checked").replaceAll("MENU_URL", "url").replaceAll("#", ""); + map.put("zTreeNodes", json); + map.put("MENU_URL",MENU_URL); //本ID菜单链接 + map.put("result", errInfo); + return map; + } + + /**根据角色权限获取本权限的菜单列表(递归处理) + * @param menuList:传入的总菜单 + * @param roleRights:加密的权限字符串 + * @return + */ + public List readMenu(List menuList,String roleRights){ + for(int i=0;i map = new HashMap(); + String errInfo = "success"; + PageData pd = this.getPageData(); + // 横排一级组 + String corpId = Jurisdiction.getCORPINFO_ID(); + pd.put("CORPINFO_ID", corpId); + PageData corp = corpInfoService.findById(pd); + PageData fpd = new PageData(); + fpd.put("CORPINFO_ID",corp.getString("ROLE_NAME")); + fpd.put("ROLE_ID",corp.getString("ROLE_NAME")); + pd.put("ROLE_ID",corp.getString("ROLE_NAME")); + Role roleList = corpRoleService.getRoleById(corp.getString("ROLE_NAME")); //列出组(页面横向排列的一级组) + List roleList_z = corpRoleService.listAllRolesByPId(fpd); //列出此组下架角色 + pd = corpRoleService.findById(pd); //取得点击的角色组(横排的) + map.put("pd", pd); + map.put("roleList", Collections.singletonList(roleList)); + map.put("roleList_z", roleList_z); + map.put("result", errInfo); + return map; + } + + /**保存新增角色 + * @return + * @throws Exception + */ + @RequestMapping(value="/add") + @ResponseBody + public Object add()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String parent_id = pd.getString("PARENT_ID"); //父类角色id + pd.put("ROLE_ID", parent_id); + if("0".equals(parent_id)){ + pd.put("RIGHTS", ""); //菜单权限 + }else{ + String rights = corpRoleService.findById(pd).getString("RIGHTS"); + pd.put("RIGHTS", (null == rights)?"":rights); //组菜单权限 + } + String RNUMBER = "R"+DateUtil.getDays()+Tools.getRandomNum(); + pd.put("RNUMBER", RNUMBER); //编码 + pd.put("ROLE_ID", this.get32UUID()); //主键 + pd.put("ADD_QX", "0"); //初始新增权限为否 + pd.put("DEL_QX", "0"); //删除权限 + pd.put("EDIT_QX", "0"); //修改权限 + pd.put("CHA_QX", "0"); //查看权限 + if ("".equals(pd.getString("LEVEL"))) { + pd.put("LEVEL",0); + } + corpRoleService.add(pd); + FHLOG.save(Jurisdiction.getUsername(), "新增角色"+pd.getString("ROLE_NAME")); //记录日志 + map.put("result", errInfo); + return map; + } + + /**请求编辑 + * @return + * @throws Exception + */ + @RequestMapping(value="/toEdit") + @ResponseBody + public Object toEdit()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd = corpRoleService.findById(pd); + map.put("pd", pd); + map.put("result", errInfo); + return map; + } + + /**保存修改 + * @return + * @throws Exception + */ + @RequestMapping(value="/edit") + @ResponseBody + public Object edit()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + corpRoleService.edit(pd); + FHLOG.save(Jurisdiction.getUsername(), "修改角色"+pd.getString("ROLE_NAME")); //记录日志 + map.put("result", errInfo); + return map; + } + + /**删除角色 + * @param ROLE_ID + * @return + * @throws Exception + */ + @RequestMapping(value="/delete") + @ResponseBody + public Object deleteRole(@RequestParam String ROLE_ID)throws Exception{ + Map map = new HashMap(); + PageData pd = new PageData(); + String errInfo = "success"; + pd.put("ROLE_ID", ROLE_ID); + List roleList_z = corpRoleService.listAllRolesByPId(pd); //列出此角色的所有下级 + if("fhadminzhuche".equals(ROLE_ID)|| roleList_z.size() > 0){ +// errInfo = "false"; //下级有数据时or注册用户角色,删除失败 + errInfo = "fail"; + map.put("result", "errInfo"); + map.put("msg", "此组下有角色,不能删除!"); + return map; + }else{ + List userlist = corpUsersService.listAllUserByRoldId(pd); //此角色下的用户 + if(userlist.size() > 0){ //此角色已被使用就不能删除 + errInfo = "false2"; + }else{ + corpRoleService.deleteRoleById(ROLE_ID); //执行删除 + errInfo = "success"; + FHLOG.save(Jurisdiction.getUsername(), "删除角色ID为:"+ROLE_ID); //记录日志 + } + } + map.put("result", errInfo); + return map; + } + + /** + * 显示菜单列表ztree(菜单授权菜单) + * @return + */ + @RequestMapping(value="/menuqx") + @ResponseBody + public Object listAllMenu(String ROLE_ID)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + Role role = corpRoleService.getRoleById(ROLE_ID); //根据角色ID获取角色对象 + String roleRights = role.getRIGHTS(); //取出本角色菜单权限 + List menuList = corpMenuService.listAllMenuQx("0"); //获取所有菜单 + menuList = this.readMenu(menuList, roleRights); //根据角色权限处理菜单权限状态(递归处理) + JSONArray arr = JSONArray.fromObject(menuList); + String json = arr.toString(); + json = json.replaceAll("MENU_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("MENU_NAME", "name").replaceAll("subMenu", "nodes").replaceAll("hasMenu", "checked"); + map.put("zTreeNodes", json); + map.put("result", errInfo); + return map; + } + + /**根据角色权限处理权限状态(递归处理) + * @param menuList:传入的总菜单 + * @param roleRights:加密的权限字符串 + * @return + */ + public List readMenu(List menuList,String roleRights){ + for(int i=0;i map = new HashMap(); + PageData pd = new PageData(); + if(null != menuIds && !"".equals(menuIds.trim())){ + BigInteger rights = RightsHelper.sumRights(Tools.str2StrArray(menuIds));//用菜单ID做权处理 + Role role = corpRoleService.getRoleById(ROLE_ID); //通过id获取角色对象 + role.setRIGHTS(rights.toString()); + corpRoleService.updateRoleRights(role); //更新当前角色菜单权限 + pd.put("rights",rights.toString()); + }else{ + Role role = new Role(); + role.setRIGHTS(""); + role.setROLE_ID(ROLE_ID); + corpRoleService.updateRoleRights(role); //更新当前角色菜单权限(没有任何勾选) + pd.put("rights",""); + } + pd.put("ROLE_ID", ROLE_ID); + if(!"1".equals(ROLE_ID)){ //当修改admin权限时,不修改其它角色权限 + corpRoleService.setAllRights(pd); //更新此角色所有子角色的菜单权限 + } + map.put("result", "success"); + FHLOG.save(Jurisdiction.getUsername(), "给角色ID:"+ROLE_ID+" 授权了菜单权限操作"); //记录日志 + return map; + } + + /**请求角色按钮授权页面(增删改查) + * @param ROLE_ID: 角色ID + * @param msg: 区分增删改查 + * @return + * @throws Exception + */ + @RequestMapping(value="/b4Button") + @ResponseBody + public Object b4Button(@RequestParam String ROLE_ID,@RequestParam String msg)throws Exception{ + Map map = new HashMap(); + List menuList = corpMenuService.listAllMenuQx("0"); //获取所有菜单 + Role role = corpRoleService.getRoleById(ROLE_ID); //根据角色ID获取角色对象 + String roleRights = ""; + if("add_qx".equals(msg)){ + roleRights = role.getADD_QX(); //新增权限 + }else if("del_qx".equals(msg)){ + roleRights = role.getDEL_QX(); //删除权限 + }else if("edit_qx".equals(msg)){ + roleRights = role.getEDIT_QX(); //修改权限 + }else if("cha_qx".equals(msg)){ + roleRights = role.getCHA_QX(); //查看权限 + } + menuList = this.readMenu(menuList, roleRights); //根据角色权限处理菜单权限状态(递归处理) + JSONArray arr = JSONArray.fromObject(menuList); + String json = arr.toString(); + json = json.replaceAll("MENU_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("MENU_NAME", "name").replaceAll("subMenu", "nodes").replaceAll("hasMenu", "checked"); + map.put("zTreeNodes", json); + map.put("result", "success"); + return map; + } + + /** + * 保存角色按钮权限 + * @param ROLE_ID + * @param menuIds + * @param msg + * @throws Exception + */ + @RequestMapping(value="/saveB4Button") + @ResponseBody + public Object saveB4Button(@RequestParam String ROLE_ID,@RequestParam String menuIds,@RequestParam String msg)throws Exception{ + Map map = new HashMap(); + PageData pd = new PageData(); + pd = this.getPageData(); + if(null != menuIds && !"".equals(menuIds.trim())){ + BigInteger rights = RightsHelper.sumRights(Tools.str2StrArray(menuIds)); + pd.put("value",rights.toString()); + }else{ + pd.put("value",""); + } + pd.put("ROLE_ID", ROLE_ID); + corpRoleService.saveB4Button(msg,pd); + map.put("result", "success"); + FHLOG.save(Jurisdiction.getUsername(), "给角色ID:"+ROLE_ID+" 授权了增删改查按钮权限操作"); //记录日志 + return map; + } + + /** 选择角色(弹窗选择用) + * @param + * @return + * @throws Exception + */ + @RequestMapping(value="/roleListWindow") + @ResponseBody + public Object roleListWindow(Page page)throws Exception{ + Map map = new HashMap(); + PageData pd = new PageData(); + pd = this.getPageData(); + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + page.setPd(pd); + List roleList = corpRoleService.roleListWindow(page); //列出所有角色 + map.put("roleList", roleList); + map.put("page", page); + map.put("result", "success"); + return map; + } + + /**根据名称查询角色 + * @param ROLE_ID + * @return + * @throws Exception + */ + @RequestMapping(value="/findByName") + @ResponseBody + public Object findByName()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); +// pd = corpRoleService.findByName(pd);/// + map.put("pd", pd); + map.put("result", errInfo); + return map; + } + @RequestMapping(value="/b4ButtonV2") + @ResponseBody + public Object b4ButtonV2(@RequestParam String ROLE_ID,@RequestParam String msg)throws Exception{ + PageData pd = new PageData(); + pd = this.getPageData(); + String pid =pd.getString("PARENT_ID"); + Map map = new HashMap(); + String errInfo = "success"; + Role role = corpRoleService.getRoleById(ROLE_ID); //根据角色ID获取角色对象 + String roleRights = ""; + if("add_qx".equals(msg)){ + roleRights = role.getADD_QX(); //新增权限 + }else if("del_qx".equals(msg)){ + roleRights = role.getDEL_QX(); //删除权限 + }else if("edit_qx".equals(msg)){ + roleRights = role.getEDIT_QX(); //修改权限 + }else if("cha_qx".equals(msg)){ + roleRights = role.getCHA_QX(); //查看权限 + } + List menuListAll = corpMenuService.listSubMenuAll(); + Map> menuAllMap = new HashMap<>(); + for (int i=0;i menuListValue = new ArrayList<>(); + Menu menu = menuListAll.get(i); + if(menuAllMap.containsKey(menu.getPARENT_ID())){ + menuListValue = menuAllMap.get(menu.getPARENT_ID()); + } + menuListValue.add(menu); + menuAllMap.put(menu.getPARENT_ID(),menuListValue); + } + List menuList = this.listAllMenuDigui("0",menuAllMap,roleRights); //获取所有菜单 + menuList = this.readMenu(menuList, roleRights); //根据角色权限处理菜单权限状态(递归处理) + JSONArray arr = JSONArray.fromObject(menuList); + String json = arr.toString(); + json = json.replaceAll("MENU_ID", "id") + .replaceAll("PARENT_ID", "pId") + .replaceAll("MENU_NAME", "name") + .replaceAll("subMenu", "nodes") + .replaceAll("hasMenu", "checked"); + map.put("zTreeNodes", json); + map.put("result", errInfo); + return map; + + } + /** + * 显示菜单列表ztree(菜单授权菜单) + * @return + */ + @RequestMapping(value="/listAllMenuV2") + @ResponseBody + public Object listAllMenuByParentID(String ROLE_ID)throws Exception{ + PageData pd = new PageData(); + pd = this.getPageData(); + String pid =pd.getString("PARENT_ID"); + Map map = new HashMap(); + String errInfo = "success"; + Role role = corpRoleService.getRoleById(ROLE_ID); //根据角色ID获取角色对象 + String roleRights = role.getRIGHTS(); //取出本角色菜单权限 + List menuListAll = corpMenuService.listSubMenuAll(); + Map> menuAllMap = new HashMap<>(); + for (int i=0;i menuListValue = new ArrayList<>(); + Menu menu = menuListAll.get(i); + if(menuAllMap.containsKey(menu.getPARENT_ID())){ + menuListValue = menuAllMap.get(menu.getPARENT_ID()); + } + menuListValue.add(menu); + menuAllMap.put(menu.getPARENT_ID(),menuListValue); + } + List menuList = this.listAllMenuDigui("0",menuAllMap,roleRights); //获取所有菜单 + menuList = this.readMenu(menuList, roleRights); //根据角色权限处理菜单权限状态(递归处理) + JSONArray arr = JSONArray.fromObject(menuList); + String json = arr.toString(); + json = json.replaceAll("MENU_ID", "id") + .replaceAll("PARENT_ID", "pId") + .replaceAll("MENU_NAME", "name") + .replaceAll("subMenu", "nodes") + .replaceAll("hasMenu", "checked"); + map.put("zTreeNodes", json); + map.put("result", errInfo); + return map; + + } + + /** + * + * @param MENU_ID + * @param menuAllList key pid val Pid 下面的list + * @return + * @throws Exception + */ + public List listAllMenuDigui(String MENU_ID,Map> menuAllList,String roleRights) throws Exception { + List menuList = this.listSubMenuByParentId(MENU_ID,menuAllList); //更具pid 获取数据 + for(Menu menu : menuList){ + menu.setMENU_URL("menu_edit.html?MENU_ID="+menu.getMENU_ID()); + menu.setSubMenu(this.listAllMenuDigui(menu.getMENU_ID(),menuAllList,roleRights)); + menu.setTarget("treeFrame"); + menu.setHasMenu(RightsHelper.testRights(roleRights, menu.getMENU_ID())); + } + return menuList; + } + public List listSubMenuByParentId (String MENU_ID,Map> menuAllList){ //更具pid 获取数据 + List menuList = new ArrayList<>(); + if(menuAllList.containsKey(MENU_ID)){ + menuList = menuAllList.get(MENU_ID); + } + return menuList; + } +} diff --git a/src/main/java/com/zcloud/controller/corpsystem/CorpUsersController.java b/src/main/java/com/zcloud/controller/corpsystem/CorpUsersController.java new file mode 100644 index 00000000..4653f46c --- /dev/null +++ b/src/main/java/com/zcloud/controller/corpsystem/CorpUsersController.java @@ -0,0 +1,725 @@ +package com.zcloud.controller.corpsystem; + +import com.zcloud.controller.base.BaseController; +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Department; +import com.zcloud.entity.system.Role; +import com.zcloud.service.system.DepartmentService; +import com.zcloud.service.system.FHlogService; +import com.zcloud.service.system.RoleService; +import com.zcloud.service.system.UeditorService; +import com.zcloud.service.system.corpsystem.CorpUsersService; +import com.zcloud.util.*; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.*; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.crypto.hash.SimpleHash; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 说明:系统用户处理类 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +@Controller +@RequestMapping("/corpUser") +public class CorpUsersController extends BaseController { + + @Autowired + private CorpUsersService corpUsersService; + @Autowired + private RoleService roleService; + @Autowired + private UeditorService ueditorService; + @Autowired + private FHlogService FHLOG; + @Autowired + private DepartmentService departmentService; + + + /**列表 + * @param page + * @throws Exception + */ + @RequestMapping(value="/listAll") + @ResponseBody + public Object listAll() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + List userList = corpUsersService.listAllUser(pd); //列出Post列表 + map.put("userList", userList); + map.put("result", errInfo); + return map; + } + + + + + + + + + /**用户列表 + * @param page + * @return + * @throws Exception + */ + @RequestMapping("/list") + @ResponseBody + public Object listUsers(Page page)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + + /*检索条件*/ + String ROLE_ID = pd.getString("ROLE_ID"); //角色ID + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + String STRARTTIME = pd.getString("STRARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if(Tools.notEmpty(STRARTTIME))pd.put("STRARTTIME", STRARTTIME+" 00:00:00"); + if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00"); + if(!"admin".equals(Jurisdiction.getUsername())) { + Session session = Jurisdiction.getSession(); + PageData dept = (PageData)session.getAttribute(Const.SESSION_DEPT); + if(Tools.isEmpty(pd.get("PROVINCE")) && Tools.isEmpty(pd.get("CITY")) && Tools.isEmpty(pd.get("COUNTRY")) && Tools.isEmpty(pd.get("VILLAGE")) ){ + if (!"000000".equals(dept.getString("PROVINCE"))){ + pd.put("PROVINCE", dept.get("PROVINCE")); + } + pd.put("CITY", dept.get("CITY")); + pd.put("COUNTRY", dept.get("COUNTRY")); + pd.put("VILLAGE", dept.get("VILLAGE")); + } + } + page.setPd(pd); + List userList = corpUsersService.userlistPage(page); //列出用户列表 + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + + map.put("userList", userList); + map.put("roleList", roleList); + map.put("ROLE_ID", ROLE_ID); + map.put("page", page); + map.put("pd", pd); + + map.put("result", errInfo); + return map; + } + + /**去新增用户页面 + * @return + * @throws Exception + */ + @RequestMapping(value="/goAddUser") + @ResponseBody + public Object goAddUser()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + map.put("roleList", roleList); + map.put("result", errInfo); + return map; + } + + /**去修改用户页面(从系统用户页面修改) + * @return + * @throws Exception + */ + @RequestMapping(value="/goEditUser") + @ResponseBody + public Object goEditUser() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if("1".equals(pd.getString("USER_ID"))){return null;} //不能修改admin用户 + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + List departmentList=departmentService.listAllDepartment("c14c41b8058b421ba6b988c2c3bd3139"); + pd = corpUsersService.findById(pd); //根据ID读取 + String ROLE_IDS = pd.getString("ROLE_IDS"); //副职角色ID + if(Tools.notEmpty(ROLE_IDS)){ + String arryROLE_ID[] = ROLE_IDS.split(","); + for(int i=0;i map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + pd.put("USERNAME", Jurisdiction.getUsername()); + pd = corpUsersService.findByUsername(pd); //根据用户名读取 + map.put("pd", pd); + map.put("roleList", roleList); + map.put("result", errInfo); + return map; + } + + /** + * 修改用户(系统用户列表修改) + */ + @RequestMapping(value="/editUser") + @ResponseBody + public Object editUser() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + FHLOG.save(Jurisdiction.getUsername(), "从系统用户中修改"+pd.getString("USERNAME")+"的资料"); //记录日志 + if(!Jurisdiction.getUsername().equals(pd.getString("USERNAME"))){ //如果当前登录用户修改用户资料提交的用户名非本人 + if("admin".equals(pd.getString("USERNAME")) && !"admin".equals(Jurisdiction.getUsername())){return null;} //非admin用户不能修改admin + }else{ //如果当前登录用户修改用户资料提交的用户名是本人,则不能修改本人的角色ID + PageData upd = new PageData(); + upd = corpUsersService.findByUsername(pd); + pd.put("ROLE_ID", upd.getString("ROLE_ID")); //对角色ID还原本人角色ID + pd.put("ROLE_IDS", Tools.notEmpty(upd.getString("ROLE_IDS"))?upd.get("ROLE_IDS"):""); //对角色ID还原本人副职角色ID + } + if(pd.getString("PASSWORD") != null && !"".equals(pd.getString("PASSWORD"))){ + pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString()); + } + corpUsersService.editUser(pd); //执行修改 + map.put("result", errInfo); + return map; + } + + /** + * 修改用户(系统用户列表修改) + */ + @RequestMapping(value="/editUserFuns") + @ResponseBody + public Object editUserFuns() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + FHLOG.save(Jurisdiction.getUsername(), "从系统用户中修改"+pd.getString("USERNAME")+"的小程序菜单权限"); //记录日志 + corpUsersService.editUserFuns(pd); //执行修改 + map.put("result", errInfo); + return map; + } + + /** + * 修改用户(个人资料修改) + */ + @RequestMapping(value="/editUserOwn") + @ResponseBody + public Object editUserOwn() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if(!Jurisdiction.getUsername().equals(pd.getString("USERNAME"))){ //如果当前登录用户修改用户资料提交的用户名非本人 + FHLOG.save(Jurisdiction.getUsername(), "恶意修改用户资料:"+pd.getString("USERNAME")); + return null;//不能修改非本人的资料 + }else{ //如果当前登录用户修改用户资料提交的用户名是本人,则不能修改本人的角色ID + PageData upd = new PageData(); + upd = corpUsersService.findByUsername(pd); + pd.put("USER_ID", upd.getString("USER_ID")); //对ID还原本人ID,防止串改 + pd.put("ROLE_ID", upd.getString("ROLE_ID")); //对角色ID还原本人角色ID + pd.put("ROLE_IDS", Tools.notEmpty(upd.getString("ROLE_IDS"))?upd.get("ROLE_IDS"):""); //对角色ID还原本人副职角色ID + } + if(pd.getString("PASSWORD") != null && !"".equals(pd.getString("PASSWORD"))){ + pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString()); + } + corpUsersService.editUser(pd); //执行修改 + FHLOG.save(Jurisdiction.getUsername(), "从个人资料中修改"+pd.getString("USERNAME")+"的资料"); //记录日志 + map.put("result", errInfo); + return map; + } + + /** + * 修改用户密码() + */ + @RequestMapping(value="/editUserPwd") + @ResponseBody + public Object editUserPwd() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String userName = Jurisdiction.getUsername(); + String userOldPwd = pd.getString("password"); + UsernamePasswordToken token = new UsernamePasswordToken(userName, new SimpleHash("SHA-1", userName, userOldPwd).toString()); + + Subject subject = SecurityUtils.getSubject(); + try { + subject.login(token); //这一步在调用login(token)方法时,它会走到MyRealm.doGetAuthenticationInfo()方法中 + }catch(UnknownAccountException uae){ + errInfo = "usererror"; + }catch(IncorrectCredentialsException ice){ + errInfo = "usererror"; + }catch(LockedAccountException lae){ + errInfo = "usererror"; + }catch(ExcessiveAttemptsException eae){ + errInfo = "usererror4"; + }catch (DisabledAccountException sae){ + errInfo = "usererror"; + }catch(AuthenticationException ae){ + errInfo = "usererror"; + } + + if("success".equals(errInfo)) { + if(subject.isAuthenticated()){ //密码验证成功 + String newPwd =new SimpleHash("SHA-1",userName, pd.getString("newpwd")).toString();//加密新密码 + PageData updateUserPd = new PageData(); + updateUserPd.put("USER_ID", Jurisdiction.getUSER_ID()); + updateUserPd.put("PASSWORD", newPwd); + corpUsersService.editPassword(updateUserPd); + FHLOG.save(userName, "从app修改密码中修改"+userName+"的密码"); //记录日志 + }else { + token.clear(); + errInfo = "usererror"; + } + }else { + errInfo="error"; + map.put("result", errInfo); + map.put("msg", "用户密码错误"); + return map; + } + /** + * 1.验证原始密码是否正确 + * 2.密码加密 + * 3.修改数据库 + * 4.增加日志 + */ + map.put("result", errInfo); + return map; + } + + /** + * @param page + * @throws Exception + */ + @RequestMapping(value="/resetPwd") + @ResponseBody + public Object resetPwd (Page page) throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + PageData pageData = corpUsersService.findById(pd); + //corpInfo + String pwd = new SimpleHash("SHA-1", pageData.getString("USERNAME"), "Aa@123456789").toString(); + PageData updateUser = new PageData(); + updateUser.put("PASSWORD", pwd); + updateUser.put("USER_ID", pageData.getString("USER_ID")); + corpUsersService.editPassword(updateUser); + + map.put("result", errInfo); + return map; + } + + /**判断用户名是否存在 + * @return + */ + @RequestMapping(value="/hasUser") + @ResponseBody + public Object hasUser() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if(corpUsersService.findByUsername(pd) != null){ + errInfo = "fail"; + } + map.put("result", errInfo); //返回结果 + return map; + } + + /**判断邮箱是否存在 + * @return + */ + @RequestMapping(value="/hasEmail") + @ResponseBody + public Object hasEmail() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if(corpUsersService.findByEmail(pd) != null){ + errInfo = "error"; + } + map.put("result", errInfo); //返回结果 + return map; + } + + /**判断编码是否存在 + * @return + */ + @RequestMapping(value="/hasNumber") + @ResponseBody + public Object hasNumber() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if(corpUsersService.findByNumbe(pd) != null){ + errInfo = "error"; + } + map.put("result", errInfo); //返回结果 + return map; + } + + /**保存用户 + * @return + * @throws Exception + */ + @RequestMapping(value="/saveUser") + @ResponseBody + public Object saveUser() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + pd.put("USER_ID", this.get32UUID()); //ID 主键 + pd.put("LAST_LOGIN", ""); //最后登录时间 + pd.put("IP", ""); //IP + pd.put("STATUS", "0"); //状态 + pd.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,"); //用户默认皮肤 + String userPwd = Tools.isEmpty(pd.get("PASSWORD"))?"Aa@123456789" : pd.getString("PASSWORD"); + pd.put("PASSWORD", new SimpleHash("SHA-1", pd.getString("USERNAME"), userPwd).toString()); //密码加密 + String[] userRole = pd.getString("roleIDs").split(";"); //处理多角色的用户 + pd.put("ROLE_ID",userRole[0]); + pd.put("PASSWORD",pd.getString("userPASSWORD")); + if(userRole.length>1){ + String ROLE_IDS =pd.getString("roleIDs").replaceAll(";",",").replaceAll(userRole[0]+',' ,""); + pd.put("ROLE_IDS",ROLE_IDS); + } + if(null == corpUsersService.findByUsername(pd)){ //判断用户名是否存在 + corpUsersService.saveUser(pd); //执行保存 + }else{ + map.put("result","failed"); + } + FHLOG.save(Jurisdiction.getUsername(), "新增用户:"+pd.getString("USERNAME")); //记录日志 + map.put("result", errInfo); //返回结果 + return map; + } + + /**删除用户 + * @return + */ + @RequestMapping(value="/deleteUser") + @ResponseBody + public Object deleteUser() throws Exception{ + Map map = new HashMap(); + PageData pd = new PageData(); + String errInfo = "success"; + pd = this.getPageData(); + FHLOG.save(Jurisdiction.getUsername(), "删除用户ID:"+pd.getString("USER_ID")); //记录日志 + corpUsersService.deleteUser(pd); //删除用户 + ueditorService.delete(pd); //删除副文本关联数据 + map.put("result", errInfo); //返回结果 + return map; + } + + /** + * 批量删除 + * @throws Exception + */ + @RequestMapping(value="/deleteAllUser") + @ResponseBody + public Object deleteAllUser() throws Exception{ + PageData pd = new PageData(); + Map map = new HashMap(); + pd = this.getPageData(); + String USER_IDS = pd.getString("USER_IDS"); + String errInfo = "success"; + if(Tools.notEmpty(USER_IDS)){ + String ArrayUSER_IDS[] = USER_IDS.split(","); + FHLOG.save(Jurisdiction.getUsername(), "批量删除用户"); //记录日志 + corpUsersService.deleteAllUser(ArrayUSER_IDS); //删除用户 + ueditorService.deleteAll(ArrayUSER_IDS); //删除副文本关联数据 + errInfo = "success"; + }else{ + errInfo = "error"; + } + map.put("result", errInfo); //返回结果 + return map; + } + + /**导出用户信息到EXCEL + * @return + * @throws Exception + */ + @RequestMapping(value="/excel") + public ModelAndView exportExcel() throws Exception{ + ModelAndView mv = new ModelAndView(); + PageData pd = new PageData(); + pd = this.getPageData(); + try{ + + /*检索条件*/ + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + String STRARTTIME = pd.getString("STRARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if(Tools.notEmpty(STRARTTIME))pd.put("STRARTTIME", STRARTTIME+" 00:00:00"); + if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00"); + + Map dataMap = new HashMap(); + List titles = new ArrayList(); + titles.add("用户名"); //1 + titles.add("编号"); //2 + titles.add("姓名"); //3 + titles.add("职位"); //4 + titles.add("手机"); //5 + titles.add("邮箱"); //6 + titles.add("最近登录"); //7 + titles.add("上次登录IP"); //8 + dataMap.put("titles", titles); + List userList = corpUsersService.listAllUser(pd); + List varList = new ArrayList(); + for(int i=0;i map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + if (null != file && !file.isEmpty()) { + String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase(); + if (!"xls".equals(suffixName)) { + map.put("result", "fail"); + map.put("exception", "上传文件格式不正确"); + return map; + } + String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE; //文件上传路径 + String fileName = FileUpload.fileUp(file, filePath, "userexcel"); //执行上传 + List listPd = (List)ObjectExcelRead.readExcel(filePath, fileName, 2, 0, 0); //执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet + pd.put("LAST_LOGIN", ""); //最后登录时间 + pd.put("IP", ""); //IP + pd.put("STATUS", "0"); //状态 + pd.put("SKIN", "pcoded-navbar navbar-image-3,navbar pcoded-header navbar-expand-lg navbar-light header-dark,"); //默认皮肤 + pd.put("ROLE_ID", "fhadminzhuche"); //默认角色注册用户 + pd.put("ROLE_IDS", ""); //副职角色 + /** + * var0 :编号 + * var1 :姓名 + * var2 :手机 + * var3 :邮箱 + * var4 :备注 + */ + for(int i=0;i map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + if("admin".equals(pd.getString("USERNAME"))){return null;} //不能查看admin用户 + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + map.put("fx", "user"); + pd = corpUsersService.findByUsername(pd); //根据ID读取 + String ROLE_IDS = pd.getString("ROLE_IDS"); //副职角色ID + if(Tools.notEmpty(ROLE_IDS)){ + String arryROLE_ID[] = ROLE_IDS.split(","); + for(int i=0;i map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String USERNAME = pd.getString("USERNAME"); + if("admin".equals(USERNAME)){return null;} //不能查看admin用户 + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + pd = corpUsersService.findByUsername(pd); //根据ID读取 + map.put("msg", "1"); + if(null == pd){ + PageData rpd = new PageData(); + rpd.put("RNUMBER", USERNAME); //用户名查不到数据时就把数据当作角色的编码去查询角色表 + rpd = roleService.getRoleByRnumber(rpd); + map.put("rpd", rpd); + map.put("msg", "2"); + } + map.put("pd", pd); + map.put("roleList", roleList); + map.put("result", errInfo); + return map; + } + + /**显示用户列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + @RequestMapping(value="/listUsersForWindow") + @ResponseBody + public Object listUsersForWindow(Page page)throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + String STRARTTIME = pd.getString("STRARTTIME"); //开始时间 + String ENDTIME = pd.getString("ENDTIME"); //结束时间 + if(Tools.notEmpty(STRARTTIME))pd.put("STRARTTIME", STRARTTIME+" 00:00:00"); + if(Tools.notEmpty(ENDTIME))pd.put("ENDTIME", ENDTIME+" 00:00:00"); + page.setPd(pd); + List userList = corpUsersService.listUsersBystaff(page); //列出用户列表(弹窗选择用) + pd.put("ROLE_ID", "1"); + List roleList = roleService.listAllRolesByPId(pd); //列出所有系统用户角色 + map.put("userList", userList); + map.put("roleList", roleList); + map.put("page", page); + map.put("pd", pd); + map.put("result", errInfo); + return map; + } + /**修改用户状态 STATUS + * @return + */ + @RequestMapping(value="/updateUserStatus") + @ResponseBody + public Object updateUserStatus() throws Exception{ + Map map = new HashMap(); + PageData pd = new PageData(); + String errInfo = "success"; + pd = this.getPageData(); + pd.put("STATUS",pd.getString("status")); + corpUsersService.updateUserStatus(pd); + FHLOG.save(Jurisdiction.getUsername(), "修改用户状态ID:"+pd.getString("USER_ID")); //记录日志 + map.put("result", errInfo); //返回结果 + return map; + } + +} diff --git a/src/main/java/com/zcloud/controller/system/ButtonrightsController.java b/src/main/java/com/zcloud/controller/system/ButtonrightsController.java index 2be7d301..d02e5a6d 100644 --- a/src/main/java/com/zcloud/controller/system/ButtonrightsController.java +++ b/src/main/java/com/zcloud/controller/system/ButtonrightsController.java @@ -1,9 +1,11 @@ package com.zcloud.controller.system; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.zcloud.service.bus.CorpInfoService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -28,53 +30,62 @@ import com.zcloud.util.Tools; @Controller @RequestMapping(value="/buttonrights") public class ButtonrightsController extends BaseController { - + @Autowired private ButtonrightsService buttonrightsService; @Autowired private RoleService roleService; + @Autowired + private CorpInfoService corpInfoService; @Autowired private FhButtonService fhButtonService; @Autowired private FHlogService FHLOG; - + /**列表 * @throws Exception */ @RequestMapping(value="/list") - @RequiresPermissions("buttonrights:list") @ResponseBody public Object list() throws Exception{ Map map = new HashMap(); String errInfo = "success"; - PageData pd = new PageData(); - pd = this.getPageData(); - if(Tools.isEmpty(pd.getString("ROLE_ID"))){ - pd.put("ROLE_ID", "1"); //默认列出第一组角色(初始设计系统用户组不能删除) - } + PageData pd = this.getPageData(); +// if(Tools.isEmpty(pd.getString("ROLE_ID"))){ +// pd.put("ROLE_ID", "1"); //默认列出第一组角色(初始设计系统用户组不能删除) +// } +// PageData fpd = new PageData(); +// fpd.put("ROLE_ID", "0"); + + + + String corpId = Jurisdiction.getCORPINFO_ID(); + pd.put("CORPINFO_ID", corpId); + PageData corp = corpInfoService.findById(pd); PageData fpd = new PageData(); - fpd.put("ROLE_ID", "0"); - List roleList = roleService.listAllRolesByPId(fpd); //列出组(页面横向排列的一级组) + fpd.put("CORPINFO_ID",corp.getString("ROLE_NAME")); + fpd.put("ROLE_ID",corp.getString("ROLE_NAME")); + pd.put("ROLE_ID",corp.getString("ROLE_NAME")); + Role roleList = roleService.getRoleById(corp.getString("ROLE_NAME")); //列出组(页面横向排列的一级组) List roleList_z = roleService.listAllRolesByPId(pd); //列出此组下架角色 List buttonlist = fhButtonService.listAll(pd); //列出所有按钮 List roleFhbuttonlist = buttonrightsService.listAll(pd); //列出所有角色按钮关联数据 pd = roleService.findById(pd); //取得点击的角色组(横排的) map.put("pd", pd); - map.put("roleList", roleList); + map.put("roleList", Collections.singletonList(roleList)); map.put("roleList_z", roleList_z); map.put("buttonlist", buttonlist); map.put("roleFhbuttonlist", roleFhbuttonlist); map.put("result", errInfo); return map; } - + /**点击按钮处理关联表 * @return * @throws Exception */ @RequestMapping(value="/upRb") @ResponseBody - @RequiresPermissions("buttonrights:edit") public Object updateRolebuttonrightd()throws Exception{ Map map = new HashMap(); PageData pd = new PageData(); @@ -90,5 +101,5 @@ public class ButtonrightsController extends BaseController { map.put("result", errInfo); return map; } - + } diff --git a/src/main/java/com/zcloud/controller/system/UsersController.java b/src/main/java/com/zcloud/controller/system/UsersController.java index 8beec699..1b92751a 100644 --- a/src/main/java/com/zcloud/controller/system/UsersController.java +++ b/src/main/java/com/zcloud/controller/system/UsersController.java @@ -1718,7 +1718,6 @@ public class UsersController extends BaseController { * * @param parentId 部门父节点id * @param departMap 全部部门信息 - * @param valName 部门名称 * @return 从子节点开始往上循序 */ public String getParentName(String parentId, Map departMap) { diff --git a/src/main/java/com/zcloud/entity/system/Role.java b/src/main/java/com/zcloud/entity/system/Role.java index b83ae519..369c8beb 100644 --- a/src/main/java/com/zcloud/entity/system/Role.java +++ b/src/main/java/com/zcloud/entity/system/Role.java @@ -15,6 +15,16 @@ public class Role { private String EDIT_QX; //修改权限(存放的除权后的菜单ID)有修改权限的菜单ID private String CHA_QX; //查看权限(存放的除权后的菜单ID)有查看权限的菜单ID private String RNUMBER; //编号(在处理类中新增的时候自动生成) + private String DEPT_TYPE; + + public String getDEPT_TYPE() { + return DEPT_TYPE; + } + + public void setDEPT_TYPE(String DEPT_TYPE) { + this.DEPT_TYPE = DEPT_TYPE; + } + private String Level; //用户等级 public String getROLE_ID() { diff --git a/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpMenuMapper.java b/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpMenuMapper.java new file mode 100644 index 00000000..7afb951d --- /dev/null +++ b/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpMenuMapper.java @@ -0,0 +1,62 @@ +package com.zcloud.mapper.datasource.corpsystem; + +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Menu; + +import java.util.List; + +/** + * 说明:菜单Mapper + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public interface CorpMenuMapper { + + /**新增菜单 + * @param menu + */ + void addMenu(Menu menu); + + /**保存修改菜单 + * @param menu + */ + void edit(Menu menu); + + /** + * 通过菜单ID获取数据 + * @param pd + * @return + */ + PageData getMenuById(PageData pd); + + /**获取最大的菜单ID + * @param pd + * @return + */ + PageData findMaxId(PageData pd); + + /**通过ID获取其子一级菜单 + * @param parentId + * @return + */ + List listSubMenuByParentId(String parentId); + + /**获取所有菜单并填充每个菜单的子菜单列表(菜单管理) + * @param MENU_ID + * @return + */ + List listAllMenu(String MENU_ID); + + /**删除菜单 + * @param MENU_ID + */ + void deleteMenuById(String MENU_ID); + + /**保存菜单图标 + * @param pd + * @return + */ + void editicon(PageData pd); + + List listSubMenuAll(String MENU_ID); +} diff --git a/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpRoleMapper.java b/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpRoleMapper.java new file mode 100644 index 00000000..fe3585ae --- /dev/null +++ b/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpRoleMapper.java @@ -0,0 +1,110 @@ +package com.zcloud.mapper.datasource.corpsystem; + + +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Role; + +import java.util.List; + +/** + * 说明:角色Mapper + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public interface CorpRoleMapper { + + /**通过角色ID获取数据 + * @param pd + * @return + */ + PageData findById(PageData pd); + + /**通过id查找(返回角色对象) + * @param roleId + * @return + */ + Role getRoleById(String ROLE_ID); + + /**通过角色编码查找 + * @param pd + * @return + */ + PageData getRoleByRnumber(PageData pd); + + /**通过组ID获取组下级角色列表 + * @param pd + * @return + */ + List listAllRolesByPId(PageData pd); + + /**添加 + * @param pd + */ + void add(PageData pd); + + /**保存修改 + * @param pd + */ + void edit(PageData pd); + + /**删除角色 + * @param ROLE_ID + * @throws Exception + */ + void deleteRoleById(String ROLE_ID); + + /**给当前角色附加菜单权限 + * @param role + * @throws Exception + */ + void updateRoleRights(Role role); + + /**给全部子角色加菜单权限 + * @param pd + * @throws Exception + */ + void setAllRights(PageData pd); + + /**权限(增删改查) + * @param msg 区分增删改查 + * @param pd + * @throws Exception + */ + void addQx(PageData pd); + + /**权限(增删改查) + * @param msg 区分增删改查 + * @param pd + * @throws Exception + */ + void delQx(PageData pd); + + /**权限(增删改查) + * @param msg 区分增删改查 + * @param pd + * @throws Exception + */ + void editQx(PageData pd); + + /**权限(增删改查) + * @param msg 区分增删改查 + * @param pd + * @throws Exception + */ + void chaQx(PageData pd); + + /**通过角色ID数组获取角色列表 + * @param arryROLE_ID + * @throws Exception + */ + List listAllRolesByArryROLE_ID(String[] arryROLE_ID); + + /**角色列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + List roleWindowlistPage(Page page); + +} diff --git a/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpUsersMapper.java b/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpUsersMapper.java new file mode 100644 index 00000000..3c0bb8d1 --- /dev/null +++ b/src/main/java/com/zcloud/mapper/datasource/corpsystem/CorpUsersMapper.java @@ -0,0 +1,130 @@ +package com.zcloud.mapper.datasource.corpsystem; + +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.User; + +import java.util.List; + +/** + * 说明:用户Mapper + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public interface CorpUsersMapper { + + /**通过用户获取数据 + * @param pd + * @return + */ + PageData findByUsername(PageData pd); + + /**用户列表 + * @param page + * @return + */ + List userlistPage(Page page); + + /**通过用户ID获取用户信息和角色信息 + * @param USER_ID + * @return + */ + User getUserAndRoleById(String USER_ID); + + /**通过邮箱获取数据 + * @param pd + * @return + * @throws Exception + */ + PageData findByEmail(PageData pd); + + /**通过编码获取数据 + * @param pd + * @return + * @throws Exception + */ + PageData findByNumbe(PageData pd); + + /**列出某角色下的所有用户 + * @param pd + * @return + * @throws Exception + */ + List listAllUserByRoldId(PageData pd); + + /**用户列表(全部) + * @param pd + * @return + * @throws Exception + */ + List listAllUser(PageData pd); + + /**用户列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + List userBystafflistPage(Page page); + + /**通过用户ID获取数据 + * @param pd + * @return + * @throws Exception + */ + PageData findById(PageData pd); + + /**通过分公司ID获取数据 + * @param pd + * @return + * @throws Exception + */ + PageData findByCorpId(PageData pd); + + /**保存用户IP + * @param pd + */ + void saveIP(PageData pd); + + /**保存用户 + * @param pd + * @throws Exception + */ + void saveUser(PageData pd); + void editPassword(PageData pd); + + /**保存用户系统皮肤 + * @param pd + * @throws Exception + */ + void saveSkin(PageData pd); + + /**修改用户 + * @param pd + * @throws Exception + */ + void editUser(PageData pd); + + /**删除用户 + * @param pd + * @throws Exception + */ + void deleteUser(PageData pd); + + /**批量删除用户 + * @param pd + * @throws Exception + */ + void deleteAllUser(String[] USER_IDS); + + /**修改用户小程序权限 + * @param pd + * @throws Exception + */ + void editUserFuns(PageData pd); + Integer hasUserName (PageData pd); + + List listUserAndDept (PageData pd); + void updateUserStatus (PageData pd); + + void unLockUser(PageData pd); +} diff --git a/src/main/java/com/zcloud/service/system/corpsystem/CorpMenuService.java b/src/main/java/com/zcloud/service/system/corpsystem/CorpMenuService.java new file mode 100644 index 00000000..931731b8 --- /dev/null +++ b/src/main/java/com/zcloud/service/system/corpsystem/CorpMenuService.java @@ -0,0 +1,75 @@ +package com.zcloud.service.system.corpsystem; + +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Menu; + +import java.util.List; + +/** + * 说明:菜单服务接口 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public interface CorpMenuService { + + /**新增菜单 + * @param menu + * @throws Exception + */ + public void addMenu(Menu menu) throws Exception; + + /**保存修改菜单 + * @param menu + * @throws Exception + */ + public void edit(Menu menu) throws Exception; + + /**获取最大的菜单ID + * @param pd + * @return + * @throws Exception + */ + public PageData findMaxId(PageData pd) throws Exception; + + /**获取所有菜单并填充每个菜单的子菜单列表(系统菜单列表) + * @param MENU_ID + * @return + * @throws Exception + */ + public List listAllMenuQx(String MENU_ID) throws Exception; + + /**通过ID获取其子一级菜单 + * @param parentId + * @return + * @throws Exception + */ + public List listSubMenuByParentId(String parentId)throws Exception; + + /**获取所有菜单并填充每个菜单的子菜单列表(菜单管理)( + * @param MENU_ID + * @return + * @throws Exception + */ + public List listAllMenu(String MENU_ID) throws Exception; + + /**获取所有菜单并填充每个菜单的子菜单列表(系统菜单列表) + * @param pd + * @return + * @throws Exception + */ + public PageData getMenuById(PageData pd) throws Exception; + + /**删除菜单 + * @param MENU_ID + * @throws Exception + */ + public void deleteMenuById(String MENU_ID) throws Exception; + + /**保存菜单图标 + * @param pd + * @throws Exception + */ + public void editicon(PageData pd) throws Exception; + public List listSubMenuAll()throws Exception; + +} diff --git a/src/main/java/com/zcloud/service/system/corpsystem/CorpRoleService.java b/src/main/java/com/zcloud/service/system/corpsystem/CorpRoleService.java new file mode 100644 index 00000000..753d1458 --- /dev/null +++ b/src/main/java/com/zcloud/service/system/corpsystem/CorpRoleService.java @@ -0,0 +1,94 @@ +package com.zcloud.service.system.corpsystem; + +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Role; + +import java.util.List; + +/** + * 说明:角色服务接口 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public interface CorpRoleService { + + /**通过角色ID获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData findById(PageData pd)throws Exception; + + /**通过id查找(返回角色对象) + * @param roleId + * @return + * @throws Exception + */ + public Role getRoleById(String ROLE_ID) throws Exception; + + /**通过组ID获取组下级角色列表 + * @param pd + * @return + * @throws Exception + */ + public List listAllRolesByPId(PageData pd) throws Exception; + + /**通过角色编码查找 + * @param pd + * @return + * @throws Exception + */ + public PageData getRoleByRnumber(PageData pd) throws Exception; + + /**添加 + * @param pd + * @throws Exception + */ + public void add(PageData pd) throws Exception; + + /**保存修改 + * @param pd + * @throws Exception + */ + public void edit(PageData pd) throws Exception; + + /**删除角色 + * @param ROLE_ID + * @throws Exception + */ + public void deleteRoleById(String ROLE_ID) throws Exception; + + /**给当前角色附加菜单权限 + * @param role + * @throws Exception + */ + public void updateRoleRights(Role role) throws Exception; + + /**给全部子角色加菜单权限 + * @param pd + * @throws Exception + */ + public void setAllRights(PageData pd) throws Exception; + + /**权限(增删改查) + * @param msg 区分增删改查 + * @param pd + * @throws Exception + */ + public void saveB4Button(String msg,PageData pd) throws Exception; + + /**通过角色ID数组获取角色列表 + * @param arryROLE_ID + * @throws Exception + */ + public List getRoleByArryROLE_ID(String[] arryROLE_ID)throws Exception; + + /**角色列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + public List roleListWindow(Page page)throws Exception; + +} diff --git a/src/main/java/com/zcloud/service/system/corpsystem/CorpUsersService.java b/src/main/java/com/zcloud/service/system/corpsystem/CorpUsersService.java new file mode 100644 index 00000000..90e57b56 --- /dev/null +++ b/src/main/java/com/zcloud/service/system/corpsystem/CorpUsersService.java @@ -0,0 +1,133 @@ +package com.zcloud.service.system.corpsystem; + +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.User; + +import java.util.List; + +/** + * 说明:用户服务接口 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public interface CorpUsersService { + + /**通过用户名获取用户信息 + * @param pd + * @return + * @throws Exception + */ + public PageData findByUsername(PageData pd)throws Exception; + + /**通过用户ID获取用户信息 + * @param pd + * @return + * @throws Exception + */ + public PageData findById(PageData pd)throws Exception; + + /**用户列表 + * @param page + * @return + * @throws Exception + */ + public List userlistPage(Page page)throws Exception; + + /**通过用户ID获取用户信息和角色信息 + * @param USER_ID + * @return + * @throws Exception + */ + public User getUserAndRoleById(String USER_ID) throws Exception; + + /**保存用户IP + * @param pd + * @throws Exception + */ + public void saveIP(PageData pd)throws Exception; + + /**通过邮箱获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData findByEmail(PageData pd)throws Exception; + + /**通过编码获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData findByNumbe(PageData pd) throws Exception; + + /**列出某角色下的所有用户 + * @param pd + * @return + * @throws Exception + */ + public List listAllUserByRoldId(PageData pd) throws Exception; + + /**用户列表(全部) + * @param pd + * @return + * @throws Exception + */ + public List listAllUser(PageData pd)throws Exception; + + /**用户列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + public List listUsersBystaff(Page page)throws Exception; + + /**保存用户 + * @param pd + * @throws Exception + */ + public void saveUser(PageData pd)throws Exception; + + /**保存用户系统皮肤 + * @param pd + * @throws Exception + */ + public void saveSkin(PageData pd)throws Exception; + + /**修改用户 + * @param pd + * @throws Exception + */ + public void editUser(PageData pd)throws Exception; + public void editPassword(PageData pd)throws Exception; + + /**删除用户 + * @param pd + * @throws Exception + */ + public void deleteUser(PageData pd)throws Exception; + + /**批量删除用户 + * @param pd + * @throws Exception + */ + public void deleteAllUser(String[] USER_IDS)throws Exception; + + /**修改用户小程序权限 + * @param pd + * @throws Exception + */ + public void editUserFuns(PageData pd); + + public Integer hasUserName(PageData pd)throws Exception; + + public List listUserAndDept (PageData pd) throws Exception; + + /*** + * 修改用户状态 + * @param pd + * @return + * @throws Exception + */ + public void updateUserStatus (PageData pd) throws Exception; +} diff --git a/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpMenuServiceImpl.java b/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpMenuServiceImpl.java new file mode 100644 index 00000000..8b09cca3 --- /dev/null +++ b/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpMenuServiceImpl.java @@ -0,0 +1,126 @@ +package com.zcloud.service.system.corpsystem.impl; + +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Menu; +import com.zcloud.mapper.datasource.corpsystem.CorpMenuMapper; +import com.zcloud.service.system.corpsystem.CorpMenuService; +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 java.util.List; + +/** + * 说明:菜单服务接口实现类 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +@Service +@Transactional //开启事物 +public class CorpMenuServiceImpl implements CorpMenuService { + + @Autowired + private CorpMenuMapper corpMenuMapper; + + /**新增菜单 + * @param menu + * @throws Exception + */ + @CacheEvict(value="menucache", allEntries=true) + public void addMenu(Menu menu) throws Exception{ + corpMenuMapper.addMenu(menu); + } + + /**保存修改菜单 + * @param menu + * @throws Exception + */ + @CacheEvict(value="menucache", allEntries=true) + public void edit(Menu menu) throws Exception{ + corpMenuMapper.edit(menu); + } + + /** + * 通过菜单ID获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData getMenuById(PageData pd) throws Exception { + return corpMenuMapper.getMenuById(pd); + } + + /**获取最大的菜单ID + * @param pd + * @return + * @throws Exception + */ + public PageData findMaxId(PageData pd) throws Exception{ + return corpMenuMapper.findMaxId(pd); + } + + /** + * 通过ID获取其子一级菜单 + * @param parentId + * @return + * @throws Exception + */ + @Cacheable(key="'menu-'+#parentId",value="menucache") + public List listSubMenuByParentId(String parentId) throws Exception { + return corpMenuMapper.listSubMenuByParentId(parentId); + } + + /** + * 获取所有菜单并填充每个菜单的子菜单列表(菜单管理)(递归处理) + * @param MENU_ID + * @return + * @throws Exception + */ + public List listAllMenu(String MENU_ID) throws Exception { + List menuList = this.listSubMenuByParentId(MENU_ID); + for(Menu menu : menuList){ + menu.setMENU_URL("menu_edit.html?MENU_ID="+menu.getMENU_ID()); + menu.setSubMenu(this.listAllMenu(menu.getMENU_ID())); + menu.setTarget("treeFrame"); + } + return menuList; + } + + /** + * 获取所有菜单并填充每个菜单的子菜单列表(系统菜单列表)(递归处理) + * @param MENU_ID + * @return + * @throws Exception + */ + public List listAllMenuQx(String MENU_ID) throws Exception { + List menuList = this.listSubMenuByParentId(MENU_ID); + for(Menu menu : menuList){ + menu.setSubMenu(this.listAllMenuQx(menu.getMENU_ID())); + menu.setTarget("treeFrame"); + } + return menuList; + } + + /**删除菜单 + * @param MENU_ID + * @throws Exception + */ + @CacheEvict(value="menucache", allEntries=true) + public void deleteMenuById(String MENU_ID) throws Exception{ + corpMenuMapper.deleteMenuById(MENU_ID); + } + + /**保存菜单图标 + * @param pd + * @throws Exception + */ + @CacheEvict(value="menucache", allEntries=true) + public void editicon(PageData pd) throws Exception{ + corpMenuMapper.editicon(pd); + } + public List listSubMenuAll()throws Exception{ + return corpMenuMapper.listSubMenuAll(""); + } +} diff --git a/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpRoleServiceImpl.java b/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpRoleServiceImpl.java new file mode 100644 index 00000000..1f4442cc --- /dev/null +++ b/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpRoleServiceImpl.java @@ -0,0 +1,136 @@ +package com.zcloud.service.system.corpsystem.impl; + +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.Role; +import com.zcloud.mapper.datasource.corpsystem.CorpRoleMapper; +import com.zcloud.service.system.corpsystem.CorpRoleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 说明:角色服务接口实现类 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +@Service +@Transactional //开启事物 +public class CorpRoleServiceImpl implements CorpRoleService { + + @Autowired + private CorpRoleMapper corpRoleMapper; + + /**通过角色ID获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData findById(PageData pd) throws Exception { + return corpRoleMapper.findById(pd); + } + + /**通过id查找(返回角色对象) + * @param roleId + * @return + * @throws Exception + */ + public Role getRoleById(String ROLE_ID) throws Exception{ + return corpRoleMapper.getRoleById(ROLE_ID); + } + + /**通过角色编码查找 + * @param pd + * @return + * @throws Exception + */ + public PageData getRoleByRnumber(PageData pd) throws Exception{ + return corpRoleMapper.getRoleByRnumber(pd); + } + + /**通过组ID获取组下级角色列表 + * @param pd + * @return + * @throws Exception + */ + public List listAllRolesByPId(PageData pd) throws Exception { + return corpRoleMapper.listAllRolesByPId(pd); + } + + /**添加 + * @param pd + * @throws Exception + */ + public void add(PageData pd) throws Exception{ + corpRoleMapper.add( pd); + } + + /**保存修改 + * @param pd + * @throws Exception + */ + public void edit(PageData pd) throws Exception{ + corpRoleMapper.edit( pd); + } + + /**删除角色 + * @param ROLE_ID + * @throws Exception + */ + public void deleteRoleById(String ROLE_ID) throws Exception{ + corpRoleMapper.deleteRoleById(ROLE_ID); + } + + /**给当前角色附加菜单权限 + * @param role + * @throws Exception + */ + public void updateRoleRights(Role role) throws Exception{ + corpRoleMapper.updateRoleRights(role); + } + + /**给全部子角色加菜单权限 + * @param pd + * @throws Exception + */ + public void setAllRights(PageData pd) throws Exception{ + corpRoleMapper.setAllRights(pd); + } + + /**权限(增删改查) + * @param msg 区分增删改查 + * @param pd + * @throws Exception + */ + public void saveB4Button(String msg,PageData pd) throws Exception{ + if("add_qx".equals(msg)){ + corpRoleMapper.addQx(pd); + }else if("del_qx".equals(msg)){ + corpRoleMapper.delQx(pd); + }else if("edit_qx".equals(msg)){ + corpRoleMapper.editQx(pd); + }else if("cha_qx".equals(msg)){ + corpRoleMapper.chaQx(pd); + } + } + + /**通过角色ID数组获取角色列表 + * @param arryROLE_ID + * @throws Exception + */ + public List getRoleByArryROLE_ID(String[] arryROLE_ID)throws Exception{ + return corpRoleMapper.listAllRolesByArryROLE_ID(arryROLE_ID); + } + + /**角色列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + public List roleListWindow(Page page)throws Exception{ + return corpRoleMapper.roleWindowlistPage(page); + } + +} diff --git a/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpUsersServiceImpl.java b/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpUsersServiceImpl.java new file mode 100644 index 00000000..ccc6e72a --- /dev/null +++ b/src/main/java/com/zcloud/service/system/corpsystem/impl/CorpUsersServiceImpl.java @@ -0,0 +1,177 @@ +package com.zcloud.service.system.corpsystem.impl; + +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.entity.system.User; +import com.zcloud.mapper.datasource.corpsystem.CorpUsersMapper; +import com.zcloud.service.system.corpsystem.CorpUsersService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 说明:用户服务接口实现类 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +@Service +@Transactional //开启事物 +public class CorpUsersServiceImpl implements CorpUsersService { + + @Autowired + private CorpUsersMapper corpUsersMapper; + + /**通过用户名获取用户信息 + * @param pd + * @return + * @throws Exception + */ + public PageData findByUsername(PageData pd) throws Exception { + return corpUsersMapper.findByUsername(pd); + } + + /**通过用户ID获取用户信息 + * @param pd + * @return + * @throws Exception + */ + public PageData findById(PageData pd)throws Exception{ + return corpUsersMapper.findById(pd); + } + + /**用户列表 + * @param page + * @return + * @throws Exception + */ + public List userlistPage(Page page) throws Exception { + return corpUsersMapper.userlistPage(page); + } + + /**通过用户ID获取用户信息和角色信息 + * @param USER_ID + * @return + * @throws Exception + */ + public User getUserAndRoleById(String USER_ID) throws Exception { + return corpUsersMapper.getUserAndRoleById(USER_ID); + } + + /**保存用户IP + * @param pd + * @throws Exception + */ + public void saveIP(PageData pd) throws Exception { + corpUsersMapper.saveIP(pd); + } + + /**通过邮箱获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData findByEmail(PageData pd) throws Exception { + return corpUsersMapper.findByEmail(pd); + } + + /**通过编码获取数据 + * @param pd + * @return + * @throws Exception + */ + public PageData findByNumbe(PageData pd) throws Exception { + return corpUsersMapper.findByNumbe(pd); + } + + /**列出某角色下的所有用户 + * @param pd + * @return + * @throws Exception + */ + public List listAllUserByRoldId(PageData pd) throws Exception{ + return corpUsersMapper.listAllUserByRoldId(pd); + } + + /**用户列表(全部) + * @param pd + * @return + * @throws Exception + */ + public List listAllUser(PageData pd)throws Exception{ + return corpUsersMapper.listAllUser(pd); + } + + /**用户列表(弹窗选择用) + * @param page + * @return + * @throws Exception + */ + public List listUsersBystaff(Page page)throws Exception{ + return corpUsersMapper.userBystafflistPage(page); + } + + /**保存用户 + * @param pd + * @throws Exception + */ + public void saveUser(PageData pd)throws Exception { + corpUsersMapper.saveUser(pd); + } + + /**保存用户系统皮肤 + * @param pd + * @throws Exception + */ + public void saveSkin(PageData pd)throws Exception{ + corpUsersMapper.saveSkin(pd); + } + + /**修改用户 + * @param pd + * @throws Exception + */ + public void editUser(PageData pd)throws Exception{ + corpUsersMapper.editUser(pd); + } + public void editPassword(PageData pd)throws Exception{ + corpUsersMapper.editPassword(pd); + } + + /**删除用户 + * @param pd + * @throws Exception + */ + public void deleteUser(PageData pd)throws Exception{ + corpUsersMapper.deleteUser(pd); + } + + /**批量删除用户 + * @param pd + * @throws Exception + */ + public void deleteAllUser(String[] USER_IDS)throws Exception{ + corpUsersMapper.deleteAllUser(USER_IDS); + } + + /**修改用户小程序权限 + * @param pd + * @throws Exception + */ + public void editUserFuns(PageData pd) { + corpUsersMapper.editUserFuns(pd); + } + + @Override + public Integer hasUserName(PageData pd) throws Exception { + return corpUsersMapper.hasUserName(pd); + } + + public List listUserAndDept (PageData pd) throws Exception{ + return corpUsersMapper.listUserAndDept(pd); + } + public void updateUserStatus (PageData pd) throws Exception{ + corpUsersMapper.updateUserStatus(pd); + } +} diff --git a/src/main/java/com/zcloud/util/Const.java b/src/main/java/com/zcloud/util/Const.java index ef400d4c..80f20580 100644 --- a/src/main/java/com/zcloud/util/Const.java +++ b/src/main/java/com/zcloud/util/Const.java @@ -8,6 +8,8 @@ package com.zcloud.util; public class Const { public static final String SESSION_USER = "SESSION_USER"; //session用的用户 + public static final String SESSION_DEPT = "SESSION_DEPT"; //session用的用户 + public static final String SESSION_USERROL = "SESSION_USERROL"; //用户对象(包含角色信息) public static final String SESSION_ROLE_RIGHTS = "SESSION_ROLE_RIGHTS"; //角色菜单权限 public static final String SHIROSET = "SHIROSET"; //菜单权限标识 diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 0841eb62..20e9d9dc 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,13 +1,13 @@ datasource.no1.driver-class-name: com.mysql.cj.jdbc.Driver -datasource.no1.url=jdbc:mysql://39.101.130.96:33068/qa-gwj-prevention?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8 +datasource.no1.url=jdbc:mysql://192.168.0.17:3306/qa-gwj-prevention?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8 datasource.no1.username=root -datasource.no1.password=Mysql@zcloud88888 +datasource.no1.password=root datasource.no2.driver-class-name: com.mysql.cj.jdbc.Driver -datasource.no2.url=jdbc:mysql://39.101.130.96:33068/qa-gwj-regulatory?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8 +datasource.no2.url=jdbc:mysql://192.168.0.17:3306/qa-gwj-regulatory?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8 datasource.no2.username=root -datasource.no2.password=Mysql@zcloud88888 +datasource.no2.password=root #druid??? diff --git a/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml b/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml new file mode 100644 index 00000000..24f3cd6b --- /dev/null +++ b/src/main/resources/mybatis/datasource/corpsystem/CorpMenuMapper.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SYS_MENU + + + + + MENU_ID, + MENU_NAME, + MENU_URL, + PARENT_ID, + MENU_ICON, + SHIRO_KEY, + MENU_ORDER, + MENU_STATE, + MENU_TYPE, + COMPONENT, + SHOW_MODEL + + + + + #{MENU_ID}, + #{MENU_NAME}, + #{MENU_URL}, + #{PARENT_ID}, + #{MENU_ICON}, + #{SHIRO_KEY}, + #{MENU_ORDER}, + #{MENU_STATE}, + #{MENU_TYPE}, + #{COMPONENT}, + #{SHOW_MODEL} + + + + + insert into + + ( + + ) values ( + + ) + + + + + update + + set + MENU_NAME =#{MENU_NAME}, + MENU_URL =#{MENU_URL} , + MENU_ORDER=#{MENU_ORDER}, + MENU_STATE=#{MENU_STATE}, + SHIRO_KEY=#{SHIRO_KEY}, + MENU_TYPE =#{MENU_TYPE}, + COMPONENT=#{COMPONENT}, + SHOW_MODEL=#{SHOW_MODEL} + where + MENU_ID=#{MENU_ID} + + + + + + + + + + + + + + delete from + + where MENU_ID=#{MENU_ID} + + + + + update + + set + MENU_ICON=#{MENU_ICON} + where + MENU_ID=#{MENU_ID} + + + + diff --git a/src/main/resources/mybatis/datasource/corpsystem/CorpRoleMapper.xml b/src/main/resources/mybatis/datasource/corpsystem/CorpRoleMapper.xml new file mode 100644 index 00000000..00d9bf33 --- /dev/null +++ b/src/main/resources/mybatis/datasource/corpsystem/CorpRoleMapper.xml @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + SYS_ROLE + + + + + ROLE_ID, + ROLE_NAME, + RIGHTS, + PARENT_ID, + ADD_QX, + DEL_QX, + EDIT_QX, + CHA_QX, + DEPT_TYPE, + RNUMBER, + LEVEL, + PRIMARYNUM + + + + + #{ROLE_ID}, + #{ROLE_NAME}, + #{RIGHTS}, + #{PARENT_ID}, + #{ADD_QX}, + #{DEL_QX}, + #{EDIT_QX}, + #{CHA_QX}, + #{DEPT_TYPE}, + #{RNUMBER}, + #{LEVEL}, + #{PRIMARYNUM} + + + + + + + + + + + + + + + + + insert into + + ( + + ) values ( + + ) + + + + + update + + set ROLE_NAME = #{ROLE_NAME}, + DEPT_TYPE = #{DEPT_TYPE}, + PRIMARYNUM = #{PRIMARYNUM}, + LEVEL = #{LEVEL} + where ROLE_ID = #{ROLE_ID} + + + + + delete from + + where ROLE_ID=#{ROLE_ID} + + + + + update + + set RIGHTS=#{RIGHTS} + where ROLE_ID=#{ROLE_ID} + + + + + update + + set RIGHTS=#{rights} + where PARENT_ID=#{ROLE_ID} + + + + + update + + set ADD_QX=#{value} + where ROLE_ID=#{ROLE_ID} + + + + + update + + set DEL_QX=#{value} + where ROLE_ID=#{ROLE_ID} + + + + + update + + set EDIT_QX=#{value} + where ROLE_ID=#{ROLE_ID} + + + + + update + + set CHA_QX=#{value} + where ROLE_ID=#{ROLE_ID} + + + + + + + + + diff --git a/src/main/resources/mybatis/datasource/corpsystem/CorpUsersMapper.xml b/src/main/resources/mybatis/datasource/corpsystem/CorpUsersMapper.xml new file mode 100644 index 00000000..63d5f9de --- /dev/null +++ b/src/main/resources/mybatis/datasource/corpsystem/CorpUsersMapper.xml @@ -0,0 +1,549 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SYS_USER + + + + + SYS_ROLE + + + + + USER_ID, + USERNAME, + PASSWORD, + NAME, + ROLE_ID, + LAST_LOGIN, + IP, + STATUS, + BZ, + SKIN, + EMAIL, + NUMBER, + PHONE, + ROLE_IDS, + FUN_IDS, + TYPE, + LEVEL, + PROVINCE, + CITY, + COUNTRY, + VILLAGE, + SEX, + SORT, + JOB_LEVEL, + JOB + + + + + #{USER_ID}, + #{USERNAME}, + #{PASSWORD}, + #{NAME}, + #{ROLE_ID}, + #{LAST_LOGIN}, + #{IP}, + #{STATUS}, + #{BZ}, + #{SKIN}, + #{EMAIL}, + #{NUMBER}, + #{PHONE}, + #{ROLE_IDS}, + #{DEPARTMENT_ID}, + #{FUN_IDS}, + #{TYPE}, + #{LEVEL}, + #{PROVINCE}, + #{CITY}, + #{COUNTRY}, + #{VILLAGE}, + #{SEX}, + #{SORT}, + #{JOB_LEVEL}, + #{JOB} + + + + + + + + + + + + + + + + + + + + + + + insert into ( + + ) values ( + + ) + + + + + update + + set NAME = #{NAME}, + DEPARTMENT_ID = #{DEPARTMENT_ID}, + ROLE_ID = #{ROLE_ID}, + ROLE_IDS = #{ROLE_IDS}, + BZ = #{BZ}, + EMAIL = #{EMAIL}, + NUMBER = #{NUMBER}, + PHONE = #{PHONE}, + LEVEL=#{LEVEL}, + TYPE=#{TYPE}, + PROVINCE=#{PROVINCE}, + CITY=#{CITY}, + COUNTRY=#{COUNTRY}, + VILLAGE=#{VILLAGE} + + ,PASSWORD = #{PASSWORD} + + where + USER_ID = #{USER_ID} + + + update + + set PASSWORD = #{PASSWORD} + where + USER_ID = #{USER_ID} + + + + + + + + + + + + + + update + + set + IP = #{IP}, + LAST_LOGIN = #{LAST_LOGIN} + where + USERNAME = #{USERNAME} + + + + + update + + set + SKIN = #{SKIN} + where USERNAME = #{USERNAME} + + + + + delete from + + where + USER_ID = #{USER_ID} + and + USER_ID != '1' + + + + + delete from + + where + USER_ID in + + #{item} + + and + USER_ID != '1' + + + + + + + + update + + set FUN_IDS = #{FUN_IDS} + where + USER_ID = #{USER_ID} + + + + + + update + + set + STATUS = #{STATUS} + where USER_ID = #{USER_ID} + + + + + update + + set + STATUS = #{STATUS}, + ERROR_COUNT = #{ERROR_COUNT} + where USER_ID = #{USER_ID} + +