调整通用接口返回格式,避免两层

This commit is contained in:
hecan 2024-07-29 15:53:18 +08:00
parent 63b0a26a65
commit cf845501c0
2 changed files with 13 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package com.hzya.frame.sysnew.comparison.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.pagehelper.PageInfo;
import com.hzya.frame.basedao.service.IBaseService; import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity; import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
@ -17,7 +18,7 @@ public interface IComparisonService extends IBaseService<ComparisonEntity, Strin
* @Author hecan * @Author hecan
* @Date 2024/5/7 15:55 * @Date 2024/5/7 15:55
* **/ * **/
JsonResultEntity queryEntityPage(JSONObject jsonObject); Object queryEntityPage(JSONObject jsonObject);
/** /**
* *
@ -27,7 +28,7 @@ public interface IComparisonService extends IBaseService<ComparisonEntity, Strin
* @Author hecan * @Author hecan
* @Date 2024/5/7 16:52 * @Date 2024/5/7 16:52
* **/ * **/
JsonResultEntity saveEntity(JSONObject jsonObject); Object saveEntity(JSONObject jsonObject);
/** /**
* *
@ -37,7 +38,7 @@ public interface IComparisonService extends IBaseService<ComparisonEntity, Strin
* @Author hecan * @Author hecan
* @Date 2024/5/9 10:19 * @Date 2024/5/9 10:19
* **/ * **/
JsonResultEntity updateEntity(JSONObject jsonObject); Object updateEntity(JSONObject jsonObject);
/** /**
* *
@ -47,7 +48,7 @@ public interface IComparisonService extends IBaseService<ComparisonEntity, Strin
* @Author hecan * @Author hecan
* @Date 2024/5/9 13:59 * @Date 2024/5/9 13:59
* **/ * **/
JsonResultEntity deleteEntity(JSONObject jsonObject); Object deleteEntity(JSONObject jsonObject);
/** /**
* *

View File

@ -57,7 +57,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
//分页查询通用数据数据 //分页查询通用数据数据
@Override @Override
public JsonResultEntity queryEntityPage(JSONObject json) { public Object queryEntityPage(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
if (jsonObject == null) { if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据"); return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
@ -122,7 +122,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
} }
} }
PageInfo pageInfo = new PageInfo(list); PageInfo pageInfo = new PageInfo(list);
return BaseResult.getSuccessMessageEntity("查询成功", pageInfo); return pageInfo;
} catch (Exception e) { } catch (Exception e) {
logger.info("查询通用数据错误:{}", e.getMessage()); logger.info("查询通用数据错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("查询失败"); return BaseResult.getFailureMessageEntity("查询失败");
@ -133,7 +133,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
//新增通用数据数据 //新增通用数据数据
@Override @Override
public JsonResultEntity saveEntity(JSONObject json) { public Object saveEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
if (jsonObject == null) { if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据"); return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
@ -330,7 +330,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
list.add(jsonObjectList); list.add(jsonObjectList);
//保存操作日志 //保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","1"); controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),tableName+"_option_log","1");
return BaseResult.getSuccessMessageEntity("保存成功", list); return list;
} catch (Exception e) { } catch (Exception e) {
logger.info("保存通用数据时候错误:{}", e.getMessage()); logger.info("保存通用数据时候错误:{}", e.getMessage());
//保存操作日志 //保存操作日志
@ -345,7 +345,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
//更新通用数据数据 //更新通用数据数据
@Override @Override
public JsonResultEntity updateEntity(JSONObject json) { public Object updateEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
if (jsonObject == null) { if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据"); return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
@ -465,7 +465,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
jsonObjects.add(jsonObjectList); jsonObjects.add(jsonObjectList);
//保存操作日志 //保存操作日志
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log","1"); controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log","1");
return BaseResult.getSuccessMessageEntity("更新成功", jsonObjects); return jsonObjects;
}else{ }else{
return BaseResult.getFailureMessageEntity("更新失败"); return BaseResult.getFailureMessageEntity("更新失败");
} }
@ -487,7 +487,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
//删除通用数据 //删除通用数据
@Override @Override
public JsonResultEntity deleteEntity(JSONObject json) { public Object deleteEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
if (jsonObject == null) { if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据"); return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
@ -575,7 +575,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口删除",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log"); // controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口删除",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log");
} }
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口删除",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log","1"); controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口删除",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log","1");
return BaseResult.getSuccessMessageEntity("删除成功",integer); return integer;
}else{ }else{
return BaseResult.getFailureMessageEntity("删除失败","请查看data_id是否在表中存在"); return BaseResult.getFailureMessageEntity("删除失败","请查看data_id是否在表中存在");
} }