重构返回结果集

This commit is contained in:
Binlin B Wang 2022-07-18 21:11:36 +08:00
parent 59493751d6
commit 5aed8f5f77
24 changed files with 238 additions and 437 deletions

View File

@ -149,6 +149,12 @@
<version>1.5.21</version> <version>1.5.21</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId> <artifactId>swagger-models</artifactId>

View File

@ -37,7 +37,6 @@ import javax.annotation.Resource;
@RestController @RestController
@RequestMapping("/tool/apiclass") @RequestMapping("/tool/apiclass")
public class ApiClassController extends BaseController { public class ApiClassController extends BaseController {
protected final Logger logger = LoggerFactory.getLogger(ApiClassController.class);
@Resource @Resource
private ApiClassService apiClassService; private ApiClassService apiClassService;

View File

@ -1,38 +1,27 @@
package com.ebts.generator.controller; package com.ebts.generator.controller;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.ebts.common.annotation.Log; import com.ebts.common.annotation.Log;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.controller.BaseController; import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI; import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.core.page.TableDataInfo; import com.ebts.common.core.page.TableDataInfo;
import com.ebts.common.core.text.Convert; import com.ebts.common.core.text.Convert;
import com.ebts.common.enums.BusinessType; import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.ServerResult;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ebts.generator.entity.GenTable; import com.ebts.generator.entity.GenTable;
import com.ebts.generator.entity.GenTableColumn; import com.ebts.generator.entity.GenTableColumn;
import com.ebts.generator.service.GenTableColumnService; import com.ebts.generator.service.GenTableColumnService;
import com.ebts.generator.service.GenTableService; import com.ebts.generator.service.GenTableService;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/** /**
* 代码生成 操作处理 * 代码生成 操作处理
@ -42,7 +31,6 @@ import com.ebts.generator.service.GenTableService;
@RestController @RestController
@RequestMapping("/tool/gen") @RequestMapping("/tool/gen")
public class GenController extends BaseController { public class GenController extends BaseController {
private Logger logger = LoggerFactory.getLogger(GenController.class);
@Autowired @Autowired
private GenTableService genTableService; private GenTableService genTableService;

View File

@ -10,8 +10,6 @@ import com.ebts.common.core.entity.Result;
import com.ebts.common.enums.BusinessType; import com.ebts.common.enums.BusinessType;
import com.ebts.generator.dto.InterTableDto; import com.ebts.generator.dto.InterTableDto;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -36,7 +34,6 @@ import javax.servlet.http.HttpServletResponse;
@RestController @RestController
@RequestMapping("/generator/intertable") @RequestMapping("/generator/intertable")
public class InterTableController extends BaseController { public class InterTableController extends BaseController {
protected final Logger logger = LoggerFactory.getLogger(InterTableController.class);
@Resource @Resource
private InterTableService interTableService; private InterTableService interTableService;
@ -103,12 +100,12 @@ public class InterTableController extends BaseController {
@GetMapping("/modulegen/{id}") @GetMapping("/modulegen/{id}")
public Result<byte[]> moduleGenerator(@PathVariable("id") Long id, HttpServletResponse response) throws IOException { public Result<byte[]> moduleGenerator(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
Result<byte[]> result = interTableService.generatorCodeModule(id); Result<byte[]> result = interTableService.generatorCodeModule(id);
if (result.isSuccess()) { if (result.isSuccess()) {
genCode(response, result.getData()); genCode(response, result.getData());
return Result.ok(); return Result.ok();
} else { } else {
return result; return result;
} }
} }

View File

@ -10,8 +10,6 @@ import com.ebts.common.core.entity.Result;
import com.ebts.common.enums.BusinessType; import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.StringUtils; import com.ebts.common.utils.StringUtils;
import com.ebts.common.utils.poi.ExcelUtil; import com.ebts.common.utils.poi.ExcelUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -35,7 +33,6 @@ import com.ebts.generator.service.ModuleService;
@RestController @RestController
@RequestMapping("/tool/module") @RequestMapping("/tool/module")
public class ModuleController extends BaseController { public class ModuleController extends BaseController {
protected final Logger logger = LoggerFactory.getLogger(ModuleController.class);
@Autowired @Autowired
private ModuleService moduleService; private ModuleService moduleService;

View File

@ -9,8 +9,6 @@ import com.github.pagehelper.PageHelper;
import com.ebts.generator.entity.UniCon; import com.ebts.generator.entity.UniCon;
import com.ebts.generator.entity.UniQuery; import com.ebts.generator.entity.UniQuery;
import com.ebts.generator.service.QueryService; import com.ebts.generator.service.QueryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;

View File

@ -1,30 +1,20 @@
package com.ebts.generator.controller; 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.enums.BusinessType;
import com.ebts.common.utils.poi.ExcelUtil;
import com.ebts.generator.entity.Regular;
import com.ebts.generator.service.RegularService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.ebts.common.annotation.Log;
import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.ServerResult;
import com.ebts.common.utils.poi.ExcelUtil;
import com.ebts.generator.entity.Regular;
import com.ebts.generator.service.RegularService;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 校验规则Controller * 校验规则Controller
* *
@ -34,7 +24,6 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/tool/regular") @RequestMapping("/tool/regular")
public class RegularController extends BaseController { public class RegularController extends BaseController {
protected final Logger logger = LoggerFactory.getLogger(RegularController.class);
@Autowired @Autowired
private RegularService regularService; private RegularService regularService;
@ -49,11 +38,11 @@ public class RegularController extends BaseController {
@GetMapping("/list") @GetMapping("/list")
public Serializable list(Regular regular) { public Serializable list(Regular regular) {
startPage(); startPage();
ServerResult<List<Regular>> ServerResult = regularService.selectRegularList(regular); Result<List<Regular>> result = regularService.selectRegularList(regular);
if (ServerResult.isStart()) { if (result.isSuccess()) {
return getDataTable(ServerResult.getData()); return getDataTable(result.getData());
} else { } else {
return ResultBackI.info(ServerResult.getMsg()); return result;
} }
} }
@ -66,11 +55,11 @@ public class RegularController extends BaseController {
@GetMapping("/option") @GetMapping("/option")
public Serializable option() { public Serializable option() {
startPage(); startPage();
ServerResult<List<Regular>> ServerResult = regularService.selectRegularOption(); Result<List<Regular>> result = regularService.selectRegularOption();
if (ServerResult.isStart()) { if (result.isSuccess()) {
return getDataTable(ServerResult.getData()); return getDataTable(result.getData());
} else { } else {
return ResultBackI.info(ServerResult.getMsg()); return result;
} }
} }
@ -83,13 +72,13 @@ public class RegularController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:regular:export')") @PreAuthorize("@ebts.hasPermi('tool:regular:export')")
@Log(title = "校验规则", businessType = BusinessType.EXPORT) @Log(title = "校验规则", businessType = BusinessType.EXPORT)
@GetMapping("/export") @GetMapping("/export")
public ResultBackI export(Regular regular) { public Result<Regular> export(Regular regular) {
ServerResult<List<Regular>> ServerResult = regularService.selectRegularList(regular); Result<List<Regular>> result = regularService.selectRegularList(regular);
ExcelUtil<Regular> util = new ExcelUtil<Regular>(Regular.class); ExcelUtil<Regular> util = new ExcelUtil<Regular>(Regular.class);
if (ServerResult.isStart()) { if (result.isSuccess()) {
return util.exportExcel(ServerResult.getData(), "regular"); return util.exportExcelRest(result.getData(), "regular");
} else { } else {
return ResultBackI.error(ServerResult.getMsg()); return Result.error(result.getMsg());
} }
} }
@ -101,13 +90,8 @@ public class RegularController extends BaseController {
*/ */
@PreAuthorize("@ebts.hasPermi('tool:regular:query')") @PreAuthorize("@ebts.hasPermi('tool:regular:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public ResultBackI getInfo(@PathVariable("id") Long id) { public Result<Regular> getInfo(@PathVariable("id") Long id) {
ServerResult<Regular> ServerResult = regularService.selectRegularById(id); return regularService.selectRegularById(id);
if (ServerResult.isStart()) {
return ResultBackI.success(ServerResult.getData());
} else {
return ResultBackI.info(ServerResult.getMsg());
}
} }
/** /**
@ -119,25 +103,11 @@ public class RegularController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:regular:add')") @PreAuthorize("@ebts.hasPermi('tool:regular:add')")
@Log(title = "校验规则", businessType = BusinessType.INSERT) @Log(title = "校验规则", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public ResultBackI add(@RequestBody Regular regular) { public Result<Integer> add(@RequestBody Regular regular) {
if (regular.getName() == null || regular.getName().equals("")) {
return ResultBackI.error("正则名称不能为空!");
}
if (regular.getRegular() == null || regular.getRegular().equals("")) {
return ResultBackI.error("正则内容不能为空!");
}
if (regular.getEnable() == null || regular.getEnable() < 0) {
return ResultBackI.error("是否启用不能为空!");
}
if (!verifyRegular(regular)) { if (!verifyRegular(regular)) {
return ResultBackI.error("正则表达式校验不通过!"); return Result.error("正则表达式校验不通过!");
}
ServerResult<Integer> ServerResult = regularService.insertRegular(regular);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
} }
return regularService.insertRegular(regular);
} }
/** /**
@ -149,25 +119,11 @@ public class RegularController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:regular:edit')") @PreAuthorize("@ebts.hasPermi('tool:regular:edit')")
@Log(title = "校验规则", businessType = BusinessType.UPDATE) @Log(title = "校验规则", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public ResultBackI edit(@RequestBody Regular regular) { public Result<Integer> edit(@RequestBody Regular regular) {
if (regular.getName() == null || regular.getName().equals("")) {
return ResultBackI.error("正则名称不能为空!");
}
if (regular.getRegular() == null || regular.getRegular().equals("")) {
return ResultBackI.error("正则内容不能为空!");
}
if (regular.getEnable() == null || regular.getEnable() < 0) {
return ResultBackI.error("是否启用不能为空!");
}
if (!verifyRegular(regular)) { if (!verifyRegular(regular)) {
return ResultBackI.error("正则表达式校验不通过!"); return Result.error("正则表达式校验不通过!");
}
ServerResult<Integer> ServerResult = regularService.updateRegular(regular);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
} }
return regularService.updateRegular(regular);
} }
/** /**
@ -179,16 +135,11 @@ public class RegularController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:regular:remove')") @PreAuthorize("@ebts.hasPermi('tool:regular:remove')")
@Log(title = "校验规则", businessType = BusinessType.DELETE) @Log(title = "校验规则", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public ResultBackI remove(@PathVariable Long[] ids) { public Result<Integer> remove(@PathVariable Long[] ids) {
if (ids.length == 0) { if (ids.length == 0) {
return ResultBackI.error("需要删除id数不能为空!"); return Result.error("需要删除id数不能为空!");
}
ServerResult<Integer> ServerResult = regularService.deleteRegularByIds(ids);
if (ServerResult.isStart()) {
return ResultBackI.success();
} else {
return ResultBackI.error(ServerResult.getMsg());
} }
return regularService.deleteRegularByIds(ids);
} }
public boolean verifyRegular(Regular regular) { public boolean verifyRegular(Regular regular) {

View File

@ -1,8 +1,6 @@
package com.ebts.generator.controller; package com.ebts.generator.controller;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.entity.RelColumn; import com.ebts.generator.entity.RelColumn;
import com.ebts.generator.entity.RelTable; import com.ebts.generator.entity.RelTable;
import com.ebts.generator.service.RelService; import com.ebts.generator.service.RelService;

View File

@ -1,27 +1,22 @@
package com.ebts.generator.controller; package com.ebts.generator.controller;
import com.ebts.common.annotation.Log;
import com.ebts.common.core.controller.EBTSController;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.text.Convert;
import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.poi.ExcelUtil;
import com.ebts.generator.entity.TopSearchTable;
import com.ebts.generator.service.TopSearchTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; 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;
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.*;
import com.ebts.common.annotation.Log;
import com.ebts.common.enums.BusinessType;
import com.ebts.generator.entity.TopSearchTable;
import com.ebts.generator.service.TopSearchTableService;
import com.ebts.common.utils.poi.ExcelUtil;
/** /**
* top万能查询主Controller * top万能查询主Controller
* *
@ -32,7 +27,6 @@ import com.ebts.common.utils.poi.ExcelUtil;
@RestController @RestController
@RequestMapping("/tool/table") @RequestMapping("/tool/table")
public class TopSearchTableController extends EBTSController { public class TopSearchTableController extends EBTSController {
protected final Logger logger = LoggerFactory.getLogger(TopSearchTableController.class);
@Autowired @Autowired
private TopSearchTableService topSearchTableService; private TopSearchTableService topSearchTableService;

View File

@ -1,34 +1,21 @@
package com.ebts.generator.controller; package com.ebts.generator.controller;
import java.io.Serializable;
import java.util.List;
import com.ebts.common.annotation.Log; import com.ebts.common.annotation.Log;
import com.ebts.common.core.controller.BaseController; import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.ResultBackI;
import com.ebts.common.enums.BusinessType; import com.ebts.common.enums.BusinessType;
import com.ebts.common.utils.ServerResult;
import com.ebts.common.utils.poi.ExcelUtil; import com.ebts.common.utils.poi.ExcelUtil;
import com.ebts.generator.entity.UniQuery; import com.ebts.generator.entity.UniQuery;
import com.ebts.generator.service.UniQueryService; import com.ebts.generator.service.UniQueryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/** /**
* 万能查询Controller * 万能查询Controller
@ -39,9 +26,8 @@ import javax.validation.constraints.NotNull;
@RestController @RestController
@RequestMapping("/tool/query") @RequestMapping("/tool/query")
public class UniQueryController extends BaseController { public class UniQueryController extends BaseController {
protected final Logger logger = LoggerFactory.getLogger(UniQueryController.class);
@Autowired @Resource
private UniQueryService uniQueryService; private UniQueryService uniQueryService;
/** /**

View File

@ -5,6 +5,8 @@ import com.ebts.common.core.entity.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
/** /**
* 校验规则对象 sys_regular * 校验规则对象 sys_regular
* *
@ -23,24 +25,28 @@ public class Regular extends BaseEntity {
* 正则名称 * 正则名称
*/ */
@Excel(name = "正则名称") @Excel(name = "正则名称")
@NotBlank(message = "正则名称不能为空!")
private String name; private String name;
/** /**
* 正则内容 * 正则内容
*/ */
@Excel(name = "正则内容") @Excel(name = "正则内容")
@NotBlank(message = "正则内容不能为空!")
private String regular; private String regular;
/** /**
* 验证内容 * 验证内容
*/ */
@Excel(name = "验证内容") @Excel(name = "验证内容")
@NotBlank(message = "验证内容不能为空!")
private String validation; private String validation;
/** /**
* 是否启用 1:启动 2:关闭 * 是否启用 1:启动 2:关闭
*/ */
@Excel(name = "是否启用 1:启动 2:关闭") @Excel(name = "是否启用 1:启动 2:关闭")
@NotBlank(message = "是否启用不能为空!")
private Integer enable; private Integer enable;

View File

@ -3,7 +3,6 @@ package com.ebts.generator.service;
import java.util.Map; import java.util.Map;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dto.InterTableDto; import com.ebts.generator.dto.InterTableDto;
import com.ebts.generator.entity.InterTable; import com.ebts.generator.entity.InterTable;
@ -20,7 +19,7 @@ public interface InterTableService {
* @param id 接口信息ID * @param id 接口信息ID
* @return 接口信息 * @return 接口信息
*/ */
ServerResult<InterTable> selectInterTableById(Long id); Result<InterTable> selectInterTableById(Long id);
/** /**
* 查询接口信息列表 * 查询接口信息列表
@ -36,7 +35,7 @@ public interface InterTableService {
* @param interTable 接口信息 * @param interTable 接口信息
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> insertInterTable(InterTable interTable); Result<Integer> insertInterTable(InterTable interTable);
/** /**
* 修改接口信息 * 修改接口信息
@ -52,7 +51,7 @@ public interface InterTableService {
* @param ids 需要删除的接口信息ID * @param ids 需要删除的接口信息ID
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> deleteInterTableByIds(Long[] ids); Result<Integer> deleteInterTableByIds(Long[] ids);
/** /**
* 删除接口信息信息 * 删除接口信息信息
@ -60,7 +59,7 @@ public interface InterTableService {
* @param id 接口信息ID * @param id 接口信息ID
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> deleteInterTableById(Long id); Result<Integer> deleteInterTableById(Long id);
/** /**
* 预览代码(工作流) * 预览代码(工作流)

View File

@ -1,6 +1,6 @@
package com.ebts.generator.service; package com.ebts.generator.service;
import com.ebts.common.utils.ServerResult; import com.ebts.common.core.entity.Result;
import com.ebts.generator.entity.Regular; import com.ebts.generator.entity.Regular;
import java.util.List; import java.util.List;
@ -18,7 +18,7 @@ public interface RegularService {
* @param id 校验规则ID * @param id 校验规则ID
* @return 校验规则 * @return 校验规则
*/ */
ServerResult<Regular> selectRegularById(Long id); Result<Regular> selectRegularById(Long id);
/** /**
* 查询校验规则列表 * 查询校验规则列表
@ -26,13 +26,13 @@ public interface RegularService {
* @param regular 校验规则 * @param regular 校验规则
* @return 校验规则集合 * @return 校验规则集合
*/ */
ServerResult<List<Regular>> selectRegularList(Regular regular); Result<List<Regular>> selectRegularList(Regular regular);
/** /**
* 查询校验规则下拉框列表 * 查询校验规则下拉框列表
* *
* @return 校验规则集合 * @return 校验规则集合
*/ */
ServerResult<List<Regular>> selectRegularOption(); Result<List<Regular>> selectRegularOption();
/** /**
* 新增校验规则 * 新增校验规则
@ -40,7 +40,7 @@ public interface RegularService {
* @param regular 校验规则 * @param regular 校验规则
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> insertRegular(Regular regular); Result<Integer> insertRegular(Regular regular);
/** /**
* 修改校验规则 * 修改校验规则
@ -48,7 +48,7 @@ public interface RegularService {
* @param regular 校验规则 * @param regular 校验规则
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> updateRegular(Regular regular); Result<Integer> updateRegular(Regular regular);
/** /**
* 批量删除校验规则 * 批量删除校验规则
@ -56,7 +56,7 @@ public interface RegularService {
* @param ids 需要删除的校验规则ID * @param ids 需要删除的校验规则ID
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> deleteRegularByIds(Long[] ids); Result<Integer> deleteRegularByIds(Long[] ids);
/** /**
* 删除校验规则信息 * 删除校验规则信息
@ -64,5 +64,5 @@ public interface RegularService {
* @param id 校验规则ID * @param id 校验规则ID
* @return 结果 * @return 结果
*/ */
ServerResult<Integer> deleteRegularById(Long id); Result<Integer> deleteRegularById(Long id);
} }

