diff --git a/README.md b/README.md index d658e25..7356943 100644 --- a/README.md +++ b/README.md @@ -57,5 +57,6 @@ * 每张表的分页查询参数,严格按照一张表对应一个请求参数对象进行开发,如系统用户分页查询参数:com.songpeng.sparchetype.system.request.SysUserPageReq # 总结 Q群87652870 欢迎想一起开发的小伙伴。。本人前端太弱,都是自己乱摸索。还请有一个前端选手能一起弄 - +## QQ Group +[![QQ](https://img.shields.io/badge/QQ-87652870-green.svg?logo=tencent%20qq&logoColor=red)](https://jq.qq.com/?_wv=1027&k=55NGCxl) [![MES-智能制造/MES-Sprongboot](https://gitee.com/wangziyangyang/MES-Sprongboot/widgets/widget_card.svg?colors=393222,ebdfc1,fffae5,d8ca9f,393222,a28b40)](https://gitee.com/wangziyangyang/MES-Sprongboot) \ No newline at end of file diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/controller/TableNameDataController.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/controller/TableNameDataController.java index 2e59048..f5b8164 100644 --- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/controller/TableNameDataController.java +++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/controller/TableNameDataController.java @@ -76,12 +76,12 @@ public class TableNameDataController extends BaseController { /** - * 主数据通用修改和新增 + * 通用主数据通用修改和新增 * * @param request 请求对象 * @return 执行结果 */ - @ApiOperation("主数据表头修改") + @ApiOperation("主数据通用修改和新增") @PostMapping("/add-or-update") @ResponseBody public Result addOrUpdate(HttpServletRequest request) throws Exception { @@ -94,4 +94,20 @@ public class TableNameDataController extends BaseController { } return Result.success(); } + + + /** + * 通用删除接口 + * + * @param commonDto 请求参数 + * @return Result 执行结果 + */ + @ApiOperation("通用删除接口") + @ApiImplicitParams({@ApiImplicitParam(name = "commonDto", value = "通用数据传输", defaultValue = "表信息")}) + @PostMapping("delete") + @ResponseBody + public Result deleteCommon(CommonDto commonDto) throws Exception { + tableNameDataService.commonDelete(commonDto); + return Result.success(); + } } \ No newline at end of file diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/mapper/QueryTableNameDataMapper.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/mapper/QueryTableNameDataMapper.java index 7dfa55e..480f865 100644 --- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/mapper/QueryTableNameDataMapper.java +++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/mapper/QueryTableNameDataMapper.java @@ -45,4 +45,11 @@ public interface QueryTableNameDataMapper extends BaseMapper * @param commonDto 通用数据传输 */ void commonUpdate(CommonDto commonDto); + + /** + * 通用删除服务 + * + * @param commonDto 通用数据传输 + */ + void commonDelete( CommonDto commonDto); } diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/TableNameDataService.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/TableNameDataService.java index 0ca8146..e517f25 100644 --- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/TableNameDataService.java +++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/TableNameDataService.java @@ -39,16 +39,28 @@ public interface TableNameDataService { String buildCol(String tableNameId) throws Exception; /** - * 基础数据通用保存 + * 基础数据通用存 * - * @param request 通用数据传输 + * @param request 请求数据 + * @param user 用户对象 + * @throws Exception 异常 */ void commonSave(HttpServletRequest request, SysUser user) throws Exception; /** * 基础数据通用修改 * - * @param request 通用数据传输 + * @param request 请求数据 + * @param user 用户对象 + * @throws Exception 异常 */ - void commonUpdate(HttpServletRequest request, SysUser user); + void commonUpdate(HttpServletRequest request, SysUser user) throws Exception; + + /** + * 基础数据通用删除 + * + * @param request 请求数据 + * @throws Exception 异常 + */ + void commonDelete(CommonDto commonDto) throws Exception; } diff --git a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/impl/TableNameDataServiceImpl.java b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/impl/TableNameDataServiceImpl.java index 71bfa39..ccec333 100644 --- a/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/impl/TableNameDataServiceImpl.java +++ b/sparchetype/src/main/java/com/songpeng/sparchetype/basedata/common/service/impl/TableNameDataServiceImpl.java @@ -83,9 +83,22 @@ public class TableNameDataServiceImpl implements TableNameDataService { } /** - * 基础数据通用保存 + * 基础数据通用删除 * - * @param request 通用数据传输 + * @param commonDto 通用数据传输 + * @throws Exception 异常 + */ + @Override + public void commonDelete(CommonDto commonDto) throws Exception { + queryTableNameDataMapper.commonDelete(commonDto); + } + + /** + * 基础数据通用新增 + * + * @param request 请求数据 + * @param user 用户对象 + * @throws Exception 异常 */ @Override public void commonSave(HttpServletRequest request, SysUser user) throws Exception { @@ -122,14 +135,33 @@ public class TableNameDataServiceImpl implements TableNameDataService { /** * 基础数据通用修改 * - * @param request 通用数据传输 + * @param request 请求数据 + * @param user 用户对象 + * @throws Exception 异常 */ @Override - public void commonUpdate(HttpServletRequest request, SysUser user) { + public void commonUpdate(HttpServletRequest request, SysUser user) throws Exception { //拿到列 - String col = ""; - //拿到对应的值 + CommonDto commonDto = new CommonDto(); + String jsTableName = request.getParameter("jsTableName"); + String id = request.getParameter("id"); + String jsTableNameId = request.getParameter("jsTableNameId"); //拼接修改的SQL语句 + //拿到对应的修改列和值 + StringBuilder valueBuilder = new StringBuilder(); + List spTableManagerItems = iSpTableManagerItemService.queryItemBytableNameId(jsTableNameId); + for (SpTableManagerItem spTableManagerItem : spTableManagerItems) { + String values = spTableManagerItem.getField() + "=" + "'" + request.getParameter(spTableManagerItem.getField()) + "',"; + valueBuilder.append(values); + } + String updateUsername = "update_username=" + "'" + user.getUsername() + "',"; + String updateTime = "update_time=" + "SYSDATE()"; + valueBuilder.append(updateUsername).append(updateTime); + commonDto.setTableName(jsTableName); + commonDto.setCol(valueBuilder.toString()); + commonDto.setId(id); //执行mapper + queryTableNameDataMapper.commonUpdate(commonDto); + } } diff --git a/sparchetype/src/main/resources/mapper/basedata/common/QueryTableNameDataMapper.xml b/sparchetype/src/main/resources/mapper/basedata/common/QueryTableNameDataMapper.xml index 7c8a2fb..76acb9c 100644 --- a/sparchetype/src/main/resources/mapper/basedata/common/QueryTableNameDataMapper.xml +++ b/sparchetype/src/main/resources/mapper/basedata/common/QueryTableNameDataMapper.xml @@ -15,12 +15,21 @@ - + insert into ${tableName} (${col}) VALUES (${values}) - - + UPDATE ${tableName} + SET ${col} + + id = #{id} + + + delete from ${tableName} + + id = #{id} + + diff --git a/sparchetype/src/main/resources/templates/basedata/manageritem/list.ftl b/sparchetype/src/main/resources/templates/basedata/manageritem/list.ftl index ae04570..24552c5 100644 --- a/sparchetype/src/main/resources/templates/basedata/manageritem/list.ftl +++ b/sparchetype/src/main/resources/templates/basedata/manageritem/list.ftl @@ -214,7 +214,7 @@ if (obj.event === 'delete') { layer.confirm('确认要删除吗?', function (index) { spUtil.ajax({ - url: '${request.contextPath}/basedata/common/delete/by/tableNameId', + url: '${request.contextPath}/basedata/common/delete', async: false, type: 'POST', // 是否显示 loading