|
|
@@ -10,9 +10,10 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
|
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
|
|
import com.aliyuncs.profile.DefaultProfile;
|
|
|
import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
+import com.lc.ibps.api.form.sql.util.BeanUtils;
|
|
|
+import com.lc.ibps.base.core.util.Collections;
|
|
|
import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
|
-import com.lc.ibps.cloud.util.AESUtil;
|
|
|
import com.lc.ibps.components.querybuilder.utils.StringUtils;
|
|
|
import com.lc.ibps.config.JcjdConfig;
|
|
|
import com.lc.ibps.sysdata.entity.Smsconfig;
|
|
|
@@ -83,44 +84,36 @@ public class UpdateDataTableController {
|
|
|
@PostMapping("/batchDelete")
|
|
|
APIResult<Void> batchDelete(@RequestBody String data){
|
|
|
APIResult<Void> apiResult = new APIResult<>();
|
|
|
- /*鉴权,当前接口只允许pc端发送请求 */
|
|
|
-// if(data.isEmpty() || !updateDataTableService.sigVerify(data)){
|
|
|
-// apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
-// apiResult.setMessage("非法的签名,接口请求失败!");
|
|
|
-// return apiResult;
|
|
|
-// }
|
|
|
String tableName = "";
|
|
|
String paramWhere = "";
|
|
|
- Map map = JSONObject.parseObject(data);
|
|
|
- String ciphertext = (String)map.get("ciphertext");
|
|
|
try{
|
|
|
- String decrypt = AESUtil.decrypt(ciphertext);
|
|
|
+ String decrypt = updateDataTableService.checkParameters(data);
|
|
|
JSONObject sqlMap = JSONObject.parseObject(decrypt);
|
|
|
-
|
|
|
- tableName = sqlMap.getString("tableName");
|
|
|
- paramWhere = sqlMap.getString("paramWhere");
|
|
|
+ tableName = sqlMap.getString("tableName");
|
|
|
+ paramWhere = sqlMap.getString("paramWhere");
|
|
|
} catch (Exception e) {
|
|
|
+ log.warn("操作失败", e);
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("参数类型错误");
|
|
|
return apiResult;
|
|
|
}
|
|
|
-// if (StringUtils.isEmpty(tableName) && StringUtils.isEmpty(paramWhere)) {
|
|
|
-// apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
-// apiResult.setMessage("注意:所有参数均不能为空");
|
|
|
-// return apiResult;
|
|
|
-// }
|
|
|
- // 解决 不传where 条件的时候 报错 不传where的时候 删除所有数据
|
|
|
- if (StringUtils.isEmpty(tableName)) {
|
|
|
+ if (BeanUtils.isEmpty(tableName)) {
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("注意:tableName不能为空");
|
|
|
return apiResult;
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(paramWhere)){
|
|
|
+ if (BeanUtils.isEmpty(paramWhere)){
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("注意:ID不能为空");
|
|
|
return apiResult;
|
|
|
}else {
|
|
|
- updateDataTableService.batchDelete(tableName,paramWhere);
|
|
|
+ try{
|
|
|
+ updateDataTableService.batchDelete(tableName,paramWhere);
|
|
|
+ }catch (Exception e) {
|
|
|
+ apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
+ apiResult.setMessage("操作失败");
|
|
|
+ return apiResult;
|
|
|
+ }
|
|
|
}
|
|
|
return apiResult;
|
|
|
}
|
|
|
@@ -166,32 +159,22 @@ public class UpdateDataTableController {
|
|
|
@PostMapping("/updateDatasContextTable")
|
|
|
APIResult<Void> updatesDatasContextTable(@RequestBody String data) {
|
|
|
APIResult<Void> apiResult = new APIResult<>();
|
|
|
-
|
|
|
- /*鉴权,当前接口只允许pc端发送请求 */
|
|
|
-// if(data.isEmpty() || !updateDataTableService.sigVerify(data)){
|
|
|
-// apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
-// apiResult.setMessage("调用接口时,签名不合法!");
|
|
|
-// return apiResult;
|
|
|
-// }
|
|
|
-
|
|
|
- Map mapData = JSONObject.parseObject(data); /*转换成map*/
|
|
|
- String ciphertext =(String) mapData.get("ciphertext");
|
|
|
String tableName = null;
|
|
|
Map paramCond = null;
|
|
|
- List<Map<String, String>> paramWhere = null; /*条件 : 值*/
|
|
|
+ List<Map<String, String>> paramWhere = null;
|
|
|
try {
|
|
|
- String decrypt = AESUtil.decrypt(ciphertext);
|
|
|
+ String decrypt = updateDataTableService.checkParameters(data);
|
|
|
Map jsonMap = JSONObject.parseObject(decrypt);
|
|
|
tableName = (String) jsonMap.get("tableName");
|
|
|
paramCond = (Map) jsonMap.get("paramCond");
|
|
|
paramWhere = (List<Map<String, String>>) jsonMap.get("paramWhere");
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.warn("操作失败", e);
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("参数类型错误");
|
|
|
return apiResult;
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(tableName) && /*非空判断 表名*/ StringUtils.isEmpty(paramWhere) && /*条件*/ StringUtils.isEmpty(paramCond)) { /*参数*/
|
|
|
+ if (BeanUtils.isEmpty(tableName) || Collections.isEmpty(paramWhere) || BeanUtils.isEmpty(paramCond)) {
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("注意:所有参数均不能为空");
|
|
|
return apiResult;
|
|
|
@@ -208,31 +191,21 @@ public class UpdateDataTableController {
|
|
|
@PostMapping("/updatesBatchContextTable")
|
|
|
APIResult<Void> updatesBatchContextTable(@RequestBody String data) {
|
|
|
APIResult<Void> apiResult = new APIResult<>();
|
|
|
-
|
|
|
- /*鉴权,当前接口只允许pc端发送请求 */
|
|
|
-// if(data.isEmpty() || !updateDataTableService.sigVerify(data)){
|
|
|
-// apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
-// apiResult.setMessage("调用接口时,签名不合法!");
|
|
|
-// return apiResult;
|
|
|
-// }
|
|
|
-
|
|
|
- Map mapData = JSONObject.parseObject(data); /*转换成map*/
|
|
|
- String ciphertext =(String) mapData.get("ciphertext");
|
|
|
String tableName = null;
|
|
|
- List<Map<String,String>> updList = new ArrayList<>();
|
|
|
+ List<Map<String,String>> updList;
|
|
|
try {
|
|
|
- String decrypt = AESUtil.decrypt(ciphertext);
|
|
|
+ String decrypt = updateDataTableService.checkParameters(data);
|
|
|
Map jsonMap = JSONObject.parseObject(decrypt);
|
|
|
tableName = (String) jsonMap.get("tableName");
|
|
|
updList = (List<Map<String, String>>) jsonMap.get("updList");
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.warn("操作失败", e);
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("参数类型错误");
|
|
|
apiResult.setMessage(e.getMessage());
|
|
|
return apiResult;
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(tableName) && /*非空判断 表名*/ StringUtils.isEmpty(updList) ) { /*参数*/
|
|
|
+ if (BeanUtils.isEmpty(tableName) || Collections.isEmpty(updList) ) {
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
apiResult.setMessage("注意:所有参数均不能为空");
|
|
|
return apiResult;
|
|
|
@@ -391,31 +364,24 @@ public class UpdateDataTableController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation("添加接口")
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "tableName", value = "添加的表名", required = true), @ApiImplicitParam(name = "paramWhere", value = "添加的字段值[{}]", required = true),})
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "tableName", value = "添加的表名", required = true),
|
|
|
+ @ApiImplicitParam(name = "paramWhere", value = "添加的字段值[{}]", required = true)
|
|
|
+ })
|
|
|
@PostMapping("/addDataContextTable")
|
|
|
APIResult<Void> addDataContextTable(@RequestBody String data) {
|
|
|
APIResult<Void> apiResult = new APIResult<>();
|
|
|
-
|
|
|
- /*鉴权,当前接口只允许pc端发送请求 */
|
|
|
-// if(data.isEmpty() || !updateDataTableService.sigVerify(data)){
|
|
|
-// apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
-// apiResult.setMessage("非法的签名,接口请求失败!");
|
|
|
-// return apiResult;
|
|
|
-// }
|
|
|
- Map jsonMap = JSONObject.parseObject(data);/*转换成map*/
|
|
|
- String sql =(String) jsonMap.get("ciphertext");
|
|
|
String tableName = null;
|
|
|
String defKey = null;
|
|
|
- String formKey = null; /*表名*/
|
|
|
- String type = null; /*类型*/
|
|
|
- List<LinkedHashMap> paramWhere = null; /*条件 : 值*/
|
|
|
+ String formKey = null;
|
|
|
+ String type = null;
|
|
|
+ List<LinkedHashMap> paramWhere = null;
|
|
|
try {
|
|
|
- String decrypt = AESUtil.decrypt(sql);
|
|
|
- JSONObject map = JSONObject.parseObject(decrypt);/*转换成map*/
|
|
|
- tableName =(String) map.get("tableName");/*获取表名*/
|
|
|
- type = StringUtils.isEmpty(map.getString("type")) ? null:map.getString("type");/*获取类型*/
|
|
|
- String paramWhere1 = map.getString("paramWhere");/*获取参数数组*/
|
|
|
-
|
|
|
+ String decrypt = updateDataTableService.checkParameters(data);
|
|
|
+ JSONObject map = JSONObject.parseObject(decrypt);
|
|
|
+ tableName = map.getString("tableName");
|
|
|
+ type = StringUtils.isEmpty(map.getString("type")) ? null : map.getString("type");
|
|
|
+ String paramWhere1 = map.getString("paramWhere");
|
|
|
paramWhere = JSONObject.parseArray(paramWhere1, LinkedHashMap.class);
|
|
|
defKey = map.getString("defKey");
|
|
|
formKey = map.getString("formKey");
|
|
|
@@ -424,24 +390,33 @@ public class UpdateDataTableController {
|
|
|
apiResult.setMessage("参数类型错误");
|
|
|
return apiResult;
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(tableName) && /*非空判断 表名*/ StringUtils.isEmpty(paramWhere)) { /*条件*/
|
|
|
+ if (BeanUtils.isEmpty(tableName) || Collections.isEmpty(paramWhere)) {
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
- apiResult.setMessage("注意:所有参数均不能为空");
|
|
|
+ apiResult.setMessage("所有参数均不能为空");
|
|
|
return apiResult;
|
|
|
}
|
|
|
- List<LinkedHashMap> retrunData = null;
|
|
|
- if (null != defKey && null != formKey && type==null) {
|
|
|
- retrunData = updateDataTableService.addDataContextTable(tableName, paramWhere, defKey, formKey);/*查询*/
|
|
|
- }else if(null != defKey && null != formKey && type != null){
|
|
|
- retrunData = updateDataTableService.addDataContextTable(tableName, paramWhere, defKey, formKey,type);/*查询*/
|
|
|
- }
|
|
|
- else retrunData = updateDataTableService.addDataContextTable(tableName, paramWhere);/*查询*/
|
|
|
- if (null != retrunData) {
|
|
|
- apiResult.setState(StateEnum.SUCCESS.getCode());
|
|
|
- apiResult.addVariable("cont", retrunData);
|
|
|
- } else {
|
|
|
+ try {
|
|
|
+ List<LinkedHashMap> retrunData;
|
|
|
+ if (defKey != null && formKey != null) {
|
|
|
+ if (type != null) {
|
|
|
+ retrunData = updateDataTableService.addDataContextTable(tableName, paramWhere, defKey, formKey, type);
|
|
|
+ } else {
|
|
|
+ retrunData = updateDataTableService.addDataContextTable(tableName, paramWhere, defKey, formKey);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ retrunData = updateDataTableService.addDataContextTable(tableName, paramWhere);
|
|
|
+ }
|
|
|
+ if (retrunData != null) {
|
|
|
+ apiResult.setState(StateEnum.SUCCESS.getCode());
|
|
|
+ apiResult.addVariable("cont", retrunData);
|
|
|
+ } else {
|
|
|
+ apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
+ apiResult.setMessage("数据操作失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("添加数据异常", e);
|
|
|
apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
- apiResult.setMessage("数据开启错误!");
|
|
|
+ apiResult.setMessage("操作失败,请稍后重试");
|
|
|
}
|
|
|
return apiResult;
|
|
|
}
|