View File

@ -1,22 +1,18 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.ApiClassDao; import com.ebts.generator.dao.ApiClassDao;
import com.ebts.generator.entity.ApiClass; import com.ebts.generator.entity.ApiClass;
import com.ebts.generator.service.ApiClassService; import com.ebts.generator.service.ApiClassService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/** /**
* 接口类名Service业务层处理 * 接口类名Service业务层处理
* *
@ -25,9 +21,8 @@ import org.springframework.transaction.annotation.Transactional;
*/ */
@Service @Service
public class ApiClassServiceImpl implements ApiClassService { public class ApiClassServiceImpl implements ApiClassService {
private Logger logger = LoggerFactory.getLogger(ApiClassServiceImpl.class);
@Autowired @Resource
private ApiClassDao apiclassDao; private ApiClassDao apiclassDao;
/** /**

View File

@ -1,22 +1,18 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.core.text.Convert; import com.ebts.common.core.text.Convert;
import com.ebts.common.exception.EbtsException;
import com.ebts.generator.service.GenTableColumnService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ebts.generator.entity.GenTableColumn;
import com.ebts.generator.dao.GenTableColumnDao; import com.ebts.generator.dao.GenTableColumnDao;
import com.ebts.generator.entity.GenTableColumn;
import com.ebts.generator.service.GenTableColumnService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/** /**
* 业务字段 服务层实现 * 业务字段 服务层实现
* *
@ -24,9 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
*/ */
@Service @Service
public class GenTableColumnServiceImpl implements GenTableColumnService { public class GenTableColumnServiceImpl implements GenTableColumnService {
private Logger logger = LoggerFactory.getLogger(GenTableColumnServiceImpl.class);
@Autowired @Resource
private GenTableColumnDao genTableColumnDao; private GenTableColumnDao genTableColumnDao;
/** /**
@ -39,9 +34,9 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
@Transactional(propagation = Propagation.SUPPORTS) @Transactional(propagation = Propagation.SUPPORTS)
public Result<List<GenTableColumn>> selectGenTableColumnListByTableId(Long tableId) { public Result<List<GenTableColumn>> selectGenTableColumnListByTableId(Long tableId) {
List<GenTableColumn> columnList = genTableColumnDao.selectGenTableColumnListByTableId(tableId); List<GenTableColumn> columnList = genTableColumnDao.selectGenTableColumnListByTableId(tableId);
if (columnList.size() !=0){ if (columnList.size() != 0) {
return Result.ok(columnList); return Result.ok(columnList);
}else { } else {
return Result.info(); return Result.info();
} }
} }
@ -54,12 +49,7 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
*/ */
@Override @Override
public int insertGenTableColumn(GenTableColumn genTableColumn) { public int insertGenTableColumn(GenTableColumn genTableColumn) {
try { return genTableColumnDao.insertGenTableColumn(genTableColumn);
return genTableColumnDao.insertGenTableColumn(genTableColumn);
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
/** /**
@ -70,14 +60,9 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
*/ */
@Override @Override
public int updateGenTableColumn(GenTableColumn genTableColumn) { public int updateGenTableColumn(GenTableColumn genTableColumn) {
try { List<GenTableColumn> genTableColumns = new ArrayList<GenTableColumn>();
List<GenTableColumn> genTableColumns = new ArrayList<GenTableColumn>(); genTableColumns.add(genTableColumn);
genTableColumns.add(genTableColumn); return genTableColumnDao.updateGenTableColumn(genTableColumns);
return genTableColumnDao.updateGenTableColumn(genTableColumns);
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
/** /**
@ -88,11 +73,6 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
*/ */
@Override @Override
public int deleteGenTableColumnByIds(String ids) { public int deleteGenTableColumnByIds(String ids) {
try { return genTableColumnDao.deleteGenTableColumnByIds(Convert.toLongArray(ids));
return genTableColumnDao.deleteGenTableColumnByIds(Convert.toLongArray(ids));
}catch (RuntimeException e){
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
} }

View File

@ -1,27 +1,27 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import java.io.ByteArrayOutputStream; import com.alibaba.fastjson.JSON;
import java.io.File; import com.alibaba.fastjson.JSONObject;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.ebts.common.constant.Constants; import com.ebts.common.constant.Constants;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.core.text.CharsetKit; import com.ebts.common.core.text.CharsetKit;
import com.ebts.common.exception.CustomException; import com.ebts.common.exception.CustomException;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.StringUtils; import com.ebts.common.utils.StringUtils;
import com.ebts.generator.dao.GenTableColumnDao;
import com.ebts.generator.dao.GenTableDao;
import com.ebts.generator.dao.RelDao; import com.ebts.generator.dao.RelDao;
import com.ebts.generator.entity.*; import com.ebts.generator.entity.GenTable;
import com.ebts.generator.entity.GenTableColumn;
import com.ebts.generator.entity.RelColumn;
import com.ebts.generator.entity.RelTable;
import com.ebts.generator.service.GenTableService; import com.ebts.generator.service.GenTableService;
import com.ebts.generator.utils.*; import com.ebts.generator.utils.GenUtils;
import com.ebts.generator.utils.VelocityInitializer;
import com.ebts.generator.utils.VelocityUtils;
import com.ebts.generator.utils.constant.GenConstants; import com.ebts.generator.utils.constant.GenConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template; import org.apache.velocity.Template;
@ -32,12 +32,16 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ebts.generator.dao.GenTableColumnDao;
import com.ebts.generator.dao.GenTableDao;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/** /**
* 业务 服务层实现 * 业务 服务层实现
@ -45,8 +49,9 @@ import javax.annotation.Resource;
* @author binlin * @author binlin
*/ */
@Service @Service
@Slf4j
public class GenTableServiceImpl implements GenTableService { public class GenTableServiceImpl implements GenTableService {
private static final Logger logger = LoggerFactory.getLogger(GenTableServiceImpl.class);
@Resource @Resource
private GenTableDao genTableDao; private GenTableDao genTableDao;
@ -65,15 +70,11 @@ public class GenTableServiceImpl implements GenTableService {
* @return 业务信息 * @return 业务信息
*/ */
@Override @Override
@Transactional(propagation = Propagation.SUPPORTS)
public GenTable selectGenTableById(Long id) { public GenTable selectGenTableById(Long id) {
try {
GenTable genTable = genTableDao.selectGenTableById(id); GenTable genTable = genTableDao.selectGenTableById(id);
setTableFromOptions(genTable); setTableFromOptions(genTable);
return genTable; return genTable;
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
} }
/** /**
@ -83,13 +84,9 @@ public class GenTableServiceImpl implements GenTableService {
* @return 业务集合 * @return 业务集合
*/ */
@Override @Override
@Transactional(propagation = Propagation.SUPPORTS)
public List<GenTable> selectGenTableList(GenTable genTable) { public List<GenTable> selectGenTableList(GenTable genTable) {
try {
return genTableDao.selectGenTableList(genTable); return genTableDao.selectGenTableList(genTable);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
} }
@Override @Override
@ -339,7 +336,7 @@ public class GenTableServiceImpl implements GenTableService {
String path = getGenPath(table, template); String path = getGenPath(table, template);
FileUtils.writeStringToFile(new File(path), stringWriter.toString(), CharsetKit.UTF_8); FileUtils.writeStringToFile(new File(path), stringWriter.toString(), CharsetKit.UTF_8);
} catch (IOException e) { } catch (IOException e) {
logger.error("渲染模板失败,表名:" + table.getTableName()); log.error("渲染模板失败,表名:" + table.getTableName());
return false; return false;
} }
} }
@ -358,7 +355,7 @@ public class GenTableServiceImpl implements GenTableService {
String path = getGenPath(table, template); String path = getGenPath(table, template);
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
} catch (IOException e) { } catch (IOException e) {
logger.error("渲染模板失败,表名:" + table.getTableName()); log.error("渲染模板失败,表名:" + table.getTableName());
return false; return false;
} }
} }
@ -473,7 +470,7 @@ public class GenTableServiceImpl implements GenTableService {
zip.flush(); zip.flush();
zip.closeEntry(); zip.closeEntry();
} catch (IOException e) { } catch (IOException e) {
logger.error("渲染模板失败,表名:" + table.getTableName(), e); log.error("渲染模板失败,表名:" + table.getTableName(), e);
} }
} }
continue; continue;
@ -496,7 +493,7 @@ public class GenTableServiceImpl implements GenTableService {
zip.flush(); zip.flush();
zip.closeEntry(); zip.closeEntry();
} catch (IOException e) { } catch (IOException e) {
logger.error("渲染模板失败,表名:" + table.getTableName(), e); log.error("渲染模板失败,表名:" + table.getTableName(), e);
} }
} }
return zip; return zip;

View File

@ -13,9 +13,7 @@ import java.util.zip.ZipOutputStream;
import com.ebts.common.constant.Constants; import com.ebts.common.constant.Constants;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.ApiClassDao; import com.ebts.generator.dao.ApiClassDao;
import com.ebts.generator.dao.GenTableDao; import com.ebts.generator.dao.GenTableDao;
import com.ebts.generator.dao.ModuleDao; import com.ebts.generator.dao.ModuleDao;
@ -27,16 +25,14 @@ import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template; import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext; import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity; import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ebts.generator.dao.InterTableDao; import com.ebts.generator.dao.InterTableDao;
import com.ebts.generator.entity.InterTable; import com.ebts.generator.entity.InterTable;
import com.ebts.generator.service.InterTableService; import com.ebts.generator.service.InterTableService;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
/** /**
* 接口信息Service业务层处理 * 接口信息Service业务层处理
@ -46,15 +42,14 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
*/ */
@Service @Service
public class InterTableServiceImpl implements InterTableService { public class InterTableServiceImpl implements InterTableService {
private Logger logger = LoggerFactory.getLogger(InterTableServiceImpl.class);
@Autowired @Resource
private InterTableDao interTableDao; private InterTableDao interTableDao;
@Autowired @Resource
private ApiClassDao apiclassDao; private ApiClassDao apiclassDao;
@Autowired @Resource
private ModuleDao moduleDao; private ModuleDao moduleDao;
@Autowired @Resource
private GenTableDao genTableDao; private GenTableDao genTableDao;
/** /**
@ -64,17 +59,12 @@ public class InterTableServiceImpl implements InterTableService {
* @return 接口信息 * @return 接口信息
*/ */
@Override @Override
public ServerResult<InterTable> selectInterTableById(Long id) { public Result<InterTable> selectInterTableById(Long id) {
try { InterTable interTable = interTableDao.selectInterTableById(id);
InterTable interTable = interTableDao.selectInterTableById(id); if (interTable != null) {
if (interTable != null) { return Result.ok(interTable);
return new ServerResult<InterTable>(true, interTable); } else {
} else { return Result.info(ReturnConstants.RESULT_EMPTY);
return new ServerResult<InterTable>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e);
} }
} }
@ -106,19 +96,10 @@ public class InterTableServiceImpl implements InterTableService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> insertInterTable(InterTable interTable) { public Result<Integer> insertInterTable(InterTable interTable) {
try { interTable.setCreateBy(SecurityUtils.getUserId());
interTable.setCreateBy(SecurityUtils.getUserId()); interTableDao.insertInterTable(interTable);
Integer renewal = interTableDao.insertInterTable(interTable); return Result.ok();
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);
}
} }
/** /**
@ -156,18 +137,9 @@ public class InterTableServiceImpl implements InterTableService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> deleteInterTableByIds(Long[] ids) { public Result<Integer> deleteInterTableByIds(Long[] ids) {
try { interTableDao.deleteInterTableByIds(ids);
Integer renewal = interTableDao.deleteInterTableByIds(ids); return Result.ok();
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);
}
} }
/** /**
@ -178,18 +150,9 @@ public class InterTableServiceImpl implements InterTableService {
*/ */
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ServerResult<Integer> deleteInterTableById(Long id) { public Result<Integer> deleteInterTableById(Long id) {
try { interTableDao.deleteInterTableById(id);
Integer renewal = interTableDao.deleteInterTableById(id); return Result.ok();
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);
}
} }
@Override @Override
@ -273,7 +236,7 @@ public class InterTableServiceImpl implements InterTableService {
} }
@Override @Override
@Transactional(propagation = Propagation.SUPPORTS,rollbackFor = Exception.class) @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public Result<byte[]> generatorCodeModule(Long mid) { public Result<byte[]> generatorCodeModule(Long mid) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
@ -314,7 +277,7 @@ public class InterTableServiceImpl implements InterTableService {
zip.closeEntry(); zip.closeEntry();
return zip; return zip;
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getMessage()); e.printStackTrace();
return null; return null;
} }
} }

