Browse Source

日志列增加customer_id列

日志查询接口,改为模糊查询
master
wxz 4 years ago
parent
commit
cf238e3ac2
  1. 1
      epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java
  2. 2
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java
  3. 2
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java
  4. 1
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java
  5. 1
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java
  6. 1
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java
  7. 35
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java
  8. 1
      epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.4__addlog_ope_col.sql
  9. 2
      epmet-admin/epmet-admin-server/src/main/resources/logback-spring.xml
  10. 1
      epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml
  11. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

1
epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java

@ -40,6 +40,7 @@ public class LogOperationResultDTO {
/** /**
* 操作人ID * 操作人ID
*/ */
private String customerId;
private String operatorId; private String operatorId;
private String operatorName; private String operatorName;
private String operatorMobile; private String operatorMobile;

2
epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java

@ -65,6 +65,8 @@ public class LogOperationEntity extends BaseEpmetEntity {
*/ */
private String targetId; private String targetId;
private String customerId;
/** /**
* 操作人ID * 操作人ID
*/ */

2
epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java

@ -58,6 +58,6 @@ public class LogOperationHelper implements ResultDataResolver {
Result<CustomerStaffDTO> result = userOpenFeignClient.getCustomerStaffInfoByUserId(form); Result<CustomerStaffDTO> result = userOpenFeignClient.getCustomerStaffInfoByUserId(form);
CustomerStaffDTO staffInfo = getResultDataOrThrowsException(result, ServiceConstant.EPMET_ADMIN_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), CustomerStaffDTO staffInfo = getResultDataOrThrowsException(result, ServiceConstant.EPMET_ADMIN_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(),
"调用epmet-user服务获取staff信息发生异常"); "调用epmet-user服务获取staff信息发生异常");
return new OperatorInfo(staffInfo.getMobile(), staffInfo.getRealName()); return new OperatorInfo(staffInfo.getCustomerId(), staffInfo.getMobile(), staffInfo.getRealName());
} }
} }

1
epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java

@ -6,6 +6,7 @@ import lombok.Data;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class OperatorInfo { public class OperatorInfo {
private String customerId;
private String mobile; private String mobile;
private String name; private String name;
} }

1
epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java

@ -67,6 +67,7 @@ public class AuthOperationLogListener implements MessageListenerConcurrently {
logEntity.setFromApp(msgObj.getFromApp()); logEntity.setFromApp(msgObj.getFromApp());
logEntity.setFromClient(msgObj.getFromClient()); logEntity.setFromClient(msgObj.getFromClient());
logEntity.setTargetId(""); logEntity.setTargetId("");
logEntity.setCustomerId(operatorInfo.getCustomerId());
logEntity.setOperatorId(msgObj.getUserId()); logEntity.setOperatorId(msgObj.getUserId());
logEntity.setOperatorName(operatorInfo.getName()); logEntity.setOperatorName(operatorInfo.getName());
logEntity.setOperatorMobile(operatorInfo.getMobile()); logEntity.setOperatorMobile(operatorInfo.getMobile());

1
epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java

@ -63,6 +63,7 @@ public class ProjectOperationLogListener implements MessageListenerConcurrently
logEntity.setIp(msgObj.getIp()); logEntity.setIp(msgObj.getIp());
logEntity.setFromApp(msgObj.getFromApp()); logEntity.setFromApp(msgObj.getFromApp());
logEntity.setFromClient(msgObj.getFromClient()); logEntity.setFromClient(msgObj.getFromClient());
logEntity.setCustomerId(operatorInfo.getCustomerId());
logEntity.setOperatorId(msgObj.getOperatorId()); logEntity.setOperatorId(msgObj.getOperatorId());
logEntity.setOperatorMobile(operatorInfo.getMobile()); logEntity.setOperatorMobile(operatorInfo.getMobile());
logEntity.setOperatorName(operatorInfo.getName()); logEntity.setOperatorName(operatorInfo.getName());

35
epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java

@ -16,14 +16,12 @@ import com.epmet.dto.region.LogOperationResultDTO;
import com.epmet.entity.LogOperationEntity; import com.epmet.entity.LogOperationEntity;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.LogOperationService; import com.epmet.service.LogOperationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -54,29 +52,35 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR
@Override @Override
public List<LogOperationResultDTO> listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize) { public List<LogOperationResultDTO> listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize) {
// 1.条件查询 // 1.条件查询
List<LogOperationResultDTO> logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize); //List<LogOperationResultDTO> logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize);
if (CollectionUtils.isEmpty(logDtos)) { //if (CollectionUtils.isEmpty(logDtos)) {
logDtos = listByOperatorName(condition, pageNo, pageSize); // logDtos = listByOperatorName(condition, pageNo, pageSize);
} //}
//
if (CollectionUtils.isEmpty(logDtos)) { //if (CollectionUtils.isEmpty(logDtos)) {
return new ArrayList<>(); // return new ArrayList<>();
} //}
// 2.直接分页查询 // 2.直接分页查询
// 条件查询,排序 // 条件查询,排序
LambdaQueryWrapper<LogOperationEntity> w = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LogOperationEntity> w = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(condition)) {
w.like(LogOperationEntity::getOperatorName, condition)
.or()
.like(LogOperationEntity::getOperatorMobile, condition);
}
w.eq(LogOperationEntity::getCustomerId, customerId);
w.orderByDesc(LogOperationEntity::getOperatingTime); w.orderByDesc(LogOperationEntity::getOperatingTime);
IPage<LogOperationEntity> iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); IPage<LogOperationEntity> iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w);
List<LogOperationEntity> logEntities = iPage.getRecords(); List<LogOperationEntity> logEntities = iPage.getRecords();
List<String> userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toList()); Set<String> userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toSet());
return convertLogOperationEntity2DTO(logEntities, getStaffMapByUserIds(userIds)); return convertLogOperationEntity2DTO(logEntities, getStaffMapByUserIds(userIds));
} }
private Map<String, CustomerStaffDTO> getStaffMapByUserIds(List<String> userIds) { private Map<String, CustomerStaffDTO> getStaffMapByUserIds(Set<String> userIds) {
CustomerStaffFormDTO form = new CustomerStaffFormDTO(); CustomerStaffFormDTO form = new CustomerStaffFormDTO();
form.setUserIds(userIds); form.setUserIds(new ArrayList<>(userIds));
Result<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form); Result<List<CustomerStaffDTO>> result = userOpenFeignClient.list(form);
List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); List<CustomerStaffDTO> staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常");
@ -168,6 +172,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR
ldto.setTargetId(l.getTargetId()); ldto.setTargetId(l.getTargetId());
ldto.setType(l.getType()); ldto.setType(l.getType());
ldto.setTypeDisplay(l.getTypeDisplay()); ldto.setTypeDisplay(l.getTypeDisplay());
ldto.setCustomerId(l.getCustomerId());
ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile());
ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName());
return ldto; return ldto;

