package com.product.data.center.controller;
|
|
import com.product.admin.service.PublicService;
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.data.center.config.CmnConst;
|
import com.product.data.center.config.ErrorCode;
|
import com.product.data.center.service.SyncDelRecordService;
|
import com.product.data.center.service.ide.ICommonService;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
/**
|
* @Author cheng
|
* @Date 2022/7/21 13:23
|
* @Desc
|
*/
|
@RestController
|
@RequestMapping("/api")
|
public class CommonController extends AbstractBaseController {
|
|
|
@Resource
|
ICommonService dataCommonService;
|
|
@Resource
|
PublicService publicService;
|
@Resource
|
SyncDelRecordService syncDelRecordService;
|
|
|
|
@PostMapping("/mes-sync/save/{version}")
|
@ApiVersion(1)
|
public String saveMesSyncDataConfig(HttpServletRequest request) {
|
try {
|
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, "product_sys_data_sync_mes");
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
service.saveMesSyncDataConfig(fse);
|
|
return OK_List(publicService.getFieldSetEntity(fse, true));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_MES_SYNC_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 采集配置保存
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/collect/save/{version}")
|
@ApiVersion(1)
|
public String saveCollectConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
String uuid = service.saveCollectConfig(fse);
|
//创建触发器 2子库删除数据, 同步主库
|
// syncDelRecordService.createTrigger(fse);
|
return OK_Add(uuid);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 采集配置详情
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/collect/find/{version}")
|
@ApiVersion(1)
|
public String findCollectConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(dataCommonService.findCollectConfig(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 采集配置删除
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/collect/del/{version}")
|
@ApiVersion(1)
|
public String delCollectConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
service.delCollectConfig(fse);
|
//删除对应的触发器
|
syncDelRecordService.deleteTrigger(fse);
|
return OK();
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 提取配置保存
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/extract/save/{version}")
|
@ApiVersion(1)
|
public String saveExtractConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
return OK_Add(service.saveExtractConfig(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 提取配置查询
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/extract/find/{version}")
|
@ApiVersion(1)
|
public String findExtractConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(dataCommonService.findExtractConfig(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 提取配置删除
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/extract/del/{version}")
|
@ApiVersion(1)
|
public String delExtractConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
service.delExtractConfig(fse);
|
return OK();
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 归档配置保存
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/archiving/save/{version}")
|
@ApiVersion(1)
|
public String saveArchivingConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
return OK_Add(service.saveArchivingConfig(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 归档配置详情
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/archiving/find/{version}")
|
@ApiVersion(1)
|
public String findArchivingConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(dataCommonService.findArchivingConfig(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 归档配置删除
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/archiving/del/{version}")
|
@ApiVersion(1)
|
public String delArchivingConfig(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
service.delArchivingConfig(fse);
|
return OK();
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_COLLECT_CONFIG_FAIL);
|
}
|
}
|
|
/**
|
* 订单数据验证配置
|
*
|
* @param request
|
* @return
|
*/
|
@PostMapping("/order-data-verification/save/{version}")
|
@ApiVersion(1)
|
public String orderDataVerification(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_SYS_ORDER_DATA_VERIFICATION);
|
ICommonService service = (ICommonService) getProxyInstance(dataCommonService);
|
String uuid = service.saveOrderDataVerification(fse);
|
return OK_Add(uuid);
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.SAVE_ORDER_DATA_VERIFY_CONFIG_FAIL);
|
}
|
}
|
}
|