View File

@ -1,23 +1,17 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.ModuleDao; import com.ebts.generator.dao.ModuleDao;
import com.ebts.generator.entity.Module; import com.ebts.generator.entity.Module;
import com.ebts.generator.service.ModuleService; import com.ebts.generator.service.ModuleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* 模块管理Service业务层处理 * 模块管理Service业务层处理

View File

@ -10,6 +10,7 @@ import com.ebts.generator.dao.UniQueryDao;
import com.ebts.generator.entity.UniCon; import com.ebts.generator.entity.UniCon;
import com.ebts.generator.entity.UniQuery; import com.ebts.generator.entity.UniQuery;
import com.ebts.generator.service.QueryService; import com.ebts.generator.service.QueryService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -27,8 +28,8 @@ import java.util.Map;
* Version 1.0 * Version 1.0
*/ */
@Service @Service
@Slf4j
public class QueryServiceImpl implements QueryService { public class QueryServiceImpl implements QueryService {
private final Logger logger = LoggerFactory.getLogger(QueryServiceImpl.class);
@Resource @Resource
private QueryDao queryDao; private QueryDao queryDao;
@ -171,7 +172,7 @@ public class QueryServiceImpl implements QueryService {
sql += uniCon.getUcKey() + " between '" + startTime + "' AND '" + endTime + "'"; sql += uniCon.getUcKey() + " between '" + startTime + "' AND '" + endTime + "'";
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); log.error(e.getMessage());
sql = ""; sql = "";
} }
break; break;

