Commit 973ccbc1 authored by 赵啸非's avatar 赵啸非

添加统计子站点

parent 3d60a94f
package com.mortals.xhx.module.access.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.access.dao.AccessDao;
import com.mortals.xhx.module.access.model.AccessEntity;
import com.mortals.xhx.module.access.service.AccessService;
import org.springframework.beans.factory.annotation.Autowired;
import com.mortals.xhx.module.access.model.AccessSystemEntity;
import com.mortals.xhx.module.access.model.AccessSystemQuery;
import com.mortals.xhx.module.access.service.AccessService;
import com.mortals.xhx.module.access.service.AccessSystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
import java.util.stream.Collectors;
/**
* AccessService
* 区域接入 service实现
*
* @author zxfei
* @date 2024-07-02
*/
* AccessService
* 区域接入 service实现
*
* @author zxfei
* @date 2024-07-02
*/
@Service("accessService")
@Slf4j
public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, AccessEntity, Long> implements AccessService {
@Autowired
private AccessSystemService accessSystemService;
@Override
protected void findAfter(AccessEntity params, PageInfo pageInfo, Context context, List<AccessEntity> list) throws AppException {
fillSubData(list);
super.findAfter(params, pageInfo, context, list);
}
@Override
protected void findAfter(AccessEntity params, Context context, List<AccessEntity> list) throws AppException {
fillSubData(list);
super.findAfter(params, context, list);
}
private void fillSubData(List<AccessEntity> list) {
List<Long> idList = list.stream().map(i -> i.getId()).collect(Collectors.toList());
AccessSystemQuery accessSystemQuery = new AccessSystemQuery();
accessSystemQuery.setAccessIdList(idList);
Map<Long, List<AccessSystemEntity>> accessSystemListMap = accessSystemService.find(accessSystemQuery).stream().collect(Collectors.groupingBy(AccessSystemEntity::getAccessId));
list.forEach(item -> item.setAccessSystemList(accessSystemListMap.get(item.getId())));
}
@Override
protected void saveAfter(AccessEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getAccessSystemList())){
entity.getAccessSystemList().stream().peek(item->{
if (!ObjectUtils.isEmpty(entity.getAccessSystemList())) {
entity.getAccessSystemList().stream().peek(item -> {
item.setAccessId(entity.getId());
item.setCreateUserId(this.getContextUserId(context));
item.setCreateTime(new Date());
......@@ -43,10 +70,10 @@ public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, Access
@Override
protected void updateAfter(AccessEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getAccessSystemList())){
if (!ObjectUtils.isEmpty(entity.getAccessSystemList())) {
Long[] accessSystemIds = accessSystemService.find(new AccessSystemQuery().accessId(entity.getId())).stream().map(AccessSystemEntity::getId).toArray(Long[]::new);
accessSystemService.remove(accessSystemIds,context);
entity.getAccessSystemList().stream().peek(item ->{
accessSystemService.remove(accessSystemIds, context);
entity.getAccessSystemList().stream().peek(item -> {
item.setAccessId(entity.getId());
item.setCreateUserId(this.getContextUserId(context));
item.setCreateTime(new Date());
......@@ -61,7 +88,7 @@ public class AccessServiceImpl extends AbstractCRUDServiceImpl<AccessDao, Access
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
List<AccessSystemEntity> accessSystemlist = accessSystemService.find(new AccessSystemQuery().accessIdList(Arrays.asList(ids)));
accessSystemService.removeList(accessSystemlist,context);
accessSystemService.removeList(accessSystemlist, context);
super.removeAfter(ids, context, result);
}
}
\ No newline at end of file
......@@ -35,8 +35,14 @@ Content-Type: application/json
"bigPath":"5EdNCy",
"tag":"Nu6DiD",
"sort":0,
"remark":"IWuGf0",
}
"accessSystemList":[{
"systemName":"7oX31m",
"systemCode":"aooVxK",
"enabled":0,
"accessTime":"1719504000000",
"sort":0,
"remark":"yIVksS"}],
"remark":"IWuGf0"}
> {%
client.global.set("Access_id", JSON.parse(response.body).data.id);
......
......@@ -66,7 +66,7 @@ POST {{baseUrl}}/stat/stat
Content-Type: application/json
{
"createTimeStart": "2024-01-01",
"createTimeStart": "2023-01-01",
"createTimeEnd": "2024-07-29"
}
......
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