1
epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.4__addlog_ope_col.sql

@ -0,0 +1 @@
alter table log_operation add CUSTOMER_ID varchar(64) comment '客户id' not null after OPERATOR_ID;

2
epmet-admin/epmet-admin-server/src/main/resources/logback-spring.xml

@ -134,7 +134,7 @@
</appender> </appender>
<!-- 开发、测试环境 --> <!-- 开发、测试环境 -->
<springProfile name="dev,test"> <springProfile name="dev,test,local">
<logger name="org.springframework.web" level="INFO"/> <logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/> <logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/> <logger name="com.epmet.dao" level="INFO"/>

1
epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml

@ -13,6 +13,7 @@
<result property="fromApp" column="FROM_APP"/> <result property="fromApp" column="FROM_APP"/>
<result property="fromClient" column="FROM_CLIENT"/> <result property="fromClient" column="FROM_CLIENT"/>
<result property="category" column="CATEGORY"/> <result property="category" column="CATEGORY"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="operatorId" column="OPERATOR_ID"/> <result property="operatorId" column="OPERATOR_ID"/>
<result property="operatorName" column="OPERATOR_NAME"/> <result property="operatorName" column="OPERATOR_NAME"/>
<result property="operatorMobile" column="OPERATOR_MOBILE"/> <result property="operatorMobile" column="OPERATOR_MOBILE"/>

4
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -424,9 +424,7 @@ public class CustomerStaffController {
*/ */
@PostMapping("list") @PostMapping("list")
public Result<List<CustomerStaffDTO>> list(@RequestBody CustomerStaffFormDTO input) { public Result<List<CustomerStaffDTO>> list(@RequestBody CustomerStaffFormDTO input) {
String customerId = StringUtils.isBlank(input.getCustomerId()) ? loginUserUtil.getLoginUserCustomerId() : input.getCustomerId(); List<CustomerStaffDTO> staffs = customerStaffService.list(input.getCustomerId(), input.getRealName(), input.getMobile(), input.getUserIds());
List<CustomerStaffDTO> staffs = customerStaffService.list(customerId, input.getRealName(), input.getMobile(), input.getUserIds());
return new Result<List<CustomerStaffDTO>>().ok(staffs); return new Result<List<CustomerStaffDTO>>().ok(staffs);
} }

Loading…
Cancel
Save