提交 170e9e6f 编写于 作者: sq3536's avatar sq3536

配置

上级 04aeea74
......@@ -3,6 +3,8 @@ package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.lite.service.impl.DstComponentServiceImpl;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.lite.domain.DstComponent;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
......@@ -31,5 +33,16 @@ public class DstComponentExService extends DstComponentServiceImpl {
public DstComponent sync(DstComponent et) {
return super.sync(et);
}
@Override
@Caching( evict = {
@CacheEvict( value="dstcomponent",key = "'row:'+#p0.appId+'.'+#p0.name"),
@CacheEvict( value="dstcomponent",key = "'row:'+#p0.appId+'.'+#p0.codeName")
})
public boolean update(DstComponent et) {
return super.update(et);
}
}
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.lite.domain.DstApp;
import cn.ibizlab.core.lite.domain.DstSystem;
import cn.ibizlab.core.lite.domain.MetaEntity;
import cn.ibizlab.core.lite.domain.MetaRelationship;
import cn.ibizlab.core.lite.domain.*;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.FieldModel;
import cn.ibizlab.core.lite.extensions.domain.RelationshipModel;
import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import cn.ibizlab.core.lite.service.*;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -16,8 +15,10 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import javax.annotation.PostConstruct;
import java.sql.Wrapper;
......@@ -63,6 +64,10 @@ public class LiteModelService {
@Lazy
private IMetaDataSetService metaDataSetService;
@Autowired
@Lazy
private IDstComponentService dstComponentService;
@Cacheable( value="entitymodel",key = "'row:'+#p0+'.'+#p1")
public EntityModel getEntityModel(String systemId, String name)
{
......@@ -198,4 +203,25 @@ public class LiteModelService {
return list;
}
@Cacheable( value="dstcomponent",key = "'row:'+#p0+'.'+#p1")
public DstComponent getComponent(String app, String component) {
DstComponent dstComponent = dstComponentService.getOne(Wrappers.<DstComponent>lambdaQuery().eq(DstComponent::getAppId, app).and(
wrapper ->
wrapper.eq(DstComponent::getCodeName, component).or().eq(DstComponent::getName, component)),
true);
if (dstComponent==null||StringUtils.isEmpty(dstComponent.getConfig()))
throw new BadRequestAlertException("未找到配置", "DstComponent", component);
return dstComponent;
}
@CacheEvict( value="dstcomponent",key = "'row:'+#p0+'.'+#p1")
public void resetComponent(String app, String component)
{
}
}
......@@ -46,13 +46,7 @@ public class LiteCoreResource {
@RequestMapping(method = RequestMethod.GET, value = "/lite/{app}/components/{component}")
public ResponseEntity<JSON> getComponent(@PathVariable("app") String app, @PathVariable("component") String component) {
DstComponent dstComponent = dstComponentService.getOne(Wrappers.<DstComponent>lambdaQuery().eq(DstComponent::getAppId,app).and(
wrapper ->
wrapper.eq(DstComponent::getCodeName,component).or().eq(DstComponent::getName,component)),
true);
if(StringUtils.isEmpty(dstComponent.getConfig()))
throw new BadRequestAlertException("未找到配置","DstComponent",component);
DstComponent dstComponent = liteModelService.getComponent(app,component);
return ResponseEntity.status(HttpStatus.OK).body(JSON.parseObject(dstComponent.getConfig()));
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册