重构返回结果集

This commit is contained in:
Binlin B Wang 2022-07-18 11:42:24 +08:00
parent 97a965a71e
commit 711b258f12
17 changed files with 380 additions and 471 deletions

View File

@ -3,13 +3,15 @@ package com.ebts.common.core.entity;
import com.ebts.common.constant.HttpStatus;
import java.io.Serializable;
/**
* @description: some desc
* @author: Binlin B Wang
* @email: binlin.b.wang@cn.pwc.com
* @date: 2022/5/31 10:00
*/
public class Result<T> {
public class Result<T> implements Serializable {
private int code;
private boolean success;
private String msg;

View File

@ -8,7 +8,7 @@ import java.util.List;
*
* @author binlin
*/
public class TableDataInfo implements Serializable {
public class TableDataInfo<T> implements Serializable {
/**
@ -19,7 +19,7 @@ public class TableDataInfo implements Serializable {
/**
* 列表数据
*/
private List<?> rows;
private List<T> rows;
/**
* 消息状态码
@ -43,7 +43,7 @@ public class TableDataInfo implements Serializable {
* @param list 列表数据
* @param total 总记录数
*/
public TableDataInfo(List<?> list, int total) {
public TableDataInfo(List<T> list, int total) {
this.rows = list;
this.total = total;
}
@ -60,7 +60,7 @@ public class TableDataInfo implements Serializable {
return rows;
}
public void setRows(List<?> rows) {
public void setRows(List<T> rows) {
this.rows = rows;
}

View File

@ -19,6 +19,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.BorderStyle;
@ -267,6 +268,18 @@ public class ExcelUtil<T> {
return exportExcel();
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
*/
public Result<T> exportExcelRest(List<T> list, String sheetName) {
this.init(list, sheetName, Type.EXPORT);
return exportExcelRest();
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
@ -329,6 +342,58 @@ public class ExcelUtil<T> {
}
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @return 结果
*/
public Result<T> exportExcelRest() {
OutputStream out = null;
try {
// 取出一共有多少个sheet.
double sheetNo = Math.ceil(list.size() / sheetSize);
for (int index = 0; index <= sheetNo; index++) {
createSheet(sheetNo, index);
// 产生一行
Row row = sheet.createRow(0);
int column = 0;
// 写入各个字段的列头名称
for (Object[] os : fields) {
Excel excel = (Excel) os[1];
this.createCell(excel, row, column++);
}
if (Type.EXPORT.equals(type)) {
fillExcelData(index, row);
addStatisticsRow();
}
}
String filename = encodingFilename(sheetName);
out = new FileOutputStream(getAbsoluteFile(filename));
wb.write(out);
return Result.ok(filename);
} catch (Exception e) {
log.error("导出Excel异常{}", e.getMessage());
throw new CustomException("导出Excel失败请联系网站管理员");
} finally {
if (wb != null) {
try {
wb.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (out != null) {
try {
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
/**
* 填充excel数据
*

View File

@ -1,6 +1,8 @@
package com.ebts.framework.web.exception;
import com.ebts.common.constant.HttpStatus;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.exception.BaseException;
import com.ebts.common.exception.CustomException;
@ -12,6 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -80,13 +83,6 @@ public class GlobalExceptionHandler {
log.error(e.getMessage(), e);
return ResultBackI.error(e.getMessage());
}
@ExceptionHandler(Exception.class)
public ResultBackI handleException(Exception e) {
log.error(e.getMessage(), e);
return ResultBackI.error(e.getMessage());
}
/**
* 自定义验证异常
*/
@ -114,4 +110,11 @@ public class GlobalExceptionHandler {
public ResultBackI demoModeException(DemoModeException e) {
return ResultBackI.error("演示模式,不允许操作");
}
@ExceptionHandler(Exception.class)
public Result<String> handleException(Exception e) {
log.error(e.getMessage(), e);
return Result.error(ReturnConstants.SYS_ERROR);
}
}

View File

@ -2,6 +2,7 @@ package com.ebts.generator.controller;
import com.ebts.common.annotation.Log;
import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.ServerResult;
@ -42,17 +43,12 @@ public class TopQueryController extends BaseController {
*/
@PreAuthorize("@ebts.hasPermi('top:query')")
@GetMapping(value = "/{id}")
public ResultBackI getInfo(@PathVariable("id") Long id) {
ServerResult<UniQuery> ServerResult = uniQueryService.selectUniQueryById(id);
if (ServerResult.isStart()) {
return ResultBackI.success(ServerResult.getData());
} else {
return ResultBackI.info(ServerResult.getMsg());
}
public Result<UniQuery> getInfo(@PathVariable("id") Long id) {
return uniQueryService.selectUniQueryById(id);
}
@GetMapping("/online/{id}")
public ResultBackI online(@PathVariable("id") Long id){
public ResultBackI online(@PathVariable("id") Long id) {
// ServerResult ServerResult = queryService.updateQueryInfo(uniQuery);
// if (ServerResult.isStart()) {
// return AjaxResult.success(ServerResult.getData());
@ -71,8 +67,8 @@ public class TopQueryController extends BaseController {
*/
@PreAuthorize("@ebts.hasPermi('top:table')")
@GetMapping("/table")
public ResultBackI table() {
return ResultBackI.success(topQueryService.selectTopSearchTables());
public Result<Map<String,Object>> table() {
return Result.ok(topQueryService.selectTopSearchTables());
}
/**
@ -81,35 +77,20 @@ public class TopQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('top:edit')")
@Log(title = "top万能查询", businessType = BusinessType.UPDATE)
@PutMapping
public ResultBackI edit(@RequestBody UniQuery uniQuery) {
if (uniQuery.getId()<0){
return ResultBackI.error("缺少关键字段");
}
if (StringUtils.isNull(uniQuery.getTopJson())){
return ResultBackI.error("缺少关键字段");
}
ServerResult<Integer> ServerResult = uniQueryService.updateUniQuery(uniQuery);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
}
public Result<Integer> edit(@RequestBody UniQuery uniQuery) {
return uniQueryService.updateUniQuery(uniQuery);
}
/**
* 简单修改top万能能查询
*/
@PreAuthorize("@ebts.hasPermi('top:preview')")
@Log(title = "top预览", businessType = BusinessType.OTHER)
@PostMapping("/preview")
public Serializable preview(@RequestBody Map<String,String> params){
if (StringUtils.isNull(params.get("jsonData"))){
public Serializable preview(@RequestBody Map<String, String> params) {
if (StringUtils.isNull(params.get("jsonData"))) {
return ResultBackI.error("缺少必要参数!");
}
ServerResult<TopResult> serverResult = topQueryService.preview(params.get("jsonData"),params.get("id"));
if (serverResult.isStart()){
return getDataTable(serverResult.getData().getDataMap(),serverResult.getData().getUniCons());
}else {
return ResultBackI.error(serverResult.getMsg());
}
return topQueryService.preview(params.get("jsonData"), params.get("id"));
}
}

View File

@ -6,6 +6,7 @@ import java.util.Map;
import com.ebts.common.core.controller.EBTSController;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.core.text.Convert;
import com.ebts.common.utils.ServerResult;
@ -42,18 +43,22 @@ public class TopSearchTableController extends EBTSController {
@PreAuthorize("@ebts.hasPermi('tool:table:list')")
@PostMapping("/list")
public Serializable list(@Validated @RequestBody TopSearchTable topSearchTable) {
// if (topSearchTable.getRoleIds()==null){
// return Result.error("角色列表不能为空!");
// }
startPage(topSearchTable.getPageInfo());
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableList(topSearchTable);
if (genServerResult.isStart()) {
return getDataTable(genServerResult.getData());
Result<List<TopSearchTable>> result = topSearchTableService.selectTopSearchTableList(topSearchTable);
if (result.isSuccess()) {
return getDataTable(result.getData());
} else {
return ResultBackI.info(genServerResult.getMsg());
return result;
}
}
@PreAuthorize("@ebts.hasPermi('tool:table:cloumns')")
@GetMapping("/columns/{id}")
public ResultBackI columns(@PathVariable("id") Long id){
return ResultBackI.success(topSearchTableService.selectTableColumns(id));
public Result columns(@PathVariable("id") Long id) {
return Result.ok(topSearchTableService.selectTableColumns(id));
}
@ -63,11 +68,11 @@ public class TopSearchTableController extends EBTSController {
@PreAuthorize("@ebts.hasPermi('tool:table:info')")
@PostMapping("/info")
public Serializable info() {
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableInfo();
if (genServerResult.isStart()) {
return getDataTable(genServerResult.getData());
Result<List<TopSearchTable>> result = topSearchTableService.selectTopSearchTableInfo();
if (result.isSuccess()) {
return getDataTable(result.getData());
} else {
return ResultBackI.info(genServerResult.getMsg());
return result;
}
}
@ -77,13 +82,13 @@ public class TopSearchTableController extends EBTSController {
@PreAuthorize("@ebts.hasPermi('tool:table:export')")
@Log(title = "top万能查询主", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public ResultBackI export(@Validated @RequestBody TopSearchTable topSearchTable) {
ServerResult<List<TopSearchTable>> genServerResult = topSearchTableService.selectTopSearchTableList(topSearchTable);
ExcelUtil<TopSearchTable> util = new ExcelUtil<TopSearchTable>(TopSearchTable. class);
if (genServerResult.isStart()) {
return util.exportExcel(genServerResult.getData(), "table");
public Result<TopSearchTable> export(@Validated @RequestBody TopSearchTable topSearchTable) {
Result<List<TopSearchTable>> result = topSearchTableService.selectTopSearchTableList(topSearchTable);
ExcelUtil<TopSearchTable> util = new ExcelUtil<TopSearchTable>(TopSearchTable.class);
if (result.isSuccess()) {
return util.exportExcelRest(result.getData(), "table");
} else {
return ResultBackI.error(genServerResult.getMsg());
return Result.error(result.getMsg());
}
}
@ -92,13 +97,8 @@ public class TopSearchTableController extends EBTSController {
*/
@PreAuthorize("@ebts.hasPermi('tool:table:query')")
@GetMapping(value = "/{id}")
public ResultBackI getInfo(@PathVariable("id") Long id) {
ServerResult<TopSearchTable> genServerResult = topSearchTableService.selectTopSearchTableById(id);
if (genServerResult.isStart()) {
return ResultBackI.success(genServerResult.getData());
} else {
return ResultBackI.info(genServerResult.getMsg());
}
public Result<TopSearchTable> getInfo(@PathVariable("id") Long id) {
return topSearchTableService.selectTopSearchTableById(id);
}
/**
@ -107,13 +107,8 @@ public class TopSearchTableController extends EBTSController {
@PreAuthorize("@ebts.hasPermi('tool:table:add')")
@Log(title = "top万能查询主", businessType = BusinessType.INSERT)
@PostMapping
public ResultBackI add(@Validated @RequestBody TopSearchTable topSearchTable) {
ServerResult<Integer> genServerResult = topSearchTableService.insertTopSearchTable(topSearchTable);
if (genServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(genServerResult.getMsg());
}
public Result<Integer> add(@Validated @RequestBody TopSearchTable topSearchTable) {
return topSearchTableService.insertTopSearchTable(topSearchTable);
}
/**
@ -122,16 +117,11 @@ public class TopSearchTableController extends EBTSController {
@PreAuthorize("@ebts.hasPermi('tool:table:edit')")
@Log(title = "top万能查询主", businessType = BusinessType.UPDATE)
@PutMapping
public ResultBackI edit(@Validated @RequestBody TopSearchTable topSearchTable) {
if (topSearchTable.getRoleIds().length==0){
return ResultBackI.error("角色不能为空!");
}
ServerResult<Integer> genServerResult = topSearchTableService.updateTopSearchTable(topSearchTable);
if (genServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(genServerResult.getMsg());
public Result<Integer> edit(@Validated @RequestBody TopSearchTable topSearchTable) {
if (topSearchTable.getRoleIds().length == 0){
return Result.error("角色不能为空!");
}
return topSearchTableService.updateTopSearchTable(topSearchTable);
}
/**
@ -139,30 +129,25 @@ public class TopSearchTableController extends EBTSController {
*/
@PreAuthorize("@ebts.hasPermi('tool:table:remove')")
@Log(title = "top万能查询主", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public ResultBackI remove(@PathVariable Long[] ids) {
if (ids.length<0){
return ResultBackI.error("id不能为空!");
}
ServerResult<Integer> genServerResult = topSearchTableService.deleteTopSearchTableByIds(ids);
if (genServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(genServerResult.getMsg());
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable Long[] ids) {
if (ids.length == 0) {
return Result.error("id不能为空!");
}
return topSearchTableService.deleteTopSearchTableByIds(ids);
}
/**
* 导入表结构保存
*/
@PreAuthorize("@ebts.hasPermi('tool:table:import')")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTopTable")
public ResultBackI importTableSave(String tables) {
public Result<String> importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables);
// 查询表信息
List<TopSearchTable> tableList = topSearchTableService.selectDbTableListByNames(tableNames);
topSearchTableService.importGenTable(tableList);
return ResultBackI.success();
topSearchTableService.importGenTable(tableNames);
return Result.ok();
}
@ -171,12 +156,11 @@ public class TopSearchTableController extends EBTSController {
*/
@PreAuthorize("@ebts.hasPermi('tool:table:db:list')")
@PostMapping("/db/list")
public Serializable dbList(@RequestBody Map<String,Object> params){
public Serializable dbList(@RequestBody Map<String, Object> params) {
startPage(params);
List<Map<String,Object>> list = topSearchTableService.selectDbTableList(params);
List<Map<String, Object>> list = topSearchTableService.selectDbTableList(params);
return getDataTable(list);
}
}

View File

@ -6,6 +6,7 @@ import java.util.List;
import com.ebts.common.annotation.Log;
import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.ServerResult;
@ -16,6 +17,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -25,6 +27,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 万能查询Controller
*
@ -46,11 +51,11 @@ public class UniQueryController extends BaseController {
@GetMapping("/list")
public Serializable list(UniQuery uniQuery) {
startPage();
ServerResult<List<UniQuery>> ServerResult = uniQueryService.selectUniQueryList(uniQuery);
if (ServerResult.isStart()) {
return getDataTable(ServerResult.getData());
Result<List<UniQuery>> result = uniQueryService.selectUniQueryList(uniQuery);
if (result.isSuccess()) {
return getDataTable(result.getData());
} else {
return ResultBackI.info(ServerResult.getMsg());
return result;
}
}
@ -60,13 +65,13 @@ public class UniQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:query:export')")
@Log(title = "万能查询", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public ResultBackI export(UniQuery uniQuery) {
ServerResult<List<UniQuery>> ServerResult = uniQueryService.selectUniQueryList(uniQuery);
public Result<UniQuery> export(UniQuery uniQuery) {
Result<List<UniQuery>> result = uniQueryService.selectUniQueryList(uniQuery);
ExcelUtil<UniQuery> util = new ExcelUtil<UniQuery>(UniQuery.class);
if (ServerResult.isStart()) {
return util.exportExcel(ServerResult.getData(), "query");
if (result.isSuccess()) {
return util.exportExcelRest(result.getData(), "query");
} else {
return ResultBackI.error(ServerResult.getMsg());
return Result.error(result.getMsg());
}
}
@ -75,13 +80,9 @@ public class UniQueryController extends BaseController {
*/
@PreAuthorize("@ebts.hasPermi('tool:query:query')")
@GetMapping(value = "/{id}")
public ResultBackI getInfo(@PathVariable("id") Long id) {
ServerResult<UniQuery> ServerResult = uniQueryService.selectUniQueryById(id);
if (ServerResult.isStart()) {
return ResultBackI.success(ServerResult.getData());
} else {
return ResultBackI.info(ServerResult.getMsg());
}
public Result<UniQuery> getInfo(@PathVariable("id") Long id) {
Result<UniQuery> result = uniQueryService.selectUniQueryById(id);
return result;
}
/**
@ -90,19 +91,8 @@ public class UniQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:query:add')")
@Log(title = "万能查询", businessType = BusinessType.INSERT)
@PostMapping
public ResultBackI add(@RequestBody UniQuery uniQuery) {
if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) {
return ResultBackI.error("名称不能为空!");
}
if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) {
return ResultBackI.error("描述不能为空!");
}
ServerResult<Integer> ServerResult = uniQueryService.insertUniQuery(uniQuery);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
}
public Result add(@RequestBody @Validated UniQuery uniQuery) {
return uniQueryService.insertUniQuery(uniQuery);
}
/**
@ -111,19 +101,8 @@ public class UniQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:query:edit')")
@Log(title = "万能查询", businessType = BusinessType.UPDATE)
@PutMapping
public ResultBackI edit(@RequestBody UniQuery uniQuery) {
if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) {
return ResultBackI.error("名称不能为空!");
}
if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) {
return ResultBackI.error("描述不能为空!");
}
ServerResult<Integer> ServerResult = uniQueryService.updateUniQuery(uniQuery);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
}
public Result<Integer> edit(@RequestBody @Validated UniQuery uniQuery) {
return uniQueryService.updateUniQuery(uniQuery);
}
/**
@ -132,15 +111,7 @@ public class UniQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:query:remove')")
@Log(title = "万能查询", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public ResultBackI remove(@PathVariable Long[] ids) {
if (ids.length < 0) {
return ResultBackI.error("id不能为空!");
}
ServerResult<Integer> ServerResult = uniQueryService.deleteUniQueryByIds(ids);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
}
public Result<Integer> remove(@PathVariable @NotNull @NotBlank(message = "id不能为空!") Long[] ids) {
return uniQueryService.deleteUniQueryByIds(ids);
}
}

View File

@ -58,7 +58,9 @@ public interface UniQueryDao {
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteUniQueryByIds(Long[] ids);
int deleteUniQueryByIds(Long[] ids);
int deleteUniQueryByUqIds(Long[] ids);
int deleteUniQueryByUqId(Long id);

View File

@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**

View File

@ -4,6 +4,7 @@ import com.ebts.common.core.entity.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;
@ -23,6 +24,7 @@ public class UniQuery extends BaseEntity {
/**
* 名称
*/
@NotBlank(message = "名称不能为空!")
private String uqName;
/**
@ -33,6 +35,7 @@ public class UniQuery extends BaseEntity {
/**
* 描述
*/
@NotBlank(message = "描述不能为空!")
private String uqDescribe;
private String topJson;

View File

@ -1,5 +1,6 @@
package com.ebts.generator.service;
import com.ebts.common.core.entity.Result;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dto.TopResult;
@ -15,7 +16,7 @@ public interface TopQueryService {
Map<String, Object> selectTopSearchTables();
ServerResult<TopResult> preview(String jsonData, String id);
Result<TopResult> preview(String jsonData, String id);
ServerResult<String> online(Long id);
}

View File

@ -3,6 +3,7 @@ package com.ebts.generator.service;
import java.util.List;
import java.util.Map;
import com.ebts.common.core.entity.Result;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.entity.TopSearchColumn;
import com.ebts.generator.entity.TopSearchTable;
@ -20,7 +21,7 @@ public interface TopSearchTableService {
* @param id top万能查询主ID
* @return top万能查询主
*/
ServerResult<TopSearchTable> selectTopSearchTableById(Long id);
Result<TopSearchTable> selectTopSearchTableById(Long id);
/**
* 查询top万能查询主列表
@ -28,12 +29,12 @@ public interface TopSearchTableService {
* @param topSearchTable top万能查询主
* @return top万能查询主集合
*/
ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable);
Result<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable);
/**
* @return
*/
ServerResult<List<TopSearchTable>> selectTopSearchTableInfo();
Result<List<TopSearchTable>> selectTopSearchTableInfo();
List<TopSearchColumn> selectTableColumns(Long id);
@ -43,7 +44,7 @@ public interface TopSearchTableService {
* @param topSearchTable top万能查询主
* @return 结果
*/
ServerResult<Integer> insertTopSearchTable(TopSearchTable topSearchTable);
Result<Integer> insertTopSearchTable(TopSearchTable topSearchTable);
/**
* 修改top万能查询主
@ -51,13 +52,11 @@ public interface TopSearchTableService {
* @param topSearchTable top万能查询主
* @return 结果
*/
ServerResult<Integer> updateTopSearchTable(TopSearchTable topSearchTable);
Result<Integer> updateTopSearchTable(TopSearchTable topSearchTable);
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
List<Map<String, Object>> selectDbTableList(Map<String, Object> params);
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
void importGenTable(List<TopSearchTable> tableList);
void importGenTable(String[] tableNames);
/**
* 批量删除top万能查询主
@ -65,7 +64,7 @@ public interface TopSearchTableService {
* @param ids 需要删除的top万能查询主ID
* @return 结果
*/
ServerResult<Integer> deleteTopSearchTableByIds(Long[] ids);
Result<Integer> deleteTopSearchTableByIds(Long[] ids);
/**
* 删除top万能查询主信息

View File

@ -2,7 +2,7 @@ package com.ebts.generator.service;
import java.util.List;
import com.ebts.common.utils.ServerResult;
import com.ebts.common.core.entity.Result;
import com.ebts.generator.entity.UniQuery;
/**
@ -18,7 +18,7 @@ public interface UniQueryService {
* @param id 万能查询ID
* @return 万能查询
*/
ServerResult<UniQuery> selectUniQueryById(Long id);
Result<UniQuery> selectUniQueryById(Long id);
/**
* 查询万能查询列表
@ -26,7 +26,7 @@ public interface UniQueryService {
* @param uniQuery 万能查询
* @return 万能查询集合
*/
ServerResult<List<UniQuery>> selectUniQueryList(UniQuery uniQuery);
Result<List<UniQuery>> selectUniQueryList(UniQuery uniQuery);
/**
* 新增万能查询
@ -34,7 +34,7 @@ public interface UniQueryService {
* @param uniQuery 万能查询
* @return 结果
*/
ServerResult<Integer> insertUniQuery(UniQuery uniQuery);
Result<Integer> insertUniQuery(UniQuery uniQuery);
/**
* 修改万能查询
@ -42,7 +42,7 @@ public interface UniQueryService {
* @param uniQuery 万能查询
* @return 结果
*/
ServerResult<Integer> updateUniQuery(UniQuery uniQuery);
Result<Integer> updateUniQuery(UniQuery uniQuery);
/**
* 批量删除万能查询
@ -50,7 +50,7 @@ public interface UniQueryService {
* @param ids 需要删除的万能查询ID
* @return 结果
*/
ServerResult<Integer> deleteUniQueryByIds(Long[] ids);
Result<Integer> deleteUniQueryByIds(Long[] ids);
/**
* 删除万能查询信息
@ -58,5 +58,5 @@ public interface UniQueryService {
* @param id 万能查询ID
* @return 结果
*/
ServerResult<Integer> deleteUniQueryById(Long id);
Result<Integer> deleteUniQueryById(Long id);
}

View File

@ -3,6 +3,7 @@ package com.ebts.generator.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ebts.common.core.entity.Result;
import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.QueryDao;
@ -49,106 +50,99 @@ public class TopQueryServiceImpl implements TopQueryService {
Map<String, Object> modeMap = new HashMap<>();
//采用原子式获取到forEach中的值,原子式能够允许其他线程进行尝试性的修改值
AtomicReference<String> roleIds = new AtomicReference<>("");
SecurityUtils.getLoginUser().getUser().getRoles().forEach(role->{
roleIds.updateAndGet(v -> v + role.getRoleId()+",");
SecurityUtils.getLoginUser().getUser().getRoles().forEach(role -> {
roleIds.updateAndGet(v -> v + role.getRoleId() + ",");
});
modeMap.put("tables", topSearchTableDao.selectTopSearchTables(roleIds.get().substring(0,roleIds.get().length()-1).split(",")));
modeMap.put("tables", topSearchTableDao.selectTopSearchTables(roleIds.get().substring(0, roleIds.get().length() - 1).split(",")));
modeMap.put("relationalMap", relationalMapDao.selectRelationalMapList(new RelationalMap()));
return modeMap;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResult<TopResult> preview(String jsonData, String id) {
try {
JSONObject graphData = JSON.parseObject(jsonData);
//将数据格式化为自定义的java类列表
List<TopEdge> topEdges = JSON.parseArray(graphData.getString("edges"), TopEdge.class);
List<TopNode> topNodes = JSON.parseArray(graphData.getString("nodes"), TopNode.class);
if (topNodes.size() == 0) {
return new ServerResult<>(false, "top图结构有误,请整理后在试");
}
//整理连线的关系
StringBuffer sql = new StringBuffer("");
StringBuilder selectSql = new StringBuilder("select ");
StringBuilder selectQuery = new StringBuilder(" where 1=1 ");
TopNode mainNode = null;
if (topNodes.size() > 1) {
for (int i = 0; i < topEdges.size(); i++) {
for (int j = 0; j < topEdges.size(); j++) {
if (i != j) {
TopEdge topEdgeJ = topEdges.get(j);
if (topEdges.get(i).getSource().equals(topEdgeJ.getTarget())) {
topEdges.get(i).setSourceEdge(topEdgeJ.getId());
}
public Result<TopResult> preview(String jsonData, String id) {
JSONObject graphData = JSON.parseObject(jsonData);
//将数据格式化为自定义的java类列表
List<TopEdge> topEdges = JSON.parseArray(graphData.getString("edges"), TopEdge.class);
List<TopNode> topNodes = JSON.parseArray(graphData.getString("nodes"), TopNode.class);
if (topNodes.size() == 0) {
return Result.error("top图结构有误,请整理后在试");
}
//整理连线的关系
StringBuffer sql = new StringBuffer("");
StringBuilder selectSql = new StringBuilder("select ");
StringBuilder selectQuery = new StringBuilder(" where 1=1 ");
TopNode mainNode = null;
if (topNodes.size() > 1) {
for (int i = 0; i < topEdges.size(); i++) {
for (int j = 0; j < topEdges.size(); j++) {
if (i != j) {
TopEdge topEdgeJ = topEdges.get(j);
if (topEdges.get(i).getSource().equals(topEdgeJ.getTarget())) {
topEdges.get(i).setSourceEdge(topEdgeJ.getId());
}
}
}
// 解析出top图中与主表的连线,可能为多条
List<TopEdge> targets = new ArrayList<>();
for (int i = 0; i < topEdges.size(); i++) {
if (topEdges.get(i).getSourceEdge() == null) {
targets.add(topEdges.get(i));
}
}
mainNode = getNode(topNodes, targets.get(0).getSource());
// 组合查询字段信息
ParseSelectSQL(mainNode, topNodes, selectSql, selectQuery);
// 组合表与表之间得到关联关系sql
String relSql = "";
for (int i = 0; i < targets.size(); i++) {
relSql += getRelSql(topNodes, topEdges, targets.get(i));
}
sql.append(selectSql).append(" from ").append(mainNode.getTable()).append(" ")
.append(mainNode.getRelTable()).append(relSql);
} else {
mainNode = topNodes.get(0);
selectSql.append(mainNode.getTableSQL());
selectQuery.append(mainNode.getQuerySql());
sql.append(selectSql).append(" from ").append(mainNode.getTable()).append(" ")
.append(mainNode.getRelTable());
}
UniQuery uniQuery = new UniQuery();
uniQuery.setId(Long.valueOf(id));
uniQuery.setUqSql(sql.toString());
uniQuery.setIsPreview(1);
List<UniCon> uniCons = uniQuery.getUniCons();
for (TopNode node : topNodes) {
JSONArray columns = node.getColumns();
for (int i = 0; i < columns.size(); i++) {
if (columns.getJSONObject(i).getInteger("isQuery") == 1) {
JSONObject column = columns.getJSONObject(i);
UniCon uniCon = new UniCon(uniQuery.getId(), column.getString("ucName"), node.getRelTable() + "." + column.getString("columnName"), column.getString("ucCon"), column.getString("ucType"), column.getInteger("type"));
uniCons.add(uniCon);
}
// 解析出top图中与主表的连线,可能为多条
List<TopEdge> targets = new ArrayList<>();
for (int i = 0; i < topEdges.size(); i++) {
if (topEdges.get(i).getSourceEdge() == null) {
targets.add(topEdges.get(i));
}
}
int query = uniQueryDao.updateUniQuery(uniQuery);
if (query > 0) {
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
queryDao.deleteUniCon(uniQuery.getId());
queryDao.insertUniCon(uniCons);
}
mainNode = getNode(topNodes, targets.get(0).getSource());
// 组合查询字段信息
ParseSelectSQL(mainNode, topNodes, selectSql, selectQuery);
// 组合表与表之间得到关联关系sql
String relSql = "";
for (int i = 0; i < targets.size(); i++) {
relSql += getRelSql(topNodes, topEdges, targets.get(i));
}
sql.append(selectQuery);
PageHelper.startPage(1, 10, "");
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
TopResult topResult = new TopResult(dataMap,uniCons);
return new ServerResult<>(true, topResult);
} catch (RuntimeException e) {
e.printStackTrace();
logger.error(e.getMessage());
return new ServerResult<>(false, e.getMessage());
sql.append(selectSql).append(" from ").append(mainNode.getTable()).append(" ")
.append(mainNode.getRelTable()).append(relSql);
} else {
mainNode = topNodes.get(0);
selectSql.append(mainNode.getTableSQL());
selectQuery.append(mainNode.getQuerySql());
sql.append(selectSql).append(" from ").append(mainNode.getTable()).append(" ")
.append(mainNode.getRelTable());
}
UniQuery uniQuery = new UniQuery();
uniQuery.setId(Long.valueOf(id));
uniQuery.setUqSql(sql.toString());
uniQuery.setIsPreview(1);
List<UniCon> uniCons = uniQuery.getUniCons();
for (TopNode node : topNodes) {
JSONArray columns = node.getColumns();
for (int i = 0; i < columns.size(); i++) {
if (columns.getJSONObject(i).getInteger("isQuery") == 1) {
JSONObject column = columns.getJSONObject(i);
UniCon uniCon = new UniCon(uniQuery.getId(), column.getString("ucName"), node.getRelTable() + "." + column.getString("columnName"), column.getString("ucCon"), column.getString("ucType"), column.getInteger("type"));
uniCons.add(uniCon);
}
}
}
int query = uniQueryDao.updateUniQuery(uniQuery);
if (query > 0) {
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
queryDao.deleteUniCon(uniQuery.getId());
queryDao.insertUniCon(uniCons);
}
}
sql.append(selectQuery);
PageHelper.startPage(1, 10, "");
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
TopResult topResult = new TopResult(dataMap, uniCons);
return Result.ok(topResult);
}
@Override
@ -163,7 +157,7 @@ public class TopQueryServiceImpl implements TopQueryService {
if (node.getId().equals(mainNode.getId())) {
continue;
}
if (node.getTableSQL().trim().equals("")){
if (node.getTableSQL().trim().equals("")) {
continue;
}
selectSql.append(", ").append(node.getTableSQL());
@ -204,7 +198,7 @@ public class TopQueryServiceImpl implements TopQueryService {
sql.append(" ").append(edge.getAppConfig().getString("associated")).append(" join ")
.append(target.getTable()).append(" ").append(target.getRelTable()).append(" on ")
.append(target.getRelTable()).append(".").append(edge.getAppConfig()
.getString("relComment")).append(" = ").append(source.getRelTable())
.getString("relComment")).append(" = ").append(source.getRelTable())
.append(".").append(edge.getAppConfig().getString("tableComment"));
// 获取到target 连接表的连线
targetEdge = getEdgeListById(edges, edge.getTarget());

View File

@ -3,6 +3,7 @@ package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
@ -19,6 +20,7 @@ import java.util.ArrayList;
import java.util.Map;
import com.ebts.common.utils.StringUtils;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.ebts.generator.entity.TopSearchColumn;
import com.ebts.generator.dao.TopSearchTableDao;
@ -49,23 +51,19 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
* @return top万能查询主
*/
@Override
public ServerResult<TopSearchTable> selectTopSearchTableById(Long id) {
try {
TopSearchTable topSearchTable = topSearchTableDao.selectTopSearchTableById(id);
List<SearchTableRole> roleList = searchTableRoleDao.selectSearchTableRoleList(new SearchTableRole(id, null));
Long[] roles = new Long[roleList.size()];
for (int i = 0; i < roleList.size(); i++) {
roles[i] = roleList.get(i).getRoleId();
}
topSearchTable.setRoleIds(roles);
if (topSearchTable != null) {
return new ServerResult<>(true, topSearchTable);
} else {
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
@Transactional(propagation = Propagation.SUPPORTS)
public Result<TopSearchTable> selectTopSearchTableById(Long id) {
TopSearchTable topSearchTable = topSearchTableDao.selectTopSearchTableById(id);
List<SearchTableRole> roleList = searchTableRoleDao.selectSearchTableRoleList(new SearchTableRole(id, null));
Long[] roles = new Long[roleList.size()];
for (int i = 0; i < roleList.size(); i++) {
roles[i] = roleList.get(i).getRoleId();
}
topSearchTable.setRoleIds(roles);
if (topSearchTable != null) {
return Result.ok(topSearchTable);
} else {
return Result.info(ReturnConstants.RESULT_EMPTY);
}
}
@ -76,29 +74,21 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
* @return top万能查询主
*/
@Override
public ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable) {
try {
List<TopSearchTable> topSearchTableList = topSearchTableDao.selectTopSearchTableList(topSearchTable);
if (topSearchTableList.size() > 0) {
return new ServerResult<>(true, topSearchTableList);
} else {
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
@Transactional(propagation = Propagation.SUPPORTS)
public Result<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable) {
List<TopSearchTable> topSearchTableList = topSearchTableDao.selectTopSearchTableList(topSearchTable);
if (topSearchTableList.size() > 0) {
return Result.ok(topSearchTableList);
} else {
return Result.info(ReturnConstants.RESULT_EMPTY);
}
}
@Override
public ServerResult<List<TopSearchTable>> selectTopSearchTableInfo() {
try {
List<TopSearchTable> tableList = topSearchTableDao.selectTopSearchTableInfo();
return new ServerResult<>(true, tableList);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
@Transactional(propagation = Propagation.SUPPORTS)
public Result<List<TopSearchTable>> selectTopSearchTableInfo() {
List<TopSearchTable> tableList = topSearchTableDao.selectTopSearchTableInfo();
return Result.ok(tableList);
}
public List<TopSearchColumn> selectTableColumns(Long id) {
@ -111,24 +101,15 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
* @param topSearchTable top万能查询主
* @return 结果
*/
@Transactional
@Override
public ServerResult<Integer> insertTopSearchTable(TopSearchTable topSearchTable) {
try {
topSearchTable.setCreateBy(SecurityUtils.getUserId());
int renewal = topSearchTableDao.insertTopSearchTable(topSearchTable);
if (insertTopSearchColumn(topSearchTable)) {
return new ServerResult<>(false, ReturnConstants.DB_EX);
}
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Result<Integer> insertTopSearchTable(TopSearchTable topSearchTable) {
topSearchTable.setCreateBy(SecurityUtils.getUserId());
topSearchTableDao.insertTopSearchTable(topSearchTable);
if (insertTopSearchColumn(topSearchTable)) {
return Result.error(ReturnConstants.SYS_FAILL);
}
return Result.ok();
}
/**
@ -137,40 +118,28 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
* @param topSearchTable top万能查询主
* @return 结果
*/
@Transactional
@Override
public ServerResult<Integer> updateTopSearchTable(TopSearchTable topSearchTable) {
try {
topSearchTable.setUpdateBy(SecurityUtils.getUserId());
topSearchTableDao.deleteTopSearchColumnBySearchTableId(topSearchTable.getId());
if (insertTopSearchColumn(topSearchTable)) {
return new ServerResult<>(false, ReturnConstants.DB_EX);
}
List<SearchTableRole> searchTableRoles = new ArrayList<>();
for (Long roleId : topSearchTable.getRoleIds()) {
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(), roleId));
}
relationalMapDao.deleteRelationalMapById(topSearchTable.getId());
List<RelationalMap> relationalMapList = topSearchTable.getRelationalMapList();
for (RelationalMap relationalMap : relationalMapList) {
relationalMap.setMainId(topSearchTable.getId());
}
insertRelationalMap(relationalMapList);
searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId());
boolean renewalRole = inserTopTableRole(searchTableRoles);
Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable);
if (renewal > 0 && renewalRole) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
e.printStackTrace();
throw new EbtsException(ReturnConstants.OP_ERROR, e);
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Result<Integer> updateTopSearchTable(TopSearchTable topSearchTable) {
topSearchTable.setUpdateBy(SecurityUtils.getUserId());
topSearchTableDao.deleteTopSearchColumnBySearchTableId(topSearchTable.getId());
insertTopSearchColumn(topSearchTable);
List<SearchTableRole> searchTableRoles = new ArrayList<>();
for (Long roleId : topSearchTable.getRoleIds()) {
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(), roleId));
}
relationalMapDao.deleteRelationalMapById(topSearchTable.getId());
List<RelationalMap> relationalMapList = topSearchTable.getRelationalMapList();
for (RelationalMap relationalMap : relationalMapList) {
relationalMap.setMainId(topSearchTable.getId());
}
insertRelationalMap(relationalMapList);
searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId());
inserTopTableRole(searchTableRoles);
topSearchTableDao.updateTopSearchTable(topSearchTable);
return Result.ok();
}
// void deleteSearchTableRoleById(Long id){
// try {
@ -180,15 +149,6 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
// }
// }
@Override
public List<TopSearchTable> selectDbTableListByNames(String[] tableNames) {
try {
return topSearchTableDao.selectDbTableListByNames(tableNames);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
@Override
public List<Map<String, Object>> selectDbTableList(Map<String, Object> params) {
@ -201,29 +161,24 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importGenTable(List<TopSearchTable> tableList) {
try {
Long createBy = SecurityUtils.getUserId();
for (TopSearchTable table : tableList) {
String tableName = table.getTableName();
table.setCreateBy(createBy);
int row = topSearchTableDao.insertTopSearchTable(table);
if (row > 0) {
List<TopSearchColumn> searchColumns = topSearchTableDao.selectDbTableColumnsByName(tableName);
for (TopSearchColumn searchColumn : searchColumns) {
searchColumn.setSearchTableId(table.getId());
}
if (searchColumns.size() > 0) {
topSearchTableDao.batchTopSearchColumn(searchColumns);
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void importGenTable(String[] tableNames) {
List<TopSearchTable> tableList = topSearchTableDao.selectDbTableListByNames(tableNames);
Long createBy = SecurityUtils.getUserId();
for (TopSearchTable table : tableList) {
String tableName = table.getTableName();
table.setCreateBy(createBy);
int row = topSearchTableDao.insertTopSearchTable(table);
if (row > 0) {
List<TopSearchColumn> searchColumns = topSearchTableDao.selectDbTableColumnsByName(tableName);
for (TopSearchColumn searchColumn : searchColumns) {
searchColumn.setSearchTableId(table.getId());
}
if (searchColumns.size() > 0) {
topSearchTableDao.batchTopSearchColumn(searchColumns);
}
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException("导入失败:" + e.getMessage(), e);
}
}
/**
@ -234,21 +189,12 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
*/
@Transactional
@Override
public ServerResult<Integer> deleteTopSearchTableByIds(Long[] ids) {
try {
//批量删除子表数据
topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids);
searchTableRoleDao.deleteSearchTableRoleByIds(ids);
Integer renewal = topSearchTableDao.deleteTopSearchTableByIds(ids);
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
public Result<Integer> deleteTopSearchTableByIds(Long[] ids) {
//批量删除子表数据
topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids);
searchTableRoleDao.deleteSearchTableRoleByIds(ids);
topSearchTableDao.deleteTopSearchTableByIds(ids);
return Result.ok();
}
/**
@ -274,24 +220,20 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
}
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public boolean inserTopTableRole(List<SearchTableRole> roleList) {
if (StringUtils.isNotNull(roleList)) {
Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList);
if (renewal > 0) {
return true;
}
searchTableRoleDao.batchSearchTableRole(roleList);
}
return false;
return true;
}
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public boolean insertRelationalMap(List<RelationalMap> relationalMaps) {
if (StringUtils.isNotNull(relationalMaps) && relationalMaps.size() > 0) {
Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps);
if (renewal > 0) {
return true;
}
relationalMapDao.batchRelationalMap(relationalMaps);
}
return false;
return true;
}
/**
@ -299,6 +241,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
*
* @param topSearchTable top万能查询主对象
*/
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public boolean insertTopSearchColumn(TopSearchTable topSearchTable) {
List<TopSearchColumn> topSearchColumnList = topSearchTable.getTopSearchColumnList();
Long id = topSearchTable.getId();

View File

@ -3,6 +3,7 @@ package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
@ -36,17 +37,13 @@ public class UniQueryServiceImpl implements UniQueryService {
* @return 万能查询
*/
@Override
public ServerResult<UniQuery> selectUniQueryById(Long id) {
try {
UniQuery uniQuery = uniQueryDao.selectUniQueryById(id);
if (uniQuery != null) {
return new ServerResult<UniQuery>(true, uniQuery);
} else {
return new ServerResult<UniQuery>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
public Result<UniQuery> selectUniQueryById(Long id) {
UniQuery uniQuery = uniQueryDao.selectUniQueryById(id);
System.out.println(1/0);
if (uniQuery != null) {
return Result.ok(uniQuery);
} else {
return Result.info(ReturnConstants.RESULT_EMPTY);
}
}
@ -57,17 +54,12 @@ public class UniQueryServiceImpl implements UniQueryService {
* @return 万能查询
*/
@Override
public ServerResult<List<UniQuery>> selectUniQueryList(UniQuery uniQuery) {
try {
List<UniQuery> uniQueryList = uniQueryDao.selectUniQueryList(uniQuery);
if (uniQueryList.size() > 0) {
return new ServerResult<List<UniQuery>>(true, uniQueryList);
} else {
return new ServerResult<List<UniQuery>>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
public Result<List<UniQuery>> selectUniQueryList(UniQuery uniQuery) {
List<UniQuery> uniQueryList = uniQueryDao.selectUniQueryList(uniQuery);
if (uniQueryList.size() > 0) {
return Result.ok(uniQueryList);
} else {
return Result.info(ReturnConstants.RESULT_EMPTY);
}
}
@ -78,19 +70,10 @@ public class UniQueryServiceImpl implements UniQueryService {
* @return 结果
*/
@Override
public ServerResult<Integer> insertUniQuery(UniQuery uniQuery) {
try {
uniQuery.setCreateBy(SecurityUtils.getUserId());
Integer renewal = uniQueryDao.insertUniQuery(uniQuery);
if (renewal > 0) {
return new ServerResult<Integer>(true, renewal);
} else {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
public Result<Integer> insertUniQuery(UniQuery uniQuery) {
uniQuery.setCreateBy(SecurityUtils.getUserId());
uniQueryDao.insertUniQuery(uniQuery);
return Result.ok();
}
/**
@ -100,19 +83,10 @@ public class UniQueryServiceImpl implements UniQueryService {
* @return 结果
*/
@Override
public ServerResult<Integer> updateUniQuery(UniQuery uniQuery) {
try {
uniQuery.setUpdateBy(SecurityUtils.getUserId());
Integer renewal = uniQueryDao.updateUniQuery(uniQuery);
if (renewal > 0) {
return new ServerResult<Integer>(true, renewal);
} else {
return new ServerResult<Integer>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
public Result<Integer> updateUniQuery(UniQuery uniQuery) {
uniQuery.setUpdateBy(SecurityUtils.getUserId());
uniQueryDao.updateUniQuery(uniQuery);
return Result.ok();
}
/**
@ -123,22 +97,10 @@ public class UniQueryServiceImpl implements UniQueryService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResult<Integer> deleteUniQueryByIds(Long[] ids) {
try {
Integer renewal = uniQueryDao.deleteUniQueryByIds(ids);
for (Long id : ids) {
uniQueryDao.deleteUniQueryByUqId(id);
}
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
public Result<Integer> deleteUniQueryByIds(Long[] ids) {
uniQueryDao.deleteUniQueryByIds(ids);
uniQueryDao.deleteUniQueryByUqIds(ids);
return Result.ok();
}
/**
@ -149,18 +111,9 @@ public class UniQueryServiceImpl implements UniQueryService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResult<Integer> deleteUniQueryById(Long id) {
try {
Integer renewal = uniQueryDao.deleteUniQueryById(id);
uniQueryDao.deleteUniQueryByUqId(id);
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
public Result<Integer> deleteUniQueryById(Long id) {
uniQueryDao.deleteUniQueryById(id);
uniQueryDao.deleteUniQueryByUqId(id);
return Result.ok();
}
}

View File

@ -79,7 +79,14 @@
</delete>
<delete id="deleteUniQueryByUqId" parameterType="Long">
delete from gen_uni_con where uq_id = #{id}
delete from gen_uni_con where uq_id in #{id}
</delete>
<delete id="deleteUniQueryByUqIds" parameterType="Long">
delete from gen_uni_con where uq_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteUniQueryByIds" parameterType="String">