前后端分目录
This commit is contained in:
22
ddp/ddp-authx/pom.xml
Normal file
22
ddp/ddp-authx/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ddp</artifactId>
|
||||
<groupId>com.fibo.ddp</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ddp-authx</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fibo.ddp</groupId>
|
||||
<artifactId>ddp-common-service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.fibo.ddp.authx.dictionary.controller;
|
||||
|
||||
import com.fibo.ddp.common.model.authx.dictionary.Dictionary;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.model.common.requestParam.QueryListParam;
|
||||
import com.fibo.ddp.common.service.authx.dictionary.DictionaryService;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (Dictionary)表控制层
|
||||
*
|
||||
* @author jgp
|
||||
* @since 2021-12-15 15:08:06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dictionary")
|
||||
public class DictionaryController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
@PostMapping("/getByKey")
|
||||
public ResponseEntityDto<Dictionary> getByKey (@RequestBody Dictionary param){
|
||||
Dictionary dictionary = dictionaryService.queryByKey(param.getDictKey());
|
||||
return ResponseEntityBuilder.buildNormalResponse(dictionary);
|
||||
}
|
||||
@PostMapping("/getList")
|
||||
public ResponseEntityDto<PageInfo> getList (@RequestBody QueryListParam<Dictionary> param){
|
||||
PageInfo pageInfo = dictionaryService.queryList(param);
|
||||
return ResponseEntityBuilder.buildNormalResponse(pageInfo);
|
||||
}
|
||||
@PostMapping("/addBatch")
|
||||
public ResponseEntityDto addBatch (@RequestBody Collection<Dictionary> param){
|
||||
boolean result = dictionaryService.saveBatchDictionary(param);
|
||||
return ResponseEntityBuilder.buildNormalResponse(result);
|
||||
}
|
||||
@PostMapping("/updateById")
|
||||
public ResponseEntityDto updateById (Dictionary param){
|
||||
boolean result = dictionaryService.update(param);
|
||||
return ResponseEntityBuilder.buildNormalResponse(result);
|
||||
}
|
||||
@PostMapping("/deleteByIds")
|
||||
public ResponseEntityDto deleteByIds (@RequestBody List<Long> ids){
|
||||
if (CollectionUtils.isEmpty(ids)){
|
||||
throw new ApiException(ErrorCodeEnum.PARAMS_EXCEPTION.getCode(),"删除字典表id不能为空");
|
||||
}
|
||||
boolean result = dictionaryService.deleteByIds(ids);
|
||||
return ResponseEntityBuilder.buildNormalResponse(result);
|
||||
}
|
||||
@PostMapping("/refreshCache")
|
||||
public ResponseEntityDto refreshCache (){
|
||||
Map<String, Dictionary> result = dictionaryService.refreshCache();
|
||||
return ResponseEntityBuilder.buildNormalResponse(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.fibo.ddp.authx.system.business;
|
||||
|
||||
|
||||
public class LoginBusiness {
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
|
||||
package com.fibo.ddp.authx.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.authx.system.request.LoginInfoParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.authx.system.SysUserService;
|
||||
import com.fibo.ddp.common.service.common.AccountSessionWrap;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.monitor.logger.ArchivesLog;
|
||||
import com.fibo.ddp.common.service.redis.RedisManager;
|
||||
import com.fibo.ddp.common.utils.common.MD5;
|
||||
import com.fibo.ddp.common.utils.constant.Constants;
|
||||
import com.fibo.ddp.common.utils.constant.OpTypeConst;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @apiDefine account 1. 账户
|
||||
*/
|
||||
@Controller("loginControllerV2")
|
||||
@RequestMapping("/v2/login/*")
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
private RedisManager redisManager;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
/**
|
||||
* @api {POST} /v2/login/login 1.01. 用户登录
|
||||
* @apiGroup account
|
||||
* @apiVersion 1.0.1
|
||||
* @apiParam {String} account 账号
|
||||
* @apiParam {String} password 密码
|
||||
* @apiSuccess {String} token 会话token
|
||||
* @apiParamExample {json} Request:
|
||||
* {"account":"admin","password":"123456"}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"token":"21fd6379df134ea590a462e4de1f6b33"}}
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/login")
|
||||
@ArchivesLog(operationType = OpTypeConst.LOGIN)
|
||||
public ResponseEntityDto<Object> login(@RequestBody LoginInfoParam param) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String account = param.getAccount();
|
||||
String password = param.getPassword();
|
||||
if(!("".equals(account)) && !("".equals(password))){
|
||||
|
||||
SysUser user = sysUserService.login(account.trim(), MD5.GetMD5Code(password));
|
||||
if(null != user && user.getStatus()==1){
|
||||
String token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
redisManager.set(token, JSONObject.toJSONString(user), Constants.LOGIN_TOKEN_TIME.intValue());
|
||||
map.put("token", token);
|
||||
|
||||
com.fibo.ddp.common.service.common.AccountSessionWrap acsw = new AccountSessionWrap(null, null);
|
||||
acsw.setSysUser(user);
|
||||
SessionManager.setSession(acsw);
|
||||
}else{
|
||||
return ResponseEntityBuilder.buildErrorResponse(ErrorCodeEnum.LOGIN_ERROR);
|
||||
}
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/login/logout 1.02. 用户登出
|
||||
* @apiGroup account
|
||||
* @apiVersion 1.0.1
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} Request:
|
||||
* {}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":null}
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "logout", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.LOGOUT)
|
||||
public ResponseEntityDto<Object> logout(HttpServletRequest request) {
|
||||
String token = request.getHeader(Constants.SYSTEM_KEY_TOKEN);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
redisManager.del(token);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,386 @@
|
||||
package com.fibo.ddp.authx.system.controller;
|
||||
|
||||
import com.fibo.ddp.common.model.authx.system.SysMenu;
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.authx.system.request.MenuParam;
|
||||
import com.fibo.ddp.common.model.authx.system.response.SysMenuVo;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.authx.system.SysMenuService;
|
||||
import com.fibo.ddp.common.service.authx.system.SysUserService;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.monitor.logger.ArchivesLog;
|
||||
import com.fibo.ddp.common.utils.constant.OpTypeConst;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Controller("sysMenuControllerV2")
|
||||
@RequestMapping("v2/sysMenu")
|
||||
@ResponseBody
|
||||
public class SysMenuController {
|
||||
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/getMenuList 6.31. 获取资源列表
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} pageNo 页数
|
||||
* @apiParam {Integer} pageSize 每页的条数
|
||||
* @apiSuccess {JSON} pager 分页信息
|
||||
* @apiSuccess {JSONArray} listMenu 资源列表
|
||||
* @apiSuccess (listMenu) {Long} userId 资源编号
|
||||
* @apiSuccess (listMenu) {Long} userId 分配者
|
||||
* @apiSuccess (listMenu) {String} name 资源名称
|
||||
* @apiSuccess (listMenu) {String} versionCode 资源代号
|
||||
* @apiSuccess (listMenu) {String} url 资源路径
|
||||
* @apiSuccess (listMenu) {Long} parentId 父节点
|
||||
* @apiSuccess (listMenu) {String} des 资源描述
|
||||
* @apiSuccess (listMenu) {Long} birth 创建时间
|
||||
* @apiSuccess (listMenu) {String} icon 图标
|
||||
* @apiSuccess (listMenu) {Integer} sort 顺序(值越小优先级越高)
|
||||
* @apiSuccess (listMenu) {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"pageNo":1,"pageSize":2}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"pager":{"pageNum":1,"pageSize":2,"size":2,"startRow":1,"endRow":2,"total":17,"pages":9,"list":null,"prePage":0,"nextPage":2,"isFirstPage":true,"isLastPage":false,"hasPreviousPage":false,"hasNextPage":true,"navigatePages":8,"navigatepageNums":[1,2,3,4,5,6,7,8],"navigateFirstPage":1,"navigateLastPage":8,"lastPage":8,"firstPage":1},"listMenu":[{"userId":1,"userId":0,"name":"引擎管理","versionCode":"0001","url":"sysMenu/getChildMenu","parentId":0,"des":"引擎管理","birth":1498721562000,"icon":null,"sort":0,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"hidden":false},{"userId":2,"userId":0,"name":"规则管理","versionCode":"0002","url":"sysMenu/getChildMenu","parentId":0,"des":"规则管理","birth":1498807962000,"icon":"bb","sort":5,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"hidden":false}]}}
|
||||
*/
|
||||
@RequestMapping(value = "getMenuList", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getMenuList(@RequestBody MenuParam menuParam) {
|
||||
PageHelper.startPage(menuParam.getPageNo(),menuParam.getPageSize());
|
||||
// 获取所有菜单
|
||||
List<SysMenu> listMenu = sysMenuService.getAllSysMenu(menuParam.getEntity());
|
||||
PageInfo<SysMenu> pageInfo = new PageInfo<SysMenu>(listMenu);
|
||||
pageInfo.setList(null);
|
||||
HashMap<String, Object> modelMap = new HashMap<>();
|
||||
modelMap.put("listMenu", listMenu);
|
||||
modelMap.put("pager", pageInfo);
|
||||
return ResponseEntityBuilder.buildNormalResponse(modelMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/save 6.32. 创建资源
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {String} name 资源名称
|
||||
* @apiParam {String} versionCode 资源代号
|
||||
* @apiParam {String} url 资源路径
|
||||
* @apiParam {Long} parentId 父节点
|
||||
* @apiParam {String} des 资源描述
|
||||
* @apiParam {String} icon 图标
|
||||
* @apiParam {Integer} sort 顺序(值越小优先级越高)
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"name":"测试资源","versionCode":"0066","url":"testMenu","parentId":0,"des":"测试资源描述","icon":"el-icon-eleme","sort":2}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "save", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.SAVE_SYS_MENU)
|
||||
public ResponseEntityDto save(@RequestBody SysMenu sysMenu) {
|
||||
List<SysMenu> list = sysMenuService.validateMenuOnly(sysMenu);
|
||||
if(list!=null&&list.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_MENU_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_MENU_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysMenuService.createSysMenu(sysMenu);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/getMenuInfo/{userId} 6.33. 获取资源详情
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 资源编号(url参数)
|
||||
* @apiSuccess {Long} userId 资源编号
|
||||
* @apiSuccess {Long} userId 分配者
|
||||
* @apiSuccess {String} name 资源名称
|
||||
* @apiSuccess {String} versionCode 资源代号
|
||||
* @apiSuccess {String} url 资源路径
|
||||
* @apiSuccess {Long} parentId 父节点
|
||||
* @apiSuccess {String} des 资源描述
|
||||
* @apiSuccess {Long} birth 创建时间
|
||||
* @apiSuccess {String} icon 图标
|
||||
* @apiSuccess {Integer} sort 顺序(值越小优先级越高)
|
||||
* @apiSuccess {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"userId":32,"userId":135,"name":"测试资源","versionCode":"0066","url":"testMenu","parentId":0,"des":"测试资源描述","birth":1616760174000,"icon":"el-icon-eleme","sort":2,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"hidden":false}}
|
||||
*/
|
||||
@RequestMapping(value = "/getMenuInfo/{id}", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getMenuInfo(@PathVariable long id) {
|
||||
SysMenu sysMenu = sysMenuService.findById(id);
|
||||
return ResponseEntityBuilder.buildNormalResponse(sysMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/update 6.34. 修改资源
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 资源编号
|
||||
* @apiParam {String} name 资源名称
|
||||
* @apiParam {String} versionCode 资源代号
|
||||
* @apiParam {String} url 资源路径
|
||||
* @apiParam {Long} parentId 父节点
|
||||
* @apiParam {String} des 资源描述
|
||||
* @apiParam {String} icon 图标
|
||||
* @apiParam {Integer} sort 顺序(值越小优先级越高)
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"userId":32,"name":"测试资源1","versionCode":"0067","url":"testMenu","parentId":0,"des":"测试资源描述","icon":"el-icon-eleme","sort":5}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_SYS_MENU)
|
||||
public ResponseEntityDto update(@RequestBody SysMenu sysMenu) {
|
||||
List<SysMenu> list = sysMenuService.validateMenuOnly(sysMenu);
|
||||
if(list!=null&&list.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_MENU_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_MENU_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysMenuService.updateSysMenu(sysMenu);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/updateStatus 6.35. 资源删除
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} status 状态:-1删除
|
||||
* @apiParam {String} ids 资源编号,逗号分隔
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"status":-1,"ids":"26"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "updateStatus", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_SYS_MENU_STATUS)
|
||||
public ResponseEntityDto updateStatus(@RequestBody Map<String, Object> param) {
|
||||
int status = (Integer) param.get("status");
|
||||
String ids = (String)param.get("ids");
|
||||
int num = 0;
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
if (ids != "") {
|
||||
String[] strs = ids.split(",");
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
list.add(Integer.parseInt(strs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (list != null && list.size() > 0) {
|
||||
num = sysMenuService.updateStatus(status, list);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/getTreeMenu 6.36. 新增/修改资源获取父节点树
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} parentId 父节点Id
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"parentId":0}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":[{"userId":22,"userId":0,"name":"模型管理","versionCode":"0007","url":"sysMenu/getChildMenu","parentId":0,"des":"模型管理","birth":1498980762000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false},{"userId":23,"userId":0,"name":"数据源管理","versionCode":"0008","url":"sysMenu/getChildMenu","parentId":0,"des":"数据源管理","birth":1498984362000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false},{"userId":24,"userId":0,"name":"黑白名单库管理","versionCode":"0009","url":"sysMenu/getChildMenu","parentId":0,"des":"黑白名单库管理","birth":1498987962000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false},{"userId":25,"userId":0,"name":"评分卡管理","versionCode":"0010","url":"sysMenu/getChildMenu","parentId":0,"des":"评分卡管理","birth":1498897962000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false}]}
|
||||
*/
|
||||
@RequestMapping(value = "getTreeMenu", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getTreeMenu(@RequestBody MenuParam menuParam){
|
||||
long parentId = menuParam.getParentId();
|
||||
List<SysMenu> listMenu = sysMenuService.getAllValidMenu(menuParam.getEntity());
|
||||
if(listMenu!=null&&listMenu.size()>0){
|
||||
for(int i=0;i<listMenu.size();i++){
|
||||
if(listMenu.get(i).getResourceId()==parentId){
|
||||
listMenu.get(i).setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(listMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/findTreeList 6.37.1. 权限分配,获取资源树
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} roleId 角色编号
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"roleId":76}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":[{"userId":22,"userId":0,"name":"模型管理","versionCode":"0007","url":"sysMenu/getChildMenu","parentId":0,"des":"模型管理","birth":1498980762000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false},{"userId":23,"userId":0,"name":"数据源管理","versionCode":"0008","url":"sysMenu/getChildMenu","parentId":0,"des":"数据源管理","birth":1498984362000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false},{"userId":24,"userId":0,"name":"黑白名单库管理","versionCode":"0009","url":"sysMenu/getChildMenu","parentId":0,"des":"黑白名单库管理","birth":1498987962000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false},{"userId":25,"userId":0,"name":"评分卡管理","versionCode":"0010","url":"sysMenu/getChildMenu","parentId":0,"des":"评分卡管理","birth":1498897962000,"icon":null,"status":1,"roleId":0,"checked":false,"chkDisabled":false,"isHidden":false}]}
|
||||
*/
|
||||
@RequestMapping(value = "findTreeList", method = RequestMethod.POST)
|
||||
public ResponseEntityDto findTreeList(@RequestBody MenuParam menuParam){
|
||||
Long roleId = menuParam.getRoleId();
|
||||
Long organRoleId = 0L;
|
||||
List<SysMenu> listAll = new ArrayList<SysMenu>();
|
||||
//获取登录用户id
|
||||
SysUser user = SessionManager.getLoginAccount();
|
||||
long userId = user.getUserId();
|
||||
long orgId = user.getOrganId();
|
||||
//获取登录人角色id
|
||||
SysUser sysUser = sysUserService.findRoleByUserId(userId);
|
||||
if(sysUser!=null){
|
||||
organRoleId = sysUser.getSysRole().getRoleId();
|
||||
}
|
||||
//角色资源
|
||||
menuParam.getEntity().setRoleId(roleId);
|
||||
List<SysMenu> listRoleMenu = sysMenuService.findTreeList(menuParam.getEntity());
|
||||
if(orgId==1){
|
||||
//全部启用资源
|
||||
listAll = sysMenuService.getAllValidMenu(menuParam.getEntity());
|
||||
if(listAll!=null&&listAll.size()>0){
|
||||
for(int i=0;i<listAll.size();i++){
|
||||
//初始化禁用节点
|
||||
if(listAll.get(i).getResourceId()==14 || listAll.get(i).getResourceId()==13){
|
||||
listAll.get(i).setChkDisabled(true);
|
||||
listAll.get(i).setHidden(true);
|
||||
}
|
||||
//判断默认选中
|
||||
long id_i = listAll.get(i).getResourceId();
|
||||
if (listRoleMenu != null && listRoleMenu.size() > 0) {
|
||||
for (int j = 0; j < listRoleMenu.size(); j++) {
|
||||
long id_j = listRoleMenu.get(j).getResourceId();
|
||||
if (id_j == id_i) {
|
||||
listAll.get(i).setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
//公司资源
|
||||
menuParam.getEntity().setRoleId(organRoleId);
|
||||
listAll = sysMenuService.findTreeList(menuParam.getEntity());
|
||||
if(listAll!=null&&listAll.size()>0){
|
||||
for(int i=0;i<listAll.size();i++){
|
||||
//初始化禁用节点
|
||||
if(listAll.get(i).getResourceId()==4){
|
||||
listAll.get(i).setChkDisabled(true);
|
||||
listAll.get(i).setHidden(true);
|
||||
}
|
||||
//判断默认选中
|
||||
long id_i = listAll.get(i).getResourceId();
|
||||
if (listRoleMenu != null && listRoleMenu.size() > 0) {
|
||||
for (int j = 0; j < listRoleMenu.size(); j++) {
|
||||
long id_j = listRoleMenu.get(j).getResourceId();
|
||||
if (id_j == id_i) {
|
||||
listAll.get(i).setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(listAll);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/insertRoleMenu 6.38.1. 权限分配保存
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} roleId 角色编号
|
||||
* @apiParam {String} ids 资源编号,逗号分隔
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"roleId":76,"ids":"1,18,2,15,3,16,17,4,11,12,19"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":11}
|
||||
*/
|
||||
@RequestMapping(value = "insertRoleMenu", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.SAVE_OR_UPDATE_MENU_ROLE)
|
||||
public ResponseEntityDto insertRoleMenu(@RequestBody Map<String, Object> param) {
|
||||
long roleId = Long.valueOf(param.get("roleId").toString());
|
||||
String ids = (String)param.get("ids");
|
||||
int num = 0;
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
if (ids != "") {
|
||||
String[] strs = ids.split(",");
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
list.add(Integer.parseInt(strs[i]));
|
||||
}
|
||||
if (list != null && list.size() > 0) {
|
||||
num = sysMenuService.insertRoleMenu(roleId, list);
|
||||
}
|
||||
}else{
|
||||
num = sysMenuService.deleteRoleMenu(roleId);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysMenu/getMenus 6.39. 获取菜单信息
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":[{"title":"系统首页","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"引擎列表","index":"sysMenu/getChildMenu","icon":"xx","subs":[]},{"title":"引擎管理","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"指标管理","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"规则管理","index":"sysMenu/getChildMenu","icon":"bb","subs":[]},{"title":"评分卡管理","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"模型管理","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"数据源管理","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"黑白名单库管理","index":"sysMenu/getChildMenu","icon":null,"subs":[]},{"title":"系统管理","index":"sysMenu/getChildMenu","icon":null,"subs":[{"title":"用户管理","index":"sysUser/view","icon":null,"subs":[]},{"title":"角色管理","index":"sysRole/view","icon":"aa","subs":[]},{"title":"日志管理","index":"log/index","icon":null,"subs":[]}]}]}
|
||||
*/
|
||||
@RequestMapping(value = "getMenus", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getMenus(@RequestBody MenuParam menuParam){
|
||||
List<SysMenu> menuList = new ArrayList<>();
|
||||
SysUser user = SessionManager.getLoginAccount();
|
||||
long orgId = user.getOrganId();
|
||||
long userId = user.getUserId();
|
||||
if(orgId==1){
|
||||
menuList = sysMenuService.getAllValidMenu(menuParam.getEntity());
|
||||
}else{
|
||||
long roleId = 0;
|
||||
SysUser sysUser = sysUserService.findRoleByUserId(userId);
|
||||
if(sysUser!=null){
|
||||
roleId = sysUser.getSysRole().getRoleId();
|
||||
}
|
||||
menuParam.getEntity().setRoleId(roleId);
|
||||
menuList = sysMenuService.findTreeList(menuParam.getEntity());
|
||||
}
|
||||
|
||||
long parentId = 0;
|
||||
List<SysMenuVo> result = recursionMenu(menuList, parentId);
|
||||
|
||||
return ResponseEntityBuilder.buildNormalResponse(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取子菜单
|
||||
* @param menuList
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
private List<SysMenuVo> recursionMenu(List<SysMenu> menuList, long parentId){
|
||||
List<SysMenuVo> sysMenuVoList = new ArrayList<>();
|
||||
for(SysMenu sysMenu : menuList) {
|
||||
if(sysMenu.getParentId() == parentId){
|
||||
SysMenuVo sysMenuVo = new SysMenuVo();
|
||||
sysMenuVo.setTitle(sysMenu.getName());
|
||||
sysMenuVo.setIndex(StringUtils.isBlank(sysMenu.getUrl()) ? UUID.randomUUID().toString() : sysMenu.getUrl());
|
||||
sysMenuVo.setIcon(sysMenu.getIcon());
|
||||
|
||||
List<SysMenuVo> sysMenuVos = recursionMenu(menuList, sysMenu.getResourceId());
|
||||
if(!sysMenuVos.isEmpty()){
|
||||
sysMenuVo.setSubs(sysMenuVos);
|
||||
}
|
||||
|
||||
sysMenuVoList.add(sysMenuVo);
|
||||
}
|
||||
}
|
||||
return sysMenuVoList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package com.fibo.ddp.authx.system.controller;
|
||||
|
||||
import com.fibo.ddp.common.model.authx.system.SysOrganization;
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.common.BaseParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.authx.system.SysOrganizationService;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.monitor.logger.ArchivesLog;
|
||||
import com.fibo.ddp.common.utils.constant.OpTypeConst;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller("sysOrganizationControllerV2")
|
||||
@RequestMapping("v2/sysOrganization")
|
||||
@ResponseBody
|
||||
public class SysOrganizationController {
|
||||
|
||||
@Autowired
|
||||
private SysOrganizationService sysOrganizationService;
|
||||
/**
|
||||
* @api {POST} /v2/sysOrganization/getOrganList 6.41. 获取组织列表
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} pageNo 页数
|
||||
* @apiParam {Integer} pageSize 每页的条数
|
||||
* @apiSuccess {JSON} pager 分页信息
|
||||
* @apiSuccess {JSONArray} listOrgan 组织列表
|
||||
* @apiSuccess (listOrgan) {Long} userId 组织编号
|
||||
* @apiSuccess (listOrgan) {String} name 组织名称
|
||||
* @apiSuccess (listOrgan) {String} versionCode 组织代号
|
||||
* @apiSuccess (listOrgan) {Integer} status 状态:0禁用,1启用
|
||||
* @apiSuccess (listOrgan) {String} author 创建者
|
||||
* @apiSuccess (listOrgan) {Long} birth 创建时间
|
||||
* @apiSuccess (listOrgan) {String} token 唯一标识
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"pageNo":1,"pageSize":2}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"listOrgan":[{"userId":46,"name":"管理员","versionCode":"007","email":null,"telephone":null,"status":1,"author":"超级管理员","birth":1498722046000,"token":"4f15125c-93c0-43fb-9ed2-e0b92763fa3d"}],"pager":{"pageNum":1,"pageSize":2,"size":1,"startRow":1,"endRow":1,"total":1,"pages":1,"list":null,"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[1],"navigateFirstPage":1,"navigateLastPage":1,"lastPage":1,"firstPage":1}}}
|
||||
*/
|
||||
@RequestMapping(value = "getOrganList", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getOrganList(@RequestBody BaseParam baseParam){
|
||||
PageHelper.startPage(baseParam.getPageNo(), baseParam.getPageSize());
|
||||
List<SysOrganization> listOrgan = sysOrganizationService.getAllSysOrganization();
|
||||
PageInfo<SysOrganization> pageInfo = new PageInfo<SysOrganization>(listOrgan);
|
||||
pageInfo.setList(null);
|
||||
HashMap<String, Object> modelMap = new HashMap<>();
|
||||
modelMap.put("listOrgan", listOrgan);
|
||||
modelMap.put("pager", pageInfo);
|
||||
return ResponseEntityBuilder.buildNormalResponse(modelMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysOrganization/getAllValidOrgan 6.42. 获取所有已启用组织
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiSuccess {Long} userId 组织编号
|
||||
* @apiSuccess {String} name 组织名称
|
||||
* @apiSuccess {String} versionCode 组织代号
|
||||
* @apiSuccess {Integer} status 状态:0禁用,1启用
|
||||
* @apiSuccess {String} author 创建者
|
||||
* @apiSuccess {Long} birth 创建时间
|
||||
* @apiSuccess {String} token 唯一标识
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":[{"userId":46,"name":"管理员","versionCode":"007","email":null,"telephone":null,"status":1,"author":"超级管理员","birth":1498722046000,"token":"4f15125c-93c0-43fb-9ed2-e0b92763fa3d"},{"userId":1,"name":"rik","versionCode":"0001","email":"123.com ","telephone":"1234567489","status":1,"author":"超级管理员","birth":1498721562000,"token":"6a6ea35e-aabe-4e64-bd98-dae304b10a21"}]}
|
||||
*/
|
||||
@RequestMapping(value = "getAllValidOrgan", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getAllValidOrgan(){
|
||||
List<SysOrganization> list = new ArrayList<>();
|
||||
SysUser sysUser = SessionManager.getLoginAccount();
|
||||
Long organId = sysUser.getOrganId();
|
||||
if(organId.longValue() == 1){
|
||||
list = sysOrganizationService.getAllValidOrgan();
|
||||
} else {
|
||||
SysOrganization sysOrganization = sysOrganizationService.findById(organId);
|
||||
list.add(sysOrganization);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysOrganization/save 6.43. 创建组织
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {String} name 组织名称
|
||||
* @apiParam {String} versionCode 组织代号
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"name":"测试公司","versionCode":"666"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "save", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.SAVE_ORGAN)
|
||||
public ResponseEntityDto save(@RequestBody SysOrganization sysOrganization) {
|
||||
//验证唯一性
|
||||
List<SysOrganization> list = sysOrganizationService.validateOrganOnly(sysOrganization);
|
||||
if(list!=null&&list.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_ORGAN_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_ORGAN_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysOrganizationService.createSysOrganization(sysOrganization);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysOrganization/getOrganInfo/{userId} 6.44. 获取组织详情
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 组织编号(url参数)
|
||||
* @apiSuccess {Long} userId 组织编号
|
||||
* @apiSuccess {String} name 组织名称
|
||||
* @apiSuccess {String} versionCode 组织代号
|
||||
* @apiSuccess {Integer} status 状态:0禁用,1启用
|
||||
* @apiSuccess {String} author 创建者
|
||||
* @apiSuccess {Long} birth 创建时间
|
||||
* @apiSuccess {String} token 唯一标识
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"userId":46,"name":"管理员","versionCode":"007","email":null,"telephone":null,"status":1,"author":"超级管理员","birth":1498722046000,"token":"4f15125c-93c0-43fb-9ed2-e0b92763fa3d"}}
|
||||
*/
|
||||
@RequestMapping(value = "/getOrganInfo/{id}", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getOrganInfo(@PathVariable long id){
|
||||
SysOrganization sysOrganization = sysOrganizationService.findById(id);
|
||||
return ResponseEntityBuilder.buildNormalResponse(sysOrganization);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysOrganization/update 6.45. 修改组织
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 组织编号
|
||||
* @apiParam {String} name 组织名称
|
||||
* @apiParam {String} versionCode 组织代号
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"userId":47,"name":"测试公司2","versionCode":"666"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_ORGAN)
|
||||
public ResponseEntityDto update(@RequestBody SysOrganization sysOrganization) {
|
||||
//验证唯一性
|
||||
List<SysOrganization> list = sysOrganizationService.validateOrganOnly(sysOrganization);
|
||||
if(list!=null&&list.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_ORGAN_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_ORGAN_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysOrganizationService.updateSysOrganization(sysOrganization);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysOrganization/updateStatus 6.46. 组织停用、启用、删除
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiParam {String} ids 用户Id,逗号分隔
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"status":0,"ids":"46"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "updateStatus", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_ORGAN_STATUS)
|
||||
public ResponseEntityDto updateStates(@RequestBody Map<String, Object> param){
|
||||
int status = (Integer) param.get("status");
|
||||
String ids = (String)param.get("ids");
|
||||
int num = 0;
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
if(ids!=""){
|
||||
String[] strs = ids.split(",");
|
||||
for(int i=0;i<strs.length;i++){
|
||||
list.add(Integer.parseInt(strs[i]));
|
||||
}
|
||||
}
|
||||
if(list!=null && list.size()>0){
|
||||
num = sysOrganizationService.updateStatus(status,list);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package com.fibo.ddp.authx.system.controller;
|
||||
|
||||
import com.fibo.ddp.common.model.authx.system.SysRole;
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.common.BaseParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.authx.system.SysRoleService;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.monitor.logger.ArchivesLog;
|
||||
import com.fibo.ddp.common.utils.constant.OpTypeConst;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller("sysRoleControllerV2")
|
||||
@RequestMapping("v2/sysRole")
|
||||
@ResponseBody
|
||||
public class SysRoleController {
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
/**
|
||||
* @api {POST} /v2/sysRole/getRoleList 6.21. 获取角色列表
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} pageNo 页数
|
||||
* @apiParam {Integer} pageSize 每页的条数
|
||||
* @apiSuccess {JSON} pager 分页信息
|
||||
* @apiSuccess {JSONArray} listRole 角色列表
|
||||
* @apiSuccess (listRole) {Integer} userId 角色编号
|
||||
* @apiSuccess (listRole) {Integer} organId 组织编号
|
||||
* @apiSuccess (listRole) {String} roleName 角色名称
|
||||
* @apiSuccess (listRole) {String} author 创建者
|
||||
* @apiSuccess (listRole) {Long} birth 创建时间
|
||||
* @apiSuccess (listRole) {Integer} status 状态:0禁用,1启用
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"pageNo":1,"pageSize":2}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"listRole":[{"userId":72,"organId":46,"roleName":"业务管理员","roleCode":null,"roleDesc":null,"author":"超级管理员","birth":1498725111000,"status":1},{"userId":71,"organId":46,"roleName":"引擎管理员","roleCode":null,"roleDesc":null,"author":"超级管理员","birth":1498725103000,"status":1}],"pager":{"pageNum":1,"pageSize":2,"size":2,"startRow":1,"endRow":2,"total":3,"pages":2,"list":null,"prePage":0,"nextPage":2,"isFirstPage":true,"isLastPage":false,"hasPreviousPage":false,"hasNextPage":true,"navigatePages":8,"navigatepageNums":[1,2],"navigateFirstPage":1,"navigateLastPage":2,"firstPage":1,"lastPage":2}}}
|
||||
*/
|
||||
@RequestMapping(value = "/getRoleList", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getRoleList(@RequestBody BaseParam baseParam){
|
||||
List<SysRole> listRole = null;
|
||||
//获取公司管理员所在公司
|
||||
SysUser sysUser = SessionManager.getLoginAccount();
|
||||
long organId = sysUser.getOrganId();
|
||||
PageHelper.startPage(baseParam.getPageNo(),baseParam.getPageSize());
|
||||
if(organId==1){
|
||||
//获取所有未删除角色
|
||||
listRole = sysRoleService.getAllRoles();
|
||||
}else{
|
||||
//获取本公司未删除角色
|
||||
listRole = sysRoleService.getAllSysRole(organId);
|
||||
}
|
||||
PageInfo<SysRole> pageInfo = new PageInfo<SysRole>(listRole);
|
||||
pageInfo.setList(null);
|
||||
HashMap<String, Object> modelMap = new HashMap<>();
|
||||
modelMap.put("listRole", listRole);
|
||||
modelMap.put("pager", pageInfo);
|
||||
return ResponseEntityBuilder.buildNormalResponse(modelMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysRole/getAllValidRole 6.22. 根据公司获取所有启用角色
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} organId 组织编号
|
||||
* @apiSuccess {Integer} userId 角色编号
|
||||
* @apiSuccess {Integer} organId 组织编号
|
||||
* @apiSuccess {String} roleName 角色名称
|
||||
* @apiSuccess {String} author 创建者
|
||||
* @apiSuccess {Long} birth 创建时间
|
||||
* @apiSuccess {Integer} status 状态:0禁用,1启用
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"organId":46}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":[{"userId":70,"organId":46,"roleName":"管理员","roleCode":null,"roleDesc":null,"author":"超级管理员","birth":1498724751000,"status":1},{"userId":71,"organId":46,"roleName":"引擎管理员","roleCode":null,"roleDesc":null,"author":"超级管理员","birth":1498725103000,"status":1},{"userId":72,"organId":46,"roleName":"业务管理员","roleCode":null,"roleDesc":null,"author":"超级管理员","birth":1498725111000,"status":1}]}
|
||||
*/
|
||||
@RequestMapping(value = "getAllValidRole", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getAllValidRole(@RequestBody Map<String, Object> param){
|
||||
String author = "";
|
||||
SysUser sysUser = SessionManager.getLoginAccount();
|
||||
Long orgId = sysUser.getOrganId();
|
||||
if(orgId==1){
|
||||
author = "超级管理员";
|
||||
}
|
||||
|
||||
long organId = orgId;
|
||||
if(param.get("organId") != null){
|
||||
organId = Long.valueOf(param.get("organId").toString());
|
||||
}
|
||||
List<SysRole> list = sysRoleService.getAllValidRole(organId,author);
|
||||
return ResponseEntityBuilder.buildNormalResponse(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysRole/save 6.23. 创建角色
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} organId 组织编号
|
||||
* @apiParam {String} roleName 角色名称
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"organId":1,"roleName":"浏览者"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "save", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.SAVE_SYS_ROLE)
|
||||
public ResponseEntityDto save(@RequestBody SysRole sysRole) {
|
||||
//确保每个公司只能创建一个公司管理员
|
||||
SysUser sysUser = SessionManager.getLoginAccount();
|
||||
Long or_id = sysUser.getOrganId();
|
||||
if(or_id==1){
|
||||
sysRole.setAuthor(sysUser.getNickName());
|
||||
//查询公司管理员是否存在
|
||||
List<SysRole> list_role = sysRoleService.getOrganRoleByAuthor(sysRole);
|
||||
if(list_role!=null&&list_role.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_ROLE_ADMIN_REPEAT.getCode(), ErrorCodeEnum.CREATE_ROLE_ADMIN_REPEAT.getMessage());
|
||||
}
|
||||
}else{
|
||||
sysRole.setAuthor(sysUser.getNickName());
|
||||
}
|
||||
//验证名称唯一性
|
||||
List<SysRole> list = sysRoleService.validateRoleOnly(sysRole);
|
||||
if(list!=null&&list.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_ROLE_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_ROLE_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysRoleService.createSysRole(sysRole);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysRole/getRoleInfo/{userId} 6.24. 获取角色详情
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 角色编号(url参数)
|
||||
* @apiSuccess {Integer} userId 角色编号
|
||||
* @apiSuccess {Integer} organId 组织编号
|
||||
* @apiSuccess {String} roleName 角色名称
|
||||
* @apiSuccess {String} author 创建者
|
||||
* @apiSuccess {Long} birth 创建时间
|
||||
* @apiSuccess {Integer} status 状态:0禁用,1启用
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"userId":76,"organId":46,"roleName":"浏览者","roleCode":null,"roleDesc":null,"author":"管理员","birth":1563634443000,"status":1}}
|
||||
*/
|
||||
@RequestMapping(value = "/getRoleInfo/{id}", method = RequestMethod.POST)
|
||||
public ResponseEntityDto getRoleInfo(@PathVariable long id){
|
||||
SysRole sysrole = null;
|
||||
//获取管理员所在公司
|
||||
SysUser sysUser = SessionManager.getLoginAccount();
|
||||
long organId = sysUser.getOrganId();
|
||||
if(organId==1){
|
||||
sysrole = sysRoleService.findByAId(id);
|
||||
}else{
|
||||
sysrole = sysRoleService.findById(id,organId);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(sysrole);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysRole/update 6.25. 修改角色
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} userId 角色编号
|
||||
* @apiParam {Integer} organId 组织编号
|
||||
* @apiParam {String} roleName 角色名称
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"userId":77,"organId":1,"roleName":"浏览者2"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_SYS_ROLE)
|
||||
public ResponseEntityDto update(@RequestBody SysRole sysRole) {
|
||||
List<SysRole> list = sysRoleService.validateRoleOnly(sysRole);
|
||||
if(list!=null&&list.size()>0){
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_ROLE_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_ROLE_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysRoleService.updateSysRole(sysRole);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysRole/updateStatus 6.26. 角色停用、启用、删除
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiParam {String} ids 用户Id,逗号分隔
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"status":0,"ids":"77"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "updateStatus", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_SYS_ROLE_STATUS)
|
||||
public ResponseEntityDto updateStates(@RequestBody Map<String, Object> param){
|
||||
int status = (Integer) param.get("status");
|
||||
String ids = (String)param.get("ids");
|
||||
int num = 0;
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
if(ids!=""){
|
||||
String[] strs = ids.split(",");
|
||||
for(int i=0;i<strs.length;i++){
|
||||
list.add(Integer.parseInt(strs[i]));
|
||||
}
|
||||
}
|
||||
if(list!=null && list.size()>0){
|
||||
num = sysRoleService.updateStatus(status,list);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package com.fibo.ddp.authx.system.controller;
|
||||
|
||||
import com.fibo.ddp.common.model.authx.system.SysUser;
|
||||
import com.fibo.ddp.common.model.common.BaseParam;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityBuilder;
|
||||
import com.fibo.ddp.common.model.common.ResponseEntityDto;
|
||||
import com.fibo.ddp.common.model.common.enums.ErrorCodeEnum;
|
||||
import com.fibo.ddp.common.service.authx.system.SysUserService;
|
||||
import com.fibo.ddp.common.service.common.SessionManager;
|
||||
import com.fibo.ddp.common.service.monitor.logger.ArchivesLog;
|
||||
import com.fibo.ddp.common.utils.constant.OpTypeConst;
|
||||
import com.fibo.ddp.common.utils.exception.ApiException;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @apiDefine sysManager 6.系统管理
|
||||
*/
|
||||
@Controller("sysUserControllerV2")
|
||||
@RequestMapping("v2/sysUser")
|
||||
@ResponseBody
|
||||
public class SysUserController {
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
/**
|
||||
* @api {POST} /v2/sysUser/getUserList 6.11. 获取用户列表
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} pageNo 页数
|
||||
* @apiParam {Integer} pageSize 每页的条数
|
||||
* @apiSuccess {JSON} pager 分页信息
|
||||
* @apiSuccess {JSONArray} listUser 用户列表
|
||||
* @apiSuccess (listUser) {Long} userId 用户Id
|
||||
* @apiSuccess (listUser) {Long} organId 组织编号
|
||||
* @apiSuccess (listUser) {String} employeeId 员工编号
|
||||
* @apiSuccess (listUser) {String} account 账号
|
||||
* @apiSuccess (listUser) {String} nickName 姓名
|
||||
* @apiSuccess (listUser) {String} cellphone 手机号
|
||||
* @apiSuccess (listUser) {String} email 邮箱
|
||||
* @apiSuccess (listUser) {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiSuccess (listUser) {String} author 创建人
|
||||
* @apiSuccess (listUser) {Long} birth 创建时间
|
||||
* @apiSuccess (listUser) {JSON} sysRole 角色信息
|
||||
* @apiSuccess (sysRole) {Long} userId 角色编号
|
||||
* @apiSuccess (sysRole) {String} roleName 角色名称
|
||||
* @apiSuccess (listUser) {JSON} sysOrgan 公司信息
|
||||
* @apiSuccess (sysOrgan) {Long} userId 组织编号
|
||||
* @apiSuccess (sysOrgan) {String} name 组织名称
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"pageNo":1,"pageSize":2}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"pager":{"pageNum":1,"pageSize":2,"size":2,"startRow":1,"endRow":2,"total":12,"pages":6,"list":null,"prePage":0,"nextPage":2,"isFirstPage":true,"isLastPage":false,"hasPreviousPage":false,"hasNextPage":true,"navigatePages":8,"navigatepageNums":[1,2,3,4,5,6],"navigateFirstPage":1,"navigateLastPage":6,"lastPage":6,"firstPage":1},"listUser":[{"userId":149,"organId":46,"employeeId":"011","account":"rong360","password":"4m774i0~4m2&5n1c4i55296#2@1j010i","nickName":"rong","email":"11@qq.com","cellphone":"15222222222","qq":null,"latestTime":null,"latestIp":null,"status":1,"birth":1613801940000,"author":"超级管理员","sysRole":{"userId":70,"organId":0,"roleName":"管理员","roleCode":null,"roleDesc":null,"author":null,"birth":null,"status":0},"sysOrgan":{"userId":46,"name":"管理员","versionCode":null,"email":null,"telephone":null,"status":0,"author":null,"birth":null,"token":null}},{"userId":148,"organId":46,"employeeId":"010","account":"yljr","password":"4m774i0~4m2&5n1c4i55296#2@1j010i","nickName":"yljr","email":"11@qq.com","cellphone":"15222222222","qq":null,"latestTime":null,"latestIp":null,"status":1,"birth":1613720093000,"author":"超级管理员","sysRole":{"userId":70,"organId":0,"roleName":"管理员","roleCode":null,"roleDesc":null,"author":null,"birth":null,"status":0},"sysOrgan":{"userId":46,"name":"管理员","versionCode":null,"email":null,"telephone":null,"status":0,"author":null,"birth":null,"token":null}}]}}
|
||||
*/
|
||||
@RequestMapping(value = "getUserList", method = RequestMethod.POST)
|
||||
public ResponseEntityDto<Object> getUserList(@RequestBody BaseParam baseParam) {
|
||||
SysUser sysUser = new SysUser();
|
||||
//获取登录人所在公司
|
||||
SysUser user = SessionManager.getLoginAccount();
|
||||
long organId = user.getOrganId();
|
||||
sysUser.setOrganId(organId);
|
||||
PageHelper.startPage(baseParam.getPageNo(), baseParam.getPageSize());
|
||||
List<SysUser> listUser = sysUserService.getAllUsers(sysUser);
|
||||
PageInfo<SysUser> pageInfo = new PageInfo<SysUser>(listUser);
|
||||
pageInfo.setList(null);
|
||||
HashMap<String, Object> modelMap = new HashMap<>();
|
||||
modelMap.put("listUser", listUser);
|
||||
modelMap.put("pager", pageInfo);
|
||||
return ResponseEntityBuilder.buildNormalResponse(modelMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysUser/save 6.12. 创建用户
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} organId 组织编号
|
||||
* @apiParam {String} employeeId 员工编号
|
||||
* @apiParam {String} account 账号
|
||||
* @apiParam {String} nickName 姓名
|
||||
* @apiParam {String} cellphone 手机号
|
||||
* @apiParam {String} email 邮箱
|
||||
* @apiParam {JSON} sysRole 角色信息
|
||||
* @apiParam (sysRole) {Long} userId 角色编号
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"organId":46,"employeeId":"012","account":"testuser","nickName":"张三","email":"11@qq.com","cellphone":"15222222222","sysRole":{"userId":71}}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "save", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.SAVE_SYS_USER)
|
||||
public ResponseEntityDto<Object> save(@RequestBody SysUser sysUser) {
|
||||
String nickName = sysUser.getNickName();
|
||||
if (nickName.equals("超级管理员")) {
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_USER_NAME_ERROR.getCode(), ErrorCodeEnum.CREATE_USER_NAME_ERROR.getMessage());
|
||||
}
|
||||
String account = sysUser.getAccount();
|
||||
sysUser.setAccount(account);
|
||||
//验证唯一性
|
||||
List<SysUser> list = sysUserService.validateUserOnly(sysUser);
|
||||
if (list != null && list.size() > 0) {
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_USER_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_USER_NAME_REPEAT.getMessage());
|
||||
}
|
||||
long num = sysUserService.createSysUser(sysUser);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysUser/getUserInfo/{userId} 6.13. 获取用户详情
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 用户Id(url参数)
|
||||
* @apiSuccess {Long} userId 用户Id
|
||||
* @apiSuccess {Long} organId 组织编号
|
||||
* @apiSuccess {String} employeeId 员工编号
|
||||
* @apiSuccess {String} account 账号
|
||||
* @apiSuccess {String} nickName 姓名
|
||||
* @apiSuccess {String} cellphone 手机号
|
||||
* @apiSuccess {String} email 邮箱
|
||||
* @apiSuccess {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiSuccess {String} author 创建人
|
||||
* @apiSuccess {Long} birth 创建时间
|
||||
* @apiSuccess {JSON} sysRole 角色信息
|
||||
* @apiSuccess (sysRole) {Long} userId 角色编号
|
||||
* @apiSuccess (sysRole) {String} roleName 角色名称
|
||||
* @apiSuccess {JSON} sysOrgan 公司信息
|
||||
* @apiSuccess (sysOrgan) {Long} userId 组织编号
|
||||
* @apiSuccess (sysOrgan) {String} name 组织名称
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":{"userId":149,"organId":46,"employeeId":"011","account":"rong360","password":"4m774i0~4m2&5n1c4i55296#2@1j010i","nickName":"rong","email":"11@qq.com","cellphone":"15222222222","qq":null,"latestTime":null,"latestIp":null,"status":1,"birth":1613801940000,"author":"超级管理员","sysRole":{"userId":70,"organId":0,"roleName":"管理员","roleCode":null,"roleDesc":null,"author":null,"birth":null,"status":0},"sysOrgan":{"userId":46,"name":null,"versionCode":null,"email":null,"telephone":null,"status":0,"author":null,"birth":null,"token":null}}}
|
||||
*/
|
||||
@RequestMapping(value = "/getUserInfo/{id}", method = RequestMethod.POST)
|
||||
public ResponseEntityDto<Object> getUserInfo(@PathVariable long id) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(id);
|
||||
//获取用户所在公司
|
||||
SysUser user = SessionManager.getLoginAccount();
|
||||
long organId = user.getOrganId();
|
||||
sysUser.setOrganId(organId);
|
||||
SysUser result = sysUserService.findById(sysUser);
|
||||
return ResponseEntityBuilder.buildNormalResponse(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysUser/update 6.14. 修改用户
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 用户Id
|
||||
* @apiParam {Long} organId 组织编号
|
||||
* @apiParam {String} employeeId 员工编号
|
||||
* @apiParam {String} account 账号
|
||||
* @apiParam {String} nickName 姓名
|
||||
* @apiParam {String} cellphone 手机号
|
||||
* @apiParam {String} email 邮箱
|
||||
* @apiParam {JSON} sysRole 角色信息
|
||||
* @apiParam (sysRole) {Long} userId 角色编号
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"userId":150,"organId":46,"employeeId":"012","account":"testuser2","nickName":"张三","email":"11@qq.com","cellphone":"15222222222","sysRole":{"userId":72}}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_SYS_USER)
|
||||
public ResponseEntityDto<Object> update(@RequestBody SysUser sysUser) {
|
||||
String account = sysUser.getAccount();
|
||||
sysUser.setAccount(account);
|
||||
List<SysUser> list = sysUserService.validateUserOnly(sysUser);
|
||||
if (list != null && list.size() > 0) {
|
||||
throw new ApiException(ErrorCodeEnum.CREATE_USER_NAME_REPEAT.getCode(), ErrorCodeEnum.CREATE_USER_NAME_REPEAT.getMessage());
|
||||
}
|
||||
int num = sysUserService.updateSysUser(sysUser);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysUser/updateStatus 6.15. 用户停用、启用、删除
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Integer} status 状态:0停用,1启用, -1删除
|
||||
* @apiParam {String} ids 用户Id,逗号分隔
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"status":0,"ids":"150,151"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":2}
|
||||
*/
|
||||
@RequestMapping(value = "updateStatus", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDATE_SYS_USER_STATUS)
|
||||
public ResponseEntityDto<Object> updateStatus(@RequestBody Map<String, Object> param) {
|
||||
int status = (Integer) param.get("status");
|
||||
String ids = (String) param.get("ids");
|
||||
int num = 0;
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
if (ids != "") {
|
||||
String[] strs = ids.split(",");
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
list.add(Integer.parseInt(strs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (list != null && list.size() > 0) {
|
||||
num = sysUserService.updateStates(status, list);
|
||||
}
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {POST} /v2/sysUser/updatePassword 6.16. 修改密码
|
||||
* @apiGroup sysManager
|
||||
* @apiVersion 2.0.0
|
||||
* @apiParam {Long} userId 用户Id
|
||||
* @apiParam {String} password 新密码
|
||||
* @apiSuccess {String} status 状态: 1成功, 0失败
|
||||
* @apiParamExample {json} 请求示例:
|
||||
* {"userId":136,"password":"654321"}
|
||||
* @apiSuccessExample {json} 成功返回数据示例:
|
||||
* {"status":"1","error":"00000000","msg":null,"data":1}
|
||||
*/
|
||||
@RequestMapping(value = "updatePassword", method = RequestMethod.POST)
|
||||
@ArchivesLog(operationType = OpTypeConst.UPDTE_PASSWORD)
|
||||
public ResponseEntityDto updatePassword(@RequestBody SysUser sysUser) {
|
||||
int num = sysUserService.updatePassword(sysUser);
|
||||
return ResponseEntityBuilder.buildNormalResponse(num);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user