package com.product.patch.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.product.core.config.CoreConst;
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.entity.RequestParameterEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.patch.config.CmnConst;
|
import com.product.patch.config.ErrorCode;
|
import com.product.patch.service.PatchExtractService;
|
import com.product.util.BaseUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
/**
|
* Copyright © 6c
|
*
|
* @Date: 2022-04-02 17:08
|
* @Author: 6c
|
* @Description:
|
*/
|
@RestController
|
@RequestMapping("/api/patch/extract")
|
public class PatchExtractController extends AbstractBaseController {
|
@Autowired
|
private PatchExtractService patchExtractService;
|
|
/**
|
* 获取表、视图、索引信息
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/list-table-info/{version}")
|
@ApiVersion(1)
|
public String listTableInfo(HttpServletRequest request) {
|
try {
|
return BaseUtil.success(patchExtractService.listTableInfo(), null);
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(ErrorCode.EXTRACT_LIST_TABLE_INFO_FAIL);
|
}
|
}
|
|
/**
|
* 补丁抽取
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/execute/{version}")
|
@ApiVersion(1)
|
public String extract(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity rpe = (RequestParameterEntity) bean;
|
fse = rpe.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(ErrorCode.SYSTEM_FORM_COUNT.getValue(), ErrorCode.SYSTEM_FORM_COUNT.getText());
|
return error(ErrorCode.SYSTEM_FORM_COUNT);
|
}
|
patchExtractService.extract(fse);
|
return OK();
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(ErrorCode.EXTRACT_FAIL);
|
}
|
}
|
}
|