View File

@ -3,6 +3,7 @@ package com.ebts.generator.service.impl;
import java.util.List; import java.util.List;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException; import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.DateUtils; import com.ebts.common.utils.DateUtils;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
@ -10,11 +11,11 @@ import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.RegularDao; import com.ebts.generator.dao.RegularDao;
import com.ebts.generator.entity.Regular; import com.ebts.generator.entity.Regular;
import com.ebts.generator.service.RegularService; import com.ebts.generator.service.RegularService;
import org.slf4j.Logger; import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/** /**
* 校验规则Service业务层处理 * 校验规则Service业务层处理
* *
@ -22,10 +23,10 @@ import org.springframework.stereotype.Service;
* @date 2021-01-18 * @date 2021-01-18
*/ */
@Service @Service
@Slf4j
public class RegularServiceImpl implements RegularService { public class RegularServiceImpl implements RegularService {
private Logger logger = LoggerFactory.getLogger(RegularServiceImpl.class);
@Autowired @Resource
private RegularDao regularDao; private RegularDao regularDao;
/** /**
@ -35,17 +36,12 @@ public class RegularServiceImpl implements RegularService {
* @return 校验规则 * @return 校验规则
*/ */
@Override @Override
public ServerResult<Regular> selectRegularById(Long id) { public Result<Regular> selectRegularById(Long id) {
try { Regular regular = regularDao.selectRegularById(id);
Regular regular = regularDao.selectRegularById(id); if (regular != null) {
if (regular != null) { return Result.ok(regular);
return new ServerResult<>(true, regular); } else {
} else { return Result.info(ReturnConstants.RESULT_EMPTY);
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
} }
} }
@ -56,36 +52,27 @@ public class RegularServiceImpl implements RegularService {
* @return 校验规则 * @return 校验规则
*/ */
@Override @Override
public ServerResult<List<Regular>> selectRegularList(Regular regular) { public Result<List<Regular>> selectRegularList(Regular regular) {
try { List<Regular> regulars = regularDao.selectRegularList(regular);
List<Regular> regulars = regularDao.selectRegularList(regular); if (regulars.size() > 0) {
if (regulars.size() > 0) { return Result.ok(regulars);
return new ServerResult<>(true, regulars); } else {
} else { return Result.info(ReturnConstants.RESULT_EMPTY);
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
} }
} }
/** /**
* 查询校验规则下拉框列表 * 查询校验规则下拉框列表
* *
* @return 校验规则 * @return 校验规则
*/ */
@Override @Override
public ServerResult<List<Regular>> selectRegularOption() { public Result<List<Regular>> selectRegularOption() {
try { List<Regular> regulars = regularDao.selectRegularOption();
List<Regular> regulars = regularDao.selectRegularOption(); if (regulars.size() > 0) {
if (regulars.size() > 0) { return Result.ok(regulars);
return new ServerResult<>(true, regulars); } else {
} else { return Result.info(ReturnConstants.RESULT_EMPTY);
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
} }
} }
@ -96,16 +83,11 @@ public class RegularServiceImpl implements RegularService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> insertRegular(Regular regular) { public Result<Integer> insertRegular(Regular regular) {
try { regular.setCreateTime(DateUtils.getNowDate());
regular.setCreateTime(DateUtils.getNowDate()); regular.setCreateBy(SecurityUtils.getUserId());
regular.setCreateBy(SecurityUtils.getUserId()); regularDao.insertRegular(regular);
int renewal = regularDao.insertRegular(regular); return Result.ok();
return new ServerResult<>(true, renewal);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
/** /**
@ -115,16 +97,11 @@ public class RegularServiceImpl implements RegularService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> updateRegular(Regular regular) { public Result<Integer> updateRegular(Regular regular) {
try { regular.setUpdateTime(DateUtils.getNowDate());
regular.setUpdateTime(DateUtils.getNowDate()); regular.setUpdateBy(SecurityUtils.getUserId());
regular.setUpdateBy(SecurityUtils.getUserId()); regularDao.updateRegular(regular);
int renewal = regularDao.updateRegular(regular); return Result.ok();
return new ServerResult<>(true, renewal);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
/** /**
@ -134,14 +111,9 @@ public class RegularServiceImpl implements RegularService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> deleteRegularByIds(Long[] ids) { public Result<Integer> deleteRegularByIds(Long[] ids) {
try { regularDao.deleteRegularByIds(ids);
Integer renewals = regularDao.deleteRegularByIds(ids); return Result.ok();
return new ServerResult<>(true, renewals);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
/** /**
@ -151,13 +123,8 @@ public class RegularServiceImpl implements RegularService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public ServerResult<Integer> deleteRegularById(Long id) { public Result<Integer> deleteRegularById(Long id) {
try { regularDao.deleteRegularById(id);
Integer renewal = regularDao.deleteRegularById(id); return Result.ok();
return new ServerResult<>(true, renewal);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
}
} }
} }

View File

@ -1,8 +1,6 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.RelDao; import com.ebts.generator.dao.RelDao;
import com.ebts.generator.entity.RelColumn; import com.ebts.generator.entity.RelColumn;
import com.ebts.generator.entity.RelTable; import com.ebts.generator.entity.RelTable;
@ -10,7 +8,6 @@ import com.ebts.generator.service.RelService;
import com.ebts.generator.utils.RelUtil; import com.ebts.generator.utils.RelUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;

View File

@ -14,12 +14,10 @@ import com.ebts.generator.dto.TopResult;
import com.ebts.generator.entity.*; import com.ebts.generator.entity.*;
import com.ebts.generator.service.TopQueryService; import com.ebts.generator.service.TopQueryService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -34,15 +32,14 @@ import java.util.concurrent.atomic.AtomicReference;
*/ */
@Service @Service
public class TopQueryServiceImpl implements TopQueryService { public class TopQueryServiceImpl implements TopQueryService {
private final Logger logger = LoggerFactory.getLogger(TopQueryServiceImpl.class);
@Autowired @Resource
private TopSearchTableDao topSearchTableDao; private TopSearchTableDao topSearchTableDao;
@Autowired @Resource
private RelationalMapDao relationalMapDao; private RelationalMapDao relationalMapDao;
@Autowired @Resource
private QueryDao queryDao; private QueryDao queryDao;
@Autowired @Resource
private UniQueryDao uniQueryDao; private UniQueryDao uniQueryDao;
@Override @Override

View File

@ -1,31 +1,28 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException; import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult; import com.ebts.common.utils.ServerResult;
import com.ebts.common.utils.StringUtils;
import com.ebts.generator.dao.RelationalMapDao; import com.ebts.generator.dao.RelationalMapDao;
import com.ebts.generator.dao.SearchTableRoleDao; import com.ebts.generator.dao.SearchTableRoleDao;
import com.ebts.generator.dao.TopSearchTableDao;
import com.ebts.generator.entity.RelationalMap; import com.ebts.generator.entity.RelationalMap;
import com.ebts.generator.entity.SearchTableRole; import com.ebts.generator.entity.SearchTableRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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.entity.TopSearchColumn;
import com.ebts.generator.dao.TopSearchTableDao;
import com.ebts.generator.entity.TopSearchTable; import com.ebts.generator.entity.TopSearchTable;
import com.ebts.generator.service.TopSearchTableService; import com.ebts.generator.service.TopSearchTableService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/** /**
* top万能查询主Service业务层处理 * top万能查询主Service业务层处理
@ -34,14 +31,14 @@ import com.ebts.generator.service.TopSearchTableService;
* @date 2021-07-20 * @date 2021-07-20
*/ */
@Service @Service
@Slf4j
public class TopSearchTableServiceImpl implements TopSearchTableService { public class TopSearchTableServiceImpl implements TopSearchTableService {
private Logger logger = LoggerFactory.getLogger(TopSearchTableServiceImpl.class);
@Autowired @Resource
private TopSearchTableDao topSearchTableDao; private TopSearchTableDao topSearchTableDao;
@Autowired @Resource
private SearchTableRoleDao searchTableRoleDao; private SearchTableRoleDao searchTableRoleDao;
@Autowired @Resource
private RelationalMapDao relationalMapDao; private RelationalMapDao relationalMapDao;
/** /**
@ -145,7 +142,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
// try { // try {
// //
// }catch (RuntimeException e){ // }catch (RuntimeException e){
// logger.error("无数据"); // log.error("无数据");
// } // }
// } // }
@ -155,7 +152,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
try { try {
return topSearchTableDao.selectDbTableList(params); return topSearchTableDao.selectDbTableList(params);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); log.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e); throw new EbtsException(ReturnConstants.OP_ERROR, e);
} }
} }
@ -215,7 +212,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL); return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); log.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR, e); throw new EbtsException(ReturnConstants.OP_ERROR, e);
} }
} }

View File

@ -1,21 +1,16 @@
package com.ebts.generator.service.impl; package com.ebts.generator.service.impl;
import java.util.List;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ebts.generator.dao.UniQueryDao; import com.ebts.generator.dao.UniQueryDao;
import com.ebts.generator.entity.UniQuery; import com.ebts.generator.entity.UniQuery;
import com.ebts.generator.service.UniQueryService; import com.ebts.generator.service.UniQueryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.util.List;
/** /**
* 万能查询Service业务层处理 * 万能查询Service业务层处理
@ -25,9 +20,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
*/ */
@Service @Service
public class UniQueryServiceImpl implements UniQueryService { public class UniQueryServiceImpl implements UniQueryService {
private Logger logger = LoggerFactory.getLogger(UniQueryServiceImpl.class);
@Autowired @Resource
private UniQueryDao uniQueryDao; private UniQueryDao uniQueryDao;
/** /**