|
@@ -7,14 +7,24 @@ import com.citu.framework.tenant.core.context.TenantContextHolder;
|
|
|
import com.citu.framework.tenant.core.util.TenantUtils;
|
|
|
import com.citu.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
|
|
import com.citu.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
|
|
+import com.citu.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
|
|
import com.citu.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
|
|
import com.citu.module.infra.dal.mysql.logger.ApiAccessLogMapper;
|
|
|
+import com.citu.module.menduner.system.api.user.MendunerUserApi;
|
|
|
+import com.citu.module.menduner.system.api.user.UserInfoRespDTO;
|
|
|
+import com.citu.module.system.api.dict.DictDataApi;
|
|
|
+import com.citu.module.system.api.dict.dto.DictDataRespDTO;
|
|
|
+import com.citu.module.system.api.user.AdminUserApi;
|
|
|
+import com.citu.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static com.citu.module.infra.dal.dataobject.logger.ApiAccessLogDO.REQUEST_PARAMS_MAX_LENGTH;
|
|
|
import static com.citu.module.infra.dal.dataobject.logger.ApiAccessLogDO.RESULT_MSG_MAX_LENGTH;
|
|
@@ -32,6 +42,16 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
|
|
|
@Resource
|
|
|
private ApiAccessLogMapper apiAccessLogMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ MendunerUserApi mendunerUserApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ AdminUserApi adminUserApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ DictDataApi dictDataApi;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
|
|
|
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
|
|
@@ -46,8 +66,41 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageResult<ApiAccessLogDO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) {
|
|
|
- return apiAccessLogMapper.selectPage(pageReqVO);
|
|
|
+ public PageResult<ApiAccessLogRespVO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) {
|
|
|
+ PageResult<ApiAccessLogRespVO> bean = BeanUtils.toBean(apiAccessLogMapper.selectPage(pageReqVO), ApiAccessLogRespVO.class);
|
|
|
+ List<DictDataRespDTO> datas = dictDataApi.getDictDataList("").getData();
|
|
|
+ Map<String, Map<Long,String>> userTypeMap =new HashMap<>();
|
|
|
+ for (DictDataRespDTO data : datas) {
|
|
|
+ userTypeMap.put(data.getValue(), new HashMap<>());
|
|
|
+ }
|
|
|
+ bean.getList().forEach(item ->userTypeMap.get(item.getUserType().toString()).put(null==item.getUserId()?-1L:item.getUserId(),""));
|
|
|
+ userTypeMap.forEach((key, value) -> {
|
|
|
+ value.remove(-1L);
|
|
|
+
|
|
|
+ if(value.keySet().isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 会员用户
|
|
|
+ if(key.equals("1") ){
|
|
|
+ List<UserInfoRespDTO> data = mendunerUserApi.getUserList(value.keySet()).getData();
|
|
|
+ for (UserInfoRespDTO datum : data) {
|
|
|
+ value.put(datum.getUserId(),datum.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 管理员用户
|
|
|
+ if(key.equals("2")){
|
|
|
+ List<AdminUserRespDTO> data = adminUserApi.getUserList(value.keySet()).getData();
|
|
|
+ for (AdminUserRespDTO datum : data) {
|
|
|
+ value.put(datum.getId(),datum.getNickname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return bean;
|
|
|
}
|
|
|
|
|
|
@Override
|