|
@@ -1,17 +1,19 @@
|
|
|
package com.ruoyi.web.controller.dragForm;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.ruoyi.common.constant.ButtonTypeConstants;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.exception.tenantdatassource.TenantDataSource;
|
|
|
import com.ruoyi.system.entity.CommonEntity;
|
|
|
+import com.ruoyi.system.entity.DragForm;
|
|
|
import com.ruoyi.system.entity.TableSql;
|
|
|
-import com.ruoyi.system.service.ICommonService;
|
|
|
-import com.ruoyi.system.service.IDragTableGroupService;
|
|
|
-import com.ruoyi.system.service.IDragTableService;
|
|
|
-import com.ruoyi.system.service.ITableSqlService;
|
|
|
+import com.ruoyi.system.service.*;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/dragform/common")
|
|
@@ -29,6 +31,9 @@ public class CommonController extends BaseController {
|
|
|
@Resource
|
|
|
private IDragTableGroupService dragTableGroupService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IDragFormService dragFormService;
|
|
|
+
|
|
|
/**
|
|
|
* 共通查询
|
|
|
*/
|
|
@@ -97,4 +102,44 @@ public class CommonController extends BaseController {
|
|
|
startPage();
|
|
|
return getDataTable(commonService.dragTablePreview(commonEntity));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理按钮通用接口(新增、修改、删除)
|
|
|
+ */
|
|
|
+ @PostMapping("/commonBtnHandle")
|
|
|
+ public AjaxResult commonBtnHandle(@RequestBody CommonEntity commonEntity) throws JsonProcessingException {
|
|
|
+ //按钮类型
|
|
|
+ Long btnType = Long.valueOf(commonEntity.getBasicMap().get("btnType").toString());
|
|
|
+ //是否开启弹窗
|
|
|
+ String visible = commonEntity.getBasicMap().get("visible").toString();
|
|
|
+ /*
|
|
|
+ * 判断什么类型走什么接口:
|
|
|
+ * btnType 10:新增、8:修改、9:删除、5:脚本
|
|
|
+ * visible false代表弹窗未开启时走回显表单模板及数据信息接口;true代表弹窗开启时走保存数据接口
|
|
|
+ * */
|
|
|
+ if (btnType == ButtonTypeConstants.INSERT && visible.equals("true")) {
|
|
|
+ return toAjax(commonService.batchInsert(commonEntity));
|
|
|
+ } else if (btnType == ButtonTypeConstants.INSERT && visible.equals("false")) {
|
|
|
+ String sqlKey = commonEntity.getBasicMap().get("sqlKey").toString();
|
|
|
+ return success(dragFormService.selectDragFormBySqlKey(sqlKey));
|
|
|
+ } else if (btnType == ButtonTypeConstants.UPDATE && visible.equals("true")) {
|
|
|
+ return toAjax(commonService.edit(commonEntity));
|
|
|
+ } else if (btnType == ButtonTypeConstants.UPDATE && visible.equals("false")) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ //获取模板信息
|
|
|
+ String sqlKey = commonEntity.getBasicMap().get("sqlKey").toString();
|
|
|
+ DragForm dragForm = dragFormService.selectDragFormBySqlKey(sqlKey);
|
|
|
+ map.put("template",dragForm);
|
|
|
+ //返回结果
|
|
|
+ map.put("result",commonService.getInfoById(commonEntity));
|
|
|
+ return success(map);
|
|
|
+ } else if (btnType == ButtonTypeConstants.DELETE) {
|
|
|
+ return toAjax(commonService.batchDelete(commonEntity));
|
|
|
+ } else if(btnType == ButtonTypeConstants.SCRIPT) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return warn("暂不支持该操作!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|