package com.ibeetl.admin.console.api; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.ibeetl.admin.console.model.AppRoleModel; import com.ibeetl.admin.console.model.CoreRoleModel; import com.ibeetl.admin.console.model.CoreUserModel; import com.ibeetl.admin.console.service.*; import com.ibeetl.admin.console.web.query.*; import com.ibeetl.admin.core.dao.CoreUserRoleDao; import com.ibeetl.admin.core.entity.*; import com.ibeetl.admin.core.rbac.UserLoginInfo; import com.ibeetl.admin.core.rbac.tree.MenuItem; import com.ibeetl.admin.core.rbac.tree.OrgItem; import com.ibeetl.admin.core.service.CoreDictService; import com.ibeetl.admin.core.service.CorePlatformService; import com.ibeetl.admin.core.service.CoreRoleService; import com.ibeetl.admin.core.service.CoreUserService; import com.ibeetl.admin.core.util.*; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.dto.MenuNodeView; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.engine.PageQuery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.util.*; import java.util.List; /** * 用户管理 */ @RestController @Api(value = "登陆和用户管理的接口") public class CuserApi { private static final String MODEL = "/admin/front"; private final Logger log = LoggerFactory.getLogger(this.getClass()); @Autowired CuserConsoleService service; @Autowired CoreUserService userService; @Autowired HttpRequestLocal httpRequestLocal; @Autowired CorePlatformService platformService; @Autowired RedisService redisService; @Autowired private DictConsoleService dictService; @Autowired XzxSysAddressLevelInfoService xzxSysAddressLevelInfoService; @Autowired UserConsoleService userConsoleService; @Autowired private OrgConsoleService orgConsoleService; @Autowired private RoleConsoleService roleConsoleService; @Autowired CoreDictService coreDictService; @Autowired FunctionConsoleService functionConsoleService; @Autowired CoreRoleService coreRoleService; @Autowired XzxCityPartnerService xzxCityPartnerService; /** * 登陆接口 * @param request * @param response * @return */ @PostMapping(MODEL+"/loginData.do") @ResponseBody @ApiOperation(value="用户登陆", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "code", value = "用户ID", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "password", value = "密码", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "verify", value = "验证码", required = true, dataType = "String") }) public JsonResult> loginData(HttpServletRequest request, HttpServletResponse response, @RequestBody AppRoleModel model){ //String ipAddr = request.getRequestURL().toString(); String userType="1"; Map resultMap = new HashMap<>(); if(null!=redisService.get("xzx:user:verify:code")){ System.out.println(redisService.get("xzx:user:verify:code").toString()); if(!redisService.get("xzx:user:verify:code").toString().equalsIgnoreCase(model.getVerify())){ /*if(ipAddr.indexOf("192.168.0.83") != -1){ }else{*/ if(!request.getSession().getAttribute("cap").toString().equalsIgnoreCase(model.getVerify())){ resultMap.put("code",-1); resultMap.put("msg","验证码错误"); return JsonResult.failMessage("验证码错误"); } //} } }else{ if(!request.getSession().getAttribute("cap").toString().equalsIgnoreCase(model.getVerify())){ /* if(ipAddr.indexOf("192.168.0.83") != -1){ }else{*/ //redisService.set("xzx:user:verify:"+model.getCode(), request.getSession().getAttribute("cap").toString()); resultMap.put("code",-1); resultMap.put("msg","验证码错误"); return JsonResult.failMessage("验证码错误"); //} } } String jsessionid = request.getSession().getId(); Cookie cookie =new Cookie("JSESSIONID",jsessionid); cookie.setMaxAge(60*60*24*7); response.addCookie(cookie); String code = model.getCode(); String password = model.getPassword(); Map map = userService.loginApi(code, password,userType); Object obj = map.get("userLoginInfo"); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); UserLoginInfo info = objectMapper.convertValue(obj, UserLoginInfo.class); if (map.get("msg") != null) { return JsonResult.failMessage(map.get("msg").toString()); } CoreUser user = info.getUser(); redisService.remove("xzx:user:token:"+user.getId()); //redisService.remove("xzx:user:verify:"+model.getCode()); CoreOrg currentOrg = info.getOrgs().get(0); for (CoreOrg org : info.getOrgs()) { if (org.getId() == user.getOrgId()) { currentOrg = org; break; } } info.setCurrentOrg(currentOrg); // 记录登录信息到session this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs()); String token = TokenUtils.createToken(); redisService.set("xzx:user:loginToken:"+info.getUser().getId(), token); //Gson gson = new Gson(); resultMap.put("userId",info.getUser().getId()); resultMap.put("token",token); resultMap.put("userType",map.get("userType")); resultMap.put("jsessionid",jsessionid); //redisService.remove("xzx:user:verify:code"); return JsonResult.success(resultMap); } @PostMapping("/logoutApi.do") @ResponseBody @ApiOperation(value="用户登出", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "session", value = "需要把sessionId放入请求头", required = true, dataType = "String") }) public JsonResult logout(HttpServletRequest request) { HttpSession session = request.getSession(); Enumeration eum = session.getAttributeNames(); while(eum.hasMoreElements()) { String key = (String)eum.nextElement(); session.removeAttribute(key); } return JsonResult.success("登出成功!"); } /** * 菜单接口 * @return */ @PostMapping(MODEL+"/userMenu.do") @ApiOperation(value="用户获取菜单", notes="用户跨域获取权限菜单") @ResponseBody public JsonResult> userMenu(){ CoreUser user =platformService.getCurrentUser(); //查询角色 //CoreUserRole coreRole =coreRoleService.getRoleByUserId(user.getId(),user.getOrgId()); //List dbs = functionConsoleService.getFunctionByRole(coreRole.getRoleId()); //List dbs = functionConsoleService.getFunctionByRole(user.getRoleId()); Map resultMap = new HashMap<>(); List allView= new ArrayList<>(); List view=new ArrayList<>(); MenuItem allItem = platformService.getAllMenuItem(); //判断是否是合伙人 XzxCityPartner partner = xzxCityPartnerService.queryById(user.getId()); if(null!=partner){ /* String pUid = partner.getUserId(); pUid = pUid.substring(pUid.length()-6,pUid.length()); XzxCityPartner pn = xzxCityPartnerService.queryEntityByUserIds(pUid); String userId = pn.getUserId().substring(pn.getUserId().length()-6,pn.getUserId().length());*/ MenuItem menuItem = platformService.getPartnerMenuItem(partner.getId(), user.getOrgId()); view = this.build(menuItem); }else{ MenuItem menuItem = platformService.getMenuItem(user.getId(), user.getOrgId()); view = this.build(menuItem); } allView = this.build(allItem); resultMap.put("user",user); resultMap.put("menu",view); resultMap.put("allView",allView); return JsonResult.success(resultMap); } private List buildExitFunction(MenuItem node,List dbs) { List list = node.getChildren(); if (list.size() == 0) { return Collections.EMPTY_LIST; } List views = new ArrayList(list.size()); for (MenuItem item : list) { boolean bool = false; if(!item.getParent().getName().equals("主菜单")){ for (Long menuId:dbs) { if(menuId.equals(item.getId())){ bool=true; } } if(bool){ MenuNodeView view = new MenuNodeView(); view.setCode(item.getData().getCode()); view.setName(item.getData().getName()); view.setIcon(item.getData().getIcon()); view.setId(item.getData().getId()); view.setCreateTime(item.getCreateTime()); view.setPath((String) item.getData().get("accessUrl")); List children = this.build(item); view.setChildren(children); views.add(view); } }else{ MenuNodeView view = new MenuNodeView(); view.setCode(item.getData().getCode()); view.setName(item.getData().getName()); view.setIcon(item.getData().getIcon()); view.setId(item.getData().getId()); view.setCreateTime(item.getCreateTime()); view.setPath((String) item.getData().get("accessUrl")); List children = this.buildExitFunction(item,dbs); view.setChildren(children); views.add(view); } } return views; } private List build(MenuItem node) { List list = node.getChildren(); if (list.size() == 0) { return Collections.EMPTY_LIST; } List views = new ArrayList(list.size()); for (MenuItem item : list) { MenuNodeView view = new MenuNodeView(); view.setCode(item.getData().getCode()); view.setName(item.getData().getName()); view.setIcon(item.getData().getIcon()); view.setId(item.getData().getId()); view.setCreateTime(item.getCreateTime()); view.setPath((String) item.getData().get("accessUrl")); List children = this.build(item); view.setChildren(children); views.add(view); } return views; } /** * 用户管理列表接口 * @param condtion * @return */ @PostMapping(MODEL + "/userList.do") @ResponseBody @ApiOperation(value="用户管理列表接口", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "code", value = "用户名", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "姓名", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "orgId", value = "部门", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "state", value = "状态", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "jobType0", value = "职务", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "jobType1", value = "职务明细", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "startTime", value = "创建日期开始时间", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "endTime", value = "创建日期结束时间", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "limit", value = "每页数据个数", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int") }) public JsonResult> userList(@RequestBody CoreUserModel query) { //userConsoleService.queryByCondtion(query); List list = userConsoleService.queryByCondtion(query); for (CoreUserModel model:list) { //查询角色Id CoreUserRole coreRole =coreRoleService.getRoleByUserId(model.getId(),model.getOrgId()); if(null!=coreRole){ model.setRoleId(coreRole.getRoleId()); model.setOrgName(orgConsoleService.queryById(model.getOrgId()).getName()); model.setJobType0Text(coreDictService.findNameByType(model.getJobType0())); model.setJobType1Text(coreDictService.findNameByType(model.getJobType1())); model.setStateText(coreDictService.findNameByType(model.getState())); } } PageQuery result = new PageQuery(); int count = userConsoleService.queryByCondtionCount(query); result.setTotalRow(count); /*result.setPageSize(page.getPageSize()); result.setTotalRow(count);*/ result.setList(list); return JsonResult.success(result); } /** * 用户管理删除操作 * @param user * @return */ @PostMapping(MODEL + "/userDelete.do") @ResponseBody @ApiOperation(value="用户管理(删除))", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "id", value = "用户Id", required = true, dataType = "Long") }) public JsonResult userDelete(@RequestBody CoreUser user) { List dels = new ArrayList<>(); dels.add(user.getId()); userConsoleService.batchDelSysUser(dels); return JsonResult.success(); } /** * 用户修改 * @param * @return */ @PostMapping(MODEL + "/userUpdate.json") @ResponseBody @ApiOperation(value="用户管理(修改))", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "id", value = "用户Id", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "code", value = "用户编号不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "用户名不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "orgId", value = "组织机构id", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "password", value = "登陆密码", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "state", value = "状态(1:启用,2:禁用)", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "jobType0", value = "扩展例子", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "jobType1", value = "扩展例子1", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "attachmentId", value = "用户的个人资料附件,保存到Core_File 表里", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "roleId", value = "角色Id", required = true, dataType = "Long") }) public JsonResult update(@RequestBody CoreUserModel model) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); CoreUser user = objectMapper.convertValue(model, CoreUser.class); ObjectMapper objectMapper1 = new ObjectMapper(); objectMapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); XzxCityPartner userParty = objectMapper1.convertValue(model, XzxCityPartner.class); boolean success = userConsoleService.updateTemplate(user); if(!success){ userConsoleService.updateRole(user,model.getRoleId()); success = xzxCityPartnerService.updateTemplate(userParty); if(success){ this.platformService.clearFunctionCache(); return JsonResult.success(); }else{ return JsonResult.failMessage("保存失败!"); } }else{ if (success) { userConsoleService.updateRole(user,model.getRoleId()); this.platformService.clearFunctionCache(); return JsonResult.success(); } else { return JsonResult.failMessage("保存失败!"); } } } /** * 用户添加 * @param user * @return */ @PostMapping(MODEL + "/userAdd.json") @ResponseBody @ApiOperation(value="用户管理(添加))", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "code", value = "用户编号不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "用户名不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "orgId", value = "组织机构id", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "password", value = "登陆密码", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "state", value = "状态(1:启用,2:禁用)", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "jobType0", value = "扩展例子", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "jobType1", value = "扩展例子1", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "attachmentId", value = "用户的个人资料附件,保存到Core_File 表里", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "roleId", value = "角色Id", required = true, dataType = "Long") }) public JsonResult userAdd(@RequestBody CoreUserModel user) { if (!platformService.isAllowUserName(user.getCode())) { return JsonResult.failMessage("不允许的注册名字 " + user.getCode()); } user.setCreateTime(new Date()); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); CoreUser coreUser = objectMapper.convertValue(user, CoreUser.class); coreUser.setPassword("123456"); userConsoleService.saveUser(coreUser,user.getRoleId()); return JsonResult.success(user.getId()); } /** * 用户所在公司的组织机构树 * * @return */ @PostMapping(MODEL + "/userOrg.do") @ResponseBody @ApiOperation(value="用户所在公司的组织机构树", notes="test: 仅0有正确返回") public JsonResult> getUserCompany(HttpServletRequest request) { List list = new ArrayList<>(); OrgItem orgItem = platformService.getUserOrgTree(); list.add(orgItem); return JsonResult.success(list); } /** * 组织机构列表 分页 * @param condtion 查询条件 * @return */ @PostMapping(MODEL + "/organizationList.do") @ResponseBody @ApiOperation(value="组织机构列表 分页", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "code", value = "用户编号", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "用户名", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "type", value = "机构类型(1 集团 2 公司,3 部门,4 小组)", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "limit", value = "每页条数", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "parentOrgId", value = "上一级机构", required = true, dataType = "String") }) public JsonResult> organizationList(@RequestBody OrgQuery condtion) { PageQuery page = condtion.getPageQuery(); orgConsoleService.queryByCondtion(page); return JsonResult.success(page); } /** * 保存组织机构数据 * @param org * @return */ @PostMapping(MODEL + "/orgSave.json") @ResponseBody @ApiOperation(value="保存组织机构数据", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "code", value = "用户编号不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "用户名不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "type", value = "机构类型(1 集团 2 公司,3 部门,4 小组)", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "parentOrgId", value = "上一级机构", required = true, dataType = "String") }) public JsonResult orgSave(@RequestBody CoreOrg org) { org.setCode(org.getName()); org.setCreateTime(new Date()); org.setDelFlag(0); orgConsoleService.save(org); platformService.clearOrgCache(); return JsonResult.success(org.getId()); } /** * 更新数据 * @param org * @return */ @PostMapping(MODEL + "/orgUpdate.json") @ResponseBody @ApiOperation(value="更新组织机构数据", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "id", value = "用户编号不能为空", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "code", value = "用户编号不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "用户名不能为空", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "type", value = "机构类型(1 集团 2 公司,3 部门,4 小组)", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "parentOrgId", value = "上一级机构", required = true, dataType = "String") }) public JsonResult orgUpdate(@RequestBody CoreOrg org){ //判断是否为总公司,总公司不能选择他自己作为他的父类 CoreOrg co = orgConsoleService.queryById(org.getId()); if(co.getParentOrgId()==null){ if(org.getParentOrgId()!=null){ if(org.getParentOrgId().equals(org.getId())){ return JsonResult.failMessage("保存失败,不能选择他自己作为父类"); } } }else{ if(co.getId().equals(org.getParentOrgId())){ return JsonResult.failMessage("保存失败,不能选择他自己作为父类"); } } boolean success = orgConsoleService.updateTemplate(org); if (success) { platformService.clearOrgCache(); return JsonResult.successMessage("保存成功"); } else { return JsonResult.failMessage("保存失败"); } } /** * 删除组织机构 * @param org 组织, * @return */ @PostMapping(MODEL + "/orgDelete.json") @ResponseBody @ApiOperation(value="删除组织机构数据", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "id", value = "用户编号不能为空", required = true, dataType = "Long") }) public JsonResult orgDelete(@RequestBody CoreOrg org) { Long id = org.getId(); List idList = new ArrayList<>(); idList.add(id); orgConsoleService.deleteById(idList); this.platformService.clearOrgCache(); return new JsonResult().success(); } /** *字典列表 * @param * @return */ @PostMapping(MODEL + "/typeValue.do") @ResponseBody @ApiOperation(value="字典列表", notes="test: 仅0有正确返回") public JsonResult>> typeValue(@RequestBody CoreDict dict) { List list =coreDictService.findAllByType(dict.getType()); List> result = new ArrayList<>(); for (CoreDict d:list) { List> children = new ArrayList<>(); List childlist = coreDictService.findChildByParent(d.getId()); for (CoreDict cmap:childlist) { Map m = new HashMap<>(); m.put("id",cmap.getValue()); m.put("name",cmap.getName()); children.add(m); } Map map = new HashMap<>(); map.put("id",d.getValue()); map.put("name",d.getName()); if(null!=children&&children.size()>0){ map.put("childen",children); } result.add(map); } return JsonResult.success(result); } /** * 列表页、 分页数据 * * @param condtion * @return */ @PostMapping(MODEL + "/userRoleList.do") @ResponseBody @ApiOperation(value="角色管理 列表页、 分页数据", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "limit", value = "每页条数", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "code", value = "编码", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "名称", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "type", value = "业务角色类型(1:操作角色,2:工作流角色)", required = true, dataType = "String") }) public JsonResult userRoleList(@RequestBody RoleQuery condtion) { PageQuery page = condtion.getPageQuery(); roleConsoleService.queryByCondtion(page); return JsonResult.success(page); } /** * 管理员重置用户密码 * * @return */ @PostMapping(MODEL + "/changeUserPassword.json") @ResponseBody @ApiOperation(value="管理员重置用户密码", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "id", value = "用户ID", required = true, dataType = "Long"), @ApiImplicitParam(paramType="query", name = "password", value = "密码", required = true, dataType = "String") }) public JsonResult changeUserPassword(@RequestBody CoreUser user) { userConsoleService.resetPassword(user.getId(), user.getPassword()); return new JsonResult().success(); } /** * 保存添加角色 * * @return */ @PostMapping(MODEL + "/addRole.json") @ResponseBody @ApiOperation(value="角色管理添加角色", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "code", value = "角色编码", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "角色名称", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "type", value = "角色类型,系统的角色,工作流角色(R0,R1...)", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "ids", value = "角色Id,多个用逗号隔开", required = true, dataType = "String") }) public JsonResult addRole(@RequestBody CoreRole role) { CoreRole role1 = roleConsoleService.queryByCode(role.getCode()); if (role1 != null) { return JsonResult.failMessage("用户编号已存在"); } JsonResult result = new JsonResult(); role.setCreateTime(new Date()); role.setDelFlag("0"); roleConsoleService.save(role); platformService.clearFunctionCache(); return result.success(); } /** * 更新角色 * * @param role * @return */ @PostMapping(MODEL + "/updateRole.json") @ResponseBody @ApiOperation(value="角色管理更新角色", notes="test: 仅0有正确返回") public JsonResult updateRole(@RequestBody CoreRole role) { role.setDelFlag("0"); boolean success = roleConsoleService.update(role); if (success) { platformService.clearFunctionCache(); return new JsonResult().success(); } else { return JsonResult.failMessage("保存失败"); } } /** * (批量)删除角色 * * @param model * 角色id * @return */ @PostMapping(MODEL + "/deleteRole.json") @ResponseBody @ApiOperation(value="角色管理删除角色", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "ids", value = "角色Id", required = true, dataType = "String") }) public JsonResult deleteRole(@RequestBody CoreRoleModel model) { String ids = model.getIds(); if (ids.endsWith(",")) { ids = StringUtils.substringBeforeLast(ids, ","); } List idList = ConvertUtil.str2longs(ids); Long id = idList.get(0); CoreRole cr = roleConsoleService.queryById(id); cr.setDelFlag("1"); roleConsoleService.update(cr); return new JsonResult().success(); } @PostMapping(MODEL + "/dictList.json") @ResponseBody @ApiOperation(value="组织机构列表", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "type", value = "类型(org_type:组织机构)", required = true, dataType = "String") }) public JsonResult>> dictList(@RequestBody CoreDictQuery condtion) { condtion.setPage(Integer.parseInt("1")); condtion.setLimit(Integer.parseInt("100")); PageQuery page = condtion.getPageQuery(); dictService.queryByCondition(page); return JsonResult.success(page.getList()); } @RequestMapping(MODEL + "/functionList.json") @ResponseBody @ApiOperation(value="功能点管理", notes="test: 仅0有正确返回") @ApiImplicitParams({ @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "limit", value = "每页条数", required = true, dataType = "int"), @ApiImplicitParam(paramType="query", name = "code", value = "代码", required = true, dataType = "String"), @ApiImplicitParam(paramType="query", name = "name", value = "名称", required = true, dataType = "String") }) public JsonResult> functionList(@RequestBody FunctionQuery condtion) { PageQuery page = condtion.getPageQuery(); functionConsoleService.queryByCondtion(page); return JsonResult.success(page); } }