mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix TablePropertiesRepository related class
This commit is contained in:
parent
f6a09e8c48
commit
192c664db0
@ -112,7 +112,7 @@ public class AppCtxRefreshEventListener implements ApplicationListener<ContextRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 加载系统全局配置
|
* 加载系统全局配置
|
||||||
*/
|
*/
|
||||||
SystemConfigRepository systemConfigRes = event.getApplicationContext().getBean(SystemConfigRepository.class);
|
SystemConfigRepository systemConfigRes = event.getApplicationContext().getBean(SystemConfigRepository.class);
|
||||||
|
@ -29,26 +29,26 @@ import com.chatopera.cc.util.Menu;
|
|||||||
import com.chatopera.cc.util.metadata.DatabaseMetaDataHandler;
|
import com.chatopera.cc.util.metadata.DatabaseMetaDataHandler;
|
||||||
import com.chatopera.cc.util.metadata.UKColumnMetadata;
|
import com.chatopera.cc.util.metadata.UKColumnMetadata;
|
||||||
import com.chatopera.cc.util.metadata.UKTableMetaData;
|
import com.chatopera.cc.util.metadata.UKTableMetaData;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.jdbc.Work;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -56,43 +56,39 @@ import java.util.List;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/admin/metadata")
|
@RequestMapping("/admin/metadata")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class MetadataController extends Handler {
|
public class MetadataController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MetadataRepository metadataRes;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseService<?> service;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysDicRepository sysDicRes;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TablePropertiesRepository tablePropertiesRes;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MetadataController.class);
|
private static final Logger logger = LoggerFactory.getLogger(MetadataController.class);
|
||||||
|
@NonNull
|
||||||
@Autowired
|
private final MetadataRepository metadataRes;
|
||||||
|
@NonNull
|
||||||
|
private final BaseService<?> service;
|
||||||
|
@NonNull
|
||||||
|
private final SysDicRepository sysDicRes;
|
||||||
|
@NonNull
|
||||||
|
private final TablePropertiesRepository tablePropertiesRes;
|
||||||
|
@NonNull
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private final EntityManager em;
|
||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView index(ModelMap map, HttpServletRequest request) throws SQLException {
|
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
||||||
map.addAttribute("metadataList", metadataRes.findAll(PageRequest.of(super.getP(request), super.getPs(request))));
|
map.addAttribute("metadataList", metadataRes.findAll(PageRequest.of(super.getP(request), super.getPs(request))));
|
||||||
return request(super.createAdminTempletResponse("/admin/system/metadata/index"));
|
return request(super.createAdminTempletResponse("/admin/system/metadata/index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/edit")
|
@RequestMapping("/edit")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView edit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
public ModelAndView edit(ModelMap map, @Valid String id) {
|
||||||
map.addAttribute("metadata", metadataRes.findById(id));
|
map.addAttribute("metadata", metadataRes.findById(id));
|
||||||
return request(super.createRequestPageTempletResponse("/admin/system/metadata/edit"));
|
return request(super.createRequestPageTempletResponse("/admin/system/metadata/edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView update(ModelMap map, HttpServletRequest request, @Valid MetadataTable metadata) throws SQLException {
|
public ModelAndView update(@Valid MetadataTable metadata) {
|
||||||
MetadataTable table = metadataRes.findById(metadata.getId());
|
MetadataTable table = metadataRes.findById(metadata.getId());
|
||||||
table.setName(metadata.getName());
|
table.setName(metadata.getName());
|
||||||
table.setFromdb(metadata.isFromdb());
|
table.setFromdb(metadata.isFromdb());
|
||||||
@ -104,7 +100,7 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/properties/edit")
|
@RequestMapping("/properties/edit")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView propertiesedit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
public ModelAndView propertiesedit(ModelMap map, @Valid String id) {
|
||||||
map.addAttribute("tp", tablePropertiesRes.findById(id));
|
map.addAttribute("tp", tablePropertiesRes.findById(id));
|
||||||
map.addAttribute("sysdicList", sysDicRes.findByParentid("0"));
|
map.addAttribute("sysdicList", sysDicRes.findByParentid("0"));
|
||||||
map.addAttribute("dataImplList", Dict.getInstance().getDic("com.dic.data.impl"));
|
map.addAttribute("dataImplList", Dict.getInstance().getDic("com.dic.data.impl"));
|
||||||
@ -114,8 +110,9 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/properties/update")
|
@RequestMapping("/properties/update")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView propertiesupdate(ModelMap map, HttpServletRequest request, @Valid TableProperties tp) throws SQLException {
|
public ModelAndView propertiesupdate(@Valid TableProperties tp) {
|
||||||
TableProperties tableProperties = tablePropertiesRes.findById(tp.getId());
|
TableProperties tableProperties = tablePropertiesRes.findById(tp.getId())
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Table properties %s not found", tp.getId())));
|
||||||
tableProperties.setName(tp.getName());
|
tableProperties.setName(tp.getName());
|
||||||
tableProperties.setSeldata(tp.isSeldata());
|
tableProperties.setSeldata(tp.isSeldata());
|
||||||
tableProperties.setSeldatacode(tp.getSeldatacode());
|
tableProperties.setSeldatacode(tp.getSeldatacode());
|
||||||
@ -139,7 +136,7 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView delete(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException {
|
public ModelAndView delete(@Valid String id) {
|
||||||
MetadataTable table = metadataRes.findById(id);
|
MetadataTable table = metadataRes.findById(id);
|
||||||
metadataRes.delete(table);
|
metadataRes.delete(table);
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
|
||||||
@ -147,33 +144,34 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/batdelete")
|
@RequestMapping("/batdelete")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView batdelete(ModelMap map, HttpServletRequest request, @Valid String[] ids) throws SQLException {
|
public ModelAndView batdelete(@Valid String[] ids) {
|
||||||
if (ids != null && ids.length > 0) {
|
if (ids != null && ids.length > 0) {
|
||||||
metadataRes.delete(metadataRes.findAll(Arrays.asList(ids)));
|
metadataRes.deleteAll(metadataRes.findAllById(Arrays.asList(ids)));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/index.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/properties/delete")
|
@RequestMapping("/properties/delete")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView propertiesdelete(ModelMap map, HttpServletRequest request, @Valid String id, @Valid String tbid) throws SQLException {
|
public ModelAndView propertiesdelete(@Valid String id, @Valid String tbid) {
|
||||||
TableProperties prop = tablePropertiesRes.findById(id);
|
TableProperties prop = tablePropertiesRes.findById(id)
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Table properties %s not found", id)));
|
||||||
tablePropertiesRes.delete(prop);
|
tablePropertiesRes.delete(prop);
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + (!StringUtils.isBlank(tbid) ? tbid : prop.getDbtableid())));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + (!StringUtils.isBlank(tbid) ? tbid : prop.getDbtableid())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/properties/batdelete")
|
@RequestMapping("/properties/batdelete")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView propertiesbatdelete(ModelMap map, HttpServletRequest request, @Valid String[] ids, @Valid String tbid) throws SQLException {
|
public ModelAndView propertiesbatdelete(@Valid String[] ids, @Valid String tbid) {
|
||||||
if (ids != null && ids.length > 0) {
|
if (ids != null && ids.length > 0) {
|
||||||
tablePropertiesRes.delete(tablePropertiesRes.findAll(Arrays.asList(ids)));
|
tablePropertiesRes.deleteAll(tablePropertiesRes.findAllById(Arrays.asList(ids)));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + tbid));
|
return request(super.createRequestPageTempletResponse("redirect:/admin/metadata/table.html?id=" + tbid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/table")
|
@RequestMapping("/table")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView table(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException {
|
public ModelAndView table(ModelMap map, @Valid String id) {
|
||||||
map.addAttribute("propertiesList", tablePropertiesRes.findByDbtableid(id));
|
map.addAttribute("propertiesList", tablePropertiesRes.findByDbtableid(id));
|
||||||
map.addAttribute("tbid", id);
|
map.addAttribute("tbid", id);
|
||||||
map.addAttribute("table", metadataRes.findById(id));
|
map.addAttribute("table", metadataRes.findById(id));
|
||||||
@ -182,17 +180,15 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/imptb")
|
@RequestMapping("/imptb")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView imptb(final ModelMap map, HttpServletRequest request) throws Exception {
|
public ModelAndView imptb(final ModelMap map) {
|
||||||
|
|
||||||
Session session = (Session) em.getDelegate();
|
Session session = (Session) em.getDelegate();
|
||||||
session.doWork(new Work() {
|
session.doWork(connection -> {
|
||||||
public void execute(Connection connection) throws SQLException {
|
try {
|
||||||
try {
|
map.addAttribute("tablesList",
|
||||||
map.addAttribute("tablesList",
|
DatabaseMetaDataHandler.getTables(connection));
|
||||||
DatabaseMetaDataHandler.getTables(connection));
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
logger.error("When import metadata", e);
|
||||||
logger.error("When import metadata", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -202,34 +198,32 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/imptbsave")
|
@RequestMapping("/imptbsave")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView imptb(ModelMap map, HttpServletRequest request, final @Valid String[] tables) throws Exception {
|
public ModelAndView imptb(HttpServletRequest request, final @Valid String[] tables) {
|
||||||
final User user = super.getUser(request);
|
final User user = super.getUser(request);
|
||||||
if (tables != null && tables.length > 0) {
|
if (tables != null && tables.length > 0) {
|
||||||
Session session = (Session) em.getDelegate();
|
Session session = (Session) em.getDelegate();
|
||||||
session.doWork(
|
session.doWork(
|
||||||
new Work() {
|
connection -> {
|
||||||
public void execute(Connection connection) throws SQLException {
|
try {
|
||||||
try {
|
for (String table : tables) {
|
||||||
for (String table : tables) {
|
int count = metadataRes.countByTablename(table);
|
||||||
int count = metadataRes.countByTablename(table);
|
if (count == 0) {
|
||||||
if (count == 0) {
|
MetadataTable metaDataTable = new MetadataTable();
|
||||||
MetadataTable metaDataTable = new MetadataTable();
|
//当前记录没有被添加过,进行正常添加
|
||||||
//当前记录没有被添加过,进行正常添加
|
metaDataTable.setTablename(table);
|
||||||
metaDataTable.setTablename(table);
|
metaDataTable.setOrgi(user.getOrgi());
|
||||||
metaDataTable.setOrgi(user.getOrgi());
|
metaDataTable.setId(MainUtils.md5(metaDataTable.getTablename()));
|
||||||
metaDataTable.setId(MainUtils.md5(metaDataTable.getTablename()));
|
metaDataTable.setTabledirid("0");
|
||||||
metaDataTable.setTabledirid("0");
|
metaDataTable.setCreater(user.getId());
|
||||||
metaDataTable.setCreater(user.getId());
|
metaDataTable.setCreatername(user.getUsername());
|
||||||
metaDataTable.setCreatername(user.getUsername());
|
metaDataTable.setName(table);
|
||||||
metaDataTable.setName(table);
|
metaDataTable.setUpdatetime(new Date());
|
||||||
metaDataTable.setUpdatetime(new Date());
|
metaDataTable.setCreatetime(new Date());
|
||||||
metaDataTable.setCreatetime(new Date());
|
metadataRes.save(processMetadataTable(DatabaseMetaDataHandler.getTable(connection, metaDataTable.getTablename()), metaDataTable));
|
||||||
metadataRes.save(processMetadataTable(DatabaseMetaDataHandler.getTable(connection, metaDataTable.getTablename()), metaDataTable));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("When import metadata", e);
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("When import metadata", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -240,7 +234,7 @@ public class MetadataController extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MetadataTable processMetadataTable(UKTableMetaData metaData, MetadataTable table) {
|
private MetadataTable processMetadataTable(UKTableMetaData metaData, MetadataTable table) {
|
||||||
table.setTableproperty(new ArrayList<TableProperties>());
|
table.setTableproperty(new ArrayList<>());
|
||||||
if (metaData != null) {
|
if (metaData != null) {
|
||||||
for (UKColumnMetadata colum : metaData.getColumnMetadatas()) {
|
for (UKColumnMetadata colum : metaData.getColumnMetadatas()) {
|
||||||
TableProperties tablePorperties = new TableProperties(colum.getName().toLowerCase(), colum.getTypeName(), colum.getColumnSize(), metaData.getName().toLowerCase());
|
TableProperties tablePorperties = new TableProperties(colum.getName().toLowerCase(), colum.getTypeName(), colum.getColumnSize(), metaData.getName().toLowerCase());
|
||||||
@ -263,7 +257,7 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
public String getDataTypeName(String type) {
|
public String getDataTypeName(String type) {
|
||||||
String typeName = "text";
|
String typeName = "text";
|
||||||
if (type.indexOf("varchar") >= 0) {
|
if (type.contains("varchar")) {
|
||||||
typeName = "text";
|
typeName = "text";
|
||||||
} else if (type.equalsIgnoreCase("date") || type.equalsIgnoreCase("datetime")) {
|
} else if (type.equalsIgnoreCase("date") || type.equalsIgnoreCase("datetime")) {
|
||||||
typeName = type.toLowerCase();
|
typeName = type.toLowerCase();
|
||||||
@ -275,7 +269,7 @@ public class MetadataController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping("/clean")
|
@RequestMapping("/clean")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView clean(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException, BeansException, ClassNotFoundException {
|
public ModelAndView clean(@Valid String id) throws BeansException, ClassNotFoundException {
|
||||||
if (!StringUtils.isBlank(id)) {
|
if (!StringUtils.isBlank(id)) {
|
||||||
MetadataTable table = metadataRes.findById(id);
|
MetadataTable table = metadataRes.findById(id);
|
||||||
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
|
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
|
||||||
@ -295,7 +289,7 @@ public class MetadataController extends Handler {
|
|||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@RequestMapping("/synctoes")
|
@RequestMapping("/synctoes")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView synctoes(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException, BeansException, ClassNotFoundException {
|
public ModelAndView synctoes(@Valid String id) throws BeansException, ClassNotFoundException {
|
||||||
if (!StringUtils.isBlank(id)) {
|
if (!StringUtils.isBlank(id)) {
|
||||||
MetadataTable table = metadataRes.findById(id);
|
MetadataTable table = metadataRes.findById(id);
|
||||||
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
|
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
|
||||||
@ -309,9 +303,7 @@ public class MetadataController extends Handler {
|
|||||||
SysDic jpaDic = Dict.getInstance().getDicItem(table.getPreviewtemplet());
|
SysDic jpaDic = Dict.getInstance().getDicItem(table.getPreviewtemplet());
|
||||||
List dataList = service.list(jpaDic.getCode());
|
List dataList = service.list(jpaDic.getCode());
|
||||||
List values = new CskefuList();
|
List values = new CskefuList();
|
||||||
for (Object object : dataList) {
|
values.addAll(dataList);
|
||||||
values.add(object);
|
|
||||||
}
|
|
||||||
if (dataList.size() > 0) {
|
if (dataList.size() > 0) {
|
||||||
jpa.save(values);
|
jpa.save(values);
|
||||||
}
|
}
|
||||||
@ -326,7 +318,7 @@ public class MetadataController extends Handler {
|
|||||||
@SuppressWarnings({"rawtypes"})
|
@SuppressWarnings({"rawtypes"})
|
||||||
@RequestMapping("/synctodb")
|
@RequestMapping("/synctodb")
|
||||||
@Menu(type = "admin", subtype = "metadata", admin = true)
|
@Menu(type = "admin", subtype = "metadata", admin = true)
|
||||||
public ModelAndView synctodb(ModelMap map, HttpServletRequest request, @Valid String id) throws SQLException, BeansException, ClassNotFoundException {
|
public ModelAndView synctodb(@Valid String id) throws BeansException, ClassNotFoundException {
|
||||||
if (!StringUtils.isBlank(id)) {
|
if (!StringUtils.isBlank(id)) {
|
||||||
MetadataTable table = metadataRes.findById(id);
|
MetadataTable table = metadataRes.findById(id);
|
||||||
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
|
if (table.isFromdb() && !StringUtils.isBlank(table.getListblocktemplet())) {
|
||||||
|
@ -26,11 +26,14 @@ import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.DimensionRepository;
|
import com.chatopera.cc.persistence.repository.DimensionRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
|
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -39,123 +42,126 @@ import java.util.List;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/apps/report/cubelevel")
|
@RequestMapping("/apps/report/cubelevel")
|
||||||
public class CubeLevelController extends Handler{
|
@RequiredArgsConstructor
|
||||||
|
public class CubeLevelController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private CubeLevelRepository cubeLevelRes;
|
private final CubeLevelRepository cubeLevelRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private DimensionRepository dimensionRes;
|
private final DimensionRepository dimensionRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TablePropertiesRepository tablePropertiesRes;
|
private final TablePropertiesRepository tablePropertiesRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private CubeMetadataRepository cubeMetadataRes;
|
private final CubeMetadataRepository cubeMetadataRes;
|
||||||
|
|
||||||
@RequestMapping("/add")
|
@RequestMapping("/add")
|
||||||
@Menu(type = "report" , subtype = "cubelevel")
|
@Menu(type = "report", subtype = "cubelevel")
|
||||||
public ModelAndView cubeLeveladd(ModelMap map , HttpServletRequest request , @Valid String cubeid,@Valid String dimid) {
|
public ModelAndView cubeLeveladd(ModelMap map, HttpServletRequest request, @Valid String cubeid, @Valid String dimid) {
|
||||||
map.addAttribute("cubeid", cubeid);
|
map.addAttribute("cubeid", cubeid);
|
||||||
map.addAttribute("dimid", dimid);
|
map.addAttribute("dimid", dimid);
|
||||||
//map.addAttribute("fktableList",cubeMetadataRes.findByCubeid(cubeid));
|
//map.addAttribute("fktableList",cubeMetadataRes.findByCubeid(cubeid));
|
||||||
Dimension dim = dimensionRes.findByIdAndOrgi(dimid,super.getOrgi(request));
|
Dimension dim = dimensionRes.findByIdAndOrgi(dimid, super.getOrgi(request));
|
||||||
|
|
||||||
if(dim!=null){
|
if (dim != null) {
|
||||||
if(!StringUtils.isBlank(dim.getFktable())) {
|
if (!StringUtils.isBlank(dim.getFktable())) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dim.getFktable()));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dim.getFktable()));
|
||||||
}else {
|
} else {
|
||||||
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeid,"0");
|
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeid, "0");
|
||||||
if(!cmList.isEmpty() && cmList.get(0)!=null) {
|
if (!cmList.isEmpty() && cmList.get(0) != null) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/add"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
@Menu(type = "report" , subtype = "cubelevel" )
|
@Menu(type = "report", subtype = "cubelevel")
|
||||||
public ModelAndView cubeLevelsave(ModelMap map , HttpServletRequest request , @Valid CubeLevel cubeLevel,@Valid String tableid) {
|
public ModelAndView cubeLevelsave(HttpServletRequest request, @Valid CubeLevel cubeLevel, @Valid String tableid) {
|
||||||
if(!StringUtils.isBlank(cubeLevel.getName())){
|
if (!StringUtils.isBlank(cubeLevel.getName())) {
|
||||||
cubeLevel.setOrgi(super.getOrgi(request));
|
cubeLevel.setOrgi(super.getOrgi(request));
|
||||||
cubeLevel.setCreater(super.getUser(request).getId());
|
cubeLevel.setCreater(super.getUser(request).getId());
|
||||||
cubeLevel.setCode(cubeLevel.getColumname());
|
cubeLevel.setCode(cubeLevel.getColumname());
|
||||||
if(!StringUtils.isBlank(tableid)) {
|
if (!StringUtils.isBlank(tableid)) {
|
||||||
TableProperties tb = new TableProperties();
|
TableProperties tb = new TableProperties();
|
||||||
tb.setId(tableid);
|
tb.setId(tableid);
|
||||||
TableProperties t = tablePropertiesRes.findById(tableid);
|
TableProperties t = tablePropertiesRes.findById(tableid)
|
||||||
cubeLevel.setTablename(t.getTablename());
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Table properties %s not found", tableid)));
|
||||||
cubeLevel.setCode(t.getFieldname());
|
cubeLevel.setTablename(t.getTablename());
|
||||||
cubeLevel.setColumname(t.getFieldname());
|
cubeLevel.setCode(t.getFieldname());
|
||||||
cubeLevel.setTableproperty(tb);
|
cubeLevel.setColumname(t.getFieldname());
|
||||||
}
|
cubeLevel.setTableproperty(tb);
|
||||||
cubeLevelRes.save(cubeLevel) ;
|
}
|
||||||
}
|
cubeLevelRes.save(cubeLevel);
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeLevel.getCubeid()+"&dimensionId="+cubeLevel.getDimid()));
|
}
|
||||||
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id=" + cubeLevel.getCubeid() + "&dimensionId=" + cubeLevel.getDimid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
@Menu(type = "report" , subtype = "cubelevel" )
|
@Menu(type = "report", subtype = "cubelevel")
|
||||||
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
|
public ModelAndView quickreplydelete(@Valid String id) {
|
||||||
CubeLevel cubeLevel = cubeLevelRes.findOne(id) ;
|
CubeLevel cubeLevel = cubeLevelRes.findById(id)
|
||||||
if(cubeLevel!=null){
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Cube level %s not found", id)));
|
||||||
cubeLevelRes.delete(cubeLevel);
|
cubeLevelRes.delete(cubeLevel);
|
||||||
}
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id=" + cubeLevel.getCubeid() + "&dimensionId=" + cubeLevel.getDimid()));
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeLevel.getCubeid()+"&dimensionId="+cubeLevel.getDimid()));
|
|
||||||
}
|
}
|
||||||
@RequestMapping("/edit")
|
|
||||||
@Menu(type = "report" , subtype = "cubelevel" , admin= true)
|
|
||||||
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
|
|
||||||
CubeLevel cubeLevel = cubeLevelRes.findOne(id) ;
|
|
||||||
map.put("cubeLevel", cubeLevel) ;
|
|
||||||
Dimension dim = dimensionRes.findByIdAndOrgi(cubeLevel.getDimid(),super.getOrgi(request));
|
|
||||||
if(dim!=null){
|
|
||||||
if(!StringUtils.isBlank(dim.getFktable())) {
|
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dim.getFktable()));
|
|
||||||
map.addAttribute("tableid", dim.getFktable());
|
|
||||||
}else {
|
|
||||||
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeLevel.getCubeid(),"0");
|
|
||||||
if(!cmList.isEmpty() && cmList.get(0)!=null) {
|
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
|
||||||
map.addAttribute("tableid", cmList.get(0).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
@RequestMapping("/edit")
|
||||||
|
@Menu(type = "report", subtype = "cubelevel", admin = true)
|
||||||
|
public ModelAndView quickreplyedit(ModelMap map, HttpServletRequest request, @Valid String id) {
|
||||||
|
CubeLevel cubeLevel = cubeLevelRes.findById(id)
|
||||||
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Cube level %s not found", id)));
|
||||||
|
map.put("cubeLevel", cubeLevel);
|
||||||
|
Dimension dim = dimensionRes.findByIdAndOrgi(cubeLevel.getDimid(), super.getOrgi(request));
|
||||||
|
if (dim != null) {
|
||||||
|
if (!StringUtils.isBlank(dim.getFktable())) {
|
||||||
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dim.getFktable()));
|
||||||
|
map.addAttribute("tableid", dim.getFktable());
|
||||||
|
} else {
|
||||||
|
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeLevel.getCubeid(), "0");
|
||||||
|
if (!cmList.isEmpty() && cmList.get(0) != null) {
|
||||||
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
||||||
|
map.addAttribute("tableid", cmList.get(0).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/edit"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
@Menu(type = "report" , subtype = "cubelevel" , admin= true)
|
@Menu(type = "report", subtype = "cubelevel", admin = true)
|
||||||
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid CubeLevel cubeLevel,@Valid String tableid) {
|
public ModelAndView quickreplyupdate(HttpServletRequest request, @Valid CubeLevel cubeLevel, @Valid String tableid) {
|
||||||
if(!StringUtils.isBlank(cubeLevel.getId())){
|
if (!StringUtils.isBlank(cubeLevel.getId())) {
|
||||||
CubeLevel temp = cubeLevelRes.findOne(cubeLevel.getId()) ;
|
cubeLevel.setOrgi(super.getOrgi(request));
|
||||||
cubeLevel.setOrgi(super.getOrgi(request));
|
cubeLevel.setCreater(super.getUser(request).getId());
|
||||||
cubeLevel.setCreater(super.getUser(request).getId());
|
cubeLevelRes.findById(cubeLevel.getId())
|
||||||
if(temp!=null){
|
.ifPresent(it -> cubeLevel.setCreatetime(it.getCreatetime()));
|
||||||
cubeLevel.setCreatetime(temp.getCreatetime());
|
if (!StringUtils.isBlank(tableid)) {
|
||||||
}
|
TableProperties tb = new TableProperties();
|
||||||
if(!StringUtils.isBlank(tableid)) {
|
tb.setId(tableid);
|
||||||
TableProperties tb = new TableProperties();
|
TableProperties t = tablePropertiesRes.findById(tableid)
|
||||||
tb.setId(tableid);
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Table properties %s not found", tableid)));
|
||||||
TableProperties t = tablePropertiesRes.findById(tableid);
|
cubeLevel.setTablename(t.getTablename());
|
||||||
cubeLevel.setTablename(t.getTablename());
|
cubeLevel.setCode(t.getFieldname());
|
||||||
cubeLevel.setCode(t.getFieldname());
|
cubeLevel.setColumname(t.getFieldname());
|
||||||
cubeLevel.setColumname(t.getFieldname());
|
cubeLevel.setTableproperty(tb);
|
||||||
cubeLevel.setTableproperty(tb);
|
}
|
||||||
}
|
cubeLevelRes.save(cubeLevel);
|
||||||
cubeLevelRes.save(cubeLevel) ;
|
}
|
||||||
}
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id=" + cubeLevel.getCubeid() + "&dimensionId=" + cubeLevel.getDimid()));
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+cubeLevel.getCubeid()+"&dimensionId="+cubeLevel.getDimid()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/fktableid")
|
@RequestMapping("/fktableid")
|
||||||
@Menu(type = "report" , subtype = "cubelevel" , admin= true)
|
@Menu(type = "report", subtype = "cubelevel", admin = true)
|
||||||
public ModelAndView fktableid(ModelMap map , HttpServletRequest request , @Valid String tableid) {
|
public ModelAndView fktableid(ModelMap map, @Valid String tableid) {
|
||||||
if(!StringUtils.isBlank(tableid)){
|
if (!StringUtils.isBlank(tableid)) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/fktableiddiv"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubelevel/fktableiddiv"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,11 +23,13 @@ import com.chatopera.cc.persistence.repository.CubeMeasureRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
|
import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
|
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -36,86 +38,85 @@ import java.util.List;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/apps/report/cubemeasure")
|
@RequestMapping("/apps/report/cubemeasure")
|
||||||
public class CubeMeasureController extends Handler{
|
@RequiredArgsConstructor
|
||||||
|
public class CubeMeasureController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private CubeMeasureRepository cubeMeasureRes;
|
private final CubeMeasureRepository cubeMeasureRes;
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private TablePropertiesRepository tablePropertiesRes;
|
private final TablePropertiesRepository tablePropertiesRes;
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private CubeMetadataRepository cubeMetadataRes;
|
private final CubeMetadataRepository cubeMetadataRes;
|
||||||
|
|
||||||
@RequestMapping("/add")
|
@RequestMapping("/add")
|
||||||
@Menu(type = "report" , subtype = "cubemeasure")
|
@Menu(type = "report", subtype = "cubemeasure")
|
||||||
public ModelAndView cubeMeasureadd(ModelMap map , HttpServletRequest request , @Valid String cubeid) {
|
public ModelAndView cubeMeasureadd(ModelMap map, @Valid String cubeid) {
|
||||||
map.addAttribute("cubeid", cubeid);
|
map.addAttribute("cubeid", cubeid);
|
||||||
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeid,"0");
|
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeid, "0");
|
||||||
if(!cmList.isEmpty() && cmList.get(0)!=null) {
|
if (!cmList.isEmpty() && cmList.get(0) != null) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
||||||
map.put("table", cmList.get(0).getTb());
|
map.put("table", cmList.get(0).getTb());
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/add"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
@Menu(type = "report" , subtype = "cubemeasure" )
|
@Menu(type = "report", subtype = "cubemeasure")
|
||||||
public ModelAndView cubeMeasuresave(ModelMap map , HttpServletRequest request , @Valid CubeMeasure cubeMeasure) {
|
public ModelAndView cubeMeasuresave(HttpServletRequest request, @Valid CubeMeasure cubeMeasure) {
|
||||||
if(!StringUtils.isBlank(cubeMeasure.getName())){
|
if (!StringUtils.isBlank(cubeMeasure.getName())) {
|
||||||
cubeMeasure.setOrgi(super.getOrgi(request));
|
cubeMeasure.setOrgi(super.getOrgi(request));
|
||||||
cubeMeasure.setCreater(super.getUser(request).getId());
|
cubeMeasure.setCreater(super.getUser(request).getId());
|
||||||
cubeMeasure.setCode(cubeMeasure.getColumname());
|
cubeMeasure.setCode(cubeMeasure.getColumname());
|
||||||
cubeMeasureRes.save(cubeMeasure) ;
|
cubeMeasureRes.save(cubeMeasure);
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id="+cubeMeasure.getCubeid()));
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id=" + cubeMeasure.getCubeid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
@Menu(type = "report" , subtype = "cubemeasure" )
|
@Menu(type = "report", subtype = "cubemeasure")
|
||||||
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
|
public ModelAndView quickreplydelete(@Valid String id) {
|
||||||
CubeMeasure cubeMeasure = cubeMeasureRes.findOne(id) ;
|
cubeMeasureRes.deleteById(id);
|
||||||
if(cubeMeasure!=null){
|
CubeMeasure cubeMeasure = cubeMeasureRes.findById(id)
|
||||||
cubeMeasureRes.delete(cubeMeasure);
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Cube measure %s not found", id)));
|
||||||
}
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id=" + cubeMeasure.getCubeid()));
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id="+cubeMeasure.getCubeid()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/edit")
|
@RequestMapping("/edit")
|
||||||
@Menu(type = "report" , subtype = "cubemeasure" , admin= true)
|
@Menu(type = "report", subtype = "cubemeasure", admin = true)
|
||||||
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
|
public ModelAndView quickreplyedit(ModelMap map, @Valid String id) {
|
||||||
CubeMeasure cubeMeasure = cubeMeasureRes.findOne(id) ;
|
CubeMeasure cubeMeasure = cubeMeasureRes.findById(id).orElse(null);
|
||||||
map.put("cubemeasure", cubeMeasure) ;
|
map.put("cubemeasure", cubeMeasure);
|
||||||
if(cubeMeasure!=null) {
|
if (cubeMeasure != null) {
|
||||||
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeMeasure.getCubeid(),"0");
|
List<CubeMetadata> cmList = cubeMetadataRes.findByCubeidAndMtype(cubeMeasure.getCubeid(), "0");
|
||||||
if(!cmList.isEmpty() && cmList.get(0)!=null) {
|
if (!cmList.isEmpty() && cmList.get(0) != null) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(cmList.get(0).getTb().getId()));
|
||||||
map.put("table", cmList.get(0).getTb());
|
map.put("table", cmList.get(0).getTb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/edit"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
@Menu(type = "report" , subtype = "cubemeasure" , admin= true)
|
@Menu(type = "report", subtype = "cubemeasure", admin = true)
|
||||||
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid CubeMeasure cubeMeasure) {
|
public ModelAndView quickreplyupdate(HttpServletRequest request, @Valid CubeMeasure cubeMeasure) {
|
||||||
if(!StringUtils.isBlank(cubeMeasure.getId())){
|
if (!StringUtils.isBlank(cubeMeasure.getId())) {
|
||||||
CubeMeasure temp = cubeMeasureRes.findOne(cubeMeasure.getId()) ;
|
cubeMeasure.setOrgi(super.getOrgi(request));
|
||||||
cubeMeasure.setOrgi(super.getOrgi(request));
|
cubeMeasure.setCreater(super.getUser(request).getId());
|
||||||
cubeMeasure.setCreater(super.getUser(request).getId());
|
cubeMeasureRes.findById(cubeMeasure.getId()).ifPresent(temp -> cubeMeasure.setCreatetime(temp.getCreatetime()));
|
||||||
if(temp!=null){
|
cubeMeasure.setCode(cubeMeasure.getColumname());
|
||||||
cubeMeasure.setCreatetime(temp.getCreatetime());
|
cubeMeasureRes.save(cubeMeasure);
|
||||||
}
|
}
|
||||||
cubeMeasure.setCode(cubeMeasure.getColumname());
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id=" + cubeMeasure.getCubeid()));
|
||||||
cubeMeasureRes.save(cubeMeasure) ;
|
|
||||||
}
|
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?dimensionId=cubemeasure&id="+cubeMeasure.getCubeid()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/fktableid")
|
@RequestMapping("/fktableid")
|
||||||
@Menu(type = "report" , subtype = "cubemeasure" , admin= true)
|
@Menu(type = "report", subtype = "cubemeasure", admin = true)
|
||||||
public ModelAndView fktableid(ModelMap map , HttpServletRequest request , @Valid String tableid) {
|
public ModelAndView fktableid(ModelMap map, @Valid String tableid) {
|
||||||
if(!StringUtils.isBlank(tableid)){
|
if (!StringUtils.isBlank(tableid)) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/fktableiddiv"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/cubemeasure/fktableiddiv"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,11 +25,13 @@ import com.chatopera.cc.persistence.repository.CubeMetadataRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.DimensionRepository;
|
import com.chatopera.cc.persistence.repository.DimensionRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
|
import com.chatopera.cc.persistence.repository.TablePropertiesRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -38,87 +40,87 @@ import java.util.List;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/apps/report/dimension")
|
@RequestMapping("/apps/report/dimension")
|
||||||
public class DimensionController extends Handler{
|
@RequiredArgsConstructor
|
||||||
|
public class DimensionController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private DimensionRepository dimensionRes;
|
private final DimensionRepository dimensionRes;
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private CubeLevelRepository cubeLevelRes;
|
private final CubeLevelRepository cubeLevelRes;
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private CubeMetadataRepository cubeMetadataRes;
|
private final CubeMetadataRepository cubeMetadataRes;
|
||||||
|
|
||||||
@Autowired
|
@org.springframework.lang.NonNull
|
||||||
private TablePropertiesRepository tablePropertiesRes;
|
private final TablePropertiesRepository tablePropertiesRes;
|
||||||
|
|
||||||
@RequestMapping("/add")
|
@RequestMapping("/add")
|
||||||
@Menu(type = "report" , subtype = "dimension")
|
@Menu(type = "report", subtype = "dimension")
|
||||||
public ModelAndView dimensionadd(ModelMap map , HttpServletRequest request , @Valid String cubeid) {
|
public ModelAndView dimensionadd(ModelMap map, @Valid String cubeid) {
|
||||||
map.addAttribute("cubeid", cubeid);
|
map.addAttribute("cubeid", cubeid);
|
||||||
map.addAttribute("fkfieldList",cubeMetadataRes.findByCubeidAndMtype(cubeid,"0"));
|
map.addAttribute("fkfieldList", cubeMetadataRes.findByCubeidAndMtype(cubeid, "0"));
|
||||||
map.addAttribute("fktableList",cubeMetadataRes.findByCubeidAndMtypeNot(cubeid,"0"));
|
map.addAttribute("fktableList", cubeMetadataRes.findByCubeidAndMtypeNot(cubeid, "0"));
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/add"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
@Menu(type = "report" , subtype = "dimension" )
|
@Menu(type = "report", subtype = "dimension")
|
||||||
public ModelAndView dimensionsave(ModelMap map , HttpServletRequest request , @Valid Dimension dimension) {
|
public ModelAndView dimensionsave(HttpServletRequest request, @Valid Dimension dimension) {
|
||||||
if(!StringUtils.isBlank(dimension.getName())){
|
if (!StringUtils.isBlank(dimension.getName())) {
|
||||||
dimension.setOrgi(super.getOrgi(request));
|
dimension.setOrgi(super.getOrgi(request));
|
||||||
dimension.setCreater(super.getUser(request).getId());
|
dimension.setCreater(super.getUser(request).getId());
|
||||||
dimensionRes.save(dimension) ;
|
dimensionRes.save(dimension);
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+dimension.getCubeid()+"&dimensionId="+dimension.getId()));
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id=" + dimension.getCubeid() + "&dimensionId=" + dimension.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
@Menu(type = "report" , subtype = "dimension" )
|
@Menu(type = "report", subtype = "dimension")
|
||||||
public ModelAndView quickreplydelete(ModelMap map , HttpServletRequest request , @Valid String id) {
|
public ModelAndView quickreplydelete(HttpServletRequest request, @Valid String id) {
|
||||||
Dimension dimension = dimensionRes.findOne(id) ;
|
Dimension dimension = dimensionRes.findById(id)
|
||||||
if(dimension!=null){
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Dimension %s not found", id)));
|
||||||
dimensionRes.delete(dimension);
|
dimensionRes.delete(dimension);
|
||||||
List<CubeLevel> cubeLevelList = cubeLevelRes.findByOrgiAndDimid(super.getOrgi(request), id);
|
List<CubeLevel> cubeLevelList = cubeLevelRes.findByOrgiAndDimid(super.getOrgi(request), id);
|
||||||
if(!cubeLevelList.isEmpty()) {
|
if (!cubeLevelList.isEmpty()) {
|
||||||
cubeLevelRes.delete(cubeLevelList);
|
cubeLevelRes.deleteAll(cubeLevelList);
|
||||||
}
|
}
|
||||||
}
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id=" + dimension.getCubeid()));
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+dimension.getCubeid()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/edit")
|
@RequestMapping("/edit")
|
||||||
@Menu(type = "report" , subtype = "dimension" , admin= true)
|
@Menu(type = "report", subtype = "dimension", admin = true)
|
||||||
public ModelAndView quickreplyedit(ModelMap map , HttpServletRequest request , @Valid String id) {
|
public ModelAndView quickreplyedit(ModelMap map, @Valid String id) {
|
||||||
Dimension dimension = dimensionRes.findOne(id) ;
|
Dimension dimension = dimensionRes.findById(id)
|
||||||
map.put("dimension", dimension) ;
|
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, String.format("Dimension %s not found", id)));
|
||||||
String cubeid = dimension.getCubeid();
|
map.put("dimension", dimension);
|
||||||
map.addAttribute("cubeid", cubeid);
|
String cubeid = dimension.getCubeid();
|
||||||
map.addAttribute("fkfieldList",cubeMetadataRes.findByCubeidAndMtype(cubeid,"0"));
|
map.addAttribute("cubeid", cubeid);
|
||||||
List<CubeMetadata> fktableList = cubeMetadataRes.findByCubeidAndMtypeNot(cubeid,"0");
|
map.addAttribute("fkfieldList", cubeMetadataRes.findByCubeidAndMtype(cubeid, "0"));
|
||||||
map.addAttribute("fktableList",fktableList);
|
List<CubeMetadata> fktableList = cubeMetadataRes.findByCubeidAndMtypeNot(cubeid, "0");
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dimension.getFktable()));
|
map.addAttribute("fktableList", fktableList);
|
||||||
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(dimension.getFktable()));
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/edit"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/edit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
@Menu(type = "report" , subtype = "dimension" , admin= true)
|
@Menu(type = "report", subtype = "dimension", admin = true)
|
||||||
public ModelAndView quickreplyupdate(ModelMap map , HttpServletRequest request , @Valid Dimension dimension) {
|
public ModelAndView quickreplyupdate(HttpServletRequest request, @Valid Dimension dimension) {
|
||||||
if(!StringUtils.isBlank(dimension.getId())){
|
if (!StringUtils.isBlank(dimension.getId())) {
|
||||||
Dimension temp = dimensionRes.findOne(dimension.getId()) ;
|
dimension.setOrgi(super.getOrgi(request));
|
||||||
dimension.setOrgi(super.getOrgi(request));
|
dimension.setCreater(super.getUser(request).getId());
|
||||||
dimension.setCreater(super.getUser(request).getId());
|
dimensionRes.findById(dimension.getId()).ifPresent(it -> dimension.setCreatetime(it.getCreatetime()));
|
||||||
if(temp!=null){
|
dimensionRes.save(dimension);
|
||||||
dimension.setCreatetime(temp.getCreatetime());
|
}
|
||||||
}
|
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id=" + dimension.getCubeid() + "&dimensionId=" + dimension.getId()));
|
||||||
dimensionRes.save(dimension) ;
|
|
||||||
}
|
|
||||||
return request(super.createRequestPageTempletResponse("redirect:/apps/report/cube/detail.html?id="+dimension.getCubeid()+"&dimensionId="+dimension.getId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/fktableid")
|
@RequestMapping("/fktableid")
|
||||||
@Menu(type = "report" , subtype = "dimension" , admin= true)
|
@Menu(type = "report", subtype = "dimension", admin = true)
|
||||||
public ModelAndView fktableid(ModelMap map , HttpServletRequest request , @Valid String tableid) {
|
public ModelAndView fktableid(ModelMap map, @Valid String tableid) {
|
||||||
if(!StringUtils.isBlank(tableid)){
|
if (!StringUtils.isBlank(tableid)) {
|
||||||
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
|
map.put("fktableidList", tablePropertiesRes.findByDbtableid(tableid));
|
||||||
}
|
}
|
||||||
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/fktableiddiv"));
|
return request(super.createRequestPageTempletResponse("/apps/business/report/cube/dimension/fktableiddiv"));
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -21,15 +21,15 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TablePropertiesRepository extends JpaRepository<TableProperties, String>{
|
public interface TablePropertiesRepository extends JpaRepository<TableProperties, String> {
|
||||||
|
|
||||||
TableProperties findById(String id);
|
// TableProperties findById(String id);
|
||||||
|
|
||||||
List<TableProperties> findByDbtableid(String dbtableid) ;
|
List<TableProperties> findByDbtableid(String dbtableid);
|
||||||
|
|
||||||
List<TableProperties> findByTablename(String tablename) ;
|
List<TableProperties> findByTablename(String tablename);
|
||||||
|
|
||||||
List<TableProperties> findBySecfield(boolean secfield) ;
|
List<TableProperties> findBySecfield(boolean secfield);
|
||||||
|
|
||||||
TableProperties findByTablenameAndFieldname(String tablename, String fieldname) ;
|
// TableProperties findByTablenameAndFieldname(String tablename, String fieldname) ;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user