Commit 3028e9b1 authored by 赵啸非's avatar 赵啸非

Merge remote-tracking branch 'origin/master'

parents ece29de7 df368471
package com.mortals.xhx.module.system.service.impl; package com.mortals.xhx.module.system.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.system.dao.SystemServiceApiDao; import com.mortals.xhx.module.system.dao.SystemServiceApiDao;
...@@ -13,5 +17,13 @@ import com.mortals.xhx.module.system.service.SystemServiceApiService; ...@@ -13,5 +17,13 @@ import com.mortals.xhx.module.system.service.SystemServiceApiService;
*/ */
@Service("systemServiceApiService") @Service("systemServiceApiService")
public class SystemServiceApiServiceImpl extends AbstractCRUDServiceImpl<SystemServiceApiDao, SystemServiceApiEntity, Long> implements SystemServiceApiService { public class SystemServiceApiServiceImpl extends AbstractCRUDServiceImpl<SystemServiceApiDao, SystemServiceApiEntity, Long> implements SystemServiceApiService {
@Override
protected SystemServiceApiEntity findBefore(SystemServiceApiEntity entity, PageInfo pageInfo, Context context) throws AppException {
if(StringUtils.isNotEmpty(entity.getApiName())){
entity.setApiName("%"+entity.getApiName()+"%");
}
pageInfo.setPrePageResult(-1);
return entity;
}
} }
\ No newline at end of file
package com.mortals.xhx.module.system.web; package com.mortals.xhx.module.system.web;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.param.service.ParamService; import com.mortals.xhx.module.param.service.ParamService;
import com.mortals.xhx.module.system.model.SystemServiceApiEntity; import com.mortals.xhx.module.system.model.SystemServiceApiEntity;
import com.mortals.xhx.module.system.service.SystemServiceApiService; import com.mortals.xhx.module.system.service.SystemServiceApiService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.*;
import java.util.stream.Collectors;
/** /**
* *
* API服务 * API服务
...@@ -35,5 +45,24 @@ public class SystemServiceApiController extends BaseCRUDJsonBodyMappingControlle ...@@ -35,5 +45,24 @@ public class SystemServiceApiController extends BaseCRUDJsonBodyMappingControlle
super.init(model, context); super.init(model, context);
} }
@Override
protected int doListAfter(SystemServiceApiEntity query, Map<String, Object> model, Context context) throws AppException {
List<SystemServiceApiEntity> result = (List<SystemServiceApiEntity>) model.get("data");
if(CollectionUtils.isNotEmpty(result)){
List<JSONObject> jsonObjectList = new ArrayList<>();
Map<String,List<SystemServiceApiEntity>> map = result.stream().collect(Collectors.groupingBy(SystemServiceApiEntity::getSystemServiceCode));
Iterator<Map.Entry<String,List<SystemServiceApiEntity>>> iterator = map.entrySet().iterator();
while(iterator.hasNext()){
Map.Entry<String,List<SystemServiceApiEntity>> item = iterator.next();
JSONObject jsonObject = new JSONObject();
jsonObject.put("serviceName",item.getValue().get(0).getSystemServiceName());
jsonObject.put("serviceCode",item.getValue().get(0).getSystemServiceCode());
jsonObject.put("count",item.getValue().size());
jsonObject.put("serviceList",item.getValue());
jsonObjectList.add(jsonObject);
}
model.put("data",jsonObjectList);
}
return 1;
}
} }
\ No newline at end of file
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