提交 7cffb530 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 a621dfda
package cn.ibizlab.web.filter;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
/**
* 将应用实体映射到对应的系统服务接口
*/
@Component
public class webDataEntitySysApiMappingFilter extends ZuulFilter {
private static Map<String, String> AppDataEntitySysApiMapping = new HashMap<>();
@PostConstruct
private void initDataEntitySysApiMapping() {
AppDataEntitySysApiMapping.put("ibzdictitem", "dictapi");
AppDataEntitySysApiMapping.put("ibzdict", "dictapi");
}
@Override
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
Object entity = context.get(FilterConstants.PROXY_KEY);
Object requestPath = context.get(FilterConstants.REQUEST_URI_KEY);
if (ObjectUtils.isEmpty(requestPath) || ObjectUtils.isEmpty(entity)) {
return null;
}
String sysApiPrefix = AppDataEntitySysApiMapping.get(entity);
if (StringUtils.isEmpty(sysApiPrefix)) {
return null;
}
context.put(FilterConstants.REQUEST_URI_KEY, String.format("/%s%s", sysApiPrefix,requestPath));
return null;
}
@Override
public String filterType() {
return FilterConstants.PRE_TYPE;
}
@Override
public int filterOrder() {
return FilterConstants.PRE_DECORATION_FILTER_ORDER + 1;
}
@Override
public boolean shouldFilter() {
return true;
}
}
......@@ -35,16 +35,26 @@ import cn.ibizlab.core.dict.filter.IBZDictSearchContext;
import cn.ibizlab.core.dict.service.mapping.IBZDictMapping;
import cn.ibizlab.service.dictapi.dto.IBZDictItemDTO;
import cn.ibizlab.core.dict.domain.IBZDictItem;
import cn.ibizlab.core.dict.service.IIBZDictItemService;
@Slf4j
@Api(tags = {"IBZDict" })
@RestController("dictapiIBZDict")
@RestController("dictapi-ibzdict")
@RequestMapping("")
public class IBZDictResource {
@Autowired
private IIBZDictService ibzdictService;
@Autowired
private IBZDictMapping ibzdictMapping;
@Autowired
private IIBZDictItemService ibzdictitemService;
@ApiOperation(value = "Get", tags = {"IBZDict" }, notes = "Get")
@RequestMapping(method = RequestMethod.GET, value = "/dictapi/ibzdicts/{ibzdict_id}")
public ResponseEntity<IBZDictDTO> get(@PathVariable("ibzdict_id") String ibzdict_id) {
......@@ -57,9 +67,10 @@ public class IBZDictResource {
@RequestMapping(method = RequestMethod.POST, value = "/dictapi/ibzdicts")
@Transactional
public ResponseEntity<IBZDictDTO> create(@RequestBody IBZDictDTO ibzdictdto) {
IBZDict domain = IBZDictMapping.MAPPER.toDomain(ibzdictdto);
IBZDict domain = ibzdictMapping.toDomain(ibzdictdto);
ibzdictService.create(domain);
IBZDictDTO dto = IBZDictMapping.MAPPER.toDto(domain);
IBZDictDTO dto = ibzdictMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册