Commit 0103f7b2 by guojuxing

操作日志查询接口

parent 9edf0a74
......@@ -197,4 +197,13 @@ public interface UserApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.UserDTO>>


*/
ServiceResponse<List<UserDTO>> listGicUser(Integer enterpriseId);
/**
* 查询全部
* @Title: listUser

* @Description:

* @author guojuxing
* @param enterpriseId

* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.UserDTO>>


*/
ServiceResponse<List<UserDTO>> listUser(Integer enterpriseId);
}
......@@ -449,6 +449,15 @@ public class UserApiServiceImpl implements UserApiService {
return ServiceResponse.success(Collections.emptyList());
}
@Override
public ServiceResponse<List<UserDTO>> listUser(Integer enterpriseId) {
List<TabSysUser> list = userService.listGicUser(enterpriseId, null);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(EntityUtil.changeEntityListNew(UserDTO.class, list));
}
return ServiceResponse.success(Collections.emptyList());
}
/**
* 保存关联数据,角色关联、资源关联
* @Title: saveRole

......
package com.gic.auth.web.controller;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gic.api.base.commons.Page;
import com.gic.auth.service.CollaboratorApiService;
import com.gic.auth.web.vo.LogListVO;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.utils.UserDetail;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -16,18 +13,28 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.MenuLevelConstants;
import com.gic.auth.constant.MenuTypeEnum;
import com.gic.auth.dto.MenuDTO;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.qo.MenuListQO;
import com.gic.auth.service.CollaboratorApiService;
import com.gic.auth.service.MenuApiService;
import com.gic.auth.service.MenuItemApiService;
import com.gic.auth.service.UserApiService;
import com.gic.auth.web.vo.LogListVO;
import com.gic.auth.web.vo.UserOperationItemAuthVO;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.qo.PageQO;
import com.gic.enterprise.response.EnterpriseRestResponse;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetail;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.log.api.dto.SystemSetLogDTO;
import com.gic.log.api.service.LogApiService;
@RestController
public class MenuController {
......@@ -39,6 +46,10 @@ public class MenuController {
private MenuItemApiService menuItemApiService;
@Autowired
private CollaboratorApiService collaboratorApiService;
@Autowired
private LogApiService logApiService;
@Autowired
private UserApiService userApiService;
/**
* 查询登录用户的gic菜单
......@@ -74,14 +85,7 @@ public class MenuController {
LOGGER.info("查询登录用户的应用的菜单参数:{}-{}-{}", currentMenu, appId, menuCode);
Integer userId = UserDetailUtils.getUserDetail().getUserId();
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
if (StringUtils.isBlank(appId)) {
//根据menuCode去查询对应的appId
ServiceResponse<MenuDTO> menuDTOServiceResponse = menuApiService.getMenuByMenuCode(menuCode);
if (menuDTOServiceResponse.isSuccess()) {
MenuDTO tempDTO = menuDTOServiceResponse.getResult();
appId = tempDTO.getProject();
}
}
appId = getAppId(appId, menuCode);
ServiceResponse<List<MenuDTO>> userMenu = this.menuApiService.getUserMenuOfApp(enterpriseId, userId,
currentMenu, appId);
if (userMenu.isSuccess()) {
......@@ -91,8 +95,10 @@ public class MenuController {
}
@RequestMapping("login-collaborator-menu-of-app")
public RestResponse getCollaboratorMenu(String appId) {
public RestResponse getCollaboratorMenu(String appId, String menuCode) {
LOGGER.info("查询登录用户的协作应用的菜单参数:{}-{}", appId, menuCode);
UserDetail userDetail = UserDetailUtils.getUserDetail();
appId = getAppId(appId, menuCode);
ServiceResponse<List<MenuDTO>> userMenu = this.collaboratorApiService.getCollaboratorMenuPage(
userDetail.getEnterpriseId(), userDetail.getUserInfo().getPhoneNumber(), appId);
if (userMenu.isSuccess()) {
......@@ -102,8 +108,10 @@ public class MenuController {
}
@RequestMapping("login-collaborator-operation-item")
public RestResponse getCollaboratorOperationItem(String appId) {
public RestResponse getCollaboratorOperationItem(String appId, String menuCode) {
LOGGER.info("查询登录用户的协作应用的操作项参数:{}-{}", appId, menuCode);
UserDetail userDetail = UserDetailUtils.getUserDetail();
appId = getAppId(appId, menuCode);
boolean isSuperAdmin = userDetail.getUserInfo().getSuperAdmin().intValue() == 1;
ServiceResponse<List<MenuDTO>> userMenu = this.collaboratorApiService.getCollaboratorOperationItem(
userDetail.getEnterpriseId(), userDetail.getUserInfo().getPhoneNumber(), appId, isSuperAdmin);
......@@ -134,8 +142,10 @@ public class MenuController {
* @return com.gic.commons.webapi.reponse.RestResponse


*/
@RequestMapping("login-user-operation-item-of-app")
public RestResponse loginUserOperationItemOfApp(String appId) {
public RestResponse loginUserOperationItemOfApp(String appId, String menuCode) {
LOGGER.info("登陆用户没有权限的操作项列表数据:{}-{}", appId, menuCode);
Integer userId = UserDetailUtils.getUserDetail().getUserId();
appId = getAppId(appId, menuCode);
ServiceResponse<List<MenuDTO>> menuList = this.menuApiService.getNoAuthOperationItemOfApp(userId, "");
List<UserOperationItemAuthVO> resultList = new ArrayList<>();
if (menuList.isSuccess()) {
......@@ -182,19 +192,52 @@ public class MenuController {
* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/list-log")
public RestResponse listOperationLog(String startTime, String endTime, Integer menuId, String search) {
public RestResponse listOperationLog(String startTime, String endTime, Integer menuId, String search, PageQO pageQO) {
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
Page<Map<String, Object>> pageParam = new Page<>();
Map<String, Object> param = new HashMap<>(16);
param.put("relationId", menuId);
param.put("enterpriseId", enterpriseId);
param.put("logTimeBegin", startTime);
param.put("logTimeEnd", endTime);
param.put("interfaceName", search);
pageParam.setCurrentPage(pageQO.getCurrentPage());
pageParam.setPageSize(pageQO.getPageSize());
pageParam.setParams(param);
ServiceResponse<Page<SystemSetLogDTO>> response = logApiService.listSystemSetLog(pageParam);
Page<LogListVO> result = new Page<>();
LogListVO vo = new LogListVO();
vo.setContent("北丐测试");
vo.setLogId(1234567899L);
vo.setLogTime(new Date());
vo.setOperationObject("北丐");
vo.setProject("北丐-北丐测试");
vo.setUserName("北丐");
List<LogListVO> list = new ArrayList<>(1);
list.add(vo);
result.setResult(list);
if (response.isSuccess()) {
Page<SystemSetLogDTO> pageResult = response.getResult();
List<SystemSetLogDTO> list = pageResult.getResult();
if (CollectionUtils.isNotEmpty(list)) {
//用户ID和手机号码的映射数据
Map<String, UserDTO> userMapPhone = new HashMap<>(16);
ServiceResponse<List<UserDTO>> userResponse = userApiService.listUser(enterpriseId);
if (userResponse.isSuccess()) {
List<UserDTO> userList = userResponse.getResult();
for (UserDTO userDTO : userList) {
userMapPhone.put(userDTO.getUserId().toString(), userDTO);
}
}
List<LogListVO> voList = new ArrayList<>(list.size());
result = EntityUtil.changeEntityNew(Page.class, pageResult);
for (SystemSetLogDTO logDTO : list) {
LogListVO vo = EntityUtil.changeEntityNew(LogListVO.class, logDTO);
UserDTO temp = userMapPhone.get(logDTO.getUserId());
if (temp != null) {
vo.setNationCode(temp.getPhoneAreaCode());
vo.setPhone(temp.getPhoneNumber());
}
voList.add(vo);
}
result.setResult(voList);
}
}
return RestResponse.success(result);
}
......@@ -223,4 +266,16 @@ public class MenuController {
return result;
}
private String getAppId(String appId, String menuCode) {
if (StringUtils.isBlank(appId)) {
//根据menuCode去查询对应的appId
ServiceResponse<MenuDTO> menuDTOServiceResponse = menuApiService.getMenuByMenuCode(menuCode);
if (menuDTOServiceResponse.isSuccess()) {
MenuDTO tempDTO = menuDTOServiceResponse.getResult();
appId = tempDTO.getProject();
}
}
return appId;
}
}
......@@ -16,92 +16,130 @@ public class LogListVO implements Serializable{
private static final long serialVersionUID = -2104494155980859518L;
private Long logId;
// 商户用户
/**
* 操作人
*/
private Long userId;
private String userName;
// 模块
private String nationCode;
private String phone;
/**
* 操作模块
*/
private String project;
// 操作时间
/**
* 操作时间
*/
private Date logTime;
// 日志内容
private String content;
// 创建时间
private Date createTime = new Date();
private Date createTime;
//关联ID
/**
*
*/
private Long relationId;
/**
*
*/
private String operationObject;
public Long getLogId() {
return logId;
}
public void setLogId(Long logId) {
public LogListVO setLogId(Long logId) {
this.logId = logId;
return this;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
public LogListVO setUserId(Long userId) {
this.userId = userId;
return this;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
public LogListVO setUserName(String userName) {
this.userName = userName;
return this;
}
public String getNationCode() {
return nationCode;
}
public LogListVO setNationCode(String nationCode) {
this.nationCode = nationCode;
return this;
}
public String getPhone() {
return phone;
}
public LogListVO setPhone(String phone) {
this.phone = phone;
return this;
}
public String getProject() {
return project;
}
public void setProject(String project) {
public LogListVO setProject(String project) {
this.project = project;
return this;
}
public Date getLogTime() {
return logTime;
}
public void setLogTime(Date logTime) {
public LogListVO setLogTime(Date logTime) {
this.logTime = logTime;
return this;
}
public String getContent() {
return content;
}
public void setContent(String content) {
public LogListVO setContent(String content) {
this.content = content;
return this;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
public LogListVO setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Long getRelationId() {
return relationId;
}
public void setRelationId(Long relationId) {
public LogListVO setRelationId(Long relationId) {
this.relationId = relationId;
return this;
}
public String getOperationObject() {
return operationObject;
}
public void setOperationObject(String operationObject) {
public LogListVO setOperationObject(String operationObject) {
this.operationObject = operationObject;
return this;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment