|
@@ -1,6 +1,7 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
+import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.common.ResultEnum;
|
|
|
import com.welampiot.dto.GlobalLocationDTO;
|
|
|
import com.welampiot.dto.SectionDTO;
|
|
@@ -13,6 +14,7 @@ import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.vo.GlobalLocationVO;
|
|
|
import com.welampiot.vo.ListResponseVO;
|
|
|
import com.welampiot.vo.LoginVO;
|
|
|
+import com.welampiot.vo.UserVO;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
@@ -142,4 +145,85 @@ public class UserController {
|
|
|
listResponseVO.setList(sectionDTOList);
|
|
|
return BaseResult.success(listResponseVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户信息
|
|
|
+ * @param request 用户id
|
|
|
+ * @return 返回用户信息
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "info", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> info(HttpServletRequest request) {
|
|
|
+ int id = (int) toolUtils.getRequestContent(request,"id",1);
|
|
|
+ int version = (int) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ UserVO userVO = userService.getUserInfoById(id);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,userVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取子账号列表
|
|
|
+ * @param request 用户名username
|
|
|
+ * @return 返回子账号列表
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/userList", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> userList(HttpServletRequest request) {
|
|
|
+ int version = (int) toolUtils.getRequestContent(request,"version",1);
|
|
|
+ String username = (String) toolUtils.getRequestContent(request,"username",2);
|
|
|
+ if (username == null || username.length() == 0)
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ int role = (int) toolUtils.getRequestContent(request,"role",1);
|
|
|
+ int department = (int) toolUtils.getRequestContent(request,"department",1);
|
|
|
+ int companyId = (int) toolUtils.getRequestContent(request,"companyId",1);
|
|
|
+ String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
|
|
|
+ int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
|
|
|
+ int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
|
|
|
+
|
|
|
+ UserDTO dto = new UserDTO();
|
|
|
+ dto.setPage(count * (page - 1));
|
|
|
+ dto.setCount(count);
|
|
|
+ dto.setKeyword(keyword);
|
|
|
+ dto.setRole(role);
|
|
|
+ dto.setDepartment(department);
|
|
|
+ dto.setCompanyId(companyId);
|
|
|
+ dto.setUsername(username);
|
|
|
+ UserDTO dto1 = userService.queryUserIdByUsername(dto.getUsername());
|
|
|
+ if (dto1 == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
+ dto.setId(dto1.getId());
|
|
|
+ List<UserDTO> userList;
|
|
|
+ if (dto1.getRole() == 1) {
|
|
|
+ userList = userService.getAllUserListByUserVO(dto);
|
|
|
+ } else {
|
|
|
+ userList = userService.getUserListByUserVO(dto);
|
|
|
+ }
|
|
|
+ List<UserDTO> list = new ArrayList<>();
|
|
|
+ userList.forEach(userDTO -> {
|
|
|
+ if (userDTO.getRole() == 1) {
|
|
|
+ if (version == 0) {
|
|
|
+ userDTO.setRoleStr("超级管理员");
|
|
|
+ } else if (version == 1) {
|
|
|
+ userDTO.setRoleStr("Super Administrator");
|
|
|
+ } else {
|
|
|
+ userDTO.setRoleStr("суперинтендант");
|
|
|
+ }
|
|
|
+ } else if (userDTO.getRole() == 2) {
|
|
|
+ if (version == 0) {
|
|
|
+ userDTO.setRoleStr("单位管理员");
|
|
|
+ } else if (version == 1) {
|
|
|
+ userDTO.setRoleStr("Unit Administrator");
|
|
|
+ } else {
|
|
|
+ userDTO.setRoleStr("Администратор единицы");
|
|
|
+ }
|
|
|
+ } else if (userDTO.getRole() == 3){
|
|
|
+ if (version == 0) {
|
|
|
+ userDTO.setRoleStr("公司子账号");
|
|
|
+ } else if (version == 1) {
|
|
|
+ userDTO.setRoleStr("Company Sub Account");
|
|
|
+ } else {
|
|
|
+ userDTO.setRoleStr("Субсчет компании");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(userDTO);
|
|
|
+ });
|
|
|
+ return BaseResult.success(list);
|
|
|
+ }
|
|
|
}
|