许鹏程
2024-11-05 2264630f3bc0483fd432cdd8e85e55abd3c4b10f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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);
        }
    }
}